Commit ae628a86 authored by Ell's avatar Ell

Issue #2222 - Warp Transform doesn't commit changes upon saving ...

... the XCF file

Add a "saving" signal to GimpImage, which is emitted when the image
is about to be saved or exported (but before it's actually saved/
exported).  Connect to this signal in tool-manager, and commit the
current tool in response (unless its GimpToolControl::preserve is
TRUE).
parent fca05065
......@@ -111,6 +111,7 @@ enum
SELECTION_INVALIDATE,
CLEAN,
DIRTY,
SAVING,
SAVED,
EXPORTED,
GUIDE_ADDED,
......@@ -431,6 +432,15 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_DIRTY_MASK);
gimp_image_signals[SAVING] =
g_signal_new ("saving",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, saving),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[SAVED] =
g_signal_new ("saved",
G_TYPE_FROM_CLASS (klass),
......@@ -588,6 +598,7 @@ gimp_image_class_init (GimpImageClass *klass)
klass->clean = NULL;
klass->dirty = NULL;
klass->saving = NULL;
klass->saved = NULL;
klass->exported = NULL;
klass->guide_added = NULL;
......@@ -3413,6 +3424,21 @@ gimp_image_get_dirty_time (GimpImage *image)
return GIMP_IMAGE_GET_PRIVATE (image)->dirty_time;
}
/**
* gimp_image_saving:
* @image:
*
* Emits the "saving" signal, indicating that @image is about to be saved,
* or exported.
*/
void
gimp_image_saving (GimpImage *image)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
g_signal_emit (image, gimp_image_signals[SAVING], 0);
}
/**
* gimp_image_saved:
* @image:
......
......@@ -76,6 +76,7 @@ struct _GimpImageClass
GimpDirtyMask dirty_mask);
void (* dirty) (GimpImage *image,
GimpDirtyMask dirty_mask);
void (* saving) (GimpImage *image);
void (* saved) (GimpImage *image,
GFile *file);
void (* exported) (GimpImage *image,
......@@ -169,6 +170,7 @@ GimpPlugInProcedure * gimp_image_get_load_proc (GimpImage *image);
void gimp_image_set_save_proc (GimpImage *image,
GimpPlugInProcedure *proc);
GimpPlugInProcedure * gimp_image_get_save_proc (GimpImage *image);
void gimp_image_saving (GimpImage *image);
void gimp_image_saved (GimpImage *image,
GFile *file);
void gimp_image_set_export_proc (GimpImage *image,
......
......@@ -89,6 +89,8 @@ file_save (Gimp *gimp,
g_object_ref (image);
g_object_ref (file);
gimp_image_saving (image);
drawable = gimp_image_get_active_drawable (image);
if (! drawable)
......
......@@ -54,6 +54,7 @@ struct _GimpToolManager
GQuark image_clean_handler_id;
GQuark image_dirty_handler_id;
GQuark image_saving_handler_id;
};
......@@ -72,6 +73,8 @@ static void tool_manager_preset_changed (GimpContext *user_context,
static void tool_manager_image_clean_dirty (GimpImage *image,
GimpDirtyMask dirty_mask,
GimpToolManager *tool_manager);
static void tool_manager_image_saving (GimpImage *image,
GimpToolManager *tool_manager);
static void tool_manager_cast_spell (GimpToolInfo *tool_info);
......@@ -106,6 +109,11 @@ tool_manager_init (Gimp *gimp)
G_CALLBACK (tool_manager_image_clean_dirty),
tool_manager);
tool_manager->image_saving_handler_id =
gimp_container_add_handler (gimp->images, "saving",
G_CALLBACK (tool_manager_image_saving),
tool_manager);
user_context = gimp_get_user_context (gimp);
g_signal_connect (user_context, "tool-changed",
......@@ -145,6 +153,8 @@ tool_manager_exit (Gimp *gimp)
tool_manager->image_clean_handler_id);
gimp_container_remove_handler (gimp->images,
tool_manager->image_dirty_handler_id);
gimp_container_remove_handler (gimp->images,
tool_manager->image_saving_handler_id);
g_clear_object (&tool_manager->active_tool);
......@@ -771,6 +781,23 @@ tool_manager_image_clean_dirty (GimpImage *image,
}
}
static void
tool_manager_image_saving (GimpImage *image,
GimpToolManager *tool_manager)
{
GimpTool *tool = tool_manager->active_tool;
if (tool &&
! gimp_tool_control_get_preserve (tool->control))
{
GimpDisplay *display = gimp_tool_has_image (tool, image);
if (display)
tool_manager_control_active (image->gimp, GIMP_TOOL_ACTION_COMMIT,
display);
}
}
static void
tool_manager_cast_spell (GimpToolInfo *tool_info)
{
......
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