Blame 0012-dash-Reuse-as-much-as-possible-upstream-code.patch

Mike DePaulo 6928dd2
From 7c2e2bf87d1eca72a9948bef2255195c03586335 Mon Sep 17 00:00:00 2001
Mike DePaulo 607d837
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Mike DePaulo 607d837
Date: Thu, 27 Feb 2020 22:52:41 +0100
Mike DePaulo 6928dd2
Subject: [PATCH 12/36] dash: Reuse as much as possible upstream code
Mike DePaulo 607d837
Mike DePaulo 607d837
Many functions in dash were just copy-pasted from upstream source, and this
Mike DePaulo 607d837
may lead to living with non-updated code, so instead of this just re-use
Mike DePaulo 607d837
the default methods, given that JS is nice (or not?) enough to allow to do
Mike DePaulo 607d837
that easily.
Mike DePaulo 607d837
Mike DePaulo 607d837
Less code to maintain, yay!
Mike DePaulo 607d837
---
Mike DePaulo 607d837
 dash.js | 352 +++++++++-----------------------------------------------
Mike DePaulo 607d837
 1 file changed, 54 insertions(+), 298 deletions(-)
Mike DePaulo 607d837
Mike DePaulo 607d837
diff --git a/dash.js b/dash.js
Mike DePaulo 6928dd2
index 495e1ed..0d245a2 100644
Mike DePaulo 607d837
--- a/dash.js
Mike DePaulo 607d837
+++ b/dash.js
Mike DePaulo 6928dd2
@@ -309,6 +309,58 @@ var MyDash = GObject.registerClass({
Mike DePaulo 607d837
         this._signalsHandler.destroy();
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
 
Mike DePaulo 607d837
+    _onDragBegin() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._onDragBegin.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _onDragCancelled() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._onDragCancelled.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _onDragEnd() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._onDragEnd.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _endDrag() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._endDrag.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _onDragMotion() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._onDragMotion.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _appIdListToHash() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._appIdListToHash.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _queueRedisplay() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._queueRedisplay.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _hookUpLabel() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._hookUpLabel.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _syncLabel() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._syncLabel.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _clearDragPlaceholder() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._clearDragPlaceholder.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    _clearEmptyDropTarget() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype._clearEmptyDropTarget.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    handleDragOver() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype.handleDragOver.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
+    acceptDrop() {
Mike DePaulo 607d837
+        return Dash.Dash.prototype.acceptDrop.call(this, ...arguments);
Mike DePaulo 607d837
+    }
Mike DePaulo 607d837
+
Mike DePaulo 607d837
     _onScrollEvent(actor, event) {
Mike DePaulo 607d837
         // If scroll is not used because the icon is resized, let the scroll event propagate.
Mike DePaulo 607d837
         if (!Docking.DockManager.settings.get_boolean('icon-size-fixed'))
Mike DePaulo 6928dd2
@@ -354,88 +406,6 @@ var MyDash = GObject.registerClass({
Mike DePaulo 607d837
         return Clutter.EVENT_STOP;
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
 
Mike DePaulo 607d837
-    _onDragBegin() {
Mike DePaulo 607d837
-        this._dragCancelled = false;
Mike DePaulo 607d837
-        this._dragMonitor = {
Mike DePaulo 607d837
-            dragMotion: this._onDragMotion.bind(this)
Mike DePaulo 607d837
-        };
Mike DePaulo 607d837
-        DND.addDragMonitor(this._dragMonitor);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (this._box.get_n_children() == 0) {
Mike DePaulo 607d837
-            this._emptyDropTarget = new Dash.EmptyDropTargetItem();
Mike DePaulo 607d837
-            this._box.insert_child_at_index(this._emptyDropTarget, 0);
Mike DePaulo 607d837
-            this._emptyDropTarget.show(true);
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _onDragCancelled() {
Mike DePaulo 607d837
-        this._dragCancelled = true;
Mike DePaulo 607d837
-        this._endDrag();
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _onDragEnd() {
Mike DePaulo 607d837
-        if (this._dragCancelled)
Mike DePaulo 607d837
-            return;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        this._endDrag();
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _endDrag() {
Mike DePaulo 607d837
-        this._clearDragPlaceholder();
Mike DePaulo 607d837
-        this._clearEmptyDropTarget();
Mike DePaulo 607d837
-        this._showAppsIcon.setDragApp(null);
Mike DePaulo 607d837
-        DND.removeDragMonitor(this._dragMonitor);
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _onDragMotion(dragEvent) {
Mike DePaulo 607d837
-        let app = Dash.getAppFromSource(dragEvent.source);
Mike DePaulo 607d837
-        if (app == null)
Mike DePaulo 607d837
-            return DND.DragMotionResult.CONTINUE;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let showAppsHovered = this._showAppsIcon.contains(dragEvent.targetActor);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (!this._box.contains(dragEvent.targetActor) || showAppsHovered)
Mike DePaulo 607d837
-            this._clearDragPlaceholder();
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (showAppsHovered)
Mike DePaulo 607d837
-            this._showAppsIcon.setDragApp(app);
Mike DePaulo 607d837
-        else
Mike DePaulo 607d837
-            this._showAppsIcon.setDragApp(null);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        return DND.DragMotionResult.CONTINUE;
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _appIdListToHash(apps) {
Mike DePaulo 607d837
-        let ids = {};
Mike DePaulo 607d837
-        for (let i = 0; i < apps.length; i++)
Mike DePaulo 607d837
-            ids[apps[i].get_id()] = apps[i];
Mike DePaulo 607d837
-        return ids;
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _queueRedisplay() {
Mike DePaulo 607d837
-        Main.queueDeferredWork(this._workId);
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _hookUpLabel(item, appIcon) {
Mike DePaulo 607d837
-        item.child.connect('notify::hover', () => {
Mike DePaulo 607d837
-            this._syncLabel(item, appIcon);
Mike DePaulo 607d837
-        });
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let id = Main.overview.connect('hiding', () => {
Mike DePaulo 607d837
-            this._labelShowing = false;
Mike DePaulo 607d837
-            item.hideLabel();
Mike DePaulo 607d837
-        });
Mike DePaulo 607d837
-        item.child.connect('destroy', function() {
Mike DePaulo 607d837
-            Main.overview.disconnect(id);
Mike DePaulo 607d837
-        });
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (appIcon) {
Mike DePaulo 607d837
-            appIcon.connect('sync-tooltip', () => {
Mike DePaulo 607d837
-                this._syncLabel(item, appIcon);
Mike DePaulo 607d837
-            });
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
     _createAppItem(app) {
Mike DePaulo 607d837
         let appIcon = new AppIcons.MyAppIcon(this._remoteModel, app,
Mike DePaulo 607d837
             this._monitorIndex);
Mike DePaulo 6928dd2
@@ -528,18 +498,9 @@ var MyDash = GObject.registerClass({
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
 
Mike DePaulo 607d837
     _itemMenuStateChanged(item, opened) {
Mike DePaulo 607d837
-        // When the menu closes, it calls sync_hover, which means
Mike DePaulo 607d837
-        // that the notify::hover handler does everything we need to.
Mike DePaulo 607d837
-        if (opened) {
Mike DePaulo 607d837
-            if (this._showLabelTimeoutId > 0) {
Mike DePaulo 607d837
-                GLib.source_remove(this._showLabelTimeoutId);
Mike DePaulo 607d837
-                this._showLabelTimeoutId = 0;
Mike DePaulo 607d837
-            }
Mike DePaulo 607d837
+        Dash.Dash.prototype.acceptDrop.call(this, item, opened);
Mike DePaulo 607d837
 
Mike DePaulo 607d837
-            item.label.opacity = 0;
Mike DePaulo 607d837
-            item.label.hide();
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-        else {
Mike DePaulo 607d837
+        if (!opened) {
Mike DePaulo 607d837
             // I want to listen from outside when a menu is closed. I used to
Mike DePaulo 607d837
             // add a custom signal to the appIcon, since gnome 3.8 the signal
Mike DePaulo 607d837
             // calling this callback was added upstream.
Mike DePaulo 6928dd2
@@ -547,49 +508,6 @@ var MyDash = GObject.registerClass({
Mike DePaulo 607d837
         }
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
 
Mike DePaulo 607d837
-    _syncLabel(item, appIcon) {
Mike DePaulo 607d837
-        let shouldShow = appIcon ? appIcon.shouldShowTooltip() : item.child.get_hover();
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (shouldShow) {
Mike DePaulo 607d837
-            if (this._showLabelTimeoutId == 0) {
Mike DePaulo 607d837
-                let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
Mike DePaulo 607d837
-                let actor = (item instanceof Clutter.Actor) ? item : item.actor;
Mike DePaulo 607d837
-                let destroyId = actor.connect('destroy', () => {
Mike DePaulo 607d837
-                    if (this._showLabelTimeoutId)
Mike DePaulo 607d837
-                        GLib.source_remove(this._showLabelTimeoutId);
Mike DePaulo 607d837
-                });
Mike DePaulo 607d837
-                this._showLabelTimeoutId = GLib.timeout_add(
Mike DePaulo 607d837
-                    GLib.PRIORITY_DEFAULT, timeout, () => {
Mike DePaulo 607d837
-                    this._showLabelTimeoutId = 0;
Mike DePaulo 607d837
-                    actor.disconnect(destroyId);
Mike DePaulo 607d837
-                    this._labelShowing = true;
Mike DePaulo 607d837
-                    item.showLabel();
Mike DePaulo 607d837
-                    return GLib.SOURCE_REMOVE;
Mike DePaulo 607d837
-                });
Mike DePaulo 607d837
-                GLib.Source.set_name_by_id(this._showLabelTimeoutId, '[gnome-shell] item.showLabel');
Mike DePaulo 607d837
-                if (this._resetHoverTimeoutId > 0) {
Mike DePaulo 607d837
-                    GLib.source_remove(this._resetHoverTimeoutId);
Mike DePaulo 607d837
-                    this._resetHoverTimeoutId = 0;
Mike DePaulo 607d837
-                }
Mike DePaulo 607d837
-            }
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-        else {
Mike DePaulo 607d837
-            if (this._showLabelTimeoutId > 0)
Mike DePaulo 607d837
-                GLib.source_remove(this._showLabelTimeoutId);
Mike DePaulo 607d837
-            this._showLabelTimeoutId = 0;
Mike DePaulo 607d837
-            item.hideLabel();
Mike DePaulo 607d837
-            if (this._labelShowing) {
Mike DePaulo 607d837
-                this._resetHoverTimeoutId = GLib.timeout_add(
Mike DePaulo 607d837
-                    GLib.PRIORITY_DEFAULT, DASH_ITEM_HOVER_TIMEOUT, () => {
Mike DePaulo 607d837
-                    this._labelShowing = false;
Mike DePaulo 607d837
-                    this._resetHoverTimeoutId = 0;
Mike DePaulo 607d837
-                    return GLib.SOURCE_REMOVE;
Mike DePaulo 607d837
-                });
Mike DePaulo 607d837
-                GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing');
Mike DePaulo 607d837
-            }
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
     _adjustIconSize() {
Mike DePaulo 607d837
         // For the icon size, we only consider children which are "proper"
Mike DePaulo 607d837
         // icons (i.e. ignoring drag placeholders) and which are not
Mike DePaulo 6928dd2
@@ -960,168 +878,6 @@ var MyDash = GObject.registerClass({
Mike DePaulo 607d837
 
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
 
Mike DePaulo 607d837
-    _clearDragPlaceholder() {
Mike DePaulo 607d837
-        if (this._dragPlaceholder) {
Mike DePaulo 607d837
-            this._animatingPlaceholdersCount++;
Mike DePaulo 607d837
-            this._dragPlaceholder.animateOutAndDestroy();
Mike DePaulo 607d837
-            this._dragPlaceholder.connect('destroy', () => {
Mike DePaulo 607d837
-                this._animatingPlaceholdersCount--;
Mike DePaulo 607d837
-            });
Mike DePaulo 607d837
-            this._dragPlaceholder = null;
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-        this._dragPlaceholderPos = -1;
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    _clearEmptyDropTarget() {
Mike DePaulo 607d837
-        if (this._emptyDropTarget) {
Mike DePaulo 607d837
-            this._emptyDropTarget.animateOutAndDestroy();
Mike DePaulo 607d837
-            this._emptyDropTarget = null;
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    handleDragOver(source, actor, x, y, time) {
Mike DePaulo 607d837
-        let app = Dash.getAppFromSource(source);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // Don't allow favoriting of transient apps
Mike DePaulo 607d837
-        if (app == null || app.is_window_backed())
Mike DePaulo 607d837
-            return DND.DragMotionResult.NO_DROP;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (!this._shellSettings.is_writable('favorite-apps') ||
Mike DePaulo 607d837
-            !Docking.DockManager.settings.get_boolean('show-favorites'))
Mike DePaulo 607d837
-            return DND.DragMotionResult.NO_DROP;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let favorites = AppFavorites.getAppFavorites().getFavorites();
Mike DePaulo 607d837
-        let numFavorites = favorites.length;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let favPos = favorites.indexOf(app);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let children = this._box.get_children();
Mike DePaulo 607d837
-        let numChildren = children.length;
Mike DePaulo 607d837
-        let boxHeight = 0;
Mike DePaulo 607d837
-        for (let i = 0; i < numChildren; i++)
Mike DePaulo 607d837
-            boxHeight += this._isHorizontal?children[i].width:children[i].height;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // Keep the placeholder out of the index calculation; assuming that
Mike DePaulo 607d837
-        // the remove target has the same size as "normal" items, we don't
Mike DePaulo 607d837
-        // need to do the same adjustment there.
Mike DePaulo 607d837
-        if (this._dragPlaceholder) {
Mike DePaulo 607d837
-            boxHeight -= this._isHorizontal?this._dragPlaceholder.width:this._dragPlaceholder.height;
Mike DePaulo 607d837
-            numChildren--;
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let pos;
Mike DePaulo 607d837
-        if (!this._emptyDropTarget) {
Mike DePaulo 607d837
-            pos = Math.floor((this._isHorizontal?x:y) * numChildren / boxHeight);
Mike DePaulo 607d837
-            if (pos >  numChildren)
Mike DePaulo 607d837
-                pos = numChildren;
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-        else
Mike DePaulo 607d837
-            pos = 0; // always insert at the top when dash is empty
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // Take into account childredn position in rtl
Mike DePaulo 607d837
-        if (this._isHorizontal && (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL))
Mike DePaulo 607d837
-            pos = numChildren - pos;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if ((pos != this._dragPlaceholderPos) && (pos <= numFavorites) && (this._animatingPlaceholdersCount == 0)) {
Mike DePaulo 607d837
-            this._dragPlaceholderPos = pos;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-            // Don't allow positioning before or after self
Mike DePaulo 607d837
-            if ((favPos != -1) && (pos == favPos || pos == favPos + 1)) {
Mike DePaulo 607d837
-                this._clearDragPlaceholder();
Mike DePaulo 607d837
-                return DND.DragMotionResult.CONTINUE;
Mike DePaulo 607d837
-            }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-            // If the placeholder already exists, we just move
Mike DePaulo 607d837
-            // it, but if we are adding it, expand its size in
Mike DePaulo 607d837
-            // an animation
Mike DePaulo 607d837
-            let fadeIn;
Mike DePaulo 607d837
-            if (this._dragPlaceholder) {
Mike DePaulo 607d837
-                this._dragPlaceholder.destroy();
Mike DePaulo 607d837
-                fadeIn = false;
Mike DePaulo 607d837
-            }
Mike DePaulo 607d837
-            else
Mike DePaulo 607d837
-                fadeIn = true;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-            this._dragPlaceholder = new Dash.DragPlaceholderItem();
Mike DePaulo 607d837
-            this._dragPlaceholder.child.set_width (this.iconSize);
Mike DePaulo 607d837
-            this._dragPlaceholder.child.set_height (this.iconSize / 2);
Mike DePaulo 607d837
-            this._box.insert_child_at_index(this._dragPlaceholder,
Mike DePaulo 607d837
-                                            this._dragPlaceholderPos);
Mike DePaulo 607d837
-            this._dragPlaceholder.show(fadeIn);
Mike DePaulo 607d837
-            // Ensure the next and previous icon are visible when moving the placeholder
Mike DePaulo 607d837
-            // (I assume there's room for both of them)
Mike DePaulo 607d837
-            if (this._dragPlaceholderPos > 1)
Mike DePaulo 607d837
-                ensureActorVisibleInScrollView(this._scrollView, this._box.get_children()[this._dragPlaceholderPos-1]);
Mike DePaulo 607d837
-            if (this._dragPlaceholderPos < this._box.get_children().length-1)
Mike DePaulo 607d837
-                ensureActorVisibleInScrollView(this._scrollView, this._box.get_children()[this._dragPlaceholderPos+1]);
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // Remove the drag placeholder if we are not in the
Mike DePaulo 607d837
-        // "favorites zone"
Mike DePaulo 607d837
-        if (pos > numFavorites)
Mike DePaulo 607d837
-            this._clearDragPlaceholder();
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (!this._dragPlaceholder)
Mike DePaulo 607d837
-            return DND.DragMotionResult.NO_DROP;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let srcIsFavorite = (favPos != -1);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (srcIsFavorite)
Mike DePaulo 607d837
-            return DND.DragMotionResult.MOVE_DROP;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        return DND.DragMotionResult.COPY_DROP;
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-    /**
Mike DePaulo 607d837
-     * Draggable target interface
Mike DePaulo 607d837
-     */
Mike DePaulo 607d837
-    acceptDrop(source, actor, x, y, time) {
Mike DePaulo 607d837
-        let app = Dash.getAppFromSource(source);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // Don't allow favoriting of transient apps
Mike DePaulo 607d837
-        if (app == null || app.is_window_backed())
Mike DePaulo 607d837
-            return false;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        if (!this._shellSettings.is_writable('favorite-apps') ||
Mike DePaulo 607d837
-            !Docking.DockManager.settings.get_boolean('show-favorites'))
Mike DePaulo 607d837
-            return false;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let id = app.get_id();
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let srcIsFavorite = (id in favorites);
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        let favPos = 0;
Mike DePaulo 607d837
-        let children = this._box.get_children();
Mike DePaulo 607d837
-        for (let i = 0; i < this._dragPlaceholderPos; i++) {
Mike DePaulo 607d837
-            if (this._dragPlaceholder && (children[i] == this._dragPlaceholder))
Mike DePaulo 607d837
-                continue;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-            let childId = children[i].child.app.get_id();
Mike DePaulo 607d837
-            if (childId == id)
Mike DePaulo 607d837
-                continue;
Mike DePaulo 607d837
-            if (childId in favorites)
Mike DePaulo 607d837
-                favPos++;
Mike DePaulo 607d837
-        }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        // No drag placeholder means we don't wan't to favorite the app
Mike DePaulo 607d837
-        // and we are dragging it to its original position
Mike DePaulo 607d837
-        if (!this._dragPlaceholder)
Mike DePaulo 607d837
-            return true;
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
Mike DePaulo 607d837
-            let appFavorites = AppFavorites.getAppFavorites();
Mike DePaulo 607d837
-            if (srcIsFavorite)
Mike DePaulo 607d837
-                appFavorites.moveFavoriteToPos(id, favPos);
Mike DePaulo 607d837
-            else
Mike DePaulo 607d837
-                appFavorites.addFavoriteAtPos(id, favPos);
Mike DePaulo 607d837
-            return false;
Mike DePaulo 607d837
-        });
Mike DePaulo 607d837
-
Mike DePaulo 607d837
-        return true;
Mike DePaulo 607d837
-    }
Mike DePaulo 607d837
-
Mike DePaulo 607d837
     get showAppsButton() {
Mike DePaulo 607d837
         return this._showAppsIcon.toggleButton;
Mike DePaulo 607d837
     }
Mike DePaulo 607d837
-- 
Mike DePaulo 6928dd2
2.25.1
Mike DePaulo 607d837