[gnome-shell] dash: Grow the empty dash during drag operations
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dash: Grow the empty dash during drag operations
- Date: Wed, 5 Jun 2013 13:33:38 +0000 (UTC)
commit 90c787634139aa89e9449c3b5f51ef7fdf50cb46
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 bcf4bfb..785cac4 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 a916de1..498bd7a 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]