Merge lp:~jamesh/unity-scope-scopes/category-renderer into lp:unity-scope-scopes

Proposed by James Henstridge
Status: Merged
Approved by: Michal Hruby
Approved revision: 16
Merged at revision: 13
Proposed branch: lp:~jamesh/unity-scope-scopes/category-renderer
Merge into: lp:unity-scope-scopes
Prerequisite: lp:~jamesh/unity-scope-scopes/scopes-api-0.3
Diff against target: 120 lines (+37/-21)
2 files modified
src/scopes-scope.cpp (+37/-19)
src/scopes.ini (+0/-2)
To merge this branch: bzr merge lp:~jamesh/unity-scope-scopes/category-renderer
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+206146@code.launchpad.net

Commit message

Use a custom category renderer, and update the preview to show the scope icon.

Description of the change

Add a custom category renderer to the scopes scope: rather than showing large artwork, use a mascot to the left of the description.

I've also updated the preview code to use add_component() to bind widget attributes to the result, and shown the scope icon in the preview as the header mascot.

To post a comment you must log in.
13. By James Henstridge

Fix widget type for art, and rename it from "screenshot" to "art", to
match the terminology in the scope metadata.

14. By James Henstridge

Add "publisher" key to result, and use it as subtitle in the category
renderer and preview header. Currently it is hard coded to "Canonical
Ltd", but should eventually come from scope metadata.

15. By James Henstridge

Rename publisher to author, as discussed on IRC.

16. By James Henstridge

Remove empty Icon and Art metadata keys.

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/scopes-scope.cpp'
2--- src/scopes-scope.cpp 2014-02-13 11:25:18 +0000
3+++ src/scopes-scope.cpp 2014-02-13 11:25:18 +0000
4@@ -29,6 +29,22 @@
5
6 using namespace unity::scopes;
7
8+static const char MISSING_ICON[] = "/usr/share/icons/unity-icon-theme/places/svg/service-generic.svg";
9+static const char SCOPES_CATEGORY_DEFINITION[] = R"(
10+{
11+ "schema-version": 1,
12+ "template": {
13+ "category-layout": "grid",
14+ "card-size": "medium"
15+ },
16+ "components": {
17+ "title": "title",
18+ "subtitle": "author",
19+ "mascot": "icon"
20+ }
21+}
22+)";
23+
24 int ScopesScope::start(std::string const&, RegistryProxy const &registry) {
25 this->registry = registry;
26 return VERSION;
27@@ -73,7 +89,8 @@
28 }
29
30 void ScopesQuery::run(SearchReplyProxy const &reply) {
31- auto cat = reply->register_category("scopes", "Scopes", "");
32+ CategoryRenderer renderer(SCOPES_CATEGORY_DEFINITION);
33+ auto cat = reply->register_category("scopes", "Scopes", "", renderer);
34
35 std::string term = lowercase(query.query_string());
36 const auto matches = scope.registry->list_if(
37@@ -102,19 +119,18 @@
38 result.set_title(item.scope_name());
39 }
40 try {
41- result.set_art(item.icon());
42+ result.set_art(item.art());
43 } catch (NotFoundException &e) {
44 }
45- if (result.art().empty()) {
46- result.set_art("/usr/share/icons/unity-icon-theme/places/svg/service-generic.svg");
47- }
48 result.set_dnd_uri(uri);
49 result["scope_name"] = item.scope_name();
50+ // FIXME: this should be provided by the scope metadata
51+ result["author"] = "Canonical Ltd";
52 result["description"] = item.description();
53 try {
54- result["screenshot"] = item.art();
55+ result["icon"] = item.icon();
56 } catch (NotFoundException &e) {
57- result["screenshot"] = "";
58+ result["icon"] = MISSING_ICON;
59 }
60 reply->push(result);
61 }
62@@ -129,24 +145,26 @@
63
64 void ScopesPreview::run(PreviewReplyProxy const &reply) {
65 ColumnLayout layout1col(1), layout2col(2), layout3col(3);
66- layout1col.add_column({"screenshot", "header", "actions", "description"});
67-
68- layout2col.add_column({"screenshot", "header"});
69- layout2col.add_column({"actions", "description"});
70-
71- layout3col.add_column({"screenshot", "header"});
72- layout3col.add_column({"actions", "description"});
73+ layout1col.add_column({"art", "header", "actions", "description"});
74+
75+ layout2col.add_column({"art"});
76+ layout2col.add_column({"header", "actions", "description"});
77+
78+ layout3col.add_column({"art"});
79+ layout3col.add_column({"header", "actions", "description"});
80 layout3col.add_column({});
81 reply->register_layout({layout1col, layout2col, layout3col});
82
83 PreviewWidget header("header", "header");
84- header.add_attribute("title", Variant(result.title()));
85+ header.add_component("title", "title");
86+ header.add_component("subtitle", "author");
87+ header.add_component("mascot", "icon");
88
89- PreviewWidget screenshot("screenshot", "img");
90- screenshot.add_attribute("source", result["screenshot"]);
91+ PreviewWidget art("art", "image");
92+ art.add_component("source", "art");
93
94 PreviewWidget description("description", "text");
95- description.add_attribute("text", result["description"]);
96+ description.add_component("text", "description");
97
98 PreviewWidget actions("actions", "actions");
99 {
100@@ -158,7 +176,7 @@
101 actions.add_attribute("actions", builder.end());
102 }
103
104- reply->push({header, screenshot, description, actions});
105+ reply->push({art, header, actions, description});
106 }
107
108 ScopesActivation::ScopesActivation(Result const &result)
109
110=== modified file 'src/scopes.ini'
111--- src/scopes.ini 2014-02-06 04:39:29 +0000
112+++ src/scopes.ini 2014-02-13 11:25:18 +0000
113@@ -1,7 +1,5 @@
114 [ScopeConfig]
115 DisplayName = Scopes
116 Description = This is an Ubuntu search plugin that enables information from available search plugins to be searched and displayed in the Dash underneath the Dash plugins header. If you do not wish to search this content source, you can disable this search plugin.
117-Art =
118-Icon =
119 SearchHint = Search for scopes
120 HotKey =

Subscribers

People subscribed via source and target branches

to all changes: