[gnome-music/wip/mschraal/gtk-event-controller: 3/7] window: Use Gtk.EventController for back button
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk-event-controller: 3/7] window: Use Gtk.EventController for back button
- Date: Sat, 15 Dec 2018 10:28:51 +0000 (UTC)
commit c2286f86c4a6860add890c9f436ac00f3e4213dd
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Aug 28 20:48:27 2018 +0200
window: Use Gtk.EventController for back button
gnomemusic/window.py | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index aacfb9ed..c4e77d3b 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -217,6 +217,12 @@ class Window(Gtk.ApplicationWindow):
self._key_press_event_id = self.connect(
'key_press_event', self._on_key_press)
+ self._btn_ctrl = Gtk.GestureMultiPress().new(self)
+ self._btn_ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
+ # Mouse button 8 is the back button.
+ self._btn_ctrl.props.button = 8
+ self._btn_ctrl.connect("pressed", self._on_back_button_pressed)
+
# FIXME: In case Grilo is already initialized before the views
# get created, they never receive a 'ready' signal to trigger
# population. To fix this another check was added to baseview
@@ -389,15 +395,8 @@ class Window(Gtk.ApplicationWindow):
self._searchbar.reveal(True)
@log
- def do_button_release_event(self, event):
- """Override default button release event
-
- :param Gdk.EventButton event: Button event
- """
- __, code = event.get_button()
- # Mouse button 8 is the navigation button
- if code == 8:
- self._switch_back_from_childview()
+ def _on_back_button_pressed(self, gesture, n_press, x, y, data=None):
+ self.headerbar._on_back_button_clicked()
@log
def _notify_mode_disconnect(self, data=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]