[gtk+] GtkMenuTracker: rework action removal a bit



commit 8efb1404cbdeedfaf894c219fcae9dbdd1986fa2
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Jan 4 02:11:24 2014 -0500

    GtkMenuTracker: rework action removal a bit
    
    Refactor the code in the action observer remove function in order to
    make way for the (efficient) handling of hiding of the item in the case
    that hidden-when='' is given.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688421

 gtk/gtkmenutrackeritem.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkmenutrackeritem.c b/gtk/gtkmenutrackeritem.c
index dc46be8..d81c9de 100644
--- a/gtk/gtkmenutrackeritem.c
+++ b/gtk/gtkmenutrackeritem.c
@@ -353,31 +353,31 @@ gtk_menu_tracker_item_action_removed (GtkActionObserver   *observer,
                                       const gchar         *action_name)
 {
   GtkMenuTrackerItem *self = GTK_MENU_TRACKER_ITEM (observer);
+  gboolean was_sensitive, was_toggled;
+  GtkMenuTrackerItemRole old_role;
 
   if (!self->can_activate)
     return;
 
+  was_sensitive = self->sensitive;
+  was_toggled = self->toggled;
+  old_role = self->role;
+
   self->can_activate = FALSE;
+  self->sensitive = FALSE;
+  self->toggled = FALSE;
+  self->role = GTK_MENU_TRACKER_ITEM_ROLE_NORMAL;
 
   g_object_freeze_notify (G_OBJECT (self));
 
-  if (self->sensitive)
-    {
-      self->sensitive = FALSE;
-      g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_SENSITIVE]);
-    }
+  if (was_sensitive)
+    g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_SENSITIVE]);
 
-  if (self->toggled)
-    {
-      self->toggled = FALSE;
-      g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_TOGGLED]);
-    }
+  if (was_toggled)
+    g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_TOGGLED]);
 
-  if (self->role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL)
-    {
-      self->role = GTK_MENU_TRACKER_ITEM_ROLE_NORMAL;
-      g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_ROLE]);
-    }
+  if (old_role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL)
+    g_object_notify_by_pspec (G_OBJECT (self), gtk_menu_tracker_item_pspecs[PROP_ROLE]);
 
   g_object_thaw_notify (G_OBJECT (self));
 }


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