[gnome-shell] popupMenu: Remove combo boxes and child menus



commit 3816db03f5f3f3285c6e4c3fefb776b64934fd2c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Apr 23 17:46:33 2013 -0400

    popupMenu: Remove combo boxes and child menus
    
    They're no longer used with the removal of the avatar widget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704368

 data/theme/gnome-shell.css |   11 --
 js/ui/popupMenu.js         |  307 +-------------------------------------------
 2 files changed, 5 insertions(+), 313 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index cd31541..e7c0da7 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -189,13 +189,6 @@ StScrollBar StButton#vhandle:active {
     border-width: 0px;
 }
 
-.popup-combo-menu {
-    background-color: rgba(0,0,0,0.9);
-    padding: 1em 0em;
-    border: 1px solid #5f5f5f;
-    border-radius: 9px;
-}
-
 /* The remaining popup-menu sizing is all done in ems, so that if you
  * override .popup-menu.font-size, everything else will scale with it.
  */
@@ -219,10 +212,6 @@ StScrollBar StButton#vhandle:active {
 .popup-image-menu-item {
 }
 
-.popup-combobox-item {
-    spacing: 1em;
-}
-
 .popup-separator-menu-item {
     -gradient-height: 1px;
     -gradient-start: rgba(255,255,255,0.0);
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 45cfa45..a1c036a 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -130,18 +130,16 @@ const PopupBaseMenuItem = new Lang.Class({
         this.emit('activate', event);
     },
 
-    setActive: function (active, params) {
+    setActive: function (active) {
         let activeChanged = active != this.active;
-        params = Params.parse (params, { grabKeyboard: true });
-
         if (activeChanged) {
             this.active = active;
             if (active) {
                 this.actor.add_style_pseudo_class('active');
-                if (params.grabKeyboard)
-                    this.actor.grab_key_focus();
-            } else
+                this.actor.grab_key_focus();
+            } else {
                 this.actor.remove_style_pseudo_class('active');
+            }
             this.emit('active-changed', active);
         }
     },
@@ -735,10 +733,6 @@ const PopupMenuBase = new Lang.Class({
         return !hasVisibleChildren;
     },
 
-    isChildMenu: function() {
-        return false;
-    },
-
     itemActivated: function(animate) {
         if (animate == undefined)
             animate = BoxPointer.PopupAnimation.FULL;
@@ -1039,7 +1033,6 @@ const PopupMenu = new Lang.Class({
         global.focus_manager.add_group(this.actor);
         this.actor.reactive = true;
 
-        this._childMenus = [];
         this._openedSubMenu = null;
     },
 
@@ -1074,28 +1067,6 @@ const PopupMenu = new Lang.Class({
         this._boxPointer.setSourceAlignment(alignment);
     },
 
-    isChildMenu: function(menu) {
-        return this._childMenus.indexOf(menu) != -1;
-    },
-
-    addChildMenu: function(menu) {
-        if (this.isChildMenu(menu))
-            return;
-
-        this._childMenus.push(menu);
-        this.emit('child-menu-added', menu);
-    },
-
-    removeChildMenu: function(menu) {
-        let index = this._childMenus.indexOf(menu);
-
-        if (index == -1)
-            return;
-
-        this._childMenus.splice(index, 1);
-        this.emit('child-menu-removed', menu);
-    },
-
     open: function(animate) {
         if (this.isOpen)
             return;
@@ -1117,10 +1088,6 @@ const PopupMenu = new Lang.Class({
         if (this._activeMenuItem)
             this._activeMenuItem.setActive(false);
 
-        this._childMenus.forEach(function(childMenu) {
-            childMenu.close();
-        });
-
         if (this._boxPointer.actor.visible) {
             this._boxPointer.hide(animate, Lang.bind(this, function() {
                 this.emit('menu-closed');
@@ -1144,10 +1111,6 @@ const PopupDummyMenu = new Lang.Class({
         this.actor._delegate = this;
     },
 
-    isChildMenu: function() {
-        return false;
-    },
-
     getSensitive: function() {
         return true;
     },
@@ -1412,247 +1375,6 @@ const PopupSubMenuMenuItem = new Lang.Class({
     }
 });
 
-const PopupComboMenu = new Lang.Class({
-    Name: 'PopupComboMenu',
-    Extends: PopupMenuBase,
-
-    _init: function(sourceActor) {
-        this.parent(sourceActor, 'popup-combo-menu');
-
-        this.actor = this.box;
-        this.actor._delegate = this;
-        this.actor.connect('key-focus-in', Lang.bind(this, this._onKeyFocusIn));
-        sourceActor.connect('style-changed',
-                            Lang.bind(this, this._onSourceActorStyleChanged));
-        this._activeItemPos = -1;
-        global.focus_manager.add_group(this.actor);
-    },
-
-    _onKeyFocusIn: function(actor) {
-        let items = this._getMenuItems();
-        let activeItem = items[this._activeItemPos];
-        activeItem.actor.grab_key_focus();
-    },
-
-    _onSourceActorStyleChanged: function() {
-        // PopupComboBoxMenuItem clones the active item's actors
-        // to work with arbitrary items in the menu; this means
-        // that we need to propagate some style information and
-        // enforce style updates even when the menu is closed
-        let activeItem = this._getMenuItems()[this._activeItemPos];
-        if (this.sourceActor.has_style_pseudo_class('insensitive'))
-            activeItem.actor.add_style_pseudo_class('insensitive');
-        else
-            activeItem.actor.remove_style_pseudo_class('insensitive');
-
-        // To propagate the :active style, we need to make sure that the
-        // internal state of the PopupComboMenu is updated as well, but
-        // we must not move the keyboard grab
-        activeItem.setActive(this.sourceActor.has_style_pseudo_class('active'),
-                             { grabKeyboard: false });
-
-        _ensureStyle(this.actor);
-    },
-
-    open: function() {
-        if (this.isOpen)
-            return;
-
-        if (this.isEmpty())
-            return;
-
-        this.isOpen = true;
-
-        let [sourceX, sourceY] = this.sourceActor.get_transformed_position();
-        let items = this._getMenuItems();
-        let activeItem = items[this._activeItemPos];
-
-        this.actor.set_position(sourceX, sourceY - activeItem.actor.y);
-        this.actor.width = Math.max(this.actor.width, this.sourceActor.width);
-        this.actor.raise_top();
-
-        this.actor.opacity = 0;
-        this.actor.show();
-
-        Tweener.addTween(this.actor,
-                         { opacity: 255,
-                           transition: 'linear',
-                           time: BoxPointer.POPUP_ANIMATION_TIME });
-
-        this.emit('open-state-changed', true);
-    },
-
-    close: function() {
-        if (!this.isOpen)
-            return;
-
-        this.isOpen = false;
-        Tweener.addTween(this.actor,
-                         { opacity: 0,
-                           transition: 'linear',
-                           time: BoxPointer.POPUP_ANIMATION_TIME,
-                           onComplete: Lang.bind(this,
-                               function() {
-                                   this.actor.hide();
-                               })
-                         });
-
-        this.emit('open-state-changed', false);
-    },
-
-    setActiveItem: function(position) {
-        this._activeItemPos = position;
-    },
-
-    getActiveItem: function() {
-        return this._getMenuItems()[this._activeItemPos];
-    },
-
-    setItemVisible: function(position, visible) {
-        if (!visible && position == this._activeItemPos) {
-            log('Trying to hide the active menu item.');
-            return;
-        }
-
-        this._getMenuItems()[position].actor.visible = visible;
-    },
-
-    getItemVisible: function(position) {
-        return this._getMenuItems()[position].actor.visible;
-    }
-});
-
-const PopupComboBoxMenuItem = new Lang.Class({
-    Name: 'PopupComboBoxMenuItem',
-    Extends: PopupBaseMenuItem,
-
-    _init: function (params) {
-        this.parent(params);
-
-        this.actor.accessible_role = Atk.Role.COMBO_BOX;
-
-        this._itemBox = new Shell.Stack();
-        this.addActor(this._itemBox);
-
-        let expander = new St.Label({ text: '\u2304' });
-        this.addActor(expander, { align: St.Align.END });
-
-        this._menu = new PopupComboMenu(this.actor);
-        Main.uiGroup.add_actor(this._menu.actor);
-        this._menu.actor.hide();
-
-        if (params.style_class)
-            this._menu.actor.add_style_class_name(params.style_class);
-
-        this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
-
-        this._activeItemPos = -1;
-        this._items = [];
-    },
-
-    _getTopMenu: function() {
-        let actor = this.actor.get_parent();
-        while (actor) {
-            if (actor._delegate && actor._delegate instanceof PopupMenu)
-                return actor._delegate;
-
-            actor = actor.get_parent();
-        }
-
-        return null;
-    },
-
-    _onScrollEvent: function(actor, event) {
-        if (this._activeItemPos == -1)
-            return;
-
-        let position = this._activeItemPos;
-        let direction = event.get_scroll_direction();
-        if (direction == Clutter.ScrollDirection.DOWN) {
-            while (position < this._items.length - 1) {
-                position++;
-                if (this._menu.getItemVisible(position))
-                    break;
-            }
-        } else if (direction == Clutter.ScrollDirection.UP) {
-            while (position > 0) {
-                position--;
-                if (this._menu.getItemVisible(position))
-                    break;
-            }
-        }
-
-        if (position == this._activeItemPos)
-            return;
-
-        this.setActiveItem(position);
-        this.emit('active-item-changed', position);
-    },
-
-    activate: function(event) {
-        let topMenu = this._getTopMenu();
-        if (!topMenu)
-            return;
-
-        topMenu.addChildMenu(this._menu);
-        this._menu.toggle();
-    },
-
-    addMenuItem: function(menuItem, position) {
-        if (position === undefined)
-            position = this._menu.numMenuItems;
-
-        this._menu.addMenuItem(menuItem, position);
-        _ensureStyle(this._menu.actor);
-
-        let item = new St.BoxLayout({ style_class: 'popup-combobox-item' });
-
-        let children = menuItem.actor.get_children();
-        for (let i = 0; i < children.length; i++) {
-            let clone = new Clutter.Clone({ source: children[i] });
-            item.add(clone, { y_fill: false });
-        }
-
-        let oldItem = this._items[position];
-        if (oldItem)
-            this._itemBox.remove_actor(oldItem);
-
-        this._items[position] = item;
-        this._itemBox.add_actor(item);
-
-        menuItem.connect('activate',
-                         Lang.bind(this, this._itemActivated, position));
-    },
-
-    checkAccessibleLabel: function() {
-        let activeItem = this._menu.getActiveItem();
-        this.actor.label_actor = activeItem.label;
-    },
-
-    setActiveItem: function(position) {
-        let item = this._items[position];
-        if (!item)
-            return;
-        if (this._activeItemPos == position)
-            return;
-        this._menu.setActiveItem(position);
-        this._activeItemPos = position;
-        for (let i = 0; i < this._items.length; i++)
-            this._items[i].visible = (i == this._activeItemPos);
-
-        this.checkAccessibleLabel();
-    },
-
-    setItemVisible: function(position, visible) {
-        this._menu.setItemVisible(position, visible);
-    },
-
-    _itemActivated: function(menuItem, event, position) {
-        this.setActiveItem(position);
-        this.emit('active-item-changed', position);
-    }
-});
-
 /* Basic implementation of a menu manager.
  * Call addMenu to add menus
  */
@@ -1672,8 +1394,6 @@ const PopupMenuManager = new Lang.Class({
         let menudata = {
             menu:              menu,
             openStateChangeId: menu.connect('open-state-changed', Lang.bind(this, this._onMenuOpenState)),
-            childMenuAddedId:  menu.connect('child-menu-added', Lang.bind(this, this._onChildMenuAdded)),
-            childMenuRemovedId: menu.connect('child-menu-removed', Lang.bind(this, 
this._onChildMenuRemoved)),
             destroyId:         menu.connect('destroy', Lang.bind(this, this._onMenuDestroy)),
             enterId:           0,
             focusInId:         0
@@ -1703,8 +1423,6 @@ const PopupMenuManager = new Lang.Class({
 
         let menudata = this._menus[position];
         menu.disconnect(menudata.openStateChangeId);
-        menu.disconnect(menudata.childMenuAddedId);
-        menu.disconnect(menudata.childMenuRemovedId);
         menu.disconnect(menudata.destroyId);
 
         if (menudata.enterId)
@@ -1731,7 +1449,7 @@ const PopupMenuManager = new Lang.Class({
 
     _onMenuOpenState: function(menu, open) {
         if (open) {
-            if (this.activeMenu && !this.activeMenu.isChildMenu(menu))
+            if (this.activeMenu)
                 this.activeMenu.close(BoxPointer.PopupAnimation.FADE);
             this._grabHelper.grab({ actor: menu.actor, focus: menu.sourceActor,
                                     onUngrab: Lang.bind(this, this._closeMenu, menu) });
@@ -1740,14 +1458,6 @@ const PopupMenuManager = new Lang.Class({
         }
     },
 
-    _onChildMenuAdded: function(menu, childMenu) {
-        this.addMenu(childMenu);
-    },
-
-    _onChildMenuRemoved: function(menu, childMenu) {
-        this.removeMenu(childMenu);
-    },
-
     _changeMenu: function(newMenu) {
         newMenu.open(this.activeMenu ? BoxPointer.PopupAnimation.FADE
                                      : BoxPointer.PopupAnimation.FULL);
@@ -1760,13 +1470,6 @@ const PopupMenuManager = new Lang.Class({
         if (this._grabHelper.isActorGrabbed(menu.actor))
             return false;
 
-        let isChildMenu = this._grabHelper.grabStack.some(function(grab) {
-            let existingMenu = grab.actor._delegate;
-            return existingMenu.isChildMenu(menu);
-        });
-        if (isChildMenu)
-            return false;
-
         this._changeMenu(menu);
         return false;
     },


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