]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-string-parser.h
GNOME Goal: Update icon names
[empathy.git] / libempathy-gtk / empathy-string-parser.h
1 /*
2  * Copyright (C) 2010 Collabora Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Xavier Claessens <xclaesse@gmail.com>
19  */
20
21 #ifndef __EMPATHY_STRING_PARSER_H__
22 #define __EMPATHY_STRING_PARSER_H__
23
24 #include <glib.h>
25
26 G_BEGIN_DECLS
27
28 typedef struct _EmpathyStringParser EmpathyStringParser;
29
30 typedef void (*EmpathyStringReplace) (const gchar *text,
31                                       gssize len,
32                                       gpointer match_data,
33                                       gpointer user_data);
34 typedef void (*EmpathyStringMatch) (const gchar *text,
35                                     gssize len,
36                                     EmpathyStringReplace replace_func,
37                                     EmpathyStringParser *sub_parsers,
38                                     gpointer user_data);
39
40 struct _EmpathyStringParser {
41         EmpathyStringMatch match_func;
42         EmpathyStringReplace replace_func;
43 };
44
45 void
46 empathy_string_parser_substr (const gchar *text,
47                               gssize len,
48                               EmpathyStringParser *parsers,
49                               gpointer user_data);
50
51 void
52 empathy_string_match_link (const gchar *text,
53                            gssize len,
54                            EmpathyStringReplace replace_func,
55                            EmpathyStringParser *sub_parsers,
56                            gpointer user_data);
57
58 void
59 empathy_string_match_smiley (const gchar *text,
60                              gssize len,
61                              EmpathyStringReplace replace_func,
62                              EmpathyStringParser *sub_parsers,
63                              gpointer user_data);
64
65 void
66 empathy_string_match_all (const gchar *text,
67                           gssize len,
68                           EmpathyStringReplace replace_func,
69                           EmpathyStringParser *sub_parsers,
70                           gpointer user_data);
71
72 /* Replace functions assume user_data is a GString */
73 void
74 empathy_string_replace_link (const gchar *text,
75                              gssize len,
76                              gpointer match_data,
77                              gpointer user_data);
78
79 void
80 empathy_string_replace_escaped (const gchar *text,
81                                 gssize len,
82                                 gpointer match_data,
83                                 gpointer user_data);
84
85 /* Returns a new string with <a> html tag around links, and escape the rest.
86  * To be used with gtk_label_set_markup() for example */
87 gchar *
88 empathy_add_link_markup (const gchar *text);
89
90 G_END_DECLS
91
92 #endif /*  __EMPATHY_STRING_PARSER_H__ */