Merge lp:~3v1n0/unity/quicklist-markup-support into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 1773
Proposed branch: lp:~3v1n0/unity/quicklist-markup-support
Merge into: lp:unity
Diff against target: 595 lines (+166/-151)
12 files modified
plugins/unityshell/src/BFBLauncherIcon.cpp (+2/-4)
plugins/unityshell/src/BamfLauncherIcon.cpp (+8/-4)
plugins/unityshell/src/LauncherIcon.cpp (+8/-8)
plugins/unityshell/src/QuicklistMenuItem.cpp (+103/-38)
plugins/unityshell/src/QuicklistMenuItem.h (+7/-3)
plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp (+9/-30)
plugins/unityshell/src/QuicklistMenuItemCheckmark.h (+1/-1)
plugins/unityshell/src/QuicklistMenuItemLabel.cpp (+9/-30)
plugins/unityshell/src/QuicklistMenuItemLabel.h (+1/-1)
plugins/unityshell/src/QuicklistMenuItemRadio.cpp (+9/-31)
plugins/unityshell/src/QuicklistMenuItemRadio.h (+1/-1)
tests/unit/TestQuicklistMenuitems.cpp (+8/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/quicklist-markup-support
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Tim Penhey (community) Approve
Review via email: mp+84695@code.launchpad.net

Commit message

QuicklistMenuItem code cleanup and support for markup text and bold application titles.

Description of the change

In order to fix the bug #899677, as the quicklist uses the pango markup to draw its label, I made the quicklist to always escape the label text by default.
Actually this could have been done also making pango to just draw text, but since the design team asked me to still support the "_" (underscore) to show menu-items accelerators, I had to use this way.

Also, now a quicklist item can use markup only if the related dbusmenuitem has a "unity-use-markup" property that can be set only internally (i.e. it doesn't work if used through libunity) and that currently we only use to make every application name bold (to fix bug #900400).

I've also made a code cleanup of the QuicklistMenuItem* to reduce the code duplication, however I've not changed too much the types used not to change too much what has been already done.

Some basic tests have also been added.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

OK, lets make:

  gchar* app_name;
  gchar* tmp;
  tmp = g_markup_escape_text(BamfName(), -1);
  app_name = g_strdup_printf("<b>%s</b>", tmp);
  g_free(tmp);

less C and more C++ :)

#include <sstream>

  glib::String app_name(g_markup_escape_text(BamfName(), -1));
  std::ostringstream sout;
  sout << "<b>" << app_name << "</b>";

  // use sout.str().c_str(); to get a const char*

No need for g_free(app_name).

Why did you remove the texture unreferencing?

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> less C and more C++ :)
Ok, done!

> Why did you remove the texture unreferencing?

Since the textures are controlled by QuicklistMenuItem I just moved the unreferencing thing from each ~QuicklistMenuItem* to ~QuicklistMenuItem to avoid code duplication.

Revision history for this message
Tim Penhey (thumper) wrote :

OK. I'd still like Mirco to look at this though :-)

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Agree.

Revision history for this message
Mirco Müller (macslow) wrote :

Looks fine, works as expected, tests pass... good to go!

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/BFBLauncherIcon.cpp'
2--- plugins/unityshell/src/BFBLauncherIcon.cpp 2011-12-06 16:27:58 +0000
3+++ plugins/unityshell/src/BFBLauncherIcon.cpp 2011-12-09 14:48:26 +0000
4@@ -72,7 +72,7 @@
5 ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, g_variant_new("(sus)", lens, dash::GOTO_DASH_URI, ""));
6 g_free(lens);
7 }
8-}
9+}
10
11 std::list<DbusmenuMenuitem*> BFBLauncherIcon::GetMenus()
12 {
13@@ -99,11 +99,9 @@
14 if (!lens->visible())
15 continue;
16
17- glib::String name(g_markup_escape_text(lens->name().c_str(), -1));
18-
19 menu_item = dbusmenu_menuitem_new();
20
21- dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, name.Value());
22+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, lens->name().c_str());
23 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
24 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
25
26
27=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
28--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-10-25 17:00:12 +0000
29+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-12-09 14:48:26 +0000
30@@ -1003,6 +1003,7 @@
31 if (dbusmenu_menuitem_property_get_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE))
32 {
33 first_separator_needed = true;
34+ dbusmenu_menuitem_property_set_bool(item, "unity-use-markup", FALSE);
35
36 result.push_back(item);
37 }
38@@ -1053,18 +1054,21 @@
39 }
40 else
41 {
42- gchar* app_name;
43- app_name = g_markup_escape_text(BamfName(), -1);
44+ glib::String app_name(g_markup_escape_text(BamfName(), -1));
45+ std::ostringstream bold_app_name;
46+ bold_app_name << "<b>" << app_name << "</b>";
47
48 item = dbusmenu_menuitem_new();
49 dbusmenu_menuitem_property_set(item,
50 DBUSMENU_MENUITEM_PROP_LABEL,
51- app_name);
52+ bold_app_name.str().c_str());
53 dbusmenu_menuitem_property_set_bool(item,
54 DBUSMENU_MENUITEM_PROP_ENABLED,
55 true);
56+ dbusmenu_menuitem_property_set_bool(item,
57+ "unity-use-markup",
58+ true);
59 g_signal_connect(item, "item-activated", (GCallback) OnAppLabelActivated, this);
60- g_free(app_name);
61
62 _menu_items_extra["AppName"] = item;
63 }
64
65=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
66--- plugins/unityshell/src/LauncherIcon.cpp 2011-12-08 03:52:32 +0000
67+++ plugins/unityshell/src/LauncherIcon.cpp 2011-12-09 14:48:26 +0000
68@@ -549,6 +549,8 @@
69
70 for (auto menu_item : menus)
71 {
72+ QuicklistMenuItem* ql_item;
73+
74 const gchar* type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TYPE);
75 const gchar* toggle_type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
76 gboolean prop_visible = dbusmenu_menuitem_property_get_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE);
77@@ -559,24 +561,22 @@
78
79 if (g_strcmp0(type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
80 {
81- QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator(menu_item, NUX_TRACKER_LOCATION);
82- _quicklist->AddMenuItem(item);
83+ ql_item = new QuicklistMenuItemSeparator(menu_item, NUX_TRACKER_LOCATION);
84 }
85 else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
86 {
87- QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark(menu_item, NUX_TRACKER_LOCATION);
88- _quicklist->AddMenuItem(item);
89+ ql_item = new QuicklistMenuItemCheckmark(menu_item, NUX_TRACKER_LOCATION);
90 }
91 else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
92 {
93- QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio(menu_item, NUX_TRACKER_LOCATION);
94- _quicklist->AddMenuItem(item);
95+ ql_item = new QuicklistMenuItemRadio(menu_item, NUX_TRACKER_LOCATION);
96 }
97 else //(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
98 {
99- QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel(menu_item, NUX_TRACKER_LOCATION);
100- _quicklist->AddMenuItem(item);
101+ ql_item = new QuicklistMenuItemLabel(menu_item, NUX_TRACKER_LOCATION);
102 }
103+
104+ _quicklist->AddMenuItem(ql_item);
105 }
106
107 if (default_to_first_item)
108
109=== modified file 'plugins/unityshell/src/QuicklistMenuItem.cpp'
110--- plugins/unityshell/src/QuicklistMenuItem.cpp 2011-11-07 19:21:52 +0000
111+++ plugins/unityshell/src/QuicklistMenuItem.cpp 2011-12-09 14:48:26 +0000
112@@ -48,39 +48,7 @@
113 g_warning("Invalid DbusmenuMenuitem in file %s at line %s.", G_STRFUNC, G_STRLOC);
114 }
115
116- _name = 0;
117- _text = 0;
118- _color = nux::Color(1.0f, 1.0f, 1.0f, 1.0f);
119- _menuItem = item;
120- _debug = false;
121- _item_type = MENUITEM_TYPE_UNKNOWN;
122-
123- _normalTexture[0] = NULL;
124- _normalTexture[1] = NULL;
125- _prelightTexture[0] = NULL;
126- _prelightTexture[1] = NULL;
127-
128- if (_menuItem)
129- {
130- g_signal_connect(_menuItem,
131- "property-changed",
132- G_CALLBACK(OnPropertyChanged),
133- this);
134- g_signal_connect(_menuItem,
135- "item-activated",
136- G_CALLBACK(OnItemActivated),
137- this);
138- }
139-
140- mouse_down.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseDown));
141- mouse_up.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseUp));
142- mouse_click.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseClick));
143- mouse_move.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseMove));
144- mouse_drag.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseDrag));
145- mouse_enter.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseEnter));
146- mouse_leave.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseLeave));
147-
148- _prelight = false;
149+ Initialize(item, false);
150 }
151
152 QuicklistMenuItem::QuicklistMenuItem(DbusmenuMenuitem* item,
153@@ -88,11 +56,18 @@
154 NUX_FILE_LINE_DECL) :
155 View(NUX_FILE_LINE_PARAM)
156 {
157- _text = 0;
158- _color = nux::Color(1.0f, 1.0f, 1.0f, 1.0f);
159- _menuItem = item;
160- _debug = debug;
161- _item_type = MENUITEM_TYPE_UNKNOWN;
162+ Initialize(item, debug);
163+}
164+
165+void
166+QuicklistMenuItem::Initialize(DbusmenuMenuitem* item, bool debug)
167+{
168+ _name = 0;
169+ _text = 0;
170+ _color = nux::Color(1.0f, 1.0f, 1.0f, 1.0f);
171+ _menuItem = DBUSMENU_MENUITEM(g_object_ref(item));
172+ _debug = debug;
173+ _item_type = MENUITEM_TYPE_UNKNOWN;
174
175 _normalTexture[0] = NULL;
176 _normalTexture[1] = NULL;
177@@ -129,6 +104,42 @@
178
179 if (_text)
180 g_free(_text);
181+
182+ if (_normalTexture[0])
183+ _normalTexture[0]->UnReference();
184+
185+ if (_normalTexture[1])
186+ _normalTexture[1]->UnReference();
187+
188+ if (_prelightTexture[0])
189+ _prelightTexture[0]->UnReference();
190+
191+ if (_prelightTexture[1])
192+ _prelightTexture[1]->UnReference();
193+
194+ if (_menuItem)
195+ g_object_unref(_menuItem);
196+}
197+
198+const gchar*
199+QuicklistMenuItem::GetDefaultText()
200+{
201+ return NULL;
202+}
203+
204+void
205+QuicklistMenuItem::InitializeText()
206+{
207+ if (_menuItem)
208+ _text = GetText();
209+ else
210+ _text = g_strdup(GetDefaultText());
211+
212+ int textWidth = 1;
213+ int textHeight = 1;
214+ GetTextExtents(textWidth, textHeight);
215+ SetMinimumSize(textWidth + ITEM_INDENT_ABS + 3 * ITEM_MARGIN,
216+ textHeight + 2 * ITEM_MARGIN);
217 }
218
219 QuicklistMenuItemType QuicklistMenuItem::GetItemType()
220@@ -212,6 +223,31 @@
221 std::cout << "ItemActivated() called" << std::endl;
222 }
223
224+gchar* QuicklistMenuItem::GetText()
225+{
226+ const gchar *label;
227+ gchar *text;
228+
229+ if (!_menuItem)
230+ return NULL;
231+
232+ label = GetLabel();
233+
234+ if (!label)
235+ return NULL;
236+
237+ if (!IsMarkupEnabled())
238+ {
239+ text = g_markup_escape_text(label, -1);
240+ }
241+ else
242+ {
243+ text = g_strdup(label);
244+ }
245+
246+ return text;
247+}
248+
249 void QuicklistMenuItem::GetTextExtents(int& width, int& height)
250 {
251 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
252@@ -395,6 +431,35 @@
253 g_object_unref(layout);
254 }
255
256+void
257+QuicklistMenuItem::EnableLabelMarkup(bool enabled)
258+{
259+ if (IsMarkupEnabled() != enabled)
260+ {
261+ dbusmenu_menuitem_property_set_bool(_menuItem, "unity-use-markup", enabled);
262+
263+ if (_text)
264+ {
265+ g_free(_text);
266+ _text = NULL;
267+ }
268+
269+ InitializeText();
270+ }
271+}
272+
273+bool
274+QuicklistMenuItem::IsMarkupEnabled()
275+{
276+ gboolean markup;
277+
278+ if (!_menuItem)
279+ return false;
280+
281+ markup = dbusmenu_menuitem_property_get_bool(_menuItem, "unity-use-markup");
282+ return (markup != FALSE);
283+}
284+
285 // Introspection
286
287 const gchar* QuicklistMenuItem::GetName()
288
289=== modified file 'plugins/unityshell/src/QuicklistMenuItem.h'
290--- plugins/unityshell/src/QuicklistMenuItem.h 2011-11-28 21:27:17 +0000
291+++ plugins/unityshell/src/QuicklistMenuItem.h 2011-12-09 14:48:26 +0000
292@@ -75,17 +75,16 @@
293 QuicklistMenuItemType GetItemType();
294
295 void ItemActivated();
296+ void EnableLabelMarkup(bool enabled);
297+ bool IsMarkupEnabled();
298
299 sigc::signal<void, QuicklistMenuItem&> sigChanged;
300 sigc::signal<void, QuicklistMenuItem*> sigTextChanged;
301 sigc::signal<void, QuicklistMenuItem*> sigColorChanged;
302
303 virtual const gchar* GetLabel();
304-
305 virtual bool GetEnabled();
306-
307 virtual bool GetActive();
308-
309 virtual bool GetVisible();
310
311 // Introspection
312@@ -102,6 +101,11 @@
313 nux::BaseTexture* _normalTexture[2];
314 nux::BaseTexture* _prelightTexture[2];
315
316+ void Initialize(DbusmenuMenuitem* item, bool debug);
317+ void InitializeText();
318+ virtual const gchar* GetDefaultText();
319+
320+ gchar* GetText();
321 //! Return the size of the text + size of associated radio button or check box
322 void GetTextExtents(int& width, int& height);
323 void GetTextExtents(const gchar* font, int& width, int& height);
324
325=== modified file 'plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp'
326--- plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp 2011-10-11 18:18:13 +0000
327+++ plugins/unityshell/src/QuicklistMenuItemCheckmark.cpp 2011-12-09 14:48:26 +0000
328@@ -44,8 +44,9 @@
329 QuicklistMenuItem(item,
330 NUX_FILE_LINE_PARAM)
331 {
332+ _item_type = MENUITEM_TYPE_CHECK;
333 _name = g_strdup("QuicklistMenuItemCheckmark");
334- Initialize(item);
335+ InitializeText();
336 }
337
338 QuicklistMenuItemCheckmark::QuicklistMenuItemCheckmark(DbusmenuMenuitem* item,
339@@ -55,40 +56,18 @@
340 debug,
341 NUX_FILE_LINE_PARAM)
342 {
343+ _item_type = MENUITEM_TYPE_CHECK;
344 _name = g_strdup("QuicklistMenuItemCheckmark");
345- Initialize(item);
346-}
347-
348-void
349-QuicklistMenuItemCheckmark::Initialize(DbusmenuMenuitem* item)
350-{
351- _item_type = MENUITEM_TYPE_CHECK;
352-
353- if (item)
354- _text = g_strdup(dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_LABEL));
355- else
356- _text = g_strdup("Check Mark");
357-
358- int textWidth = 1;
359- int textHeight = 1;
360- GetTextExtents(textWidth, textHeight);
361- SetMinimumSize(textWidth + ITEM_INDENT_ABS + 3 * ITEM_MARGIN,
362- textHeight + 2 * ITEM_MARGIN);
363+ InitializeText();
364 }
365
366 QuicklistMenuItemCheckmark::~QuicklistMenuItemCheckmark()
367+{}
368+
369+const gchar*
370+QuicklistMenuItemCheckmark::GetDefaultText()
371 {
372- if (_normalTexture[0])
373- _normalTexture[0]->UnReference();
374-
375- if (_normalTexture[1])
376- _normalTexture[1]->UnReference();
377-
378- if (_prelightTexture[0])
379- _prelightTexture[0]->UnReference();
380-
381- if (_prelightTexture[1])
382- _prelightTexture[1]->UnReference();
383+ return "Check Mark";
384 }
385
386 void
387
388=== modified file 'plugins/unityshell/src/QuicklistMenuItemCheckmark.h'
389--- plugins/unityshell/src/QuicklistMenuItemCheckmark.h 2011-10-11 18:18:13 +0000
390+++ plugins/unityshell/src/QuicklistMenuItemCheckmark.h 2011-12-09 14:48:26 +0000
391@@ -53,7 +53,7 @@
392
393 void PostDraw(nux::GraphicsEngine& gfxContext, bool forceDraw);
394
395- void Initialize(DbusmenuMenuitem* item);
396+ virtual const gchar* GetDefaultText();
397
398 virtual void UpdateTexture();
399 virtual int CairoSurfaceWidth();
400
401=== modified file 'plugins/unityshell/src/QuicklistMenuItemLabel.cpp'
402--- plugins/unityshell/src/QuicklistMenuItemLabel.cpp 2011-10-11 18:18:13 +0000
403+++ plugins/unityshell/src/QuicklistMenuItemLabel.cpp 2011-12-09 14:48:26 +0000
404@@ -33,8 +33,9 @@
405 QuicklistMenuItem(item,
406 NUX_FILE_LINE_PARAM)
407 {
408+ _item_type = MENUITEM_TYPE_LABEL;
409 _name = g_strdup("QuicklistMenuItemLabel");
410- Initialize(item);
411+ InitializeText();
412 }
413
414 QuicklistMenuItemLabel::QuicklistMenuItemLabel(DbusmenuMenuitem* item,
415@@ -44,40 +45,18 @@
416 debug,
417 NUX_FILE_LINE_PARAM)
418 {
419+ _item_type = MENUITEM_TYPE_LABEL;
420 _name = g_strdup("QuicklistMenuItemLabel");
421- Initialize(item);
422-}
423-
424-void
425-QuicklistMenuItemLabel::Initialize(DbusmenuMenuitem* item)
426-{
427- _item_type = MENUITEM_TYPE_LABEL;
428-
429- if (item)
430- _text = g_strdup(dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_LABEL));
431- else
432- _text = g_strdup("Label");
433-
434- int textWidth = 1;
435- int textHeight = 1;
436- GetTextExtents(textWidth, textHeight);
437- SetMinimumSize(textWidth + ITEM_INDENT_ABS + 3 * ITEM_MARGIN,
438- textHeight + 2 * ITEM_MARGIN);
439+ InitializeText();
440 }
441
442 QuicklistMenuItemLabel::~QuicklistMenuItemLabel()
443+{}
444+
445+const gchar*
446+QuicklistMenuItemLabel::GetDefaultText()
447 {
448- if (_normalTexture[0])
449- _normalTexture[0]->UnReference();
450-
451- if (_normalTexture[1])
452- _normalTexture[1]->UnReference();
453-
454- if (_prelightTexture[0])
455- _prelightTexture[0]->UnReference();
456-
457- if (_prelightTexture[1])
458- _prelightTexture[1]->UnReference();
459+ return "Label";
460 }
461
462 void
463
464=== modified file 'plugins/unityshell/src/QuicklistMenuItemLabel.h'
465--- plugins/unityshell/src/QuicklistMenuItemLabel.h 2011-10-11 18:18:13 +0000
466+++ plugins/unityshell/src/QuicklistMenuItemLabel.h 2011-12-09 14:48:26 +0000
467@@ -53,7 +53,7 @@
468
469 void PostDraw(nux::GraphicsEngine& gfxContext, bool forceDraw);
470
471- void Initialize(DbusmenuMenuitem* item);
472+ virtual const gchar* GetDefaultText();
473
474 virtual void UpdateTexture();
475 virtual int CairoSurfaceWidth();
476
477=== modified file 'plugins/unityshell/src/QuicklistMenuItemRadio.cpp'
478--- plugins/unityshell/src/QuicklistMenuItemRadio.cpp 2011-10-11 18:18:13 +0000
479+++ plugins/unityshell/src/QuicklistMenuItemRadio.cpp 2011-12-09 14:48:26 +0000
480@@ -43,8 +43,9 @@
481 QuicklistMenuItem(item,
482 NUX_FILE_LINE_PARAM)
483 {
484+ _item_type = MENUITEM_TYPE_RADIO;
485 _name = g_strdup("QuicklistMenuItemRadio");
486- Initialize(item);
487+ InitializeText();
488 }
489
490 QuicklistMenuItemRadio::QuicklistMenuItemRadio(DbusmenuMenuitem* item,
491@@ -54,41 +55,18 @@
492 debug,
493 NUX_FILE_LINE_PARAM)
494 {
495+ _item_type = MENUITEM_TYPE_RADIO;
496 _name = g_strdup("QuicklistMenuItemRadio");
497- Initialize(item);
498-}
499-
500-void
501-QuicklistMenuItemRadio::Initialize(DbusmenuMenuitem* item)
502-{
503- _item_type = MENUITEM_TYPE_LABEL;
504-
505- if (item)
506- _text = g_strdup(dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_LABEL));
507- else
508- _text = g_strdup("Radio Button");
509-
510- int textWidth = 1;
511- int textHeight = 1;
512- GetTextExtents(textWidth, textHeight);
513- SetMinimumSize(textWidth + ITEM_INDENT_ABS + 3 * ITEM_MARGIN,
514- textHeight + 2 * ITEM_MARGIN);
515-
516+ InitializeText();
517 }
518
519 QuicklistMenuItemRadio::~QuicklistMenuItemRadio()
520+{}
521+
522+const gchar*
523+QuicklistMenuItemRadio::GetDefaultText()
524 {
525- if (_normalTexture[0])
526- _normalTexture[0]->UnReference();
527-
528- if (_normalTexture[1])
529- _normalTexture[1]->UnReference();
530-
531- if (_prelightTexture[0])
532- _prelightTexture[0]->UnReference();
533-
534- if (_prelightTexture[1])
535- _prelightTexture[1]->UnReference();
536+ return "Radio Button";
537 }
538
539 void
540
541=== modified file 'plugins/unityshell/src/QuicklistMenuItemRadio.h'
542--- plugins/unityshell/src/QuicklistMenuItemRadio.h 2011-10-11 18:18:13 +0000
543+++ plugins/unityshell/src/QuicklistMenuItemRadio.h 2011-12-09 14:48:26 +0000
544@@ -54,7 +54,7 @@
545 void PostDraw(nux::GraphicsEngine& gfxContext,
546 bool forceDraw);
547
548- void Initialize(DbusmenuMenuitem* item);
549+ virtual const gchar* GetDefaultText();
550
551 virtual void UpdateTexture();
552 virtual int CairoSurfaceWidth();
553
554=== modified file 'tests/unit/TestQuicklistMenuitems.cpp'
555--- tests/unit/TestQuicklistMenuitems.cpp 2011-07-21 14:59:25 +0000
556+++ tests/unit/TestQuicklistMenuitems.cpp 2011-12-09 14:48:26 +0000
557@@ -87,6 +87,7 @@
558 g_assert_cmpstr(qlCheckmarkItem->GetLabel(), == , "Unchecked");
559 g_assert_cmpint(qlCheckmarkItem->GetEnabled(), == , false);
560 g_assert_cmpint(qlCheckmarkItem->GetActive(), == , false);
561+ g_assert_cmpint(qlCheckmarkItem->IsMarkupEnabled(), == , false);
562
563 //qlCheckmarkItem->sigChanged.connect (sigc::mem_fun (pointerToCallerClass,
564 // &CallerClass::RecvChanged));
565@@ -111,12 +112,17 @@
566 DBUSMENU_MENUITEM_PROP_ENABLED,
567 true);
568
569+ dbusmenu_menuitem_property_set_bool(item,
570+ "unity-use-markup",
571+ true);
572+
573 QuicklistMenuItemLabel* qlLabelItem = NULL;
574
575 qlLabelItem = new QuicklistMenuItemLabel(item, true);
576
577 g_assert_cmpstr(qlLabelItem->GetLabel(), == , "A Label");
578 g_assert_cmpint(qlLabelItem->GetEnabled(), == , true);
579+ g_assert_cmpint(qlLabelItem->IsMarkupEnabled(), == , true);
580
581 //qlLabelItem->sigChanged.connect (sigc::mem_fun (pointerToCallerClass,
582 // &CallerClass::RecvChanged));
583@@ -151,10 +157,12 @@
584 QuicklistMenuItemRadio* qlRadioItem = NULL;
585
586 qlRadioItem = new QuicklistMenuItemRadio(item, true);
587+ qlRadioItem->EnableLabelMarkup(true);
588
589 g_assert_cmpstr(qlRadioItem->GetLabel(), == , "Radio Active");
590 g_assert_cmpint(qlRadioItem->GetEnabled(), == , true);
591 g_assert_cmpint(qlRadioItem->GetActive(), == , true);
592+ g_assert_cmpint(qlRadioItem->IsMarkupEnabled(), == , true);
593
594 //qlRadioItem->sigChanged.connect (sigc::mem_fun (pointerToCallerClass,
595 // &CallerClass::RecvChanged));