[gimp] app: Show custom preset icons in the tool options menus



commit d5a316253dfd4c7441990fe1cd4b89e388b1071a
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Thu Jan 7 18:55:52 2016 -0800

    app: Show custom preset icons in the tool options menus

 app/actions/tool-options-actions.c |    6 ++++++
 app/widgets/gimpactiongroup.c      |   24 ++++++++++++++++++++++++
 app/widgets/gimpactiongroup.h      |    3 +++
 3 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/app/actions/tool-options-actions.c b/app/actions/tool-options-actions.c
index a463746..69a653b 100644
--- a/app/actions/tool-options-actions.c
+++ b/app/actions/tool-options-actions.c
@@ -206,12 +206,15 @@ tool_options_actions_update_presets (GimpActionGroup *group,
            list = g_list_next (list), i++)
         {
           GimpObject *preset = list->data;
+          GdkPixbuf  *pixbuf = NULL;
 
           entry.name      = g_strdup_printf ("%s-%03d", action_prefix, i);
           entry.label     = gimp_object_get_name (preset);
           entry.icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (preset));
           entry.value     = i;
 
+          g_object_get (preset, "icon-pixbuf", &pixbuf, NULL);
+
           gimp_action_group_add_enum_actions (group, NULL, &entry, 1, callback);
 
           if (need_writable)
@@ -222,6 +225,9 @@ tool_options_actions_update_presets (GimpActionGroup *group,
             SET_SENSITIVE (entry.name,
                            gimp_data_is_deletable (GIMP_DATA (preset)));
 
+          if (pixbuf)
+            gimp_action_group_set_action_pixbuf (group, entry.name, pixbuf);
+
           g_free ((gchar *) entry.name);
         }
     }
diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c
index f391e93..d7b9edb 100644
--- a/app/widgets/gimpactiongroup.c
+++ b/app/widgets/gimpactiongroup.c
@@ -800,6 +800,30 @@ gimp_action_group_set_action_label (GimpActionGroup *group,
 }
 
 void
+gimp_action_group_set_action_pixbuf (GimpActionGroup *group,
+                                     const gchar     *action_name,
+                                     GdkPixbuf       *pixbuf)
+{
+  GtkAction *action;
+
+  g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
+  g_return_if_fail (action_name != NULL);
+
+  action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
+
+  if (! action)
+    {
+      g_warning ("%s: Unable to set pixbuf of action "
+                 "which doesn't exist: %s",
+                 G_STRFUNC, action_name);
+      return;
+    }
+
+  gtk_action_set_gicon (action, G_ICON (pixbuf));
+}
+
+
+void
 gimp_action_group_set_action_tooltip (GimpActionGroup     *group,
                                       const gchar         *action_name,
                                       const gchar         *tooltip)
diff --git a/app/widgets/gimpactiongroup.h b/app/widgets/gimpactiongroup.h
index d187316..5cb34b9 100644
--- a/app/widgets/gimpactiongroup.h
+++ b/app/widgets/gimpactiongroup.h
@@ -189,6 +189,9 @@ void          gimp_action_group_set_action_active     (GimpActionGroup *group,
 void          gimp_action_group_set_action_label      (GimpActionGroup *group,
                                                        const gchar     *action_name,
                                                        const gchar     *label);
+void          gimp_action_group_set_action_pixbuf     (GimpActionGroup *group,
+                                                       const gchar     *action_name,
+                                                       GdkPixbuf       *pixbuf);
 void          gimp_action_group_set_action_tooltip    (GimpActionGroup *group,
                                                        const gchar     *action_name,
                                                        const gchar     *tooltip);


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