[gnome-shell/gbsneto/custom-icon-positions: 26/27] appDisplay: Factor out folder loading code
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 26/27] appDisplay: Factor out folder loading code
- Date: Thu, 25 Jun 2020 13:12:51 +0000 (UTC)
commit 5b24169ffc2ff7782918a63666852c77c1399cfc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jun 24 15:11:51 2020 -0300
appDisplay: Factor out folder loading code
We'll reuse this code to implement custom positioning on
folders.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 66 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 40 insertions(+), 26 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index c9bd4ec799..1585ba5c6c 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1566,6 +1566,43 @@ class FolderView extends BaseAppView {
return new FolderGrid();
}
+ _getFolderApps() {
+ const appIds = [];
+ const excludedApps = this._folder.get_strv('excluded-apps');
+ const appSys = Shell.AppSystem.get_default();
+ const addAppId = appId => {
+ if (excludedApps.includes(appId))
+ return;
+
+ const app = appSys.lookup_app(appId);
+ if (!app)
+ return;
+
+ if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
+ return;
+
+ if (appIds.indexOf(appId) !== -1)
+ return;
+
+ appIds.push(appId);
+ };
+
+ const folderApps = this._folder.get_strv('apps');
+ folderApps.forEach(addAppId);
+
+ const folderCategories = this._folder.get_strv('categories');
+ const appInfos = this._parentView.getAppInfos();
+ appInfos.forEach(appInfo => {
+ let appCategories = _getCategories(appInfo);
+ if (!_listsIntersect(folderCategories, appCategories))
+ return;
+
+ addAppId(appInfo.get_id());
+ });
+
+ return appIds;
+ }
+
// Overridden from BaseAppView
animate(animationDirection) {
this._grid.animatePulse(animationDirection);
@@ -1610,40 +1647,17 @@ class FolderView extends BaseAppView {
_loadApps() {
let apps = [];
- let excludedApps = this._folder.get_strv('excluded-apps');
let appSys = Shell.AppSystem.get_default();
- let addAppId = appId => {
- if (excludedApps.includes(appId))
- return;
-
- let app = appSys.lookup_app(appId);
- if (!app)
- return;
-
- if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
- return;
+ const appIds = this._getFolderApps();
- if (apps.some(appIcon => appIcon.id == appId))
- return;
+ appIds.forEach(appId => {
+ const app = appSys.lookup_app(appId);
let icon = this._items.get(appId);
if (!icon)
icon = new AppIcon(app);
apps.push(icon);
- };
-
- let folderApps = this._folder.get_strv('apps');
- folderApps.forEach(addAppId);
-
- let folderCategories = this._folder.get_strv('categories');
- let appInfos = this._parentView.getAppInfos();
- appInfos.forEach(appInfo => {
- let appCategories = _getCategories(appInfo);
- if (!_listsIntersect(folderCategories, appCategories))
- return;
-
- addAppId(appInfo.get_id());
});
return apps;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]