@@ -5,7 +5,6 @@ const GLib = imports.gi.GLib;
55const GObject = imports . gi . GObject ;
66const Gtk = imports . gi . Gtk ;
77const St = imports . gi . St ;
8- const Lang = imports . lang ;
98const Cinnamon = imports . gi . Cinnamon ;
109const Signals = imports . signals ;
1110const Tweener = imports . ui . tweener ;
@@ -77,10 +76,8 @@ function isDragging() {
7776 return currentDraggable != null ;
7877}
7978
80- var _Draggable = new Lang . Class ( {
81- Name : 'Draggable' ,
82-
83- _init : function ( actor , params , target ) {
79+ var _Draggable = class Draggable {
80+ constructor ( actor , params , target ) {
8481 params = Params . parse ( params , { manualMode : false ,
8582 restoreOnSuccess : false ,
8683 overrideX : undefined ,
@@ -105,15 +102,15 @@ var _Draggable = new Lang.Class({
105102
106103 if ( ! params . manualMode )
107104 this . buttonPressEventId = this . actor . connect ( 'button-press-event' ,
108- Lang . bind ( this , this . _onButtonPress ) ) ;
105+ this . _onButtonPress . bind ( this ) ) ;
109106
110- this . destroyEventId = this . actor . connect ( 'destroy' , Lang . bind ( this , function ( ) {
107+ this . destroyEventId = this . actor . connect ( 'destroy' , ( ) => {
111108 this . _actorDestroyed = true ;
112109
113110 if ( this . _dragInProgress && this . _dragCancellable )
114111 this . _cancelDrag ( null ) ;
115112 this . disconnectAll ( ) ;
116- } ) ) ;
113+ } ) ;
117114 this . _onEventId = null ;
118115
119116 this . _restoreOnSuccess = params . restoreOnSuccess ;
@@ -128,9 +125,9 @@ var _Draggable = new Lang.Class({
128125 this . _dragCancellable = true ;
129126
130127 this . _eventsGrabbed = false ;
131- } ,
128+ }
132129
133- _onButtonPress : function ( actor , event ) {
130+ _onButtonPress ( actor , event ) {
134131 if ( this . inhibit )
135132 return false ;
136133
@@ -157,16 +154,16 @@ var _Draggable = new Lang.Class({
157154 this . _dragStartY = stageY ;
158155
159156 return false ;
160- } ,
157+ }
161158
162- _grabActor : function ( event ) {
159+ _grabActor ( event ) {
163160 this . drag_device = event . get_device ( ) ;
164161 this . drag_device . grab ( this . actor ) ;
165162 this . _onEventId = this . actor . connect ( 'event' ,
166- Lang . bind ( this , this . _onEvent ) ) ;
167- } ,
163+ this . _onEvent . bind ( this ) ) ;
164+ }
168165
169- _ungrabActor : function ( event ) {
166+ _ungrabActor ( event ) {
170167 if ( ! this . _onEventId )
171168 return ;
172169
@@ -178,27 +175,27 @@ var _Draggable = new Lang.Class({
178175
179176 this . actor . disconnect ( this . _onEventId ) ;
180177 this . _onEventId = null ;
181- } ,
178+ }
182179
183- _grabEvents : function ( event ) {
180+ _grabEvents ( event ) {
184181 if ( ! this . _eventsGrabbed ) {
185182 this . _eventsGrabbed = Main . pushModal ( _getEventHandlerActor ( ) , undefined , undefined , Cinnamon . ActionMode . NORMAL ) ;
186183 if ( this . _eventsGrabbed ) {
187184 this . drag_device = event . get_device ( )
188185 this . drag_device . grab ( _getEventHandlerActor ( ) ) ;
189186 }
190187 }
191- } ,
188+ }
192189
193- _ungrabEvents : function ( ) {
190+ _ungrabEvents ( ) {
194191 if ( this . _eventsGrabbed ) {
195192 this . drag_device . ungrab ( ) ;
196193 Main . popModal ( _getEventHandlerActor ( ) ) ;
197194 this . _eventsGrabbed = false ;
198195 }
199- } ,
196+ }
200197
201- _onEvent : function ( actor , event ) {
198+ _onEvent ( actor , event ) {
202199 // We intercept BUTTON_RELEASE event to know that the button was released in case we
203200 // didn't start the drag, to drop the draggable in case the drag was in progress, and
204201 // to complete the drag and ensure that whatever happens to be under the pointer does
@@ -239,7 +236,7 @@ var _Draggable = new Lang.Class({
239236 }
240237
241238 return false ;
242- } ,
239+ }
243240
244241 /**
245242 * fakeRelease:
@@ -249,10 +246,10 @@ var _Draggable = new Lang.Class({
249246 * actors for other purposes (for example if you're using
250247 * PopupMenu.ignoreRelease())
251248 */
252- fakeRelease : function ( ) {
249+ fakeRelease ( ) {
253250 this . _buttonDown = false ;
254251 this . _ungrabActor ( ) ;
255- } ,
252+ }
256253
257254 /**
258255 * startDrag:
@@ -264,7 +261,7 @@ var _Draggable = new Lang.Class({
264261 * This function is useful to call if you've specified manualMode
265262 * for the draggable.
266263 */
267- startDrag : function ( stageX , stageY , event ) {
264+ startDrag ( stageX , stageY , event ) {
268265 currentDraggable = this ;
269266 this . _dragInProgress = true ;
270267
@@ -378,9 +375,9 @@ var _Draggable = new Lang.Class({
378375 } ) ;
379376 }
380377 }
381- } ,
378+ }
382379
383- _maybeStartDrag : function ( event ) {
380+ _maybeStartDrag ( event ) {
384381 let [ stageX , stageY ] = event . get_coords ( ) ;
385382
386383 // See if the user has moved the mouse enough to trigger a drag
@@ -392,9 +389,9 @@ var _Draggable = new Lang.Class({
392389 }
393390
394391 return true ;
395- } ,
392+ }
396393
397- _updateDragHover : function ( ) {
394+ _updateDragHover ( ) {
398395 this . _updateHoverId = 0 ;
399396 let target = null ;
400397 let result = null ;
@@ -459,17 +456,17 @@ var _Draggable = new Lang.Class({
459456 if ( result in DRAG_CURSOR_MAP ) global . set_cursor ( DRAG_CURSOR_MAP [ result ] ) ;
460457 else global . set_cursor ( Cinnamon . Cursor . NO_DROP ) ;
461458 return false ;
462- } ,
459+ }
463460
464- _queueUpdateDragHover : function ( ) {
461+ _queueUpdateDragHover ( ) {
465462 if ( this . _updateHoverId )
466463 return ;
467464
468465 this . _updateHoverId = GLib . idle_add ( GLib . PRIORITY_DEFAULT ,
469- Lang . bind ( this , this . _updateDragHover ) ) ;
470- } ,
466+ this . _updateDragHover . bind ( this ) ) ;
467+ }
471468
472- _updateDragPosition : function ( event ) {
469+ _updateDragPosition ( event ) {
473470 let [ stageX , stageY ] = event . get_coords ( ) ;
474471 this . _dragX = stageX ;
475472 this . _dragY = stageY ;
@@ -478,17 +475,17 @@ var _Draggable = new Lang.Class({
478475
479476 this . _queueUpdateDragHover ( ) ;
480477 return true ;
481- } ,
478+ }
482479
483- _setDragActorPosition : function ( ) {
480+ _setDragActorPosition ( ) {
484481 this . _dragActor . x = this . _overrideX == undefined ?
485482 this . _dragX + this . _dragOffsetX : this . _overrideX ;
486483
487484 this . _dragActor . y = this . _overrideY == undefined ?
488485 this . _dragY + this . _dragOffsetY : this . _overrideY ;
489- } ,
486+ }
490487
491- _dragActorDropped : function ( event ) {
488+ _dragActorDropped ( event ) {
492489 let [ dropX , dropY ] = event . get_coords ( ) ;
493490 let target = null ;
494491
@@ -557,9 +554,9 @@ var _Draggable = new Lang.Class({
557554 this . _cancelDrag ( event ) ;
558555
559556 return true ;
560- } ,
557+ }
561558
562- _getRestoreLocation : function ( ) {
559+ _getRestoreLocation ( ) {
563560 let x , y , scale ;
564561
565562 if ( this . _dragActorSource && this . _dragActorSource . visible ) {
@@ -589,9 +586,9 @@ var _Draggable = new Lang.Class({
589586 }
590587
591588 return [ x , y , scale ] ;
592- } ,
589+ }
593590
594- _cancelDrag : function ( event ) {
591+ _cancelDrag ( event ) {
595592 let eventTime ;
596593 if ( event !== null ) {
597594 eventTime = event . get_time ( ) ;
@@ -627,9 +624,9 @@ var _Draggable = new Lang.Class({
627624 this . _onAnimationComplete ( this . _dragActor , eventTime ) ;
628625 }
629626 } ) ;
630- } ,
627+ }
631628
632- _restoreDragActor : function ( eventTime ) {
629+ _restoreDragActor ( eventTime ) {
633630 this . _dragInProgress = false ;
634631 let [ restoreX , restoreY , restoreScale ] = this . _getRestoreLocation ( ) ;
635632
@@ -648,9 +645,9 @@ var _Draggable = new Lang.Class({
648645 this . _onAnimationComplete ( this . _dragActor , eventTime ) ;
649646 }
650647 } ) ;
651- } ,
648+ }
652649
653- _onAnimationComplete : function ( dragActor , eventTime ) {
650+ _onAnimationComplete ( dragActor , eventTime ) {
654651 if ( this . _dragOrigParent ) {
655652 global . reparentActor ( dragActor , this . _dragOrigParent ) ;
656653 dragActor . set_scale ( this . _dragOrigScale , this . _dragOrigScale ) ;
@@ -664,9 +661,9 @@ var _Draggable = new Lang.Class({
664661 this . _animationInProgress = false ;
665662 if ( ! this . _buttonDown )
666663 this . _dragComplete ( ) ;
667- } ,
664+ }
668665
669- _dragComplete : function ( ) {
666+ _dragComplete ( ) {
670667 if ( this . _dragOrigParent )
671668 Cinnamon . util_set_hidden_from_pick ( this . _dragActor , false ) ;
672669
@@ -681,7 +678,7 @@ var _Draggable = new Lang.Class({
681678 this . _dragActor = undefined ;
682679 currentDraggable = null ;
683680 }
684- } ) ;
681+ } ;
685682
686683Signals . addSignalMethods ( _Draggable . prototype ) ;
687684
0 commit comments