From 55308917f91dc441152b20e2f1ca798746d5e0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 15 Nov 2011 14:58:55 +0100 Subject: [PATCH] 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 file changed, 13 insertions(+) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index fa6ddad8d..aca4ae3de 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();