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
1=== modified file 'src/unity-lens-video'
2--- src/unity-lens-video 2012-09-14 09:12:09 +0000
3+++ src/unity-lens-video 2012-09-22 11:41:20 +0000
4@@ -156,13 +156,18 @@
5 while not model.is_last(iter):
6 if model.get_string(iter, 0) == uri:
7 title = model.get_string(iter, 4);
8- subtitle = time.strftime("%x, %X", time.localtime(os.path.getmtime(GLib.filename_from_uri(uri, None))))
9+ try:
10+ subtitle = time.strftime("%x, %X", time.localtime(os.path.getmtime(GLib.filename_from_uri(uri, None))))
11+ except:
12+ # Instead of empty, maybe the date/time of the zg event?
13+ subtitle = ''
14 desc = model.get_string(iter, 5);
15 preview = Unity.MoviePreview.new(title, subtitle, desc, None)
16 preview.connect('closed', self.on_preview_closed)
17
18 # we may get remote uris from zeitgeist - fetch details for local files only
19 if uri.startswith("file://"):
20+ local_video = True
21 preview.props.image_source_uri = uri
22 try:
23 player = self.bus.get_object (PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH)
24@@ -179,11 +184,15 @@
25 preview.add_info(Unity.InfoHint.new("size", _("Size"), None, GLib.format_size(os.path.getsize(GLib.filename_from_uri(uri, None)))))
26 except Exception as e:
27 print "Couldn't get video details", e
28- show_folder = Unity.PreviewAction.new("show-in-folder", _("Show in Folder"), None)
29- show_folder.connect('activated', self.show_in_folder)
30- preview.add_action(show_folder)
31+ else:
32+ local_video = False
33+ preview.props.image_source_uri = model.get_string(iter, 1)
34 play_video = Unity.PreviewAction.new("play", _("Play"), None)
35 preview.add_action(play_video)
36+ if local_video:
37+ show_folder = Unity.PreviewAction.new("show-in-folder", _("Show in Folder"), None)
38+ show_folder.connect('activated', self.show_in_folder)
39+ preview.add_action(show_folder)
40 break
41 iter = model.next(iter)
42 if preview == None:

Subscribers

People subscribed via source and target branches