GNOME Bugzilla – Bug 508750
search bar extensibility
Last modified: 2009-03-08 23:49:37 UTC
We have a few different bugs about adding new ways to interpret the search text (bug 320243, bug 348627, probably more), which isn't really possible at the moment. There's also lots of duplicated code to deal with search actions in the various sources. rb-auto-playlist-source, rb-browser-source, rb-static-playlist-source all have some very similar code; the podcast and iradio sources have some variation on that too. My (mostly implemented) plan is: - add a new class for text->query function implementations - attach the search implementation directly to the GtkRadioAction used to select the search, rather than having functions like search_action_to_prop everywhere - in addition to the get_search_actions method on the source, emit a signal from some well-known object to allow plugins to add more search actions Aside from consolidating a lot of search-related code in rb-source-header.c, this means a plugin can add a new arbitrarily complex text->query function and insert a corresponding action into the search bar, without the source having to know anything about it.
Created attachment 102724 [details] [review] search rework Pretty much as described above. To make this available to plugins, I've added two signals on the RBSourceHeader object: get_search_actions, which returns a list of additional search actions for the selected source, and refresh_search_bar, which is an action signal (emitted by other objects) that rebuilds the search bar. Plugins need to call refresh_search_bar on activation and probably on deactivation too.
Created attachment 102725 [details] [review] it works Just to show it works, this is a python plugin that adds a 'location' search action to all sources. It doesn't create the search query itself, but that's easy enough to do.
No point leaving this here gathering dust..