]> Pileus Git - ~andy/gtk/blob - gtk/gtksettings.h
463c5d226fbad6c025445352940c90bd9d785b44
[~andy/gtk] / gtk / gtksettings.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 Red Hat, Inc.
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 Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 #ifndef __GTK_SETTINGS_H__
19 #define __GTK_SETTINGS_H__
20
21 #include        <gtk/gtkrc.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27
28 /* -- type macros --- */
29 #define GTK_TYPE_SETTINGS            (gtk_settings_get_type ())
30 #define GTK_SETTINGS(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_SETTINGS, GtkSettings))
31 #define GTK_SETTINGS_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_SETTINGS, GtkSettingsClass))
32 #define GTK_IS_SETTINGS(obj)         (GTK_CHECK_TYPE ((obj), GTK_TYPE_SETTINGS))
33 #define GTK_IS_SETTINGS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SETTINGS))
34 #define GTK_SETTINGS_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_SETTINGS, GtkSettingsClass))
35
36
37 /* --- typedefs --- */
38 typedef struct    _GtkSettingsClass GtkSettingsClass;
39 typedef struct    _GtkSettingsValue GtkSettingsValue;
40
41
42 /* --- structures --- */
43 struct _GtkSettings
44 {
45   GObject parent_instance;
46
47   GData  *queued_settings;      /* of type GtkSettingsValue* */
48   GValue *property_values;
49
50   GtkRcContext *rc_context;
51 };
52 struct _GtkSettingsClass
53 {
54   GObjectClass parent_class;
55   
56 };
57 struct _GtkSettingsValue
58 {
59   /* origin should be something like "filename:linenumber" for rc files,
60    * or e.g. "XProperty" for other sources
61    */
62   gchar *origin;
63
64   /* valid types are LONG, DOUBLE and STRING corresponding to the token parsed,
65    * or a GSTRING holding an unparsed statement
66    */
67   GValue value;
68 };
69
70
71 /* --- functions --- */
72 GType           gtk_settings_get_type                (void);
73 GtkSettings*    gtk_settings_get_default             (void);
74 void            gtk_settings_install_property        (GParamSpec         *pspec);
75 void            gtk_settings_install_property_parser (GParamSpec         *pspec,
76                                                       GtkRcPropertyParser parser);
77
78 /* --- precoded parsing functions --- */
79 gboolean gtk_rc_property_parse_color       (const GParamSpec *pspec,
80                                             const GString    *gstring,
81                                             GValue           *property_value);
82 gboolean gtk_rc_property_parse_enum        (const GParamSpec *pspec,
83                                             const GString    *gstring,
84                                             GValue           *property_value);
85 gboolean gtk_rc_property_parse_flags       (const GParamSpec *pspec,
86                                             const GString    *gstring,
87                                             GValue           *property_value);
88 gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec,
89                                             const GString    *gstring,
90                                             GValue           *property_value);
91 gboolean gtk_rc_property_parse_border      (const GParamSpec *pspec,
92                                             const GString    *gstring,
93                                             GValue           *property_value);
94
95 /*< private >*/
96 void            gtk_settings_set_property_value  (GtkSettings   *settings,
97                                                   const gchar   *name,
98                                                   const GtkSettingsValue *svalue);
99 void            gtk_settings_set_string_property (GtkSettings   *settings,
100                                                   const gchar   *name,
101                                                   const gchar   *v_string,
102                                                   const gchar   *origin);
103 void            gtk_settings_set_long_property   (GtkSettings   *settings,
104                                                   const gchar   *name,
105                                                   glong          v_long,
106                                                   const gchar   *origin);
107 void            gtk_settings_set_double_property (GtkSettings   *settings,
108                                                   const gchar   *name,
109                                                   gdouble        v_double,
110                                                   const gchar   *origin);
111
112
113 /* implementation details */
114 void                _gtk_settings_handle_event        (GdkEventSetting    *event);
115 GtkRcPropertyParser _gtk_rc_property_parser_from_type (GType               type);
116 gboolean            _gtk_settings_parse_convert       (GtkRcPropertyParser parser,
117                                                        const GValue       *src_value,
118                                                        GParamSpec         *pspec,
119                                                        GValue             *dest_value);
120
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126 #endif /* __GTK_SETTINGS_H__ */