aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-06-13 14:28:19 -0500
committerTed Gould <ted@gould.cx>2012-06-13 14:28:19 -0500
commitd1a1d09ea3487669f8622eb4106414eb01d41cfd (patch)
treeb3ad1b8a1a68ff0c57a7be7c763e5377b93eb0e2 /libdbusmenu-gtk
parent4940701cf76bc33c40cb908211b3293ab65d26c5 (diff)
parent6552cd19a5472c47e2cb89a2d597bcc90e36d3bf (diff)
downloadlibdbusmenu-d1a1d09ea3487669f8622eb4106414eb01d41cfd.tar.gz
libdbusmenu-d1a1d09ea3487669f8622eb4106414eb01d41cfd.tar.bz2
libdbusmenu-d1a1d09ea3487669f8622eb4106414eb01d41cfd.zip
Import upstream version 0.6.2
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/genericmenuitem-enum-types.h2
-rw-r--r--libdbusmenu-gtk/genericmenuitem-enum-types.h.in2
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c31
3 files changed, 31 insertions, 4 deletions
diff --git a/libdbusmenu-gtk/genericmenuitem-enum-types.h b/libdbusmenu-gtk/genericmenuitem-enum-types.h
index 3a8c50c..b5d8589 100644
--- a/libdbusmenu-gtk/genericmenuitem-enum-types.h
+++ b/libdbusmenu-gtk/genericmenuitem-enum-types.h
@@ -35,7 +35,7 @@ License version 3 and version 2.1 along with this program. If not, see
G_BEGIN_DECLS
-/* Enumerations from file: "./genericmenuitem.h" */
+/* Enumerations from file: "genericmenuitem.h" */
#include "genericmenuitem.h"
diff --git a/libdbusmenu-gtk/genericmenuitem-enum-types.h.in b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in
index 5758438..afd9132 100644
--- a/libdbusmenu-gtk/genericmenuitem-enum-types.h.in
+++ b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in
@@ -43,7 +43,7 @@ G_END_DECLS
/*** END file-tail ***/
/*** BEGIN file-production ***/
-/* Enumerations from file: "@filename@" */
+/* Enumerations from file: "@basename@" */
#include "@basename@"
/*** END file-production ***/
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index 9effd82..91004c0 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)
@@ -258,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:
@@ -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);
}
}
}