[gnome-music/wip/mschraal/gtk-event-controller: 74/79] smoothscale: Use Gtk.EventController
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk-event-controller: 74/79] smoothscale: Use Gtk.EventController
- Date: Thu, 4 Oct 2018 15:05:35 +0000 (UTC)
commit ecb184d21a5d7ed9066822778363c4adca4aa90c
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Aug 11 12:12:48 2018 +0200
smoothscale: Use Gtk.EventController
gnomemusic/widgets/smoothscale.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index b9d6cb30..8e8ccef0 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -62,9 +62,11 @@ class SmoothScale(Gtk.Scale):
self._timeout = None
- self.connect('button-press-event', self._on_smooth_scale_event)
- self.connect(
- 'button-release-event', self._on_smooth_scale_button_released)
+ self._controller = Gtk.GestureMultiPress().new(self)
+ self._controller.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
+ self._controller.connect("pressed", self._on_button_pressed)
+ self._controller.connect("released", self._on_button_released)
+
self.connect('change-value', self._on_smooth_scale_seek)
# FIXME: This is a workaround for not being able to pass the player
@@ -155,19 +157,21 @@ class SmoothScale(Gtk.Scale):
return True
@log
- def _on_smooth_scale_button_released(self, scale, data):
+ def _on_button_released(self, gesture, n_press, x, y, data=None):
if self._seek_timeout:
GLib.source_remove(self._seek_timeout)
self._on_smooth_scale_seek_finish(
self.get_value())
self._update_position_callback()
+
return False
@log
- def _on_smooth_scale_event(self, scale, data):
+ def _on_button_pressed(self, gesture, n_press, x, y, data=None):
self._remove_timeout()
self._old_smooth_scale_value = self.get_value()
+
return False
@log
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]