Blob Blame History Raw
From 3ca39599e941563898b920a04192be0edb372470 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Mon, 23 Mar 2015 23:48:56 +0100
Subject: [PATCH 1/3] apps-menu: Clean up signal code

Setting up signal handlers inside a class and rely on outside code
to disconnect them via global variables is utterly weird. Just
disconnect everything inside the class when the corresponding actor
is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=746639
---
 extensions/apps-menu/extension.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 2d198c1..b392a91 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -297,18 +297,19 @@ const ApplicationsButton = new Lang.Class({
         this.actor.label_actor = this._label;
 
         this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
+        this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
-        _showingId = Main.overview.connect('showing', Lang.bind(this, function() {
+        this._showingId = Main.overview.connect('showing', Lang.bind(this, function() {
             this.actor.add_accessible_state (Atk.StateType.CHECKED);
         }));
-        _hidingId = Main.overview.connect('hiding', Lang.bind(this, function() {
+        this._hidingId = Main.overview.connect('hiding', Lang.bind(this, function() {
             this.actor.remove_accessible_state (Atk.StateType.CHECKED);
         }));
 
         this.reloadFlag = false;
         this._createLayout();
         this._display();
-        _installedChangedId = appSys.connect('installed-changed', Lang.bind(this, function() {
+        this._installedChangedId = appSys.connect('installed-changed', Lang.bind(this, function() {
             if (this.menu.isOpen) {
                 this._redisplay();
                 this.mainBox.show();
@@ -320,7 +321,7 @@ const ApplicationsButton = new Lang.Class({
         // Since the hot corner uses stage coordinates, Clutter won't
         // queue relayouts for us when the panel moves. Queue a relayout
         // when that happens.
-        _panelBoxChangedId = Main.layoutManager.connect('panel-box-changed', Lang.bind(this, function() {
+        this._panelBoxChangedId = Main.layoutManager.connect('panel-box-changed', Lang.bind(this, function() {
             container.queue_relayout();
         }));
     },
@@ -336,6 +337,13 @@ const ApplicationsButton = new Lang.Class({
         return separator;
     },
 
+    _onDestroy: function() {
+        Main.overview.disconnect(this._showingId);
+        Main.overview.disconnect(this._hidingId);
+        Main.layoutManager.disconnect(this._panelBoxChangedId);
+        appSys.disconnect(this._installedChangedId);
+    },
+
     _onCapturedEvent: function(actor, event) {
         if (event.type() == Clutter.EventType.BUTTON_PRESS) {
             if (!Main.overview.shouldToggleByCornerOrButton())
@@ -583,10 +591,6 @@ const ApplicationsButton = new Lang.Class({
 
 let appsMenuButton;
 let activitiesButton;
-let _hidingId;
-let _installedChangedId;
-let _panelBoxChangedId;
-let _showingId;
 
 function enable() {
     activitiesButton = Main.panel.statusArea['activities'];
@@ -604,10 +608,6 @@ function enable() {
 
 function disable() {
     Main.panel.menuManager.removeMenu(appsMenuButton.menu);
-    appSys.disconnect(_installedChangedId);
-    Main.layoutManager.disconnect(_panelBoxChangedId);
-    Main.overview.disconnect(_hidingId);
-    Main.overview.disconnect(_showingId);
     appsMenuButton.destroy();
     activitiesButton.container.show();
 
-- 
2.5.0


From ddd92a1cdd2b9ab8e2ba054c8a2a131ae277808d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Mon, 23 Mar 2015 23:55:43 +0100
Subject: [PATCH 2/3] apps-menu: Move panel-main-menu handling into
 AppsMenuButton

This is really where it belongs, and will make an upcoming fix slightly
less ugly ...

https://bugzilla.gnome.org/show_bug.cgi?id=746639
---
 extensions/apps-menu/extension.js | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index b392a91..03a50b7 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -305,6 +305,7 @@ const ApplicationsButton = new Lang.Class({
         this._hidingId = Main.overview.connect('hiding', Lang.bind(this, function() {
             this.actor.remove_accessible_state (Atk.StateType.CHECKED);
         }));
+        this._setKeybinding();
 
         this.reloadFlag = false;
         this._createLayout();
@@ -342,6 +343,13 @@ const ApplicationsButton = new Lang.Class({
         Main.overview.disconnect(this._hidingId);
         Main.layoutManager.disconnect(this._panelBoxChangedId);
         appSys.disconnect(this._installedChangedId);
+
+        Main.wm.setCustomKeybindingHandler('panel-main-menu',
+                                           Shell.KeyBindingMode.NORMAL |
+                                           Shell.KeyBindingMode.OVERVIEW,
+                                           Main.sessionMode.hasOverview ?
+                                           Lang.bind(Main.overview, Main.overview.toggle) :
+                                           null);
     },
 
     _onCapturedEvent: function(actor, event) {
@@ -389,6 +397,15 @@ const ApplicationsButton = new Lang.Class({
        this.parent(menu, open);
     },
 
+    _setKeybinding: function() {
+        Main.wm.setCustomKeybindingHandler('panel-main-menu',
+                                           Shell.KeyBindingMode.NORMAL |
+                                           Shell.KeyBindingMode.OVERVIEW,
+                                           Lang.bind(this, function() {
+                                               this.menu.toggle();
+                                           }));
+    },
+
     _redisplay: function() {
         this.applicationsBox.destroy_all_children();
         this.categoriesBox.destroy_all_children();
@@ -597,26 +614,12 @@ function enable() {
     activitiesButton.container.hide();
     appsMenuButton = new ApplicationsButton();
     Main.panel.addToStatusArea('apps-menu', appsMenuButton, 1, 'left');
-
-    Main.wm.setCustomKeybindingHandler('panel-main-menu',
-                                       Shell.KeyBindingMode.NORMAL |
-                                       Shell.KeyBindingMode.OVERVIEW,
-                                       function() {
-                                           appsMenuButton.menu.toggle();
-                                       });
 }
 
 function disable() {
     Main.panel.menuManager.removeMenu(appsMenuButton.menu);
     appsMenuButton.destroy();
     activitiesButton.container.show();
-
-    Main.wm.setCustomKeybindingHandler('panel-main-menu',
-                                       Shell.KeyBindingMode.NORMAL |
-                                       Shell.KeyBindingMode.OVERVIEW,
-                                       Main.sessionMode.hasOverview ?
-                                       Lang.bind(Main.overview, Main.overview.toggle) :
-                                       null);
 }
 
 function init(metadata) {
-- 
2.5.0


From cff31d811ece77cf6eae017c6e7223f87c67cacc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 24 Mar 2015 00:28:10 +0100
Subject: [PATCH 3/3] apps-menu: Take over shortcuts again on startup-complete

For a while now, gnome-shell has initialized extensions before
setting up its own keybinding handling. As a result, our taking
over of the panel-main-menu shortcut will be overwritten when
the extension is enabled at startup - work around this by setting
up the keybinding again on LayoutManager::startup-complete.

https://bugzilla.gnome.org/show_bug.cgi?id=746639
---
 extensions/apps-menu/extension.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 03a50b7..719f298 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -305,6 +305,8 @@ const ApplicationsButton = new Lang.Class({
         this._hidingId = Main.overview.connect('hiding', Lang.bind(this, function() {
             this.actor.remove_accessible_state (Atk.StateType.CHECKED);
         }));
+        Main.layoutManager.connect('startup-complete',
+                                   Lang.bind(this, this._setKeybinding));
         this._setKeybinding();
 
         this.reloadFlag = false;
-- 
2.5.0