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
1=== modified file 'src/unity_facebook_daemon.py'
2--- src/unity_facebook_daemon.py 2013-03-21 17:03:01 +0000
3+++ src/unity_facebook_daemon.py 2013-04-23 10:07:29 +0000
4@@ -92,8 +92,6 @@
5 self._scope.connect("search-changed", self.on_search_changed)
6 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
7 self._scope.connect('preview-uri', self.on_preview_uri)
8- self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
9-
10 self.preferences = Unity.PreferencesManager.get_default()
11 self.preferences.connect("notify::remote-content-search", self.on_lens_active_or_preference_changed)
12 filters = Unity.FilterSet.new()
13@@ -313,30 +311,6 @@
14 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
15
16
17- def on_filtering_changed(self, *_):
18- """Run another search when a filter change is notified."""
19- for source in self._sources_options:
20- filtering = self._scope.props.sources.props.filtering
21- active = self._scope.props.sources.get_option(source).props.active
22- if (active and filtering) or (not active and not filtering):
23- if self._enabled:
24- self._enabled = True
25- self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
26- else:
27- self.cancel_all_searches ()
28- print (" %s enabled : %s" % (source, self._enabled))
29-
30-
31- def cancel_all_searches (self):
32- self._enabled = False
33- for i in range(len(self._pending)):
34- try:
35- self._http[i].cancel_message(self._pending[i],Soup.KnownStatusCode.CANCELLED)
36- except:
37- pass
38- self._scope.props.results_model.clear ()
39-
40-
41 def check_date_filter(self,s):
42 """Get active option for a filter name"""
43 try:
44@@ -352,6 +326,7 @@
45 def on_search_changed (self, scope, search, search_type, cancellable):
46 """Trigger a search for each category when the lens requests it"""
47 self.recent_expected = False
48+
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@@ -368,30 +343,29 @@
53 return
54 search_string = search.props.search_string.strip()
55 if self._enabled:
56- if search_type is Unity.SearchType.DEFAULT:
57- print ('Facebook : new search %s' % search_string)
58- date = self.check_date_filter (search)
59- i = 0
60- if search_string:
61+
62+ print ('Facebook : new search %s' % search_string)
63+ date = self.check_date_filter (search)
64+ i = 0
65+ if search_string:
66 # for i in range(1,3):
67- if self._pending[i] is not None:
68- self._http[i].cancel_message(self._pending[i],
69- Soup.KnownStatusCode.CANCELLED)
70- url = self._url_maker(i, search_string, date)
71- if url:
72- self._pending[i] = Soup.Message.new("GET", url)
73- self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
74- else:
75+ if self._pending[i] is not None:
76+ self._http[i].cancel_message(self._pending[i],
77+ Soup.KnownStatusCode.CANCELLED)
78+ url = self._url_maker(i, search_string, date)
79+ if url:
80+ self._pending[i] = Soup.Message.new("GET", url)
81+ self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
82+ else:
83 # for i in range(3):
84- if self._pending[i] is not None:
85- self._http[i].cancel_message(self._pending[i],
86- Soup.KnownStatusCode.CANCELLED)
87- url = self._url_maker(i, search_string, date)
88- if url:
89- self._pending[i] = Soup.Message.new("GET", url)
90- self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
91- else:
92- search.emit('finished')
93+ if self._pending[i] is not None:
94+ self._http[i].cancel_message(self._pending[i],
95+ Soup.KnownStatusCode.CANCELLED)
96+ url = self._url_maker(i, search_string, date)
97+ if url:
98+ self._pending[i] = Soup.Message.new("GET", url)
99+ self._http[i].queue_message(self._pending[i],self._search_cb,[search_string, model, i, search])
100+
101 else:
102 search.emit('finished')
103
104@@ -472,8 +446,7 @@
105 """Handle async Soup callback"""
106 results = self._handle_search_msg(msg, search_args[2])
107 self.update_results_model(search_args[0], search_args[1], results, search_args[2], False)
108- if search_args[2] == 2:
109- search_args[3].emit('finished')
110+ search_args[3].emit('finished')
111
112
113 def _handle_search_msg(self, msg, cat):
114
115=== modified file 'src/unity_picasa_daemon.py'
116--- src/unity_picasa_daemon.py 2013-03-21 17:03:01 +0000
117+++ src/unity_picasa_daemon.py 2013-04-23 10:07:29 +0000
118@@ -41,7 +41,7 @@
119 gettext.textdomain(APP_NAME)
120 _ = gettext.gettext
121
122-BUS_NAME = "com.canonical.Unity.Scope.Photos.picasa"
123+BUS_NAME = "com.canonical.Unity.Scope.Photos.Picasa"
124 CAT_MINE = _("My Photos")
125 CAT_FRIENDS = _("Friends Photos")
126 CAT_ONLINE = _("Online Photos")
127@@ -88,7 +88,6 @@
128 self._get_accounts_for_service ('google')
129 self._scope.connect("search-changed", self._on_search_changed)
130 self._scope.connect("notify::active", self.on_lens_active_or_preference_changed)
131- self._scope.props.sources.connect("notify::filtering", self.on_filtering_changed)
132 self._scope.connect('preview-uri', self.on_preview_uri)
133
134 self.preferences = Unity.PreferencesManager.get_default()
135@@ -229,28 +228,6 @@
136 self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
137
138
139- def on_filtering_changed(self, *_):
140- """Run another search when a filter change is notified."""
141- for source in self._sources_options:
142- filtering = self._scope.props.sources.props.filtering
143- active = self._scope.props.sources.get_option(source).props.active
144- if (active and filtering) or (not active and not filtering):
145- if not self._enabled:
146- self._enabled = True
147- self._scope.queue_search_changed(Unity.SearchType.DEFAULT)
148- else:
149- self.cancel_all_searches ()
150- print (" %s enabled : %s" % (source, self._enabled))
151-
152-
153- def cancel_all_searches (self):
154- """Cancel all searches and clear the lens"""
155- self._enabled = False
156- for c in self._cancellable:
157- c.cancel ()
158- self._scope.props.results_model.clear ()
159-
160-
161 def check_date_filter(self, s):
162 """Get active option for a filter name"""
163 try:
164@@ -266,8 +243,8 @@
165 def _on_search_changed (self, scope, search, search_type, cancellable):
166 """Trigger a search for each category when the lens requests it"""
167 self.recent_expected = False
168-# for c in self._cancellable:
169-# c.cancel ()
170+ for c in self._cancellable:
171+ c.cancel ()
172 model = search.props.results_model
173 search.set_reply_hint ("no-results-hint", GLib.Variant.new_string(NO_RESULTS_HINT))
174 model.clear ()
175@@ -277,14 +254,10 @@
176 if self.preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
177 search.emit('finished')
178 return
179-
180 search_string = search.props.search_string
181 if self._enabled:
182- if search_type == Unity.SearchType.DEFAULT:
183- self.update_results_model (search_string, model, search)
184- print("Picasa : new search %s" % search_string)
185- else:
186- search.emit ('finished')
187+ self.update_results_model (search_string, model, search)
188+ print("Picasa : new search %s" % search_string)
189 else:
190 search.emit ('finished')
191
192@@ -333,22 +306,14 @@
193 q = GData.Query.new (search)
194 fquery = GData.Query.get_query_uri (q, url)
195 self._cancellable[cat] = Gio.Cancellable ()
196- self._client.query_async(None, fquery, q, GData.PicasaWebFile, self._cancellable[cat], None, None, self.get_query_async_feed, [cat, model, s])
197-
198-
199- def get_query_async_feed (self, service, result, catmodel):
200- """Handle query response"""
201 try:
202- feed = self._client.query_finish (result)
203+ feed = self._client.query(None, fquery, q, GData.PicasaWebFile, self._cancellable[cat], None, None)
204 except Exception as error:
205- print(error)
206+ print (error)
207 feed = None
208- if feed and catmodel:
209- xml_feed = feed.get_xml ()
210- GLib.idle_add(self.parse_results, xml_feed, catmodel[0], catmodel[1], False)
211-# if catmodel:
212-# catmodel[2].emit('finished')
213-
214+ if feed:
215+ self.parse_results (feed.get_xml(), cat, model, False)
216+ s.emit('finished')
217
218 def parse_results (self, results, cat, model, recent_done):
219 """Parse and update results for category 0, then the others"""
220@@ -387,7 +352,7 @@
221 category=cat,
222 mimetype="text/html",
223 title=title,
224- comment=str(date)+"_ulp-date_"+album+"_ulp-album_"+photo_feed,
225+ comment=str(date)[:11]+"_ulp-date_"+album+"_ulp-album_"+photo_feed,
226 dnd_uri=photo_link,
227 result_type=Unity.ResultType.PERSONAL);
228 print ('Picasa : Added %i results to category %i' % (counter, cat))
229@@ -406,7 +371,7 @@
230 album = photo_from_feed.split('_ulp-album_')[0]
231 photo_id = photo_from_feed.split('_ulp-album_')[1]
232 timestamp = scope.last_result.comment.split('_ulp-date_')[0]
233- date = datetime.datetime.fromtimestamp(float(timestamp[:-3])).strftime('%d %b %Y')
234+ date = datetime.datetime.fromtimestamp(float(timestamp[:-1])).strftime('%d %b %Y')
235 try:
236 meta = self.getMetadataForPhoto(photo_id)
237 except:

Subscribers

People subscribed via source and target branches

to all changes: