]> Pileus Git - ~andy/gtk/blob - gtk/gtkcssparserprivate.h
colorsel: include gtkcolorutils.h
[~andy/gtk] / gtk / gtkcssparserprivate.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
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 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
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GTK_CSS_PARSER_PRIVATE_H__
21 #define __GTK_CSS_PARSER_PRIVATE_H__
22
23 #include "gtk/gtkcsstypesprivate.h"
24 #include <gtk/gtksymboliccolor.h>
25
26 G_BEGIN_DECLS
27
28 typedef enum /*< skip >*/ {
29   GTK_CSS_POSITIVE_ONLY = (1 << 0),
30   GTK_CSS_PARSE_PERCENT = (1 << 1),
31   GTK_CSS_PARSE_NUMBER = (1 << 2),
32   GTK_CSS_NUMBER_AS_PIXELS = (1 << 3),
33   GTK_CSS_PARSE_LENGTH = (1 << 4),
34   GTK_CSS_PARSE_ANGLE = (1 << 5)
35 } GtkCssNumberParseFlags;
36
37 typedef struct _GtkCssParser GtkCssParser;
38
39 typedef void (* GtkCssParserErrorFunc) (GtkCssParser *parser,
40                                         const GError *error,
41                                         gpointer      user_data);
42
43 GtkCssParser *  _gtk_css_parser_new               (const char            *data,
44                                                    GtkCssParserErrorFunc  error_func,
45                                                    gpointer               user_data);
46 void            _gtk_css_parser_free              (GtkCssParser          *parser);
47
48 void            _gtk_css_parser_take_error        (GtkCssParser          *parser,
49                                                    GError                *error);
50 void            _gtk_css_parser_error             (GtkCssParser          *parser,
51                                                    const char            *format,
52                                                     ...) G_GNUC_PRINTF (2, 3);
53
54 guint           _gtk_css_parser_get_line          (GtkCssParser          *parser);
55 guint           _gtk_css_parser_get_position      (GtkCssParser          *parser);
56
57 gboolean        _gtk_css_parser_is_eof            (GtkCssParser          *parser);
58 gboolean        _gtk_css_parser_begins_with       (GtkCssParser          *parser,
59                                                    char                   c);
60 gboolean        _gtk_css_parser_has_prefix        (GtkCssParser          *parser,
61                                                    const char            *prefix);
62 gboolean        _gtk_css_parser_is_string         (GtkCssParser          *parser);
63
64 /* IMPORTANT:
65  * _try_foo() functions do not modify the data pointer if they fail, nor do they
66  * signal an error. _read_foo() will modify the data pointer and position it at
67  * the first token that is broken and emit an error about the failure.
68  * So only call _read_foo() when you know that you are reading a foo. _try_foo()
69  * however is fine to call if you don't know yet if the token is a foo or a bar,
70  * you can _try_bar() if try_foo() failed.
71  */
72 gboolean        _gtk_css_parser_try               (GtkCssParser          *parser,
73                                                    const char            *string,
74                                                    gboolean               skip_whitespace);
75 char *          _gtk_css_parser_try_ident         (GtkCssParser          *parser,
76                                                    gboolean               skip_whitespace);
77 char *          _gtk_css_parser_try_name          (GtkCssParser          *parser,
78                                                    gboolean               skip_whitespace);
79 gboolean        _gtk_css_parser_try_int           (GtkCssParser          *parser,
80                                                    int                   *value);
81 gboolean        _gtk_css_parser_try_uint          (GtkCssParser          *parser,
82                                                    guint                 *value);
83 gboolean        _gtk_css_parser_try_double        (GtkCssParser          *parser,
84                                                    gdouble               *value);
85 gboolean        _gtk_css_parser_try_length        (GtkCssParser          *parser,
86                                                    int                   *value);
87 gboolean        _gtk_css_parser_try_enum          (GtkCssParser          *parser,
88                                                    GType                  enum_type,
89                                                    int                   *value);
90
91 gboolean        _gtk_css_parser_has_number        (GtkCssParser          *parser);
92 gboolean        _gtk_css_parser_read_number       (GtkCssParser          *parser,
93                                                    GtkCssNumber          *number,
94                                                    GtkCssNumberParseFlags flags);
95 char *          _gtk_css_parser_read_string       (GtkCssParser          *parser);
96 char *          _gtk_css_parser_read_value        (GtkCssParser          *parser);
97 GtkSymbolicColor *_gtk_css_parser_read_symbolic_color
98                                                   (GtkCssParser          *parser);
99 GFile *         _gtk_css_parser_read_url          (GtkCssParser          *parser,
100                                                    GFile                 *base);
101
102 void            _gtk_css_parser_skip_whitespace   (GtkCssParser          *parser);
103 void            _gtk_css_parser_resync            (GtkCssParser          *parser,
104                                                    gboolean               sync_at_semicolon,
105                                                    char                   terminator);
106
107 G_END_DECLS
108
109 #endif /* __GTK_CSS_PARSER_PRIVATE_H__ */