]> git.0d.be Git - empathy.git/blob - tp-account-widgets/tpaw-string-parser.h
629fa41145662243e2135b55eaa9cdd8b167ed58
[empathy.git] / tp-account-widgets / tpaw-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 __TPAW_STRING_PARSER_H__
22 #define __TPAW_STRING_PARSER_H__
23
24 #include <glib.h>
25
26 G_BEGIN_DECLS
27
28 typedef struct _TpawStringParser TpawStringParser;
29
30 typedef void (*TpawStringReplace) (const gchar *text,
31                                    gssize len,
32                                    gpointer match_data,
33                                    gpointer user_data);
34 typedef void (*TpawStringMatch) (const gchar *text,
35                                  gssize len,
36                                  TpawStringReplace replace_func,
37                                  TpawStringParser *sub_parsers,
38                                  gpointer user_data);
39
40 struct _TpawStringParser {
41         TpawStringMatch match_func;
42         TpawStringReplace replace_func;
43 };
44
45 void
46 tpaw_string_parser_substr (const gchar *text,
47                            gssize len,
48                            TpawStringParser *parsers,
49                            gpointer user_data);
50
51 void
52 tpaw_string_match_link (const gchar *text,
53                         gssize len,
54                         TpawStringReplace replace_func,
55                         TpawStringParser *sub_parsers,
56                         gpointer user_data);
57
58 void
59 tpaw_string_match_all (const gchar *text,
60                        gssize len,
61                        TpawStringReplace replace_func,
62                        TpawStringParser *sub_parsers,
63                        gpointer user_data);
64
65 /* Replace functions assume user_data is a GString */
66 void
67 tpaw_string_replace_link (const gchar *text,
68                           gssize len,
69                           gpointer match_data,
70                           gpointer user_data);
71
72 void
73 tpaw_string_replace_escaped (const gchar *text,
74                              gssize len,
75                              gpointer match_data,
76                              gpointer user_data);
77
78 /* Returns a new string with <a> html tag around links, and escape the rest.
79  * To be used with gtk_label_set_markup() for example */
80 gchar *
81 tpaw_add_link_markup (const gchar *text);
82
83 G_END_DECLS
84
85 #endif /*  __TPAW_STRING_PARSER_H__ */