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
1=== modified file 'libdbusmenu-gtk/parser.c'
2--- libdbusmenu-gtk/parser.c 2011-03-09 14:33:41 +0000
3+++ libdbusmenu-gtk/parser.c 2011-03-09 20:06:18 +0000
4@@ -362,6 +362,32 @@
5 }
6 }
7
8+static gchar *
9+sanitize_label (GtkLabel * label)
10+{
11+ gchar * text;
12+
13+ if (gtk_label_get_use_markup (label)) {
14+ text = sanitize_label_text (gtk_label_get_label (label));
15+ }
16+ else {
17+ text = g_strdup (gtk_label_get_label (label));
18+ }
19+
20+ if (!gtk_label_get_use_underline (label)) {
21+ /* Insert extra underscores */
22+ GRegex * regex = g_regex_new ("_", 0, 0, NULL);
23+ gchar * escaped = g_regex_replace_literal (regex, text, -1, 0, "__", 0, NULL);
24+
25+ g_regex_unref (regex);
26+ g_free (text);
27+
28+ text = escaped;
29+ }
30+
31+ return text;
32+}
33+
34 /* Turn a widget into a dbusmenu item depending on the type of GTK
35 object that it is. */
36 static DbusmenuMenuitem *
37@@ -445,7 +471,7 @@
38 {
39 // Sometimes, an app will directly find and modify the label
40 // (like empathy), so watch the label especially for that.
41- gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (label)));
42+ gchar * text = sanitize_label (GTK_LABEL (label));
43 dbusmenu_menuitem_property_set (mi, "label", text);
44 g_free (text);
45
46@@ -690,7 +716,7 @@
47
48 if (pspec->name == g_intern_static_string ("label"))
49 {
50- gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (widget)));
51+ gchar * text = sanitize_label (GTK_LABEL (widget));
52 dbusmenu_menuitem_property_set (child,
53 DBUSMENU_MENUITEM_PROP_LABEL,
54 text);

Subscribers

People subscribed via source and target branches