]> Pileus Git - ~andy/gtk/blob - gtk/gtkrc.h
d655ca2b0083bd1c4f79e1428528c9744c8143c8
[~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 #ifndef __GTK_RC_H__
28 #define __GTK_RC_H__
29
30
31 #include <gtk/gtkstyle.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36
37 /* Forward declarations */
38 typedef struct _GtkIconFactory  GtkIconFactory;
39 typedef struct _GtkRcContext    GtkRcContext;
40 typedef struct _GtkSettings     GtkSettings;
41
42 typedef struct _GtkRcStyleClass GtkRcStyleClass;
43
44 #define GTK_TYPE_RC_STYLE              (gtk_rc_style_get_type ())
45 #define GTK_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_RC_STYLE, GtkRcStyle))
46 #define GTK_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
47 #define GTK_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_RC_STYLE))
48 #define GTK_IS_RC_STYLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RC_STYLE))
49 #define GTK_RC_STYLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
50
51 typedef enum
52 {
53   GTK_RC_FG             = 1 << 0,
54   GTK_RC_BG             = 1 << 1,
55   GTK_RC_TEXT           = 1 << 2,
56   GTK_RC_BASE           = 1 << 3
57 } GtkRcFlags;
58
59 struct _GtkRcStyle
60 {
61   GObject parent_instance;
62
63   /*< public >*/
64   
65   gchar *name;
66   gchar *bg_pixmap_name[5];
67   PangoFontDescription *font_desc;
68
69   GtkRcFlags color_flags[5];
70   GdkColor   fg[5];
71   GdkColor   bg[5];
72   GdkColor   text[5];
73   GdkColor   base[5];
74
75   gint xthickness;
76   gint ythickness;
77
78   /*< private >*/
79   GBSearchArray *rc_properties;
80   
81   /* list of RC style lists including this RC style */
82   GSList *rc_style_lists;
83
84   GSList *icon_factories;
85 };
86
87 struct _GtkRcStyleClass
88 {
89   GObjectClass parent_class;
90
91   /* Create an empty RC style of the same type as this RC style.
92    * The default implementation, which does
93    * g_object_new (G_OBJECT_TYPE (style), NULL);
94    * should work in most cases.
95    */
96   GtkRcStyle * (*create_rc_style) (GtkRcStyle *rc_style);
97
98   /* Fill in engine specific parts of GtkRcStyle by parsing contents
99    * of brackets. Returns G_TOKEN_NONE if succesful, otherwise returns
100    * the token it expected but didn't get.
101    */
102   guint     (*parse)  (GtkRcStyle   *rc_style,
103                        GtkSettings  *settings,
104                        GScanner     *scanner);
105   
106   /* Combine RC style data from src into dest. If overriden, this
107    * function should chain to the parent.
108    */
109   void      (*merge)  (GtkRcStyle *dest,
110                        GtkRcStyle *src);
111
112   /* Create an empty style suitable to this RC style
113    */
114   GtkStyle * (*create_style) (GtkRcStyle *rc_style);
115 };
116
117 void      _gtk_rc_init                  (void);
118 void      gtk_rc_add_default_file       (const gchar *filename);
119 void      gtk_rc_set_default_files      (gchar **filenames);
120 gchar**   gtk_rc_get_default_files      (void);
121 GtkStyle* gtk_rc_get_style              (GtkWidget   *widget);
122 GtkStyle* gtk_rc_get_style_by_paths     (GtkSettings *settings,
123                                          const char  *widget_path,
124                                          const char  *class_path,
125                                          GType        type);
126
127 gboolean gtk_rc_reparse_all_for_settings (GtkSettings *settings,
128                                           gboolean     force_load);
129 gchar*   gtk_rc_find_pixmap_in_path (GtkSettings  *context,
130                                      GScanner     *scanner,
131                                      const gchar  *pixmap_file);
132
133 void      gtk_rc_parse                  (const gchar *filename);
134 void      gtk_rc_parse_string           (const gchar *rc_string);
135 gboolean  gtk_rc_reparse_all            (void);
136
137 #ifndef GTK_DISABLE_DEPRECATED
138 void      gtk_rc_add_widget_name_style  (GtkRcStyle   *rc_style,
139                                          const gchar  *pattern);
140 void      gtk_rc_add_widget_class_style (GtkRcStyle   *rc_style,
141                                          const gchar  *pattern);
142 void      gtk_rc_add_class_style        (GtkRcStyle   *rc_style,
143                                          const gchar  *pattern);
144 #endif /* GTK_DISABLE_DEPRECATED */
145
146
147 GType       gtk_rc_style_get_type   (void) G_GNUC_CONST;
148 GtkRcStyle* gtk_rc_style_new        (void);
149 GtkRcStyle* gtk_rc_style_copy       (GtkRcStyle *orig);
150 void        gtk_rc_style_ref        (GtkRcStyle *rc_style);
151 void        gtk_rc_style_unref      (GtkRcStyle *rc_style);
152
153 gchar*          gtk_rc_find_module_in_path      (const gchar    *module_file);
154 gchar*          gtk_rc_get_theme_dir            (void);
155 gchar*          gtk_rc_get_module_dir           (void);
156 gchar*          gtk_rc_get_im_module_path       (void);
157 gchar*          gtk_rc_get_im_module_file       (void);
158
159 /* private functions/definitions */
160 typedef enum {
161   GTK_RC_TOKEN_INVALID = G_TOKEN_LAST,
162   GTK_RC_TOKEN_INCLUDE,
163   GTK_RC_TOKEN_NORMAL,
164   GTK_RC_TOKEN_ACTIVE,
165   GTK_RC_TOKEN_PRELIGHT,
166   GTK_RC_TOKEN_SELECTED,
167   GTK_RC_TOKEN_INSENSITIVE,
168   GTK_RC_TOKEN_FG,
169   GTK_RC_TOKEN_BG,
170   GTK_RC_TOKEN_TEXT,
171   GTK_RC_TOKEN_BASE,
172   GTK_RC_TOKEN_XTHICKNESS,
173   GTK_RC_TOKEN_YTHICKNESS,
174   GTK_RC_TOKEN_FONT,
175   GTK_RC_TOKEN_FONTSET,
176   GTK_RC_TOKEN_FONT_NAME,
177   GTK_RC_TOKEN_BG_PIXMAP,
178   GTK_RC_TOKEN_PIXMAP_PATH,
179   GTK_RC_TOKEN_STYLE,
180   GTK_RC_TOKEN_BINDING,
181   GTK_RC_TOKEN_BIND,
182   GTK_RC_TOKEN_WIDGET,
183   GTK_RC_TOKEN_WIDGET_CLASS,
184   GTK_RC_TOKEN_CLASS,
185   GTK_RC_TOKEN_LOWEST,
186   GTK_RC_TOKEN_GTK,
187   GTK_RC_TOKEN_APPLICATION,
188   GTK_RC_TOKEN_THEME,
189   GTK_RC_TOKEN_RC,
190   GTK_RC_TOKEN_HIGHEST,
191   GTK_RC_TOKEN_ENGINE,
192   GTK_RC_TOKEN_MODULE_PATH,
193   GTK_RC_TOKEN_IM_MODULE_PATH,
194   GTK_RC_TOKEN_IM_MODULE_FILE,
195   GTK_RC_TOKEN_STOCK,
196   GTK_RC_TOKEN_LTR,
197   GTK_RC_TOKEN_RTL,
198   GTK_RC_TOKEN_LAST
199 } GtkRcTokenType;
200
201 GScanner* gtk_rc_scanner_new    (void);
202 guint     gtk_rc_parse_color    (GScanner            *scanner,
203                                  GdkColor            *color);
204 guint     gtk_rc_parse_state    (GScanner            *scanner,
205                                  GtkStateType        *state);
206 guint     gtk_rc_parse_priority (GScanner            *scanner,
207                                  GtkPathPriorityType *priority);
208
209
210 /* rc properties
211  * (structure forward declared in gtkstyle.h)
212  */
213 struct _GtkRcProperty
214 {
215   /* quark-ified property identifier like "GtkScrollbar::spacing" */
216   GQuark type_name;
217   GQuark property_name;
218
219   /* fields similar to GtkSettingsValue */
220   gchar *origin;
221   GValue value;
222 };
223 const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
224                                                        GQuark      type_name,
225                                                        GQuark      property_name);
226
227 #ifdef G_OS_WIN32
228 gchar*  gtk_win32_get_installation_directory (void);
229 #endif
230
231
232 #ifdef __cplusplus
233 }
234 #endif /* __cplusplus */
235
236
237 #endif /* __GTK_RC_H__ */