appDisplay: Rename _allItems array to _orderedItems
Since both the `_items` object and the `_allItems` array include the same items, the difference between those variables seems unclear. The real difference between them (except the different data type) is that `_allItems` is ordered in the same order as the visible grid, so rename `_allItems` to `_orderedItems` which makes that more obvious. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/799
This commit is contained in:
parent
203c3f9949
commit
2ba4108838
@ -166,7 +166,7 @@ var BaseAppView = GObject.registerClass({
|
||||
this._grid.x_expand = true;
|
||||
|
||||
this._items = new Map();
|
||||
this._allItems = [];
|
||||
this._orderedItems = [];
|
||||
}
|
||||
|
||||
_childFocused(_actor) {
|
||||
@ -174,7 +174,7 @@ var BaseAppView = GObject.registerClass({
|
||||
}
|
||||
|
||||
_redisplay() {
|
||||
let oldApps = this._allItems.slice();
|
||||
let oldApps = this._orderedItems.slice();
|
||||
let oldAppIds = oldApps.map(icon => icon.id);
|
||||
|
||||
let newApps = this._loadApps().sort(this._compareItems);
|
||||
@ -185,10 +185,10 @@ var BaseAppView = GObject.registerClass({
|
||||
|
||||
// Remove old app icons
|
||||
removedApps.forEach(icon => {
|
||||
let iconIndex = this._allItems.indexOf(icon);
|
||||
let iconIndex = this._orderedItems.indexOf(icon);
|
||||
let id = icon.id;
|
||||
|
||||
this._allItems.splice(iconIndex, 1);
|
||||
this._orderedItems.splice(iconIndex, 1);
|
||||
icon.destroy();
|
||||
this._items.delete(id);
|
||||
});
|
||||
@ -197,7 +197,7 @@ var BaseAppView = GObject.registerClass({
|
||||
addedApps.forEach(icon => {
|
||||
let iconIndex = newApps.indexOf(icon);
|
||||
|
||||
this._allItems.splice(iconIndex, 0, icon);
|
||||
this._orderedItems.splice(iconIndex, 0, icon);
|
||||
this._grid.addItem(icon, iconIndex);
|
||||
this._items.set(icon.id, icon);
|
||||
});
|
||||
@ -206,7 +206,7 @@ var BaseAppView = GObject.registerClass({
|
||||
}
|
||||
|
||||
getAllItems() {
|
||||
return this._allItems;
|
||||
return this._orderedItems;
|
||||
}
|
||||
|
||||
_compareItems(a, b) {
|
||||
@ -431,9 +431,9 @@ var AllView = GObject.registerClass({
|
||||
_itemNameChanged(item) {
|
||||
// If an item's name changed, we can pluck it out of where it's
|
||||
// supposed to be and reinsert it where it's sorted.
|
||||
let oldIdx = this._allItems.indexOf(item);
|
||||
this._allItems.splice(oldIdx, 1);
|
||||
let newIdx = Util.insertSorted(this._allItems, item, this._compareItems);
|
||||
let oldIdx = this._orderedItems.indexOf(item);
|
||||
this._orderedItems.splice(oldIdx, 1);
|
||||
let newIdx = Util.insertSorted(this._orderedItems, item, this._compareItems);
|
||||
|
||||
this._grid.removeItem(item);
|
||||
this._grid.addItem(item, newIdx);
|
||||
@ -441,9 +441,9 @@ var AllView = GObject.registerClass({
|
||||
}
|
||||
|
||||
_refilterApps() {
|
||||
let filteredApps = this._allItems.filter(icon => !icon.visible);
|
||||
let filteredApps = this._orderedItems.filter(icon => !icon.visible);
|
||||
|
||||
this._allItems.forEach(icon => {
|
||||
this._orderedItems.forEach(icon => {
|
||||
if (icon instanceof AppIcon)
|
||||
icon.visible = true;
|
||||
});
|
||||
@ -1361,12 +1361,12 @@ class FolderView extends BaseAppView {
|
||||
let subSize = Math.floor(FOLDER_SUBICON_FRACTION * size);
|
||||
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
||||
|
||||
let numItems = this._allItems.length;
|
||||
let numItems = this._orderedItems.length;
|
||||
let rtl = icon.get_text_direction() == Clutter.TextDirection.RTL;
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let bin = new St.Bin({ width: subSize * scale, height: subSize * scale });
|
||||
if (i < numItems)
|
||||
bin.child = this._allItems[i].app.create_icon_texture(subSize);
|
||||
bin.child = this._orderedItems[i].app.create_icon_texture(subSize);
|
||||
layout.attach(bin, rtl ? (i + 1) % 2 : i % 2, Math.floor(i / 2), 1, 1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user