[gnome-shell/gbsneto/icon-grid-dnd: 62/96] folderIcon: Move app icon loading to FolderView
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 62/96] folderIcon: Move app icon loading to FolderView
- Date: Tue, 16 Jul 2019 23:27:21 +0000 (UTC)
commit 4a8a6d97a2cf0af945ee0430c8b623ae40fd37fb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jun 29 12:58:26 2019 -0300
folderIcon: Move app icon loading to FolderView
Future patches will diff the old and new icons of views, in order to
animate them when necessary (e.g. adding an app icon to a folder, or
from a folder back to the app grid). In order to do that, all views
must be streamlined in how they load app icons.
Currently, FrequentView and AllView are already following the behavior
expected by BaseAppView, but FolderView isn't. Its icons are loaded by
FolderIcon, and FolderView doesn't implement BaseView._loadApps(),
which makes it impossible to diff old and new apps.
Move the app icon loading routine from FolderIcon to FolderView, by
implementing the _loadApps() method.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 76 ++++++++++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 36 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index ac95cad0d..5a1dc8c1d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1078,11 +1078,12 @@ var AppSearchProvider = class AppSearchProvider {
};
var FolderView = class FolderView extends BaseAppView {
- constructor(folderIcon) {
+ constructor(folderIcon, folder) {
super(null, null);
// If it not expand, the parent doesn't take into account its preferred_width when allocating
// the second time it allocates, so we apply the "Standard hack for ClutterBinLayout"
this._grid.x_expand = true;
+ this._folder = folder;
this._folderIcon = folderIcon;
this._grid._delegate = this;
@@ -1095,6 +1096,9 @@ var FolderView = class FolderView extends BaseAppView {
let action = new Clutter.PanAction({ interpolate: true });
action.connect('pan', this._onPan.bind(this));
this.actor.add_action(action);
+
+ this._folder.connect('changed', this._redisplay.bind(this));
+ this._redisplay();
}
_childFocused(actor) {
@@ -1197,6 +1201,40 @@ var FolderView = class FolderView extends BaseAppView {
return true;
}
+ _loadApps() {
+ 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 (!app.get_app_info().should_show())
+ return;
+
+ let icon = new AppIcon(app, this);
+ this.addItem(icon);
+ };
+
+ let folderApps = this._folder.get_strv('apps');
+ folderApps.forEach(addAppId);
+
+ let folderCategories = this._folder.get_strv('categories');
+ let appInfos = this._folderIcon._parentView.getAppInfos();
+ appInfos.forEach(appInfo => {
+ let appCategories = _getCategories(appInfo);
+ if (!_listsIntersect(folderCategories, appCategories))
+ return;
+
+ addAppId(appInfo.get_id());
+ });
+
+ this.loadGrid();
+ }
+
get folderIcon() {
return this._folderIcon;
}
@@ -1225,7 +1263,7 @@ var FolderIcon = class FolderIcon {
this.actor.set_child(this.icon);
this.actor.label_actor = this.icon.label;
- this.view = new FolderView(this);
+ this.view = new FolderView(this, this._folder);
Main.overview.connect('item-drag-begin',
this._onDragBegin.bind(this));
@@ -1303,41 +1341,7 @@ var FolderIcon = class FolderIcon {
_redisplay() {
this._updateName();
-
- this.view.removeAll();
-
- 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 (!app.get_app_info().should_show())
- return;
-
- let icon = new AppIcon(app, this.view);
- this.view.addItem(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());
- });
-
this.actor.visible = this.view.getAllItems().length > 0;
- this.view.loadGrid();
this.icon.update();
this.emit('apps-changed');
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]