From 90c787634139aa89e9449c3b5f51ef7fdf50cb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 31 May 2013 17:59:27 +0200 Subject: [PATCH] dash: Grow the empty dash during drag operations When the dash does not contain any applications (either favorites or running), it is currently impossable to add a favorite via DND. Grow the dash slightly in that case to provide a drop target. https://bugzilla.gnome.org/show_bug.cgi?id=684618 --- data/theme/gnome-shell.css | 5 +++++ js/ui/dash.js | 30 +++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index bcf4bfbfa..785cac484 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -804,6 +804,11 @@ StScrollBar StButton#vhandle:active { height: 24px; } +.empty-dash-drop-target { + width: 24px; + height: 24px; +} + /* Search Box */ #searchEntry { diff --git a/js/ui/dash.js b/js/ui/dash.js index a916de1ad..498bd7a63 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -320,6 +320,16 @@ const DragPlaceholderItem = new Lang.Class({ } }); +const EmptyDropTargetItem = new Lang.Class({ + Name: 'EmptyDropTargetItem', + Extends: DashItemContainer, + + _init: function() { + this.parent(); + this.setChild(new St.Bin({ style_class: 'empty-dash-drop-target' })); + } +}); + const DashActor = new Lang.Class({ Name: 'DashActor', Extends: St.Widget, @@ -435,6 +445,12 @@ const Dash = new Lang.Class({ dragMotion: Lang.bind(this, this._onDragMotion) }; DND.addDragMonitor(this._dragMonitor); + + if (this._box.get_n_children() == 0) { + this._emptyDropTarget = new EmptyDropTargetItem(); + this._box.insert_child_at_index(this._emptyDropTarget, 0); + this._emptyDropTarget.show(true); + } }, _onDragCancelled: function() { @@ -451,6 +467,7 @@ const Dash = new Lang.Class({ _endDrag: function() { this._clearDragPlaceholder(); + this._clearEmptyDropTarget(); this._showAppsIcon.setDragApp(null); DND.removeDragMonitor(this._dragMonitor); }, @@ -802,6 +819,13 @@ const Dash = new Lang.Class({ this._dragPlaceholderPos = -1; }, + _clearEmptyDropTarget: function() { + if (this._emptyDropTarget) { + this._emptyDropTarget.animateOutAndDestroy(); + this._emptyDropTarget = null; + } + }, + handleDragOver : function(source, actor, x, y, time) { let app = getAppFromSource(source); @@ -826,7 +850,11 @@ const Dash = new Lang.Class({ numChildren--; } - let pos = Math.floor(y * numChildren / boxHeight); + let pos; + if (!this._emptyDropTarget) + pos = Math.floor(y * numChildren / boxHeight); + else + pos = 0; // always insert at the top when dash is empty if (pos != this._dragPlaceholderPos && pos <= numFavorites && this._animatingPlaceholdersCount == 0) { this._dragPlaceholderPos = pos;