]> Pileus Git - ~andy/gtk/blob - gtk/gtkbuilder.h
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkbuilder.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2006-2007 Async Open Source,
3  *                         Johan Dahlin <jdahlin@async.com.br>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __GTK_BUILDER_H__
20 #define __GTK_BUILDER_H__
21
22 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
24 #endif
25
26 #include <gtk/gtkwidget.h>
27
28 G_BEGIN_DECLS
29
30 #define GTK_TYPE_BUILDER                 (gtk_builder_get_type ())
31 #define GTK_BUILDER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDER, GtkBuilder))
32 #define GTK_BUILDER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUILDER, GtkBuilderClass))
33 #define GTK_IS_BUILDER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDER))
34 #define GTK_IS_BUILDER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUILDER))
35 #define GTK_BUILDER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUILDER, GtkBuilderClass))
36
37 #define GTK_BUILDER_ERROR                (gtk_builder_error_quark ())
38
39 typedef struct _GtkBuilder        GtkBuilder;
40 typedef struct _GtkBuilderClass   GtkBuilderClass;
41 typedef struct _GtkBuilderPrivate GtkBuilderPrivate;
42
43 /**
44  * GtkBuilderError:
45  * @GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION: A type-func attribute didn't name
46  *  a function that returns a #GType.
47  * @GTK_BUILDER_ERROR_UNHANDLED_TAG: The input contained a tag that #GtkBuilder
48  *  can't handle.
49  * @GTK_BUILDER_ERROR_MISSING_ATTRIBUTE: An attribute that is required by
50  *  #GtkBuilder was missing.
51  * @GTK_BUILDER_ERROR_INVALID_ATTRIBUTE: #GtkBuilder found an attribute that
52  *  it doesn't understand.
53  * @GTK_BUILDER_ERROR_INVALID_TAG: #GtkBuilder found a tag that
54  *  it doesn't understand.
55  * @GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE: A required property value was
56  *  missing.
57  * @GTK_BUILDER_ERROR_INVALID_VALUE: #GtkBuilder couldn't parse
58  *  some attribute value.
59  * @GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
60  *  of GTK+.
61  * @GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
62  *
63  * Error codes that identify various errors that can occur while using
64  * #GtkBuilder.
65  */
66 typedef enum
67 {
68   GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
69   GTK_BUILDER_ERROR_UNHANDLED_TAG,
70   GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
71   GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
72   GTK_BUILDER_ERROR_INVALID_TAG,
73   GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
74   GTK_BUILDER_ERROR_INVALID_VALUE,
75   GTK_BUILDER_ERROR_VERSION_MISMATCH,
76   GTK_BUILDER_ERROR_DUPLICATE_ID
77 } GtkBuilderError;
78
79 GQuark gtk_builder_error_quark (void);
80
81 struct _GtkBuilder
82 {
83   GObject parent_instance;
84
85   GtkBuilderPrivate *priv;
86 };
87
88 struct _GtkBuilderClass
89 {
90   GObjectClass parent_class;
91   
92   GType (* get_type_from_name) (GtkBuilder *builder,
93                                 const char *type_name);
94
95   /* Padding for future expansion */
96   void (*_gtk_reserved1) (void);
97   void (*_gtk_reserved2) (void);
98   void (*_gtk_reserved3) (void);
99   void (*_gtk_reserved4) (void);
100   void (*_gtk_reserved5) (void);
101   void (*_gtk_reserved6) (void);
102   void (*_gtk_reserved7) (void);
103   void (*_gtk_reserved8) (void);
104 };
105
106 typedef void (*GtkBuilderConnectFunc) (GtkBuilder    *builder,
107                                        GObject       *object,
108                                        const gchar   *signal_name,
109                                        const gchar   *handler_name,
110                                        GObject       *connect_object,
111                                        GConnectFlags  flags,
112                                        gpointer       user_data);
113
114 GType        gtk_builder_get_type                (void) G_GNUC_CONST;
115 GtkBuilder*  gtk_builder_new                     (void);
116
117 guint        gtk_builder_add_from_file           (GtkBuilder    *builder,
118                                                   const gchar   *filename,
119                                                   GError       **error);
120 guint        gtk_builder_add_from_resource       (GtkBuilder    *builder,
121                                                   const gchar   *resource_path,
122                                                   GError       **error);
123 guint        gtk_builder_add_from_string         (GtkBuilder    *builder,
124                                                   const gchar   *buffer,
125                                                   gsize          length,
126                                                   GError       **error);
127 guint        gtk_builder_add_objects_from_file   (GtkBuilder    *builder,
128                                                   const gchar   *filename,
129                                                   gchar        **object_ids,
130                                                   GError       **error);
131 GDK_AVAILABLE_IN_3_4
132 guint        gtk_builder_add_objects_from_resource(GtkBuilder    *builder,
133                                                   const gchar   *resource_path,
134                                                   gchar        **object_ids,
135                                                   GError       **error);
136 guint        gtk_builder_add_objects_from_string (GtkBuilder    *builder,
137                                                   const gchar   *buffer,
138                                                   gsize          length,
139                                                   gchar        **object_ids,
140                                                   GError       **error);
141 GObject*     gtk_builder_get_object              (GtkBuilder    *builder,
142                                                   const gchar   *name);
143 GSList*      gtk_builder_get_objects             (GtkBuilder    *builder);
144 GDK_AVAILABLE_IN_3_8
145 void         gtk_builder_expose_object           (GtkBuilder    *builder,
146                                                   const gchar   *name,
147                                                   GObject       *object);
148 void         gtk_builder_connect_signals         (GtkBuilder    *builder,
149                                                   gpointer       user_data);
150 void         gtk_builder_connect_signals_full    (GtkBuilder    *builder,
151                                                   GtkBuilderConnectFunc func,
152                                                   gpointer       user_data);
153 void         gtk_builder_set_translation_domain  (GtkBuilder    *builder,
154                                                   const gchar   *domain);
155 const gchar* gtk_builder_get_translation_domain  (GtkBuilder    *builder);
156 GType        gtk_builder_get_type_from_name      (GtkBuilder    *builder,
157                                                   const char    *type_name);
158
159 gboolean     gtk_builder_value_from_string       (GtkBuilder    *builder,
160                                                   GParamSpec    *pspec,
161                                                   const gchar   *string,
162                                                   GValue        *value,
163                                                   GError       **error);
164 gboolean     gtk_builder_value_from_string_type  (GtkBuilder    *builder,
165                                                   GType          type,
166                                                   const gchar   *string,
167                                                   GValue        *value,
168                                                   GError       **error);
169
170 /**
171  * GTK_BUILDER_WARN_INVALID_CHILD_TYPE:
172  * @object: the #GtkBuildable on which the warning ocurred
173  * @type: the unexpected type value
174  *
175  * This macro should be used to emit a warning about and unexpected @type value
176  * in a #GtkBuildable add_child implementation.
177  */
178 #define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type) \
179   g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name (G_OBJECT_TYPE (object)))
180
181 G_END_DECLS
182
183 #endif /* __GTK_BUILDER_H__ */