Merge lp:~didrocks/unity-lens-photos/add-disabling-online-support into lp:unity-lens-photos

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: David Callé
Approved revision: 90
Merged at revision: 86
Proposed branch: lp:~didrocks/unity-lens-photos/add-disabling-online-support
Merge into: lp:unity-lens-photos
Diff against target: 257 lines (+96/-15)
6 files modified
src/facebook_scope.py (+16/-5)
src/flickr_scope.py (+16/-5)
src/picasa_scope.py (+16/-5)
tests/manual/facebook-photos.txt (+16/-0)
tests/manual/flickr-photos.txt (+16/-0)
tests/manual/picasa-photos.txt (+16/-0)
To merge this branch: bzr merge lp:~didrocks/unity-lens-photos/add-disabling-online-support
Reviewer Review Type Date Requested Status
David Callé Approve
Review via email: mp+126631@code.launchpad.net

Description of the change

Add disabling online search support on the facebook, flickr and picasa scopes

To post a comment you must log in.
Revision history for this message
David Callé (davidc3) wrote :

Looks good overall, but this needs to be fixed :

facebook_scope.py:61
- self._scope.connect("filters-changed", self.on_lens_active)
+ self._scope.connect("filters-changed", self.on_lens_active_or_preference_changed)

review: Needs Fixing
90. By Didier Roche-Tolomelli

fix missing rename

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

fixed and pushed, please rereview :)

Revision history for this message
David Callé (davidc3) wrote :

Thanks Didier! I like the fact that you don't hide remote sources in the Sources filter when the setting is changed. Makes up for the OA integration vs No remote possible confusion :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/facebook_scope.py'
2--- src/facebook_scope.py 2012-09-20 22:29:07 +0000
3+++ src/facebook_scope.py 2012-09-27 09:23:28 +0000
4@@ -58,10 +58,14 @@
5 self._authenticating = False
6 self._get_accounts_for_service ('facebook')
7 self._scope.connect("search-changed", self.on_search_changed)
8- self._scope.connect("filters-changed", self.on_lens_active)
9- self._scope.connect("notify::active", self.on_lens_active)
10+ self._scope.connect("filters-changed", self.on_lens_active_or_preference_changed)
11+ self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
12 self._scope.connect('preview-uri', self.on_preview_uri)
13 self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
14+
15+ self.preferences = Unity.PreferencesManager.get_default()
16+ self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)
17+
18 self._scope.export ()
19 lens.add_local_scope (self._scope)
20
21@@ -121,7 +125,7 @@
22 if source_name in self._sources_options:
23 self._sources_options.remove(source_name)
24 self._scope.props.sources.remove_option(source_name)
25- self.on_lens_active ()
26+ self.on_lens_active_or_preference_changed ()
27
28
29 def get_account_service(self):
30@@ -165,7 +169,7 @@
31 self.enabled = False
32 self._sources_options.remove(source_name)
33 self._scope.props.sources.remove_option(source_name)
34- self.on_lens_active ()
35+ self.on_lens_active_or_preference_changed ()
36 print ('Removed Facebook account')
37
38
39@@ -236,7 +240,7 @@
40 ########
41
42
43- def on_lens_active(self, *_):
44+ def on_lens_active_or_preference_changed(self, *_):
45 """ Update results when the lens is opened """
46 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
47
48@@ -283,6 +287,13 @@
49 model = search.props.results_model
50 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
51 model.clear()
52+
53+ # only perform the request if the user has not disabled
54+ # online results. That will hide the category as well.
55+ if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
56+ search.finished()
57+ return
58+
59 self._queued_search = (scope, search, search_type, cancellable)
60 if self._authenticating:
61 print ("authenticating, queuing search")
62
63=== modified file 'src/flickr_scope.py'
64--- src/flickr_scope.py 2012-09-20 22:29:07 +0000
65+++ src/flickr_scope.py 2012-09-27 09:23:28 +0000
66@@ -59,10 +59,14 @@
67 self._authenticating = False
68 self._get_accounts_for_service ('flickr')
69 self._scope.connect("search-changed", self.on_search_changed)
70- self._scope.connect ("filters-changed", self.on_lens_active)
71- self._scope.connect("notify::active", self.on_lens_active)
72+ self._scope.connect ("filters-changed", self.on_lens_active_or_preference_changed)
73+ self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
74 self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
75 self._scope.connect('preview-uri', self.on_preview_uri)
76+
77+ self.preferences = Unity.PreferencesManager.get_default()
78+ self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)
79+
80 self._scope.export ()
81 lens.add_local_scope (self._scope)
82
83@@ -122,7 +126,7 @@
84 if source_name in self._sources_options:
85 self._sources_options.remove(source_name)
86 self._scope.props.sources.remove_option(source_name)
87- self.on_lens_active ()
88+ self.on_lens_active_or_preference_changed ()
89
90
91 def get_account_service(self):
92@@ -166,7 +170,7 @@
93 self.enabled = False
94 self._sources_options.remove(source_name)
95 self._scope.props.sources.remove_option(source_name)
96- self.on_lens_active ()
97+ self.on_lens_active_or_preference_changed ()
98 print ('Removed Flickr account')
99
100
101@@ -300,7 +304,7 @@
102 # Lens functions
103 ########
104
105- def on_lens_active(self, *_):
106+ def on_lens_active_or_preference_changed(self, *_):
107 """ Update results when the lens is opened """
108 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
109
110@@ -348,6 +352,13 @@
111 model = search.props.results_model
112 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
113 model.clear()
114+
115+ # only perform the request if the user has not disabled
116+ # online results. That will hide the category as well.
117+ if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
118+ search.finished()
119+ return
120+
121 self._queued_search = (scope, search, search_type, cancellable)
122 if self._authenticating:
123 print ("authenticating, queuing search")
124
125=== modified file 'src/picasa_scope.py'
126--- src/picasa_scope.py 2012-09-20 22:29:07 +0000
127+++ src/picasa_scope.py 2012-09-27 09:23:28 +0000
128@@ -57,10 +57,14 @@
129 self._cancellable = [Gio.Cancellable (), Gio.Cancellable ()]
130 self._get_accounts_for_service ('google')
131 self._scope.connect("search-changed", self._on_search_changed)
132- self._scope.connect ("filters-changed", self.on_lens_active)
133- self._scope.connect("notify::active", self.on_lens_active)
134+ self._scope.connect ("filters-changed", self.on_lens_active_or_preference_changed)
135+ self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
136 self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
137 self._scope.connect('preview-uri', self.on_preview_uri)
138+
139+ self.preferences = Unity.PreferencesManager.get_default()
140+ self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)
141+
142 self._scope.export ()
143 lens.add_local_scope (self._scope)
144
145@@ -103,7 +107,7 @@
146 if source_name in self._sources_options:
147 self._sources_options.remove(source_name)
148 self._scope.props.sources.remove_option(source_name)
149- self.on_lens_active ()
150+ self.on_lens_active_or_preference_changed ()
151
152
153 def get_account_service(self):
154@@ -147,7 +151,7 @@
155 self.enabled = False
156 self._sources_options.remove(source_name)
157 self._scope.props.sources.remove_option(source_name)
158- self.on_lens_active ()
159+ self.on_lens_active_or_preference_changed ()
160 print ('Removed Picasa account')
161
162
163@@ -155,7 +159,7 @@
164 # Lens functions
165 ########
166
167- def on_lens_active(self, *_):
168+ def on_lens_active_or_preference_changed(self, *_):
169 """ Update results when the lens is opened """
170 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
171
172@@ -202,6 +206,13 @@
173 model = search.props.results_model
174 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
175 model.clear ()
176+
177+ # only perform the request if the user has not disabled
178+ # online results. That will hide the category as well.
179+ if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
180+ search.finished()
181+ return
182+
183 search_string = search.props.search_string
184 if self._enabled:
185 if search_type == Unity.SearchType.DEFAULT:
186
187=== modified file 'tests/manual/facebook-photos.txt'
188--- tests/manual/facebook-photos.txt 2012-09-21 16:08:09 +0000
189+++ tests/manual/facebook-photos.txt 2012-09-27 09:23:28 +0000
190@@ -12,3 +12,19 @@
191
192 Expected Result:
193 The lens should display the most recent Facebook photos and Facebook friends photos in the Recent category, less recent Facebook photos in the My Photos category and less recent Facebook friends photos in the Friends Photos category.
194+
195+'Disable' Online searched
196+----------------------------------------------------
197+Disabling the online searches should not search on Facebook.
198+
199+Setup:
200+Internet connectivity.
201+
202+Actions:
203+Disable the online search in gnome-control-center or directly in gsettings
204+(com.canonical.Unity.Lenses "remote-content-search" to none)
205+Perfom a search in the home dash and within the photo lens.
206+
207+Expected Results:
208+No result from Facebook in the lens should be displayed.
209+
210
211=== modified file 'tests/manual/flickr-photos.txt'
212--- tests/manual/flickr-photos.txt 2012-09-21 16:08:09 +0000
213+++ tests/manual/flickr-photos.txt 2012-09-27 09:23:28 +0000
214@@ -12,3 +12,19 @@
215
216 Expected Result:
217 The lens should display the most recent Flickr photos and Flickr contacts photos in the Recent category, less recent Flickr photos in the My Photos category and less recent Flickr contacts photos in the Friends Photos category.
218+
219+'Disable' Online searched
220+----------------------------------------------------
221+Disabling the online searches should not search on Flickr.
222+
223+Setup:
224+Internet connectivity.
225+
226+Actions:
227+Disable the online search in gnome-control-center or directly in gsettings
228+(com.canonical.Unity.Lenses "remote-content-search" to none)
229+Perfom a search in the home dash and within the photo lens.
230+
231+Expected Results:
232+No result from Flickr in the lens should be displayed.
233+
234
235=== modified file 'tests/manual/picasa-photos.txt'
236--- tests/manual/picasa-photos.txt 2012-09-21 16:08:09 +0000
237+++ tests/manual/picasa-photos.txt 2012-09-27 09:23:28 +0000
238@@ -12,3 +12,19 @@
239
240 Expected Result:
241 The lens should display the 100 most recent Picasa photos, 50 in the Recent category, 50 in the My Photos category.
242+
243+'Disable' Online searched
244+----------------------------------------------------
245+Disabling the online searches should not search on Picasa.
246+
247+Setup:
248+Internet connectivity.
249+
250+Actions:
251+Disable the online search in gnome-control-center or directly in gsettings
252+(com.canonical.Unity.Lenses "remote-content-search" to none)
253+Perfom a search in the home dash and within the photo lens.
254+
255+Expected Results:
256+No result from Picasa in the lens should be displayed.
257+

Subscribers

People subscribed via source and target branches