From fc9a96ac85fd542f8faf27480122e91011974c90 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 4 Dec 2012 14:52:34 -0500 Subject: [PATCH] popupMenu: Introduce PopupDummyMenu This is designed for things like the activities button that sort of need a menu to make navigation work, but not really have it do anything. https://bugzilla.gnome.org/show_bug.cgi?id=689109 --- js/ui/panel.js | 3 ++- js/ui/panelMenu.js | 2 +- js/ui/popupMenu.js | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 3e7f38b65..712abd7d7 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -599,11 +599,12 @@ const AppMenuButton = new Lang.Class({ menu = new PopupMenu.RemoteMenu(this.actor, this._targetApp.menu, this._targetApp.action_group); } else { - if (this.menu && !(this.menu instanceof PopupMenu.RemoteMenu)) + if (this.menu && this.menu.isDummyQuitMenu) return; // fallback to older menu menu = new PopupMenu.PopupMenu(this.actor, 0.0, St.Side.TOP, 0); + menu.isDummyQuitMenu = true; menu.addAction(_("Quit"), Lang.bind(this, function() { this._targetApp.request_quit(); })); diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js index bdfa465d3..9029b4e17 100644 --- a/js/ui/panelMenu.js +++ b/js/ui/panelMenu.js @@ -112,7 +112,7 @@ const Button = new Lang.Class({ this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress)); if (dontCreateMenu) - this.menu = null; + this.menu = new PopupMenu.PopupDummyMenu(this.actor); else this.setMenu(new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0)); diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index a50264e29..155a8546f 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -1274,6 +1274,27 @@ const PopupMenu = new Lang.Class({ } }); +const PopupDummyMenu = new Lang.Class({ + Name: 'PopupDummyMenu', + + _init: function(sourceActor) { + this.sourceActor = sourceActor; + this.actor = sourceActor; + this.actor._delegate = this; + }, + + isChildMenu: function() { + return false; + }, + + open: function() { this.emit('open-state-changed', true); }, + close: function() { this.emit('open-state-changed', false); }, + destroy: function() { + this.emit('destroy'); + }, +}); +Signals.addSignalMethods(PopupDummyMenu.prototype); + const PopupSubMenu = new Lang.Class({ Name: 'PopupSubMenu', Extends: PopupMenuBase,