[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
This commit is contained in:
parent
8b792f8942
commit
ddfe9442fa
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user