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