[gimp] app: add gimp_tool_set/get_undo_desc/icon_name/help_id()



commit 8e68743efa2546e8f256a4267ab18f783a4ae026
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jul 4 20:40:23 2017 +0200

    app: add gimp_tool_set/get_undo_desc/icon_name/help_id()
    
    which allow to override stuff from GimpToolInfo for dynamic tools like
    GimpFilterTool and friends. When NULL, the getters are falling back to
    GimpToolInfo strings.

 app/tools/gimptool.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/tools/gimptool.h |   16 ++++++++++
 2 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c
index f765607..9ba1b51 100644
--- a/app/tools/gimptool.c
+++ b/app/tools/gimptool.c
@@ -234,6 +234,24 @@ gimp_tool_finalize (GObject *object)
       tool->tool_info = NULL;
     }
 
+  if (tool->undo_desc)
+    {
+      g_free (tool->undo_desc);
+      tool->undo_desc = NULL;
+    }
+
+  if (tool->icon_name)
+    {
+      g_free (tool->icon_name);
+      tool->icon_name = NULL;
+    }
+
+  if (tool->help_id)
+    {
+      g_free (tool->help_id);
+      tool->help_id = NULL;
+    }
+
   if (tool->control)
     {
       g_object_unref (tool->control);
@@ -492,6 +510,69 @@ gimp_tool_get_options (GimpTool *tool)
   return tool->tool_info->tool_options;
 }
 
+void
+gimp_tool_set_undo_desc (GimpTool    *tool,
+                         const gchar *undo_desc)
+{
+  g_return_if_fail (GIMP_IS_TOOL (tool));
+
+  g_free (tool->undo_desc);
+  tool->undo_desc = g_strdup (undo_desc);
+}
+
+const gchar *
+gimp_tool_get_undo_desc (GimpTool *tool)
+{
+  g_return_val_if_fail (GIMP_IS_TOOL (tool), NULL);
+
+  if (tool->undo_desc)
+    return tool->undo_desc;
+
+  return tool->tool_info->blurb;
+}
+
+void
+gimp_tool_set_icon_name (GimpTool    *tool,
+                         const gchar *icon_name)
+{
+  g_return_if_fail (GIMP_IS_TOOL (tool));
+
+  g_free (tool->icon_name);
+  tool->icon_name = g_strdup (icon_name);
+}
+
+const gchar *
+gimp_tool_get_icon_name (GimpTool *tool)
+{
+  g_return_val_if_fail (GIMP_IS_TOOL (tool), NULL);
+
+  if (tool->icon_name)
+    return tool->icon_name;
+
+  return gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool->tool_info));
+}
+
+void
+gimp_tool_set_help_id (GimpTool    *tool,
+                       const gchar *help_id)
+{
+  g_return_if_fail (GIMP_IS_TOOL (tool));
+
+  g_free (tool->help_id);
+  tool->help_id = g_strdup (help_id);
+}
+
+const gchar *
+gimp_tool_get_help_id (GimpTool *tool)
+{
+  g_return_val_if_fail (GIMP_IS_TOOL (tool), NULL);
+
+  if (tool->help_id)
+    return tool->help_id;
+
+  return tool->tool_info->help_id;
+}
+
 gboolean
 gimp_tool_has_display (GimpTool    *tool,
                        GimpDisplay *display)
diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h
index 237c0a7..92e1fa9 100644
--- a/app/tools/gimptool.h
+++ b/app/tools/gimptool.h
@@ -40,6 +40,10 @@ struct _GimpTool
 
   GimpToolInfo    *tool_info;
 
+  gchar           *undo_desc;
+  gchar           *icon_name;
+  gchar           *help_id;
+
   gint             ID;          /*  unique tool ID                         */
 
   GimpToolControl *control;
@@ -160,6 +164,18 @@ GType             gimp_tool_get_type            (void) G_GNUC_CONST;
 
 GimpToolOptions * gimp_tool_get_options         (GimpTool            *tool);
 
+void              gimp_tool_set_undo_desc       (GimpTool            *tool,
+                                                 const gchar         *undo_desc);
+const gchar     * gimp_tool_get_undo_desc       (GimpTool            *tool);
+
+void              gimp_tool_set_icon_name       (GimpTool            *tool,
+                                                 const gchar         *icon_name);
+const gchar     * gimp_tool_get_icon_name       (GimpTool            *tool);
+
+void              gimp_tool_set_help_id         (GimpTool            *tool,
+                                                 const gchar         *help_id);
+const gchar     * gimp_tool_get_help_id         (GimpTool            *tool);
+
 gboolean          gimp_tool_has_display         (GimpTool            *tool,
                                                  GimpDisplay         *display);
 GimpDisplay     * gimp_tool_has_image           (GimpTool            *tool,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]