Merge lp:~jamesh/unity-scope-scopes/scopes-api-0.3 into lp:unity-scope-scopes

Proposed by James Henstridge
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: 10
Merged at revision: 12
Proposed branch: lp:~jamesh/unity-scope-scopes/scopes-api-0.3
Merge into: lp:unity-scope-scopes
Diff against target: 179 lines (+62/-19)
4 files modified
CMakeLists.txt (+1/-1)
debian/control (+1/-1)
src/scopes-scope.cpp (+43/-13)
src/scopes-scope.h (+17/-4)
To merge this branch: bzr merge lp:~jamesh/unity-scope-scopes/scopes-api-0.3
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
Review via email: mp+205696@code.launchpad.net

Commit message

Port to unity-scopes-api 0.3.1

Description of the change

Update to support unity-scopes-api 0.3

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

Require 0.3.1, since we reference the new *Metadata classes.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Looks good.

review: Approve
11. By James Henstridge

Add activation support to scope, telling the shell to perform a query on
the chosen scope.

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-02-05 06:47:24 +0000
3+++ CMakeLists.txt 2014-02-11 09:52:10 +0000
4@@ -5,7 +5,7 @@
5 find_package(Threads REQUIRED)
6
7 pkg_check_modules(UNITY REQUIRED
8- "libunity-scopes >= 0.2"
9+ "libunity-scopes >= 0.3.1"
10 )
11
12 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wmissing-declarations -pedantic -std=c++11")
13
14=== modified file 'debian/control'
15--- debian/control 2014-02-06 10:28:02 +0000
16+++ debian/control 2014-02-11 09:52:10 +0000
17@@ -4,7 +4,7 @@
18 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
19 Build-Depends: cmake (>= 2.8),
20 debhelper (>= 9),
21- libunity-scopes-dev (>= 0.2.0),
22+ libunity-scopes-dev (>= 0.3.1),
23 pkg-config,
24 Standards-Version: 3.9.4
25 Homepage: https://launchpad.net/unity-scope-scopes
26
27=== modified file 'src/scopes-scope.cpp'
28--- src/scopes-scope.cpp 2014-02-06 12:08:57 +0000
29+++ src/scopes-scope.cpp 2014-02-11 09:52:10 +0000
30@@ -24,6 +24,7 @@
31 #include <unity/scopes/PreviewWidget.h>
32 #include <unity/scopes/Registry.h>
33 #include <unity/scopes/ScopeExceptions.h>
34+#include <unity/scopes/VariantBuilder.h>
35 #include "scopes-scope.h"
36
37 using namespace unity::scopes;
38@@ -37,19 +38,29 @@
39 registry.reset();
40 }
41
42-QueryBase::UPtr ScopesScope::create_query(std::string const &q,
43- VariantMap const &hints) {
44+QueryBase::UPtr ScopesScope::create_query(Query const &q,
45+ SearchMetadata const &hints) {
46 QueryBase::UPtr query(new ScopesQuery(*this, q));
47 return query;
48 }
49
50 QueryBase::UPtr ScopesScope::preview(Result const &result,
51- VariantMap const &hints) {
52+ ActionMetadata const &hints) {
53 QueryBase::UPtr previewer(new ScopesPreview(*this, result));
54 return previewer;
55 }
56
57-ScopesQuery::ScopesQuery(ScopesScope &scope, std::string const &query)
58+ActivationBase::UPtr ScopesScope::activate(Result const &result, ActionMetadata const& hints) {
59+ ActivationBase::UPtr activation(new ScopesActivation(result));
60+ return activation;
61+}
62+
63+ActivationBase::UPtr ScopesScope::perform_action(Result const &result, ActionMetadata const& hints, std::string const &widget_id, std::string const &action_id) {
64+ ActivationBase::UPtr activation(new ScopesActivation(result));
65+ return activation;
66+}
67+
68+ScopesQuery::ScopesQuery(ScopesScope &scope, Query const &query)
69 : scope(scope), query(query) {
70 }
71
72@@ -64,7 +75,7 @@
73 void ScopesQuery::run(SearchReplyProxy const &reply) {
74 auto cat = reply->register_category("scopes", "Scopes", "");
75
76- std::string term = lowercase(this->query);
77+ std::string term = lowercase(query.query_string());
78 const auto matches = scope.registry->list_if(
79 [term](ScopeMetadata const &item) -> bool {
80 std::string display_name, description;
81@@ -118,13 +129,13 @@
82
83 void ScopesPreview::run(PreviewReplyProxy const &reply) {
84 ColumnLayout layout1col(1), layout2col(2), layout3col(3);
85- layout1col.add_column({"header", "screenshot", "description"});
86-
87- layout2col.add_column({"header", "screenshot"});
88- layout2col.add_column({"description"});
89-
90- layout3col.add_column({"header", "screenshot"});
91- layout3col.add_column({"description"});
92+ layout1col.add_column({"screenshot", "header", "actions", "description"});
93+
94+ layout2col.add_column({"screenshot", "header"});
95+ layout2col.add_column({"actions", "description"});
96+
97+ layout3col.add_column({"screenshot", "header"});
98+ layout3col.add_column({"actions", "description"});
99 layout3col.add_column({});
100 reply->register_layout({layout1col, layout2col, layout3col});
101
102@@ -137,7 +148,26 @@
103 PreviewWidget description("description", "text");
104 description.add_attribute("text", result["description"]);
105
106- reply->push({header, screenshot, description});
107+ PreviewWidget actions("actions", "actions");
108+ {
109+ VariantBuilder builder;
110+ builder.add_tuple({
111+ {"id", Variant("search")},
112+ {"label", Variant("Search")}
113+ });
114+ actions.add_attribute("actions", builder.end());
115+ }
116+
117+ reply->push({header, screenshot, description, actions});
118+}
119+
120+ScopesActivation::ScopesActivation(Result const &result)
121+ : result(result) {
122+}
123+
124+ActivationResponse ScopesActivation::activate() {
125+ Query query(result["scope_name"].get_string(), "", "");
126+ return ActivationResponse(query);
127 }
128
129 extern "C" ScopeBase *UNITY_SCOPE_CREATE_FUNCTION() {
130
131=== modified file 'src/scopes-scope.h'
132--- src/scopes-scope.h 2014-02-06 06:17:18 +0000
133+++ src/scopes-scope.h 2014-02-11 09:52:10 +0000
134@@ -29,8 +29,12 @@
135 public:
136 virtual int start(std::string const&, unity::scopes::RegistryProxy const&) override;
137 virtual void stop() override;
138- virtual unity::scopes::QueryBase::UPtr create_query(std::string const &q, unity::scopes::VariantMap const& hints) override;
139- virtual unity::scopes::QueryBase::UPtr preview(unity::scopes::Result const& result, unity::scopes::VariantMap const& hints) override;
140+
141+ virtual unity::scopes::QueryBase::UPtr create_query(unity::scopes::Query const &q, unity::scopes::SearchMetadata const& hints) override;
142+ virtual unity::scopes::QueryBase::UPtr preview(unity::scopes::Result const& result, unity::scopes::ActionMetadata const& hints) override;
143+
144+ virtual unity::scopes::ActivationBase::UPtr activate(unity::scopes::Result const &result, unity::scopes::ActionMetadata const& hints) override;
145+ virtual unity::scopes::ActivationBase::UPtr perform_action(unity::scopes::Result const &result, unity::scopes::ActionMetadata const& hints, std::string const &widget_id, std::string const &action_id) override;
146
147 private:
148 unity::scopes::RegistryProxy registry;
149@@ -39,13 +43,13 @@
150 class ScopesQuery : public unity::scopes::SearchQuery
151 {
152 public:
153- ScopesQuery(ScopesScope &scope, std::string const& query);
154+ ScopesQuery(ScopesScope &scope, unity::scopes::Query const& query);
155 virtual void cancelled() override;
156 virtual void run(unity::scopes::SearchReplyProxy const&reply) override;
157
158 private:
159 const ScopesScope &scope;
160- const std::string query;
161+ const unity::scopes::Query query;
162 };
163
164 class ScopesPreview : public unity::scopes::PreviewQuery
165@@ -60,5 +64,14 @@
166 const unity::scopes::Result result;
167 };
168
169+class ScopesActivation : public unity::scopes::ActivationBase
170+{
171+public:
172+ ScopesActivation(unity::scopes::Result const &result);
173+ virtual unity::scopes::ActivationResponse activate() override;
174+private:
175+ const unity::scopes::Result result;
176+};
177+
178
179 #endif

Subscribers

People subscribed via source and target branches

to all changes: