[gimp] app: make sure the labels of our GtkImageMenuItem replacements get updated



commit 75acae40e34ed78cc47d06703840acf9616ff12d
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 5 16:17:50 2019 +0200

    app: make sure the labels of our GtkImageMenuItem replacements get updated
    
    In GimpAction, connect to the action's "notify::label" and update the
    label inside the image-plus-label hbox we use to replace the
    deprecated GtkImageMenuItem.

 app/widgets/gimpaction.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index 969c68d8f4..b3af253b01 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -74,6 +74,9 @@ static void   gimp_action_set_proxy         (GimpAction       *action,
                                              GtkWidget        *proxy);
 static void   gimp_action_set_proxy_tooltip (GimpAction       *action,
                                              GtkWidget        *proxy);
+static void   gimp_action_label_notify      (GimpAction       *action,
+                                             const GParamSpec *pspec,
+                                             gpointer          data);
 static void   gimp_action_tooltip_notify    (GimpAction       *action,
                                              const GParamSpec *pspec,
                                              gpointer          data);
@@ -140,6 +143,9 @@ gimp_action_init (GimpAction *action)
   action->ellipsize       = PANGO_ELLIPSIZE_NONE;
   action->max_width_chars = -1;
 
+  g_signal_connect (action, "notify::label",
+                    G_CALLBACK (gimp_action_label_notify),
+                    NULL);
   g_signal_connect (action, "notify::tooltip",
                     G_CALLBACK (gimp_action_tooltip_notify),
                     NULL);
@@ -480,6 +486,34 @@ gimp_action_set_proxy_tooltip (GimpAction *action,
                                                  GIMP_HELP_ID));
 }
 
+static void
+gimp_action_label_notify (GimpAction       *action,
+                          const GParamSpec *pspec,
+                          gpointer          data)
+{
+  GSList *list;
+
+  for (list = gtk_action_get_proxies (GTK_ACTION (action));
+       list;
+       list = g_slist_next (list))
+    {
+      if (GTK_IS_MENU_ITEM (list->data))
+        {
+          GtkWidget *child = gtk_bin_get_child (GTK_BIN (list->data));
+
+          if (GTK_IS_BOX (child))
+            {
+              child = g_object_get_data (G_OBJECT (list->data),
+                                         "gimp-menu-item-label");
+
+              if (GTK_IS_LABEL (child))
+                gtk_label_set_text (GTK_LABEL (child),
+                                    gtk_action_get_label (GTK_ACTION (action)));
+            }
+        }
+    }
+}
+
 static void
 gimp_action_tooltip_notify (GimpAction       *action,
                             const GParamSpec *pspec,


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