]> Pileus Git - ~andy/gtk/commitdiff
Fix actiongroup-action interaction that relied on actions connecting to
authorMatthias Clasen <mclasen@redhat.com>
Sat, 7 Jan 2006 06:08:07 +0000 (06:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 7 Jan 2006 06:08:07 +0000 (06:08 +0000)
2006-01-07  Matthias Clasen  <mclasen@redhat.com>

Fix actiongroup-action interaction that relied on
actions connecting to notify on themselves:

* gtk/gtkaction.[hc]: Factor out the code updating the
visibility/sensitivity of proxies into _gtk_action_sync_visible()
and _gtk_action_sync_sensible().

* gtk/gtkactiongroup.c: Call the new functions when the
group visibility/sensitivity changes.

ChangeLog
ChangeLog.pre-2-10
gtk/gtkaction.c
gtk/gtkaction.h
gtk/gtkactiongroup.c
gtk/gtkuimanager.c

index 0f81c6d400a61ab24d60a9b2e31157fbc91a61d4..72d821f485c28d33d252161d0329c2a81ec0ec5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-01-07  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix actiongroup-action interaction that relied on 
+       actions connecting to notify on themselves:
+       
+       * gtk/gtkaction.[hc]: Factor out the code updating the
+       visibility/sensitivity of proxies into _gtk_action_sync_visible()
+       and _gtk_action_sync_sensible().
+
+       * gtk/gtkactiongroup.c: Call the new functions when the
+       group visibility/sensitivity changes. 
+
 2006-01-06  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkactiongroup.c (gtk_action_group_set_sensitive) 
index 0f81c6d400a61ab24d60a9b2e31157fbc91a61d4..72d821f485c28d33d252161d0329c2a81ec0ec5e 100644 (file)
@@ -1,3 +1,15 @@
+2006-01-07  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix actiongroup-action interaction that relied on 
+       actions connecting to notify on themselves:
+       
+       * gtk/gtkaction.[hc]: Factor out the code updating the
+       visibility/sensitivity of proxies into _gtk_action_sync_visible()
+       and _gtk_action_sync_sensible().
+
+       * gtk/gtkactiongroup.c: Call the new functions when the
+       group visibility/sensitivity changes. 
+
 2006-01-06  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkactiongroup.c (gtk_action_group_set_sensitive) 
index 036a057341b3fc17a1d39203c474d1eb977e58c8..a350b9eeb8f907d210839cf764f0743c4d72acca 100644 (file)
@@ -603,7 +603,7 @@ _gtk_action_sync_menu_visible (GtkAction *action,
 
   g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
   g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
-  
+
   if (action == NULL)
     action = g_object_get_qdata (G_OBJECT (proxy), quark_gtk_action_proxy);
 
@@ -1057,6 +1057,22 @@ gtk_action_get_sensitive (GtkAction *action)
   return action->private_data->sensitive;
 }
 
+void
+_gtk_action_sync_sensitive (GtkAction *action)
+{
+  GSList *p;
+  GtkWidget *proxy;
+  gboolean sensitive;
+
+  sensitive = gtk_action_is_sensitive (action);
+
+  for (p = action->private_data->proxies; p; p = p->next)
+    {
+      proxy = (GtkWidget *)p->data;
+      gtk_widget_set_sensitive (proxy, sensitive);
+    }      
+}
+
 /**
  * gtk_action_set_sensitive:
  * @action: the action object
@@ -1073,9 +1089,6 @@ void
 gtk_action_set_sensitive (GtkAction *action,
                          gboolean   sensitive)
 {
-  GSList *p;
-  GtkWidget *proxy;
-
   g_return_if_fail (GTK_IS_ACTION (action));
 
   sensitive = sensitive != FALSE;
@@ -1084,12 +1097,8 @@ gtk_action_set_sensitive (GtkAction *action,
     {
       action->private_data->sensitive = sensitive;
 
-      for (p = action->private_data->proxies; p; p = p->next)
-       {
-         proxy = (GtkWidget *)p->data;
-         gtk_widget_set_sensitive (proxy, sensitive);
-       }
-      
+      _gtk_action_sync_sensitive (action);
+
       g_object_notify (G_OBJECT (action), "sensitive");
     }
 }
@@ -1137,6 +1146,36 @@ gtk_action_get_visible (GtkAction *action)
   return action->private_data->visible;
 }
 
+void
+_gtk_action_sync_visible (GtkAction *action)
+{
+  GSList *p;
+  GtkWidget *proxy;
+  GtkWidget *menu;
+  gboolean visible;
+
+  visible = gtk_action_is_visible (action);
+    
+  for (p = action->private_data->proxies; p; p = p->next)
+    {
+      proxy = (GtkWidget *)p->data;
+
+      if (GTK_IS_MENU_ITEM (proxy))
+       {
+         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
+         
+         _gtk_action_sync_menu_visible (action, proxy, _gtk_menu_is_empty (menu));
+       }
+      else
+       {
+         if (visible)
+           gtk_widget_show (proxy);
+         else
+           gtk_widget_hide (proxy);
+       }
+    } 
+}
+
 /**
  * gtk_action_set_visible:
  * @action: the action object
@@ -1153,9 +1192,6 @@ void
 gtk_action_set_visible (GtkAction *action,
                        gboolean   visible)
 {
-  GSList *p;
-  GtkWidget *proxy;
-
   g_return_if_fail (GTK_IS_ACTION (action));
 
   visible = visible != FALSE;
@@ -1164,25 +1200,8 @@ gtk_action_set_visible (GtkAction *action,
     {
       action->private_data->visible = visible;
 
-      for (p = action->private_data->proxies; p; p = p->next)
-       {
-         proxy = (GtkWidget *)p->data;
+      _gtk_action_sync_visible (action);
 
-         if (GTK_IS_MENU_ITEM (proxy))
-           {
-             GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
-             
-             _gtk_action_sync_menu_visible (action, proxy, _gtk_menu_is_empty (menu));
-           }
-         else
-           {
-             if (visible)
-               gtk_widget_show (proxy);
-             else
-               gtk_widget_hide (proxy);
-           }
-       }
-      
       g_object_notify (G_OBJECT (action), "visible");
     }
 }
index c7e9f9d383492dd939a4ff8077d0d31c81eb7bd9..f7f4c04bfda002845228ee1157f634df07c66a9f 100644 (file)
@@ -121,7 +121,11 @@ void         gtk_action_set_accel_path         (GtkAction     *action,
                                                const gchar   *accel_path);
 void         gtk_action_set_accel_group        (GtkAction     *action,
                                                GtkAccelGroup *accel_group);
-
+void         _gtk_action_sync_sensitive        (GtkAction     *action);
+void         _gtk_action_sync_visible          (GtkAction     *action);
+void         _gtk_action_sync_menu_visible     (GtkAction     *action,
+                                               GtkWidget     *proxy,
+                                               gboolean       empty);
 
 G_END_DECLS
 
index 5b5ba732151864960d03fbc1ca94da0cd0dc29e7..91b2cb35cf8de7bf548f6e772d82a17de88ad109 100644 (file)
@@ -420,10 +420,10 @@ static void
 cb_set_action_sensitivity (const gchar *name, 
                           GtkAction   *action)
 {
-  /* Minor optimization, the action_groups state only affects actions that are
-   * themselves sensitive */
+  /* Minor optimization, the action_groups state only affects actions 
+   * that are themselves sensitive */
   if (gtk_action_get_sensitive (action))
-    g_object_notify (G_OBJECT (action), "sensitive");
+    _gtk_action_sync_sensitive (action);
 }
 
 /**
@@ -478,10 +478,10 @@ static void
 cb_set_action_visiblity (const gchar *name, 
                         GtkAction   *action)
 {
-  /* Minor optimization, the action_groups state only affects actions that are
-   * themselves sensitive */
+  /* Minor optimization, the action_groups state only affects actions 
+   * that are themselves visible */
   if (gtk_action_get_visible (action))
-    g_object_notify (G_OBJECT (action), "visible");
+    _gtk_action_sync_visible (action);
 }
 
 /**
index 3c2732025e2c053ed9b38d54a413d4d5925b46c9..5d045300578579e27cc80eb9374e13f1775a4ef5 100644 (file)
@@ -2008,10 +2008,6 @@ enum {
   SEPARATOR_MODE_HIDDEN
 };
 
-void _gtk_action_sync_menu_visible (GtkAction *action,
-                                   GtkWidget *proxy,
-                                   gboolean   empty);
-
 static void
 update_smart_separators (GtkWidget *proxy)
 {