[gnome-shell/wip/gtkmenutrackeritem: 2/5] remoteMenu: Add support for submenu items



commit 90fbcb646f1b5d71c18c46f4f516299df339a5ad
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri May 10 13:39:21 2013 -0400

    remoteMenu: Add support for submenu items

 js/ui/remoteMenu.js |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/remoteMenu.js b/js/ui/remoteMenu.js
index fbbe6b8..3ebebc5 100644
--- a/js/ui/remoteMenu.js
+++ b/js/ui/remoteMenu.js
@@ -34,6 +34,30 @@ const RemoteMenuSeparatorItemMapper = new Lang.Class({
     },
 });
 
+const RemoteMenuSubmenuItemMapper = new Lang.Class({
+    Name: 'RemoteMenuSubmenuItemMapper',
+
+    _init: function(trackerItem) {
+        this._trackerItem = trackerItem;
+        this.menuItem = new PopupMenu.PopupSubMenuMenuItem('');
+        this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
+        this._updateLabel();
+
+        this._tracker = new RemoteMenuTracker(this._trackerItem.get_observable(),
+                                              this._trackerItem.get_submenu(),
+                                              this.menuItem.menu);
+    },
+
+    destroy: function() {
+        this._tracker.destroy();
+        this.parent();
+    },
+
+    _updateLabel: function() {
+        this.menuItem.label.text = stripMnemonics(this._trackerItem.label);
+    },
+});
+
 const RemoteMenuItemMapper = new Lang.Class({
     Name: 'RemoteMenuItemMapper',
 
@@ -117,6 +141,9 @@ const RemoteMenuTracker = new Lang.Class({
         if (trackerItem.get_is_separator()) {
             let mapper = new RemoteMenuSeparatorItemMapper(trackerItem);
             item = mapper.menuItem;
+        } else if (trackerItem.get_submenu()) {
+            let mapper = new RemoteMenuSubmenuItemMapper(trackerItem);
+            item = mapper.menuItem;
         } else {
             let mapper = new RemoteMenuItemMapper(trackerItem);
             item = mapper.menuItem;


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