Merge lp:~didrocks/unity-lens-wikipedia/disable-online-search-support into lp:unity-lens-wikipedia

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: David Callé
Approved revision: 12
Merged at revision: 12
Proposed branch: lp:~didrocks/unity-lens-wikipedia/disable-online-search-support
Merge into: lp:unity-lens-wikipedia
Diff against target: 33 lines (+14/-2)
1 file modified
src/unity-lens-wikipedia (+14/-2)
To merge this branch: bzr merge lp:~didrocks/unity-lens-wikipedia/disable-online-search-support
Reviewer Review Type Date Requested Status
David Callé Pending
Review via email: mp+126621@code.launchpad.net

Description of the change

Add online search disable support.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-lens-wikipedia'
2--- src/unity-lens-wikipedia 2012-06-09 20:20:01 +0000
3+++ src/unity-lens-wikipedia 2012-09-27 07:38:22 +0000
4@@ -48,15 +48,27 @@
5 locale.setlocale(locale.LC_MESSAGES, '')
6 loc = locale.getlocale(locale.LC_MESSAGES)[0].split("_")[0]
7 self.wiki = ["http://%s.wikipedia.org" % (loc)]
8+ self.preferences = Unity.PreferencesManager.get_default()
9+ self.preferences.connect("notify::remote-content-search", self._on_preference_changed)
10 self._lens.export ();
11 self._scope.export ();
12
13+ def _on_preference_changed (self, *_):
14+ self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
15+
16 def on_search_changed (self, scope, search, search_type, *_):
17+ model = search.props.results_model
18+ model.clear ()
19+
20+ # only perform the request if the user has not disabled
21+ # online/commercial suggestions. That will hide the category as well.
22+ if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
23+ search.finished()
24+ return
25+
26 if search_type is Unity.SearchType.DEFAULT:
27 search_string = search.props.search_string.strip ()
28 print "Search changed to \"%s\"" % search_string
29- model = search.props.results_model
30- model.clear ()
31 self.update_results_model(model, search_string)
32 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string("Sorry, there are no articles that match your search."))
33 search.finished ()

Subscribers

People subscribed via source and target branches