After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 655220 - Search providers can't be asynchronous
Search providers can't be asynchronous
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks: 645326 655831
 
 
Reported: 2011-07-24 19:30 UTC by Philippe Normand
Modified: 2011-08-30 15:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
search: support for asynchronous search providers (9.12 KB, patch)
2011-07-24 19:31 UTC, Philippe Normand
reviewed Details | Review
Add support for asynchronous search providers (8.82 KB, patch)
2011-07-24 21:18 UTC, Philippe Normand
committed Details | Review
Sample Asynchronous Search Provider (3.34 KB, patch)
2011-07-26 20:55 UTC, Philippe Normand
reviewed Details | Review
Sample Asynchronous Search Provider (2.56 KB, patch)
2011-08-08 10:02 UTC, Philippe Normand
rejected Details | Review

Description Philippe Normand 2011-07-24 19:30:49 UTC
Relevant patch from Bug 640659 will be reviewed here :)
Comment 1 Philippe Normand 2011-07-24 19:31:37 UTC
Created attachment 192573 [details] [review]
search: support for asynchronous search providers

Original patch by Jasper St. Pierre and Seif Lofty.
I reworked this a bit to apply on master and did some adaptations
based on Jasper's review.
Comment 2 Philippe Normand 2011-07-24 19:38:00 UTC
I've been using this patch for a new extension adding a Grilo SearchProvider which I plan to upload to Bugzilla soon :)
Comment 3 Jasper St. Pierre (not reading bugmail) 2011-07-24 20:00:01 UTC
Review of attachment 192573 [details] [review]:

Your commit message shouldn't explain the history of the patch or the reviews. It should explain the motivation behind the change. In this case:

  Add support for asynchronous search providers

  Some search providers may want to change their results, or may
  not want to block on an external service to get their results (DBus, etc.)
  Set up an infrastructure to allow search providers to add their search
  results at a later time.

  Based on a patch by Jasper St. Pierre and Seif Lotfy.

::: js/ui/searchDisplay.js
@@ -266,3 @@
                                    style_class: 'dash-search-button-label' });
 
-        button.label_actor = title;

Why?

@@ +370,3 @@
+            if (providerResults.length == 0)
+                this._clearDisplayForProvider(i);
+            else {

nit: braces on both sides, or no braces on both sides.

@@ +371,3 @@
+                this._clearDisplayForProvider(i);
+            else {
+                if (this._providerMetaResults[provider.title] != providerResults) {

Array equality always returns false, so this is broken.
Comment 4 Philippe Normand 2011-07-24 21:17:16 UTC
(In reply to comment #3)
> Review of attachment 192573 [details] [review]:
> 
> Your commit message shouldn't explain the history of the patch or the reviews.
> It should explain the motivation behind the change. In this case:
> 
>   Add support for asynchronous search providers
> 
>   Some search providers may want to change their results, or may
>   not want to block on an external service to get their results (DBus, etc.)
>   Set up an infrastructure to allow search providers to add their search
>   results at a later time.
> 
>   Based on a patch by Jasper St. Pierre and Seif Lotfy.

All right.

> 
> ::: js/ui/searchDisplay.js
> @@ -266,3 @@
>                                     style_class: 'dash-search-button-label' });
> 
> -        button.label_actor = title;
> 
> Why?

That one slipped in by accident. Will restore it!

> 
> @@ +370,3 @@
> +            if (providerResults.length == 0)
> +                this._clearDisplayForProvider(i);
> +            else {
> 
> nit: braces on both sides, or no braces on both sides.
> 
> @@ +371,3 @@
> +                this._clearDisplayForProvider(i);
> +            else {
> +                if (this._providerMetaResults[provider.title] !=
> providerResults) {
> 
> Array equality always returns false, so this is broken.

Ok.
I'll update the patch. Thanks for the quick review!
Comment 5 Philippe Normand 2011-07-24 21:18:05 UTC
Created attachment 192586 [details] [review]
Add support for asynchronous search providers

Some search providers may want to change their results, or may not
want to block on an external service to get their results (DBus, etc.)
Set up an infrastructure to allow search providers to add their search
results at a later time.

Based on a patch by Jasper St. Pierre and Seif Lotfy.
Comment 6 Jasper St. Pierre (not reading bugmail) 2011-07-25 19:00:06 UTC
Review of attachment 192586 [details] [review]:

Looks good! I'd suggest adding a test to make sure it works. In my first implementation, I added a dummy search provider that would set a timeout when a magic search value was entered, like "test async", and added the result after a few seconds.
Comment 7 Philippe Normand 2011-07-26 20:23:19 UTC
Ok I wrote this search provider but where should I put it? Would it be fine to register it along with the other providers?

Also what icon would you suggest to use for the result item?
Comment 8 Jasper St. Pierre (not reading bugmail) 2011-07-26 20:26:12 UTC
It's just a test search provider, it's not going to go into the Shell itself. It can go in a separate patch. Icons? Doesn't matter, I think I used 'system-run' as a placeholder.
Comment 9 Philippe Normand 2011-07-26 20:55:39 UTC
Created attachment 192703 [details] [review]
Sample Asynchronous Search Provider

This search provider is not added to the Shell by default. It's meant
as a simple show-case for the asynchronous search.

If the provider is active and if the user looks for "test async" the
search provider will schedule a task in the mainloop to fire after 2
seconds and add a dummy search result.
Comment 10 Jasper St. Pierre (not reading bugmail) 2011-08-03 19:30:55 UTC
Review of attachment 192703 [details] [review]:

testcommon isn't really designed for something like this, especially as it makes it hard to import at runtime.

It may make sense to have some sort of new directory for docs/examples that can be loaded at runtime, but for now, just append this to the end of search.js, and we won't commit it.

::: tests/testcommon/dummySearch.js
@@ +10,3 @@
+// This is a sample asynchronous search provider. It can be added to
+// the Shell at runtime with the following call:
+// Main.overview.viewSelector.addSearchProvider(new DummySearchProvider());

This is a lie unless testcommon has some magic I'm not aware of.
Comment 11 Philippe Normand 2011-08-08 10:02:15 UTC
Created attachment 193400 [details] [review]
Sample Asynchronous Search Provider

This search provider is not added to the Shell by default. It's meant
as a simple show-case for the asynchronous search.

If the provider is active and if the user looks for "test async" the
search provider will schedule a task in the mainloop to fire after 2
seconds and add a dummy search result.
Comment 12 Jasper St. Pierre (not reading bugmail) 2011-08-22 13:45:25 UTC
Review of attachment 192586 [details] [review]:

Sure.
Comment 13 Jasper St. Pierre (not reading bugmail) 2011-08-22 13:45:55 UTC
Review of attachment 193400 [details] [review]:

Don't push this, it's just an example.
Comment 14 Philippe Normand 2011-08-22 13:55:04 UTC
(In reply to comment #12)
> Review of attachment 192586 [details] [review]:
> 
> Sure.

Can you commit/push please? I don't have a git account on GNOME git yet.
Comment 15 John Stowers 2011-08-30 01:40:27 UTC
Ping?

Can this be committed please.
Comment 16 Jasper St. Pierre (not reading bugmail) 2011-08-30 15:55:58 UTC
Attachment 192586 [details] pushed as 3418e6e - Add support for asynchronous search providers