Merge lp:~alecu/unity-scopes-api/demo-scope into lp:unity-scopes-api

Proposed by Alejandro J. Cura
Status: Rejected
Rejected by: Marcus Tomlinson
Proposed branch: lp:~alecu/unity-scopes-api/demo-scope
Merge into: lp:unity-scopes-api
Diff against target: 163 lines (+97/-26)
1 file modified
demo/scopes/scope-A/scope-A.cpp (+97/-26)
To merge this branch: bzr merge lp:~alecu/unity-scopes-api/demo-scope
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Disapprove
Review via email: mp+232775@code.launchpad.net

Description of the change

Do not merge; this is just a test

To post a comment you must log in.
251. By Alejandro J. Cura

Show where actual installation happens

252. By Alejandro J. Cura

Some more comments

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Hey Alejandro, is this MP needed any more? Could you either delete this branch or change the status under "Branch information" to Abandoned. Trying to clean up a bit. Thanks

review: Needs Information
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Cleaning up old MPs

review: Disapprove

Unmerged revisions

252. By Alejandro J. Cura

Some more comments

251. By Alejandro J. Cura

Show where actual installation happens

250. By Alejandro J. Cura

Modified scope-A with a simpler sequence of previews, to ease testing online accounts integration in previews

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'demo/scopes/scope-A/scope-A.cpp'
2--- demo/scopes/scope-A/scope-A.cpp 2014-07-04 03:26:15 +0000
3+++ demo/scopes/scope-A/scope-A.cpp 2014-08-30 00:21:42 +0000
4@@ -95,6 +95,41 @@
5 string scope_id_;
6 };
7
8+class InstallingPreview : public PreviewQueryBase
9+{
10+public:
11+ InstallingPreview(Result const& result, ActionMetadata const& metadata) :
12+ PreviewQueryBase(result, metadata)
13+ {
14+
15+ }
16+
17+ virtual void cancelled() override
18+ {
19+ }
20+
21+ void startInstallation()
22+ {
23+ // The dbus call to download-manager to start the installation and get the "object_path" would happen *here*
24+ // the object_path is then used to show the progress
25+ }
26+
27+ virtual void run(PreviewReplyProxy const& reply) override
28+ {
29+ startInstallation();
30+
31+ PreviewWidgetList widgets;
32+ widgets.emplace_back(PreviewWidget(R"({"id": "header", "type": "header", "title": "Actual installation happens now...", "subtitle": "0% and counting!", "rating": "rating"})"));
33+
34+ if (!reply->push(widgets))
35+ {
36+ return; // Query was cancelled
37+ }
38+ cerr << "scope-A: preview for \"" << result().uri() << "\" complete" << endl;
39+ }
40+
41+};
42+
43 class MyPreview : public PreviewQueryBase
44 {
45 public:
46@@ -120,36 +155,19 @@
47 widgets.emplace_back(PreviewWidget(R"({"id": "header", "type": "header", "title": "title", "subtitle": "author", "rating": "rating"})"));
48 widgets.emplace_back(PreviewWidget(R"({"id": "img", "type": "image", "art": "screenshot-url"})"));
49
50- PreviewWidget w("img2", "image");
51- w.add_attribute_value("zoomable", Variant(false));
52- w.add_attribute_mapping("art", "screenshot-url");
53- widgets.emplace_back(w);
54-
55- ColumnLayout layout1col(1);
56- layout1col.add_column({"header", "title"});
57-
58- ColumnLayout layout2col(2);
59- layout2col.add_column({"header", "title"});
60- layout2col.add_column({"author", "rating"});
61-
62- ColumnLayout layout3col(3);
63- layout3col.add_column({"header", "title"});
64- layout3col.add_column({"author"});
65- layout3col.add_column({"rating"});
66-
67- reply->register_layout({layout1col, layout2col, layout3col});
68+ PreviewWidget buttons("buttons", "actions");
69+ VariantBuilder builder;
70+ builder.add_tuple({
71+ {"id", Variant("install_id")},
72+ {"label", Variant("Install")}
73+ });
74+ buttons.add_attribute_value("actions", builder.end());
75+ widgets.emplace_back(buttons);
76+
77 if (!reply->push(widgets))
78 {
79 return; // Query was cancelled
80 }
81- if (!reply->push("author", Variant("Foo")))
82- {
83- return; // Query was cancelled
84- }
85- if (!reply->push("rating", Variant("4 blah")))
86- {
87- return; // Query was cancelled
88- }
89 cerr << "scope-A: preview for \"" << result().uri() << "\" complete" << endl;
90 }
91
92@@ -157,6 +175,36 @@
93 string scope_id_;
94 };
95
96+class MyActivationQuery : public ActivationQueryBase
97+{
98+protected:
99+ ActivationResponse::Status status_ = ActivationResponse::Status::ShowPreview;
100+ VariantMap hints_;
101+public:
102+ MyActivationQuery(const Result& result, const ActionMetadata& metadata)
103+ : ActivationQueryBase(result, metadata)
104+ {
105+
106+ }
107+ void setStatus(ActivationResponse::Status status)
108+ {
109+ status_ = status;
110+ }
111+
112+ void setHint(std::string key, unity::scopes::Variant value)
113+ {
114+ hints_[key] = value;
115+ }
116+
117+ ActivationResponse activate() override
118+ {
119+ auto response = ActivationResponse(status_);
120+ response.set_scope_data(Variant(hints_));
121+ return response;
122+ }
123+
124+};
125+
126 class MyScope : public ScopeBase
127 {
128 public:
129@@ -175,11 +223,34 @@
130
131 virtual PreviewQueryBase::UPtr preview(Result const& result, ActionMetadata const& metadata) override
132 {
133+
134+ if (metadata.scope_data().which() != Variant::Type::Null)
135+ {
136+ auto metadict = metadata.scope_data().get_dict();
137+ if (metadict.count("action_id") != 0 && metadict["action_id"].get_string() == "install_hint")
138+ {
139+ return PreviewQueryBase::UPtr(new InstallingPreview(result, metadata));
140+ }
141+ }
142+
143 PreviewQueryBase::UPtr preview(new MyPreview(result, metadata, scope_id_));
144 cerr << "scope-A: created previewer: \"" << result.uri() << "\"" << endl;
145 return preview;
146 }
147
148+ virtual ActivationQueryBase::UPtr perform_action(Result const& result,
149+ ActionMetadata const& metadata,
150+ std::string const& /*widget_id*/,
151+ std::string const& action_id) override
152+ {
153+ auto activation = new MyActivationQuery(result, metadata);
154+ if (action_id == "install_id") {
155+ activation->setHint("action_id", Variant("install_hint"));
156+ activation->setStatus(ActivationResponse::Status::ShowPreview);
157+ }
158+ return ActivationQueryBase::UPtr(activation);
159+ }
160+
161 private:
162 string scope_id_;
163 };

Subscribers

People subscribed via source and target branches

to all changes: