[DND] Use Params for DND.makeDraggable()
Replace boolean 'manualMode' with a params object for improved readability and future expansion. https://bugzilla.gnome.org/show_bug.cgi?id=613367
This commit is contained in:
parent
57dd02f6ae
commit
dfb110cd0f
@ -404,7 +404,8 @@ AppWellIcon.prototype = {
|
|||||||
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
||||||
this._menu = null;
|
this._menu = null;
|
||||||
|
|
||||||
this._draggable = DND.makeDraggable(this.actor, true);
|
this._draggable = DND.makeDraggable(this.actor,
|
||||||
|
{ manualMode: true });
|
||||||
this._dragStartX = null;
|
this._dragStartX = null;
|
||||||
this._dragStartY = null;
|
this._dragStartY = null;
|
||||||
|
|
||||||
|
21
js/ui/dnd.js
21
js/ui/dnd.js
@ -6,6 +6,8 @@ const Lang = imports.lang;
|
|||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
|
|
||||||
|
const Params = imports.misc.params;
|
||||||
|
|
||||||
const SNAP_BACK_ANIMATION_TIME = 0.25;
|
const SNAP_BACK_ANIMATION_TIME = 0.25;
|
||||||
|
|
||||||
let eventHandlerActor = null;
|
let eventHandlerActor = null;
|
||||||
@ -27,14 +29,16 @@ function _getEventHandlerActor() {
|
|||||||
return eventHandlerActor;
|
return eventHandlerActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _Draggable(actor, manualMode) {
|
function _Draggable(actor, params) {
|
||||||
this._init(actor, manualMode);
|
this._init(actor, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
_Draggable.prototype = {
|
_Draggable.prototype = {
|
||||||
_init : function(actor, manualMode) {
|
_init : function(actor, params) {
|
||||||
|
params = Params.parse(params, { manualMode: false });
|
||||||
|
|
||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
if (!manualMode)
|
if (!params.manualMode)
|
||||||
this.actor.connect('button-press-event',
|
this.actor.connect('button-press-event',
|
||||||
Lang.bind(this, this._onButtonPress));
|
Lang.bind(this, this._onButtonPress));
|
||||||
|
|
||||||
@ -328,10 +332,13 @@ Signals.addSignalMethods(_Draggable.prototype);
|
|||||||
/**
|
/**
|
||||||
* makeDraggable:
|
* makeDraggable:
|
||||||
* @actor: Source actor
|
* @actor: Source actor
|
||||||
* @manualMode: If given, do not automatically start drag and drop on click
|
* @params: (optional) Additional parameters
|
||||||
*
|
*
|
||||||
* Create an object which controls drag and drop for the given actor.
|
* Create an object which controls drag and drop for the given actor.
|
||||||
|
*
|
||||||
|
* If %manualMode is %true in @params, do not automatically start
|
||||||
|
* drag and drop on click
|
||||||
*/
|
*/
|
||||||
function makeDraggable(actor, manualMode) {
|
function makeDraggable(actor, params) {
|
||||||
return new _Draggable(actor, manualMode);
|
return new _Draggable(actor, params);
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,8 @@ DashPlaceDisplayItem.prototype = {
|
|||||||
this.actor._delegate = this;
|
this.actor._delegate = this;
|
||||||
this._dragStartX = null;
|
this._dragStartX = null;
|
||||||
this._dragStartY = null;
|
this._dragStartY = null;
|
||||||
this._draggable = DND.makeDraggable(this.actor, true);
|
this._draggable = DND.makeDraggable(this.actor,
|
||||||
|
{ manualMode: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
_onClicked: function(b) {
|
_onClicked: function(b) {
|
||||||
|
Loading…
Reference in New Issue
Block a user