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
This commit is contained in:
parent
1b64b09532
commit
55308917f9
@ -870,6 +870,10 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
return menuItem;
|
return menuItem;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isEmpty: function() {
|
||||||
|
return this.box.get_children().length == 0;
|
||||||
|
},
|
||||||
|
|
||||||
isChildMenu: function(menu) {
|
isChildMenu: function(menu) {
|
||||||
return this._childMenus.indexOf(menu) != -1;
|
return this._childMenus.indexOf(menu) != -1;
|
||||||
},
|
},
|
||||||
@ -1195,6 +1199,9 @@ const PopupMenu = new Lang.Class({
|
|||||||
if (this.isOpen)
|
if (this.isOpen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
|
|
||||||
this._boxPointer.setPosition(this.sourceActor, this._arrowAlignment);
|
this._boxPointer.setPosition(this.sourceActor, this._arrowAlignment);
|
||||||
@ -1286,6 +1293,9 @@ const PopupSubMenu = new Lang.Class({
|
|||||||
if (this.isOpen)
|
if (this.isOpen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
|
|
||||||
this.actor.show();
|
this.actor.show();
|
||||||
@ -1530,6 +1540,9 @@ const PopupComboMenu = new Lang.Class({
|
|||||||
if (this.isOpen)
|
if (this.isOpen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
|
|
||||||
let [sourceX, sourceY] = this.sourceActor.get_transformed_position();
|
let [sourceX, sourceY] = this.sourceActor.get_transformed_position();
|
||||||
|
Loading…
Reference in New Issue
Block a user