[gtk+/wip/quartzwork: 7/11] quartz menu: change sensitivity approach
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/quartzwork: 7/11] quartz menu: change sensitivity approach
- Date: Mon, 16 Dec 2013 18:45:18 +0000 (UTC)
commit 46cd8038f369e7bd7e74c1ed5162e174bb9bc3dc
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Dec 16 11:05:08 2013 -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.
gtk/gtkapplication-quartz-menu.c | 22 ++++++----------------
1 files changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkapplication-quartz-menu.c b/gtk/gtkapplication-quartz-menu.c
index bf88ded..6f334cb 100644
--- a/gtk/gtkapplication-quartz-menu.c
+++ b/gtk/gtkapplication-quartz-menu.c
@@ -61,12 +61,12 @@
- (void)didChangeLabel;
- (void)didChangeIcon;
-- (void)didChangeSensitive;
- (void)didChangeVisible;
- (void)didChangeToggled;
- (void)didChangeAccel;
- (void)didSelectItem:(id)sender;
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
@end
@@ -296,7 +296,6 @@ tracker_item_changed (GObject *object,
{
static const gchar *label = NULL;
static const gchar *icon = NULL;
- static const gchar *sensitive = NULL;
static const gchar *visible = NULL;
static const gchar *toggled = NULL;
static const gchar *accel = NULL;
@@ -308,8 +307,6 @@ tracker_item_changed (GObject *object,
label = g_intern_static_string ("label");
if (G_UNLIKELY (icon == NULL))
icon = g_intern_static_string ("icon");
- if (G_UNLIKELY (sensitive == NULL))
- sensitive = g_intern_static_string ("sensitive");
if (G_UNLIKELY (visible == NULL))
visible = g_intern_static_string ("visible");
if (G_UNLIKELY (toggled == NULL))
@@ -321,8 +318,6 @@ tracker_item_changed (GObject *object,
[item didChangeLabel];
else if (name == icon)
[item didChangeIcon];
- else if (name == sensitive)
- [item didChangeSensitive];
else if (name == visible)
[item didChangeVisible];
else if (name == toggled)
@@ -333,6 +328,11 @@ tracker_item_changed (GObject *object,
@implementation GNSMenuItem
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+ return gtk_menu_tracker_item_get_sensitive (trackerItem) ? YES : NO;
+}
+
- (id)initWithTrackerItem:(GtkMenuTrackerItem *)aTrackerItem
{
if ((self = [super initWithTitle:@""
@@ -346,7 +346,6 @@ tracker_item_changed (GObject *object,
[self didChangeLabel];
[self didChangeIcon];
- [self didChangeSensitive];
[self didChangeVisible];
[self didChangeToggled];
[self didChangeAccel];
@@ -553,11 +552,6 @@ tracker_item_changed (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];
@@ -646,8 +640,6 @@ menu_item_removed (gint position,
{
if ((self = [super initWithTitle:title]) != nil)
{
- [self setAutoenablesItems:NO];
-
tracker = gtk_menu_tracker_new (observable,
model,
NO,
@@ -664,8 +656,6 @@ menu_item_removed (gint position,
{
if ((self = [super initWithTitle:title]) != 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]