[gnome-shell/wip/gtkmenutrackeritem: 29/32] remoteMenu: Split the tracking code out of RemoteMenu



commit f720777673be7c57fc97008cc1d06d12c89c96a4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu May 9 17:32:52 2013 -0400

    remoteMenu: Split the tracking code out of RemoteMenu
    
    The tracking logic will be used to more easily implement submenus.

 js/ui/remoteMenu.js |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/remoteMenu.js b/js/ui/remoteMenu.js
index 17c21c0..fe09342 100644
--- a/js/ui/remoteMenu.js
+++ b/js/ui/remoteMenu.js
@@ -19,6 +19,25 @@ function stripMnemonics(label) {
     return label.replace(/_([^_])/, '$1');
 }
 
+function _insertItem(menu, trackerItem, position) {
+    let item;
+
+    if (trackerItem.get_is_separator()) {
+        let mapper = new RemoteMenuSeparatorItemMapper(trackerItem);
+        item = mapper.menuItem;
+    } else {
+        let mapper = new RemoteMenuItemMapper(trackerItem);
+        item = mapper.menuItem;
+    }
+
+    menu.addMenuItem(item, position);
+}
+
+function _removeItem(menu, position) {
+    let items = menu._getMenuItems();
+    items[position].destroy();
+}
+
 const RemoteMenuSeparatorItemMapper = new Lang.Class({
     Name: 'RemoteMenuSeparatorItemMapper',
 
@@ -106,31 +125,12 @@ const RemoteMenu = new Lang.Class({
         this._tracker = Shell.MenuTracker.new(this._actionGroup,
                                               this._model,
                                               null, /* action namespace */
-                                              Lang.bind(this, this._insertItem),
-                                              Lang.bind(this, this._removeItem));
+                                              _insertItem.bind(null, this),
+                                              _removeItem.bind(null, this));
     },
 
     destroy: function() {
         this._tracker.destroy();
         this.parent();
     },
-
-    _insertItem: function(trackerItem, position) {
-        let item;
-
-        if (trackerItem.get_is_separator()) {
-            let mapper = new RemoteMenuSeparatorItemMapper(trackerItem);
-            item = mapper.menuItem;
-        } else {
-            let mapper = new RemoteMenuItemMapper(trackerItem);
-            item = mapper.menuItem;
-        }
-
-        this.addMenuItem(item, position);
-    },
-
-    _removeItem: function(position) {
-        let items = this._getMenuItems();
-        items[position].destroy();
-    },
 });


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