Merge lp:~mardy/unity-scope-gdrive/lp1054746 into lp:unity-scope-gdrive

Proposed by Alberto Mardegan
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 19
Merged at revision: 19
Proposed branch: lp:~mardy/unity-scope-gdrive/lp1054746
Merge into: lp:unity-scope-gdrive
Diff against target: 51 lines (+12/-4)
1 file modified
unity-scope-gdocs (+12/-4)
To merge this branch: bzr merge lp:~mardy/unity-scope-gdrive/lp1054746
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
David King (community) Approve
Review via email: mp+126635@code.launchpad.net

Description of the change

Do not make any online queries if remote searches have been disabled.

To post a comment you must log in.
Revision history for this message
David King (amigadave) :
review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Looking good, approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-scope-gdocs'
2--- unity-scope-gdocs 2012-09-26 08:07:31 +0000
3+++ unity-scope-gdocs 2012-09-27 09:08:22 +0000
4@@ -41,6 +41,9 @@
5 def __init__ (self):
6 self._scope = Unity.Scope.new ("/net/launchpad/unity/scope/gdocs")
7 self._scope.search_in_global = True;
8+ self._preferences = Unity.PreferencesManager.get_default()
9+ self._preferences.connect ("notify::remote-content-search",
10+ self._on_filters_or_preferences_changed);
11
12 self._gdocs_accounts = []
13 self._account_manager = Accounts.Manager.new_for_service_type("documents")
14@@ -55,7 +58,7 @@
15 # Though it's possible to connect to a more-specific changed signal on each
16 # Fitler, as we re-do the search anyway, this catch-all signal is perfect for
17 # us.
18- self._scope.connect ("filters-changed", self._on_filters_changed);
19+ self._scope.connect ("filters-changed", self._on_filters_or_preferences_changed);
20 self._scope.export()
21
22 def _on_enabled_event (self, account_manager, account_id):
23@@ -75,6 +78,12 @@
24 def _on_search_changed (self, scope, search, search_type, cancellable):
25 search_string = search.props.search_string
26 results = search.props.results_model
27+ results.clear()
28+
29+ if self._preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
30+ search.emit("finished")
31+ return
32+
33 if search_type == Unity.SearchType.GLOBAL:
34 is_global = True
35 else:
36@@ -82,13 +91,12 @@
37
38 print("Search changed to: '%s'" % search_string)
39
40- results.clear()
41 for gdocs_account in self._gdocs_accounts:
42 gdocs_account.update_results_model (search_string, results, is_global)
43 search.emit("finished")
44
45- def _on_filters_changed (self, scope, param_spec=None):
46- scope.queue_search_changed(Unity.SearchType.DEFAULT)
47+ def _on_filters_or_preferences_changed (self, *_):
48+ self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
49
50
51 class SignOnAuthorizer(GObject.Object, GData.Authorizer):

Subscribers

People subscribed via source and target branches