Blob Blame History Raw
From d19a80a7e7b7a19a723365bae85cc99ebd5bc25b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Fri, 13 Oct 2017 00:30:31 +0200
Subject: [PATCH 1/2] apps-menu: Don't override sort order

Keep the order in which GMenu returns loaded apps, so users can
reorder entries in Alacarte.

https://bugzilla.gnome.org/show_bug.cgi?id=788939
---
 extensions/apps-menu/extension.js | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index e430140..dba31e7 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -745,9 +745,6 @@ const ApplicationsButton = new Lang.Class({
 
         if (category_menu_id) {
             applist = this.applicationsByCategory[category_menu_id];
-            applist.sort(function(a,b) {
-                return a.get_name().toLowerCase() > b.get_name().toLowerCase();
-            });
         } else {
             applist = new Array();
             let favorites = global.settings.get_strv('favorite-apps');
-- 
2.14.2


From a9d09c692cfb2944cdfd5b5c61140b3f9aa4b250 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Fri, 13 Oct 2017 01:43:20 +0200
Subject: [PATCH 2/2] 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.

https://bugzilla.gnome.org/show_bug.cgi?id=788939
---
 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();
-- 
2.14.2