appDisplay: Factor out folder loading code

We'll reuse this code to implement custom positioning in
folders.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
This commit is contained in:
Georges Basile Stavracas Neto 2020-06-24 15:11:51 -03:00 committed by Florian Müllner
parent 16a18f2ae7
commit 7afab2c28c

View File

@ -1587,6 +1587,43 @@ class FolderView extends BaseAppView {
return new FolderGrid(); 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 // Overridden from BaseAppView
animate(animationDirection) { animate(animationDirection) {
this._grid.animatePulse(animationDirection); this._grid.animatePulse(animationDirection);
@ -1631,40 +1668,17 @@ class FolderView extends BaseAppView {
_loadApps() { _loadApps() {
let apps = []; let apps = [];
let excludedApps = this._folder.get_strv('excluded-apps');
let appSys = Shell.AppSystem.get_default(); let appSys = Shell.AppSystem.get_default();
let addAppId = appId => { const appIds = this._getFolderApps();
if (excludedApps.includes(appId))
return;
let app = appSys.lookup_app(appId); appIds.forEach(appId => {
if (!app) const app = appSys.lookup_app(appId);
return;
if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
return;
if (apps.some(appIcon => appIcon.id == appId))
return;
let icon = this._items.get(appId); let icon = this._items.get(appId);
if (!icon) if (!icon)
icon = new AppIcon(app); icon = new AppIcon(app);
apps.push(icon); 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; return apps;