[gnome-shell] appDisplay: Rename _allItems array to _orderedItems



commit 2ba410883887f9850467b9ff633a9a122e68ad01
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Fri Nov 1 00:44:02 2019 +0100

    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

 js/ui/appDisplay.js | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1021971768..a39211f025 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -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);
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]