Merge lp:~mterry/libdbusmenu/respect-use-underline into lp:libdbusmenu/0.5

Proposed by Michael Terry
Status: Merged
Approved by: Ted Gould
Approved revision: 261
Merged at revision: 262
Proposed branch: lp:~mterry/libdbusmenu/respect-use-underline
Merge into: lp:libdbusmenu/0.5
Diff against target: 54 lines (+28/-2)
1 file modified
libdbusmenu-gtk/parser.c (+28/-2)
To merge this branch: bzr merge lp:~mterry/libdbusmenu/respect-use-underline
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+52752@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

  review approve
  merge approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libdbusmenu-gtk/parser.c'
--- libdbusmenu-gtk/parser.c 2011-03-09 14:33:41 +0000
+++ libdbusmenu-gtk/parser.c 2011-03-09 20:06:18 +0000
@@ -362,6 +362,32 @@
362 }362 }
363}363}
364364
365static gchar *
366sanitize_label (GtkLabel * label)
367{
368 gchar * text;
369
370 if (gtk_label_get_use_markup (label)) {
371 text = sanitize_label_text (gtk_label_get_label (label));
372 }
373 else {
374 text = g_strdup (gtk_label_get_label (label));
375 }
376
377 if (!gtk_label_get_use_underline (label)) {
378 /* Insert extra underscores */
379 GRegex * regex = g_regex_new ("_", 0, 0, NULL);
380 gchar * escaped = g_regex_replace_literal (regex, text, -1, 0, "__", 0, NULL);
381
382 g_regex_unref (regex);
383 g_free (text);
384
385 text = escaped;
386 }
387
388 return text;
389}
390
365/* Turn a widget into a dbusmenu item depending on the type of GTK391/* Turn a widget into a dbusmenu item depending on the type of GTK
366 object that it is. */392 object that it is. */
367static DbusmenuMenuitem *393static DbusmenuMenuitem *
@@ -445,7 +471,7 @@
445 {471 {
446 // Sometimes, an app will directly find and modify the label472 // Sometimes, an app will directly find and modify the label
447 // (like empathy), so watch the label especially for that.473 // (like empathy), so watch the label especially for that.
448 gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (label)));474 gchar * text = sanitize_label (GTK_LABEL (label));
449 dbusmenu_menuitem_property_set (mi, "label", text);475 dbusmenu_menuitem_property_set (mi, "label", text);
450 g_free (text);476 g_free (text);
451477
@@ -690,7 +716,7 @@
690716
691 if (pspec->name == g_intern_static_string ("label"))717 if (pspec->name == g_intern_static_string ("label"))
692 {718 {
693 gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (widget)));719 gchar * text = sanitize_label (GTK_LABEL (widget));
694 dbusmenu_menuitem_property_set (child,720 dbusmenu_menuitem_property_set (child,
695 DBUSMENU_MENUITEM_PROP_LABEL,721 DBUSMENU_MENUITEM_PROP_LABEL,
696 text);722 text);

Subscribers

People subscribed via source and target branches