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



commit a588db59920ef015acb283c7c75388a76b81535b
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 | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 97b810f4..083bb843 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -109,25 +109,30 @@ class DiscBox(Gtk.ListBoxRow):
             "show-song-numbers", song_widget, "show-song-number",
             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
 
-    def _song_activated(self, widget, event):
+    @log
+    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]