]> Pileus Git - ~andy/gtk/blob - gtk/gtkrc.h
Merge branch 'master' into broadway
[~andy/gtk] / gtk / gtkrc.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_RC_H__
32 #define __GTK_RC_H__
33
34
35 #include <gtk/gtkstyle.h>
36
37 G_BEGIN_DECLS
38
39 /* Forward declarations */
40 typedef struct _GtkIconFactory  GtkIconFactory;
41 typedef struct _GtkRcContext    GtkRcContext;
42
43 typedef struct _GtkRcStyleClass GtkRcStyleClass;
44
45 #define GTK_TYPE_RC_STYLE              (gtk_rc_style_get_type ())
46 #define GTK_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_RC_STYLE, GtkRcStyle))
47 #define GTK_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
48 #define GTK_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_RC_STYLE))
49 #define GTK_IS_RC_STYLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RC_STYLE))
50 #define GTK_RC_STYLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
51
52 typedef enum
53 {
54   GTK_RC_FG             = 1 << 0,
55   GTK_RC_BG             = 1 << 1,
56   GTK_RC_TEXT           = 1 << 2,
57   GTK_RC_BASE           = 1 << 3
58 } GtkRcFlags;
59
60 struct _GtkRcStyle
61 {
62   GObject parent_instance;
63
64   /*< public >*/
65
66   gchar *name;
67   gchar *bg_pixmap_name[5];
68   PangoFontDescription *font_desc;
69
70   GtkRcFlags color_flags[5];
71   GdkColor   fg[5];
72   GdkColor   bg[5];
73   GdkColor   text[5];
74   GdkColor   base[5];
75
76   gint xthickness;
77   gint ythickness;
78
79   /*< private >*/
80   GArray *rc_properties;
81
82   /* list of RC style lists including this RC style */
83   GSList *rc_style_lists;
84
85   GSList *icon_factories;
86
87   guint engine_specified : 1;   /* The RC file specified the engine */
88 };
89
90 struct _GtkRcStyleClass
91 {
92   GObjectClass parent_class;
93
94   /* Create an empty RC style of the same type as this RC style.
95    * The default implementation, which does
96    * g_object_new (G_OBJECT_TYPE (style), NULL);
97    * should work in most cases.
98    */
99   GtkRcStyle * (*create_rc_style) (GtkRcStyle *rc_style);
100
101   /* Fill in engine specific parts of GtkRcStyle by parsing contents
102    * of brackets. Returns G_TOKEN_NONE if successful, otherwise returns
103    * the token it expected but didn't get.
104    */
105   guint     (*parse)  (GtkRcStyle   *rc_style,
106                        GtkSettings  *settings,
107                        GScanner     *scanner);
108
109   /* Combine RC style data from src into dest. If overridden, this
110    * function should chain to the parent.
111    */
112   void      (*merge)  (GtkRcStyle *dest,
113                        GtkRcStyle *src);
114
115   /* Create an empty style suitable to this RC style
116    */
117   GtkStyle * (*create_style) (GtkRcStyle *rc_style);
118
119   /* Padding for future expansion */
120   void (*_gtk_reserved1) (void);
121   void (*_gtk_reserved2) (void);
122   void (*_gtk_reserved3) (void);
123   void (*_gtk_reserved4) (void);
124 };
125
126 void      _gtk_rc_init                   (void);
127 GSList*   _gtk_rc_parse_widget_class_path (const gchar *pattern);
128 void      _gtk_rc_free_widget_class_path (GSList       *list);
129 gboolean  _gtk_rc_match_widget_class     (GSList       *list,
130                                           gint          length,
131                                           gchar        *path,
132                                           gchar        *path_reversed);
133
134 #if !defined(GTK_DISABLE_DEPRECATED) || defined(GTK_COMPILATION)
135
136 void      gtk_rc_add_default_file       (const gchar *filename);
137 void      gtk_rc_set_default_files      (gchar **filenames);
138 gchar**   gtk_rc_get_default_files      (void);
139 GtkStyle* gtk_rc_get_style              (GtkWidget   *widget);
140 GtkStyle* gtk_rc_get_style_by_paths     (GtkSettings *settings,
141                                          const char  *widget_path,
142                                          const char  *class_path,
143                                          GType        type);
144
145 gboolean gtk_rc_reparse_all_for_settings (GtkSettings *settings,
146                                           gboolean     force_load);
147 void     gtk_rc_reset_styles             (GtkSettings *settings);
148
149 gchar*   gtk_rc_find_pixmap_in_path (GtkSettings  *settings,
150                                      GScanner     *scanner,
151                                      const gchar  *pixmap_file);
152
153 void      gtk_rc_parse                  (const gchar *filename);
154 void      gtk_rc_parse_string           (const gchar *rc_string);
155 gboolean  gtk_rc_reparse_all            (void);
156
157 GType       gtk_rc_style_get_type   (void) G_GNUC_CONST;
158 GtkRcStyle* gtk_rc_style_new        (void);
159 GtkRcStyle* gtk_rc_style_copy       (GtkRcStyle *orig);
160
161 gchar*          gtk_rc_find_module_in_path      (const gchar    *module_file);
162 gchar*          gtk_rc_get_theme_dir            (void);
163 gchar*          gtk_rc_get_module_dir           (void);
164 gchar*          gtk_rc_get_im_module_path       (void);
165 gchar*          gtk_rc_get_im_module_file       (void);
166
167 /* private functions/definitions */
168 typedef enum {
169   GTK_RC_TOKEN_INVALID = G_TOKEN_LAST,
170   GTK_RC_TOKEN_INCLUDE,
171   GTK_RC_TOKEN_NORMAL,
172   GTK_RC_TOKEN_ACTIVE,
173   GTK_RC_TOKEN_PRELIGHT,
174   GTK_RC_TOKEN_SELECTED,
175   GTK_RC_TOKEN_INSENSITIVE,
176   GTK_RC_TOKEN_FG,
177   GTK_RC_TOKEN_BG,
178   GTK_RC_TOKEN_TEXT,
179   GTK_RC_TOKEN_BASE,
180   GTK_RC_TOKEN_XTHICKNESS,
181   GTK_RC_TOKEN_YTHICKNESS,
182   GTK_RC_TOKEN_FONT,
183   GTK_RC_TOKEN_FONTSET,
184   GTK_RC_TOKEN_FONT_NAME,
185   GTK_RC_TOKEN_BG_PIXMAP,
186   GTK_RC_TOKEN_PIXMAP_PATH,
187   GTK_RC_TOKEN_STYLE,
188   GTK_RC_TOKEN_BINDING,
189   GTK_RC_TOKEN_BIND,
190   GTK_RC_TOKEN_WIDGET,
191   GTK_RC_TOKEN_WIDGET_CLASS,
192   GTK_RC_TOKEN_CLASS,
193   GTK_RC_TOKEN_LOWEST,
194   GTK_RC_TOKEN_GTK,
195   GTK_RC_TOKEN_APPLICATION,
196   GTK_RC_TOKEN_THEME,
197   GTK_RC_TOKEN_RC,
198   GTK_RC_TOKEN_HIGHEST,
199   GTK_RC_TOKEN_ENGINE,
200   GTK_RC_TOKEN_MODULE_PATH,
201   GTK_RC_TOKEN_IM_MODULE_PATH,
202   GTK_RC_TOKEN_IM_MODULE_FILE,
203   GTK_RC_TOKEN_STOCK,
204   GTK_RC_TOKEN_LTR,
205   GTK_RC_TOKEN_RTL,
206   GTK_RC_TOKEN_COLOR,
207   GTK_RC_TOKEN_UNBIND,
208   GTK_RC_TOKEN_LAST
209 } GtkRcTokenType;
210
211 GScanner* gtk_rc_scanner_new    (void);
212 guint     gtk_rc_parse_color    (GScanner            *scanner,
213                                  GdkColor            *color);
214 guint     gtk_rc_parse_color_full (GScanner          *scanner,
215                                    GtkRcStyle        *style,
216                                    GdkColor          *color);
217 guint     gtk_rc_parse_state    (GScanner            *scanner,
218                                  GtkStateType        *state);
219 guint     gtk_rc_parse_priority (GScanner            *scanner,
220                                  GtkPathPriorityType *priority);
221
222 #endif
223
224 /* rc properties
225  * (structure forward declared in gtkstyle.h)
226  */
227 struct _GtkRcProperty
228 {
229   /* quark-ified property identifier like "GtkScrollbar::spacing" */
230   GQuark type_name;
231   GQuark property_name;
232
233   /* fields similar to GtkSettingsValue */
234   gchar *origin;
235   GValue value;
236 };
237 const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
238                                                        GQuark      type_name,
239                                                        GQuark      property_name);
240 void          _gtk_rc_style_set_rc_property           (GtkRcStyle *rc_style,
241                                                        GtkRcProperty *property);
242 void          _gtk_rc_style_unset_rc_property         (GtkRcStyle *rc_style,
243                                                        GQuark      type_name,
244                                                        GQuark      property_name);
245
246 GSList     * _gtk_rc_style_get_color_hashes        (GtkRcStyle *rc_style);
247
248 void         _gtk_rc_style_set_symbolic_color       (GtkRcStyle     *rc_style,
249                                                      const gchar    *name,
250                                                      const GdkColor *color);
251
252 const gchar* _gtk_rc_context_get_default_font_name (GtkSettings *settings);
253 void         _gtk_rc_context_destroy               (GtkSettings *settings);
254
255 G_END_DECLS
256
257 #endif /* __GTK_RC_H__ */