Merge lp:~davidc3/unity-lens-photos/spring-cleaning into lp:~submarine/unity-lens-photos/libunity-7-compatible

Proposed by David Callé
Status: Merged
Approved by: David Callé
Approved revision: 146
Merged at revision: 145
Proposed branch: lp:~davidc3/unity-lens-photos/spring-cleaning
Merge into: lp:~submarine/unity-lens-photos/libunity-7-compatible
Diff against target: 237 lines (+35/-97)
2 files modified
src/unity_facebook_daemon.py (+23/-50)
src/unity_picasa_daemon.py (+12/-47)
To merge this branch: bzr merge lp:~davidc3/unity-lens-photos/spring-cleaning
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Submarine Pending
Review via email: mp+160319@code.launchpad.net

Commit message

Fix Picasa and Facebook scopes behavior

Description of the change

Fix Picasa and Facebook scopes behavior.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity_facebook_daemon.py'
--- src/unity_facebook_daemon.py 2013-03-21 17:03:01 +0000
+++ src/unity_facebook_daemon.py 2013-04-23 10:07:29 +0000
@@ -92,8 +92,6 @@
92 self._scope.connect("search-changed", self.on_search_changed)92 self._scope.connect("search-changed", self.on_search_changed)
93 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)93 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
94 self._scope.connect('preview-uri', self.on_preview_uri)94 self._scope.connect('preview-uri', self.on_preview_uri)
95 self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
96
97 self.preferences = Unity.PreferencesManager.get_default()95 self.preferences = Unity.PreferencesManager.get_default()
98 self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)96 self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)
99 filters = Unity.FilterSet.new()97 filters = Unity.FilterSet.new()
@@ -313,30 +311,6 @@
313 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)311 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
314312
315313
316 def on_filtering_changed(self, *_):
317 """Run another search when a filter change is notified."""
318 for source in self._sources_options:
319 filtering = self._scope.props.sources.props.filtering
320 active = self._scope.props.sources.get_option(source).props.active
321 if (active and filtering) or (not active and not filtering):
322 if self._enabled:
323 self._enabled = True
324 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
325 else:
326 self.cancel_all_searches ()
327 print (" %s enabled : %s" % (source, self._enabled))
328
329
330 def cancel_all_searches (self):
331 self._enabled = False
332 for i in range(len(self._pending)):
333 try:
334 self._http[i].cancel_message(self._pending[i],Soup.KnownStatusCode.CANCELLED)
335 except:
336 pass
337 self._scope.props.results_model.clear ()
338
339
340 def check_date_filter(self,s):314 def check_date_filter(self,s):
341 """Get active option for a filter name"""315 """Get active option for a filter name"""
342 try:316 try:
@@ -352,6 +326,7 @@
352 def on_search_changed (self, scope, search, search_type, cancellable):326 def on_search_changed (self, scope, search, search_type, cancellable):
353 """Trigger a search for each category when the lens requests it"""327 """Trigger a search for each category when the lens requests it"""
354 self.recent_expected = False328 self.recent_expected = False
329
355 model = search.props.results_model330 model = search.props.results_model
356 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))331 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
357 model.clear()332 model.clear()
@@ -368,30 +343,29 @@
368 return343 return
369 search_string = search.props.search_string.strip()344 search_string = search.props.search_string.strip()
370 if self._enabled:345 if self._enabled:
371 if search_type is Unity.SearchType.DEFAULT:346
372 print ('Facebook : new search %s' % search_string)347 print ('Facebook : new search %s' % search_string)
373 date = self.check_date_filter (search)348 date = self.check_date_filter (search)
374 i = 0349 i = 0
375 if search_string:350 if search_string:
376# for i in range(1,3):351# for i in range(1,3):
377 if self._pending[i] is not None:352 if self._pending[i] is not None:
378 self._http[i].cancel_message(self._pending[i],353 self._http[i].cancel_message(self._pending[i],
379 Soup.KnownStatusCode.CANCELLED)354 Soup.KnownStatusCode.CANCELLED)
380 url = self._url_maker(i, search_string, date)355 url = self._url_maker(i, search_string, date)
381 if url:356 if url:
382 self._pending[i] = Soup.Message.new("GET", url)357 self._pending[i] = Soup.Message.new("GET", url)
383 self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])358 self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
384 else:359 else:
385# for i in range(3):360# for i in range(3):
386 if self._pending[i] is not None:361 if self._pending[i] is not None:
387 self._http[i].cancel_message(self._pending[i],362 self._http[i].cancel_message(self._pending[i],
388 Soup.KnownStatusCode.CANCELLED)363 Soup.KnownStatusCode.CANCELLED)
389 url = self._url_maker(i, search_string, date)364 url = self._url_maker(i, search_string, date)
390 if url:365 if url:
391 self._pending[i] = Soup.Message.new("GET", url)366 self._pending[i] = Soup.Message.new("GET", url)
392 self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])367 self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
393 else:368
394 search.emit('finished')
395 else:369 else:
396 search.emit('finished')370 search.emit('finished')
397371
@@ -472,8 +446,7 @@
472 """Handle async Soup callback"""446 """Handle async Soup callback"""
473 results = self._handle_search_msg(msg, search_args[2])447 results = self._handle_search_msg(msg, search_args[2])
474 self.update_results_model(search_args[0], search_args[1], results, search_args[2], False)448 self.update_results_model(search_args[0], search_args[1], results, search_args[2], False)
475 if search_args[2] == 2:449 search_args[3].emit('finished')
476 search_args[3].emit('finished')
477450
478451
479 def _handle_search_msg(self, msg, cat):452 def _handle_search_msg(self, msg, cat):
480453
=== modified file 'src/unity_picasa_daemon.py'
--- src/unity_picasa_daemon.py 2013-03-21 17:03:01 +0000
+++ src/unity_picasa_daemon.py 2013-04-23 10:07:29 +0000
@@ -41,7 +41,7 @@
41gettext.textdomain(APP_NAME)41gettext.textdomain(APP_NAME)
42_ = gettext.gettext42_ = gettext.gettext
4343
44BUS_NAME = "com.canonical.Unity.Scope.Photos.picasa"44BUS_NAME = "com.canonical.Unity.Scope.Photos.Picasa"
45CAT_MINE = _("My Photos")45CAT_MINE = _("My Photos")
46CAT_FRIENDS = _("Friends Photos")46CAT_FRIENDS = _("Friends Photos")
47CAT_ONLINE = _("Online Photos")47CAT_ONLINE = _("Online Photos")
@@ -88,7 +88,6 @@
88 self._get_accounts_for_service ('google')88 self._get_accounts_for_service ('google')
89 self._scope.connect("search-changed", self._on_search_changed)89 self._scope.connect("search-changed", self._on_search_changed)
90 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)90 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
91 self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
92 self._scope.connect('preview-uri', self.on_preview_uri)91 self._scope.connect('preview-uri', self.on_preview_uri)
9392
94 self.preferences = Unity.PreferencesManager.get_default()93 self.preferences = Unity.PreferencesManager.get_default()
@@ -229,28 +228,6 @@
229 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)228 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
230229
231230
232 def on_filtering_changed(self, *_):
233 """Run another search when a filter change is notified."""
234 for source in self._sources_options:
235 filtering = self._scope.props.sources.props.filtering
236 active = self._scope.props.sources.get_option(source).props.active
237 if (active and filtering) or (not active and not filtering):
238 if not self._enabled:
239 self._enabled = True
240 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
241 else:
242 self.cancel_all_searches ()
243 print (" %s enabled : %s" % (source, self._enabled))
244
245
246 def cancel_all_searches (self):
247 """Cancel all searches and clear the lens"""
248 self._enabled = False
249 for c in self._cancellable:
250 c.cancel ()
251 self._scope.props.results_model.clear ()
252
253
254 def check_date_filter(self, s):231 def check_date_filter(self, s):
255 """Get active option for a filter name"""232 """Get active option for a filter name"""
256 try:233 try:
@@ -266,8 +243,8 @@
266 def _on_search_changed (self, scope, search, search_type, cancellable):243 def _on_search_changed (self, scope, search, search_type, cancellable):
267 """Trigger a search for each category when the lens requests it"""244 """Trigger a search for each category when the lens requests it"""
268 self.recent_expected = False245 self.recent_expected = False
269# for c in self._cancellable:246 for c in self._cancellable:
270# c.cancel ()247 c.cancel ()
271 model = search.props.results_model248 model = search.props.results_model
272 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))249 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
273 model.clear ()250 model.clear ()
@@ -277,14 +254,10 @@
277 if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:254 if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
278 search.emit('finished')255 search.emit('finished')
279 return256 return
280
281 search_string = search.props.search_string257 search_string = search.props.search_string
282 if self._enabled:258 if self._enabled:
283 if search_type == Unity.SearchType.DEFAULT:259 self.update_results_model (search_string, model, search)
284 self.update_results_model (search_string, model, search)260 print("Picasa : new search %s" % search_string)
285 print("Picasa : new search %s" % search_string)
286 else:
287 search.emit ('finished')
288 else:261 else:
289 search.emit ('finished')262 search.emit ('finished')
290263
@@ -333,22 +306,14 @@
333 q = GData.Query.new (search)306 q = GData.Query.new (search)
334 fquery = GData.Query.get_query_uri (q, url)307 fquery = GData.Query.get_query_uri (q, url)
335 self._cancellable[cat] = Gio.Cancellable ()308 self._cancellable[cat] = Gio.Cancellable ()
336 self._client.query_async(None, fquery, q, GData.PicasaWebFile, self._cancellable[cat], None, None, self.get_query_async_feed, [cat, model, s])
337
338
339 def get_query_async_feed (self, service, result, catmodel):
340 """Handle query response"""
341 try:309 try:
342 feed = self._client.query_finish (result)310 feed = self._client.query(None, fquery, q, GData.PicasaWebFile, self._cancellable[cat], None, None)
343 except Exception as error:311 except Exception as error:
344 print(error)312 print (error)
345 feed = None313 feed = None
346 if feed and catmodel:314 if feed:
347 xml_feed = feed.get_xml ()315 self.parse_results (feed.get_xml(), cat, model, False)
348 GLib.idle_add(self.parse_results, xml_feed, catmodel[0], catmodel[1], False)316 s.emit('finished')
349# if catmodel:
350# catmodel[2].emit('finished')
351
352317
353 def parse_results (self, results, cat, model, recent_done):318 def parse_results (self, results, cat, model, recent_done):
354 """Parse and update results for category 0, then the others"""319 """Parse and update results for category 0, then the others"""
@@ -387,7 +352,7 @@
387 category=cat,352 category=cat,
388 mimetype="text/html",353 mimetype="text/html",
389 title=title,354 title=title,
390 comment=str(date)+"_ulp-date_"+album+"_ulp-album_"+photo_feed,355 comment=str(date)[:11]+"_ulp-date_"+album+"_ulp-album_"+photo_feed,
391 dnd_uri=photo_link,356 dnd_uri=photo_link,
392 result_type=Unity.ResultType.PERSONAL);357 result_type=Unity.ResultType.PERSONAL);
393 print ('Picasa : Added %i results to category %i' % (counter, cat))358 print ('Picasa : Added %i results to category %i' % (counter, cat))
@@ -406,7 +371,7 @@
406 album = photo_from_feed.split('_ulp-album_')[0]371 album = photo_from_feed.split('_ulp-album_')[0]
407 photo_id = photo_from_feed.split('_ulp-album_')[1]372 photo_id = photo_from_feed.split('_ulp-album_')[1]
408 timestamp = scope.last_result.comment.split('_ulp-date_')[0]373 timestamp = scope.last_result.comment.split('_ulp-date_')[0]
409 date = datetime.datetime.fromtimestamp(float(timestamp[:-3])).strftime('%d %b %Y')374 date = datetime.datetime.fromtimestamp(float(timestamp[:-1])).strftime('%d %b %Y')
410 try:375 try:
411 meta = self.getMetadataForPhoto(photo_id)376 meta = self.getMetadataForPhoto(photo_id)
412 except:377 except:

Subscribers

People subscribed via source and target branches

to all changes: