Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/tools/gimprectangletool.c: handle fixed_width,
	fixed_height, and fixed_aspect in a reasonable way.
	Also don't crash when user modifies aspect of a
	nonexistent rectangle, and disconnect notify
	handler in dispose.
This commit is contained in:
William Skaggs 2005-11-29 23:32:55 +00:00
parent fbf0871fa7
commit 72a3574bba
2 changed files with 48 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2005-11-28 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimprectangletool.c: handle fixed_width,
fixed_height, and fixed_aspect in a reasonable way.
Also don't crash when user modifies aspect of a
nonexistent rectangle, and disconnect notify
handler in dispose.
2005-11-30 Michael Natterer <mitch@gimp.org> 2005-11-30 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpeditor.c (gimp_editor_add_button) * app/widgets/gimpeditor.c (gimp_editor_add_button)

View File

@ -1240,6 +1240,9 @@ gimp_rectangle_tool_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (options, g_signal_handlers_disconnect_by_func (options,
G_CALLBACK (gimp_rectangle_tool_notify_height), G_CALLBACK (gimp_rectangle_tool_notify_height),
rectangle); rectangle);
g_signal_handlers_disconnect_by_func (options,
G_CALLBACK (gimp_rectangle_tool_notify_aspect),
rectangle);
} }
gboolean gboolean
@ -1290,8 +1293,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool); GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool)); g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
@ -1662,6 +1665,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break; break;
case RECT_RESIZING_UPPER_RIGHT: case RECT_RESIZING_UPPER_RIGHT:
case RECT_RESIZING_TOP:
if (inc_x == 0 || inc_y / inc_x > aspect) if (inc_x == 0 || inc_y / inc_x > aspect)
x2 = rx1 + (ry2 - y1) / aspect + .5; x2 = rx1 + (ry2 - y1) / aspect + .5;
else else
@ -1669,6 +1673,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break; break;
case RECT_RESIZING_LOWER_LEFT: case RECT_RESIZING_LOWER_LEFT:
case RECT_RESIZING_LEFT:
if (inc_x == 0 || inc_y / inc_x > aspect) if (inc_x == 0 || inc_y / inc_x > aspect)
x1 = rx2 - (y2 - ry1) / aspect + .5; x1 = rx2 - (y2 - ry1) / aspect + .5;
else else
@ -1676,6 +1681,8 @@ gimp_rectangle_tool_motion (GimpTool *tool,
break; break;
case RECT_RESIZING_LOWER_RIGHT: case RECT_RESIZING_LOWER_RIGHT:
case RECT_RESIZING_RIGHT:
case RECT_RESIZING_BOTTOM:
if (inc_x == 0 || inc_y / inc_x > aspect) if (inc_x == 0 || inc_y / inc_x > aspect)
x2 = rx1 + (y2 - ry1) / aspect + .5; x2 = rx1 + (y2 - ry1) / aspect + .5;
else else
@ -2485,18 +2492,26 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
GimpSizeEntry *entry; GimpSizeEntry *entry;
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
GimpRectangleOptions *options; GimpRectangleOptions *options;
gboolean fixed_width;
gboolean fixed_height;
gboolean fixed_aspect;
shell = GIMP_DISPLAY_SHELL (gdisp->shell); shell = GIMP_DISPLAY_SHELL (gdisp->shell);
g_object_get (rectangle, g_object_get (rectangle,
"dimensions-entry", &entry, "dimensions-entry", &entry,
"x1", &x1, "x1", &x1,
"y1", &y1, "y1", &y1,
"x2", &x2, "x2", &x2,
"y2", &y2, "y2", &y2,
NULL); NULL);
options = GIMP_RECTANGLE_OPTIONS (GIMP_TOOL (rectangle)->tool_info->tool_options); options = GIMP_RECTANGLE_OPTIONS (GIMP_TOOL (rectangle)->tool_info->tool_options);
g_object_get (options,
"new-fixed-width", &fixed_width,
"new-fixed-height", &fixed_height,
"fixed-aspect", &fixed_aspect,
NULL);
width = x2 - x1; width = x2 - x1;
height = y2 - y1; height = y2 - y1;
@ -2528,11 +2543,20 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
gimp_rectangle_tool_notify_aspect, gimp_rectangle_tool_notify_aspect,
rectangle); rectangle);
g_object_set (options, if (! fixed_width)
"width", width, g_object_set (options,
"height", height, "width", width,
"aspect", aspect, NULL);
NULL);
if (! fixed_height)
g_object_set (options,
"height", height,
NULL);
if (! fixed_aspect)
g_object_set (options,
"aspect", aspect,
NULL);
g_signal_handlers_unblock_by_func (options, g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_notify_width, gimp_rectangle_tool_notify_width,
@ -2702,6 +2726,9 @@ gimp_rectangle_tool_notify_aspect (GimpRectangleOptions *options,
GimpCoords coords; GimpCoords coords;
gdouble aspect = gimp_rectangle_options_get_aspect (options); gdouble aspect = gimp_rectangle_options_get_aspect (options);
if (! GIMP_TOOL (rectangle)->gdisp)
return;
g_object_get (rectangle, g_object_get (rectangle,
"x1", &rx1, "x1", &rx1,
"y1", &ry1, "y1", &ry1,