[gnome-shell/gnome-3-8] dash: Grow the empty dash during drag operations



commit 75705b45ef4cef79d92076d003731e6d333cbf4e
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri May 31 17:59:27 2013 +0200

    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 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index ea38d12..775b687 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -800,6 +800,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 554e7db..1ce93db 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -326,6 +326,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,
@@ -441,6 +451,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() {
@@ -457,6 +473,7 @@ const Dash = new Lang.Class({
 
     _endDrag: function() {
         this._clearDragPlaceholder();
+        this._clearEmptyDropTarget();
         this._showAppsIcon.setDragApp(null);
         DND.removeDragMonitor(this._dragMonitor);
     },
@@ -808,6 +825,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);
 
@@ -832,7 +856,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;


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