summaryrefslogtreecommitdiff
path: root/src/glade-widget.h
blob: 7f9dfad79d852a7a38dc53f955f614c79861619e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_WIDGET_H__
#define __GLADE_WIDGET_H__

#include <glib.h>
#include <glib-object.h>

#include "glade-widget-class.h"
#include "glade-signal.h"
#include "glade-property.h"

G_BEGIN_DECLS
 
#define GLADE_TYPE_WIDGET            (glade_widget_get_type ())
#define GLADE_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_WIDGET, GladeWidget))
#define GLADE_WIDGET_KLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_WIDGET, GladeWidgetKlass))
#define GLADE_IS_WIDGET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_WIDGET))
#define GLADE_IS_WIDGET_KLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_WIDGET))
#define GLADE_WIDGET_GET_KLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_WIDGET, GladeWidgetKlass))

typedef struct _GladeWidgetKlass  GladeWidgetKlass;

struct _GladeWidget
{
	GObject parent_instance;

	GladeWidgetClass *widget_class;
	GladeProject     *project;     /* A pointer to the project that this widget belongs to. */

	GladeWidget  *parent;  /* A pointer to the parent widget in the hierarchy */
	
	gchar *name; /* The name of the widget. For example window1 or
		      * button2. This is a unique name and is the one
		      * used when loading widget with libglade
		      */
	
	gchar *internal; /* If the widget is an internal child of 
			  * another widget this is the name of the 
			  * internal child, otherwise is NULL.
			  * Internal children cannot be deleted.
			  */
	
	gboolean anarchist; /* Some composite widgets have internal children
			     * that are not part of the same hierarchy; hence 'anarchists',
			     * typicly a popup window or its child (we need to mark
			     * them so we can avoid bookkeeping packing props on them etc.).
			     */

	GObject *object; /* A pointer to the object that was created.
			  * if it is a GtkWidget; it is shown as a "view"
			  * of the GladeWidget. This object is updated as
			  * the properties are modified for the GladeWidget.
			  */
	
	GList *properties; /* A list of GladeProperty. A GladeProperty is an
			    * instance of a GladePropertyClass. If a
			    * GladePropertyClass for a gtkbutton is label, its
			    * property is "Ok". 
			    */

	GList *packing_properties; /* A list of GladeProperty. Note that these
				    * properties are related to the container
				    * of the widget, thus they change after
				    * pasting the widget to a different
				    * container. Toplevels widget do not have
				    * packing properties.
				    * See also child_properties of 
				    * GladeWidgetClass.
				    */
	
	GHashTable *signals; /* A table with a GPtrArray of GladeSignals (signal handlers),
			      * indexed by its name */

	gboolean   visible; /* Local copy of widget visibility, we need to keep track of this
			     * since the objects copy may be invalid due to a rebuild.
			     */


	gboolean   prop_refs_readonly; /* Whether this list is currently readonly */
	GList     *prop_refs; /* List of properties in the project who's value are `this object'
			       * (this is used to set/unset those properties when the object is
			       * added/removed from the project).
			       */

	/* Save toplevel positions */
	gint      save_x;
	gint      save_y;
	gboolean  pos_saved;


	/* Construct parameters: */
	GladeWidget       *construct_template;
	GladeWidgetInfo   *construct_info;
	GladeCreateReason  construct_reason;
	gchar             *construct_internal;
};

struct _GladeWidgetKlass
{
	GObjectClass parent_class;

	void         (*add_child)               (GladeWidget *, GladeWidget *, gboolean);
	void         (*remove_child)            (GladeWidget *, GladeWidget *);
	void         (*replace_child)           (GladeWidget *, GObject *, GObject *);

	void         (*add_signal_handler)	(GladeWidget *, GladeSignal *);
	void         (*remove_signal_handler)	(GladeWidget *, GladeSignal *);
	void         (*change_signal_handler)	(GladeWidget *, GladeSignal *, GladeSignal *);

	void         (*setup_events)            (GladeWidget *, GtkWidget *);
	gboolean     (*event)                   (GtkWidget *, GdkEvent *, GladeWidget *);

};

/*******************************************************************************
                                  General api
 *******************************************************************************/
LIBGLADEUI_API
GType                   glade_widget_get_type		    (void);
LIBGLADEUI_API
GladeWidget            *glade_widget_get_from_gobject       (gpointer          object);
LIBGLADEUI_API
void                    glade_widget_add_child              (GladeWidget      *parent,
							     GladeWidget      *child,
							     gboolean          at_mouse);
LIBGLADEUI_API
void                    glade_widget_remove_child           (GladeWidget      *parent,
							     GladeWidget      *child);
LIBGLADEUI_API 
GladeWidgetInfo        *glade_widget_write                  (GladeWidget      *widget,
							     GladeInterface   *interface);
LIBGLADEUI_API 
GladeWidget            *glade_widget_read                   (GladeProject     *project,
							     GladeWidgetInfo  *info);
LIBGLADEUI_API 
void                    glade_widget_replace                (GladeWidget      *parent,
							     GObject          *old_object,
							     GObject          *new_object);
LIBGLADEUI_API 
void                    glade_widget_rebuild                (GladeWidget      *glade_widget);
LIBGLADEUI_API 
GladeWidget            *glade_widget_dup                    (GladeWidget      *template);
LIBGLADEUI_API 
void                    glade_widget_copy_properties        (GladeWidget      *widget,
							     GladeWidget      *template);
LIBGLADEUI_API
void                    glade_widget_set_packing_properties (GladeWidget      *widget,
							     GladeWidget      *container);
LIBGLADEUI_API 
GladeProperty          *glade_widget_get_property           (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
GladeProperty          *glade_widget_get_pack_property      (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
void                    glade_widget_show                   (GladeWidget      *widget);
LIBGLADEUI_API 
void                    glade_widget_hide                   (GladeWidget      *widget);
LIBGLADEUI_API 
void                    glade_widget_add_signal_handler     (GladeWidget      *widget,
							     GladeSignal      *signal_handler);
LIBGLADEUI_API 
void                    glade_widget_remove_signal_handler  (GladeWidget      *widget,
							     GladeSignal      *signal_handler);
LIBGLADEUI_API 
void                    glade_widget_change_signal_handler  (GladeWidget      *widget,
							     GladeSignal      *old_signal_handler,
							     GladeSignal      *new_signal_handler);
LIBGLADEUI_API 
GPtrArray *             glade_widget_list_signal_handlers   (GladeWidget      *widget,
							     const gchar      *signal_name);

LIBGLADEUI_API 
gboolean                glade_widget_has_launcher           (GladeWidget      *widget);
LIBGLADEUI_API 
void                    glade_widget_launch_editor          (GladeWidget      *widget);

LIBGLADEUI_API 
gboolean                glade_widget_has_decendant          (GladeWidget      *widget,
							     GType             type);
LIBGLADEUI_API 
GladeWidget            *glade_widget_event_widget           (void);
/*******************************************************************************
                      Project, object property references
 *******************************************************************************/
LIBGLADEUI_API 
void                    glade_widget_project_notify         (GladeWidget      *widget,
							     GladeProject     *project);
LIBGLADEUI_API 
void                    glade_widget_add_prop_ref           (GladeWidget      *widget,
							     GladeProperty    *property);
LIBGLADEUI_API 
void                    glade_widget_remove_prop_ref        (GladeWidget      *widget,
							     GladeProperty    *property);

/*******************************************************************************
                   GladeProperty api convenience wrappers
 *******************************************************************************/
LIBGLADEUI_API 
gboolean                glade_widget_property_get           (GladeWidget      *widget,
							     const gchar      *id_property,
							     ...);
LIBGLADEUI_API 
gboolean                glade_widget_property_set           (GladeWidget      *widget,
							     const gchar      *id_property,
							     ...);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_get      (GladeWidget      *widget,
							     const gchar      *id_property,
							     ...);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_set      (GladeWidget      *widget,
							     const gchar      *id_property,
							     ...);
LIBGLADEUI_API 
gboolean                glade_widget_property_reset         (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_reset    (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
gboolean                glade_widget_property_default       (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_default  (GladeWidget      *widget,
							     const gchar      *id_property);
LIBGLADEUI_API 
gboolean                glade_widget_property_set_sensitive (GladeWidget      *widget,
							     const gchar      *id_property,
							     gboolean          sensitive,
							     const gchar      *reason);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_set_sensitive (GladeWidget      *widget,
								  const gchar      *id_property,
								  gboolean          sensitive,
								  const gchar      *reason);
LIBGLADEUI_API 
gboolean                glade_widget_property_set_enabled   (GladeWidget      *widget,
							     const gchar      *id_property,
							     gboolean          enabled);
LIBGLADEUI_API 
gboolean                glade_widget_pack_property_set_enabled (GladeWidget      *widget,
								const gchar      *id_property,
								gboolean          enabled);

/*******************************************************************************
                                  Accessors
 *******************************************************************************/
LIBGLADEUI_API
void                    glade_widget_set_name		    (GladeWidget      *widget,
							     const gchar      *name);
LIBGLADEUI_API 
G_CONST_RETURN gchar   *glade_widget_get_name               (GladeWidget      *widget);
LIBGLADEUI_API
void                    glade_widget_set_internal	    (GladeWidget      *widget,
							     const gchar      *internal);
LIBGLADEUI_API 
G_CONST_RETURN gchar   *glade_widget_get_internal           (GladeWidget      *widget);
LIBGLADEUI_API
void                    glade_widget_set_object		    (GladeWidget      *gwidget,
							     GObject          *new_object);
LIBGLADEUI_API 
GObject                *glade_widget_get_object             (GladeWidget      *widget);
LIBGLADEUI_API
void                    glade_widget_set_project	    (GladeWidget      *widget,
							     GladeProject     *project);
LIBGLADEUI_API 
GladeProject           *glade_widget_get_project            (GladeWidget      *widget);
LIBGLADEUI_API 
GladeWidgetClass       *glade_widget_get_class              (GladeWidget      *widget);
LIBGLADEUI_API 
GladeWidget            *glade_widget_get_parent             (GladeWidget      *widget);
LIBGLADEUI_API 
void                    glade_widget_set_parent             (GladeWidget      *widget,
							     GladeWidget      *parent);

G_END_DECLS

#endif /* __GLADE_WIDGET_H__ */