[gnome-music/wip/mschraal/gtk4: 59/66] disclistboxwidget: Make song_widget click controller somewhat work



commit e64bb122b8531c45e7b926c6514bedfbee208d69
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Oct 31 22:14:56 2019 +0100

    disclistboxwidget: Make song_widget click controller somewhat work

 gnomemusic/widgets/disclistboxwidget.py | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index d00fd276..c5e337dd 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -105,26 +105,29 @@ class DiscBox(Gtk.Box):
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
 
-        # song_widget.connect('button-release-event', self._song_activated)
+        ctrl = Gtk.GestureClick()
+        song_widget.add_controller(ctrl)
+        ctrl.connect("released", self._song_activated)
 
         return song_widget
 
     @log
-    def _song_activated(self, widget, event):
+    def _song_activated(self, controller, n_click, x, y):
+        widget = controller.get_widget()
         if widget.props.select_click:
             widget.props.select_click = False
             return
 
-        mod_mask = Gtk.accelerator_get_default_mod_mask()
-        if ((event.get_state() & mod_mask) == Gdk.ModifierType.CONTROL_MASK
-                and not self.props.selection_mode
-                and self.props.selection_mode_allowed):
-            self.props.selection_mode = True
-            widget.props.select_click = True
-            widget.props.coresong.props.selected = True
-            return
+        # mod_mask = Gtk.accelerator_get_default_mod_mask()
+        # if ((event.get_state() & mod_mask) == Gdk.ModifierType.CONTROL_MASK
+        #         and not self.props.selection_mode
+        #         and self.props.selection_mode_allowed):
+        #     self.props.selection_mode = True
+        #     widget.props.select_click = True
+        #     widget.props.coresong.props.selected = True
+        #     return
 
-        (_, button) = event.get_button()
+        button = controller.get_current_button()
         if (button == Gdk.BUTTON_PRIMARY
                 and not self.props.selection_mode):
             self.emit('song-activated', widget)


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