Commit 0a27fd37 authored by Martin Nordholts's avatar Martin Nordholts Committed by Martin Nordholts
Browse files

Keep track of the current image and manage a subscription to

2008-05-09  Martin Nordholts  <martinn@svn.gnome.org>

	* app/tools/gimpcroptool.[ch]: Keep track of the current image and
	manage a subscription to "size-changed" so that default aspect
	ratio is properly updated.
	(gimp_crop_tool_execute): No need to explicitly call
	gimp_crop_tool_update_option_defaults() any longer.

svn path=/trunk/; revision=25598
parent 168935ec
2008-05-09 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimpcroptool.[ch]: Keep track of the current image and
manage a subscription to "size-changed" so that default aspect
ratio is properly updated.
(gimp_crop_tool_execute): No need to explicitly call
gimp_crop_tool_update_option_defaults() any longer.
2008-05-09 Simon Budig <simon@gimp.org> 2008-05-09 Simon Budig <simon@gimp.org>
* app/core/gimpscanconvert.[ch]: expose the internal most * app/core/gimpscanconvert.[ch]: expose the internal most
......
...@@ -87,6 +87,7 @@ static void gimp_crop_tool_options_notify (GimpCropOptions ...@@ -87,6 +87,7 @@ static void gimp_crop_tool_options_notify (GimpCropOptions
static void gimp_crop_tool_image_changed (GimpCropTool *crop_tool, static void gimp_crop_tool_image_changed (GimpCropTool *crop_tool,
GimpImage *image, GimpImage *image,
GimpContext *context); GimpContext *context);
static void gimp_crop_tool_image_size_changed (GimpCropTool *crop_tool);
G_DEFINE_TYPE_WITH_CODE (GimpCropTool, gimp_crop_tool, GIMP_TYPE_DRAW_TOOL, G_DEFINE_TYPE_WITH_CODE (GimpCropTool, gimp_crop_tool, GIMP_TYPE_DRAW_TOOL,
...@@ -155,6 +156,8 @@ gimp_crop_tool_init (GimpCropTool *crop_tool) ...@@ -155,6 +156,8 @@ gimp_crop_tool_init (GimpCropTool *crop_tool)
gimp_tool_control_set_wants_click (tool->control, TRUE); gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP); gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
crop_tool->current_image = NULL;
} }
static GObject * static GObject *
...@@ -186,6 +189,13 @@ gimp_crop_tool_constructor (GType type, ...@@ -186,6 +189,13 @@ gimp_crop_tool_constructor (GType type,
crop_tool, crop_tool,
G_CONNECT_SWAPPED); G_CONNECT_SWAPPED);
/* Make sure we are connected to "size-changed" for the initial
* image.
*/
gimp_crop_tool_image_changed (crop_tool,
gimp_context_get_image (gimp_context),
gimp_context);
options = GIMP_CROP_TOOL_GET_OPTIONS (object); options = GIMP_CROP_TOOL_GET_OPTIONS (object);
...@@ -303,9 +313,6 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle, ...@@ -303,9 +313,6 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gimp_image_flush (image); gimp_image_flush (image);
gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (tool),
TRUE);
return TRUE; return TRUE;
} }
...@@ -398,6 +405,30 @@ gimp_crop_tool_image_changed (GimpCropTool *crop_tool, ...@@ -398,6 +405,30 @@ gimp_crop_tool_image_changed (GimpCropTool *crop_tool,
GimpImage *image, GimpImage *image,
GimpContext *context) GimpContext *context)
{ {
if (crop_tool->current_image)
{
g_signal_handlers_disconnect_by_func (crop_tool->current_image,
gimp_crop_tool_image_size_changed,
NULL);
}
if (image)
{
g_signal_connect_object (image, "size-changed",
G_CALLBACK (gimp_crop_tool_image_size_changed),
crop_tool,
G_CONNECT_SWAPPED);
}
crop_tool->current_image = image;
gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (crop_tool), gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (crop_tool),
FALSE); FALSE);
} }
static void
gimp_crop_tool_image_size_changed (GimpCropTool *crop_tool)
{
gimp_crop_tool_update_option_defaults (crop_tool,
FALSE);
}
...@@ -39,6 +39,8 @@ typedef struct _GimpCropToolClass GimpCropToolClass; ...@@ -39,6 +39,8 @@ typedef struct _GimpCropToolClass GimpCropToolClass;
struct _GimpCropTool struct _GimpCropTool
{ {
GimpDrawTool parent_instance; GimpDrawTool parent_instance;
GimpImage *current_image;
}; };
struct _GimpCropToolClass struct _GimpCropToolClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment