aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
authorAlbert Astals <albert.astals@canonical.com>2012-06-04 15:29:56 +0200
committerAlbert Astals <albert.astals@canonical.com>2012-06-04 15:29:56 +0200
commit9c77e28fb5485650e033a6cfb868785ea8f1dbad (patch)
tree17d51af1a583475a0787f75acd31a5193639e7aa /libdbusmenu-gtk
parent75bdca54d5e6838aece55c84db3fd3249a624dfb (diff)
downloadlibdbusmenu-9c77e28fb5485650e033a6cfb868785ea8f1dbad.tar.gz
libdbusmenu-9c77e28fb5485650e033a6cfb868785ea8f1dbad.tar.bz2
libdbusmenu-9c77e28fb5485650e033a6cfb868785ea8f1dbad.zip
Use g_markup_escape_text instead of manually trying to fix the text
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index ab57e86..ae6d4c0 100644
--- a/libdbusmenu-gtk/genericmenuitem.c
+++ b/libdbusmenu-gtk/genericmenuitem.c
@@ -262,27 +262,6 @@ sanitize_label (const gchar * in_label)
NULL); /* error */
}
-/* Replace '&' with '&amp' in the label */
-static gchar *
-replace_amps (const gchar * in_label)
-{
- static GRegex * amp_regex = NULL;
-
- g_return_val_if_fail(in_label != NULL, NULL);
-
- if (amp_regex == NULL) {
- amp_regex = g_regex_new("&", 0, 0, NULL);
- }
-
- return g_regex_replace_literal(amp_regex,
- in_label,
- -1, /* length */
- 0, /* start */
- "&amp;", /* replacement */
- 0, /* flags */
- NULL); /* error */
-}
-
/* Set the label on the item */
static void
set_label (GtkMenuItem * menu_item, const gchar * in_label)
@@ -300,7 +279,7 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label)
gchar * local_label = NULL;
switch (GENERICMENUITEM(menu_item)->priv->disposition) {
case GENERICMENUITEM_DISPOSITION_NORMAL:
- local_label = g_strdup(in_label);
+ local_label = g_markup_escape_text(in_label, -1);
break;
case GENERICMENUITEM_DISPOSITION_INFORMATIONAL:
case GENERICMENUITEM_DISPOSITION_WARNING:
@@ -359,15 +338,11 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label)
gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));
if (has_mnemonic(in_label, FALSE)) {
- gchar * amp_replaced = replace_amps (local_label);
gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE);
- gtk_label_set_markup_with_mnemonic(labelw, amp_replaced);
- g_free(amp_replaced);
+ gtk_label_set_markup_with_mnemonic(labelw, local_label);
} else {
gchar * sanitized = sanitize_label(local_label);
- gchar * amp_replaced = replace_amps (sanitized);
- gtk_label_set_markup(labelw, amp_replaced);
- g_free(amp_replaced);
+ gtk_label_set_markup(labelw, sanitized);
g_free(sanitized);
}