[gnome-shell/gbsneto/custom-icon-positions: 103/111] appDisplay: Introduce PageManager
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 103/111] appDisplay: Introduce PageManager
- Date: Mon, 22 Jun 2020 22:53:03 +0000 (UTC)
commit 49cff666e0852262e570588104b9808050307762
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Dec 5 12:31:52 2019 -0300
appDisplay: Introduce PageManager
The PageManager does the heavy lifting between reading the
'grid-layout' GSettings key, and saving the new pages.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 12cb01be3b..50a1c68788 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -526,6 +526,62 @@ var BaseAppView = GObject.registerClass({
}
});
+var PageManager = GObject.registerClass({
+ Signals: { 'layout-changed': {} },
+}, class PageManager extends GObject.Object {
+ _init() {
+ super._init();
+
+ this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
+ this._settings.connect('changed::grid-layout', this._loadPages.bind(this));
+
+ this._loadPages();
+ }
+
+ _loadPages() {
+ this._pages = this._settings.get_value('grid-layout').recursiveUnpack();
+ this.emit('layout-changed');
+ }
+
+ getAppPosition(appId) {
+ let position = -1;
+ let page = -1;
+
+ for (let pageIndex = 0; pageIndex < this._pages.length; pageIndex++) {
+ const pageData = this._pages[pageIndex];
+
+ if (!(appId in pageData))
+ continue;
+
+ page = pageIndex;
+ position = pageData[appId].position;
+ }
+
+ return [page, position];
+ }
+
+ set pages(p) {
+ const packedPages = [];
+
+ // Pack the icon properties as a GVariant
+ for (let page of p) {
+ const pageData = {};
+ for (let [appId, properties] of Object.entries(page)) {
+ const variant = new GLib.Variant('a{sv}', properties);
+ pageData[appId] = new GLib.Variant('v', variant);
+ }
+ packedPages.push(pageData);
+ }
+
+ const variant = new GLib.Variant('aa{sv}', packedPages);
+ this._settings.set_value('grid-layout', variant);
+ }
+
+ get pages() {
+ return this._pages;
+ }
+});
+
var AppDisplay = GObject.registerClass(
class AppDisplay extends BaseAppView {
_init() {
@@ -536,6 +592,7 @@ class AppDisplay extends BaseAppView {
});
this._grid._delegate = this;
+ this._pageManager = new PageManager();
this._scrollView.add_style_class_name('all-apps');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]