[gtk+] quartz menu: change sensitivity approach



commit e70f506e831bddfb81b6f76e57f78f8b380d6b1d
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jan 15 00:26:58 2014 -0500

    quartz menu: change sensitivity approach
    
    By default, Mac OS scans menus as they are opened, updating the
    sensitivity of each item in the menu.
    
    The current code in gtkapplication-menu-quartz disables this behaviour,
    preferring to manually control the sensitivity of each item in the menu
    (when told by the tracker that it has changed internally).
    
    Change the way that this works to more closely follow the usual Mac OS
    regime.
    
    This will allow us to construct a typical "application menu" on Mac OS
    containing the items that are typically found there ("Hide", "Hide
    Others", "Show All", "Services") and have the OS automatically update
    their sensitivity.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720552

 gtk/gtkapplication-quartz-menu.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkapplication-quartz-menu.c b/gtk/gtkapplication-quartz-menu.c
index 0e00ba5..0282996 100644
--- a/gtk/gtkapplication-quartz-menu.c
+++ b/gtk/gtkapplication-quartz-menu.c
@@ -65,12 +65,12 @@
 
 - (void)didChangeLabel;
 - (void)didChangeIcon;
-- (void)didChangeSensitive;
 - (void)didChangeVisible;
 - (void)didChangeToggled;
 - (void)didChangeAccel;
 
 - (void)didSelectItem:(id)sender;
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
 
 @end
 
@@ -126,6 +126,11 @@ icon_loaded (GObject      *object,
 
 @implementation GNSMenuItem
 
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+  return gtk_menu_tracker_item_get_sensitive (trackerItem) ? YES : NO;
+}
+
 - (id)initWithTrackerItem:(GtkMenuTrackerItem *)aTrackerItem
 {
   self = [super initWithTitle:@""
@@ -141,7 +146,6 @@ icon_loaded (GObject      *object,
 
       [self didChangeLabel];
       [self didChangeIcon];
-      [self didChangeSensitive];
       [self didChangeVisible];
       [self didChangeToggled];
       [self didChangeAccel];
@@ -226,11 +230,6 @@ icon_loaded (GObject      *object,
   [self setImage:nil];
 }
 
-- (void)didChangeSensitive
-{
-  [self setEnabled:gtk_menu_tracker_item_get_sensitive (trackerItem) ? YES : NO];
-}
-
 - (void)didChangeVisible
 {
   [self setHidden:gtk_menu_tracker_item_get_visible (trackerItem) ? NO : YES];
@@ -321,8 +320,6 @@ menu_item_removed (gint     position,
 
   if (self != nil)
     {
-      [self setAutoenablesItems:NO];
-
       tracker = gtk_menu_tracker_new (observable,
                                       model,
                                       NO,
@@ -341,8 +338,6 @@ menu_item_removed (gint     position,
 
   if (self != nil)
     {
-      [self setAutoenablesItems:NO];
-
       tracker = gtk_menu_tracker_new_for_item_submenu (trackerItem,
                                                        menu_item_inserted,
                                                        menu_item_removed,


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