← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/appmenu-gtk/action-notify into lp:appmenu-gtk

 

Cody Russell has proposed merging lp:~bratsche/appmenu-gtk/action-notify into lp:appmenu-gtk.

Requested reviews:
  Canonical Desktop Experience Team (canonical-dx-team)
Related bugs:
  #588474 Seahorse View menu not updated as items are checked or unchecked
  https://bugs.launchpad.net/bugs/588474

-- 
https://code.launchpad.net/~bratsche/appmenu-gtk/action-notify/+merge/29047
Your team ayatana-commits is subscribed to branch lp:appmenu-gtk.
=== modified file 'src/bridge.c'
--- src/bridge.c	2010-06-29 16:08:41 +0000
+++ src/bridge.c	2010-07-02 02:59:22 +0000
@@ -447,6 +447,27 @@
   dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget));
 }
 
+static void
+action_notify_cb (GtkAction  *action,
+                  GParamSpec *pspec,
+                  gpointer    data)
+{
+  DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data;
+
+  if (pspec->name == g_intern_static_string ("active"))
+    {
+      dbusmenu_menuitem_property_set_bool (mi,
+                                           DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
+                                           gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+    }
+  else if (pspec->name == g_intern_static_string ("label"))
+    {
+      dbusmenu_menuitem_property_set (mi,
+                                      DBUSMENU_MENUITEM_PROP_LABEL,
+                                      gtk_action_get_label (action));
+    }
+}
+
 static DbusmenuMenuitem *
 construct_dbusmenu_for_widget (GtkWidget *widget)
 {
@@ -502,8 +523,26 @@
                             G_CALLBACK (widget_notify_cb),
                             mi);
 
+          if (GTK_IS_ACTIVATABLE (widget))
+            {
+              GtkActivatable *activatable = GTK_ACTIVATABLE (widget);
+
+              if (gtk_activatable_get_use_action_appearance (activatable))
+                {
+                  GtkAction *action = gtk_activatable_get_related_action (activatable);
+
+                  if (action)
+                    {
+                      g_signal_connect_object (action, "notify",
+                                               G_CALLBACK (action_notify_cb),
+                                               mi,
+                                               G_CONNECT_AFTER);
+                    }
+                }
+            }
+
           g_signal_connect (G_OBJECT (mi),
-                            "item_activated",
+                            DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
                             G_CALLBACK (item_activated),
                             widget);
         }


Follow ups