[gnome-shell] popup-menu: Do not open empty menus



commit 55308917f91dc441152b20e2f1ca798746d5e0fe
Author: Florian MÃllner <fmuellner gnome org>
Date:   Tue Nov 15 14:58:55 2011 +0100

    popup-menu: Do not open empty menus
    
    There is little point in showing an empty menu, so return early from
    open() if the menu does not contain any items.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=643867

 js/ui/popupMenu.js |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index fa6ddad..aca4ae3 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -870,6 +870,10 @@ const PopupMenuBase = new Lang.Class({
         return menuItem;
     },
 
+    isEmpty: function() {
+        return this.box.get_children().length == 0;
+    },
+
     isChildMenu: function(menu) {
         return this._childMenus.indexOf(menu) != -1;
     },
@@ -1195,6 +1199,9 @@ const PopupMenu = new Lang.Class({
         if (this.isOpen)
             return;
 
+        if (this.isEmpty())
+            return;
+
         this.isOpen = true;
 
         this._boxPointer.setPosition(this.sourceActor, this._arrowAlignment);
@@ -1286,6 +1293,9 @@ const PopupSubMenu = new Lang.Class({
         if (this.isOpen)
             return;
 
+        if (this.isEmpty())
+            return;
+
         this.isOpen = true;
 
         this.actor.show();
@@ -1530,6 +1540,9 @@ const PopupComboMenu = new Lang.Class({
         if (this.isOpen)
             return;
 
+        if (this.isEmpty())
+            return;
+
         this.isOpen = true;
 
         let [sourceX, sourceY] = this.sourceActor.get_transformed_position();



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