summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-05-08 18:10:23 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-05-08 18:10:23 +0000
commit729715465a726c1bfd8a39b9bd84d7d888d3827a (patch)
tree268ccceaaa6d04978a85ee8c083d93615cec9a86 /gtk
parent8ade92495da0392c8d63e38403bf34ca27d91085 (diff)
downloadgtk+-729715465a726c1bfd8a39b9bd84d7d888d3827a.tar.gz
Elide (_x) in the middle of the string, too. (#323956, Abel Cheung)
2006-05-08 Matthias Clasen <mclasen@redhat.com> * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle of the string, too. (#323956, Abel Cheung)
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktoolbar.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 98535add88..8aa4e5970d 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -4877,38 +4877,40 @@ gchar *
_gtk_toolbar_elide_underscores (const gchar *original)
{
gchar *q, *result;
- const gchar *p;
+ const gchar *p, *end;
+ gsize len;
gboolean last_underscore;
- gint s;
if (!original)
return NULL;
- s = strlen (original);
- q = result = g_malloc (s + 1);
+ len = strlen (original);
+ q = result = g_malloc (len + 1);
last_underscore = FALSE;
- for (p = original; *p; p++)
+ end = original + len;
+ for (p = original; p < end; p++)
{
if (!last_underscore && *p == '_')
last_underscore = TRUE;
else
{
last_underscore = FALSE;
- *q++ = *p;
+ if (*p != '_' && original + 2 <= p && p + 1 <= end && p[-2] == '(' && p[1] == ')')
+ {
+ q--;
+ *q = '\0';
+ p++;
+ }
+ else
+ *q++ = *p;
}
}
+ if (last_underscore)
+ *q++ = '_';
+
*q = '\0';
-
- if (s > 4)
- {
- if (original[s - 4] == '(' &&
- original[s - 3] == '_' &&
- original[s - 1] == ')')
- q[-3] = '\0';
- }
-
return result;
}