gtkbuilder.h 7.21 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Johan Dahlin's avatar
Johan Dahlin committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 * Copyright (C) 2006-2007 Async Open Source,
 *                         Johan Dahlin <jdahlin@async.com.br>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
20

21
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22
23
24
#error "Only <gtk/gtk.h> can be included directly."
#endif

Johan Dahlin's avatar
Johan Dahlin committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __GTK_BUILDER_H__
#define __GTK_BUILDER_H__

#include <glib-object.h>

G_BEGIN_DECLS

#define GTK_TYPE_BUILDER                 (gtk_builder_get_type ())
#define GTK_BUILDER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDER, GtkBuilder))
#define GTK_BUILDER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUILDER, GtkBuilderClass))
#define GTK_IS_BUILDER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDER))
#define GTK_IS_BUILDER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUILDER))
#define GTK_BUILDER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUILDER, GtkBuilderClass))

#define GTK_BUILDER_ERROR                (gtk_builder_error_quark ())

typedef struct _GtkBuilder        GtkBuilder;
typedef struct _GtkBuilderClass   GtkBuilderClass;
typedef struct _GtkBuilderPrivate GtkBuilderPrivate;

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
 * GtkBuilderError:
 * @GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION: A type-func attribute didn't name
 *  a function that returns a #GType.
 * @GTK_BUILDER_ERROR_UNHANDLED_TAG: The input contained a tag that #GtkBuilder
 *  can't handle.
 * @GTK_BUILDER_ERROR_MISSING_ATTRIBUTE: An attribute that is required by
 *  #GtkBuilder was missing.
 * @GTK_BUILDER_ERROR_INVALID_ATTRIBUTE: #GtkBuilder found an attribute that
 *  it doesn't understand.
 * @GTK_BUILDER_ERROR_INVALID_TAG: #GtkBuilder found a tag that
 *  it doesn't understand.
 * @GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE: A required property value was
 *  missing.
 * @GTK_BUILDER_ERROR_INVALID_VALUE: #GtkBuilder couldn't parse
 *  some attribute value.
 * @GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
 *  of GTK+.
 * @GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
 *
 * Error codes that identify various errors that can occur while using
 * #GtkBuilder.
 */
Johan Dahlin's avatar
Johan Dahlin committed
68
69
70
71
72
73
typedef enum
{
  GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
  GTK_BUILDER_ERROR_UNHANDLED_TAG,
  GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
  GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
74
  GTK_BUILDER_ERROR_INVALID_TAG,
75
  GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
76
  GTK_BUILDER_ERROR_INVALID_VALUE,
77
78
  GTK_BUILDER_ERROR_VERSION_MISMATCH,
  GTK_BUILDER_ERROR_DUPLICATE_ID
Johan Dahlin's avatar
Johan Dahlin committed
79
80
81
82
83
84
85
86
} GtkBuilderError;

GQuark gtk_builder_error_quark (void);

struct _GtkBuilder
{
  GObject parent_instance;

87
  GtkBuilderPrivate *priv;
Johan Dahlin's avatar
Johan Dahlin committed
88
89
90
91
92
93
94
};

struct _GtkBuilderClass
{
  GObjectClass parent_class;
  
  GType (* get_type_from_name) (GtkBuilder *builder,
95
                                const char *type_name);
Johan Dahlin's avatar
Johan Dahlin committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
  void (*_gtk_reserved7) (void);
  void (*_gtk_reserved8) (void);
};

typedef void (*GtkBuilderConnectFunc) (GtkBuilder    *builder,
				       GObject       *object,
				       const gchar   *signal_name,
				       const gchar   *handler_name,
				       GObject       *connect_object,
				       GConnectFlags  flags,
				       gpointer       user_data);

GType        gtk_builder_get_type                (void) G_GNUC_CONST;
GtkBuilder*  gtk_builder_new                     (void);

guint        gtk_builder_add_from_file           (GtkBuilder    *builder,
                                                  const gchar   *filename,
                                                  GError       **error);
guint        gtk_builder_add_from_string         (GtkBuilder    *builder,
                                                  const gchar   *buffer,
                                                  gsize          length,
                                                  GError       **error);
126
127
128
129
130
131
132
133
134
guint        gtk_builder_add_objects_from_file   (GtkBuilder    *builder,
                                                  const gchar   *filename,
                                                  gchar        **object_ids,
                                                  GError       **error);
guint        gtk_builder_add_objects_from_string (GtkBuilder    *builder,
                                                  const gchar   *buffer,
                                                  gsize          length,
                                                  gchar        **object_ids,
                                                  GError       **error);
Johan Dahlin's avatar
Johan Dahlin committed
135
136
137
138
139
140
141
142
143
144
145
146
GObject*     gtk_builder_get_object              (GtkBuilder    *builder,
                                                  const gchar   *name);
GSList*      gtk_builder_get_objects             (GtkBuilder    *builder);
void         gtk_builder_connect_signals         (GtkBuilder    *builder,
						  gpointer       user_data);
void         gtk_builder_connect_signals_full    (GtkBuilder    *builder,
                                                  GtkBuilderConnectFunc func,
						  gpointer       user_data);
void         gtk_builder_set_translation_domain  (GtkBuilder   	*builder,
                                                  const gchar  	*domain);
const gchar* gtk_builder_get_translation_domain  (GtkBuilder   	*builder);
GType        gtk_builder_get_type_from_name      (GtkBuilder   	*builder,
147
                                                  const char   	*type_name);
Johan Dahlin's avatar
Johan Dahlin committed
148

149
150
gboolean     gtk_builder_value_from_string       (GtkBuilder    *builder,
						  GParamSpec   	*pspec,
Johan Dahlin's avatar
Johan Dahlin committed
151
                                                  const gchar  	*string,
152
153
154
155
                                                  GValue       	*value,
						  GError       **error);
gboolean     gtk_builder_value_from_string_type  (GtkBuilder    *builder,
						  GType        	 type,
Johan Dahlin's avatar
Johan Dahlin committed
156
                                                  const gchar  	*string,
157
158
                                                  GValue       	*value,
						  GError       **error);
Johan Dahlin's avatar
Johan Dahlin committed
159

160
161
162
163
164
165
166
167
/**
 * GTK_BUILDER_WARN_INVALID_CHILD_TYPE:
 * @object: the #GtkBuildable on which the warning ocurred
 * @type: the unexpected type value
 *
 * This macro should be used to emit a warning about and unexpected @type value
 * in a #GtkBuildable add_child implementation.
 */
Johan Dahlin's avatar
Johan Dahlin committed
168
#define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type) \
169
  g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name (G_OBJECT_TYPE (object)))
Johan Dahlin's avatar
Johan Dahlin committed
170
171
172
173

G_END_DECLS

#endif /* __GTK_BUILDER_H__ */