GNOME Bugzilla – Bug 743586
Startup applications: Quick search when adding an application
Last modified: 2015-02-23 10:58:25 UTC
Currently when adding an application for startup using the gui there is no search functionality (at least not that I am aware of). It would be nice to have either a search bar or just filter when the user starts typing. I might add a patch fixing this if get time.
Created attachment 295798 [details] [review] Proposed patch
Review of attachment 295798 [details] [review]: Thanks ::: gtweak/tweaks/tweak_group_startup.py @@ +38,3 @@ self._all = {} + self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks...")) certainly not "Tweaks" @@ +39,3 @@ + self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks...")) + self.entry.set_size_request(300, -1) set_width_chars() is better for this purpose @@ +125,3 @@ return row + def _list_filter_func(self, row, user_data): please use a better name than user_data here, e.g. txt is ok @@ +130,3 @@ + if type(sib) == Gtk.Label: + if user_data in sib.get_text().lower(): + return row return True @@ +131,3 @@ + if user_data in sib.get_text().lower(): + return row + return None return False @@ +134,3 @@ + + def _on_search(self, entry): + txt = entry.get_text().decode("utf-8", "ignore").lower() the decode() call isn't needed @@ +137,3 @@ + self.listbox.set_filter_func(self._list_filter_func, txt) + + def _on_key_press(self, widget, event): There should be a searchbar.handle_event() here. Also, please add return True/False appropriately on all code paths.
Created attachment 296867 [details] [review] Updated patch Fixed. Also removed _search_cb and replaced it with a lambda (I hadn't realized about the invalidate_filter() method of ListBox). I didn't known about `searchbar.handle_event` until tonight, I'm still unfamiliar with many of the Gtk methods. Thanks, Isaac
On second thought, is it OK to use lambda there because it will always return None (False)?
Review of attachment 296867 [details] [review]: (In reply to Isaac Lenton from comment #4) > On second thought, is it OK to use lambda there because it will always > return None (False)? That's fine since the search-changed signal handler doesn't need to return anything. ::: gtweak/tweaks/tweak_group_startup.py @@ +144,3 @@ + elif self.searchbar.get_search_mode(): + self.entry.grab_focus() + return True You should return True on both branches and then here return False, otherwise you can't ever cancel the dialog with escape
Created attachment 296901 [details] [review] Updated patch Updated the patch with ability to cancel the dialog using escape. I also added code for the searchentry to capture focus when visible and something else has focus. I feel adding this additional code is a little redundant, should I file a bug against Gtk requesting the desired functionality?
Review of attachment 296901 [details] [review]: looks fine
(In reply to Isaac Lenton from comment #6) > I also added code for the searchentry to capture focus when visible and > something else has focus. I feel adding this additional code is a little > redundant, should I file a bug against Gtk requesting the desired > functionality? Yes, GtkSearchBar/GtkSearchEntry could probably do a better job here. Please do
*** Bug 739932 has been marked as a duplicate of this bug. ***