[gimp/gtk3-port] app: port most menu items that want images to gimp_menu_item_set_image()



commit 92c6d8eb77b171b17b6f592ca0285bc32f5180d4
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 2 14:53:56 2018 +0200

    app: port most menu items that want images to gimp_menu_item_set_image()
    
    or remove the item setting completely.

 app/actions/edit-actions.c        |    9 ---------
 app/actions/file-actions.c        |    2 --
 app/actions/windows-actions.c     |    3 ---
 app/widgets/gimpaction.c          |   24 +++++++++++-------------
 app/widgets/gimpcoloreditor.c     |    2 ++
 app/widgets/gimpdockbook.c        |   11 ++---------
 app/widgets/gimpprocedureaction.c |    4 ++--
 app/widgets/gimpsettingsbox.c     |   13 ++-----------
 8 files changed, 19 insertions(+), 49 deletions(-)
---
diff --git a/app/actions/edit-actions.c b/app/actions/edit-actions.c
index d55b5f5..e6c9ef5 100644
--- a/app/actions/edit-actions.c
+++ b/app/actions/edit-actions.c
@@ -285,15 +285,6 @@ edit_actions_setup (GimpActionGroup *group)
 
   pattern = gimp_context_get_pattern (context);
   edit_actions_pattern_changed (context, pattern, group);
-
-#define SET_ALWAYS_SHOW_IMAGE(action,show) \
-        gimp_action_group_set_action_always_show_image (group, action, show)
-
-  SET_ALWAYS_SHOW_IMAGE ("edit-fill-fg",      TRUE);
-  SET_ALWAYS_SHOW_IMAGE ("edit-fill-bg",      TRUE);
-  SET_ALWAYS_SHOW_IMAGE ("edit-fill-pattern", TRUE);
-
-#undef SET_ALWAYS_SHOW_IMAGE
 }
 
 void
diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c
index eb49f04..9b9acc7 100644
--- a/app/actions/file-actions.c
+++ b/app/actions/file-actions.c
@@ -218,8 +218,6 @@ file_actions_setup (GimpActionGroup *group)
   for (i = 0; i < n_entries; i++)
     {
       gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
-      gimp_action_group_set_action_always_show_image (group, entries[i].name,
-                                                      TRUE);
       gimp_action_group_set_action_context (group, entries[i].name,
                                             gimp_get_user_context (group->gimp));
 
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index 80b52c6..2efb4af 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -354,9 +354,6 @@ windows_actions_image_notify (GimpDisplay      *display,
 
           gimp_action_group_add_actions (group, NULL, &entry, 1);
 
-          gimp_action_group_set_action_always_show_image (group, action_name,
-                                                          TRUE);
-
           action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                                 action_name);
 
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index 47161e7..aeafd4d 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -43,6 +43,7 @@
 #include "gimpaction-history.h"
 #include "gimpview.h"
 #include "gimpviewrenderer.h"
+#include "gimpwidgets-utils.h"
 
 
 enum
@@ -371,14 +372,14 @@ static void
 gimp_action_set_proxy (GimpAction *action,
                        GtkWidget  *proxy)
 {
-  if (! GTK_IS_IMAGE_MENU_ITEM (proxy))
+  if (! GTK_IS_MENU_ITEM (proxy))
     return;
 
   if (action->color)
     {
       GtkWidget *area;
 
-      area = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
+      area = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
 
       if (GIMP_IS_COLOR_AREA (area))
         {
@@ -398,9 +399,7 @@ gimp_action_set_proxy (GimpAction *action,
 
           gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
           gtk_widget_set_size_request (area, width, height);
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), area);
-          gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy),
-                                                     TRUE);
+          gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), area);
           gtk_widget_show (area);
         }
     }
@@ -408,7 +407,7 @@ gimp_action_set_proxy (GimpAction *action,
     {
       GtkWidget *view;
 
-      view = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
+      view = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
 
       if (GIMP_IS_VIEW (view) &&
           g_type_is_a (G_TYPE_FROM_INSTANCE (action->viewable),
@@ -437,9 +436,7 @@ gimp_action_set_proxy (GimpAction *action,
           view = gimp_view_new_full (action->context, action->viewable,
                                      width, height, border_width,
                                      FALSE, FALSE, FALSE);
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), view);
-          gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy),
-                                                     TRUE);
+          gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), view);
           gtk_widget_show (view);
         }
     }
@@ -447,13 +444,11 @@ gimp_action_set_proxy (GimpAction *action,
     {
       GtkWidget *image;
 
-      image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
+      image = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
 
       if (GIMP_IS_VIEW (image) || GIMP_IS_COLOR_AREA (image))
         {
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
-          gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy),
-                                                     FALSE);
+          gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), NULL);
           g_object_notify (G_OBJECT (action), "icon-name");
         }
     }
@@ -461,6 +456,9 @@ gimp_action_set_proxy (GimpAction *action,
   {
     GtkWidget *child = gtk_bin_get_child (GTK_BIN (proxy));
 
+    if (GTK_IS_BOX (child))
+      child = g_object_get_data (G_OBJECT (proxy), "gimp-menu-item-label");
+
     if (GTK_IS_LABEL (child))
       {
         GtkLabel *label = GTK_LABEL (child);
diff --git a/app/widgets/gimpcoloreditor.c b/app/widgets/gimpcoloreditor.c
index c3bd90d..035b976 100644
--- a/app/widgets/gimpcoloreditor.c
+++ b/app/widgets/gimpcoloreditor.c
@@ -218,6 +218,8 @@ gimp_color_editor_init (GimpColorEditor *editor)
       gtk_box_pack_start (GTK_BOX (editor->hbox), button, TRUE, TRUE, 0);
       gtk_widget_show (button);
 
+      g_printerr ("ICON NAME: %s\n", selector_class->icon_name);
+
       image = gtk_image_new_from_icon_name (selector_class->icon_name,
                                             GTK_ICON_SIZE_BUTTON);
       gtk_container_add (GTK_CONTAINER (button), image);
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 7447462..36926e5 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -50,6 +50,7 @@
 #include "gimpstringaction.h"
 #include "gimpuimanager.h"
 #include "gimpview.h"
+#include "gimpwidgets-utils.h"
 
 #include "gimp-log.h"
 #include "gimp-intl.h"
@@ -538,11 +539,7 @@ gimp_dockbook_show_menu (GimpDockbook *dockbook)
       {
         GtkWidget *image = gimp_dockable_get_icon (dockable,
                                                    GTK_ICON_SIZE_MENU);
-
-        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (parent_menu_widget),
-                                       image);
-        gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (parent_menu_widget),
-                                                   TRUE);
+        gimp_menu_item_set_image (GTK_MENU_ITEM (parent_menu_widget), image);
         gtk_widget_show (image);
       }
 
@@ -1645,8 +1642,6 @@ gimp_dockbook_tab_timeout (GimpDockbook *dockbook)
 {
   gint page_num;
 
-  GDK_THREADS_ENTER ();
-
   page_num = gtk_notebook_page_num (GTK_NOTEBOOK (dockbook),
                                     GTK_WIDGET (dockbook->p->tab_hover_dockable));
   gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), page_num);
@@ -1654,8 +1649,6 @@ gimp_dockbook_tab_timeout (GimpDockbook *dockbook)
   dockbook->p->tab_hover_timeout  = 0;
   dockbook->p->tab_hover_dockable = NULL;
 
-  GDK_THREADS_LEAVE ();
-
   return FALSE;
 }
 
diff --git a/app/widgets/gimpprocedureaction.c b/app/widgets/gimpprocedureaction.c
index ce20aaf..87789ba 100644
--- a/app/widgets/gimpprocedureaction.c
+++ b/app/widgets/gimpprocedureaction.c
@@ -177,7 +177,7 @@ gimp_procedure_action_connect_proxy (GtkAction *action,
 
   GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
 
-  if (GTK_IS_IMAGE_MENU_ITEM (proxy) && procedure_action->procedure)
+  if (GTK_IS_MENU_ITEM (proxy) && procedure_action->procedure)
     {
       GdkPixbuf *pixbuf;
 
@@ -205,7 +205,7 @@ gimp_procedure_action_connect_proxy (GtkAction *action,
             }
 
           image = gtk_image_new_from_pixbuf (pixbuf);
-          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
+          gimp_menu_item_set_image (GTK_MENU_ITEM (proxy), image);
           g_object_unref (pixbuf);
         }
     }
diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c
index a56e319..c5ff4a3 100644
--- a/app/widgets/gimpsettingsbox.c
+++ b/app/widgets/gimpsettingsbox.c
@@ -106,7 +106,6 @@ static void      gimp_settings_box_get_property  (GObject           *object,
 
 static GtkWidget *
                  gimp_settings_box_menu_item_add (GimpSettingsBox   *box,
-                                                  const gchar       *icon_name,
                                                   const gchar       *label,
                                                   GCallback          callback);
 static gboolean
@@ -355,20 +354,17 @@ gimp_settings_box_constructed (GObject *object)
 
   private->import_item =
     gimp_settings_box_menu_item_add (box,
-                                     GIMP_ICON_DOCUMENT_OPEN,
                                      _("_Import Current Settings from File..."),
                                      G_CALLBACK (gimp_settings_box_import_activate));
 
   private->export_item =
     gimp_settings_box_menu_item_add (box,
-                                     GIMP_ICON_DOCUMENT_SAVE,
                                      _("_Export Current Settings to File..."),
                                      G_CALLBACK (gimp_settings_box_export_activate));
 
-  gimp_settings_box_menu_item_add (box, NULL, NULL, NULL);
+  gimp_settings_box_menu_item_add (box, NULL, NULL);
 
   gimp_settings_box_menu_item_add (box,
-                                   GIMP_ICON_EDIT,
                                    _("_Manage Saved Presets..."),
                                    G_CALLBACK (gimp_settings_box_manage_activate));
 }
@@ -514,7 +510,6 @@ gimp_settings_box_get_property (GObject    *object,
 
 static GtkWidget *
 gimp_settings_box_menu_item_add (GimpSettingsBox *box,
-                                 const gchar     *icon_name,
                                  const gchar     *label,
                                  GCallback        callback)
 {
@@ -523,11 +518,7 @@ gimp_settings_box_menu_item_add (GimpSettingsBox *box,
 
   if (label)
     {
-      GtkWidget *image;
-
-      item = gtk_image_menu_item_new_with_mnemonic (label);
-      image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
-      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+      item = gtk_menu_item_new_with_mnemonic (label);
 
       g_signal_connect (item, "activate",
                         callback,


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