]> git.sur5r.net Git - glabels/blob - glabels2/src/gnome-recent-util.c
Initial revision
[glabels] / glabels2 / src / gnome-recent-util.c
1 #include <stdio.h>
2 #include <gtk/gtk.h>
3 #include <string.h>
4 #include "gnome-recent-util.h"
5
6 /* ripped out of gedit2 */
7 gchar* 
8 gnome_recent_util_escape_underlines (const gchar* text)
9 {
10         GString *str;
11         gint length;
12         const gchar *p;
13         const gchar *end;
14
15         g_return_val_if_fail (text != NULL, NULL);
16
17         length = strlen (text);
18
19         str = g_string_new ("");
20
21         p = text;
22         end = text + length;
23
24         while (p != end)
25         {
26                 const gchar *next;
27                 next = g_utf8_next_char (p);
28
29                 switch (*p)
30                 {
31                         case '_':
32                                 g_string_append (str, "__");
33                                 break;
34                         default:
35                                 g_string_append_len (str, p, next - p);
36                                 break;
37                 }
38
39                 p = next;
40         }
41
42         return g_string_free (str, FALSE);
43 }