forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
b73d291086
commit
e70f506e83
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user