[gnome-music/wip/mschraal/gtk4: 41/84] disclistboxwidget: Make song_widget click controller somewhat work
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk4: 41/84] disclistboxwidget: Make song_widget click controller somewhat work
- Date: Tue, 9 Jun 2020 14:24:14 +0000 (UTC)
commit 156d4184bab269f9bce7040abb7e9e3e75be0f32
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 | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 02244e91..56498ad7 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -89,7 +89,9 @@ class DiscBox(Gtk.ListBoxRow):
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)
row = Gtk.ListBoxRow()
row.props.activatable = False
@@ -98,20 +100,22 @@ class DiscBox(Gtk.ListBoxRow):
return row
- 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):
- 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):
+ # 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]