[gimp/gimp-2-10] app: update tool-group active tool in response to tool changes
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: update tool-group active tool in response to tool changes
- Date: Thu, 30 Jan 2020 00:56:06 +0000 (UTC)
commit d1cf7de23f7f18e0c63e1bfbe240d4dd890a9db1
Author: Ell <ell_se yahoo com>
Date: Wed Jan 29 20:45:11 2020 +0200
app: update tool-group active tool in response to tool changes
In the tool manager, update the active tool of a GimpToolGroup when
one of its tools becomes active (or when the active tool is added
to the group).
app/tools/tool_manager.c | 76 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 57 insertions(+), 19 deletions(-)
---
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 1a1b4e423b..338a09bb3f 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -30,6 +30,7 @@
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimpimage.h"
+#include "core/gimptoolgroup.h"
#include "core/gimptoolinfo.h"
#include "core/gimptooloptions.h"
#include "core/gimptoolpreset.h"
@@ -58,24 +59,26 @@ struct _GimpToolManager
/* local function prototypes */
-static GimpToolManager * tool_manager_get (Gimp *gimp);
-static void tool_manager_set (Gimp *gimp,
- GimpToolManager *tool_manager);
-static void tool_manager_select_tool (Gimp *gimp,
- GimpTool *tool);
-static void tool_manager_tool_changed (GimpContext *user_context,
- GimpToolInfo *tool_info,
- GimpToolManager *tool_manager);
-static void tool_manager_preset_changed (GimpContext *user_context,
- GimpToolPreset *preset,
- GimpToolManager *tool_manager);
-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);
+static GimpToolManager * tool_manager_get (Gimp *gimp);
+static void tool_manager_set (Gimp *gimp,
+ GimpToolManager *tool_manager);
+static void tool_manager_select_tool (Gimp *gimp,
+ GimpTool *tool);
+static void tool_manager_tool_changed (GimpContext *user_context,
+ GimpToolInfo *tool_info,
+ GimpToolManager *tool_manager);
+static void tool_manager_preset_changed (GimpContext *user_context,
+ GimpToolPreset *preset,
+ GimpToolManager *tool_manager);
+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_tool_ancestry_changed (GimpToolInfo *tool_info,
+ GimpToolManager *tool_manager);
+
+static void tool_manager_cast_spell (GimpToolInfo *tool_info);
/* public functions */
@@ -154,7 +157,15 @@ tool_manager_exit (Gimp *gimp)
gimp_container_remove_handler (gimp->images,
tool_manager->image_saving_handler_id);
- g_clear_object (&tool_manager->active_tool);
+ if (tool_manager->active_tool)
+ {
+ g_signal_handlers_disconnect_by_func (
+ tool_manager->active_tool->tool_info,
+ tool_manager_tool_ancestry_changed,
+ tool_manager);
+
+ g_clear_object (&tool_manager->active_tool);
+ }
g_slice_free (GimpToolManager, tool_manager);
}
@@ -683,6 +694,8 @@ tool_manager_tool_changed (GimpContext *user_context,
return;
}
+ g_return_if_fail (tool_manager->tool_stack == NULL);
+
if (tool_manager->active_tool)
{
GimpTool *active_tool = tool_manager->active_tool;
@@ -698,8 +711,18 @@ tool_manager_tool_changed (GimpContext *user_context,
if (display)
tool_manager_control_active (user_context->gimp, GIMP_TOOL_ACTION_COMMIT,
display);
+
+ g_signal_handlers_disconnect_by_func (active_tool->tool_info,
+ tool_manager_tool_ancestry_changed,
+ tool_manager);
}
+ g_signal_connect (tool_info, "ancestry-changed",
+ G_CALLBACK (tool_manager_tool_ancestry_changed),
+ tool_manager);
+
+ tool_manager_tool_ancestry_changed (tool_info, tool_manager);
+
new_tool = g_object_new (tool_info->tool_type,
"tool-info", tool_info,
NULL);
@@ -823,6 +846,21 @@ tool_manager_image_saving (GimpImage *image,
}
}
+static void
+tool_manager_tool_ancestry_changed (GimpToolInfo *tool_info,
+ GimpToolManager *tool_manager)
+{
+ GimpViewable *parent;
+
+ parent = gimp_viewable_get_parent (GIMP_VIEWABLE (tool_info));
+
+ if (parent)
+ {
+ gimp_tool_group_set_active_tool_info (GIMP_TOOL_GROUP (parent),
+ tool_info);
+ }
+}
+
static void
tool_manager_cast_spell (GimpToolInfo *tool_info)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]