[gnome-music/wip/mschraal/gtk-event-controller: 1/2] songsview: Port to event controller
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk-event-controller: 1/2] songsview: Port to event controller
- Date: Thu, 4 Oct 2018 15:07:24 +0000 (UTC)
commit 1acb3735d23292d2da81a90aee68b5e8848eccdc
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Aug 29 13:57:06 2018 +0200
songsview: Port to event controller
gnomemusic/views/songsview.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index 22451bf0..d45e0fe7 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -76,9 +76,12 @@ class SongsView(BaseView):
self._view.props.model = self.model
self._view.props.activate_on_single_click = True
+ self._ctrl = Gtk.GestureMultiPress().new(self._view)
+ self._ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
+ self._ctrl.connect("released", self._on_view_clicked)
+
self._view.get_selection().props.mode = Gtk.SelectionMode.SINGLE
self._view.connect('row-activated', self._on_item_activated)
- self._view.connect('button-release-event', self._on_view_clicked)
view_container.add(self._view)
@@ -208,21 +211,18 @@ class SongsView(BaseView):
self.player.play()
@log
- def _on_view_clicked(self, treeview, event):
- """Ctrl+click on self._view triggers selection mode.
-
- :param Gtk.TreeView treeview: self._view
- :param Gdk.EventButton event: clicked event
- """
+ def _on_view_clicked(self, gesture, n_press, x, y, data=None):
+ """Ctrl+click on self._view triggers selection mode."""
+ _, state = Gtk.get_current_event_state()
modifiers = Gtk.accelerator_get_default_mod_mask()
- if ((event.get_state() & modifiers) == Gdk.ModifierType.CONTROL_MASK
+ if (state & modifiers == Gdk.ModifierType.CONTROL_MASK
and not self.props.selection_mode):
self._on_selection_mode_request()
- if (self.selection_mode
- and not self._star_handler.star_renderer_click):
- path, col, cell_x, cell_y = treeview.get_path_at_pos(
- *event.get_coords())
+ # FIXME: In selection mode, star clicks might still trigger
+ # activation.
+ if self.props.selection_mode:
+ path, col, cell_x, cell_y = self._view.get_path_at_pos(x, y)
iter_ = self.model.get_iter(path)
self.model[iter_][6] = not self.model[iter_][6]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]