GNOME Bugzilla – Bug 721595
Typing should trigger a search
Last modified: 2014-02-10 07:36:08 UTC
It would be very convenient if typing itself triggered the search.
Created attachment 268262 [details] [review] Enables search on typing
Searching seems to work fine as far as I've tested
Review of attachment 268262 [details] [review]: ::: gnomemusic/searchbar.py @@ +57,3 @@ + if self.view: + self.view.filter.refilter() + except AttributeError: Skipping AttributeError here is a bad idea, we need to handle it better. Why would it happen here anyway?
Well, essentially the problem is Searchbar.prepare_search_filter is not called even though the functions are called in the same manner as the search button, hence generating an AttributeError when calling Searchbar.search_entry_changed. Another way to fix it is by adding self.view = None in Searchbar.__init__. Either fix produces the same result. As to why Searchbar.prepare_search_filter is not called, I have no idea. As a side comment, the function Window._show_searchbar violates encapsulation when calling "self.toolbar.searchbar._search_entry.grab_focus". It might be a better approach to create a Searchbar.show_bar which handles the same job.
(In reply to comment #4) > Either fix produces the same result. This is not really safe to do exception catching with 'pass' anyway > Another way to fix it is by adding self.view = None in Searchbar.__init__. Seems like a good idea. Care to update the patch? > It might be a better approach to create a Searchbar.show_bar which handles the same job. Agreed, could you prepare a second patch to improve this?
Created attachment 268449 [details] [review] Enables search on keypress
Thanks, works nice now https://git.gnome.org/browse/gnome-music/commit/?id=67b6c0f6bef20546b78941f41438017f45f77c79 https://git.gnome.org/browse/gnome-music/commit/?h=gnome-3-10&id=adfcde33d9ea428aa585c22ff51f795411b733d6
Even I was trying to code to get the same result. Thanks a lot for getting it done :)