Merge lp:~stolowski/unity-lens-video/remote-videos-scope-trunk.previews into lp:unity-lens-video/remote-videos-scope-trunk

Proposed by Paweł Stołowski
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 56
Merged at revision: 55
Proposed branch: lp:~stolowski/unity-lens-video/remote-videos-scope-trunk.previews
Merge into: lp:unity-lens-video/remote-videos-scope-trunk
Diff against target: 91 lines (+40/-0)
1 file modified
src/unity-scope-video-remote (+40/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-video/remote-videos-scope-trunk.previews
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+119481@code.launchpad.net

Commit message

Implementation of previews

Description of the change

Implementation of previews.

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

59 + preview.add_info(Unity.InfoHint.with_variant("uploaded-by", "Uploaded by", None, GLib.Variant('s', "")));
60 + preview.add_info(Unity.InfoHint.with_variant("uploaded-on", "Uploaded on", None, GLib.Variant('s', "")));

Let's use the default constructor here, which takes a string as the value. (+ gettext)

review: Needs Fixing
Revision history for this message
Michal Hruby (mhr3) wrote :

This will probably get more love (and detailed information) later, but atm it looks fine.

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

No commit message specified.

Revision history for this message
Unity Merger (unity-merger) wrote :
Revision history for this message
Unity Merger (unity-merger) wrote :
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

make check disable for python program now. And this should get our first python bot automerging :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-scope-video-remote'
2--- src/unity-scope-video-remote 2012-06-21 18:45:17 +0000
3+++ src/unity-scope-video-remote 2012-08-14 12:56:51 +0000
4@@ -22,6 +22,7 @@
5 import sys
6 from urllib import urlencode
7 import time
8+import gettext
9
10 #pylint: disable=E0611
11 from zeitgeist.client import ZeitgeistClient
12@@ -42,6 +43,13 @@
13 )
14 #pylint: enable=E0611
15
16+APP_NAME = "unity-lens-video"
17+LOCAL_PATH = "/usr/share/locale/"
18+
19+gettext.bindtextdomain(APP_NAME, LOCAL_PATH)
20+gettext.textdomain(APP_NAME)
21+_ = gettext.gettext
22+
23 BUS_NAME = "net.launchpad.scope.RemoteVideos"
24 SERVER = "http://videosearch.ubuntu.com/v0"
25
26@@ -74,12 +82,14 @@
27 self.scope.props.sources.connect("notify::filtering",
28 self.on_filtering_changed)
29 self.scope.connect ("activate-uri", self.on_activate_uri)
30+ self.scope.connect('preview-uri', self.on_preview_uri)
31 self.session = Soup.SessionAsync()
32 self.session.props.user_agent = "Unity Video Lens Remote Scope v0.4"
33 self.session.add_feature_by_type(SoupGNOME.ProxyResolverGNOME)
34 self.query_list_of_sources()
35 self.update_recommendations()
36 self.scope.export()
37+ self.details_map = {} #holds details not passed via lens-meta://, needed by preview
38
39 def update_recommendations(self):
40 """Query the server for 'recommendations'.
41@@ -168,6 +178,8 @@
42 print "Search changed to %r" % search_string
43 model = search.props.results_model
44 model.clear()
45+ # Clear results details map
46+ self.details_map = {}
47 # Create a list of activated sources
48 sources = [source for source in self.sources_list
49 if self.source_activated(source)]
50@@ -195,6 +207,7 @@
51 title = i['title'].encode('utf-8')
52 icon = i['img'].encode('utf-8')
53 comment = i['source'].encode('utf-8')
54+ self.details_map[uri] = (comment) #TODO: more to come
55 if uri.startswith('http'):
56 # Instead of an uri, we pass a string of uri + metadata
57 model.append(uri+'lens-meta://'+title+'lens-meta://'+icon,
58@@ -264,6 +277,33 @@
59 # Then close the Dash
60 return Unity.ActivationResponse(goto_uri='', handled=2 )
61
62+ def on_preview_uri (self, scope, rawuri):
63+ """Preview request handler"""
64+ uri = rawuri.split('lens-meta://')[0]
65+ title = rawuri.split('lens-meta://')[1]
66+ thumbnail_uri = rawuri.split('lens-meta://')[2]
67+ subtitle = ''
68+ desc = ''
69+ if self.details_map.has_key (uri):
70+ desc = self.details_map[uri][0]
71+ try:
72+ thumbnail_file = Gio.File.new_for_uri (thumbnail_uri)
73+ thumbnail_icon = Gio.FileIcon.new(thumbnail_file)
74+ except:
75+ thumbnail_icon = None
76+ preview = Unity.MoviePreview.new(title, subtitle, desc, thumbnail_icon)
77+ play_video = Unity.PreviewAction.new("play", _("Play"), None)
78+ play_video.connect('activated', self.play_video)
79+ preview.add_action(play_video)
80+ #TODO: insert proper uploader and upload date when available in videosearch metadata
81+ preview.add_info(Unity.InfoHint.new("uploaded-by", _("Uploaded by"), None, ""));
82+ preview.add_info(Unity.InfoHint.new("uploaded-on", _("Uploaded on"), None, ""));
83+ return preview
84+
85+ def play_video (self, action, uri):
86+ """Preview request - Play action handler"""
87+ return self.on_activate_uri (action, uri)
88+
89 def zeitgeist_insert_event(self, uri, title, icon):
90 """Insert item uri as a new Zeitgeist event"""
91 # "storage" is an optional zg string

Subscribers

People subscribed via source and target branches