aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog7
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c29
2 files changed, 35 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index b5fcf64..43f5e98 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+libdbusmenu (0.6.1-0ubuntu2) UNRELEASED; urgency=low
+
+ * libdbusmenu-gtk/genericmenuitem.c
+ - Fixed duplicated underscores in menus (LP: #979301)
+
+ -- Ken VanDine <ken.vandine@canonical.com> Thu, 12 Apr 2012 11:56:54 -0400
+
libdbusmenu (0.6.1-0ubuntu1) precise; urgency=low
* New upstream release.
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index 9effd82..81d67fe 100644
--- a/libdbusmenu-gtk/genericmenuitem.c
+++ b/libdbusmenu-gtk/genericmenuitem.c
@@ -241,6 +241,27 @@ has_mnemonic (const gchar * string, gboolean previous_underscore)
return FALSE;
}
+/* Sanitize the label by removing "__" meaning "_" */
+gchar *
+sanitize_label (const gchar * in_label)
+{
+ static GRegex * underscore_regex = NULL;
+
+ g_return_val_if_fail(in_label != NULL, NULL);
+
+ if (underscore_regex == NULL) {
+ underscore_regex = g_regex_new("__", 0, 0, NULL);
+ }
+
+ return g_regex_replace_literal(underscore_regex,
+ in_label,
+ -1, /* length */
+ 0, /* start */
+ "_", /* replacement */
+ 0, /* flags */
+ NULL); /* error */
+}
+
/* Set the label on the item */
static void
set_label (GtkMenuItem * menu_item, const gchar * in_label)
@@ -319,6 +340,10 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label)
gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE);
gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));
gtk_label_set_markup_with_mnemonic(labelw, local_label);
+ } else {
+ gchar * sanitized = sanitize_label(local_label);
+ gtk_label_set_markup(labelw, sanitized);
+ g_free(sanitized);
}
gtk_widget_show(GTK_WIDGET(labelw));
@@ -343,7 +368,9 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label)
gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));
gtk_label_set_markup_with_mnemonic(labelw, local_label);
} else {
- gtk_label_set_markup(labelw, local_label);
+ gchar * sanitized = sanitize_label(local_label);
+ gtk_label_set_markup(labelw, sanitized);
+ g_free(sanitized);
}
}
}