[gnome-shell/gbsneto/icon-grid-dnd: 9/10] appIcon: Show folder preview when dragging over
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 9/10] appIcon: Show folder preview when dragging over
- Date: Tue, 16 Jul 2019 23:43:31 +0000 (UTC)
commit dc59bb65bc1dba6399d5ef7def17d0c071356804
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 | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index b79579f6c..37068cb48 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -2068,6 +2068,7 @@ var AppIcon = class AppIcon extends BaseViewIcon {
this.actor._delegate = this;
this._scaleInId = 0;
+ this._folderPreviewId = 0;
delete iconParams['isDraggable'];
delete iconParams['isDropTarget'];
@@ -2102,6 +2103,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;
@@ -2260,6 +2266,56 @@ var AppIcon = class AppIcon extends BaseViewIcon {
get parentView() {
return this._parentView;
}
+
+ _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 instanceof AppIcon) &&
+ (this._parentView instanceof AllView);
+ }
};
Signals.addSignalMethods(AppIcon.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]