[gnome-music/wip/jfelder/gtk4-v3] searchheaderbar: Ensure that the entry gets the first key press



commit 4e84244c004f3d125beb664681fe81308bb41a95
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Feb 11 21:16:33 2022 +0100

    searchheaderbar: Ensure that the entry gets the first key press

 gnomemusic/widgets/searchheaderbar.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gnomemusic/widgets/searchheaderbar.py b/gnomemusic/widgets/searchheaderbar.py
index 4ec9ae89d..80d05a65e 100644
--- a/gnomemusic/widgets/searchheaderbar.py
+++ b/gnomemusic/widgets/searchheaderbar.py
@@ -22,12 +22,17 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
+from __future__ import annotations
+
 from enum import IntEnum
+import typing
 
 from gi.repository import Adw, GLib, GObject, Gtk
 
 from gnomemusic.search import Search
 from gnomemusic.widgets.headerbar import HeaderBar, SelectionBarMenuButton
+if typing.TYPE_CHECKING:
+    from gnomemusic.application import Application
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/SearchHeaderBar.ui")
@@ -101,6 +106,16 @@ class SearchHeaderBar(Adw.Bin):
 
         self._entry.connect("search-changed", self._search_entry_changed)
 
+        self._win_id = application.connect(
+            "notify::window", self._on_window_ready)
+
+    def _on_window_ready(
+            self, application: Application,
+            value: GObject.ParamSpecObject) -> None:
+        self._entry.set_key_capture_widget(application.props.window)
+        application.disconnect(self._win_id)
+        self._win_id = 0
+
     @GObject.Property(type=bool, default=False)
     def selection_mode(self):
         """Selection mode


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]