Merge lp:~michihenning/unity-scopes-api/fallback-image into lp:unity-scopes-api

Proposed by Michi Henning
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 279
Merged at revision: 276
Proposed branch: lp:~michihenning/unity-scopes-api/fallback-image
Merge into: lp:unity-scopes-api
Diff against target: 201 lines (+57/-15)
6 files modified
CMakeLists.txt (+1/-1)
RELEASE_NOTES.md (+12/-0)
debian/changelog (+14/-0)
include/unity/scopes/PreviewWidget.h (+4/-2)
src/scopes/CategoryRenderer.cpp (+17/-9)
src/scopes/PreviewWidget.cpp (+9/-3)
To merge this branch: bzr merge lp:~michihenning/unity-scopes-api/fallback-image
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
Michał Sawicz Approve
Facundo Batista (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+245622@code.launchpad.net

Commit message

Added "art-fallback" entry to "components" dictionary of the category renderer to allow a fallback image to be specified in case the art URI of a result cannot be retrieved.

Description of the change

Added "art-fallback" entry to "components" dictionary of the category renderer to allow a fallback image to be specified in case the art URI of a result cannot be retrieved.

To post a comment you must log in.
Revision history for this message
Michi Henning (michihenning) wrote :

Facundo, I added you to the reviewer list because, for this to work, remote scopes also need to provide a fallback image.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Marking as "In progress" because it looks like there is a whole bunch of other undocumented fields. See the linked bug, and please comment there, so we don't fragment the discussion.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Some inline comments.

On top of that, we probably need something similar for the preview widgets (gallery, image and header widgets). These would have to be just per-widget properties I think. Basically an additional "fallback" field for each of them.

review: Needs Fixing
278. By Michi Henning

Fixed release notes and changelog.

Made fallback a field of the "art" and "mascot" dictionaries.
Removed fallback for emblem.

279. By Michi Henning

Added "fallback" field to image, gallery, and header preview widgets.

Revision history for this message
Michi Henning (michihenning) wrote :

Thanks for the review! I agree, adding "fallback" into the existing "art" and "mascot" dictionaries is cleaner.

I've removed the emblem fallback, and I added "fallback" fields for the image, gallery, and header preview widgets.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Facundo Batista (facundo) wrote :

All looks great! Thanks

review: Approve
Revision history for this message
Michał Sawicz (saviq) :
review: Approve
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-12-09 15:26:12 +0000
3+++ CMakeLists.txt 2015-01-07 23:05:33 +0000
4@@ -207,7 +207,7 @@
5 # API version
6 set(UNITY_SCOPES_MAJOR 0)
7 set(UNITY_SCOPES_MINOR 6)
8-set(UNITY_SCOPES_MICRO 10)
9+set(UNITY_SCOPES_MICRO 11)
10 set(UNITY_SCOPES_SOVERSION 3)
11
12 # Version for testing, with all symbols visible
13
14=== modified file 'RELEASE_NOTES.md'
15--- RELEASE_NOTES.md 2014-12-09 15:51:02 +0000
16+++ RELEASE_NOTES.md 2015-01-07 23:05:33 +0000
17@@ -1,6 +1,18 @@
18 Release notes
19 =============
20
21+Changes in version 0.6.11
22+=========================
23+ - The JSON for a CategoryRenderer now supports a "fallback" field in the
24+ "art" and "mascot" entries of the "components" dictionary.
25+ This allows a scope to specify a category-specific
26+ fallback image in case the artwork for a result cannot be retrieved.
27+
28+ - PreviewWidget now supports a "fallback" field for the "image",
29+ "gallery", and "header" widget types. This allows the scope
30+ to specify a fallback image in case the artwork for a widget
31+ cannot be retrieved.
32+
33 Changes in version 0.6.10
34 =========================
35 - Renamed "Tags" scope .ini option to "Keywords".
36
37=== modified file 'debian/changelog'
38--- debian/changelog 2014-12-12 11:48:26 +0000
39+++ debian/changelog 2015-01-07 23:05:33 +0000
40@@ -1,3 +1,17 @@
41+unity-scopes-api (0.6.11+15.04.20141212-0ubuntu2) UNRELEASED; urgency=medium
42+
43+ * The JSON for a CategoryRenderer now supports a "fallback" field in the
44+ "art" and "mascot" entries of the "components" dictionary.
45+ This allows a scope to specify a category-specific
46+ fallback image in case the artwork for a result cannot be retrieved.
47+
48+ * PreviewWidget now supports a "fallback" field for the "image",
49+ "gallery", and "header" widget types. This allows the scope
50+ to specify a fallback image in case the artwork for a widget
51+ cannot be retrieved.
52+
53+ -- Michi Henning <michi.henning@canonical.com> Tue, 06 Jan 2015 14:03:54 +1000
54+
55 unity-scopes-api (0.6.10+15.04.20141212-0ubuntu1) vivid; urgency=low
56
57 [ Pawel Stolowski ]
58
59=== modified file 'include/unity/scopes/PreviewWidget.h'
60--- include/unity/scopes/PreviewWidget.h 2014-11-03 05:31:30 +0000
61+++ include/unity/scopes/PreviewWidget.h 2015-01-07 23:05:33 +0000
62@@ -64,12 +64,14 @@
63 The JSON definition must be a dictionary that includes widget "id" and all the values of attributes required by desired
64 \link previewwidgets widget type\endlink. For example, a definition of image widget may look as follows:
65 \code{.cpp}
66- PreviewWidget img(R"({"id": "img", "type": "image", "source": "http://imageuri"})");
67+ PreviewWidget img(R"({"id": "img", "type": "image", "source": "http://imageuri",
68+ "fallback": "file:///tmp/image.png"})");
69 \endcode
70
71 For cases where attribute mappings are to be used instead of direct values, they need to be enclosed in the "components" dictionary, e.g.
72 \code{.cpp}
73- PreviewWidget img(R"({"id": "img", "type": "image", "components": { "source": "screenshot-url" } })");
74+ PreviewWidget img(R"({"id": "img", "type": "image", "fallback": "file:///tmp/image.png",
75+ "components": { "source": "screenshot-url" } })");
76 \endcode
77 (this example assumes "screenshot-url" value is either available in the result object that's being previewed, or it will be pushed with
78 unity::scopes::PreviewReply::push() method)
79
80=== modified file 'src/scopes/CategoryRenderer.cpp'
81--- src/scopes/CategoryRenderer.cpp 2014-08-11 11:28:07 +0000
82+++ src/scopes/CategoryRenderer.cpp 2015-01-07 23:05:33 +0000
83@@ -49,7 +49,8 @@
84
85 As specified by the \c "category-layout" key of the \c "template" dictionary, Unity will render results associated with this category in a grid layout. The \c "components" dictionary specifies which result fields are used by Unity. In case of this definition, each tile of the grid will map the "title" field from the result (set also by the call to unity::scopes::Result::set_title()) as title for the grid tile, and "art" field from the result (see unity::scopes::Result::set_art()) as the icon for the grid tile.
86
87-To sum up, the \c "template" dictionary contains information to determine the correct renderer and its parameters, and the \c "components" dictionary contains mapping specifying which fields of the results are used by the renderer, where keys of the dictionary are understood by Unity and values specify either field name of the results directly (<tt>{"title": "album_name"}</tt> would mean that Unity will use <tt>result["album_name"]</tt> as a title for the grid tile), or the value can specify extra hints for the renderer as well as the result field name (<tt>{"art": {"field": "icon", "aspect-ratio": 1.3}}</tt>).
88+To sum up, the \c "template" dictionary contains information to determine the correct renderer and its parameters, and the \c "components" dictionary contains mapping specifying which fields of the results are used by the renderer, where keys of the dictionary are understood by Unity and values specify either field name of the results directly (<tt>{"title": "album_name"}</tt> would mean that Unity will use <tt>result["album_name"]</tt> as a title for the grid tile), or the value can specify extra hints for the renderer as well as the result field name and a fallback image
89+(<tt>{"art": {"field": "icon", "aspect-ratio": 1.3, "fallback": "file:///path_to_fallback_image}}</tt>).
90
91 \section jsonschema1 JSON structure (v1)
92
93@@ -68,9 +69,11 @@
94 \subsection components1 components keys
95
96 \arg \c title String specifying card's title
97-\arg \c art URI specifying card's art (primary graphics), can contain subkeys: \c "aspect-ratio" (double specifying the aspect ratio of the graphics, default: 1.0)
98 \arg \c subtitle String specifying subtitle of a card
99-\arg \c mascot URI specifying card's mascot (secondary graphics)
100+\arg \c art URI specifying card's art (primary graphics), can contain subkeys: \c "aspect-ratio" (double specifying the aspect ratio of the graphics, default: 1.0), \c "field" (specifying the result's field name that contains the URI), and
101+\c "fallback" (fallback image to be used if the URI for a result's artwork cannot be retrieved).
102+\arg \c mascot URI specifying card's mascot (secondary graphics), can contain subkeys: \c "aspect-ratio" (double specifying the aspect ratio of the graphics, default: 1.0), \c "field" (specifying the result's field name that contains the URI), and
103+\c "fallback" (fallback image to be used if the URI for a result's mascot cannot be retrieved).
104 \arg \c emblem URI specifying card's emblem
105 \arg \c summary String specifying text summary
106 \arg \c background Card background URI, can override the default specified in the card-background field of the template section (same format as for card-background)
107@@ -79,9 +82,13 @@
108
109 \section example Example
110
111-In the following example a category named "Recommended" containing three components is created (title, art and subtitle), and a result providing values for these components is pushed.
112+In the following example a category named "Recommended" containing three components is created (title,
113+art, and subtitle), and a result providing values for these components is pushed.
114
115-Note that the scope is free to set any other extra result fields even if they are not used by the renderer (and therefore not specified in the \c "components" dictionary), such fields will be preserved and available to the scope when handling result-specific methods (for example unity::scopes::ScopeBase::preview()).
116+Note that the scope is free to set any other extra result fields even if they are not used by the
117+renderer (and therefore not specified in the \c "components" dictionary), such fields will be
118+preserved and available to the scope when handling result-specific methods (for example
119+unity::scopes::ScopeBase::preview()).
120
121 \code{.cpp}
122 // use raw string literal, so we don't have to escape all the quotes
123@@ -90,15 +97,16 @@
124 "schema-version" : 1,
125 "template" : {
126 "category-layout" : "carousel",
127- "card-size": "small"
128+ "card-size" : "small"
129 },
130 "components" : {
131 "title" : "title",
132 "art" : {
133- "field": "art",
134- "aspect-ratio": 1.3
135+ "field" : "art",
136+ "aspect-ratio" : 1.3
137+ "fallback" : "file:///path_to_fallback_image",
138 },
139- "subtitle": "publisher"
140+ "subtitle" : "publisher"
141 }
142 }
143 )";
144
145=== modified file 'src/scopes/PreviewWidget.cpp'
146--- src/scopes/PreviewWidget.cpp 2014-08-22 11:07:41 +0000
147+++ src/scopes/PreviewWidget.cpp 2015-01-07 23:05:33 +0000
148@@ -152,12 +152,14 @@
149
150 \arg \c source A URI pointing to the image
151 \arg \c zoomable A boolean specifying whether the image is zoomable (default: \c false)
152+\arg \c fallback A fallback image to be used if the image URI cannot be retrieved (default: none)
153
154 \code{.cpp}
155 {
156 PreviewWidget w1("img1", "image");
157
158- w1.add_attribute_value("source", Variant("file:///tmp/image.jpg"));
159+ w1.add_attribute_value("source", Variant("http://example.com/image.jpg"));
160+ w1.add_attribute_value("fallback", Variant("file:///tmp/image.jpg"));
161 ...
162 }
163 \endcode
164@@ -169,16 +171,18 @@
165 List of attributes:
166
167 \arg \c sources An array of image URIs
168+\arg \c fallback A fallback image to be used if an image URI cannot be resolved (default: none)
169
170 \code{.cpp}
171 {
172 PreviewWidget w1("gal", "gallery");
173
174 VariantArray arr;
175- arr.push_back(Variant("file:///tmp/image1.jpg"));
176+ arr.push_back(Variant("http://example.com/image1.jpg"));
177 arr.push_back(Variant("file:///tmp/image2.jpg"));
178 arr.push_back(Variant("file:///tmp/image3.jpg"));
179 w1.add_attribute_value("sources", Variant(arr));
180+ w1.add_attribute_value("fallback", Variant("file:///tmp/fallback.png"));
181 ...
182 }
183 \endcode
184@@ -192,6 +196,7 @@
185 \arg \c title A string specifying the title
186 \arg \c subtitle A string specifying the subtitle
187 \arg \c mascot A URI specifying the mascot
188+\arg \c fallback A fallback image to be used if the mascot URI cannot be retrieved (default: none)
189 \arg \c emblem A URI specifying the emblem
190
191 \code{.cpp}
192@@ -199,7 +204,8 @@
193 PreviewWidget w1("hdr", "header");
194
195 w1.add_attribute_value("title", Variant("Result item"));
196- w1.add_attribute_value("mascot", Variant("file:///tmp/mascot.png"));
197+ w1.add_attribute_value("mascot", Variant("http://example.com/image.png"));
198+ w1.add_attribute_value("fallback", Variant("file:///tmp/fallback_mascot.png"));
199 ...
200 }
201 \endcode

Subscribers

People subscribed via source and target branches

to all changes: