[gnome-shell] slider: Emit a 'drag-begin' signal when starting to drag



commit 779b1ae8e565087de2203486e4f81288fb6a4aec
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Wed Jan 27 22:35:11 2016 +0000

    slider: Emit a 'drag-begin' signal when starting to drag
    
    We are already emitting a 'drag-end' signal when no more dragging
    is happening, so it makes sense to emit a 'drag-begin' too when
    starting, so that apps interested in implementing different logic
    between those two events can easily do it without needing to deal
    with the underlying 'button-press-event' signal for the actor.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761208

 js/ui/slider.js |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/slider.js b/js/ui/slider.js
index d7ae2f2..02dbfae 100644
--- a/js/ui/slider.js
+++ b/js/ui/slider.js
@@ -137,6 +137,10 @@ const Slider = new Lang.Class({
             this._motionId = this.actor.connect('motion-event', Lang.bind(this, this._motionEvent));
         }
 
+        // We need to emit 'drag-begin' before moving the handle to make
+        // sure that no 'value-changed' signal is emitted before this one.
+        this.emit('drag-begin');
+
         let absX, absY;
         [absX, absY] = event.get_coords();
         this._moveHandle(absX, absY);
@@ -224,6 +228,7 @@ const Slider = new Lang.Class({
             let delta = key == Clutter.KEY_Right ? 0.1 : -0.1;
             this._value = Math.max(0, Math.min(this._value + delta, 1));
             this.actor.queue_repaint();
+            this.emit('drag-begin');
             this.emit('value-changed', this._value);
             this.emit('drag-end');
             return Clutter.EVENT_STOP;


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