-- cgit v1.2.3 From 4b1d462aeb7ba623b007799daab4f2dfd5f6f540 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Apr 2012 16:25:22 -0500 Subject: Provide a function to sanitize the label and use that as Pango isn't doing it for us now --- libdbusmenu-gtk/genericmenuitem.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 9effd82..bff4ee5 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; } +static GRegex * underscore_regex = NULL; + +/* Sanitize the label by removing "__" meaning "_" */ +gchar * +sanitize_label (const gchar * in_label) +{ + 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); } } } -- cgit v1.2.3 From 9dd4e51920a5adccafbc2091d6e29391ab0c3bb5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Apr 2012 16:26:12 -0500 Subject: No reason to bother with that in the global namespace --- libdbusmenu-gtk/genericmenuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index bff4ee5..81d67fe 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -241,12 +241,12 @@ has_mnemonic (const gchar * string, gboolean previous_underscore) return FALSE; } -static GRegex * underscore_regex = NULL; - /* 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) { -- cgit v1.2.3 From d77f364df4d13f1d9cac8cf3bb7a04c68351da9d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Jun 2012 10:48:01 -0500 Subject: Making the headers match independent of build directory --- libdbusmenu-glib/enum-types.h.in | 2 +- libdbusmenu-gtk/genericmenuitem-enum-types.h.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in index 5758438..afd9132 100644 --- a/libdbusmenu-glib/enum-types.h.in +++ b/libdbusmenu-glib/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-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 ***/ -- cgit v1.2.3 From 6dd001a7708575f123797dae492891c1af35a308 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Jun 2012 10:55:34 -0500 Subject: Escape the text we are using for markup --- libdbusmenu-gtk/genericmenuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 81d67fe..91004c0 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -279,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: -- cgit v1.2.3 From 6552cd19a5472c47e2cb89a2d597bcc90e36d3bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 Jun 2012 14:12:03 -0500 Subject: 0.6.2 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 94bba0c..cd35002 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.6.1, ted@canonical.com) +AC_INIT(libdbusmenu, 0.6.2, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.6.1, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.6.2, [-Wno-portability]) AM_MAINTAINER_MODE @@ -166,7 +166,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=4 -LIBDBUSMENU_REVISION=12 +LIBDBUSMENU_REVISION=13 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3