[gnome-shell/gbsneto/pagination: 7/14] appDisplay: Add items in order
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/pagination: 7/14] appDisplay: Add items in order
- Date: Wed, 17 Jun 2020 19:23:53 +0000 (UTC)
commit e67bb146982c53bd690b8ff029cff73aaddc6781
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue May 19 21:31:45 2020 -0300
appDisplay: Add items in order
Add app icons to the exact page and position they're located
instead of always appending. This will be useful later when
custom icon positions are in place.
For now, it assumes pages are always filled, which is true,
but this will also change with custom icon positions.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1271
js/ui/appDisplay.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 54237fa882..3d18ee8307 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -159,12 +159,16 @@ var BaseAppView = GObject.registerClass({
});
// Add new app icons
+ const { itemsPerPage } = this._grid;
addedApps.forEach(icon => {
let iconIndex = newApps.indexOf(icon);
this._orderedItems.splice(iconIndex, 0, icon);
- this._grid.addItem(icon);
this._items.set(icon.id, icon);
+
+ const page = Math.floor(iconIndex / itemsPerPage);
+ const position = iconIndex % itemsPerPage;
+ this._grid.addItem(icon, page, position);
});
this._viewIsReady = true;
@@ -445,7 +449,12 @@ class AppDisplay extends BaseAppView {
let newIdx = Util.insertSorted(this._orderedItems, item, this._compareItems);
this._grid.removeItem(item);
- this._grid.addItem(item, -1, newIdx);
+
+ const itemsPerPage = this._grid.itemsPerPage;
+ const page = Math.floor(newIdx / itemsPerPage);
+ const position = newIdx % itemsPerPage;
+ this._grid.addItem(item, page, position);
+
this.selectApp(item.id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]