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
=== modified file 'unity-scope-gdocs'
--- unity-scope-gdocs 2012-09-26 08:07:31 +0000
+++ unity-scope-gdocs 2012-09-27 09:08:22 +0000
@@ -41,6 +41,9 @@
41 def __init__ (self):41 def __init__ (self):
42 self._scope = Unity.Scope.new ("/net/launchpad/unity/scope/gdocs")42 self._scope = Unity.Scope.new ("/net/launchpad/unity/scope/gdocs")
43 self._scope.search_in_global = True;43 self._scope.search_in_global = True;
44 self._preferences = Unity.PreferencesManager.get_default()
45 self._preferences.connect ("notify::remote-content-search",
46 self._on_filters_or_preferences_changed);
4447
45 self._gdocs_accounts = []48 self._gdocs_accounts = []
46 self._account_manager = Accounts.Manager.new_for_service_type("documents")49 self._account_manager = Accounts.Manager.new_for_service_type("documents")
@@ -55,7 +58,7 @@
55 # Though it's possible to connect to a more-specific changed signal on each58 # Though it's possible to connect to a more-specific changed signal on each
56 # Fitler, as we re-do the search anyway, this catch-all signal is perfect for59 # Fitler, as we re-do the search anyway, this catch-all signal is perfect for
57 # us.60 # us.
58 self._scope.connect ("filters-changed", self._on_filters_changed);61 self._scope.connect ("filters-changed", self._on_filters_or_preferences_changed);
59 self._scope.export()62 self._scope.export()
6063
61 def _on_enabled_event (self, account_manager, account_id):64 def _on_enabled_event (self, account_manager, account_id):
@@ -75,6 +78,12 @@
75 def _on_search_changed (self, scope, search, search_type, cancellable):78 def _on_search_changed (self, scope, search, search_type, cancellable):
76 search_string = search.props.search_string79 search_string = search.props.search_string
77 results = search.props.results_model80 results = search.props.results_model
81 results.clear()
82
83 if self._preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
84 search.emit("finished")
85 return
86
78 if search_type == Unity.SearchType.GLOBAL:87 if search_type == Unity.SearchType.GLOBAL:
79 is_global = True88 is_global = True
80 else:89 else:
@@ -82,13 +91,12 @@
8291
83 print("Search changed to: '%s'" % search_string)92 print("Search changed to: '%s'" % search_string)
8493
85 results.clear()
86 for gdocs_account in self._gdocs_accounts:94 for gdocs_account in self._gdocs_accounts:
87 gdocs_account.update_results_model (search_string, results, is_global)95 gdocs_account.update_results_model (search_string, results, is_global)
88 search.emit("finished")96 search.emit("finished")
89 97
90 def _on_filters_changed (self, scope, param_spec=None):98 def _on_filters_or_preferences_changed (self, *_):
91 scope.queue_search_changed(Unity.SearchType.DEFAULT)99 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
92 100
93101
94class SignOnAuthorizer(GObject.Object, GData.Authorizer):102class SignOnAuthorizer(GObject.Object, GData.Authorizer):

Subscribers

People subscribed via source and target branches