1/* GTK - The GIMP Toolkit
2 * Copyright (C) 2006-2007 Async Open Source,
3 * Johan Dahlin <[email protected]>
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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#ifndef __GTK_BUILDER_H__
22#define __GTK_BUILDER_H__
23
24#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25#error "Only <gtk/gtk.h> can be included directly."
26#endif
27
28#include <gdkconfig.h>
29#include <glib-object.h>
30
31G_BEGIN_DECLS
32
33#define GTK_TYPE_BUILDER (gtk_builder_get_type ())
34#define GTK_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDER, GtkBuilder))
35#define GTK_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUILDER, GtkBuilderClass))
36#define GTK_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDER))
37#define GTK_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUILDER))
38#define GTK_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUILDER, GtkBuilderClass))
39
40#define GTK_BUILDER_ERROR (gtk_builder_error_quark ())
41
42typedef struct _GtkBuilder GtkBuilder;
43typedef struct _GtkBuilderClass GtkBuilderClass;
44typedef struct _GtkBuilderPrivate GtkBuilderPrivate;
45
46typedef enum
47{
48 GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
49 GTK_BUILDER_ERROR_UNHANDLED_TAG,
50 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
51 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
52 GTK_BUILDER_ERROR_INVALID_TAG,
53 GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
54 GTK_BUILDER_ERROR_INVALID_VALUE,
55 GTK_BUILDER_ERROR_VERSION_MISMATCH,
56 GTK_BUILDER_ERROR_DUPLICATE_ID
57} GtkBuilderError;
58
59GQuark gtk_builder_error_quark (void);
60
61struct _GtkBuilder
62{
63 GObject parent_instance;
64
65 GtkBuilderPrivate *GSEAL (priv);
66};
67
68struct _GtkBuilderClass
69{
70 GObjectClass parent_class;
71
72 GType (* get_type_from_name) (GtkBuilder *builder,
73 const char *type_name);
74
75 /* Padding for future expansion */
76 void (*_gtk_reserved1) (void);
77 void (*_gtk_reserved2) (void);
78 void (*_gtk_reserved3) (void);
79 void (*_gtk_reserved4) (void);
80 void (*_gtk_reserved5) (void);
81 void (*_gtk_reserved6) (void);
82 void (*_gtk_reserved7) (void);
83 void (*_gtk_reserved8) (void);
84};
85
86typedef void (*GtkBuilderConnectFunc) (GtkBuilder *builder,
87 GObject *object,
88 const gchar *signal_name,
89 const gchar *handler_name,
90 GObject *connect_object,
91 GConnectFlags flags,
92 gpointer user_data);
93
94GType gtk_builder_get_type (void) G_GNUC_CONST;
95GtkBuilder* gtk_builder_new (void);
96
97guint gtk_builder_add_from_file (GtkBuilder *builder,
98 const gchar *filename,
99 GError **error);
100guint gtk_builder_add_from_string (GtkBuilder *builder,
101 const gchar *buffer,
102 gsize length,
103 GError **error);
104guint gtk_builder_add_objects_from_file (GtkBuilder *builder,
105 const gchar *filename,
106 gchar **object_ids,
107 GError **error);
108guint gtk_builder_add_objects_from_string (GtkBuilder *builder,
109 const gchar *buffer,
110 gsize length,
111 gchar **object_ids,
112 GError **error);
113GObject* gtk_builder_get_object (GtkBuilder *builder,
114 const gchar *name);
115GSList* gtk_builder_get_objects (GtkBuilder *builder);
116void gtk_builder_connect_signals (GtkBuilder *builder,
117 gpointer user_data);
118void gtk_builder_connect_signals_full (GtkBuilder *builder,
119 GtkBuilderConnectFunc func,
120 gpointer user_data);
121void gtk_builder_set_translation_domain (GtkBuilder *builder,
122 const gchar *domain);
123const gchar* gtk_builder_get_translation_domain (GtkBuilder *builder);
124GType gtk_builder_get_type_from_name (GtkBuilder *builder,
125 const char *type_name);
126
127gboolean gtk_builder_value_from_string (GtkBuilder *builder,
128 GParamSpec *pspec,
129 const gchar *string,
130 GValue *value,
131 GError **error);
132gboolean gtk_builder_value_from_string_type (GtkBuilder *builder,
133 GType type,
134 const gchar *string,
135 GValue *value,
136 GError **error);
137
138#define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type) \
139 g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name (G_OBJECT_TYPE (object)))
140
141G_END_DECLS
142
143#endif /* __GTK_BUILDER_H__ */
144