Merge lp:~stolowski/unity-lens-video/merge-smartscopes into lp:unity-lens-video

Proposed by Paweł Stołowski
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 118
Merged at revision: 114
Proposed branch: lp:~stolowski/unity-lens-video/merge-smartscopes
Merge into: lp:unity-lens-video
Diff against target: 1038 lines (+291/-260)
21 files modified
.bzrignore (+44/-0)
configure.ac (+16/-15)
data/Makefile.am (+8/-7)
data/local.scope.in.in (+6/-5)
data/remote.scope.in.in (+9/-0)
data/unity-scope-video-local.service.in (+1/-1)
debian/changelog (+6/-0)
debian/control (+1/-1)
debian/unity-lens-video.install (+2/-2)
debian/unity-scope-video-remote.install (+1/-1)
po/POTFILES.in (+2/-1)
src/Makefile.am (+5/-4)
src/config.vala.in (+2/-0)
src/daemon.vala (+3/-45)
src/main.vala (+1/-1)
src/remote-scope-globals.vala (+3/-3)
src/remote-scope.vala (+65/-39)
src/remote-video-main.vala (+2/-1)
src/scope.vala (+111/-132)
tests/unit/Makefile.am (+2/-2)
tests/unit/config-tests.vala.in (+1/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-video/merge-smartscopes
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+164229@code.launchpad.net

Commit message

Merge new scope API changes (100 scopes feature).

Description of the change

Merge new scope API changes (100 scopes feature).
Note: needs libunity 7.0.0 to land (should happen very soon).

To post a comment you must log in.
117. By Paweł Stołowski

Fixed required version of libunity-dev.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
118. By Paweł Stołowski

Bumped changelog.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks good, but it's late, soo... Anyway, approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2013-05-16 21:30:36 +0000
4@@ -0,0 +1,44 @@
5+Makefile
6+Makefile.in
7+config.guess
8+config.sub
9+config.h
10+config.h.in
11+config.log
12+configure
13+config.status
14+libtool
15+ltmain.sh
16+aclocal.m4
17+autom4te.cache
18+compile
19+depcomp
20+install-sh
21+missing
22+stamp-h*
23+.libs
24+.deps
25+*.stamp
26+data/*.scope
27+data/*.scope.in
28+data/*.service
29+m4/intltool.m4
30+m4/libtool.m4
31+m4/ltoptions.m4
32+m4/ltsugar.m4
33+m4/ltversion.m4
34+m4/lt~obsolete.m4
35+po/.intltool-merge-cache
36+po/Makefile.in.in
37+po/POTFILES
38+po/stamp-it
39+po/unity-lens-video.pot
40+src/*.c
41+src/config.vala
42+tests/unit/*.c
43+src/unity-scope-video-remote
44+src/unity-video-lens-daemon
45+tests/unit/config-tests.vala
46+tests/unit/test-locate
47+tests/unit/test-ubuntu-video-search
48+tests/unit/test-utils
49
50=== modified file 'configure.ac'
51--- configure.ac 2013-02-19 11:58:41 +0000
52+++ configure.ac 2013-05-16 21:30:36 +0000
53@@ -1,4 +1,4 @@
54-AC_INIT(unity-lens-video, 6.8.0, https://launchpad.net/unity-lens-video)
55+AC_INIT(unity-lens-video, 6.9.0, https://launchpad.net/unity-lens-video)
56 AC_COPYRIGHT([Copyright 2012 Canonical])
57
58 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
59@@ -46,10 +46,10 @@
60 AC_DEFINE_UNQUOTED(PREFIXDIR, "${PREFIX}",[Prefix directory])
61
62 ######################################################
63-# intltool rule for generating translated .lens file
64+# intltool rule for generating translated .scope file
65 ######################################################
66-INTLTOOL_LENS_RULE='%.lens: %.lens.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
67-AC_SUBST(INTLTOOL_LENS_RULE)
68+INTLTOOL_SCOPE_RULE='%.scope: %.scope.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
69+AC_SUBST(INTLTOOL_SCOPE_RULE)
70
71 ###########################
72 # gcov coverage reporting
73@@ -66,7 +66,7 @@
74 # Check for module and library dependancies
75 #####################################################
76 GLIB_REQUIRED=2.27
77-PKG_CHECK_MODULES(LENS_DAEMON,
78+PKG_CHECK_MODULES(SCOPE_DAEMON,
79 glib-2.0 >= $GLIB_REQUIRED
80 gobject-2.0 >= $GLIB_REQUIRED
81 gio-2.0 >= $GLIB_REQUIRED
82@@ -76,12 +76,12 @@
83 libsoup-gnome-2.4
84 json-glib-1.0
85 zeitgeist-1.0 >= 0.3.8
86- unity >= 6.90.2
87- unity-extras >= 6.90.2
88+ unity >= 7.0.0
89+ unity-extras >= 6.91.11
90 )
91
92-AC_SUBST(LENS_DAEMON_CFLAGS)
93-AC_SUBST(LENS_DAEMON_LIBS)
94+AC_SUBST(SCOPE_DAEMON_CFLAGS)
95+AC_SUBST(SCOPE_DAEMON_LIBS)
96
97 ####################################################################
98 # C compiler warnings
99@@ -153,14 +153,14 @@
100 AC_SUBST(DBUSSERVICEDIR)
101
102 #####################################################
103-# Look for correct Lenses dir
104+# Look for correct Scopes dir
105 #####################################################
106 if test "x$with_localinstall" = "xyes"; then
107- LENSESDIR="${datadir}/unity/lenses"
108+ SCOPESDIR="${datadir}/unity/scopes"
109 else
110- LENSESDIR=`$PKG_CONFIG --variable=lensesdir unity`
111+ SCOPESDIR=`$PKG_CONFIG --variable=scopesdir unity`
112 fi
113-AC_SUBST(LENSESDIR)
114+AC_SUBST(SCOPESDIR)
115
116 #############################################
117 # GSettings macros
118@@ -174,7 +174,8 @@
119 AC_CONFIG_FILES([
120 Makefile
121 data/Makefile
122- data/video.lens.in
123+ data/local.scope.in
124+ data/remote.scope.in
125 src/Makefile
126 po/Makefile.in
127 src/config.vala
128@@ -199,7 +200,7 @@
129 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS
130 Extra ValaFlags : ${CPPFLAGS} $MAINTAINER_VALAFLAGS
131
132- Lenses Directory: ${LENSESDIR}
133+ Scopes Directory: ${SCOPESDIR}
134
135 Testing
136 Headless tests : ${enable_headless_tests}
137
138=== modified file 'data/Makefile.am'
139--- data/Makefile.am 2013-02-18 11:14:01 +0000
140+++ data/Makefile.am 2013-05-16 21:30:36 +0000
141@@ -1,7 +1,7 @@
142 dbus_servicesdir = $(DBUSSERVICEDIR)
143 service_in_files = \
144 unity-scope-video-remote.service.in \
145- unity-lens-video.service.in \
146+ unity-scope-video-local.service.in \
147 $(NULL)
148
149 dbus_services_DATA = $(service_in_files:.service.in=.service)
150@@ -9,19 +9,20 @@
151 %.service: %.service.in
152 $(AM_V_GEN)sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
153
154-lens_in_files = video.lens.in video-remote.scope
155-lensdir = $(LENSESDIR)/video
156-lens_DATA = $(lens_in_files:.lens.in=.lens)
157+scope_in_files = local.scope.in remote.scope.in
158+scopedir = $(SCOPESDIR)/video
159+scope_DATA = $(scope_in_files:.scope.in=.scope)
160
161-@INTLTOOL_LENS_RULE@
162+@INTLTOOL_SCOPE_RULE@
163
164 EXTRA_DIST = \
165 $(service_in_files) \
166- $(lens_in_files) \
167+ $(scope_in_files) \
168 $(NULL)
169
170 CLEANFILES = \
171 unity-scope-video-remote.service \
172 unity-lens-video.service \
173- video.lens \
174+ local.scope \
175+ remote.scope \
176 $(NULL)
177
178=== renamed file 'data/video.lens.in.in' => 'data/local.scope.in.in'
179--- data/video.lens.in.in 2012-11-22 12:23:14 +0000
180+++ data/local.scope.in.in 2013-05-16 21:30:36 +0000
181@@ -1,9 +1,10 @@
182-[Lens]
183-DBusName=net.launchpad.lens.video
184-DBusPath=/net/launchpad/lens/video
185+[Scope]
186+DBusName=net.launchpad.scope.LocalVideos
187+DBusPath=/net/launchpad/scope/localvideos
188 _Name=Videos
189-Icon=/usr/share/unity/6/lens-nav-video.svg
190-_Description=Search local videos
191+Type=video
192+Icon=@prefix@/share/unity/icons/lens-nav-video.svg
193+_Description=This is an Ubuntu search plugin that enables local videos to be searched and displayed in the Dash underneath the Video header. If you do not wish to search this content source, you can disable this search plugin.
194 Shortcut=v
195
196 [Desktop Entry]
197
198=== renamed file 'data/video-remote.scope' => 'data/remote.scope.in.in'
199--- data/video-remote.scope 2012-11-22 12:23:14 +0000
200+++ data/remote.scope.in.in 2013-05-16 21:30:36 +0000
201@@ -1,3 +1,12 @@
202 [Scope]
203 DBusName=net.launchpad.scope.RemoteVideos
204 DBusPath=/net/launchpad/scope/remotevideos
205+_Name=Remote Videos
206+Type=video
207+Icon=@prefix@/share/unity/icons/lens-nav-video.svg
208+_Description=This is an Ubuntu search plugin that enables information from various video providers to be searched and displayed in the Dash underneath the Video header. If you do not wish to search these content sources, you can disable this search plugin.
209+GlobalSearches=false
210+RemoteContent=true
211+
212+[Desktop Entry]
213+X-Ubuntu-Gettext-Domain=unity-lens-video
214
215=== renamed file 'data/unity-lens-video.service.in' => 'data/unity-scope-video-local.service.in'
216--- data/unity-lens-video.service.in 2013-02-18 11:14:01 +0000
217+++ data/unity-scope-video-local.service.in 2013-05-16 21:30:36 +0000
218@@ -1,3 +1,3 @@
219 [D-BUS Service]
220-Name=net.launchpad.lens.video
221+Name=net.launchpad.scope.LocalVideos
222 Exec=@pkglibexecdir@/unity-video-lens-daemon
223
224=== modified file 'debian/changelog'
225--- debian/changelog 2013-05-01 21:58:03 +0000
226+++ debian/changelog 2013-05-16 21:30:36 +0000
227@@ -1,3 +1,9 @@
228+unity-lens-video (0.3.15-0ubuntu1) UNRELEASED; urgency=low
229+
230+ * New upstream release.
231+
232+ -- Pawel Stolowski <pawel.stolowski@ubuntu.com> Thu, 16 May 2013 23:27:08 +0200
233+
234 unity-lens-video (0.3.14daily13.05.01.1ubuntu.unity.next-0ubuntu1) raring; urgency=low
235
236 [ Sebastien Bacher ]
237
238=== modified file 'debian/control'
239--- debian/control 2013-04-11 08:31:17 +0000
240+++ debian/control 2013-05-16 21:30:36 +0000
241@@ -11,7 +11,7 @@
242 libglib2.0-dev (>= 2.27),
243 libjson-glib-dev,
244 libsoup-gnome2.4-dev,
245- libunity-dev (>= 6.90.2),
246+ libunity-dev (>= 7.0.0),
247 libzeitgeist-dev (>= 0.3.8),
248 valac-0.18,
249 xvfb,
250
251=== modified file 'debian/unity-lens-video.install'
252--- debian/unity-lens-video.install 2013-02-18 11:14:01 +0000
253+++ debian/unity-lens-video.install 2013-05-16 21:30:36 +0000
254@@ -1,3 +1,3 @@
255 /usr/lib/*/unity-lens-video/unity-video-lens-daemon
256-/usr/share/dbus-1/services/unity-lens-video.service
257-/usr/share/unity/lenses/video/video.lens
258+/usr/share/dbus-1/services/unity-scope-video-local.service
259+/usr/share/unity/scopes/video/local.scope
260
261=== modified file 'debian/unity-scope-video-remote.install'
262--- debian/unity-scope-video-remote.install 2013-02-18 11:14:01 +0000
263+++ debian/unity-scope-video-remote.install 2013-05-16 21:30:36 +0000
264@@ -1,3 +1,3 @@
265 /usr/lib/*/unity-lens-video/unity-scope-video-remote
266 /usr/share/dbus-1/services/unity-scope-video-remote.service
267-/usr/share/unity/lenses/video/video-remote.scope
268+/usr/share/unity/scopes/video/remote.scope
269
270=== modified file 'po/POTFILES.in'
271--- po/POTFILES.in 2013-04-22 13:09:18 +0000
272+++ po/POTFILES.in 2013-05-16 21:30:36 +0000
273@@ -6,4 +6,5 @@
274 src/scope.vala
275 src/ubuntu-video-search.vala
276 tests/unit/test-ubuntu-video-search.vala
277-[type: gettext/ini]data/video.lens.in.in
278+[type: gettext/ini]data/local.scope.in.in
279+[type: gettext/ini]data/remote.scope.in.in
280
281=== modified file 'src/Makefile.am'
282--- src/Makefile.am 2013-02-19 11:58:41 +0000
283+++ src/Makefile.am 2013-05-16 21:30:36 +0000
284@@ -5,6 +5,7 @@
285
286 DATADIR = $(datadir)
287
288+AM_CFLAGS = -w
289 AM_CPPFLAGS = $(COVERAGE_CFLAGS)
290 AM_LDFLAGS = $(COVERAGE_LDFLAGS)
291
292@@ -18,7 +19,7 @@
293 -DPKGDATADIR=\"$(PKGDATADIR)\" \
294 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
295 -DG_LOG_DOMAIN=\"unity-video-lens-daemon\" \
296- $(LENS_DAEMON_CFLAGS) \
297+ $(SCOPE_DAEMON_CFLAGS) \
298 $(MAINTAINER_CFLAGS) \
299 -I$(srcdir) \
300 $(NULL)
301@@ -28,7 +29,7 @@
302 -DPKGDATADIR=\"$(PKGDATADIR)\" \
303 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
304 -DG_LOG_DOMAIN=\"unity-scope-video-remote\" \
305- $(LENS_DAEMON_CFLAGS) \
306+ $(SCOPE_DAEMON_CFLAGS) \
307 $(MAINTAINER_CFLAGS) \
308 -I$(srcdir) \
309 $(NULL)
310@@ -68,11 +69,11 @@
311
312
313 unity_video_lens_daemon_LDADD = \
314- $(LENS_DAEMON_LIBS) \
315+ $(SCOPE_DAEMON_LIBS) \
316 $(NULL)
317
318 unity_scope_video_remote_LDADD = \
319- $(LENS_DAEMON_LIBS) \
320+ $(SCOPE_DAEMON_LIBS) \
321 $(NULL)
322
323 unity_video_lens_daemon_VALASOURCES = \
324
325=== modified file 'src/config.vala.in'
326--- src/config.vala.in 2012-11-09 15:11:21 +0000
327+++ src/config.vala.in 2013-05-16 21:30:36 +0000
328@@ -13,4 +13,6 @@
329 const string PACKAGE = "@PACKAGE@";
330
331 const string VERSION = "@VERSION@";
332+
333+ const string ICON_PATH = "@DATADIR@/icons/unity-icon-theme/places/svg";
334 }
335
336=== modified file 'src/daemon.vala'
337--- src/daemon.vala 2013-04-11 08:33:35 +0000
338+++ src/daemon.vala 2013-05-16 21:30:36 +0000
339@@ -16,64 +16,22 @@
340 * Authored by Pawel Stolowski <pawel.stolowski@canonical.com>
341 * based on python code by David Calle <davidc@framli.eu>
342 */
343-using Config;
344
345 namespace Unity.VideoLens {
346
347- const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";
348-
349 public class Daemon : GLib.Object
350 {
351- private Unity.Lens lens;
352+ private Unity.DeprecatedScope scope;
353
354 construct
355 {
356- lens = new Unity.Lens("/net/launchpad/lens/video", "video");
357- lens.search_in_global = true;
358- lens.search_hint = _("Search Videos");
359- lens.sources_display_name = _("Sources");
360- lens.visible = true;
361-
362- populate_categories ();
363- populate_filters ();
364-
365- var video_scope = new VideoScope ();
366- lens.add_local_scope (video_scope);
367+ scope = new VideoScope ();
368
369 try {
370- lens.export ();
371+ scope.export ();
372 } catch (GLib.IOError e) {
373 stdout.printf ("error %s\n", e.message);
374 }
375 }
376-
377- private void populate_filters ()
378- {
379- var filters = new GLib.List<Unity.Filter> ();
380-
381- /* TODO */
382-
383- /* A filter */
384- {
385- }
386-
387- /* Another filter */
388- {
389- }
390-
391- lens.filters = filters;
392- }
393-
394- private void populate_categories ()
395- {
396- var categories = new GLib.List<Unity.Category> ();
397- var icon_dir = File.new_for_path (ICON_PATH);
398-
399- categories.append(new Unity.Category (_("My Videos"), new FileIcon (icon_dir.get_child ("group-videos.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
400- categories.append(new Unity.Category (_("Online"), new FileIcon (icon_dir.get_child ("group-internet.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
401- categories.append(new Unity.Category (_("More suggestions"), new FileIcon (icon_dir.get_child ("group-treat-yourself.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
402-
403- lens.categories = categories;
404- }
405 }
406 }
407
408=== modified file 'src/main.vala'
409--- src/main.vala 2012-11-27 16:34:26 +0000
410+++ src/main.vala 2013-05-16 21:30:36 +0000
411@@ -35,7 +35,7 @@
412
413 try
414 {
415- app = Extras.dbus_own_name ("net.launchpad.lens.video", () =>
416+ app = Extras.dbus_own_name ("net.launchpad.scope.LocalVideos", () =>
417 {
418 daemon = new Daemon ();
419 });
420
421=== modified file 'src/remote-scope-globals.vala'
422--- src/remote-scope-globals.vala 2012-11-15 16:51:50 +0000
423+++ src/remote-scope-globals.vala 2013-05-16 21:30:36 +0000
424@@ -20,6 +20,6 @@
425
426 namespace Unity.VideoLens
427 {
428- static int CAT_INDEX_ONLINE = 1;
429- static int CAT_INDEX_MORE = 2;
430-}
431\ No newline at end of file
432+ static int CAT_INDEX_ONLINE = 0;
433+ static int CAT_INDEX_MORE = 1;
434+}
435
436=== modified file 'src/remote-scope.vala'
437--- src/remote-scope.vala 2013-03-01 11:30:20 +0000
438+++ src/remote-scope.vala 2013-05-16 21:30:36 +0000
439@@ -18,13 +18,16 @@
440 *
441 */
442
443+using Config;
444+
445 namespace Unity.VideoLens
446 {
447- public class RemoteVideoScope : Unity.Scope
448+ public class RemoteVideoScope : Unity.DeprecatedScope
449 {
450 private static int REFRESH_INTERVAL = 3600; // fetch sources & recommendations once an hour
451 private static int RETRY_INTERVAL = 60; // retry sources/recommendations after a minute
452
453+ private static string PREVIEW_ON_LMB = "lmb-preview";
454 private Soup.Session session;
455 private PreferencesManager preferences = PreferencesManager.get_default ();
456 Gee.ArrayList<RemoteVideoFile?> recommendations;
457@@ -34,11 +37,15 @@
458
459 public RemoteVideoScope ()
460 {
461- Object (dbus_path: "/net/launchpad/scope/remotevideos");
462+ Object (dbus_path: "/net/launchpad/scope/remotevideos", id: "video-remote.scope");
463 }
464
465 protected override void constructed ()
466 {
467+ base.constructed ();
468+
469+ schema.add_field (PREVIEW_ON_LMB, "b", Unity.Schema.FieldType.OPTIONAL);
470+
471 recommendations = new Gee.ArrayList<RemoteVideoFile?> ();
472
473 use_zeitgeist = false;
474@@ -63,8 +70,6 @@
475 {
476 update_search_async.begin (search, search_type, cancellable);
477 });
478- filters_changed.connect (on_filters_changed);
479- sources.notify["filtering"].connect (on_filters_changed);
480
481 generate_search_key.connect ((scope, search) =>
482 {
483@@ -76,9 +81,7 @@
484 queue_search_changed (SearchType.DEFAULT);
485 });
486
487- activate_uri.connect (on_activate_uri);
488- preview_uri.connect (on_preview_uri);
489-
490+ populate_categories ();
491 query_list_of_sources ();
492
493 // refresh the at least once every 30 minutes
494@@ -97,6 +100,17 @@
495 }
496 }
497
498+ private void populate_categories ()
499+ {
500+ var categories = new Unity.CategorySet ();
501+ var icon_dir = File.new_for_path (Config.ICON_PATH);
502+
503+ categories.add(new Unity.Category ("online", _("Online"), new FileIcon (icon_dir.get_child ("group-internet.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
504+ categories.add(new Unity.Category ("more", _("More suggestions"), new FileIcon (icon_dir.get_child ("group-treat-yourself.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
505+
506+ this.categories = categories;
507+ }
508+
509 /* Query the server for a list of sources that will be used
510 * to build sources filter options and search queries.
511 */
512@@ -164,6 +178,19 @@
513 });
514 }
515
516+ public override async Unity.ActivationResponse? activate_result (ScopeResult result)
517+ {
518+ var realcat = result.metadata.lookup (PREVIEW_ON_LMB);
519+ // activation of More Suggestions should display a preview.
520+ if (realcat != null && realcat.get_boolean ())
521+ {
522+ var preview = yield preview_result (result);
523+ return new Unity.ActivationResponse.with_preview (preview);
524+ }
525+
526+ return on_activate_uri (result.uri);
527+ }
528+
529 private Unity.ActivationResponse on_activate_uri (string rawuri)
530 {
531 var fakeuri = RemoteUri.from_rawuri (rawuri);
532@@ -250,37 +277,30 @@
533 return real_preview;
534 }
535
536- private Unity.Preview? on_preview_uri (string rawuri)
537+ public override async Preview? preview_result (ScopeResult result)
538 {
539- var fakeuri = RemoteUri.from_rawuri (rawuri);
540+ var fakeuri = RemoteUri.from_rawuri (result.uri);
541 if (fakeuri != null)
542 {
543+ RemoteVideoDetails? details = null;
544+
545 if (fakeuri.details_uri != null && fakeuri.details_uri != "")
546 {
547- var preview = new AsyncPreview ();
548- get_details.begin (fakeuri.details_uri, (obj, res) =>
549- {
550- try
551- {
552- var details = get_details.end (res);
553- preview.preview_ready (build_preview (fakeuri, details));
554- }
555- catch (Error e)
556- {
557- warning ("Failed to fetch video details: %s", e.message);
558- preview.preview_ready (build_preview (fakeuri, null));
559- }
560- });
561- return preview;
562- }
563- else
564- {
565- return build_preview (fakeuri, null);
566- }
567+ try
568+ {
569+ details = yield get_details (fakeuri.details_uri);
570+ }
571+ catch (Error e)
572+ {
573+ warning ("Failed to fetch video details: %s", e.message);
574+ }
575+ }
576+
577+ return build_preview (fakeuri, details);
578 }
579 else
580 {
581- warning ("Invalid raw uri: '%s'", rawuri);
582+ warning ("Invalid raw uri: '%s'", result.uri);
583 }
584
585 return null;
586@@ -309,7 +329,7 @@
587 }
588 }
589
590- private async void update_search_async (LensSearch search, SearchType search_type, Cancellable? cancellable)
591+ private async void update_search_async (DeprecatedScopeSearch search, SearchType search_type, GLib.Cancellable? cancellable)
592 {
593 var search_string = search.search_string.strip ();
594 debug ("Remote search string changed to: %s", search_string);
595@@ -343,7 +363,14 @@
596 {
597 if (at_least_one_source_is_on (active_sources))
598 {
599- yield perform_search (search_string, search, active_sources, cancellable);
600+ try
601+ {
602+ yield perform_search (search_string, search, active_sources, cancellable);
603+ }
604+ catch (Error e)
605+ {
606+ warning ("Search interrupted: %s", e.message);
607+ }
608 }
609 }
610
611@@ -369,14 +396,9 @@
612 return (sources.filtering && active_sources.size > 0 || !sources.filtering);
613 }
614
615- private void on_filters_changed ()
616- {
617- queue_search_changed (SearchType.DEFAULT);
618- }
619-
620 /* Query the server with the search string and the list of sources.
621 */
622- private async void perform_search (string search_string, LensSearch search, Gee.ArrayList<string> active_sources, Cancellable? cancellable)
623+ private async void perform_search (string search_string, DeprecatedScopeSearch search, Gee.ArrayList<string> active_sources, GLib.Cancellable? cancellable) throws Error
624 {
625 search.results_model.clear ();
626
627@@ -463,7 +485,11 @@
628 result_icon = anno_icon.to_string ();
629 }
630
631- model.append (fake_uri.to_rawuri (), result_icon, video.category, "text/html", video.title, video.comment, video.uri);
632+ // aggregator scope remaps categories, so we won't get real category back;
633+ // put real category into metadata
634+ var realcat = new Variant.dict_entry (PREVIEW_ON_LMB, new Variant.variant (video.category == CAT_INDEX_MORE));
635+ var metadata = new Variant.array (VariantType.VARDICT.element (), {realcat});
636+ model.append (fake_uri.to_rawuri (), result_icon, video.category, ResultType.DEFAULT, "text/html", video.title, video.comment, video.uri, metadata);
637 }
638 }
639 }
640
641=== modified file 'src/remote-video-main.vala'
642--- src/remote-video-main.vala 2012-11-27 16:34:26 +0000
643+++ src/remote-video-main.vala 2013-05-16 21:30:36 +0000
644@@ -20,7 +20,7 @@
645 namespace Unity.VideoLens {
646
647 static const string BUS_NAME = "net.launchpad.scope.RemoteVideos";
648- Unity.Scope scope;
649+ Unity.DeprecatedScope scope;
650 static Application? app = null;
651
652 public static int main (string[] args)
653@@ -39,6 +39,7 @@
654 app = Extras.dbus_own_name (BUS_NAME, () =>
655 {
656 scope = new RemoteVideoScope ();
657+ scope.export ();
658 });
659 }
660 catch (Error e)
661
662=== modified file 'src/scope.vala'
663--- src/scope.vala 2012-11-28 11:54:14 +0000
664+++ src/scope.vala 2013-05-16 21:30:36 +0000
665@@ -18,14 +18,15 @@
666 *
667 */
668
669+using Config;
670+
671 namespace Unity.VideoLens
672 {
673- public class VideoScope : Unity.Scope
674+ public class VideoScope : Unity.DeprecatedScope
675 {
676 private static const int MAX_ZG_EVENTS = 24;
677 private static const int CAT_INDEX_MY_VIDEOS = 0;
678 private static const int CAT_INDEX_ONLINE = 1;
679- private static const int CAT_INDEX_MORE = 2;
680 private static const int REFRESH_TIMEOUT = 30;
681
682 private static string cache_directory;
683@@ -36,9 +37,12 @@
684 private Locate locate;
685 private BlacklistTracker blacklist_tracker;
686
687+ private Variant empty_asv;
688+
689 public VideoScope ()
690 {
691- Object (dbus_path: "/net/launchpad/lens/video/main");
692+ Object (dbus_path: "/net/launchpad/scope/localvideos", id: "video-local.scope");
693+ empty_asv = new Variant.array (VariantType.VARDICT.element (), {});
694
695 videos_folder = GLib.Environment.get_user_special_dir (GLib.UserDirectory.VIDEOS);
696 cache_directory = GLib.Environment.get_user_cache_dir () + "/unity-lens-video";
697@@ -60,8 +64,10 @@
698 locate = new Locate (cache_directory, videos_folder);
699
700 search_in_global = true;
701+ search_hint = _("Search Videos");
702+ visible = true;
703 sources.add_option ("local", _("My Videos"), null);
704- provides_personal_content = true;
705+ populate_categories ();
706
707 GLib.Timeout.add_seconds (REFRESH_TIMEOUT, refresh_results);
708
709@@ -69,13 +75,17 @@
710 {
711 dispatch_search (search, search_type, cancellable);
712 });
713-
714- filters_changed.connect (on_filters_changed);
715- sources.notify["filtering"].connect (on_filters_changed);
716- preview_uri.connect ((uri) =>
717- {
718- return generate_preview_for_uri (uri);
719- });
720+ }
721+
722+ private void populate_categories ()
723+ {
724+ var categories = new Unity.CategorySet ();
725+ var icon_dir = File.new_for_path (Config.ICON_PATH);
726+
727+ categories.add(new Unity.Category ("local", _("My Videos"), new FileIcon (icon_dir.get_child ("group-videos.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
728+ categories.add(new Unity.Category ("online", _("Online"), new FileIcon (icon_dir.get_child ("group-internet.svg")), Unity.CategoryRenderer.VERTICAL_TILE));
729+
730+ this.categories = categories;
731 }
732
733 private bool refresh_results ()
734@@ -85,12 +95,7 @@
735 return true;
736 }
737
738- private void on_filters_changed ()
739- {
740- queue_search_changed (Unity.SearchType.DEFAULT);
741- }
742-
743- private async void dispatch_search (LensSearch search, SearchType search_type, Cancellable cancellable)
744+ private async void dispatch_search (DeprecatedScopeSearch search, SearchType search_type, GLib.Cancellable cancellable)
745 {
746 var search_string = search.search_string.strip ();
747 var search_status = search;
748@@ -134,7 +139,7 @@
749 }
750 }
751
752- private void update_results_model (string search_string, Dee.Model model, string cat, Cancellable? cancellable, LensSearch search, bool clear_model = true)
753+ private void update_results_model (string search_string, Dee.Model model, string cat, GLib.Cancellable? cancellable, DeprecatedScopeSearch search, bool clear_model = true)
754 {
755 var home_folder = GLib.Environment.get_home_dir ();
756
757@@ -155,16 +160,17 @@
758 }
759 }
760
761- internal void add_results (LensSearch search_status, Dee.Model model, string cat, Cancellable? cancellable, Gee.ArrayList<VideoFile?> result_list, string search, bool clear_model)
762+ internal void add_results (DeprecatedScopeSearch search_status, Dee.Model model, string cat, GLib.Cancellable? cancellable, Gee.ArrayList<VideoFile?> result_list, string search, bool clear_model)
763 {
764 if (cancellable != null && !cancellable.is_cancelled ())
765 {
766+ var results_model = search_status.results_model;
767 if (clear_model)
768- search_status.results_model.clear ();
769+ results_model.clear ();
770
771 foreach (var video in result_list)
772 {
773- results_model.append (video.uri, video.icon, video.category, "text/html", video.title, video.comment, video.uri);
774+ results_model.append (video.uri, video.icon, video.category, ResultType.PERSONAL, "text/html", video.title, video.comment, video.uri, empty_asv);
775 }
776
777 if (search_status != null)
778@@ -180,7 +186,7 @@
779 return a.lc_title.collate (b.lc_title);
780 }
781
782- private async void zg_call (Cancellable? cancellable, LensSearch search_status) throws Error
783+ private async void zg_call (GLib.Cancellable? cancellable, DeprecatedScopeSearch search_status) throws Error
784 {
785 bool active = sources.get_option ("local").active;
786 bool filtering = sources.filtering;
787@@ -215,7 +221,7 @@
788 return false;
789 }
790
791- internal void process_zg_events (Zeitgeist.ResultSet events, Cancellable cancellable, LensSearch search_status)
792+ internal void process_zg_events (Zeitgeist.ResultSet events, GLib.Cancellable cancellable, DeprecatedScopeSearch search_status)
793 {
794 var result_list = new Gee.ArrayList<VideoFile?> ();
795
796@@ -270,10 +276,11 @@
797 }
798 }
799
800- search_status.results_model.clear ();
801+ var results_model = search_status.results_model;
802+ results_model.clear ();
803 foreach (var video in result_list)
804 {
805- results_model.append (video.uri, video.icon, video.category, "text/html", video.title, video.comment, video.uri);
806+ results_model.append (video.uri, video.icon, video.category, ResultType.PERSONAL, "text/html", video.title, video.comment, video.uri, empty_asv);
807 }
808
809 update_results_model ("", search_status.results_model, "lens", cancellable, search_status, false);
810@@ -293,99 +300,86 @@
811 return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED);
812 }
813
814- private Preview? generate_preview_for_uri (string uri)
815+ public override async Preview? preview_result (ScopeResult result)
816 {
817- debug ("Preview uri: %s", uri);
818-
819- Unity.Preview preview = null;
820- var model = results_model;
821- var iter = model.get_first_iter ();
822- while (!model.is_last (iter))
823- {
824- if (model.get_string (iter, 0) == uri)
825- {
826- var title = model.get_string (iter, 4);
827- string subtitle = "";
828- int64 file_size = 0;
829- bool local_video = uri.has_prefix ("file://");
830-
831- if (local_video)
832- {
833- var file = GLib.File.new_for_uri (uri);
834- try
835- {
836- var finfo = file.query_info (GLib.FileAttribute.TIME_MODIFIED + "," + GLib.FileAttribute.STANDARD_SIZE, GLib.FileQueryInfoFlags.NONE, null);
837- file_size = finfo.get_size ();
838- var tval = finfo.get_modification_time ();
839- var dt = new DateTime.from_timeval_local (tval);
840- subtitle = dt.format ("%x, %X");
841- }
842- catch (Error e)
843- {
844- // empty subtitle
845- }
846- }
847- var desc = model.get_string (iter, 5);
848-
849- preview = new Unity.MoviePreview (title, subtitle, desc, null);
850- preview.closed.connect (on_preview_closed);
851- var play_video = new Unity.PreviewAction ("play", _("Play"), null);
852- preview.add_action (play_video);
853- preview.image_source_uri = model.get_string (iter, 1);
854-
855- if (local_video)
856- {
857- var show_folder = new Unity.PreviewAction ("show-in-folder", _("Show in Folder"), null);
858- show_folder.activated.connect (show_in_folder);
859- preview.add_action (show_folder);
860- }
861-
862- // we may get remote uris from zeitgeist - fetch details for local files only
863- if (local_video)
864- {
865- var async_preview = new Unity.AsyncPreview ();
866- preview.image_source_uri = uri;
867-
868- if (preview_player == null)
869- preview_player = new Unity.Extras.PreviewPlayer ();
870-
871- preview_player.video_properties.begin (uri, (obj, res) =>
872- {
873- try
874- {
875- var props = preview_player.video_properties.end (res);
876- if ("width" in props && "height" in props && "codec" in props)
877- {
878- var width = props["width"].get_uint32 ();
879- var height = props["height"].get_uint32 ();
880- var codec = props["codec"].get_string ();
881- string dimensions = "%u*%u".printf (width, height);
882- if (width > 0 && height > 0)
883- {
884- var gcd = Utils.gcd (width, height);
885- dimensions += ", %u:%u".printf (width / gcd, height / gcd);
886- }
887-
888- preview.add_info (new Unity.InfoHint ("format", _("Format"), null, codec));
889- preview.add_info (new Unity.InfoHint ("dimensions", _("Dimensions"), null, dimensions));
890- preview.add_info (new Unity.InfoHint ("size", _("Size"), null, GLib.format_size (file_size)));
891- }
892- }
893- catch (Error e)
894- {
895- warning ("Couldn't get video details: %s", e.message);
896- }
897- async_preview.preview_ready (preview);
898- });
899- return async_preview;
900- }
901- break;
902- }
903- iter = model.next (iter);
904- }
905-
906- if (preview == null)
907- warning ("Couldn't find model row for requested preview uri: %s", uri);
908+ debug ("Preview uri: %s", result.uri);
909+
910+ Unity.MoviePreview preview = null;
911+ string subtitle = "";
912+ int64 file_size = 0;
913+ bool local_video = result.uri.has_prefix ("file://");
914+
915+ if (local_video)
916+ {
917+ var file = GLib.File.new_for_uri (result.uri);
918+ try
919+ {
920+ var finfo = file.query_info (GLib.FileAttribute.TIME_MODIFIED + "," + GLib.FileAttribute.STANDARD_SIZE, GLib.FileQueryInfoFlags.NONE, null);
921+ file_size = finfo.get_size ();
922+ var tval = finfo.get_modification_time ();
923+ var dt = new DateTime.from_timeval_local (tval);
924+ subtitle = dt.format ("%x, %X");
925+ }
926+ catch (Error e)
927+ {
928+ // empty subtitle
929+ }
930+ }
931+
932+ preview = new Unity.MoviePreview (result.title, subtitle, result.comment, null);
933+ preview.set_rating (-1.0f, 0);
934+ var play_video = new Unity.PreviewAction ("play", _("Play"), null);
935+ preview.add_action (play_video);
936+ preview.image_source_uri = result.icon_hint;
937+
938+ if (local_video)
939+ {
940+ var show_folder = new Unity.PreviewAction ("show-in-folder", _("Show in Folder"), null);
941+ show_folder.activated.connect (show_in_folder);
942+ preview.add_action (show_folder);
943+ }
944+
945+ // we may get remote uris from zeitgeist - fetch details for local files only
946+ if (local_video)
947+ {
948+ preview.image_source_uri = result.uri;
949+
950+ if (preview_player == null)
951+ preview_player = new Unity.Extras.PreviewPlayer ();
952+
953+ try
954+ {
955+ var props = yield preview_player.video_properties (result.uri);
956+ if ("width" in props && "height" in props && "codec" in props)
957+ {
958+ var width = props["width"].get_uint32 ();
959+ var height = props["height"].get_uint32 ();
960+ var codec = props["codec"].get_string ();
961+ string dimensions = "%u*%u".printf (width, height);
962+ if (width > 0 && height > 0)
963+ {
964+ var gcd = Utils.gcd (width, height);
965+ dimensions += ", %u:%u".printf (width / gcd, height / gcd);
966+ }
967+
968+ preview.add_info (new Unity.InfoHint ("format", _("Format"), null, codec));
969+ preview.add_info (new Unity.InfoHint ("dimensions", _("Dimensions"), null, dimensions));
970+ preview.add_info (new Unity.InfoHint ("size", _("Size"), null, GLib.format_size (file_size)));
971+ }
972+ }
973+ catch (Error e)
974+ {
975+ warning ("Couldn't get video details: %s", e.message);
976+ }
977+ try
978+ {
979+ yield preview_player.close();
980+ }
981+ catch (Error e)
982+ {
983+ warning ("Failed to close preview player: %s", e.message);
984+ }
985+ }
986
987 return preview;
988 }
989@@ -400,21 +394,6 @@
990 return false;
991 }
992
993- private void on_preview_closed (Unity.Preview preview)
994- {
995- if (preview_player != null)
996- {
997- try
998- {
999- preview_player.close ();
1000- }
1001- catch (Error e)
1002- {
1003- warning ("Failed to close preview player: %s", e.message);
1004- }
1005- }
1006- }
1007-
1008 private bool source_activated (string source)
1009 {
1010 // Return the state of a sources filter option
1011
1012=== modified file 'tests/unit/Makefile.am'
1013--- tests/unit/Makefile.am 2013-02-19 12:20:44 +0000
1014+++ tests/unit/Makefile.am 2013-05-16 21:30:36 +0000
1015@@ -25,11 +25,11 @@
1016 $(MAINTAINER_VALAFLAGS) \
1017 $(NULL)
1018
1019-LDADD = $(LENS_DAEMON_LIBS) \
1020+LDADD = $(SCOPE_DAEMON_LIBS) \
1021 $(test_libs)
1022
1023 AM_CPPFLAGS = \
1024- $(LENS_DAEMON_CFLAGS) \
1025+ $(SCOPE_DAEMON_CFLAGS) \
1026 -I$(srcdir) \
1027 -I$(top_srcdir)/src \
1028 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
1029
1030=== modified file 'tests/unit/config-tests.vala.in'
1031--- tests/unit/config-tests.vala.in 2013-02-19 12:20:44 +0000
1032+++ tests/unit/config-tests.vala.in 2013-05-16 21:30:36 +0000
1033@@ -3,4 +3,5 @@
1034 const string LOCALEDIR = "@DATADIR@/locale";
1035 const string PACKAGE = "@PACKAGE@";
1036 const string VERSION = "@VERSION@";
1037+ const string ICON_PATH = "@DATADIR@/icons/unity-icon-theme/places/svg";
1038 }

Subscribers

People subscribed via source and target branches