]> Pileus Git - ~andy/gtk/blob - gtk/gtksettings.h
f058e00a6853ad5f3da13674efe6bcaa5013ab3a
[~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 G_BEGIN_DECLS
24
25
26 /* -- type macros --- */
27 #define GTK_TYPE_SETTINGS             (gtk_settings_get_type ())
28 #define GTK_SETTINGS(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SETTINGS, GtkSettings))
29 #define GTK_SETTINGS_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SETTINGS, GtkSettingsClass))
30 #define GTK_IS_SETTINGS(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SETTINGS))
31 #define GTK_IS_SETTINGS_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SETTINGS))
32 #define GTK_SETTINGS_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SETTINGS, GtkSettingsClass))
33
34
35 /* --- typedefs --- */
36 typedef struct    _GtkSettingsClass GtkSettingsClass;
37 typedef struct    _GtkSettingsValue GtkSettingsValue;
38 typedef struct    _GtkSettingsPropertyValue GtkSettingsPropertyValue; /* Internal */
39
40
41 /* --- structures --- */
42 struct _GtkSettings
43 {
44   GObject parent_instance;
45
46   GData  *queued_settings;      /* of type GtkSettingsValue* */
47   GtkSettingsPropertyValue *property_values;
48
49   GtkRcContext *rc_context;
50   GdkScreen    *screen;
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) G_GNUC_CONST;
73 #ifndef GDK_MULTIHEAD_SAFE
74 GtkSettings*    gtk_settings_get_default             (void);
75 #endif
76 GtkSettings*    gtk_settings_get_for_screen          (GdkScreen *screen);
77   
78 void            gtk_settings_install_property        (GParamSpec         *pspec);
79 void            gtk_settings_install_property_parser (GParamSpec         *pspec,
80                                                       GtkRcPropertyParser parser);
81
82 /* --- precoded parsing functions --- */
83 gboolean gtk_rc_property_parse_color       (const GParamSpec *pspec,
84                                             const GString    *gstring,
85                                             GValue           *property_value);
86 gboolean gtk_rc_property_parse_enum        (const GParamSpec *pspec,
87                                             const GString    *gstring,
88                                             GValue           *property_value);
89 gboolean gtk_rc_property_parse_flags       (const GParamSpec *pspec,
90                                             const GString    *gstring,
91                                             GValue           *property_value);
92 gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec,
93                                             const GString    *gstring,
94                                             GValue           *property_value);
95 gboolean gtk_rc_property_parse_border      (const GParamSpec *pspec,
96                                             const GString    *gstring,
97                                             GValue           *property_value);
98
99 /*< private >*/
100 void            gtk_settings_set_property_value  (GtkSettings   *settings,
101                                                   const gchar   *name,
102                                                   const GtkSettingsValue *svalue);
103 void            gtk_settings_set_string_property (GtkSettings   *settings,
104                                                   const gchar   *name,
105                                                   const gchar   *v_string,
106                                                   const gchar   *origin);
107 void            gtk_settings_set_long_property   (GtkSettings   *settings,
108                                                   const gchar   *name,
109                                                   glong          v_long,
110                                                   const gchar   *origin);
111 void            gtk_settings_set_double_property (GtkSettings   *settings,
112                                                   const gchar   *name,
113                                                   gdouble        v_double,
114                                                   const gchar   *origin);
115
116
117 /* implementation details */
118 void _gtk_settings_set_property_value_from_rc (GtkSettings            *settings,
119                                                const gchar            *name,
120                                                const GtkSettingsValue *svalue);
121 void _gtk_settings_reset_rc_values            (GtkSettings            *settings);
122
123 void                _gtk_settings_handle_event        (GdkEventSetting    *event);
124 GtkRcPropertyParser _gtk_rc_property_parser_from_type (GType               type);
125 gboolean            _gtk_settings_parse_convert       (GtkRcPropertyParser parser,
126                                                        const GValue       *src_value,
127                                                        GParamSpec         *pspec,
128                                                        GValue             *dest_value);
129
130
131 G_END_DECLS
132
133 #endif /* __GTK_SETTINGS_H__ */