[gnome-music/wip/mschraal/gtk4: 133/143] window: Fix event controllers
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk4: 133/143] window: Fix event controllers
- Date: Sun, 19 Jan 2020 10:55:32 +0000 (UTC)
commit 6a54ac5e34026b6b7e97529ba3bccf37948e96fe
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Nov 6 23:31:39 2019 +0100
window: Fix event controllers
gnomemusic/window.py | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 0f8a5d32..43300653 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -244,14 +244,16 @@ class Window(Gtk.ApplicationWindow):
self._on_notify_model_id = self._stack.connect(
'notify::visible-child', self._on_notify_mode)
self.connect('destroy', self._notify_mode_disconnect)
- # self._key_press_event_id = self.connect(
- # 'key_press_event', self._on_key_press)
- self._btn_ctrl = Gtk.GestureClick().new()
- self._btn_ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
+ ctrl = Gtk.EventControllerKey()
+ ctrl.connect("key-pressed", self._on_key_pressed)
+ self.add_controller(ctrl)
+
+ ctrl = Gtk.GestureClick().new()
# Mouse button 8 is the back button.
- self._btn_ctrl.props.button = 8
- self._btn_ctrl.connect("pressed", self._on_back_button_pressed)
+ ctrl.props.button = 8
+ ctrl.connect("pressed", self._on_back_button_pressed)
+ self.add_controller(ctrl)
self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
@@ -318,9 +320,8 @@ class Window(Gtk.ApplicationWindow):
view.deselect_all()
@log
- def _on_key_press(self, widget, event):
- modifiers = event.get_state() & Gtk.accelerator_get_default_mod_mask()
- (_, keyval) = event.get_keyval()
+ def _on_key_pressed(self, controller, keyval, keycode, state):
+ modifiers = state & Gtk.accelerator_get_default_mod_mask()
control_mask = Gdk.ModifierType.CONTROL_MASK
shift_mask = Gdk.ModifierType.SHIFT_MASK
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]