[gnome-shell-extensions/wip/fmuellner/alacarte-compat: 3/5] apps-menu: Reload on tree changes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/wip/fmuellner/alacarte-compat: 3/5] apps-menu: Reload on tree changes
- Date: Sat, 25 Nov 2017 05:51:36 +0000 (UTC)
commit 077a292952ac6d2b752a4826519b710770e25ccb
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Oct 13 01:43:20 2017 +0200
apps-menu: Reload on tree changes
Now that we respect the sort order defined in the .menu file, make
sure to reload the menu on those changes as well, not just when
the installed apps themselves change.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/27
extensions/apps-menu/extension.js | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index dba31e7..600eda3 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -466,18 +466,25 @@ const ApplicationsButton = new Lang.Class({
});
});
+ this._tree = new GMenu.Tree({ menu_basename: 'applications.menu' });
+ this._treeChangedId = this._tree.connect('changed',
+ Lang.bind(this, this._onTreeChanged));
+
this._applicationsButtons = new Map();
this.reloadFlag = false;
this._createLayout();
this._display();
- this._installedChangedId = appSys.connect('installed-changed', Lang.bind(this, function() {
- if (this.menu.isOpen) {
- this._redisplay();
- this.mainBox.show();
- } else {
- this.reloadFlag = true;
- }
- }));
+ this._installedChangedId = appSys.connect('installed-changed',
+ Lang.bind(this, this._onTreeChanged));
+ },
+
+ _onTreeChanged: function() {
+ if (this.menu.isOpen) {
+ this._redisplay();
+ this.mainBox.show();
+ } else {
+ this.reloadFlag = true;
+ }
},
get hotCorner() {
@@ -495,6 +502,8 @@ const ApplicationsButton = new Lang.Class({
Main.overview.disconnect(this._showingId);
Main.overview.disconnect(this._hidingId);
appSys.disconnect(this._installedChangedId);
+ this._tree.disconnect(this._treeChangedId);
+ this._tree = null;
Main.wm.setCustomKeybindingHandler('panel-main-menu',
Shell.ActionMode.NORMAL |
@@ -675,9 +684,8 @@ const ApplicationsButton = new Lang.Class({
//Load categories
this.applicationsByCategory = {};
- let tree = new GMenu.Tree({ menu_basename: 'applications.menu' });
- tree.load_sync();
- let root = tree.get_root_directory();
+ this._tree.load_sync();
+ let root = this._tree.get_root_directory();
let categoryMenuItem = new CategoryMenuItem(this, null);
this.categoriesBox.add_actor(categoryMenuItem.actor);
let iter = root.iter();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]