Merge lp:~davidc3/unity-lens-video/dont-crash-on-zg-previews into lp:unity-lens-video

Proposed by David Callé
Status: Merged
Approved by: Michal Hruby
Approved revision: 95
Merged at revision: 95
Proposed branch: lp:~davidc3/unity-lens-video/dont-crash-on-zg-previews
Merge into: lp:unity-lens-video
Diff against target: 42 lines (+13/-4)
1 file modified
src/unity-lens-video (+13/-4)
To merge this branch: bzr merge lp:~davidc3/unity-lens-video/dont-crash-on-zg-previews
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+125844@code.launchpad.net

Commit message

Don't crash when previewing Zeitgeist non local results

Description of the change

* Don't crash when previewing Zeitgeist non local results and provides the bare minimum for a preview.
* Re-order preview actions (Play is now selected by default for local results)

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

I'm going to approve this, but the remote zeitgeist results shouldn't be displayed directly, only used to sort the online results. This will need to be fixed in the future.

Of course the other fixes here still apply :)

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity-lens-video'
--- src/unity-lens-video 2012-09-14 09:12:09 +0000
+++ src/unity-lens-video 2012-09-22 11:41:20 +0000
@@ -156,13 +156,18 @@
156 while not model.is_last(iter):156 while not model.is_last(iter):
157 if model.get_string(iter, 0) == uri:157 if model.get_string(iter, 0) == uri:
158 title = model.get_string(iter, 4);158 title = model.get_string(iter, 4);
159 subtitle = time.strftime("%x, %X", time.localtime(os.path.getmtime(GLib.filename_from_uri(uri, None))))159 try:
160 subtitle = time.strftime("%x, %X", time.localtime(os.path.getmtime(GLib.filename_from_uri(uri, None))))
161 except:
162 # Instead of empty, maybe the date/time of the zg event?
163 subtitle = ''
160 desc = model.get_string(iter, 5);164 desc = model.get_string(iter, 5);
161 preview = Unity.MoviePreview.new(title, subtitle, desc, None)165 preview = Unity.MoviePreview.new(title, subtitle, desc, None)
162 preview.connect('closed', self.on_preview_closed)166 preview.connect('closed', self.on_preview_closed)
163167
164 # we may get remote uris from zeitgeist - fetch details for local files only168 # we may get remote uris from zeitgeist - fetch details for local files only
165 if uri.startswith("file://"):169 if uri.startswith("file://"):
170 local_video = True
166 preview.props.image_source_uri = uri171 preview.props.image_source_uri = uri
167 try: 172 try:
168 player = self.bus.get_object (PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH)173 player = self.bus.get_object (PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH)
@@ -179,11 +184,15 @@
179 preview.add_info(Unity.InfoHint.new("size", _("Size"), None, GLib.format_size(os.path.getsize(GLib.filename_from_uri(uri, None)))))184 preview.add_info(Unity.InfoHint.new("size", _("Size"), None, GLib.format_size(os.path.getsize(GLib.filename_from_uri(uri, None)))))
180 except Exception as e:185 except Exception as e:
181 print "Couldn't get video details", e186 print "Couldn't get video details", e
182 show_folder = Unity.PreviewAction.new("show-in-folder", _("Show in Folder"), None)187 else:
183 show_folder.connect('activated', self.show_in_folder)188 local_video = False
184 preview.add_action(show_folder)189 preview.props.image_source_uri = model.get_string(iter, 1)
185 play_video = Unity.PreviewAction.new("play", _("Play"), None)190 play_video = Unity.PreviewAction.new("play", _("Play"), None)
186 preview.add_action(play_video)191 preview.add_action(play_video)
192 if local_video:
193 show_folder = Unity.PreviewAction.new("show-in-folder", _("Show in Folder"), None)
194 show_folder.connect('activated', self.show_in_folder)
195 preview.add_action(show_folder)
187 break196 break
188 iter = model.next(iter)197 iter = model.next(iter)
189 if preview == None:198 if preview == None:

Subscribers

People subscribed via source and target branches