Merge lp:~timo-jyrinki/unity/xpathselect-1.4 into lp:unity
- xpathselect-1.4
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 3588 |
Proposed branch: | lp:~timo-jyrinki/unity/xpathselect-1.4 |
Merge into: | lp:unity |
Diff against target: |
2497 lines (+962/-740) 33 files modified
CMakeLists.txt (+1/-1) UnityCore/Filters.cpp (+1/-1) UnityCore/Result.cpp (+5/-12) UnityCore/Scope.cpp (+1/-1) UnityCore/ScopeProxy.cpp (+4/-4) UnityCore/Variant.cpp (+264/-254) UnityCore/Variant.h (+69/-15) dash/FilterBar.cpp (+1/-5) dash/PlacesGroup.cpp (+5/-2) dash/previews/MusicPaymentPreview.cpp (+1/-2) dash/previews/PaymentPreview.cpp (+1/-7) dash/previews/PreviewNavigator.cpp (+1/-0) dash/previews/Track.cpp (+2/-1) debian/control (+2/-2) launcher/LauncherController.cpp (+8/-9) launcher/QuicklistView.cpp (+1/-0) launcher/SwitcherController.cpp (+2/-2) launcher/Tooltip.cpp (+2/-5) panel/PanelIndicatorEntryView.cpp (+1/-0) plugins/unityshell/src/AggregateMonitor.cpp (+0/-63) plugins/unityshell/src/AggregateMonitor.h (+0/-50) plugins/unityshell/src/ElapsedTimeMonitor.cpp (+0/-49) plugins/unityshell/src/ElapsedTimeMonitor.h (+0/-47) plugins/unityshell/src/unityshell.cpp (+4/-3) plugins/unityshell/src/unityshell.h (+14/-1) shutdown/SessionButton.cpp (+1/-0) tests/test_glib_variant.cpp (+407/-15) tests/test_panel_menu_view.cpp (+1/-1) tests/test_results.cpp (+2/-2) unity-shared/DebugDBusInterface.cpp (+117/-137) unity-shared/Introspectable.cpp (+39/-41) unity-shared/Introspectable.h (+4/-8) unity-shared/SearchBar.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~timo-jyrinki/unity/xpathselect-1.4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Christopher Townsend | Approve | ||
Review via email: mp+194077@code.launchpad.net |
Commit message
DebugDBusInterface: add support to libxpathselect-1.4
Some cleanups and reworking of glib::Variant and debug::
Same as lp:~3v1n0/unity/xpathselect-1.4 but with double function removed and packaging dependencies added.
Description of the change
Requires https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
This should be fixed as well now https:/
Christopher Townsend (townsend) wrote : | # |
Marco's branch was still missing the change to CMakeLists.txt, so we'll use this branch instead.
I've compiled and ran make check on this and it works, so approving.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2013-10-29 20:50:07 +0000 | |||
3 | +++ CMakeLists.txt 2013-11-06 08:52:17 +0000 | |||
4 | @@ -233,7 +233,7 @@ | |||
5 | 233 | nux-4.0>=4.0.1 | 233 | nux-4.0>=4.0.1 |
6 | 234 | sigc++-2.0 | 234 | sigc++-2.0 |
7 | 235 | unity-misc>=0.4.0 | 235 | unity-misc>=0.4.0 |
9 | 236 | xpathselect>=1.2 | 236 | xpathselect=1.4 |
10 | 237 | zeitgeist-2.0 | 237 | zeitgeist-2.0 |
11 | 238 | ) | 238 | ) |
12 | 239 | 239 | ||
13 | 240 | 240 | ||
14 | === modified file 'UnityCore/Filters.cpp' | |||
15 | --- UnityCore/Filters.cpp 2013-08-15 09:59:40 +0000 | |||
16 | +++ UnityCore/Filters.cpp 2013-11-06 08:52:17 +0000 | |||
17 | @@ -103,7 +103,7 @@ | |||
18 | 103 | current_hints[iter->first] = iter->second; | 103 | current_hints[iter->first] = iter->second; |
19 | 104 | } | 104 | } |
20 | 105 | 105 | ||
22 | 106 | dee_model_set_value(model_, iter_, FilterColumn::RENDERER_STATE, glib::Variant::FromHints(current_hints)); | 106 | dee_model_set_value(model_, iter_, FilterColumn::RENDERER_STATE, glib::Variant(current_hints)); |
23 | 107 | } | 107 | } |
24 | 108 | 108 | ||
25 | 109 | 109 | ||
26 | 110 | 110 | ||
27 | === modified file 'UnityCore/Result.cpp' | |||
28 | --- UnityCore/Result.cpp 2013-02-21 14:01:55 +0000 | |||
29 | +++ UnityCore/Result.cpp 2013-11-06 08:52:17 +0000 | |||
30 | @@ -150,18 +150,11 @@ | |||
31 | 150 | 150 | ||
32 | 151 | std::vector<glib::Variant> LocalResult::Variants() const | 151 | std::vector<glib::Variant> LocalResult::Variants() const |
33 | 152 | { | 152 | { |
46 | 153 | std::vector<glib::Variant> vars; | 153 | return { |
47 | 154 | vars.push_back(g_variant_new_string(uri.c_str())); | 154 | glib::Variant(uri), glib::Variant(icon_hint), glib::Variant(category_index), |
48 | 155 | vars.push_back(g_variant_new_string(icon_hint.c_str())); | 155 | glib::Variant(result_type), glib::Variant(mimetype), glib::Variant(name), |
49 | 156 | vars.push_back(g_variant_new_uint32(category_index)); | 156 | glib::Variant(comment), glib::Variant(dnd_uri), glib::Variant(hints) |
50 | 157 | vars.push_back(g_variant_new_uint32(result_type)); | 157 | }; |
39 | 158 | vars.push_back(g_variant_new_string(mimetype.c_str())); | ||
40 | 159 | vars.push_back(g_variant_new_string(name.c_str())); | ||
41 | 160 | vars.push_back(g_variant_new_string(comment.c_str())); | ||
42 | 161 | vars.push_back(g_variant_new_string(dnd_uri.c_str())); | ||
43 | 162 | vars.push_back(glib::Variant::FromHints(hints)); | ||
44 | 163 | |||
45 | 164 | return vars; | ||
51 | 165 | } | 158 | } |
52 | 166 | 159 | ||
53 | 167 | glib::Variant LocalResult::Variant() const | 160 | glib::Variant LocalResult::Variant() const |
54 | 168 | 161 | ||
55 | === modified file 'UnityCore/Scope.cpp' | |||
56 | --- UnityCore/Scope.cpp 2013-09-25 11:51:08 +0000 | |||
57 | +++ UnityCore/Scope.cpp 2013-11-06 08:52:17 +0000 | |||
58 | @@ -278,7 +278,7 @@ | |||
59 | 278 | } | 278 | } |
60 | 279 | 279 | ||
61 | 280 | glib::HintsMap tmp_hints = hints; | 280 | glib::HintsMap tmp_hints = hints; |
63 | 281 | tmp_hints["preview-action-id"] = g_variant_new_string(action->id.c_str()); | 281 | tmp_hints["preview-action-id"] = action->id; |
64 | 282 | pimpl->Activate(result, UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_ACTION, tmp_hints, callback, cancellable); | 282 | pimpl->Activate(result, UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_ACTION, tmp_hints, callback, cancellable); |
65 | 283 | } | 283 | } |
66 | 284 | 284 | ||
67 | 285 | 285 | ||
68 | === modified file 'UnityCore/ScopeProxy.cpp' | |||
69 | --- UnityCore/ScopeProxy.cpp 2013-09-25 11:51:08 +0000 | |||
70 | +++ UnityCore/ScopeProxy.cpp 2013-11-06 08:52:17 +0000 | |||
71 | @@ -401,7 +401,7 @@ | |||
72 | 401 | glib::HintsMap hints; | 401 | glib::HintsMap hints; |
73 | 402 | if (!owner_->form_factor().empty()) | 402 | if (!owner_->form_factor().empty()) |
74 | 403 | { | 403 | { |
76 | 404 | hints["form-factor"] = g_variant_new_string(owner_->form_factor().c_str()); | 404 | hints["form-factor"] = owner_->form_factor(); |
77 | 405 | } | 405 | } |
78 | 406 | hints["changed-filter-row"] = filter->VariantValue(); | 406 | hints["changed-filter-row"] = filter->VariantValue(); |
79 | 407 | Search(last_search_, hints, nullptr, cancel_scope_); | 407 | Search(last_search_, hints, nullptr, cancel_scope_); |
80 | @@ -521,7 +521,7 @@ | |||
81 | 521 | glib::HintsMap updated_hints(hints); | 521 | glib::HintsMap updated_hints(hints); |
82 | 522 | if (!owner_->form_factor().empty()) | 522 | if (!owner_->form_factor().empty()) |
83 | 523 | { | 523 | { |
85 | 524 | updated_hints["form-factor"] = g_variant_new_string(owner_->form_factor().c_str()); | 524 | updated_hints["form-factor"] = owner_->form_factor(); |
86 | 525 | } | 525 | } |
87 | 526 | Search(search_string, updated_hints, callback, canc); | 526 | Search(search_string, updated_hints, callback, canc); |
88 | 527 | } | 527 | } |
89 | @@ -791,9 +791,9 @@ | |||
90 | 791 | void ScopeProxy::Search(std::string const& search_string, glib::HintsMap const& user_hints, SearchCallback const& callback, GCancellable* cancellable) | 791 | void ScopeProxy::Search(std::string const& search_string, glib::HintsMap const& user_hints, SearchCallback const& callback, GCancellable* cancellable) |
91 | 792 | { | 792 | { |
92 | 793 | glib::HintsMap hints = user_hints; | 793 | glib::HintsMap hints = user_hints; |
94 | 794 | if (!form_factor.Get().empty() && hints.find("form-factor") == hints.end()) | 794 | if (!form_factor().empty() && hints.find("form-factor") == hints.end()) |
95 | 795 | { | 795 | { |
97 | 796 | hints["form-factor"] = g_variant_new_string(form_factor().c_str()); | 796 | hints["form-factor"] = form_factor(); |
98 | 797 | } | 797 | } |
99 | 798 | pimpl->Search(search_string, hints, callback, cancellable); | 798 | pimpl->Search(search_string, hints, callback, cancellable); |
100 | 799 | } | 799 | } |
101 | 800 | 800 | ||
102 | === modified file 'UnityCore/Variant.cpp' | |||
103 | --- UnityCore/Variant.cpp 2013-08-23 17:21:44 +0000 | |||
104 | +++ UnityCore/Variant.cpp 2013-11-06 08:52:17 +0000 | |||
105 | @@ -1,6 +1,6 @@ | |||
106 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
107 | 2 | /* | 2 | /* |
109 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2013 Canonical Ltd |
110 | 4 | * | 4 | * |
111 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
112 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
113 | @@ -15,6 +15,7 @@ | |||
114 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
115 | 16 | * | 16 | * |
116 | 17 | * Authored by: Tim Penhey <tim.penhey@canonical.com> | 17 | * Authored by: Tim Penhey <tim.penhey@canonical.com> |
117 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
118 | 18 | */ | 19 | */ |
119 | 19 | 20 | ||
120 | 20 | #include "Variant.h" | 21 | #include "Variant.h" |
121 | @@ -27,7 +28,7 @@ | |||
122 | 27 | DECLARE_LOGGER(logger, "unity.glib.variant"); | 28 | DECLARE_LOGGER(logger, "unity.glib.variant"); |
123 | 28 | 29 | ||
124 | 29 | Variant::Variant() | 30 | Variant::Variant() |
126 | 30 | : variant_(NULL) | 31 | : variant_(nullptr) |
127 | 31 | {} | 32 | {} |
128 | 32 | 33 | ||
129 | 33 | Variant::Variant(GVariant* variant) | 34 | Variant::Variant(GVariant* variant) |
130 | @@ -41,9 +42,71 @@ | |||
131 | 41 | {} | 42 | {} |
132 | 42 | 43 | ||
133 | 43 | Variant::Variant(Variant const& other) | 44 | Variant::Variant(Variant const& other) |
135 | 44 | : variant_(other.variant_) | 45 | : Variant(other.variant_) |
136 | 46 | {} | ||
137 | 47 | |||
138 | 48 | Variant::Variant(std::nullptr_t) | ||
139 | 49 | : Variant() | ||
140 | 50 | {} | ||
141 | 51 | |||
142 | 52 | Variant::Variant(const char* value) | ||
143 | 53 | : Variant(g_variant_new_string(value ? value : value)) | ||
144 | 54 | {} | ||
145 | 55 | |||
146 | 56 | Variant::Variant(std::string const& value) | ||
147 | 57 | : Variant(g_variant_new_string(value.c_str())) | ||
148 | 58 | {} | ||
149 | 59 | |||
150 | 60 | Variant::Variant(unsigned char value) | ||
151 | 61 | : Variant(g_variant_new_byte(value)) | ||
152 | 62 | {} | ||
153 | 63 | |||
154 | 64 | Variant::Variant(int16_t value) | ||
155 | 65 | : Variant(g_variant_new_int16(value)) | ||
156 | 66 | {} | ||
157 | 67 | |||
158 | 68 | Variant::Variant(uint16_t value) | ||
159 | 69 | : Variant(g_variant_new_uint16(value)) | ||
160 | 70 | {} | ||
161 | 71 | |||
162 | 72 | Variant::Variant(int32_t value) | ||
163 | 73 | : Variant(g_variant_new_int32(value)) | ||
164 | 74 | {} | ||
165 | 75 | |||
166 | 76 | Variant::Variant(uint32_t value) | ||
167 | 77 | : Variant(g_variant_new_uint32(value)) | ||
168 | 78 | {} | ||
169 | 79 | |||
170 | 80 | Variant::Variant(int64_t value) | ||
171 | 81 | : Variant(g_variant_new_int64(value)) | ||
172 | 82 | {} | ||
173 | 83 | |||
174 | 84 | Variant::Variant(uint64_t value) | ||
175 | 85 | : Variant(g_variant_new_uint64(value)) | ||
176 | 86 | {} | ||
177 | 87 | |||
178 | 88 | Variant::Variant(bool value) | ||
179 | 89 | : Variant(g_variant_new_boolean(value)) | ||
180 | 90 | {} | ||
181 | 91 | |||
182 | 92 | Variant::Variant(double value) | ||
183 | 93 | : Variant(g_variant_new_double(value)) | ||
184 | 94 | {} | ||
185 | 95 | |||
186 | 96 | Variant::Variant(float value) | ||
187 | 97 | : Variant(static_cast<double>(value)) | ||
188 | 98 | {} | ||
189 | 99 | |||
190 | 100 | Variant::Variant(HintsMap const& hints) | ||
191 | 45 | { | 101 | { |
193 | 46 | if (variant_) g_variant_ref_sink(variant_); | 102 | GVariantBuilder b; |
194 | 103 | g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); | ||
195 | 104 | |||
196 | 105 | for (auto const& hint : hints) | ||
197 | 106 | g_variant_builder_add(&b, "{sv}", hint.first.c_str(), static_cast<GVariant*>(hint.second)); | ||
198 | 107 | |||
199 | 108 | variant_ = g_variant_builder_end(&b); | ||
200 | 109 | g_variant_ref_sink(variant_); | ||
201 | 47 | } | 110 | } |
202 | 48 | 111 | ||
203 | 49 | Variant::~Variant() | 112 | Variant::~Variant() |
204 | @@ -51,6 +114,25 @@ | |||
205 | 51 | if (variant_) g_variant_unref(variant_); | 114 | if (variant_) g_variant_unref(variant_); |
206 | 52 | } | 115 | } |
207 | 53 | 116 | ||
208 | 117 | glib::Variant get_variant(GVariant *variant_) | ||
209 | 118 | { | ||
210 | 119 | Variant value; | ||
211 | 120 | |||
212 | 121 | if (!variant_) | ||
213 | 122 | return value; | ||
214 | 123 | |||
215 | 124 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_VARIANT)) | ||
216 | 125 | { | ||
217 | 126 | value = Variant(g_variant_get_variant(variant_), StealRef()); | ||
218 | 127 | } | ||
219 | 128 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(v)"))) | ||
220 | 129 | { | ||
221 | 130 | g_variant_get(variant_, "(v)", &value); | ||
222 | 131 | } | ||
223 | 132 | |||
224 | 133 | return value; | ||
225 | 134 | } | ||
226 | 135 | |||
227 | 54 | std::string Variant::GetString() const | 136 | std::string Variant::GetString() const |
228 | 55 | { | 137 | { |
229 | 56 | const gchar *result = nullptr; | 138 | const gchar *result = nullptr; |
230 | @@ -70,182 +152,91 @@ | |||
231 | 70 | } | 152 | } |
232 | 71 | else | 153 | else |
233 | 72 | { | 154 | { |
235 | 73 | auto const& variant = GetVariant(); | 155 | auto const& variant = get_variant(variant_); |
236 | 74 | if (variant) | 156 | if (variant) |
237 | 75 | return variant.GetString(); | 157 | return variant.GetString(); |
238 | 76 | 158 | ||
241 | 77 | LOG_ERROR(logger) << "You're trying to extract a String from a variant which is of type " | 159 | LOG_ERROR(logger) << "You're trying to extract a 's' from a variant which is of type '" |
242 | 78 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | 160 | << g_variant_type_peek_string(g_variant_get_type(variant_)) << "'"; |
243 | 79 | } | 161 | } |
244 | 80 | 162 | ||
245 | 81 | return result ? result : ""; | 163 | return result ? result : ""; |
246 | 82 | } | 164 | } |
247 | 83 | 165 | ||
248 | 166 | template <typename TYPE, typename GTYPE> | ||
249 | 167 | TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str) | ||
250 | 168 | { | ||
251 | 169 | GTYPE value = 0; | ||
252 | 170 | |||
253 | 171 | if (!variant_) | ||
254 | 172 | return static_cast<TYPE>(value); | ||
255 | 173 | |||
256 | 174 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE(type_str))) | ||
257 | 175 | { | ||
258 | 176 | g_variant_get(variant_, type_str, &value); | ||
259 | 177 | } | ||
260 | 178 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE(fallback_type_str))) | ||
261 | 179 | { | ||
262 | 180 | g_variant_get(variant_, fallback_type_str, &value); | ||
263 | 181 | } | ||
264 | 182 | else | ||
265 | 183 | { | ||
266 | 184 | auto const& variant = get_variant(variant_); | ||
267 | 185 | if (variant) | ||
268 | 186 | return get_numeric_value<TYPE, GTYPE>(static_cast<GVariant*>(variant), type_str, fallback_type_str); | ||
269 | 187 | |||
270 | 188 | LOG_ERROR(logger) << "You're trying to extract a '" << type_str << "'" | ||
271 | 189 | << " from a variant which is of type '" | ||
272 | 190 | << g_variant_type_peek_string(g_variant_get_type(variant_)) | ||
273 | 191 | << "'"; | ||
274 | 192 | } | ||
275 | 193 | |||
276 | 194 | return static_cast<TYPE>(value); | ||
277 | 195 | } | ||
278 | 196 | |||
279 | 197 | unsigned char Variant::GetByte() const | ||
280 | 198 | { | ||
281 | 199 | return get_numeric_value<unsigned char, guchar>(variant_, "y", "(y)"); | ||
282 | 200 | } | ||
283 | 201 | |||
284 | 202 | int16_t Variant::GetInt16() const | ||
285 | 203 | { | ||
286 | 204 | return get_numeric_value<int16_t, gint16>(variant_, "n", "(n)"); | ||
287 | 205 | } | ||
288 | 206 | |||
289 | 207 | uint16_t Variant::GetUInt16() const | ||
290 | 208 | { | ||
291 | 209 | return get_numeric_value<uint16_t, guint16>(variant_, "q", "(q)"); | ||
292 | 210 | } | ||
293 | 211 | |||
294 | 84 | int32_t Variant::GetInt32() const | 212 | int32_t Variant::GetInt32() const |
295 | 85 | { | 213 | { |
320 | 86 | gint32 value = 0; | 214 | return get_numeric_value<int32_t, gint32>(variant_, "i", "(i)"); |
297 | 87 | |||
298 | 88 | if (!variant_) | ||
299 | 89 | return static_cast<int>(value); | ||
300 | 90 | |||
301 | 91 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_INT32)) | ||
302 | 92 | { | ||
303 | 93 | value = g_variant_get_int32(variant_); | ||
304 | 94 | } | ||
305 | 95 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(i)"))) | ||
306 | 96 | { | ||
307 | 97 | g_variant_get(variant_, "(i)", &value); | ||
308 | 98 | } | ||
309 | 99 | else | ||
310 | 100 | { | ||
311 | 101 | auto const& variant = GetVariant(); | ||
312 | 102 | if (variant) | ||
313 | 103 | return variant.GetInt32(); | ||
314 | 104 | |||
315 | 105 | LOG_ERROR(logger) << "You're trying to extract an Int32 from a variant which is of type " | ||
316 | 106 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
317 | 107 | } | ||
318 | 108 | |||
319 | 109 | return static_cast<int32_t>(value); | ||
321 | 110 | } | 215 | } |
322 | 111 | 216 | ||
323 | 112 | uint32_t Variant::GetUInt32() const | 217 | uint32_t Variant::GetUInt32() const |
324 | 113 | { | 218 | { |
349 | 114 | guint32 value = 0; | 219 | return get_numeric_value<uint32_t, guint32>(variant_, "u", "(u)"); |
350 | 115 | 220 | } | |
327 | 116 | if (!variant_) | ||
328 | 117 | return static_cast<unsigned>(value); | ||
329 | 118 | |||
330 | 119 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_UINT32)) | ||
331 | 120 | { | ||
332 | 121 | value = g_variant_get_uint32(variant_); | ||
333 | 122 | } | ||
334 | 123 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(u)"))) | ||
335 | 124 | { | ||
336 | 125 | g_variant_get(variant_, "(u)", &value); | ||
337 | 126 | } | ||
338 | 127 | else | ||
339 | 128 | { | ||
340 | 129 | auto const& variant = GetVariant(); | ||
341 | 130 | if (variant) | ||
342 | 131 | return variant.GetUInt32(); | ||
343 | 132 | |||
344 | 133 | LOG_ERROR(logger) << "You're trying to extract an UInt32 from a variant which is of type " | ||
345 | 134 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
346 | 135 | } | ||
347 | 136 | |||
348 | 137 | return static_cast<uint32_t>(value);} | ||
351 | 138 | 221 | ||
352 | 139 | int64_t Variant::GetInt64() const | 222 | int64_t Variant::GetInt64() const |
353 | 140 | { | 223 | { |
378 | 141 | gint64 value = 0; | 224 | return get_numeric_value<int64_t, gint64>(variant_, "x", "(x)"); |
355 | 142 | |||
356 | 143 | if (!variant_) | ||
357 | 144 | return static_cast<int64_t>(value); | ||
358 | 145 | |||
359 | 146 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_INT64)) | ||
360 | 147 | { | ||
361 | 148 | value = g_variant_get_int64(variant_); | ||
362 | 149 | } | ||
363 | 150 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(x)"))) | ||
364 | 151 | { | ||
365 | 152 | g_variant_get(variant_, "(x)", &value); | ||
366 | 153 | } | ||
367 | 154 | else | ||
368 | 155 | { | ||
369 | 156 | auto const& variant = GetVariant(); | ||
370 | 157 | if (variant) | ||
371 | 158 | return variant.GetInt64(); | ||
372 | 159 | |||
373 | 160 | LOG_ERROR(logger) << "You're trying to extract an Int64 from a variant which is of type " | ||
374 | 161 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
375 | 162 | } | ||
376 | 163 | |||
377 | 164 | return static_cast<int64_t>(value); | ||
379 | 165 | } | 225 | } |
380 | 166 | 226 | ||
381 | 167 | uint64_t Variant::GetUInt64() const | 227 | uint64_t Variant::GetUInt64() const |
382 | 168 | { | 228 | { |
407 | 169 | guint64 value = 0; | 229 | return get_numeric_value<uint64_t, guint64>(variant_, "t", "(t)"); |
384 | 170 | |||
385 | 171 | if (!variant_) | ||
386 | 172 | return static_cast<uint64_t>(value); | ||
387 | 173 | |||
388 | 174 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_UINT64)) | ||
389 | 175 | { | ||
390 | 176 | value = g_variant_get_uint64(variant_); | ||
391 | 177 | } | ||
392 | 178 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(t)"))) | ||
393 | 179 | { | ||
394 | 180 | g_variant_get(variant_, "(t)", &value); | ||
395 | 181 | } | ||
396 | 182 | else | ||
397 | 183 | { | ||
398 | 184 | auto const& variant = GetVariant(); | ||
399 | 185 | if (variant) | ||
400 | 186 | return variant.GetUInt64(); | ||
401 | 187 | |||
402 | 188 | LOG_ERROR(logger) << "You're trying to extract an UInt64 from a variant which is of type " | ||
403 | 189 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
404 | 190 | } | ||
405 | 191 | |||
406 | 192 | return static_cast<uint64_t>(value); | ||
408 | 193 | } | 230 | } |
409 | 194 | 231 | ||
410 | 195 | bool Variant::GetBool() const | 232 | bool Variant::GetBool() const |
411 | 196 | { | 233 | { |
436 | 197 | gboolean value = FALSE; | 234 | return get_numeric_value<bool, gboolean>(variant_, "b", "(b)"); |
413 | 198 | |||
414 | 199 | if (!variant_) | ||
415 | 200 | return (value != FALSE); | ||
416 | 201 | |||
417 | 202 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_BOOLEAN)) | ||
418 | 203 | { | ||
419 | 204 | value = g_variant_get_boolean(variant_); | ||
420 | 205 | } | ||
421 | 206 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(b)"))) | ||
422 | 207 | { | ||
423 | 208 | g_variant_get(variant_, "(b)", &value); | ||
424 | 209 | } | ||
425 | 210 | else | ||
426 | 211 | { | ||
427 | 212 | auto const& variant = GetVariant(); | ||
428 | 213 | if (variant) | ||
429 | 214 | return variant.GetBool(); | ||
430 | 215 | |||
431 | 216 | LOG_ERROR(logger) << "You're trying to extract a Boolean from a variant which is of type " | ||
432 | 217 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
433 | 218 | } | ||
434 | 219 | |||
435 | 220 | return (value != FALSE); | ||
437 | 221 | } | 235 | } |
438 | 222 | 236 | ||
439 | 223 | double Variant::GetDouble() const | 237 | double Variant::GetDouble() const |
440 | 224 | { | 238 | { |
465 | 225 | double value = 0.0; | 239 | return get_numeric_value<double, gdouble>(variant_, "d", "(d)"); |
442 | 226 | |||
443 | 227 | if (!variant_) | ||
444 | 228 | return value; | ||
445 | 229 | |||
446 | 230 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_DOUBLE)) | ||
447 | 231 | { | ||
448 | 232 | value = g_variant_get_double(variant_); | ||
449 | 233 | } | ||
450 | 234 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(d)"))) | ||
451 | 235 | { | ||
452 | 236 | g_variant_get(variant_, "(d)", &value); | ||
453 | 237 | } | ||
454 | 238 | else | ||
455 | 239 | { | ||
456 | 240 | auto const& variant = GetVariant(); | ||
457 | 241 | if (variant) | ||
458 | 242 | return variant.GetDouble(); | ||
459 | 243 | |||
460 | 244 | LOG_ERROR(logger) << "You're trying to extract a Double from a variant which is of type " | ||
461 | 245 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
462 | 246 | } | ||
463 | 247 | |||
464 | 248 | return value; | ||
466 | 249 | } | 240 | } |
467 | 250 | 241 | ||
468 | 251 | float Variant::GetFloat() const | 242 | float Variant::GetFloat() const |
469 | @@ -260,18 +251,12 @@ | |||
470 | 260 | if (!variant_) | 251 | if (!variant_) |
471 | 261 | return value; | 252 | return value; |
472 | 262 | 253 | ||
485 | 263 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_VARIANT)) | 254 | value = get_variant(variant_); |
486 | 264 | { | 255 | |
487 | 265 | value = Variant(g_variant_get_variant(variant_), StealRef()); | 256 | if (!value) |
488 | 266 | } | 257 | { |
489 | 267 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(v)"))) | 258 | LOG_ERROR(logger) << "You're trying to extract a 'v' from a variant which is of type '" |
490 | 268 | { | 259 | << g_variant_type_peek_string(g_variant_get_type(variant_)) << "'"; |
479 | 269 | g_variant_get(variant_, "(v)", &value); | ||
480 | 270 | } | ||
481 | 271 | else | ||
482 | 272 | { | ||
483 | 273 | LOG_ERROR(logger) << "You're trying to extract a Variant from a variant which is of type " | ||
484 | 274 | << g_variant_type_peek_string(g_variant_get_type(variant_)); | ||
491 | 275 | } | 260 | } |
492 | 276 | 261 | ||
493 | 277 | return value; | 262 | return value; |
494 | @@ -304,22 +289,6 @@ | |||
495 | 304 | return true; | 289 | return true; |
496 | 305 | } | 290 | } |
497 | 306 | 291 | ||
498 | 307 | Variant Variant::FromHints(HintsMap const& hints) | ||
499 | 308 | { | ||
500 | 309 | GVariantBuilder b; | ||
501 | 310 | g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); | ||
502 | 311 | |||
503 | 312 | for (glib::HintsMap::const_iterator it = hints.begin(); it != hints.end(); ++it) | ||
504 | 313 | { | ||
505 | 314 | const gchar* key = it->first.c_str(); | ||
506 | 315 | GVariant* ptr = it->second; | ||
507 | 316 | |||
508 | 317 | g_variant_builder_add(&b, "{sv}", key, ptr); | ||
509 | 318 | } | ||
510 | 319 | |||
511 | 320 | return g_variant_builder_end(&b); | ||
512 | 321 | } | ||
513 | 322 | |||
514 | 323 | void Variant::swap(Variant& other) | 292 | void Variant::swap(Variant& other) |
515 | 324 | { | 293 | { |
516 | 325 | std::swap(this->variant_, other.variant_); | 294 | std::swap(this->variant_, other.variant_); |
517 | @@ -340,6 +309,21 @@ | |||
518 | 340 | return *this; | 309 | return *this; |
519 | 341 | } | 310 | } |
520 | 342 | 311 | ||
521 | 312 | Variant& Variant::operator=(std::nullptr_t) { return operator=(Variant()); } | ||
522 | 313 | Variant& Variant::operator=(HintsMap const& map) { return operator=(Variant(map)); } | ||
523 | 314 | Variant& Variant::operator=(std::string const& value) { return operator=(Variant(value)); } | ||
524 | 315 | Variant& Variant::operator=(const char* value) { return operator=(Variant(value)); } | ||
525 | 316 | Variant& Variant::operator=(unsigned char value) { return operator=(Variant(value)); } | ||
526 | 317 | Variant& Variant::operator=(int16_t value) { return operator=(Variant(value)); } | ||
527 | 318 | Variant& Variant::operator=(uint16_t value) { return operator=(Variant(value)); } | ||
528 | 319 | Variant& Variant::operator=(int32_t value) { return operator=(Variant(value)); } | ||
529 | 320 | Variant& Variant::operator=(uint32_t value) { return operator=(Variant(value)); } | ||
530 | 321 | Variant& Variant::operator=(int64_t value) { return operator=(Variant(value)); } | ||
531 | 322 | Variant& Variant::operator=(uint64_t value) { return operator=(Variant(value)); } | ||
532 | 323 | Variant& Variant::operator=(bool value) { return operator=(Variant(value)); } | ||
533 | 324 | Variant& Variant::operator=(double value) { return operator=(Variant(value)); } | ||
534 | 325 | Variant& Variant::operator=(float value) { return operator=(Variant(value)); } | ||
535 | 326 | |||
536 | 343 | Variant::operator GVariant* () const | 327 | Variant::operator GVariant* () const |
537 | 344 | { | 328 | { |
538 | 345 | return variant_; | 329 | return variant_; |
539 | @@ -396,90 +380,116 @@ | |||
540 | 396 | 380 | ||
541 | 397 | namespace variant | 381 | namespace variant |
542 | 398 | { | 382 | { |
543 | 383 | using namespace glib; | ||
544 | 399 | 384 | ||
545 | 400 | BuilderWrapper::BuilderWrapper(GVariantBuilder* builder) | 385 | BuilderWrapper::BuilderWrapper(GVariantBuilder* builder) |
546 | 401 | : builder_(builder) | 386 | : builder_(builder) |
547 | 402 | {} | 387 | {} |
548 | 403 | 388 | ||
624 | 404 | BuilderWrapper& BuilderWrapper::add(char const* name, bool value) | 389 | BuilderWrapper& BuilderWrapper::add(std::string const& name, ValueType type, std::vector<Variant> const& values) |
625 | 405 | { | 390 | { |
626 | 406 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_boolean(value)); | 391 | GVariantBuilder array; |
627 | 407 | return *this; | 392 | g_variant_builder_init(&array, G_VARIANT_TYPE("av")); |
628 | 408 | } | 393 | g_variant_builder_add(&array, "v", g_variant_new_uint32(static_cast<uint32_t>(type))); |
629 | 409 | 394 | ||
630 | 410 | BuilderWrapper& BuilderWrapper::add(char const* name, char const* value) | 395 | for (auto const& value : values) |
631 | 411 | { | 396 | g_variant_builder_add(&array, "v", static_cast<GVariant*>(value)); |
632 | 412 | if (value) | 397 | |
633 | 413 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_string(value)); | 398 | g_variant_builder_add(builder_, "{sv}", name.c_str(), g_variant_builder_end(&array)); |
634 | 414 | else | 399 | |
635 | 415 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_string("")); | 400 | return *this; |
636 | 416 | 401 | } | |
637 | 417 | return *this; | 402 | |
638 | 418 | } | 403 | BuilderWrapper& BuilderWrapper::add(std::string const& name, bool value) |
639 | 419 | 404 | { | |
640 | 420 | BuilderWrapper& BuilderWrapper::add(char const* name, std::string const& value) | 405 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
641 | 421 | { | 406 | } |
642 | 422 | g_variant_builder_add(builder_, "{sv}", name, | 407 | |
643 | 423 | g_variant_new_string(value.c_str())); | 408 | BuilderWrapper& BuilderWrapper::add(std::string const& name, char const* value) |
644 | 424 | return *this; | 409 | { |
645 | 425 | } | 410 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
646 | 426 | 411 | } | |
647 | 427 | BuilderWrapper& BuilderWrapper::add(char const* name, int16_t value) | 412 | |
648 | 428 | { | 413 | BuilderWrapper& BuilderWrapper::add(std::string const& name, std::string const& value) |
649 | 429 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_int16(value)); | 414 | { |
650 | 430 | return *this; | 415 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
651 | 431 | } | 416 | } |
652 | 432 | 417 | ||
653 | 433 | BuilderWrapper& BuilderWrapper::add(char const* name, int32_t value) | 418 | BuilderWrapper& BuilderWrapper::add(std::string const& name, int16_t value) |
654 | 434 | { | 419 | { |
655 | 435 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_int32(value)); | 420 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
656 | 436 | return *this; | 421 | } |
657 | 437 | } | 422 | |
658 | 438 | 423 | BuilderWrapper& BuilderWrapper::add(std::string const& name, int32_t value) | |
659 | 439 | BuilderWrapper& BuilderWrapper::add(char const* name, int64_t value) | 424 | { |
660 | 440 | { | 425 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
661 | 441 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_int64(value)); | 426 | } |
662 | 442 | return *this; | 427 | |
663 | 443 | } | 428 | BuilderWrapper& BuilderWrapper::add(std::string const& name, int64_t value) |
664 | 444 | 429 | { | |
665 | 445 | BuilderWrapper& BuilderWrapper::add(char const* name, uint16_t value) | 430 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
666 | 446 | { | 431 | } |
667 | 447 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_uint16(value)); | 432 | |
668 | 448 | return *this; | 433 | BuilderWrapper& BuilderWrapper::add(std::string const& name, uint16_t value) |
669 | 449 | } | 434 | { |
670 | 450 | 435 | return add(name, ValueType::SIMPLE, {Variant(value)}); | |
671 | 451 | BuilderWrapper& BuilderWrapper::add(char const* name, uint32_t value) | 436 | } |
672 | 452 | { | 437 | |
673 | 453 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_uint32(value)); | 438 | BuilderWrapper& BuilderWrapper::add(std::string const& name, uint32_t value) |
674 | 454 | return *this; | 439 | { |
675 | 455 | } | 440 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
676 | 456 | 441 | } | |
677 | 457 | BuilderWrapper& BuilderWrapper::add(char const* name, uint64_t value) | 442 | |
678 | 458 | { | 443 | BuilderWrapper& BuilderWrapper::add(std::string const& name, uint64_t value) |
679 | 459 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_uint64(value)); | 444 | { |
680 | 460 | return *this; | 445 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
681 | 461 | } | 446 | } |
682 | 462 | 447 | ||
683 | 463 | BuilderWrapper& BuilderWrapper::add(char const* name, float value) | 448 | BuilderWrapper& BuilderWrapper::add(std::string const& name, float value) |
684 | 464 | { | 449 | { |
685 | 465 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_double(value)); | 450 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
686 | 466 | return *this; | 451 | } |
687 | 467 | } | 452 | |
688 | 468 | 453 | BuilderWrapper& BuilderWrapper::add(std::string const& name, double value) | |
689 | 469 | BuilderWrapper& BuilderWrapper::add(char const* name, double value) | 454 | { |
690 | 470 | { | 455 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
691 | 471 | g_variant_builder_add(builder_, "{sv}", name, g_variant_new_double(value)); | 456 | } |
692 | 472 | return *this; | 457 | |
693 | 473 | } | 458 | BuilderWrapper& BuilderWrapper::add(std::string const& name, GVariant* value) |
694 | 474 | 459 | { | |
695 | 475 | BuilderWrapper& BuilderWrapper::add(char const* name, GVariant* value) | 460 | return add(name, ValueType::SIMPLE, {Variant(value)}); |
696 | 476 | { | 461 | } |
697 | 477 | g_variant_builder_add(builder_, "{sv}", name, value); | 462 | |
698 | 478 | return *this; | 463 | BuilderWrapper& BuilderWrapper::add(std::string const& name, glib::Variant const& value) |
699 | 464 | { | ||
700 | 465 | return add(name, ValueType::SIMPLE, {value}); | ||
701 | 466 | } | ||
702 | 467 | |||
703 | 468 | BuilderWrapper& BuilderWrapper::add(std::string const& name, nux::Rect const& r) | ||
704 | 469 | { | ||
705 | 470 | return add(name, ValueType::RECTANGLE, {Variant(r.x), Variant(r.y), Variant(r.width), Variant(r.height)}); | ||
706 | 471 | } | ||
707 | 472 | |||
708 | 473 | BuilderWrapper& BuilderWrapper::add(std::string const& name, nux::Point const& p) | ||
709 | 474 | { | ||
710 | 475 | return add(name, ValueType::POINT, {Variant(p.x), Variant(p.y)}); | ||
711 | 476 | } | ||
712 | 477 | |||
713 | 478 | BuilderWrapper& BuilderWrapper::add(std::string const& name, nux::Size const& s) | ||
714 | 479 | { | ||
715 | 480 | return add(name, ValueType::SIZE, {Variant(s.width), Variant(s.height)}); | ||
716 | 481 | } | ||
717 | 482 | |||
718 | 483 | BuilderWrapper& BuilderWrapper::add(std::string const& name, nux::Color const& c) | ||
719 | 484 | { | ||
720 | 485 | int32_t r = c.red * 255.0f, g = c.green * 255.0f, b = c.blue * 255.0f, a = c.alpha * 255.0f; | ||
721 | 486 | return add(name, ValueType::COLOR, {Variant(r), Variant(g), Variant(b), Variant(a)}); | ||
722 | 479 | } | 487 | } |
723 | 480 | 488 | ||
724 | 481 | BuilderWrapper& BuilderWrapper::add(nux::Rect const& value) | 489 | BuilderWrapper& BuilderWrapper::add(nux::Rect const& value) |
725 | 482 | { | 490 | { |
726 | 491 | add("globalRect", value); | ||
727 | 492 | // Legacy support | ||
728 | 483 | add("x", value.x); | 493 | add("x", value.x); |
729 | 484 | add("y", value.y); | 494 | add("y", value.y); |
730 | 485 | add("width", value.width); | 495 | add("width", value.width); |
731 | 486 | 496 | ||
732 | === modified file 'UnityCore/Variant.h' | |||
733 | --- UnityCore/Variant.h 2013-08-23 17:21:44 +0000 | |||
734 | +++ UnityCore/Variant.h 2013-11-06 08:52:17 +0000 | |||
735 | @@ -1,6 +1,6 @@ | |||
736 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
737 | 2 | /* | 2 | /* |
739 | 3 | * Copyright (C) 2011 Canonical Ltd | 3 | * Copyright (C) 2011-2013 Canonical Ltd |
740 | 4 | * | 4 | * |
741 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
742 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
743 | @@ -15,6 +15,7 @@ | |||
744 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
745 | 16 | * | 16 | * |
746 | 17 | * Authored by: Tim Penhey <tim.penhey@canonical.com> | 17 | * Authored by: Tim Penhey <tim.penhey@canonical.com> |
747 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
748 | 18 | */ | 19 | */ |
749 | 19 | 20 | ||
750 | 20 | #ifndef UNITY_VARIANT_H | 21 | #ifndef UNITY_VARIANT_H |
751 | @@ -22,9 +23,11 @@ | |||
752 | 22 | 23 | ||
753 | 23 | #include <string> | 24 | #include <string> |
754 | 24 | #include <glib.h> | 25 | #include <glib.h> |
755 | 26 | #include <vector> | ||
756 | 25 | #include <map> | 27 | #include <map> |
757 | 26 | 28 | ||
758 | 27 | #include <NuxCore/Rect.h> | 29 | #include <NuxCore/Rect.h> |
759 | 30 | #include <NuxCore/Color.h> | ||
760 | 28 | 31 | ||
761 | 29 | namespace unity | 32 | namespace unity |
762 | 30 | { | 33 | { |
763 | @@ -45,10 +48,28 @@ | |||
764 | 45 | Variant(GVariant*); | 48 | Variant(GVariant*); |
765 | 46 | Variant(GVariant*, StealRef const&); | 49 | Variant(GVariant*, StealRef const&); |
766 | 47 | 50 | ||
767 | 51 | Variant(HintsMap const& hints); | ||
768 | 52 | explicit Variant(std::nullptr_t); | ||
769 | 53 | explicit Variant(std::string const&); | ||
770 | 54 | explicit Variant(const char*); | ||
771 | 55 | explicit Variant(unsigned char); | ||
772 | 56 | explicit Variant(int16_t); | ||
773 | 57 | explicit Variant(uint16_t); | ||
774 | 58 | explicit Variant(int32_t); | ||
775 | 59 | explicit Variant(uint32_t); | ||
776 | 60 | explicit Variant(int64_t); | ||
777 | 61 | explicit Variant(uint64_t); | ||
778 | 62 | explicit Variant(bool); | ||
779 | 63 | explicit Variant(double); | ||
780 | 64 | explicit Variant(float); | ||
781 | 65 | |||
782 | 48 | Variant(Variant const&); | 66 | Variant(Variant const&); |
783 | 49 | ~Variant(); | 67 | ~Variant(); |
784 | 50 | 68 | ||
785 | 51 | std::string GetString() const; | 69 | std::string GetString() const; |
786 | 70 | unsigned char GetByte() const; | ||
787 | 71 | int16_t GetInt16() const; | ||
788 | 72 | uint16_t GetUInt16() const; | ||
789 | 52 | int32_t GetInt32() const; | 73 | int32_t GetInt32() const; |
790 | 53 | uint32_t GetUInt32() const; | 74 | uint32_t GetUInt32() const; |
791 | 54 | int64_t GetInt64() const; | 75 | int64_t GetInt64() const; |
792 | @@ -59,11 +80,24 @@ | |||
793 | 59 | Variant GetVariant() const; | 80 | Variant GetVariant() const; |
794 | 60 | 81 | ||
795 | 61 | bool ASVToHints(HintsMap& hints) const; | 82 | bool ASVToHints(HintsMap& hints) const; |
796 | 62 | static Variant FromHints(HintsMap const& hints); | ||
797 | 63 | 83 | ||
798 | 64 | void swap(Variant&); | 84 | void swap(Variant&); |
799 | 65 | Variant& operator=(GVariant*); | 85 | Variant& operator=(GVariant*); |
800 | 66 | Variant& operator=(Variant); | 86 | Variant& operator=(Variant); |
801 | 87 | Variant& operator=(HintsMap const&); | ||
802 | 88 | Variant& operator=(std::nullptr_t); | ||
803 | 89 | Variant& operator=(std::string const&); | ||
804 | 90 | Variant& operator=(const char*); | ||
805 | 91 | Variant& operator=(unsigned char); | ||
806 | 92 | Variant& operator=(int16_t); | ||
807 | 93 | Variant& operator=(uint16_t); | ||
808 | 94 | Variant& operator=(int32_t); | ||
809 | 95 | Variant& operator=(uint32_t); | ||
810 | 96 | Variant& operator=(int64_t); | ||
811 | 97 | Variant& operator=(uint64_t); | ||
812 | 98 | Variant& operator=(bool); | ||
813 | 99 | Variant& operator=(double); | ||
814 | 100 | Variant& operator=(float); | ||
815 | 67 | operator GVariant*() const; | 101 | operator GVariant*() const; |
816 | 68 | operator bool() const; | 102 | operator bool() const; |
817 | 69 | 103 | ||
818 | @@ -78,24 +112,44 @@ | |||
819 | 78 | 112 | ||
820 | 79 | class BuilderWrapper | 113 | class BuilderWrapper |
821 | 80 | { | 114 | { |
822 | 115 | // XXX: Move this to Introspectable | ||
823 | 81 | public: | 116 | public: |
824 | 117 | enum class ValueType : uint32_t | ||
825 | 118 | { | ||
826 | 119 | // This should match the Autopilot Type IDs | ||
827 | 120 | SIMPLE = 0, | ||
828 | 121 | RECTANGLE = 1, | ||
829 | 122 | POINT = 2, | ||
830 | 123 | SIZE = 3, | ||
831 | 124 | COLOR = 4, | ||
832 | 125 | DATE = 5, | ||
833 | 126 | TIME = 6, | ||
834 | 127 | }; | ||
835 | 128 | |||
836 | 82 | BuilderWrapper(GVariantBuilder* builder); | 129 | BuilderWrapper(GVariantBuilder* builder); |
837 | 83 | 130 | ||
851 | 84 | BuilderWrapper& add(char const* name, bool value); | 131 | BuilderWrapper& add(std::string const& name, bool); |
852 | 85 | BuilderWrapper& add(char const* name, char const* value); | 132 | BuilderWrapper& add(std::string const& name, const char*); |
853 | 86 | BuilderWrapper& add(char const* name, std::string const& value); | 133 | BuilderWrapper& add(std::string const& name, std::string const&); |
854 | 87 | BuilderWrapper& add(char const* name, int16_t value); | 134 | BuilderWrapper& add(std::string const& name, int16_t); |
855 | 88 | BuilderWrapper& add(char const* name, int32_t value); | 135 | BuilderWrapper& add(std::string const& name, int32_t); |
856 | 89 | BuilderWrapper& add(char const* name, int64_t value); | 136 | BuilderWrapper& add(std::string const& name, int64_t); |
857 | 90 | BuilderWrapper& add(char const* name, uint16_t value); | 137 | BuilderWrapper& add(std::string const& name, uint16_t); |
858 | 91 | BuilderWrapper& add(char const* name, uint32_t value); | 138 | BuilderWrapper& add(std::string const& name, uint32_t); |
859 | 92 | BuilderWrapper& add(char const* name, uint64_t value); | 139 | BuilderWrapper& add(std::string const& name, uint64_t); |
860 | 93 | BuilderWrapper& add(char const* name, float value); | 140 | BuilderWrapper& add(std::string const& name, float); |
861 | 94 | BuilderWrapper& add(char const* name, double value); | 141 | BuilderWrapper& add(std::string const& name, double); |
862 | 95 | BuilderWrapper& add(char const* name, GVariant* value); | 142 | BuilderWrapper& add(std::string const& name, glib::Variant const&); |
863 | 96 | BuilderWrapper& add(nux::Rect const& value); | 143 | BuilderWrapper& add(std::string const& name, GVariant*); |
864 | 144 | |||
865 | 145 | BuilderWrapper& add(std::string const& name, nux::Rect const&); | ||
866 | 146 | BuilderWrapper& add(std::string const& name, nux::Point const&); | ||
867 | 147 | BuilderWrapper& add(std::string const& name, nux::Size const&); | ||
868 | 148 | BuilderWrapper& add(std::string const& name, nux::Color const&); | ||
869 | 149 | BuilderWrapper& add(nux::Rect const&); | ||
870 | 97 | 150 | ||
871 | 98 | private: | 151 | private: |
872 | 152 | BuilderWrapper& add(std::string const& name, ValueType, std::vector<glib::Variant> const&); | ||
873 | 99 | GVariantBuilder* builder_; | 153 | GVariantBuilder* builder_; |
874 | 100 | }; | 154 | }; |
875 | 101 | 155 | ||
876 | 102 | 156 | ||
877 | === modified file 'dash/FilterBar.cpp' | |||
878 | --- dash/FilterBar.cpp 2013-01-21 18:05:47 +0000 | |||
879 | +++ dash/FilterBar.cpp 2013-11-06 08:52:17 +0000 | |||
880 | @@ -144,11 +144,7 @@ | |||
881 | 144 | 144 | ||
882 | 145 | void FilterBar::AddProperties(GVariantBuilder* builder) | 145 | void FilterBar::AddProperties(GVariantBuilder* builder) |
883 | 146 | { | 146 | { |
889 | 147 | variant::BuilderWrapper(builder) | 147 | variant::BuilderWrapper(builder).add(GetAbsoluteGeometry()); |
885 | 148 | .add("x", GetAbsoluteX()) | ||
886 | 149 | .add("y", GetAbsoluteY()) | ||
887 | 150 | .add("width", GetAbsoluteWidth()) | ||
888 | 151 | .add("height", GetAbsoluteHeight()); | ||
890 | 152 | } | 148 | } |
891 | 153 | 149 | ||
892 | 154 | } // namespace dash | 150 | } // namespace dash |
893 | 155 | 151 | ||
894 | === modified file 'dash/PlacesGroup.cpp' | |||
895 | --- dash/PlacesGroup.cpp 2013-05-01 18:11:32 +0000 | |||
896 | +++ dash/PlacesGroup.cpp 2013-11-06 08:52:17 +0000 | |||
897 | @@ -649,6 +649,7 @@ | |||
898 | 649 | wrapper.add("header-y", _header_view->GetAbsoluteY()); | 649 | wrapper.add("header-y", _header_view->GetAbsoluteY()); |
899 | 650 | wrapper.add("header-width", _header_view->GetAbsoluteWidth()); | 650 | wrapper.add("header-width", _header_view->GetAbsoluteWidth()); |
900 | 651 | wrapper.add("header-height", _header_view->GetAbsoluteHeight()); | 651 | wrapper.add("header-height", _header_view->GetAbsoluteHeight()); |
901 | 652 | wrapper.add("header-geo", _header_view->GetAbsoluteGeometry()); | ||
902 | 652 | wrapper.add("header-has-keyfocus", HeaderHasKeyFocus()); | 653 | wrapper.add("header-has-keyfocus", HeaderHasKeyFocus()); |
903 | 653 | wrapper.add("header-is-highlighted", ShouldBeHighlighted()); | 654 | wrapper.add("header-is-highlighted", ShouldBeHighlighted()); |
904 | 654 | wrapper.add("name", _name->GetText()); | 655 | wrapper.add("name", _name->GetText()); |
905 | @@ -656,22 +657,24 @@ | |||
906 | 656 | wrapper.add("is-expanded", GetExpanded()); | 657 | wrapper.add("is-expanded", GetExpanded()); |
907 | 657 | wrapper.add("expand-label-is-visible", _expand_label->IsVisible()); | 658 | wrapper.add("expand-label-is-visible", _expand_label->IsVisible()); |
908 | 658 | wrapper.add("expand-label-y", _expand_label->GetAbsoluteY()); | 659 | wrapper.add("expand-label-y", _expand_label->GetAbsoluteY()); |
909 | 660 | wrapper.add("expand-label-geo", _expand_label->GetAbsoluteGeometry()); | ||
910 | 659 | wrapper.add("expand-label-baseline", _expand_label->GetBaseline()); | 661 | wrapper.add("expand-label-baseline", _expand_label->GetBaseline()); |
911 | 660 | wrapper.add("name-label-y", _name->GetAbsoluteY()); | 662 | wrapper.add("name-label-y", _name->GetAbsoluteY()); |
912 | 661 | wrapper.add("name-label-baseline", _name->GetBaseline()); | 663 | wrapper.add("name-label-baseline", _name->GetBaseline()); |
913 | 664 | wrapper.add("name-label-geo", _name->GetAbsoluteGeometry()); | ||
914 | 662 | } | 665 | } |
915 | 663 | 666 | ||
916 | 664 | glib::Variant PlacesGroup::GetCurrentFocus() const | 667 | glib::Variant PlacesGroup::GetCurrentFocus() const |
917 | 665 | { | 668 | { |
918 | 666 | if (_header_view && _header_view->HasKeyFocus()) | 669 | if (_header_view && _header_view->HasKeyFocus()) |
919 | 667 | { | 670 | { |
921 | 668 | return g_variant_new_string("HeaderView"); | 671 | return glib::Variant("HeaderView"); |
922 | 669 | } | 672 | } |
923 | 670 | else if (_child_view && _child_view->HasKeyFocus()) | 673 | else if (_child_view && _child_view->HasKeyFocus()) |
924 | 671 | { | 674 | { |
925 | 672 | return g_variant_new("(si)", "ResultView", _child_view->GetSelectedIndex()); | 675 | return g_variant_new("(si)", "ResultView", _child_view->GetSelectedIndex()); |
926 | 673 | } | 676 | } |
928 | 674 | return glib::Variant(); | 677 | return nullptr; |
929 | 675 | } | 678 | } |
930 | 676 | 679 | ||
931 | 677 | void PlacesGroup::SetCurrentFocus(glib::Variant const& variant) | 680 | void PlacesGroup::SetCurrentFocus(glib::Variant const& variant) |
932 | 678 | 681 | ||
933 | === modified file 'dash/previews/MusicPaymentPreview.cpp' | |||
934 | --- dash/previews/MusicPaymentPreview.cpp 2013-07-10 15:14:02 +0000 | |||
935 | +++ dash/previews/MusicPaymentPreview.cpp 2013-11-06 08:52:17 +0000 | |||
936 | @@ -98,9 +98,8 @@ | |||
937 | 98 | { | 98 | { |
938 | 99 | // HACK: We need to think a better way to do this | 99 | // HACK: We need to think a better way to do this |
939 | 100 | auto const& password = password_entry_->text_entry()->GetText(); | 100 | auto const& password = password_entry_->text_entry()->GetText(); |
940 | 101 | glib::Variant variant_pw(g_variant_new_string(password.c_str())); | ||
941 | 102 | glib::HintsMap hints { | 101 | glib::HintsMap hints { |
943 | 103 | std::make_pair(MusicPaymentPreview::DATA_PASSWORD_KEY, variant_pw) | 102 | {MusicPaymentPreview::DATA_PASSWORD_KEY, glib::Variant(password)} |
944 | 104 | }; | 103 | }; |
945 | 105 | preview_model_->PerformAction(id, hints); | 104 | preview_model_->PerformAction(id, hints); |
946 | 106 | 105 | ||
947 | 107 | 106 | ||
948 | === modified file 'dash/previews/PaymentPreview.cpp' | |||
949 | --- dash/previews/PaymentPreview.cpp 2013-07-10 15:14:02 +0000 | |||
950 | +++ dash/previews/PaymentPreview.cpp 2013-11-06 08:52:17 +0000 | |||
951 | @@ -170,13 +170,7 @@ | |||
952 | 170 | 170 | ||
953 | 171 | void OverlaySpinner::AddProperties(GVariantBuilder* builder) | 171 | void OverlaySpinner::AddProperties(GVariantBuilder* builder) |
954 | 172 | { | 172 | { |
962 | 173 | nux::Geometry geo = GetGeometry(); | 173 | variant::BuilderWrapper(builder).add(GetAbsoluteGeometry()); |
956 | 174 | |||
957 | 175 | variant::BuilderWrapper(builder) | ||
958 | 176 | .add("x", geo.x) | ||
959 | 177 | .add("y", geo.y) | ||
960 | 178 | .add("width", geo.width) | ||
961 | 179 | .add("height", geo.height); | ||
963 | 180 | } | 174 | } |
964 | 181 | 175 | ||
965 | 182 | 176 | ||
966 | 183 | 177 | ||
967 | === modified file 'dash/previews/PreviewNavigator.cpp' | |||
968 | --- dash/previews/PreviewNavigator.cpp 2012-11-29 10:19:01 +0000 | |||
969 | +++ dash/previews/PreviewNavigator.cpp 2013-11-06 08:52:17 +0000 | |||
970 | @@ -70,6 +70,7 @@ | |||
971 | 70 | .add("button-y", texture_->GetAbsoluteY()) | 70 | .add("button-y", texture_->GetAbsoluteY()) |
972 | 71 | .add("button-width", texture_->GetGeometry().width) | 71 | .add("button-width", texture_->GetGeometry().width) |
973 | 72 | .add("button-height", texture_->GetGeometry().height) | 72 | .add("button-height", texture_->GetGeometry().height) |
974 | 73 | .add("button-geo", texture_->GetAbsoluteGeometry()) | ||
975 | 73 | .add("direction", static_cast<int>(direction_)); | 74 | .add("direction", static_cast<int>(direction_)); |
976 | 74 | } | 75 | } |
977 | 75 | 76 | ||
978 | 76 | 77 | ||
979 | === modified file 'dash/previews/Track.cpp' | |||
980 | --- dash/previews/Track.cpp 2013-07-01 21:17:59 +0000 | |||
981 | +++ dash/previews/Track.cpp 2013-11-06 08:52:17 +0000 | |||
982 | @@ -147,7 +147,8 @@ | |||
983 | 147 | .add("playpause-x", track_status_layout_->GetAbsoluteX()) | 147 | .add("playpause-x", track_status_layout_->GetAbsoluteX()) |
984 | 148 | .add("playpause-y", track_status_layout_->GetAbsoluteX()) | 148 | .add("playpause-y", track_status_layout_->GetAbsoluteX()) |
985 | 149 | .add("playpause-width", track_status_layout_->GetGeometry().width) | 149 | .add("playpause-width", track_status_layout_->GetGeometry().width) |
987 | 150 | .add("playpause-height", track_status_layout_->GetGeometry().height); | 150 | .add("playpause-height", track_status_layout_->GetGeometry().height) |
988 | 151 | .add("playpause-geo", track_status_layout_->GetAbsoluteGeometry()); | ||
989 | 151 | } | 152 | } |
990 | 152 | 153 | ||
991 | 153 | void Track::Update(dash::Track const& track) | 154 | void Track::Update(dash::Track const& track) |
992 | 154 | 155 | ||
993 | === modified file 'debian/control' | |||
994 | --- debian/control 2013-10-29 20:50:07 +0000 | |||
995 | +++ debian/control 2013-11-06 08:52:17 +0000 | |||
996 | @@ -48,7 +48,7 @@ | |||
997 | 48 | libxcb-icccm4-dev, | 48 | libxcb-icccm4-dev, |
998 | 49 | libxfixes-dev (>= 1:5.0.1-1), | 49 | libxfixes-dev (>= 1:5.0.1-1), |
999 | 50 | libxi-dev (>= 2:1.7.1.901), | 50 | libxi-dev (>= 2:1.7.1.901), |
1001 | 51 | libxpathselect-dev (>=1.3), | 51 | libxpathselect-dev (>=1.4), |
1002 | 52 | libzeitgeist-2.0-dev, | 52 | libzeitgeist-2.0-dev, |
1003 | 53 | pkg-config, | 53 | pkg-config, |
1004 | 54 | python (>= 2.7), | 54 | python (>= 2.7), |
1005 | @@ -178,7 +178,7 @@ | |||
1006 | 178 | python-testtools, | 178 | python-testtools, |
1007 | 179 | python-xdg, | 179 | python-xdg, |
1008 | 180 | python-xlib, | 180 | python-xlib, |
1010 | 181 | libxpathselect1.3 (>= 1.3), | 181 | libxpathselect1.4 (>= 1.4), |
1011 | 182 | Description: Autopiloted tests for Unity | 182 | Description: Autopiloted tests for Unity |
1012 | 183 | We test Unity automatically through autopilot, a framework which enables us | 183 | We test Unity automatically through autopilot, a framework which enables us |
1013 | 184 | to trigger keyboard and mouse events on the fly as well as introspecting | 184 | to trigger keyboard and mouse events on the fly as well as introspecting |
1014 | 185 | 185 | ||
1015 | === modified file 'launcher/LauncherController.cpp' | |||
1016 | --- launcher/LauncherController.cpp 2013-10-21 23:48:47 +0000 | |||
1017 | +++ launcher/LauncherController.cpp 2013-11-06 08:52:17 +0000 | |||
1018 | @@ -164,8 +164,7 @@ | |||
1019 | 164 | 164 | ||
1020 | 165 | if (selected) | 165 | if (selected) |
1021 | 166 | { | 166 | { |
1024 | 167 | ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, | 167 | ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, glib::Variant(selected->tooltip_text())); |
1023 | 168 | g_variant_new_string(selected->tooltip_text().c_str())); | ||
1025 | 169 | } | 168 | } |
1026 | 170 | }); | 169 | }); |
1027 | 171 | 170 | ||
1028 | @@ -1312,12 +1311,12 @@ | |||
1029 | 1312 | if (pimpl->launcher_grabbed) | 1311 | if (pimpl->launcher_grabbed) |
1030 | 1313 | { | 1312 | { |
1031 | 1314 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV, | 1313 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV, |
1033 | 1315 | g_variant_new_int32(pimpl->keyboard_launcher_->monitor)); | 1314 | glib::Variant(pimpl->keyboard_launcher_->monitor())); |
1034 | 1316 | } | 1315 | } |
1035 | 1317 | else | 1316 | else |
1036 | 1318 | { | 1317 | { |
1037 | 1319 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_SWITCHER, | 1318 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_SWITCHER, |
1039 | 1320 | g_variant_new_int32(pimpl->keyboard_launcher_->monitor)); | 1319 | glib::Variant(pimpl->keyboard_launcher_->monitor())); |
1040 | 1321 | } | 1320 | } |
1041 | 1322 | 1321 | ||
1042 | 1323 | AbstractLauncherIcon::Ptr const& selected = pimpl->model_->Selection(); | 1322 | AbstractLauncherIcon::Ptr const& selected = pimpl->model_->Selection(); |
1043 | @@ -1325,7 +1324,7 @@ | |||
1044 | 1325 | if (selected) | 1324 | if (selected) |
1045 | 1326 | { | 1325 | { |
1046 | 1327 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, | 1326 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, |
1048 | 1328 | g_variant_new_string(selected->tooltip_text().c_str())); | 1327 | glib::Variant(selected->tooltip_text())); |
1049 | 1329 | } | 1328 | } |
1050 | 1330 | } | 1329 | } |
1051 | 1331 | 1330 | ||
1052 | @@ -1338,7 +1337,7 @@ | |||
1053 | 1338 | if (selected) | 1337 | if (selected) |
1054 | 1339 | { | 1338 | { |
1055 | 1340 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, | 1339 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, |
1057 | 1341 | g_variant_new_string(selected->tooltip_text().c_str())); | 1340 | glib::Variant(selected->tooltip_text())); |
1058 | 1342 | } | 1341 | } |
1059 | 1343 | } | 1342 | } |
1060 | 1344 | 1343 | ||
1061 | @@ -1351,7 +1350,7 @@ | |||
1062 | 1351 | if (selected) | 1350 | if (selected) |
1063 | 1352 | { | 1351 | { |
1064 | 1353 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, | 1352 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, |
1066 | 1354 | g_variant_new_string(selected->tooltip_text().c_str())); | 1353 | glib::Variant(selected->tooltip_text())); |
1067 | 1355 | } | 1354 | } |
1068 | 1356 | } | 1355 | } |
1069 | 1357 | 1356 | ||
1070 | @@ -1376,12 +1375,12 @@ | |||
1071 | 1376 | pimpl->launcher_event_outside_connection_->disconnect(); | 1375 | pimpl->launcher_event_outside_connection_->disconnect(); |
1072 | 1377 | pimpl->launcher_grabbed = false; | 1376 | pimpl->launcher_grabbed = false; |
1073 | 1378 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV, | 1377 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV, |
1075 | 1379 | g_variant_new_boolean(pimpl->keynav_restore_window_)); | 1378 | glib::Variant(pimpl->keynav_restore_window_)); |
1076 | 1380 | } | 1379 | } |
1077 | 1381 | else | 1380 | else |
1078 | 1382 | { | 1381 | { |
1079 | 1383 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_SWITCHER, | 1382 | pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_SWITCHER, |
1081 | 1384 | g_variant_new_boolean(pimpl->keynav_restore_window_)); | 1383 | glib::Variant(pimpl->keynav_restore_window_)); |
1082 | 1385 | } | 1384 | } |
1083 | 1386 | 1385 | ||
1084 | 1387 | if (activate) | 1386 | if (activate) |
1085 | 1388 | 1387 | ||
1086 | === modified file 'launcher/QuicklistView.cpp' | |||
1087 | --- launcher/QuicklistView.cpp 2013-10-03 22:31:18 +0000 | |||
1088 | +++ launcher/QuicklistView.cpp 2013-11-06 08:52:17 +0000 | |||
1089 | @@ -1303,6 +1303,7 @@ | |||
1090 | 1303 | .add(GetAbsoluteGeometry()) | 1303 | .add(GetAbsoluteGeometry()) |
1091 | 1304 | .add("base_x", GetBaseX()) | 1304 | .add("base_x", GetBaseX()) |
1092 | 1305 | .add("base_y", GetBaseY()) | 1305 | .add("base_y", GetBaseY()) |
1093 | 1306 | .add("base", nux::Point(GetBaseX(), GetBaseY())) | ||
1094 | 1306 | .add("active", IsVisible()); | 1307 | .add("active", IsVisible()); |
1095 | 1307 | } | 1308 | } |
1096 | 1308 | 1309 | ||
1097 | 1309 | 1310 | ||
1098 | === modified file 'launcher/SwitcherController.cpp' | |||
1099 | --- launcher/SwitcherController.cpp 2013-10-02 23:36:48 +0000 | |||
1100 | +++ launcher/SwitcherController.cpp 2013-11-06 08:52:17 +0000 | |||
1101 | @@ -395,7 +395,7 @@ | |||
1102 | 395 | } | 395 | } |
1103 | 396 | 396 | ||
1104 | 397 | ubus_manager_.SendMessage(UBUS_SWITCHER_SELECTION_CHANGED, | 397 | ubus_manager_.SendMessage(UBUS_SWITCHER_SELECTION_CHANGED, |
1106 | 398 | g_variant_new_string(icon->tooltip_text().c_str())); | 398 | glib::Variant(icon->tooltip_text())); |
1107 | 399 | } | 399 | } |
1108 | 400 | } | 400 | } |
1109 | 401 | 401 | ||
1110 | @@ -497,7 +497,7 @@ | |||
1111 | 497 | } | 497 | } |
1112 | 498 | } | 498 | } |
1113 | 499 | 499 | ||
1115 | 500 | ubus_manager_.SendMessage(UBUS_SWITCHER_END, g_variant_new_boolean(!accept_state)); | 500 | ubus_manager_.SendMessage(UBUS_SWITCHER_END, glib::Variant(!accept_state)); |
1116 | 501 | ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, obj_->monitor_)); | 501 | ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, obj_->monitor_)); |
1117 | 502 | 502 | ||
1118 | 503 | sources_.Remove(VIEW_CONSTRUCT_IDLE); | 503 | sources_.Remove(VIEW_CONSTRUCT_IDLE); |
1119 | 504 | 504 | ||
1120 | === modified file 'launcher/Tooltip.cpp' | |||
1121 | --- launcher/Tooltip.cpp 2013-10-03 22:30:57 +0000 | |||
1122 | +++ launcher/Tooltip.cpp 2013-11-06 08:52:17 +0000 | |||
1123 | @@ -559,11 +559,8 @@ | |||
1124 | 559 | { | 559 | { |
1125 | 560 | variant::BuilderWrapper(builder) | 560 | variant::BuilderWrapper(builder) |
1126 | 561 | .add("text", text) | 561 | .add("text", text) |
1132 | 562 | .add("x", GetBaseX()) | 562 | .add("active", IsVisible()) |
1133 | 563 | .add("y", GetBaseY()) | 563 | .add(GetAbsoluteGeometry()); |
1129 | 564 | .add("width", GetBaseWidth()) | ||
1130 | 565 | .add("height", GetBaseHeight()) | ||
1131 | 566 | .add("active", IsVisible()); | ||
1134 | 567 | } | 564 | } |
1135 | 568 | 565 | ||
1136 | 569 | } // namespace nux | 566 | } // namespace nux |
1137 | 570 | 567 | ||
1138 | === modified file 'panel/PanelIndicatorEntryView.cpp' | |||
1139 | --- panel/PanelIndicatorEntryView.cpp 2013-05-17 16:02:09 +0000 | |||
1140 | +++ panel/PanelIndicatorEntryView.cpp 2013-11-06 08:52:17 +0000 | |||
1141 | @@ -664,6 +664,7 @@ | |||
1142 | 664 | .add("menu_y", proxy_->geometry().y) | 664 | .add("menu_y", proxy_->geometry().y) |
1143 | 665 | .add("menu_width", proxy_->geometry().width) | 665 | .add("menu_width", proxy_->geometry().width) |
1144 | 666 | .add("menu_height", proxy_->geometry().height) | 666 | .add("menu_height", proxy_->geometry().height) |
1145 | 667 | .add("menu_geo", proxy_->geometry()) | ||
1146 | 667 | .add("focused", IsFocused()); | 668 | .add("focused", IsFocused()); |
1147 | 668 | } | 669 | } |
1148 | 669 | 670 | ||
1149 | 670 | 671 | ||
1150 | === removed file 'plugins/unityshell/src/AggregateMonitor.cpp' | |||
1151 | --- plugins/unityshell/src/AggregateMonitor.cpp 2012-03-14 06:24:18 +0000 | |||
1152 | +++ plugins/unityshell/src/AggregateMonitor.cpp 1970-01-01 00:00:00 +0000 | |||
1153 | @@ -1,63 +0,0 @@ | |||
1154 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1155 | 2 | /* | ||
1156 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1157 | 4 | * | ||
1158 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1159 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1160 | 7 | * published by the Free Software Foundation. | ||
1161 | 8 | * | ||
1162 | 9 | * This program is distributed in the hope that it will be useful, | ||
1163 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1164 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1165 | 12 | * GNU General Public License for more details. | ||
1166 | 13 | * | ||
1167 | 14 | * You should have received a copy of the GNU General Public License | ||
1168 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1169 | 16 | * | ||
1170 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | ||
1171 | 18 | */ | ||
1172 | 19 | |||
1173 | 20 | #include "AggregateMonitor.h" | ||
1174 | 21 | #include "ElapsedTimeMonitor.h" | ||
1175 | 22 | #include <UnityCore/Variant.h> | ||
1176 | 23 | |||
1177 | 24 | namespace unity { | ||
1178 | 25 | namespace performance { | ||
1179 | 26 | |||
1180 | 27 | AggregateMonitor::AggregateMonitor() | ||
1181 | 28 | { | ||
1182 | 29 | _monitors.push_back(new ElapsedTimeMonitor()); | ||
1183 | 30 | } | ||
1184 | 31 | |||
1185 | 32 | AggregateMonitor::~AggregateMonitor() | ||
1186 | 33 | { | ||
1187 | 34 | } | ||
1188 | 35 | |||
1189 | 36 | std::string AggregateMonitor::GetName() const | ||
1190 | 37 | { | ||
1191 | 38 | return "AggregateMonitor"; | ||
1192 | 39 | } | ||
1193 | 40 | |||
1194 | 41 | void AggregateMonitor::StartMonitor() | ||
1195 | 42 | { | ||
1196 | 43 | for (std::list<Monitor*>::iterator iter = _monitors.begin(), end = _monitors.end(); | ||
1197 | 44 | iter != end; ++iter) | ||
1198 | 45 | { | ||
1199 | 46 | Monitor* monitor = *iter; | ||
1200 | 47 | monitor->Start(); | ||
1201 | 48 | } | ||
1202 | 49 | } | ||
1203 | 50 | |||
1204 | 51 | void AggregateMonitor::StopMonitor(GVariantBuilder* builder) | ||
1205 | 52 | { | ||
1206 | 53 | variant::BuilderWrapper wrapper(builder); | ||
1207 | 54 | for (std::list<Monitor*>::iterator iter = _monitors.begin(), end = _monitors.end(); | ||
1208 | 55 | iter != end; ++iter) | ||
1209 | 56 | { | ||
1210 | 57 | Monitor* monitor = *iter; | ||
1211 | 58 | wrapper.add(monitor->GetName().c_str(), monitor->Stop()); | ||
1212 | 59 | } | ||
1213 | 60 | } | ||
1214 | 61 | |||
1215 | 62 | } | ||
1216 | 63 | } | ||
1217 | 64 | 0 | ||
1218 | === removed file 'plugins/unityshell/src/AggregateMonitor.h' | |||
1219 | --- plugins/unityshell/src/AggregateMonitor.h 2011-12-08 04:24:00 +0000 | |||
1220 | +++ plugins/unityshell/src/AggregateMonitor.h 1970-01-01 00:00:00 +0000 | |||
1221 | @@ -1,50 +0,0 @@ | |||
1222 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1223 | 2 | /* | ||
1224 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1225 | 4 | * | ||
1226 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1227 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1228 | 7 | * published by the Free Software Foundation. | ||
1229 | 8 | * | ||
1230 | 9 | * This program is distributed in the hope that it will be useful, | ||
1231 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1232 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1233 | 12 | * GNU General Public License for more details. | ||
1234 | 13 | * | ||
1235 | 14 | * You should have received a copy of the GNU General Public License | ||
1236 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1237 | 16 | * | ||
1238 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | ||
1239 | 18 | */ | ||
1240 | 19 | |||
1241 | 20 | #ifndef UNITY_PERFORMANCE_AGGREGATE_MONITOR | ||
1242 | 21 | #define UNITY_PERFORMANCE_AGGREGATE_MONITOR | ||
1243 | 22 | |||
1244 | 23 | #include <list> | ||
1245 | 24 | #include <string> | ||
1246 | 25 | #include <gio/gio.h> | ||
1247 | 26 | |||
1248 | 27 | #include "Monitor.h" | ||
1249 | 28 | |||
1250 | 29 | namespace unity { | ||
1251 | 30 | namespace performance { | ||
1252 | 31 | |||
1253 | 32 | class AggregateMonitor : public Monitor | ||
1254 | 33 | { | ||
1255 | 34 | public: | ||
1256 | 35 | AggregateMonitor(); | ||
1257 | 36 | ~AggregateMonitor(); | ||
1258 | 37 | std::string GetName() const; | ||
1259 | 38 | |||
1260 | 39 | protected: | ||
1261 | 40 | void StartMonitor(); | ||
1262 | 41 | void StopMonitor(GVariantBuilder* builder); | ||
1263 | 42 | |||
1264 | 43 | private: | ||
1265 | 44 | std::list<Monitor*> _monitors; | ||
1266 | 45 | }; | ||
1267 | 46 | |||
1268 | 47 | } | ||
1269 | 48 | } | ||
1270 | 49 | |||
1271 | 50 | #endif // UNITY_PERFORMANCE_AGGREGATE_MONITOR | ||
1272 | 51 | 0 | ||
1273 | === removed file 'plugins/unityshell/src/ElapsedTimeMonitor.cpp' | |||
1274 | --- plugins/unityshell/src/ElapsedTimeMonitor.cpp 2012-11-30 20:22:13 +0000 | |||
1275 | +++ plugins/unityshell/src/ElapsedTimeMonitor.cpp 1970-01-01 00:00:00 +0000 | |||
1276 | @@ -1,49 +0,0 @@ | |||
1277 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1278 | 2 | /* | ||
1279 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1280 | 4 | * | ||
1281 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1282 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1283 | 7 | * published by the Free Software Foundation. | ||
1284 | 8 | * | ||
1285 | 9 | * This program is distributed in the hope that it will be useful, | ||
1286 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1287 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1288 | 12 | * GNU General Public License for more details. | ||
1289 | 13 | * | ||
1290 | 14 | * You should have received a copy of the GNU General Public License | ||
1291 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1292 | 16 | * | ||
1293 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | ||
1294 | 18 | */ | ||
1295 | 19 | |||
1296 | 20 | #include <UnityCore/Variant.h> | ||
1297 | 21 | |||
1298 | 22 | #include "ElapsedTimeMonitor.h" | ||
1299 | 23 | #include "TimeUtil.h" | ||
1300 | 24 | |||
1301 | 25 | namespace unity{ | ||
1302 | 26 | namespace performance { | ||
1303 | 27 | |||
1304 | 28 | std::string ElapsedTimeMonitor::GetName() const | ||
1305 | 29 | { | ||
1306 | 30 | return "ElapsedTimeMonitor"; | ||
1307 | 31 | } | ||
1308 | 32 | |||
1309 | 33 | void ElapsedTimeMonitor::StartMonitor() | ||
1310 | 34 | { | ||
1311 | 35 | clock_gettime(CLOCK_MONOTONIC, &_start); | ||
1312 | 36 | } | ||
1313 | 37 | |||
1314 | 38 | void ElapsedTimeMonitor::StopMonitor(GVariantBuilder* builder) | ||
1315 | 39 | { | ||
1316 | 40 | struct timespec current; | ||
1317 | 41 | clock_gettime(CLOCK_MONOTONIC, ¤t); | ||
1318 | 42 | DeltaTime diff = TimeUtil::TimeDelta(¤t, &_start); | ||
1319 | 43 | |||
1320 | 44 | variant::BuilderWrapper(builder) | ||
1321 | 45 | .add("elapsed-time", diff); | ||
1322 | 46 | } | ||
1323 | 47 | |||
1324 | 48 | } | ||
1325 | 49 | } | ||
1326 | 50 | 0 | ||
1327 | === removed file 'plugins/unityshell/src/ElapsedTimeMonitor.h' | |||
1328 | --- plugins/unityshell/src/ElapsedTimeMonitor.h 2011-11-08 18:21:44 +0000 | |||
1329 | +++ plugins/unityshell/src/ElapsedTimeMonitor.h 1970-01-01 00:00:00 +0000 | |||
1330 | @@ -1,47 +0,0 @@ | |||
1331 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1332 | 2 | /* | ||
1333 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1334 | 4 | * | ||
1335 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1336 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1337 | 7 | * published by the Free Software Foundation. | ||
1338 | 8 | * | ||
1339 | 9 | * This program is distributed in the hope that it will be useful, | ||
1340 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1341 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1342 | 12 | * GNU General Public License for more details. | ||
1343 | 13 | * | ||
1344 | 14 | * You should have received a copy of the GNU General Public License | ||
1345 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1346 | 16 | * | ||
1347 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | ||
1348 | 18 | */ | ||
1349 | 19 | |||
1350 | 20 | #ifndef UNITY_PERFORMANCE_ELAPSED_TIME_MONITOR | ||
1351 | 21 | #define UNITY_PERFORMANCE_ELAPSED_TIME_MONITOR | ||
1352 | 22 | |||
1353 | 23 | #include <glib.h> | ||
1354 | 24 | #include <time.h> | ||
1355 | 25 | |||
1356 | 26 | #include "Monitor.h" | ||
1357 | 27 | |||
1358 | 28 | namespace unity { | ||
1359 | 29 | namespace performance { | ||
1360 | 30 | |||
1361 | 31 | class ElapsedTimeMonitor : public Monitor | ||
1362 | 32 | { | ||
1363 | 33 | public: | ||
1364 | 34 | std::string GetName() const; | ||
1365 | 35 | |||
1366 | 36 | protected: | ||
1367 | 37 | void StartMonitor(); | ||
1368 | 38 | void StopMonitor(GVariantBuilder* builder); | ||
1369 | 39 | |||
1370 | 40 | private: | ||
1371 | 41 | struct timespec _start; | ||
1372 | 42 | }; | ||
1373 | 43 | |||
1374 | 44 | } | ||
1375 | 45 | } | ||
1376 | 46 | |||
1377 | 47 | #endif // UNITY_PERFORMANCE_ELAPSED_TIME_MONITOR | ||
1378 | 48 | 0 | ||
1379 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
1380 | --- plugins/unityshell/src/unityshell.cpp 2013-10-22 16:17:43 +0000 | |||
1381 | +++ plugins/unityshell/src/unityshell.cpp 2013-11-06 08:52:17 +0000 | |||
1382 | @@ -745,9 +745,9 @@ | |||
1383 | 745 | unsigned int oldGlAddGeometryIndex = uTrayWindow->gWindow->glAddGeometryGetCurrentIndex (); | 745 | unsigned int oldGlAddGeometryIndex = uTrayWindow->gWindow->glAddGeometryGetCurrentIndex (); |
1384 | 746 | unsigned int oldGlDrawIndex = uTrayWindow->gWindow->glDrawGetCurrentIndex (); | 746 | unsigned int oldGlDrawIndex = uTrayWindow->gWindow->glDrawGetCurrentIndex (); |
1385 | 747 | 747 | ||
1389 | 748 | attrib.opacity = OPAQUE; | 748 | attrib.opacity = COMPIZ_COMPOSITE_OPAQUE; |
1390 | 749 | attrib.brightness = BRIGHT; | 749 | attrib.brightness = COMPIZ_COMPOSITE_BRIGHT; |
1391 | 750 | attrib.saturation = COLOR; | 750 | attrib.saturation = COMPIZ_COMPOSITE_COLOR; |
1392 | 751 | 751 | ||
1393 | 752 | oTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); | 752 | oTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); |
1394 | 753 | 753 | ||
1395 | @@ -3504,6 +3504,7 @@ | |||
1396 | 3504 | .add("vertically_maximized", wm.IsWindowVerticallyMaximized(xid)) | 3504 | .add("vertically_maximized", wm.IsWindowVerticallyMaximized(xid)) |
1397 | 3505 | .add("minimized", wm.IsWindowMinimized(xid)) | 3505 | .add("minimized", wm.IsWindowMinimized(xid)) |
1398 | 3506 | .add("scaled", scaled) | 3506 | .add("scaled", scaled) |
1399 | 3507 | .add("scaled_close_geo", close_button_geo_) | ||
1400 | 3507 | .add("scaled_close_x", close_button_geo_.x) | 3508 | .add("scaled_close_x", close_button_geo_.x) |
1401 | 3508 | .add("scaled_close_y", close_button_geo_.y) | 3509 | .add("scaled_close_y", close_button_geo_.y) |
1402 | 3509 | .add("scaled_close_width", close_button_geo_.width) | 3510 | .add("scaled_close_width", close_button_geo_.width) |
1403 | 3510 | 3511 | ||
1404 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
1405 | --- plugins/unityshell/src/unityshell.h 2013-10-21 21:57:54 +0000 | |||
1406 | +++ plugins/unityshell/src/unityshell.h 2013-11-06 08:52:17 +0000 | |||
1407 | @@ -32,9 +32,22 @@ | |||
1408 | 32 | #include <scale/scale.h> | 32 | #include <scale/scale.h> |
1409 | 33 | #include <core/core.h> | 33 | #include <core/core.h> |
1410 | 34 | #include <core/pluginclasshandler.h> | 34 | #include <core/pluginclasshandler.h> |
1411 | 35 | #include <composite/composite.h> | ||
1412 | 36 | #include <opengl/opengl.h> | 35 | #include <opengl/opengl.h> |
1413 | 37 | 36 | ||
1414 | 37 | // These fixes some definitions from the composite header | ||
1415 | 38 | #ifdef COLOR | ||
1416 | 39 | #define COMPIZ_COMPOSITE_COLOR 0xffff | ||
1417 | 40 | #undef COLOR | ||
1418 | 41 | #endif | ||
1419 | 42 | #ifdef OPAQUE | ||
1420 | 43 | #define COMPIZ_COMPOSITE_OPAQUE 0xffff | ||
1421 | 44 | #undef OPAQUE | ||
1422 | 45 | #endif | ||
1423 | 46 | #ifdef BRIGHT | ||
1424 | 47 | #define COMPIZ_COMPOSITE_BRIGHT 0xffff | ||
1425 | 48 | #undef BRIGHT | ||
1426 | 49 | #endif | ||
1427 | 50 | |||
1428 | 38 | #include "unityshell_options.h" | 51 | #include "unityshell_options.h" |
1429 | 39 | 52 | ||
1430 | 40 | #include "Introspectable.h" | 53 | #include "Introspectable.h" |
1431 | 41 | 54 | ||
1432 | === modified file 'shutdown/SessionButton.cpp' | |||
1433 | --- shutdown/SessionButton.cpp 2013-03-19 14:54:43 +0000 | |||
1434 | +++ shutdown/SessionButton.cpp 2013-11-06 08:52:17 +0000 | |||
1435 | @@ -130,6 +130,7 @@ | |||
1436 | 130 | unity::variant::BuilderWrapper(builder) | 130 | unity::variant::BuilderWrapper(builder) |
1437 | 131 | .add("highlighted", highlighted()) | 131 | .add("highlighted", highlighted()) |
1438 | 132 | .add("label", label()) | 132 | .add("label", label()) |
1439 | 133 | .add("label_color", label_view_->GetTextColor()) | ||
1440 | 133 | .add("label_visible", label_view_->GetTextColor() != nux::color::Transparent); | 134 | .add("label_visible", label_view_->GetTextColor() != nux::color::Transparent); |
1441 | 134 | } | 135 | } |
1442 | 135 | 136 | ||
1443 | 136 | 137 | ||
1444 | === modified file 'tests/test_glib_variant.cpp' | |||
1445 | --- tests/test_glib_variant.cpp 2013-08-23 17:36:51 +0000 | |||
1446 | +++ tests/test_glib_variant.cpp 2013-11-06 08:52:17 +0000 | |||
1447 | @@ -71,6 +71,121 @@ | |||
1448 | 71 | EXPECT_FALSE(IsFloating(v)); | 71 | EXPECT_FALSE(IsFloating(v)); |
1449 | 72 | } | 72 | } |
1450 | 73 | 73 | ||
1451 | 74 | TEST(TestGLibVariant, ConstructNullptr) | ||
1452 | 75 | { | ||
1453 | 76 | Variant v(nullptr); | ||
1454 | 77 | EXPECT_FALSE(v); | ||
1455 | 78 | } | ||
1456 | 79 | |||
1457 | 80 | TEST(TestGLibVariant, ConstructNull) | ||
1458 | 81 | { | ||
1459 | 82 | GVariant* value = NULL; | ||
1460 | 83 | Variant v(value); | ||
1461 | 84 | EXPECT_FALSE(v); | ||
1462 | 85 | } | ||
1463 | 86 | |||
1464 | 87 | TEST(TestGLibVariant, ConstructString) | ||
1465 | 88 | { | ||
1466 | 89 | std::string value = "UnityVariant"; | ||
1467 | 90 | Variant v(value); | ||
1468 | 91 | EXPECT_EQ(value, g_variant_get_string(v, nullptr)); | ||
1469 | 92 | } | ||
1470 | 93 | |||
1471 | 94 | TEST(TestGLibVariant, ConstructCharString) | ||
1472 | 95 | { | ||
1473 | 96 | const char* value = "UnityVariantCharStr"; | ||
1474 | 97 | Variant v(value); | ||
1475 | 98 | EXPECT_STREQ(value, g_variant_get_string(v, nullptr)); | ||
1476 | 99 | } | ||
1477 | 100 | |||
1478 | 101 | TEST(TestGLibVariant, ConstructByte) | ||
1479 | 102 | { | ||
1480 | 103 | unsigned char value = g_random_int_range(0, 256); | ||
1481 | 104 | Variant v(value); | ||
1482 | 105 | EXPECT_EQ(value, g_variant_get_byte(v)); | ||
1483 | 106 | } | ||
1484 | 107 | |||
1485 | 108 | TEST(TestGLibVariant, ConstructInt16) | ||
1486 | 109 | { | ||
1487 | 110 | int16_t value = g_random_int_range(G_MININT16, G_MAXINT16); | ||
1488 | 111 | Variant v(value); | ||
1489 | 112 | EXPECT_EQ(value, g_variant_get_int16(v)); | ||
1490 | 113 | } | ||
1491 | 114 | |||
1492 | 115 | TEST(TestGLibVariant, ConstructUInt16) | ||
1493 | 116 | { | ||
1494 | 117 | uint16_t value = g_random_int_range(0, G_MAXUINT16); | ||
1495 | 118 | Variant v(value); | ||
1496 | 119 | EXPECT_EQ(value, g_variant_get_uint16(v)); | ||
1497 | 120 | } | ||
1498 | 121 | |||
1499 | 122 | TEST(TestGLibVariant, ConstructInt32) | ||
1500 | 123 | { | ||
1501 | 124 | int32_t value = g_random_int_range(G_MININT32, G_MAXINT32); | ||
1502 | 125 | Variant v(value); | ||
1503 | 126 | EXPECT_EQ(value, g_variant_get_int32(v)); | ||
1504 | 127 | } | ||
1505 | 128 | |||
1506 | 129 | TEST(TestGLibVariant, ConstructUInt32) | ||
1507 | 130 | { | ||
1508 | 131 | uint32_t value = g_random_int(); | ||
1509 | 132 | Variant v(value); | ||
1510 | 133 | EXPECT_EQ(value, g_variant_get_uint32(v)); | ||
1511 | 134 | } | ||
1512 | 135 | |||
1513 | 136 | TEST(TestGLibVariant, ConstructInt64) | ||
1514 | 137 | { | ||
1515 | 138 | int64_t value = g_random_int_range(G_MININT, G_MAXINT); | ||
1516 | 139 | Variant v(value); | ||
1517 | 140 | EXPECT_EQ(value, g_variant_get_int64(v)); | ||
1518 | 141 | } | ||
1519 | 142 | |||
1520 | 143 | TEST(TestGLibVariant, ConstructUInt64) | ||
1521 | 144 | { | ||
1522 | 145 | uint64_t value = g_random_int(); | ||
1523 | 146 | Variant v(value); | ||
1524 | 147 | EXPECT_EQ(value, g_variant_get_uint64(v)); | ||
1525 | 148 | } | ||
1526 | 149 | |||
1527 | 150 | TEST(TestGLibVariant, ConstructBool) | ||
1528 | 151 | { | ||
1529 | 152 | bool value = g_random_int(); | ||
1530 | 153 | Variant v(value); | ||
1531 | 154 | EXPECT_EQ(value, g_variant_get_boolean(v)); | ||
1532 | 155 | } | ||
1533 | 156 | |||
1534 | 157 | TEST(TestGLibVariant, ConstructDouble) | ||
1535 | 158 | { | ||
1536 | 159 | double value = g_random_int(); | ||
1537 | 160 | Variant v(value); | ||
1538 | 161 | EXPECT_DOUBLE_EQ(value, g_variant_get_double(v)); | ||
1539 | 162 | } | ||
1540 | 163 | |||
1541 | 164 | TEST(TestGLibVariant, ConstructFloat) | ||
1542 | 165 | { | ||
1543 | 166 | float value = g_random_int(); | ||
1544 | 167 | Variant v(value); | ||
1545 | 168 | EXPECT_FLOAT_EQ(value, static_cast<float>(g_variant_get_double(v))); | ||
1546 | 169 | } | ||
1547 | 170 | |||
1548 | 171 | TEST(TestGLibVariant, ConstructNumericInt) | ||
1549 | 172 | { | ||
1550 | 173 | Variant v0(0); | ||
1551 | 174 | EXPECT_EQ(0, v0.GetInt32()); | ||
1552 | 175 | |||
1553 | 176 | Variant v1(123456789); | ||
1554 | 177 | EXPECT_EQ(123456789, v1.GetInt32()); | ||
1555 | 178 | } | ||
1556 | 179 | |||
1557 | 180 | TEST(TestGLibVariant, ConstructNumericDouble) | ||
1558 | 181 | { | ||
1559 | 182 | Variant v0(0.0f); | ||
1560 | 183 | EXPECT_EQ(0.0f, v0.GetDouble()); | ||
1561 | 184 | |||
1562 | 185 | Variant v1(0.987654321); | ||
1563 | 186 | EXPECT_EQ(0.987654321, v1.GetDouble()); | ||
1564 | 187 | } | ||
1565 | 188 | |||
1566 | 74 | TEST(TestGLibVariant, Copy) | 189 | TEST(TestGLibVariant, Copy) |
1567 | 75 | { | 190 | { |
1568 | 76 | Variant v1 (g_variant_new_string ("bar")); | 191 | Variant v1 (g_variant_new_string ("bar")); |
1569 | @@ -108,6 +223,179 @@ | |||
1570 | 108 | EXPECT_TRUE(ValuesEqual(v, raw_variant)); | 223 | EXPECT_TRUE(ValuesEqual(v, raw_variant)); |
1571 | 109 | } | 224 | } |
1572 | 110 | 225 | ||
1573 | 226 | TEST(TestGLibVariant, ConstructHintsMap) | ||
1574 | 227 | { | ||
1575 | 228 | Variant v({ | ||
1576 | 229 | {"charstring-key", g_variant_new_string("charstring-value")}, | ||
1577 | 230 | {"string-key", g_variant_new_string(std::string("string-value").c_str())}, | ||
1578 | 231 | {"gint32-key", g_variant_new_int32(-1)}, | ||
1579 | 232 | {"guint32-key", g_variant_new_uint32(2)}, | ||
1580 | 233 | {"gint64-key", g_variant_new_int64(-3)}, | ||
1581 | 234 | {"guint64-key", g_variant_new_uint64(4)}, | ||
1582 | 235 | {"float-key", g_variant_new_double((float)1.1)}, | ||
1583 | 236 | {"double-key", g_variant_new_double(2.2)}, | ||
1584 | 237 | {"bool-key", g_variant_new_boolean(true)}, | ||
1585 | 238 | {"variant-key", g_variant_new_int32(123)} | ||
1586 | 239 | }); | ||
1587 | 240 | |||
1588 | 241 | EXPECT_EQ("charstring-value", Variant(g_variant_lookup_value(v, "charstring-key", nullptr)).GetString()); | ||
1589 | 242 | EXPECT_EQ("string-value", Variant(g_variant_lookup_value(v, "string-key", nullptr)).GetString()); | ||
1590 | 243 | EXPECT_EQ(-1, Variant(g_variant_lookup_value(v, "gint32-key", nullptr)).GetInt32()); | ||
1591 | 244 | EXPECT_EQ(2, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32()); | ||
1592 | 245 | EXPECT_EQ(-3, Variant(g_variant_lookup_value(v, "gint64-key", nullptr)).GetInt64()); | ||
1593 | 246 | EXPECT_EQ(4, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64()); | ||
1594 | 247 | EXPECT_FLOAT_EQ(1.1, Variant(g_variant_lookup_value(v, "float-key", nullptr)).GetFloat()); | ||
1595 | 248 | EXPECT_DOUBLE_EQ(2.2, Variant(g_variant_lookup_value(v, "double-key", nullptr)).GetDouble()); | ||
1596 | 249 | EXPECT_EQ(true, Variant(g_variant_lookup_value(v, "bool-key", nullptr)).GetBool()); | ||
1597 | 250 | EXPECT_EQ(123, Variant(g_variant_lookup_value(v, "variant-key", nullptr)).GetInt32()); | ||
1598 | 251 | } | ||
1599 | 252 | |||
1600 | 253 | TEST(TestGLibVariant, AssignString) | ||
1601 | 254 | { | ||
1602 | 255 | std::string value = "UnityVariant"; | ||
1603 | 256 | Variant v; | ||
1604 | 257 | v = value; | ||
1605 | 258 | EXPECT_EQ(value, g_variant_get_string(v, nullptr)); | ||
1606 | 259 | } | ||
1607 | 260 | |||
1608 | 261 | TEST(TestGLibVariant, AssignCharString) | ||
1609 | 262 | { | ||
1610 | 263 | const char* value = "UnityVariantCharStr"; | ||
1611 | 264 | Variant v; | ||
1612 | 265 | v = value; | ||
1613 | 266 | EXPECT_STREQ(value, g_variant_get_string(v, nullptr)); | ||
1614 | 267 | } | ||
1615 | 268 | |||
1616 | 269 | TEST(TestGLibVariant, AssignByte) | ||
1617 | 270 | { | ||
1618 | 271 | unsigned char value = g_random_int_range(0, 256); | ||
1619 | 272 | Variant v; | ||
1620 | 273 | v = value; | ||
1621 | 274 | EXPECT_EQ(value, g_variant_get_byte(v)); | ||
1622 | 275 | } | ||
1623 | 276 | |||
1624 | 277 | TEST(TestGLibVariant, AssignInt16) | ||
1625 | 278 | { | ||
1626 | 279 | int16_t value = g_random_int_range(G_MININT16, G_MAXINT16); | ||
1627 | 280 | Variant v; | ||
1628 | 281 | v = value; | ||
1629 | 282 | EXPECT_EQ(value, g_variant_get_int16(v)); | ||
1630 | 283 | } | ||
1631 | 284 | |||
1632 | 285 | TEST(TestGLibVariant, AssignUInt16) | ||
1633 | 286 | { | ||
1634 | 287 | uint16_t value = g_random_int_range(0, G_MAXUINT16); | ||
1635 | 288 | Variant v; | ||
1636 | 289 | v = value; | ||
1637 | 290 | EXPECT_EQ(value, g_variant_get_uint16(v)); | ||
1638 | 291 | } | ||
1639 | 292 | |||
1640 | 293 | TEST(TestGLibVariant, AssignInt32) | ||
1641 | 294 | { | ||
1642 | 295 | int32_t value = g_random_int_range(G_MININT32, G_MAXINT32); | ||
1643 | 296 | Variant v; | ||
1644 | 297 | v = value; | ||
1645 | 298 | EXPECT_EQ(value, g_variant_get_int32(v)); | ||
1646 | 299 | } | ||
1647 | 300 | |||
1648 | 301 | TEST(TestGLibVariant, AssignUInt32) | ||
1649 | 302 | { | ||
1650 | 303 | uint32_t value = g_random_int(); | ||
1651 | 304 | Variant v; | ||
1652 | 305 | v = value; | ||
1653 | 306 | EXPECT_EQ(value, g_variant_get_uint32(v)); | ||
1654 | 307 | } | ||
1655 | 308 | |||
1656 | 309 | TEST(TestGLibVariant, AssignInt64) | ||
1657 | 310 | { | ||
1658 | 311 | int64_t value = g_random_int_range(G_MININT, G_MAXINT); | ||
1659 | 312 | Variant v; | ||
1660 | 313 | v = value; | ||
1661 | 314 | EXPECT_EQ(value, g_variant_get_int64(v)); | ||
1662 | 315 | } | ||
1663 | 316 | |||
1664 | 317 | TEST(TestGLibVariant, AssignUInt64) | ||
1665 | 318 | { | ||
1666 | 319 | uint64_t value = g_random_int(); | ||
1667 | 320 | Variant v; | ||
1668 | 321 | v = value; | ||
1669 | 322 | EXPECT_EQ(value, g_variant_get_uint64(v)); | ||
1670 | 323 | } | ||
1671 | 324 | |||
1672 | 325 | TEST(TestGLibVariant, AssignBool) | ||
1673 | 326 | { | ||
1674 | 327 | bool value = g_random_int(); | ||
1675 | 328 | Variant v; | ||
1676 | 329 | v = value; | ||
1677 | 330 | EXPECT_EQ(value, g_variant_get_boolean(v)); | ||
1678 | 331 | } | ||
1679 | 332 | |||
1680 | 333 | TEST(TestGLibVariant, AssignDouble) | ||
1681 | 334 | { | ||
1682 | 335 | double value = g_random_int(); | ||
1683 | 336 | Variant v; | ||
1684 | 337 | v = value; | ||
1685 | 338 | EXPECT_DOUBLE_EQ(value, g_variant_get_double(v)); | ||
1686 | 339 | } | ||
1687 | 340 | |||
1688 | 341 | TEST(TestGLibVariant, AssignFloat) | ||
1689 | 342 | { | ||
1690 | 343 | float value = g_random_int(); | ||
1691 | 344 | Variant v; | ||
1692 | 345 | v = value; | ||
1693 | 346 | EXPECT_FLOAT_EQ(value, static_cast<float>(g_variant_get_double(v))); | ||
1694 | 347 | } | ||
1695 | 348 | |||
1696 | 349 | TEST(TestGLibVariant, AssignNumericInt) | ||
1697 | 350 | { | ||
1698 | 351 | Variant v0; | ||
1699 | 352 | v0 = 0; | ||
1700 | 353 | EXPECT_EQ(0, v0.GetInt32()); | ||
1701 | 354 | |||
1702 | 355 | Variant v1; | ||
1703 | 356 | v1 = 123456789; | ||
1704 | 357 | EXPECT_EQ(123456789, v1.GetInt32()); | ||
1705 | 358 | } | ||
1706 | 359 | |||
1707 | 360 | TEST(TestGLibVariant, AssignNumericDouble) | ||
1708 | 361 | { | ||
1709 | 362 | Variant v0; | ||
1710 | 363 | v0 = 0.0f; | ||
1711 | 364 | EXPECT_EQ(0.0f, v0.GetDouble()); | ||
1712 | 365 | |||
1713 | 366 | Variant v1; | ||
1714 | 367 | v1 = 0.987654321; | ||
1715 | 368 | EXPECT_EQ(0.987654321, v1.GetDouble()); | ||
1716 | 369 | } | ||
1717 | 370 | |||
1718 | 371 | TEST(TestGLibVariant, AssignHintsMap) | ||
1719 | 372 | { | ||
1720 | 373 | Variant v; | ||
1721 | 374 | v = { | ||
1722 | 375 | {"charstring-key", g_variant_new_string("charstring-value")}, | ||
1723 | 376 | {"string-key", g_variant_new_string(std::string("string-value").c_str())}, | ||
1724 | 377 | {"gint32-key", g_variant_new_int32(-1)}, | ||
1725 | 378 | {"guint32-key", g_variant_new_uint32(2)}, | ||
1726 | 379 | {"gint64-key", g_variant_new_int64(-3)}, | ||
1727 | 380 | {"guint64-key", g_variant_new_uint64(4)}, | ||
1728 | 381 | {"float-key", g_variant_new_double((float)1.1)}, | ||
1729 | 382 | {"double-key", g_variant_new_double(2.2)}, | ||
1730 | 383 | {"bool-key", g_variant_new_boolean(true)}, | ||
1731 | 384 | {"variant-key", g_variant_new_int32(123)} | ||
1732 | 385 | }; | ||
1733 | 386 | |||
1734 | 387 | EXPECT_EQ("charstring-value", Variant(g_variant_lookup_value(v, "charstring-key", nullptr)).GetString()); | ||
1735 | 388 | EXPECT_EQ("string-value", Variant(g_variant_lookup_value(v, "string-key", nullptr)).GetString()); | ||
1736 | 389 | EXPECT_EQ(-1, Variant(g_variant_lookup_value(v, "gint32-key", nullptr)).GetInt32()); | ||
1737 | 390 | EXPECT_EQ(2, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32()); | ||
1738 | 391 | EXPECT_EQ(-3, Variant(g_variant_lookup_value(v, "gint64-key", nullptr)).GetInt64()); | ||
1739 | 392 | EXPECT_EQ(4, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64()); | ||
1740 | 393 | EXPECT_FLOAT_EQ(1.1, Variant(g_variant_lookup_value(v, "float-key", nullptr)).GetFloat()); | ||
1741 | 394 | EXPECT_DOUBLE_EQ(2.2, Variant(g_variant_lookup_value(v, "double-key", nullptr)).GetDouble()); | ||
1742 | 395 | EXPECT_EQ(true, Variant(g_variant_lookup_value(v, "bool-key", nullptr)).GetBool()); | ||
1743 | 396 | EXPECT_EQ(123, Variant(g_variant_lookup_value(v, "variant-key", nullptr)).GetInt32()); | ||
1744 | 397 | } | ||
1745 | 398 | |||
1746 | 111 | TEST(TestGLibVariant, KeepsRef) | 399 | TEST(TestGLibVariant, KeepsRef) |
1747 | 112 | { | 400 | { |
1748 | 113 | GVariant *gv = g_variant_new_int32 (456); | 401 | GVariant *gv = g_variant_new_int32 (456); |
1749 | @@ -141,17 +429,16 @@ | |||
1750 | 141 | GVariantBuilder b; | 429 | GVariantBuilder b; |
1751 | 142 | 430 | ||
1752 | 143 | g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}")); | 431 | g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}")); |
1764 | 144 | variant::BuilderWrapper bw (&b); | 432 | g_variant_builder_add(&b, "{sv}", "charstring-key", g_variant_new_string("charstring-value")); |
1765 | 145 | bw.add ("charstring-key", "charstring-value"); | 433 | g_variant_builder_add(&b, "{sv}", "string-key", g_variant_new_string(std::string("string-value").c_str())); |
1766 | 146 | bw.add ("string-key", std::string("string-value")); | 434 | g_variant_builder_add(&b, "{sv}", "gint32-key", g_variant_new_int32(-1)); |
1767 | 147 | bw.add ("gint32-key", (gint32)-1); | 435 | g_variant_builder_add(&b, "{sv}", "guint32-key", g_variant_new_uint32(-2)); |
1768 | 148 | bw.add ("guint32-key", (guint32)-2); | 436 | g_variant_builder_add(&b, "{sv}", "gint64-key", g_variant_new_int64(-3)); |
1769 | 149 | bw.add ("gint64-key", (gint64)-3); | 437 | g_variant_builder_add(&b, "{sv}", "guint64-key", g_variant_new_uint64(-4)); |
1770 | 150 | bw.add ("guint64-key", (guint64)-4); | 438 | g_variant_builder_add(&b, "{sv}", "float-key", g_variant_new_double((float)1.1)); |
1771 | 151 | bw.add ("float-key", (float)1.1); | 439 | g_variant_builder_add(&b, "{sv}", "double-key", g_variant_new_double(2.2)); |
1772 | 152 | bw.add ("double-key", (double)2.2); | 440 | g_variant_builder_add(&b, "{sv}", "bool-key", g_variant_new_boolean(true)); |
1773 | 153 | bw.add ("bool-key", true); | 441 | g_variant_builder_add(&b, "{sv}", "variant-key", g_variant_new_int32(123)); |
1763 | 154 | bw.add ("variant-key", g_variant_new_int32(123)); | ||
1774 | 155 | 442 | ||
1775 | 156 | GVariant *dict_variant = g_variant_builder_end (&b); | 443 | GVariant *dict_variant = g_variant_builder_end (&b); |
1776 | 157 | Variant dict (g_variant_new_tuple (&dict_variant, 1)); | 444 | Variant dict (g_variant_new_tuple (&dict_variant, 1)); |
1777 | @@ -208,13 +495,76 @@ | |||
1778 | 208 | EXPECT_EQ(v5.GetString(), "Yeah!!!"); | 495 | EXPECT_EQ(v5.GetString(), "Yeah!!!"); |
1779 | 209 | } | 496 | } |
1780 | 210 | 497 | ||
1781 | 498 | TEST(TestGLibVariant, GetByte) | ||
1782 | 499 | { | ||
1783 | 500 | guchar value = g_random_int_range(0, 256); | ||
1784 | 501 | Variant v1(g_variant_new_byte(value)); | ||
1785 | 502 | EXPECT_EQ(v1.GetByte(), value); | ||
1786 | 503 | |||
1787 | 504 | value = g_random_int_range(0, 256); | ||
1788 | 505 | Variant v2(g_variant_new("(y)", value)); | ||
1789 | 506 | EXPECT_EQ(v2.GetByte(), value); | ||
1790 | 507 | |||
1791 | 508 | Variant v3(g_variant_new("(ny)", value, "fooostring")); | ||
1792 | 509 | EXPECT_EQ(v3.GetByte(), 0); | ||
1793 | 510 | |||
1794 | 511 | Variant v4; | ||
1795 | 512 | EXPECT_EQ(v4.GetByte(), 0); | ||
1796 | 513 | |||
1797 | 514 | value = g_random_int_range(0, 256); | ||
1798 | 515 | Variant v5(g_variant_new_variant(g_variant_new_byte(value))); | ||
1799 | 516 | EXPECT_EQ(v5.GetByte(), value); | ||
1800 | 517 | } | ||
1801 | 518 | |||
1802 | 519 | TEST(TestGLibVariant, GetInt16) | ||
1803 | 520 | { | ||
1804 | 521 | gint16 value = g_random_int_range(G_MININT16, G_MAXINT16); | ||
1805 | 522 | Variant v1(g_variant_new_int16(value)); | ||
1806 | 523 | EXPECT_EQ(v1.GetInt16(), value); | ||
1807 | 524 | |||
1808 | 525 | value = g_random_int_range(G_MININT16, G_MAXINT16); | ||
1809 | 526 | Variant v2(g_variant_new("(n)", value)); | ||
1810 | 527 | EXPECT_EQ(v2.GetInt16(), value); | ||
1811 | 528 | |||
1812 | 529 | Variant v3(g_variant_new("(ns)", value, "fooostring")); | ||
1813 | 530 | EXPECT_EQ(v3.GetInt16(), 0); | ||
1814 | 531 | |||
1815 | 532 | Variant v4; | ||
1816 | 533 | EXPECT_EQ(v4.GetInt16(), 0); | ||
1817 | 534 | |||
1818 | 535 | value = g_random_int_range(G_MININT16, G_MAXINT16); | ||
1819 | 536 | Variant v5(g_variant_new_variant(g_variant_new_int16(value))); | ||
1820 | 537 | EXPECT_EQ(v5.GetInt16(), value); | ||
1821 | 538 | } | ||
1822 | 539 | |||
1823 | 540 | TEST(TestGLibVariant, GetUInt16) | ||
1824 | 541 | { | ||
1825 | 542 | guint16 value = g_random_int(); | ||
1826 | 543 | Variant v1(g_variant_new_uint16(value)); | ||
1827 | 544 | EXPECT_EQ(v1.GetUInt16(), value); | ||
1828 | 545 | |||
1829 | 546 | value = g_random_int(); | ||
1830 | 547 | Variant v2(g_variant_new("(q)", value)); | ||
1831 | 548 | EXPECT_EQ(v2.GetUInt16(), value); | ||
1832 | 549 | |||
1833 | 550 | Variant v3(g_variant_new("(qi)", value, G_MAXINT16)); | ||
1834 | 551 | EXPECT_EQ(v3.GetUInt16(), 0); | ||
1835 | 552 | |||
1836 | 553 | Variant v4; | ||
1837 | 554 | EXPECT_EQ(v4.GetUInt16(), 0); | ||
1838 | 555 | |||
1839 | 556 | value = g_random_int(); | ||
1840 | 557 | Variant v5(g_variant_new_variant(g_variant_new_uint16(value))); | ||
1841 | 558 | EXPECT_EQ(v5.GetUInt16(), value); | ||
1842 | 559 | } | ||
1843 | 560 | |||
1844 | 211 | TEST(TestGLibVariant, GetInt32) | 561 | TEST(TestGLibVariant, GetInt32) |
1845 | 212 | { | 562 | { |
1847 | 213 | gint32 value = g_random_int_range(G_MININT, G_MAXINT); | 563 | gint32 value = g_random_int_range(G_MININT32, G_MAXINT32); |
1848 | 214 | Variant v1(g_variant_new_int32(value)); | 564 | Variant v1(g_variant_new_int32(value)); |
1849 | 215 | EXPECT_EQ(v1.GetInt32(), value); | 565 | EXPECT_EQ(v1.GetInt32(), value); |
1850 | 216 | 566 | ||
1852 | 217 | value = g_random_int_range(G_MININT, G_MAXINT); | 567 | value = g_random_int_range(G_MININT32, G_MAXINT32); |
1853 | 218 | Variant v2(g_variant_new("(i)", value)); | 568 | Variant v2(g_variant_new("(i)", value)); |
1854 | 219 | EXPECT_EQ(v2.GetInt32(), value); | 569 | EXPECT_EQ(v2.GetInt32(), value); |
1855 | 220 | 570 | ||
1856 | @@ -224,7 +574,7 @@ | |||
1857 | 224 | Variant v4; | 574 | Variant v4; |
1858 | 225 | EXPECT_EQ(v4.GetInt32(), 0); | 575 | EXPECT_EQ(v4.GetInt32(), 0); |
1859 | 226 | 576 | ||
1861 | 227 | value = g_random_int_range(G_MININT, G_MAXINT); | 577 | value = g_random_int_range(G_MININT32, G_MAXINT32); |
1862 | 228 | Variant v5(g_variant_new_variant(g_variant_new_int32(value))); | 578 | Variant v5(g_variant_new_variant(g_variant_new_int32(value))); |
1863 | 229 | EXPECT_EQ(v5.GetInt32(), value); | 579 | EXPECT_EQ(v5.GetInt32(), value); |
1864 | 230 | } | 580 | } |
1865 | @@ -239,7 +589,7 @@ | |||
1866 | 239 | Variant v2(g_variant_new("(u)", value)); | 589 | Variant v2(g_variant_new("(u)", value)); |
1867 | 240 | EXPECT_EQ(v2.GetUInt32(), value); | 590 | EXPECT_EQ(v2.GetUInt32(), value); |
1868 | 241 | 591 | ||
1870 | 242 | Variant v3(g_variant_new("(ui)", value, G_MAXINT)); | 592 | Variant v3(g_variant_new("(ui)", value, G_MAXUINT32)); |
1871 | 243 | EXPECT_EQ(v3.GetUInt32(), 0); | 593 | EXPECT_EQ(v3.GetUInt32(), 0); |
1872 | 244 | 594 | ||
1873 | 245 | Variant v4; | 595 | Variant v4; |
1874 | @@ -250,6 +600,48 @@ | |||
1875 | 250 | EXPECT_EQ(v5.GetUInt32(), value); | 600 | EXPECT_EQ(v5.GetUInt32(), value); |
1876 | 251 | } | 601 | } |
1877 | 252 | 602 | ||
1878 | 603 | TEST(TestGLibVariant, GetInt64) | ||
1879 | 604 | { | ||
1880 | 605 | gint64 value = g_random_int_range(G_MININT, G_MAXINT); | ||
1881 | 606 | Variant v1(g_variant_new_int64(value)); | ||
1882 | 607 | EXPECT_EQ(v1.GetInt64(), value); | ||
1883 | 608 | |||
1884 | 609 | value = g_random_int_range(G_MININT, G_MAXINT); | ||
1885 | 610 | Variant v2(g_variant_new("(x)", value)); | ||
1886 | 611 | EXPECT_EQ(v2.GetInt64(), value); | ||
1887 | 612 | |||
1888 | 613 | Variant v3(g_variant_new("(xs)", value, "fooostring")); | ||
1889 | 614 | EXPECT_EQ(v3.GetInt64(), 0); | ||
1890 | 615 | |||
1891 | 616 | Variant v4; | ||
1892 | 617 | EXPECT_EQ(v4.GetInt64(), 0); | ||
1893 | 618 | |||
1894 | 619 | value = g_random_int_range(G_MININT, G_MAXINT); | ||
1895 | 620 | Variant v5(g_variant_new_variant(g_variant_new_int64(value))); | ||
1896 | 621 | EXPECT_EQ(v5.GetInt64(), value); | ||
1897 | 622 | } | ||
1898 | 623 | |||
1899 | 624 | TEST(TestGLibVariant, GetUInt64) | ||
1900 | 625 | { | ||
1901 | 626 | guint64 value = g_random_int(); | ||
1902 | 627 | Variant v1(g_variant_new_uint64(value)); | ||
1903 | 628 | EXPECT_EQ(v1.GetUInt64(), value); | ||
1904 | 629 | |||
1905 | 630 | value = g_random_int(); | ||
1906 | 631 | Variant v2(g_variant_new("(t)", value)); | ||
1907 | 632 | EXPECT_EQ(v2.GetUInt64(), value); | ||
1908 | 633 | |||
1909 | 634 | Variant v3(g_variant_new("(ti)", value, G_MAXINT64)); | ||
1910 | 635 | EXPECT_EQ(v3.GetUInt64(), 0); | ||
1911 | 636 | |||
1912 | 637 | Variant v4; | ||
1913 | 638 | EXPECT_EQ(v4.GetUInt64(), 0); | ||
1914 | 639 | |||
1915 | 640 | value = g_random_int(); | ||
1916 | 641 | Variant v5(g_variant_new_variant(g_variant_new_uint64(value))); | ||
1917 | 642 | EXPECT_EQ(v5.GetUInt64(), value); | ||
1918 | 643 | } | ||
1919 | 644 | |||
1920 | 253 | TEST(TestGLibVariant, GetBool) | 645 | TEST(TestGLibVariant, GetBool) |
1921 | 254 | { | 646 | { |
1922 | 255 | gboolean value = (g_random_int() % 2) ? TRUE : FALSE; | 647 | gboolean value = (g_random_int() % 2) ? TRUE : FALSE; |
1923 | 256 | 648 | ||
1924 | === modified file 'tests/test_panel_menu_view.cpp' | |||
1925 | --- tests/test_panel_menu_view.cpp 2013-10-14 17:36:51 +0000 | |||
1926 | +++ tests/test_panel_menu_view.cpp 2013-11-06 08:52:17 +0000 | |||
1927 | @@ -81,7 +81,7 @@ | |||
1928 | 81 | UBusManager ubus; | 81 | UBusManager ubus; |
1929 | 82 | ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV); | 82 | ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV); |
1930 | 83 | ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, | 83 | ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, |
1932 | 84 | g_variant_new_string(escapedText)); | 84 | glib::Variant(escapedText)); |
1933 | 85 | Utils::WaitUntilMSec([this] {return menu_view.GetCurrentTitle() == escapedText;}); | 85 | Utils::WaitUntilMSec([this] {return menu_view.GetCurrentTitle() == escapedText;}); |
1934 | 86 | 86 | ||
1935 | 87 | 87 | ||
1936 | 88 | 88 | ||
1937 | === modified file 'tests/test_results.cpp' | |||
1938 | --- tests/test_results.cpp 2013-07-10 16:07:04 +0000 | |||
1939 | +++ tests/test_results.cpp 2013-11-06 08:52:17 +0000 | |||
1940 | @@ -279,8 +279,8 @@ | |||
1941 | 279 | local_result_1.comment = "comment"; | 279 | local_result_1.comment = "comment"; |
1942 | 280 | local_result_1.dnd_uri = "dnd_uri"; | 280 | local_result_1.dnd_uri = "dnd_uri"; |
1943 | 281 | 281 | ||
1946 | 282 | local_result_1.hints["key1"] = g_variant_new_string("value1"); | 282 | local_result_1.hints["key1"] = glib::Variant("value1"); |
1947 | 283 | local_result_1.hints["key2"] = g_variant_new_string("value2"); | 283 | local_result_1.hints["key2"] = glib::Variant("value2"); |
1948 | 284 | 284 | ||
1949 | 285 | glib::Variant variant_value = local_result_1.Variant(); | 285 | glib::Variant variant_value = local_result_1.Variant(); |
1950 | 286 | LocalResult local_result_2 = LocalResult::FromVariant(variant_value); | 286 | LocalResult local_result_2 = LocalResult::FromVariant(variant_value); |
1951 | 287 | 287 | ||
1952 | === modified file 'unity-shared/DebugDBusInterface.cpp' | |||
1953 | --- unity-shared/DebugDBusInterface.cpp 2013-10-29 20:50:07 +0000 | |||
1954 | +++ unity-shared/DebugDBusInterface.cpp 2013-11-06 08:52:17 +0000 | |||
1955 | @@ -1,6 +1,6 @@ | |||
1956 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1957 | 2 | /* | 2 | /* |
1959 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2013 Canonical Ltd |
1960 | 4 | * | 4 | * |
1961 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
1962 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
1963 | @@ -15,20 +15,16 @@ | |||
1964 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1965 | 16 | * | 16 | * |
1966 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> |
1967 | 18 | * Thomi Richards <thomi.richards@canonical.com> | ||
1968 | 19 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
1969 | 18 | */ | 20 | */ |
1970 | 19 | 21 | ||
1971 | 20 | #include <queue> | ||
1972 | 21 | #include <iostream> | ||
1973 | 22 | #include <fstream> | 22 | #include <fstream> |
1974 | 23 | #include <sstream> | 23 | #include <sstream> |
1975 | 24 | #include <iostream> | ||
1976 | 25 | #include <boost/algorithm/string.hpp> | 24 | #include <boost/algorithm/string.hpp> |
1977 | 26 | #include <boost/algorithm/string/split.hpp> | ||
1978 | 27 | #include <boost/algorithm/string/classification.hpp> | ||
1979 | 28 | #include <boost/bind.hpp> | ||
1980 | 29 | #include <NuxCore/Logger.h> | 25 | #include <NuxCore/Logger.h> |
1981 | 30 | #include <NuxCore/LoggingWriter.h> | 26 | #include <NuxCore/LoggingWriter.h> |
1983 | 31 | #include <xpathselect/node.h> | 27 | #include <UnityCore/Variant.h> |
1984 | 32 | #include <xpathselect/xpathselect.h> | 28 | #include <xpathselect/xpathselect.h> |
1985 | 33 | #include <dlfcn.h> | 29 | #include <dlfcn.h> |
1986 | 34 | 30 | ||
1987 | @@ -45,17 +41,25 @@ | |||
1988 | 45 | { | 41 | { |
1989 | 46 | namespace local | 42 | namespace local |
1990 | 47 | { | 43 | { |
1991 | 44 | const std::string PROTOCOL_VERSION = "1.4"; | ||
1992 | 45 | const std::string XPATH_SELECT_LIB = "libxpathselect.so.1.4"; | ||
1993 | 46 | |||
1994 | 48 | std::ofstream output_file; | 47 | std::ofstream output_file; |
1996 | 49 | void* xpathselect_driver_ = NULL; | 48 | void* xpathselect_driver_ = nullptr; |
1997 | 50 | 49 | ||
1999 | 51 | class IntrospectableAdapter: public xpathselect::Node | 50 | class IntrospectableAdapter : public std::enable_shared_from_this<IntrospectableAdapter>, public xpathselect::Node |
2000 | 52 | { | 51 | { |
2001 | 53 | public: | 52 | public: |
2005 | 54 | typedef std::shared_ptr<IntrospectableAdapter> Ptr; | 53 | typedef std::shared_ptr<IntrospectableAdapter const> Ptr; |
2006 | 55 | IntrospectableAdapter(Introspectable* node, std::string const& parent_path) | 54 | IntrospectableAdapter(Introspectable* node, IntrospectableAdapter::Ptr const& parent = nullptr) |
2007 | 56 | : node_(node) | 55 | : node_(node) |
2008 | 56 | , parent_(parent) | ||
2009 | 57 | , full_path_((parent_ ? parent_->GetPath() : "") + "/" + GetName()) | ||
2010 | 58 | {} | ||
2011 | 59 | |||
2012 | 60 | int32_t GetId() const | ||
2013 | 57 | { | 61 | { |
2015 | 58 | full_path_ = parent_path + "/" + GetName(); | 62 | return node_->GetIntrospectionId(); |
2016 | 59 | } | 63 | } |
2017 | 60 | 64 | ||
2018 | 61 | std::string GetName() const | 65 | std::string GetName() const |
2019 | @@ -68,145 +72,124 @@ | |||
2020 | 68 | return full_path_; | 72 | return full_path_; |
2021 | 69 | } | 73 | } |
2022 | 70 | 74 | ||
2035 | 71 | bool MatchProperty(const std::string& name, const std::string& value) const | 75 | Node::Ptr GetParent() const |
2036 | 72 | { | 76 | { |
2037 | 73 | bool matches = false; | 77 | return parent_; |
2038 | 74 | 78 | } | |
2039 | 75 | GVariantBuilder child_builder; | 79 | |
2040 | 76 | g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a{sv}")); | 80 | bool MatchStringProperty(std::string const& name, std::string const& value) const |
2041 | 77 | g_variant_builder_add(&child_builder, "{sv}", "id", g_variant_new_uint64(node_->GetIntrospectionId())); | 81 | { |
2042 | 78 | node_->AddProperties(&child_builder); | 82 | auto const& prop_value = GetPropertyValue(name); |
2043 | 79 | GVariant* prop_dict = g_variant_builder_end(&child_builder); | 83 | |
2044 | 80 | GVariant *prop_value = g_variant_lookup_value(prop_dict, name.c_str(), NULL); | 84 | if (prop_value) |
2045 | 81 | 85 | { | |
2046 | 82 | if (prop_value != NULL) | 86 | if (!g_variant_is_of_type(prop_value, G_VARIANT_TYPE_STRING)) |
2047 | 87 | { | ||
2048 | 88 | LOG_WARNING(logger) << "Unable to match '"<< name << "', it's not a string property."; | ||
2049 | 89 | return false; | ||
2050 | 90 | } | ||
2051 | 91 | |||
2052 | 92 | return (prop_value.GetString() == value); | ||
2053 | 93 | } | ||
2054 | 94 | |||
2055 | 95 | return false; | ||
2056 | 96 | } | ||
2057 | 97 | |||
2058 | 98 | bool MatchBooleanProperty(std::string const& name, bool value) const | ||
2059 | 99 | { | ||
2060 | 100 | auto const& prop_value = GetPropertyValue(name); | ||
2061 | 101 | |||
2062 | 102 | if (prop_value) | ||
2063 | 103 | { | ||
2064 | 104 | if (!g_variant_is_of_type(prop_value, G_VARIANT_TYPE_BOOLEAN)) | ||
2065 | 105 | { | ||
2066 | 106 | LOG_WARNING(logger) << "Unable to match '"<< name << "', it's not a boolean property."; | ||
2067 | 107 | return false; | ||
2068 | 108 | } | ||
2069 | 109 | |||
2070 | 110 | return (prop_value.GetBool() == value); | ||
2071 | 111 | } | ||
2072 | 112 | |||
2073 | 113 | return false; | ||
2074 | 114 | } | ||
2075 | 115 | |||
2076 | 116 | bool MatchIntegerProperty(std::string const& name, int32_t value) const | ||
2077 | 117 | { | ||
2078 | 118 | auto const& prop_value = GetPropertyValue(name); | ||
2079 | 119 | |||
2080 | 120 | if (prop_value) | ||
2081 | 83 | { | 121 | { |
2082 | 84 | GVariantClass prop_val_type = g_variant_classify(prop_value); | 122 | GVariantClass prop_val_type = g_variant_classify(prop_value); |
2087 | 85 | // it'd be nice to be able to do all this with one method. However, the booleans need | 123 | // it'd be nice to be able to do all this with one method. |
2088 | 86 | // special treatment, and I can't figure out how to group all the integer types together | 124 | // I can't figure out how to group all the integer types together |
2085 | 87 | // without resorting to template functions.... and we all know what happens when you | ||
2086 | 88 | // start doing that... | ||
2089 | 89 | switch (prop_val_type) | 125 | switch (prop_val_type) |
2090 | 90 | { | 126 | { |
2091 | 91 | case G_VARIANT_CLASS_STRING: | ||
2092 | 92 | { | ||
2093 | 93 | const gchar* prop_val = g_variant_get_string(prop_value, NULL); | ||
2094 | 94 | if (g_strcmp0(prop_val, value.c_str()) == 0) | ||
2095 | 95 | { | ||
2096 | 96 | matches = true; | ||
2097 | 97 | } | ||
2098 | 98 | } | ||
2099 | 99 | break; | ||
2100 | 100 | case G_VARIANT_CLASS_BOOLEAN: | ||
2101 | 101 | { | ||
2102 | 102 | std::string value = boost::to_upper_copy(value); | ||
2103 | 103 | bool p = value == "TRUE" || | ||
2104 | 104 | value == "ON" || | ||
2105 | 105 | value == "YES" || | ||
2106 | 106 | value == "1"; | ||
2107 | 107 | matches = (g_variant_get_boolean(prop_value) == p); | ||
2108 | 108 | } | ||
2109 | 109 | break; | ||
2110 | 110 | case G_VARIANT_CLASS_BYTE: | 127 | case G_VARIANT_CLASS_BYTE: |
2120 | 111 | { | 128 | return static_cast<unsigned char>(value) == prop_value.GetByte(); |
2112 | 112 | // It would be nice if I could do all the integer types together, but I couldn't see how... | ||
2113 | 113 | std::stringstream stream(value); | ||
2114 | 114 | int val; // changing this to guchar causes problems. | ||
2115 | 115 | stream >> val; | ||
2116 | 116 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2117 | 117 | val == g_variant_get_byte(prop_value); | ||
2118 | 118 | } | ||
2119 | 119 | break; | ||
2121 | 120 | case G_VARIANT_CLASS_INT16: | 129 | case G_VARIANT_CLASS_INT16: |
2130 | 121 | { | 130 | return value == prop_value.GetInt16(); |
2123 | 122 | std::stringstream stream(value); | ||
2124 | 123 | gint16 val; | ||
2125 | 124 | stream >> val; | ||
2126 | 125 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2127 | 126 | val == g_variant_get_int16(prop_value); | ||
2128 | 127 | } | ||
2129 | 128 | break; | ||
2131 | 129 | case G_VARIANT_CLASS_UINT16: | 131 | case G_VARIANT_CLASS_UINT16: |
2140 | 130 | { | 132 | return static_cast<uint16_t>(value) == prop_value.GetUInt16(); |
2133 | 131 | std::stringstream stream(value); | ||
2134 | 132 | guint16 val; | ||
2135 | 133 | stream >> val; | ||
2136 | 134 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2137 | 135 | val == g_variant_get_uint16(prop_value); | ||
2138 | 136 | } | ||
2139 | 137 | break; | ||
2141 | 138 | case G_VARIANT_CLASS_INT32: | 133 | case G_VARIANT_CLASS_INT32: |
2150 | 139 | { | 134 | return value == prop_value.GetInt32(); |
2143 | 140 | std::stringstream stream(value); | ||
2144 | 141 | gint32 val; | ||
2145 | 142 | stream >> val; | ||
2146 | 143 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2147 | 144 | val == g_variant_get_int32(prop_value); | ||
2148 | 145 | } | ||
2149 | 146 | break; | ||
2151 | 147 | case G_VARIANT_CLASS_UINT32: | 135 | case G_VARIANT_CLASS_UINT32: |
2160 | 148 | { | 136 | return static_cast<uint32_t>(value) == prop_value.GetUInt32(); |
2153 | 149 | std::stringstream stream(value); | ||
2154 | 150 | guint32 val; | ||
2155 | 151 | stream >> val; | ||
2156 | 152 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2157 | 153 | val == g_variant_get_uint32(prop_value); | ||
2158 | 154 | } | ||
2159 | 155 | break; | ||
2161 | 156 | case G_VARIANT_CLASS_INT64: | 137 | case G_VARIANT_CLASS_INT64: |
2170 | 157 | { | 138 | return value == prop_value.GetInt64(); |
2163 | 158 | std::stringstream stream(value); | ||
2164 | 159 | gint64 val; | ||
2165 | 160 | stream >> val; | ||
2166 | 161 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2167 | 162 | val == g_variant_get_int64(prop_value); | ||
2168 | 163 | } | ||
2169 | 164 | break; | ||
2171 | 165 | case G_VARIANT_CLASS_UINT64: | 139 | case G_VARIANT_CLASS_UINT64: |
2180 | 166 | { | 140 | return static_cast<uint64_t>(value) == prop_value.GetUInt64(); |
2173 | 167 | std::stringstream stream(value); | ||
2174 | 168 | guint64 val; | ||
2175 | 169 | stream >> val; | ||
2176 | 170 | matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && | ||
2177 | 171 | val == g_variant_get_uint64(prop_value); | ||
2178 | 172 | } | ||
2179 | 173 | break; | ||
2181 | 174 | default: | 141 | default: |
2183 | 175 | LOG_WARNING(logger) << "Unable to match against property of unknown type."; | 142 | LOG_WARNING(logger) << "Unable to match '"<< name << "' against property of unknown integer type."; |
2184 | 176 | }; | 143 | }; |
2185 | 177 | } | 144 | } |
2189 | 178 | g_variant_unref(prop_value); | 145 | |
2190 | 179 | g_variant_unref(prop_dict); | 146 | return false; |
2191 | 180 | return matches; | 147 | } |
2192 | 148 | |||
2193 | 149 | glib::Variant GetPropertyValue(std::string const& name) const | ||
2194 | 150 | { | ||
2195 | 151 | if (name == "id") | ||
2196 | 152 | return glib::Variant(GetId()); | ||
2197 | 153 | |||
2198 | 154 | GVariantBuilder properties_builder; | ||
2199 | 155 | g_variant_builder_init(&properties_builder, G_VARIANT_TYPE("a{sv}")); | ||
2200 | 156 | node_->AddProperties(&properties_builder); | ||
2201 | 157 | glib::Variant props_dict(g_variant_builder_end(&properties_builder)); | ||
2202 | 158 | return g_variant_lookup_value(props_dict, name.c_str(), nullptr); | ||
2203 | 181 | } | 159 | } |
2204 | 182 | 160 | ||
2205 | 183 | std::vector<xpathselect::Node::Ptr> Children() const | 161 | std::vector<xpathselect::Node::Ptr> Children() const |
2206 | 184 | { | 162 | { |
2207 | 185 | std::vector<xpathselect::Node::Ptr> children; | 163 | std::vector<xpathselect::Node::Ptr> children; |
2212 | 186 | for(auto child: node_->GetIntrospectableChildren()) | 164 | auto const& this_ptr = shared_from_this(); |
2213 | 187 | { | 165 | |
2214 | 188 | children.push_back(std::make_shared<IntrospectableAdapter>(child, GetPath() )); | 166 | for(auto const& child: node_->GetIntrospectableChildren()) |
2215 | 189 | } | 167 | children.push_back(std::make_shared<IntrospectableAdapter>(child, this_ptr)); |
2216 | 168 | |||
2217 | 190 | return children; | 169 | return children; |
2221 | 191 | 170 | } | |
2222 | 192 | } | 171 | |
2223 | 193 | 172 | Introspectable* Node() const | |
2224 | 173 | { | ||
2225 | 174 | return node_; | ||
2226 | 175 | } | ||
2227 | 176 | |||
2228 | 177 | private: | ||
2229 | 194 | Introspectable* node_; | 178 | Introspectable* node_; |
2231 | 195 | private: | 179 | IntrospectableAdapter::Ptr parent_; |
2232 | 196 | std::string full_path_; | 180 | std::string full_path_; |
2233 | 197 | }; | 181 | }; |
2234 | 198 | 182 | ||
2237 | 199 | xpathselect::NodeList select_nodes(local::IntrospectableAdapter::Ptr root, | 183 | xpathselect::NodeVector select_nodes(IntrospectableAdapter::Ptr const& root, std::string const& query) |
2236 | 200 | std::string const& query) | ||
2238 | 201 | { | 184 | { |
2241 | 202 | if (xpathselect_driver_ == NULL) | 185 | if (!xpathselect_driver_) |
2242 | 203 | xpathselect_driver_ = dlopen("libxpathselect.so.1.3", RTLD_LAZY); | 186 | xpathselect_driver_ = dlopen(XPATH_SELECT_LIB.c_str(), RTLD_LAZY); |
2243 | 204 | 187 | ||
2244 | 205 | if (xpathselect_driver_) | 188 | if (xpathselect_driver_) |
2245 | 206 | { | 189 | { |
2247 | 207 | typedef decltype(&xpathselect::SelectNodes) entry_t; | 190 | typedef decltype(&xpathselect::SelectNodes) select_nodes_t; |
2248 | 208 | dlerror(); | 191 | dlerror(); |
2250 | 209 | entry_t entry_point = (entry_t) dlsym(xpathselect_driver_, "SelectNodes"); | 192 | auto SelectNodes = reinterpret_cast<select_nodes_t>(dlsym(xpathselect_driver_, "SelectNodes")); |
2251 | 210 | const char* err = dlerror(); | 193 | const char* err = dlerror(); |
2252 | 211 | if (err) | 194 | if (err) |
2253 | 212 | { | 195 | { |
2254 | @@ -214,7 +197,7 @@ | |||
2255 | 214 | } | 197 | } |
2256 | 215 | else | 198 | else |
2257 | 216 | { | 199 | { |
2259 | 217 | return entry_point(root, query); | 200 | return SelectNodes(root, query); |
2260 | 218 | } | 201 | } |
2261 | 219 | } | 202 | } |
2262 | 220 | else | 203 | else |
2263 | @@ -223,7 +206,7 @@ | |||
2264 | 223 | } | 206 | } |
2265 | 224 | 207 | ||
2266 | 225 | // Fallen through here as we've hit an error | 208 | // Fallen through here as we've hit an error |
2268 | 226 | return xpathselect::NodeList(); | 209 | return xpathselect::NodeVector(); |
2269 | 227 | } | 210 | } |
2270 | 228 | 211 | ||
2271 | 229 | // This needs to be called at destruction to cleanup the dlopen | 212 | // This needs to be called at destruction to cleanup the dlopen |
2272 | @@ -240,10 +223,8 @@ | |||
2273 | 240 | GVariant* GetState(std::string const& query); | 223 | GVariant* GetState(std::string const& query); |
2274 | 241 | void StartLogToFile(std::string const& file_path); | 224 | void StartLogToFile(std::string const& file_path); |
2275 | 242 | void ResetLogging(); | 225 | void ResetLogging(); |
2280 | 243 | void SetLogSeverity(std::string const& log_component, | 226 | void SetLogSeverity(std::string const& log_component, std::string const& severity); |
2281 | 244 | std::string const& severity); | 227 | void LogMessage(std::string const& severity, std::string const& message); |
2278 | 245 | void LogMessage(std::string const& severity, | ||
2279 | 246 | std::string const& message); | ||
2282 | 247 | 228 | ||
2283 | 248 | namespace dbus | 229 | namespace dbus |
2284 | 249 | { | 230 | { |
2285 | @@ -317,7 +298,7 @@ | |||
2286 | 317 | } | 298 | } |
2287 | 318 | else if (method == "GetVersion") | 299 | else if (method == "GetVersion") |
2288 | 319 | { | 300 | { |
2290 | 320 | return g_variant_new("(s)", "1.3"); | 301 | return g_variant_new("(s)", local::PROTOCOL_VERSION.c_str()); |
2291 | 321 | } | 302 | } |
2292 | 322 | else if (method == "StartLogToFile") | 303 | else if (method == "StartLogToFile") |
2293 | 323 | { | 304 | { |
2294 | @@ -352,16 +333,15 @@ | |||
2295 | 352 | 333 | ||
2296 | 353 | GVariant* GetState(std::string const& query) | 334 | GVariant* GetState(std::string const& query) |
2297 | 354 | { | 335 | { |
2299 | 355 | GVariantBuilder builder; | 336 | GVariantBuilder builder; |
2300 | 356 | g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sv)")); | 337 | g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sv)")); |
2301 | 357 | 338 | ||
2305 | 358 | local::IntrospectableAdapter::Ptr root_node = std::make_shared<local::IntrospectableAdapter>(_parent_introspectable, std::string()); | 339 | auto root_node = std::make_shared<local::IntrospectableAdapter>(_parent_introspectable); |
2306 | 359 | auto nodes = local::select_nodes(root_node, query); | 340 | for (auto const& n : local::select_nodes(root_node, query)) |
2304 | 360 | for (auto n : nodes) | ||
2307 | 361 | { | 341 | { |
2309 | 362 | auto p = std::static_pointer_cast<local::IntrospectableAdapter>(n); | 342 | auto p = std::static_pointer_cast<local::IntrospectableAdapter const>(n); |
2310 | 363 | if (p) | 343 | if (p) |
2312 | 364 | g_variant_builder_add(&builder, "(sv)", p->GetPath().c_str(), p->node_->Introspect()); | 344 | g_variant_builder_add(&builder, "(sv)", p->GetPath().c_str(), p->Node()->Introspect()); |
2313 | 365 | } | 345 | } |
2314 | 366 | 346 | ||
2315 | 367 | return g_variant_new("(a(sv))", &builder); | 347 | return g_variant_new("(a(sv))", &builder); |
2316 | 368 | 348 | ||
2317 | === modified file 'unity-shared/Introspectable.cpp' | |||
2318 | --- unity-shared/Introspectable.cpp 2013-01-23 02:59:06 +0000 | |||
2319 | +++ unity-shared/Introspectable.cpp 2013-11-06 08:52:17 +0000 | |||
2320 | @@ -17,6 +17,7 @@ | |||
2321 | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> | 17 | * Authored by: Alex Launi <alex.launi@canonical.com> |
2322 | 18 | */ | 18 | */ |
2323 | 19 | 19 | ||
2324 | 20 | #include <UnityCore/Variant.h> | ||
2325 | 20 | #include "Introspectable.h" | 21 | #include "Introspectable.h" |
2326 | 21 | 22 | ||
2327 | 22 | namespace unity | 23 | namespace unity |
2328 | @@ -24,88 +25,85 @@ | |||
2329 | 24 | namespace debug | 25 | namespace debug |
2330 | 25 | { | 26 | { |
2331 | 26 | 27 | ||
2332 | 28 | const std::string CHILDREN_NAME = "Children"; | ||
2333 | 29 | |||
2334 | 27 | Introspectable::Introspectable() | 30 | Introspectable::Introspectable() |
2335 | 28 | { | 31 | { |
2338 | 29 | static guint64 unique_id=0; | 32 | static int32_t unique_id_ = 0; |
2339 | 30 | _id = unique_id++; | 33 | id_ = unique_id_++; |
2340 | 31 | } | 34 | } |
2341 | 32 | 35 | ||
2342 | 33 | Introspectable::~Introspectable() | 36 | Introspectable::~Introspectable() |
2343 | 34 | { | 37 | { |
2348 | 35 | for (auto parent : _parents) | 38 | for (auto parent : parents_) |
2349 | 36 | parent->_children.remove(this); | 39 | parent->children_.remove(this); |
2350 | 37 | for (auto child : _children) | 40 | for (auto child : children_) |
2351 | 38 | child->_parents.remove(this); | 41 | child->parents_.remove(this); |
2352 | 39 | } | 42 | } |
2353 | 40 | 43 | ||
2354 | 41 | Introspectable::IntrospectableList Introspectable::GetIntrospectableChildren() | 44 | Introspectable::IntrospectableList Introspectable::GetIntrospectableChildren() |
2355 | 42 | { | 45 | { |
2357 | 43 | return _children; | 46 | return children_; |
2358 | 44 | } | 47 | } |
2359 | 45 | 48 | ||
2360 | 46 | GVariant* | 49 | GVariant* |
2361 | 47 | Introspectable::Introspect() | 50 | Introspectable::Introspect() |
2362 | 48 | { | 51 | { |
2366 | 49 | GVariantBuilder builder; | 52 | GVariantBuilder builder; |
2367 | 50 | GVariantBuilder child_builder; | 53 | GVariantBuilder child_builder; |
2368 | 51 | gint n_children = 0; | 54 | bool has_valid_children = false; |
2369 | 52 | 55 | ||
2370 | 53 | g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); | 56 | g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); |
2373 | 54 | g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id)); | 57 | variant::BuilderWrapper build_wrapper(&builder); |
2374 | 55 | 58 | build_wrapper.add("id", id_); | |
2375 | 56 | AddProperties(&builder); | 59 | AddProperties(&builder); |
2376 | 57 | 60 | ||
2377 | 58 | g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); | 61 | g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); |
2378 | 59 | 62 | ||
2381 | 60 | auto children = GetIntrospectableChildren(); | 63 | for (auto const& child : GetIntrospectableChildren()) |
2380 | 61 | for (auto it = children.begin(); it != children.end(); it++) | ||
2382 | 62 | { | 64 | { |
2384 | 63 | if ((*it)->GetName() != "") | 65 | auto const& child_name = child->GetName(); |
2385 | 66 | |||
2386 | 67 | if (!child_name.empty()) | ||
2387 | 64 | { | 68 | { |
2390 | 65 | g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str()); | 69 | g_variant_builder_add(&child_builder, "s", child_name.c_str()); |
2391 | 66 | n_children++; | 70 | has_valid_children = true; |
2392 | 67 | } | 71 | } |
2393 | 68 | } | 72 | } |
2394 | 69 | 73 | ||
2399 | 70 | GVariant* child_results = g_variant_builder_end(&child_builder); | 74 | glib::Variant child_results(g_variant_builder_end(&child_builder)); |
2400 | 71 | 75 | ||
2401 | 72 | if (n_children > 0) | 76 | if (has_valid_children) |
2402 | 73 | g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results); | 77 | build_wrapper.add(CHILDREN_NAME, child_results); |
2403 | 78 | |||
2404 | 74 | return g_variant_builder_end(&builder); | 79 | return g_variant_builder_end(&builder); |
2405 | 75 | } | 80 | } |
2406 | 76 | 81 | ||
2407 | 77 | void | 82 | void |
2408 | 78 | Introspectable::AddChild(Introspectable* child) | 83 | Introspectable::AddChild(Introspectable* child) |
2409 | 79 | { | 84 | { |
2412 | 80 | _children.push_back(child); | 85 | children_.push_back(child); |
2413 | 81 | child->_parents.push_back(this); | 86 | child->parents_.push_back(this); |
2414 | 82 | } | 87 | } |
2415 | 83 | 88 | ||
2416 | 84 | void | 89 | void |
2417 | 85 | Introspectable::RemoveChild(Introspectable* child) | 90 | Introspectable::RemoveChild(Introspectable* child) |
2418 | 86 | { | 91 | { |
2432 | 87 | _children.remove(child); | 92 | children_.remove(child); |
2433 | 88 | child->_parents.remove(this); | 93 | child->parents_.remove(this); |
2434 | 89 | } | 94 | } |
2435 | 90 | 95 | ||
2436 | 91 | std::string | 96 | int32_t Introspectable::GetIntrospectionId() const |
2437 | 92 | Introspectable::GetChildsName() const | 97 | { |
2438 | 93 | { | 98 | return id_; |
2426 | 94 | return "Children"; | ||
2427 | 95 | } | ||
2428 | 96 | |||
2429 | 97 | guint64 Introspectable::GetIntrospectionId() const | ||
2430 | 98 | { | ||
2431 | 99 | return _id; | ||
2439 | 100 | } | 99 | } |
2440 | 101 | 100 | ||
2441 | 102 | void Introspectable::RemoveAllChildren() | 101 | void Introspectable::RemoveAllChildren() |
2442 | 103 | { | 102 | { |
2448 | 104 | for (auto child : _children) | 103 | for (auto child : children_) |
2449 | 105 | { | 104 | child->parents_.remove(this); |
2450 | 106 | child->_parents.remove(this); | 105 | |
2451 | 107 | } | 106 | children_.clear(); |
2447 | 108 | _children.clear(); | ||
2452 | 109 | } | 107 | } |
2453 | 110 | 108 | ||
2454 | 111 | } | 109 | } |
2455 | 112 | 110 | ||
2456 | === modified file 'unity-shared/Introspectable.h' | |||
2457 | --- unity-shared/Introspectable.h 2013-01-23 02:59:06 +0000 | |||
2458 | +++ unity-shared/Introspectable.h 2013-11-06 08:52:17 +0000 | |||
2459 | @@ -41,13 +41,9 @@ | |||
2460 | 41 | void RemoveChild(Introspectable* child); | 41 | void RemoveChild(Introspectable* child); |
2461 | 42 | virtual void AddProperties(GVariantBuilder* builder) = 0; | 42 | virtual void AddProperties(GVariantBuilder* builder) = 0; |
2462 | 43 | virtual IntrospectableList GetIntrospectableChildren(); | 43 | virtual IntrospectableList GetIntrospectableChildren(); |
2464 | 44 | guint64 GetIntrospectionId() const; | 44 | int32_t GetIntrospectionId() const; |
2465 | 45 | 45 | ||
2466 | 46 | protected: | 46 | protected: |
2467 | 47 | /// Please don't override this unless you really need to. The only valid reason | ||
2468 | 48 | /// is if you have a property that simply *must* be called 'Children'. | ||
2469 | 49 | virtual std::string GetChildsName() const; | ||
2470 | 50 | |||
2471 | 51 | void RemoveAllChildren(); | 47 | void RemoveAllChildren(); |
2472 | 52 | 48 | ||
2473 | 53 | /* | 49 | /* |
2474 | @@ -61,9 +57,9 @@ | |||
2475 | 61 | */ | 57 | */ |
2476 | 62 | 58 | ||
2477 | 63 | private: | 59 | private: |
2481 | 64 | std::list<Introspectable*> _children; | 60 | std::list<Introspectable*> children_; |
2482 | 65 | std::list<Introspectable*> _parents; | 61 | std::list<Introspectable*> parents_; |
2483 | 66 | guint64 _id; | 62 | int32_t id_; |
2484 | 67 | }; | 63 | }; |
2485 | 68 | } | 64 | } |
2486 | 69 | } | 65 | } |
2487 | 70 | 66 | ||
2488 | === modified file 'unity-shared/SearchBar.cpp' | |||
2489 | --- unity-shared/SearchBar.cpp 2013-07-24 01:01:44 +0000 | |||
2490 | +++ unity-shared/SearchBar.cpp 2013-11-06 08:52:17 +0000 | |||
2491 | @@ -617,6 +617,7 @@ | |||
2492 | 617 | .add("filter-label-y", show_filters_->GetAbsoluteY()) | 617 | .add("filter-label-y", show_filters_->GetAbsoluteY()) |
2493 | 618 | .add("filter-label-width", show_filters_->GetAbsoluteWidth()) | 618 | .add("filter-label-width", show_filters_->GetAbsoluteWidth()) |
2494 | 619 | .add("filter-label-height", show_filters_->GetAbsoluteHeight()) | 619 | .add("filter-label-height", show_filters_->GetAbsoluteHeight()) |
2495 | 620 | .add("filter-label-geo", show_filters_->GetAbsoluteGeometry()) | ||
2496 | 620 | .add("im_active", pango_entry_->im_active()); | 621 | .add("im_active", pango_entry_->im_active()); |
2497 | 621 | } | 622 | } |
2498 | 622 | 623 |
FAILED: Continuous integration, rev:3590 jenkins. qa.ubuntu. com/job/ unity-ci/ 491/ jenkins. qa.ubuntu. com/job/ unity-trusty- amd64-ci/ 22/console jenkins. qa.ubuntu. com/job/ unity-trusty- armhf-ci/ 22/console jenkins. qa.ubuntu. com/job/ unity-trusty- i386-ci/ 22/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/unity- ci/491/ rebuild
http://