[gnome-shell/gbsneto/icon-grid-dnd: 115/117] appIcon: Show folder preview when dragging over



commit 0b6d365fa7b3223a330824e86181ccc5c576c7df
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jul 12 19:32:54 2019 -0300

    appIcon: Show folder preview when dragging over
    
    WIP
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603

 js/ui/appDisplay.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 2fbf4749e..6f87931e7 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -2077,6 +2077,7 @@ var AppIcon = class AppIcon extends BaseViewIcon {
 
         this.actor._delegate = this;
         this._scaleInId = 0;
+        this._folderPreviewId = 0;
 
         delete iconParams['isDraggable'];
 
@@ -2109,6 +2110,11 @@ var AppIcon = class AppIcon extends BaseViewIcon {
     _onDestroy() {
         super._onDestroy();
 
+        if (this._folderPreviewId > 0) {
+            GLib.source_remove(this._folderPreviewId);
+            this._folderPreviewId = 0;
+        }
+
         if (this._stateChangedId > 0)
             this.app.disconnect(this._stateChangedId);
         this._stateChangedId = 0;
@@ -2263,6 +2269,57 @@ var AppIcon = class AppIcon extends BaseViewIcon {
     shouldShowTooltip() {
         return this.actor.hover && (!this._menu || !this._menu.isOpen);
     }
+
+    _showFolderPreview() {
+        this.icon.label.opacity = 0;
+
+        // HACK!!!
+        this.icon._iconBin.save_easing_state();
+        this.icon._iconBin.scale_x = FOLDER_SUBICON_FRACTION;
+        this.icon._iconBin.scale_y = FOLDER_SUBICON_FRACTION;
+        this.icon._iconBin.restore_easing_state();
+    }
+
+    _hideFolderPreview() {
+        this.icon.label.opacity = 255;
+
+        // HACK!!!
+        this.icon._iconBin.save_easing_state();
+        this.icon._iconBin.scale_x = 1.0;
+        this.icon._iconBin.scale_y = 1.0;
+        this.icon._iconBin.restore_easing_state();
+    }
+
+    _setHoveringByDnd(hovering) {
+        if (hovering) {
+            if (this._folderPreviewId > 0)
+                return;
+
+            this._folderPreviewId =
+                GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
+                this._folderPreviewId = 0;
+
+                super._setHoveringByDnd(true);
+                this._showFolderPreview();
+
+                return GLib.SOURCE_REMOVE;
+            });
+        } else {
+            if (this._folderPreviewId > 0) {
+                GLib.source_remove(this._folderPreviewId);
+                this._folderPreviewId = 0;
+            }
+
+            super._setHoveringByDnd(false);
+            this._hideFolderPreview();
+        }
+    }
+
+    _canDropAt(source) {
+        return source != this &&
+               (source instanceof AppIcon) &&
+               (this.view instanceof AllView);
+    }
 };
 Signals.addSignalMethods(AppIcon.prototype);
 


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