[gnome-shell] [placeDisplay] Fix dnd regression
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [placeDisplay] Fix dnd regression
- Date: Thu, 18 Mar 2010 17:05:12 +0000 (UTC)
commit ddfe9442fa5d928e871d12f4f3c1144ec8c26129
Author: Florian Müllner <fmuellner src gnome org>
Date: Tue Feb 23 14:25:09 2010 +0100
[placeDisplay] Fix dnd regression
DND from the places section broke with 1c4c3afb when St.Label was
replaced with St.Button.
To fix, replace St.Button with St.Clickable and use a fake_release
when starting a drag.
https://bugzilla.gnome.org/show_bug.cgi?id=609218
data/theme/gnome-shell.css | 10 +++++-
js/ui/placeDisplay.js | 71 ++++++++++++++++++++++++++++++++++---------
2 files changed, 65 insertions(+), 16 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 835042d..3d15322 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -516,10 +516,18 @@ StTooltip {
/* Places */
-.places-actions {
+.places-item-box {
spacing: 4px;
}
+.places-item {
+ padding: 2px;
+}
+
+.places-actions {
+ spacing: 2px;
+}
+
#placesDevices {
padding-top: 4px;
}
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index 67da06c..46f5303 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -408,31 +408,44 @@ DashPlaceDisplayItem.prototype = {
this.name = info.name;
this._info = info;
this._icon = info.iconFactory(PLACES_ICON_SIZE);
- this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
- spacing: 4 });
- let text = new St.Button({ style_class: 'places-item',
- label: info.name,
- x_align: St.Align.START });
- text.connect('clicked', Lang.bind(this, this._onClicked));
- let iconBox = new St.Bin({ child: this._icon, reactive: true });
- iconBox.connect('button-release-event',
- Lang.bind(this, this._onClicked));
- this.actor.append(iconBox, Big.BoxPackFlags.NONE);
- this.actor.append(text, Big.BoxPackFlags.EXPAND);
+
+ this.actor = new St.Clickable({ style_class: 'places-item',
+ reactive: true,
+ x_align: St.Align.START,
+ x_fill: true });
+
+ let box = new St.BoxLayout({ style_class: 'places-item-box' });
+ this.actor.set_child(box);
+
+ let bin = new St.Bin({ child: this._icon });
+ box.add(bin);
+
+ let text = new St.Label({ text: info.name });
+ box.add(text, { expand: true, x_fill: true });
if (info.isRemovable()) {
let removeIcon = St.TextureCache.get_default().load_icon_name ('media-eject', PLACES_ICON_SIZE);
- let removeIconBox = new St.Button({ child: removeIcon,
- reactive: true });
- this.actor.append(removeIconBox, Big.BoxPackFlags.NONE);
+ let removeIconBox = new St.Clickable({ child: removeIcon,
+ reactive: true });
+ box.add(removeIconBox);
removeIconBox.connect('clicked',
Lang.bind(this, function() {
this._info.remove();
}));
}
+ this.actor.connect('clicked', Lang.bind(this, this._onClicked));
+ this.actor.connect('notify::hover',
+ Lang.bind(this, this._onHoverChanged));
+ this.actor.connect('button-press-event',
+ Lang.bind(this, this._onButtonPress));
+ this.actor.connect('button-release-event',
+ Lang.bind(this, this._onButtonRelease));
+
this.actor._delegate = this;
- let draggable = DND.makeDraggable(this.actor);
+ this._dragStartX = null;
+ this._dragStartY = null;
+ this._draggable = DND.makeDraggable(this.actor, true);
},
_onClicked: function(b) {
@@ -440,6 +453,34 @@ DashPlaceDisplayItem.prototype = {
Main.overview.hide();
},
+ _onButtonPress: function(actor, event) {
+ if (event.get_button() != 1)
+ return false;
+
+ let [stageX, stageY] = event.get_coords();
+ this._dragStartX = stageX;
+ this._dragStartY = stageY;
+ },
+
+ _onButtonRelease: function(actor, event) {
+ if (event.get_button() != 1)
+ return false;
+
+ this._dragStartX = null;
+ this._dragStartY = null;
+ },
+
+ _onHoverChanged: function(button) {
+ let hover = button.hover;
+ if (!hover) {
+ if (button.pressed && this._dragStartX != null) {
+ button.fake_release();
+ this._draggable.startDrag(this._dragStartX, this._dragStartY,
+ global.get_current_time());
+ }
+ }
+ },
+
getDragActorSource: function() {
return this._icon;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]