From 69f6c43b6077bd46c2b3297555922a3a287d5e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 17 Feb 2020 16:56:10 +0100 Subject: [PATCH] appDisplay: Implement an addApp() method for FolderViews Similar to removeApp(), implement addApp() in FolderView to make adding folders to views a bit more obvious. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1011 --- js/ui/appDisplay.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 97bf72d6a..042598ddc 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1429,6 +1429,22 @@ class FolderView extends BaseAppView { return apps; } + addApp(app) { + let folderApps = this._folder.get_strv('apps'); + folderApps.push(app.id); + + this._folder.set_strv('apps', folderApps); + + // Also remove from 'excluded-apps' if the app id is listed + // there. This is only possible on categories-based folders. + let excludedApps = this._folder.get_strv('excluded-apps'); + let index = excludedApps.indexOf(app.id); + if (index >= 0) { + excludedApps.splice(index, 1); + this._folder.set_strv('excluded-apps', excludedApps); + } + } + removeApp(app) { let folderApps = this._folder.get_strv('apps'); let index = folderApps.indexOf(app.id); @@ -1459,8 +1475,6 @@ class FolderView extends BaseAppView { } else { this._folder.set_strv('apps', folderApps); } - - return true; } }); @@ -1589,20 +1603,7 @@ var FolderIcon = GObject.registerClass({ if (!this._canAccept(source)) return false; - let app = source.app; - let folderApps = this._folder.get_strv('apps'); - folderApps.push(app.id); - - this._folder.set_strv('apps', folderApps); - - // Also remove from 'excluded-apps' if the app id is listed - // there. This is only possible on categories-based folders. - let excludedApps = this._folder.get_strv('excluded-apps'); - let index = excludedApps.indexOf(app.id); - if (index >= 0) { - excludedApps.splice(index, 1); - this._folder.set_strv('excluded-apps', excludedApps); - } + this.view.addApp(source.app); return true; }