GNOME Bugzilla – Bug 729518
Add search provider to do computation
Last modified: 2014-05-28 21:37:30 UTC
Similarly to what Spotlight can do on OSX, it would be nice if typing "1 + 1" in GNOME shell's search entry would show a result of "2" in the calculator's search results. Clicking on it would launch the calculator with the operation loaded in. See also: http://lifehacker.com/323584/calculate-with-spotlight
There are gnome-shell extensions available for this usecase. What we can have is get the appropriate extension to be included in the default Gnome-shell extensions distribution. The support for having Calculator launched with given expression has already been added.
I was actually thinking of search provider, not a shell extension. I'd like it to be disableable from the Search settings panel, and I'd like it to be enabled by default when the calculator is used.
Created attachment 276310 [details] [review] Add a search provider The search provider will display exactly one result if and only if the search term can be converted to an equation of the form recognized by GNOME Calculator. If a result is activated, Calculator will be launched displaying the equation. To test the patch if installing to /usr/local, run sudo cp /usr/local/share/gnome-shell/search-providers/gnome-calculator-search-provider.ini /usr/share/gnome-shell/search-providers/ after installing.
Created attachment 276311 [details] screenshot Sample screenshot, hopefully demonstrates that search provider works better than a shell extension Bastien, do you want me to associate the Calculator icon with the search result? This would create a second Calculator icon immediately to the left of the result, so there would be two Calculator icons total (like there is for Web in this screenshot). This seems a bit silly to me so I did not add it, but I think all other applications do this.
Created attachment 276332 [details] [review] Add a search provider The search provider will display exactly one result if and only if the search term can be converted to an equation of the form recognized by GNOME Calculator. If a result is activated, Calculator will be launched displaying the equation.
Review of attachment 276332 [details] [review]: ::: search-provider/search-provider.vala @@ +24,3 @@ + int exit_status; + Process.spawn_command_line_sync ( + "gnome-calculator --solve '" + terms_to_equation (terms) + "'", This definitely needs to use g_shell_quote() instead of doing the quoting by hand.
Created attachment 276347 [details] [review] Add a search provider Thanks, fixed.
Review of attachment 276347 [details] [review]: Committed. Thank you.. :)
Bastien Nocera, Thank you for the feature request. This feature is implemented, and will be available with next version of Calculator. Thank you, again.. :)