[gtk+/wip/quartzwork: 10/11] quartz menu: add special items



commit c91574b17ced36d858559bce18e3a94a113d3bc1
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Dec 16 10:13:49 2013 -0500

    quartz menu: add special items
    
    Add support for the "Hide app", "Hide Others" and "Show All" special
    items and for the "Services" submenu.

 gtk/gtkapplication-quartz-menu.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkapplication-quartz-menu.c b/gtk/gtkapplication-quartz-menu.c
index 625da39..b5b832c 100644
--- a/gtk/gtkapplication-quartz-menu.c
+++ b/gtk/gtkapplication-quartz-menu.c
@@ -339,7 +339,25 @@ tracker_item_changed (GObject    *object,
                             action:@selector(didSelectItem:)
                      keyEquivalent:@""]) != nil)
     {
-      [self setTarget:self];
+      const gchar *special = gtk_menu_tracker_item_get_special (aTrackerItem);
+
+      if (special && g_str_equal (special, "hide-this"))
+        {
+          [self setAction:@selector(hide:)];
+          [self setTarget:NSApp];
+        }
+      else if (special && g_str_equal (special, "hide-others"))
+        {
+          [self setAction:@selector(hideOtherApplications:)];
+          [self setTarget:NSApp];
+        }
+      else if (special && g_str_equal (special, "show-all"))
+        {
+          [self setAction:@selector(unhideAllApplications:)];
+          [self setTarget:NSApp];
+        }
+      else
+        [self setTarget:self];
 
       trackerItem = g_object_ref (aTrackerItem);
       trackerItemChangedHandler = g_signal_connect (trackerItem, "notify", G_CALLBACK 
(tracker_item_changed), self);
@@ -351,7 +369,12 @@ tracker_item_changed (GObject    *object,
       [self didChangeAccel];
 
       if (gtk_menu_tracker_item_get_has_submenu (trackerItem))
-        [self setSubmenu:[[[GNSMenu alloc] initWithTitle:[self title] trackerItem:trackerItem] autorelease]];
+        {
+          [self setSubmenu:[[[GNSMenu alloc] initWithTitle:[self title] trackerItem:trackerItem] 
autorelease]];
+
+          if (special && g_str_equal (special, "services-submenu"))
+            [NSApp setServicesMenu:[self submenu]];
+        }
     }
 
   return self;


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