appDisplay: Move findBestPageToAppend() behavior to IconGrid
This behavior makes more sense to have in the iconGrid itself: When a page is filled up with items, the new item should never go to the start of the next page, but always to next empty slot. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2348>
This commit is contained in:
parent
245137ff35
commit
2566f938e6
@ -1074,11 +1074,6 @@ var BaseAppView = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addItem(item, page, position) {
|
_addItem(item, page, position) {
|
||||||
// Append icons to the first page with empty slot, starting from
|
|
||||||
// the second page
|
|
||||||
if (this._grid.nPages > 1 && page === -1 && position === -1)
|
|
||||||
page = this._findBestPageToAppend();
|
|
||||||
|
|
||||||
this._items.set(item.id, item);
|
this._items.set(item.id, item);
|
||||||
this._grid.addItem(item, page, position);
|
this._grid.addItem(item, page, position);
|
||||||
|
|
||||||
@ -1125,10 +1120,18 @@ var BaseAppView = GObject.registerClass({
|
|||||||
// Add new app icons, or move existing ones
|
// Add new app icons, or move existing ones
|
||||||
newApps.forEach(icon => {
|
newApps.forEach(icon => {
|
||||||
const [page, position] = this._getItemPosition(icon);
|
const [page, position] = this._getItemPosition(icon);
|
||||||
if (addedApps.includes(icon))
|
if (addedApps.includes(icon)) {
|
||||||
this._addItem(icon, page, position);
|
// If there's two pages, newly installed apps should not appear
|
||||||
else if (page !== -1 && position !== -1)
|
// on page 0
|
||||||
|
if (page === -1 && position === -1 && this._grid.nPages > 1)
|
||||||
|
this._addItem(icon, 1, -1);
|
||||||
|
else
|
||||||
|
this._addItem(icon, page, position);
|
||||||
|
} else if (page !== -1 && position !== -1) {
|
||||||
this._moveItem(icon, page, position);
|
this._moveItem(icon, page, position);
|
||||||
|
} else {
|
||||||
|
// App is part of a folder
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.emit('view-loaded');
|
this.emit('view-loaded');
|
||||||
@ -1484,7 +1487,7 @@ class AppDisplay extends BaseAppView {
|
|||||||
let [page, position] = this._grid.getItemPosition(item);
|
let [page, position] = this._grid.getItemPosition(item);
|
||||||
|
|
||||||
if (page === -1)
|
if (page === -1)
|
||||||
page = this._findBestPageToAppend(this._grid.currentPage);
|
page = this._grid.currentPage;
|
||||||
|
|
||||||
return [page, position];
|
return [page, position];
|
||||||
}
|
}
|
||||||
|
@ -798,6 +798,19 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
this._shouldEaseItems = false;
|
this._shouldEaseItems = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_findBestPageToAppend(startPage) {
|
||||||
|
const itemsPerPage = this.columnsPerPage * this.rowsPerPage;
|
||||||
|
|
||||||
|
for (let i = startPage; i < this._pages.length; i++) {
|
||||||
|
const visibleItems = this._pages[i].visibleChildren;
|
||||||
|
|
||||||
|
if (visibleItems.length < itemsPerPage)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._pages.length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addItem:
|
* addItem:
|
||||||
* @param {Clutter.Actor} item: item to append to the grid
|
* @param {Clutter.Actor} item: item to append to the grid
|
||||||
@ -822,6 +835,9 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
if (!this._container)
|
if (!this._container)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (page !== -1 && index === -1)
|
||||||
|
page = this._findBestPageToAppend(page);
|
||||||
|
|
||||||
this._shouldEaseItems = true;
|
this._shouldEaseItems = true;
|
||||||
|
|
||||||
this._container.add_child(item);
|
this._container.add_child(item);
|
||||||
@ -853,6 +869,10 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
this._shouldEaseItems = true;
|
this._shouldEaseItems = true;
|
||||||
|
|
||||||
this._removeItemData(item);
|
this._removeItemData(item);
|
||||||
|
|
||||||
|
if (newPage !== -1 && newPosition === -1)
|
||||||
|
newPage = this._findBestPageToAppend(newPage);
|
||||||
|
|
||||||
this._addItemToPage(item, newPage, newPosition);
|
this._addItemToPage(item, newPage, newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user