[gnome-music/wip/jfelder/gtk4-v3] searchheaderbar: Use entry search-changed signal
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gtk4-v3] searchheaderbar: Use entry search-changed signal
- Date: Fri, 11 Feb 2022 20:24:35 +0000 (UTC)
commit b17663554d9afac30b0a2a753c2239f3378208e8
Author: Jean Felder <jfelder src gnome org>
Date: Fri Feb 11 20:44:59 2022 +0100
searchheaderbar: Use entry search-changed signal
Contrary to the changed signal, this does not react to every change
in the entry text immediately, but only after a short delay.
This allows to remove the timeout logic.
gnomemusic/widgets/searchheaderbar.py | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/widgets/searchheaderbar.py b/gnomemusic/widgets/searchheaderbar.py
index 30319b03e..5c71148af 100644
--- a/gnomemusic/widgets/searchheaderbar.py
+++ b/gnomemusic/widgets/searchheaderbar.py
@@ -59,7 +59,6 @@ class SearchHeaderBar(Adw.Bin):
self._coregrilo = application.props.coregrilo
self._selection_mode = False
- self._timeout = None
self._entry = Gtk.SearchEntry()
self._entry.props.halign = Gtk.Align.CENTER
@@ -100,7 +99,7 @@ class SearchHeaderBar(Adw.Bin):
"notify::search-mode-active", self._on_search_mode_changed)
self.connect("notify::search-state", self._search_state_changed)
- self._entry.connect("changed", self._search_entry_timeout)
+ self._entry.connect("search-changed", self._search_entry_changed)
@GObject.Property(type=bool, default=False)
def selection_mode(self):
@@ -175,16 +174,7 @@ class SearchHeaderBar(Adw.Bin):
else:
self._select_button.props.sensitive = False
- def _search_entry_timeout(self, widget):
- if self._timeout:
- GLib.source_remove(self._timeout)
-
- self._timeout = GLib.timeout_add(
- 500, self._search_entry_changed, widget)
-
- def _search_entry_changed(self, widget):
- self._timeout = None
-
+ def _search_entry_changed(self, widget: Gtk.SearchEntry) -> bool:
search_term = self._entry.get_text()
if search_term != "":
self.props.stack.set_visible_child_name("search")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]