[gnome-shell] [DND] Use Params for DND.makeDraggable()



commit dfb110cd0f64d90f006773ca76a4a6b96aa00939
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Mar 22 15:25:43 2010 -0400

    [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

 js/ui/appDisplay.js   |    3 ++-
 js/ui/dnd.js          |   21 ++++++++++++++-------
 js/ui/placeDisplay.js |    3 ++-
 3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index b980460..ab06c35 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -404,7 +404,8 @@ AppWellIcon.prototype = {
         this.actor.connect('clicked', Lang.bind(this, this._onClicked));
         this._menu = null;
 
-        this._draggable = DND.makeDraggable(this.actor, true);
+        this._draggable = DND.makeDraggable(this.actor,
+                                            { manualMode: true });
         this._dragStartX = null;
         this._dragStartY = null;
 
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index bfd3010..f64dc75 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -6,6 +6,8 @@ const Lang = imports.lang;
 const Signals = imports.signals;
 const Tweener = imports.ui.tweener;
 
+const Params = imports.misc.params;
+
 const SNAP_BACK_ANIMATION_TIME = 0.25;
 
 let eventHandlerActor = null;
@@ -27,14 +29,16 @@ function _getEventHandlerActor() {
     return eventHandlerActor;
 }
 
-function _Draggable(actor, manualMode) {
-    this._init(actor, manualMode);
+function _Draggable(actor, params) {
+    this._init(actor, params);
 }
 
 _Draggable.prototype = {
-    _init : function(actor, manualMode) {
+    _init : function(actor, params) {
+        params = Params.parse(params, { manualMode: false });
+
         this.actor = actor;
-        if (!manualMode)
+        if (!params.manualMode)
             this.actor.connect('button-press-event',
                                Lang.bind(this, this._onButtonPress));
 
@@ -328,10 +332,13 @@ Signals.addSignalMethods(_Draggable.prototype);
 /**
  * makeDraggable:
  * @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.
+ *
+ * If %manualMode is %true in @params, do not automatically start
+ * drag and drop on click
  */
-function makeDraggable(actor, manualMode) {
-    return new _Draggable(actor, manualMode);
+function makeDraggable(actor, params) {
+    return new _Draggable(actor, params);
 }
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index a7a35d1..99aecec 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -445,7 +445,8 @@ DashPlaceDisplayItem.prototype = {
         this.actor._delegate = this;
         this._dragStartX = null;
         this._dragStartY = null;
-        this._draggable = DND.makeDraggable(this.actor, true);
+        this._draggable = DND.makeDraggable(this.actor,
+                                            { manualMode: true });
     },
 
     _onClicked: function(b) {



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