Merge lp:~canonical-dx-team/unity/unity.quicklist-introspection into lp:unity

Proposed by Jay Taoko on 2010-12-02
Status: Merged
Merged at revision: 658
Proposed branch: lp:~canonical-dx-team/unity/unity.quicklist-introspection
Merge into: lp:unity
Diff against target: 425 lines (+124/-3)
12 files modified
src/LauncherIcon.cpp (+8/-0)
src/QuicklistMenuItem.cpp (+23/-0)
src/QuicklistMenuItem.h (+9/-1)
src/QuicklistMenuItemCheckmark.cpp (+2/-0)
src/QuicklistMenuItemLabel.cpp (+2/-0)
src/QuicklistMenuItemRadio.cpp (+2/-0)
src/QuicklistMenuItemSeparator.cpp (+2/-0)
src/QuicklistView.cpp (+32/-0)
src/QuicklistView.h (+11/-1)
src/Tooltip.cpp (+21/-0)
src/Tooltip.h (+11/-1)
tests/CMakeLists.txt (+1/-0)
To merge this branch: bzr merge lp:~canonical-dx-team/unity/unity.quicklist-introspection
Reviewer Review Type Date Requested Status
Alex Launi (community) 2010-12-02 Approve on 2010-12-02
Review via email: mp+42494@code.launchpad.net

Description of the Change

* Added introspection to Quiclist, tooltip and Launcher Icon

To post a comment you must log in.
653. By Jason Smith on 2010-12-02

Merge jason.fixes branch

654. By Jason Smith on 2010-12-02

Merge launcher introspection branch

655. By Jason Smith on 2010-12-02

Fix merge issues

656. By Jay Taoko on 2010-12-02

* Added introspection to Quicklist, QuicklistMenuItem and Tooltip

[modified]
  src/LauncherIcon.cpp
 src/LauncherIcon.h
  src/QuicklistMenuItem.cpp
  src/QuicklistMenuItem.h
  src/QuicklistMenuItemCheckmark.cpp
  src/QuicklistMenuItemLabel.cpp
  src/QuicklistMenuItemRadio.cpp
  src/QuicklistMenuItemSeparator.cpp
  src/QuicklistView.cpp
  src/QuicklistView.h
  src/Tooltip.cpp
  src/Tooltip.h
  tests/CMakeLists.txt

Alex Launi (alexlauni) wrote :

The only things I would add are the actual text of the tooltip and the quicklist items. Other than that, looks good. Merge!

review: Approve
657. By Jay Taoko on 2010-12-02

* Adding more introspection parameters to Tooltip and QuicklistMenuItem.

[modified]
  src/QuicklistMenuItem.cpp
  src/Tooltip.cpp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/LauncherIcon.cpp'
2--- src/LauncherIcon.cpp 2010-12-02 16:21:39 +0000
3+++ src/LauncherIcon.cpp 2010-12-02 17:09:36 +0000
4@@ -70,6 +70,10 @@
5 _quicklist->sigHidden.connect (sigc::mem_fun (this, &LauncherIcon::RecvHideQuicklist));
6 _quicklist_is_initialized = false;
7
8+ // Add to introspection
9+ AddChild (_quicklist);
10+ AddChild (_tooltip);
11+
12 MouseEnter.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter));
13 MouseLeave.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave));
14 MouseDown.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));
15@@ -79,6 +83,10 @@
16
17 LauncherIcon::~LauncherIcon()
18 {
19+ // Remove from introspection
20+ RemoveChild (_quicklist);
21+ RemoveChild (_tooltip);
22+
23 if (_present_time_handle)
24 g_source_remove (_present_time_handle);
25 _present_time_handle = 0;
26
27=== modified file 'src/QuicklistMenuItem.cpp'
28--- src/QuicklistMenuItem.cpp 2010-11-30 11:33:50 +0000
29+++ src/QuicklistMenuItem.cpp 2010-12-02 17:09:36 +0000
30@@ -43,6 +43,7 @@
31 g_warning ("Invalid DbusmenuMenuitem in file %s at line %s.", G_STRFUNC, G_STRLOC);
32 }
33
34+ _name = 0;
35 _text = 0;
36 _color = nux::Color (1.0f, 1.0f, 1.0f, 1.0f);
37 _menuItem = item;
38@@ -118,6 +119,9 @@
39
40 QuicklistMenuItem::~QuicklistMenuItem ()
41 {
42+ if (_name)
43+ g_free (_name);
44+
45 if (_text)
46 g_free (_text);
47 }
48@@ -444,3 +448,22 @@
49 g_free (fontName);
50 g_object_unref (layout);
51 }
52+
53+// Introspection
54+
55+const gchar* QuicklistMenuItem::GetName ()
56+{
57+ return g_strdup (_name);
58+}
59+
60+void QuicklistMenuItem::AddProperties (GVariantBuilder *builder)
61+{
62+ g_variant_builder_add (builder, "{sv}", "text", g_variant_new_string (_text));
63+ g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (GetBaseX ()));
64+ g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (GetBaseY ()));
65+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (GetBaseWidth ()));
66+ g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (GetBaseHeight ()));
67+ g_variant_builder_add (builder, "{sv}", "enabled", g_variant_new_boolean (GetEnabled ()));
68+ g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (GetActive ()));
69+
70+}
71
72=== modified file 'src/QuicklistMenuItem.h'
73--- src/QuicklistMenuItem.h 2010-12-01 22:22:43 +0000
74+++ src/QuicklistMenuItem.h 2010-12-02 17:09:36 +0000
75@@ -30,6 +30,8 @@
76 #include <pango/pango.h>
77 #include <pango/pangocairo.h>
78
79+#include "Introspectable.h"
80+
81 #define ITEM_INDENT_ABS 16
82 #define ITEM_CORNER_RADIUS_ABS 3
83 #define ITEM_MARGIN 4
84@@ -43,7 +45,7 @@
85 MENUITEM_TYPE_RADIO,
86 } QuicklistMenuItemType;
87
88-class QuicklistMenuItem : public nux::View
89+class QuicklistMenuItem : public nux::View, public Introspectable
90 {
91 public:
92 QuicklistMenuItem (DbusmenuMenuitem* item,
93@@ -86,6 +88,9 @@
94
95 virtual bool GetActive ();
96
97+ // Introspection
98+ const gchar* GetName ();
99+ void AddProperties (GVariantBuilder *builder);
100 protected:
101
102 gchar* _text;
103@@ -139,6 +144,9 @@
104 int height,
105 nux::Color color);
106
107+ // Introspection
108+ gchar *_name;
109+
110 friend class QuicklistView;
111 };
112
113
114=== modified file 'src/QuicklistMenuItemCheckmark.cpp'
115--- src/QuicklistMenuItemCheckmark.cpp 2010-12-01 22:22:43 +0000
116+++ src/QuicklistMenuItemCheckmark.cpp 2010-12-02 17:09:36 +0000
117@@ -39,6 +39,7 @@
118 QuicklistMenuItem (item,
119 NUX_FILE_LINE_PARAM)
120 {
121+ _name = g_strdup ("QuicklistMenuItemCheckmark");
122 Initialize (item);
123 }
124
125@@ -49,6 +50,7 @@
126 debug,
127 NUX_FILE_LINE_PARAM)
128 {
129+ _name = g_strdup ("QuicklistMenuItemCheckmark");
130 Initialize (item);
131 }
132
133
134=== modified file 'src/QuicklistMenuItemLabel.cpp'
135--- src/QuicklistMenuItemLabel.cpp 2010-12-01 22:22:43 +0000
136+++ src/QuicklistMenuItemLabel.cpp 2010-12-02 17:09:36 +0000
137@@ -28,6 +28,7 @@
138 QuicklistMenuItem (item,
139 NUX_FILE_LINE_PARAM)
140 {
141+ _name = g_strdup ("QuicklistMenuItemLabel");
142 Initialize (item);
143 }
144
145@@ -38,6 +39,7 @@
146 debug,
147 NUX_FILE_LINE_PARAM)
148 {
149+ _name = g_strdup ("QuicklistMenuItemLabel");
150 Initialize (item);
151 }
152
153
154=== modified file 'src/QuicklistMenuItemRadio.cpp'
155--- src/QuicklistMenuItemRadio.cpp 2010-12-01 22:22:43 +0000
156+++ src/QuicklistMenuItemRadio.cpp 2010-12-02 17:09:36 +0000
157@@ -38,6 +38,7 @@
158 QuicklistMenuItem (item,
159 NUX_FILE_LINE_PARAM)
160 {
161+ _name = g_strdup ("QuicklistMenuItemRadio");
162 Initialize (item);
163 }
164
165@@ -48,6 +49,7 @@
166 debug,
167 NUX_FILE_LINE_PARAM)
168 {
169+ _name = g_strdup ("QuicklistMenuItemRadio");
170 Initialize (item);
171 }
172
173
174=== modified file 'src/QuicklistMenuItemSeparator.cpp'
175--- src/QuicklistMenuItemSeparator.cpp 2010-12-01 22:22:43 +0000
176+++ src/QuicklistMenuItemSeparator.cpp 2010-12-02 17:09:36 +0000
177@@ -24,6 +24,7 @@
178 QuicklistMenuItem (item,
179 NUX_FILE_LINE_PARAM)
180 {
181+ _name = g_strdup ("QuicklistMenuItemSeparator");
182 SetMinimumHeight (5);
183 SetBaseSize (64, 5);
184 //_normalTexture = NULL;
185@@ -38,6 +39,7 @@
186 debug,
187 NUX_FILE_LINE_PARAM)
188 {
189+ _name = g_strdup ("QuicklistMenuItemSeparator");
190 SetMinimumHeight (5);
191 SetBaseSize (64, 5);
192 //_normalTexture = NULL;
193
194=== modified file 'src/QuicklistView.cpp'
195--- src/QuicklistView.cpp 2010-11-30 12:24:08 +0000
196+++ src/QuicklistView.cpp 2010-12-02 17:09:36 +0000
197@@ -35,10 +35,13 @@
198 #include "QuicklistMenuItemCheckmark.h"
199 #include "QuicklistMenuItemRadio.h"
200
201+#include "Introspectable.h"
202+
203 NUX_IMPLEMENT_OBJECT_TYPE (QuicklistView);
204
205 QuicklistView::QuicklistView ()
206 {
207+ _name = g_strdup ("Quicklist");
208 _texture_bg = 0;
209 _texture_mask = 0;
210 _texture_outline = 0;
211@@ -93,6 +96,9 @@
212
213 QuicklistView::~QuicklistView ()
214 {
215+ if (_name)
216+ g_free (_name);
217+
218 if (_texture_bg)
219 _texture_bg->UnReference ();
220
221@@ -105,11 +111,15 @@
222 std::list<QuicklistMenuItem*>::iterator it;
223 for (it = _item_list.begin(); it != _item_list.end(); it++)
224 {
225+ // Remove from introspection
226+ RemoveChild (*it);
227 (*it)->UnReference();
228 }
229
230 for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
231 {
232+ // Remove from introspection
233+ RemoveChild (*it);
234 (*it)->UnReference();
235 }
236
237@@ -579,11 +589,15 @@
238 std::list<QuicklistMenuItem*>::iterator it;
239 for (it = _item_list.begin(); it != _item_list.end(); it++)
240 {
241+ // Remove from introspection
242+ RemoveChild (*it);
243 (*it)->UnReference();
244 }
245
246 for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
247 {
248+ // Remove from introspection
249+ RemoveChild (*it);
250 (*it)->UnReference();
251 }
252
253@@ -612,6 +626,8 @@
254 _item_layout->AddView(item, 1, nux::eCenter, nux::eFull);
255 _item_list.push_back (item);
256 item->Reference();
257+ // Add to introspection
258+ AddChild (item);
259
260 _cairo_text_has_changed = true;
261 nux::GetGraphicsThread ()->AddObjectToRefreshList (this);
262@@ -1438,3 +1454,19 @@
263 }
264 }
265
266+// Introspection
267+
268+const gchar* QuicklistView::GetName ()
269+{
270+ return g_strdup (_name);
271+}
272+
273+void QuicklistView::AddProperties (GVariantBuilder *builder)
274+{
275+ g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (GetBaseX ()));
276+ g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (GetBaseY ()));
277+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (GetBaseWidth ()));
278+ g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (GetBaseHeight ()));
279+ g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (IsVisible ()));
280+}
281+
282
283=== modified file 'src/QuicklistView.h'
284--- src/QuicklistView.h 2010-12-01 22:22:43 +0000
285+++ src/QuicklistView.h 2010-12-02 17:09:36 +0000
286@@ -31,6 +31,8 @@
287
288 #include "QuicklistMenuItem.h"
289
290+#include "Introspectable.h"
291+
292 #define ANCHOR_WIDTH 10.0f
293 #define ANCHOR_HEIGHT 18.0f
294 #define HIGH_LIGHT_Y -30.0f
295@@ -50,7 +52,7 @@
296 class QuicklistMenuItem;
297 class QuicklistMenuItemLabel;
298
299-class QuicklistView : public nux::BaseWindow
300+class QuicklistView : public nux::BaseWindow, public Introspectable
301 {
302 NUX_DECLARE_OBJECT_TYPE (QuicklistView, nux::BaseWindow);
303 public:
304@@ -86,6 +88,10 @@
305
306 void TestMenuItems (DbusmenuMenuitem* root);
307
308+ // Introspection
309+ const gchar* GetName ();
310+ void AddProperties (GVariantBuilder *builder);
311+
312 private:
313 void RecvCairoTextChanged (QuicklistMenuItem* item);
314 void RecvCairoTextColorChanged (QuicklistMenuItem* item);
315@@ -153,6 +159,10 @@
316 void UpdateTexture ();
317 std::list<QuicklistMenuItem*> _item_list;
318 std::list<QuicklistMenuItem*> _default_item_list;
319+
320+ // Introspection
321+ gchar *_name;
322+
323 };
324
325 #endif // QUICKLISTVIEW_H
326
327=== modified file 'src/Tooltip.cpp'
328--- src/Tooltip.cpp 2010-11-18 23:00:10 +0000
329+++ src/Tooltip.cpp 2010-12-02 17:09:36 +0000
330@@ -38,6 +38,7 @@
331
332 Tooltip::Tooltip ()
333 {
334+ _name = g_strdup ("Tooltip");
335 _texture_bg = 0;
336 _texture_mask = 0;
337 _texture_outline = 0;
338@@ -83,6 +84,9 @@
339
340 Tooltip::~Tooltip ()
341 {
342+ if (_name)
343+ g_free (_name);
344+
345 if (_texture_bg)
346 _texture_bg->UnReference ();
347
348@@ -915,4 +919,21 @@
349 this->ComputeChildLayout ();
350 }
351
352+ // Introspection
353+
354+ const gchar* Tooltip::GetName ()
355+ {
356+ return g_strdup (_name);
357+ }
358+
359+ void Tooltip::AddProperties (GVariantBuilder *builder)
360+ {
361+ g_variant_builder_add (builder, "{sv}", "text", g_variant_new_string (_labelText.GetTCharPtr ()));
362+ g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (GetBaseX ()));
363+ g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (GetBaseY ()));
364+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (GetBaseWidth ()));
365+ g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (GetBaseHeight ()));
366+ g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (IsVisible ()));
367+ }
368+
369 } // namespace nux
370
371=== modified file 'src/Tooltip.h'
372--- src/Tooltip.h 2010-11-18 23:00:10 +0000
373+++ src/Tooltip.h 2010-12-02 17:09:36 +0000
374@@ -31,6 +31,8 @@
375 #include <pango/pango.h>
376 #include <pango/pangocairo.h>
377
378+#include "Introspectable.h"
379+
380 #if defined(NUX_OS_LINUX)
381 #include <X11/Xlib.h>
382 #endif
383@@ -55,7 +57,7 @@
384 class HLayout;
385 class SpaceLayout;
386
387- class Tooltip : public BaseWindow
388+ class Tooltip : public BaseWindow, public Introspectable
389 {
390 NUX_DECLARE_OBJECT_TYPE (Tooltip, BaseWindow);
391 public:
392@@ -76,6 +78,11 @@
393 void SetText (NString text);
394
395 void ShowTooltipWithTipAt (int anchor_tip_x, int anchor_tip_y);
396+
397+ // Introspection
398+ const gchar* GetName ();
399+ void AddProperties (GVariantBuilder *builder);
400+
401 private:
402 void RecvCairoTextChanged (StaticCairoText* cairo_text);
403
404@@ -119,6 +126,9 @@
405
406 bool _cairo_text_has_changed;
407 void UpdateTexture ();
408+
409+ // Introspection
410+ gchar *_name;
411 };
412 }
413
414
415=== modified file 'tests/CMakeLists.txt'
416--- tests/CMakeLists.txt 2010-12-01 23:14:08 +0000
417+++ tests/CMakeLists.txt 2010-12-02 17:09:36 +0000
418@@ -45,6 +45,7 @@
419 ../src/FavoriteStore.h
420 ../src/FavoriteStoreGSettings.cpp
421 ../src/FavoriteStoreGSettings.h
422+ ../src/Introspectable.cpp
423 ../src/QuicklistMenuItem.cpp
424 ../src/QuicklistMenuItem.h
425 ../src/QuicklistMenuItemCheckmark.cpp