[gimp] Issue #2222 - Warp Transform doesn't commit changes upon saving ...
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #2222 - Warp Transform doesn't commit changes upon saving ...
- Date: Sat, 29 Sep 2018 06:41:20 +0000 (UTC)
commit ae628a86640cfc8c2bc0e420c23518c03b65361b
Author: Ell <ell_se yahoo com>
Date: Sat Sep 29 02:25:34 2018 -0400
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).
app/core/gimpimage.c | 26 ++++++++++++++++++++++++++
app/core/gimpimage.h | 2 ++
app/file/file-save.c | 2 ++
app/tools/tool_manager.c | 27 +++++++++++++++++++++++++++
4 files changed, 57 insertions(+)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 343f1f6a6f..566f0159d7 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -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:
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index fd404404d7..da851e6d84 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -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,
diff --git a/app/file/file-save.c b/app/file/file-save.c
index 334455f43b..252d62a280 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -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)
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index c74652d2ab..0921a35fc7 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]