glade-widget.h 22.9 KB
Newer Older
Jose Maria Celorio's avatar
Jose Maria Celorio committed
1 2 3
#ifndef __GLADE_WIDGET_H__
#define __GLADE_WIDGET_H__

4
#include <gladeui/glade-widget-adaptor.h>
5
#include <gladeui/glade-widget-action.h>
6 7 8
#include <gladeui/glade-signal.h>
#include <gladeui/glade-property.h>

9 10
#include <glib.h>
#include <glib-object.h>
Tristan Van Berkom's avatar
Tristan Van Berkom committed
11

Jose Maria Celorio's avatar
Jose Maria Celorio committed
12
G_BEGIN_DECLS
13 14 15
 
#define GLADE_TYPE_WIDGET            (glade_widget_get_type ())
#define GLADE_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_WIDGET, GladeWidget))
16
#define GLADE_WIDGET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_WIDGET, GladeWidgetClass))
17
#define GLADE_IS_WIDGET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_WIDGET))
18 19
#define GLADE_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_WIDGET))
#define GLADE_WIDGET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_WIDGET, GladeWidgetClass))
Jose Maria Celorio's avatar
Jose Maria Celorio committed
20

21 22
typedef struct _GladeWidgetClass   GladeWidgetClass;
typedef struct _GladeWidgetPrivate GladeWidgetPrivate;
Paolo Borelli's avatar
Paolo Borelli committed
23 24 25

struct _GladeWidget
{
26
  GInitiallyUnowned parent_instance;
Jose Maria Celorio's avatar
Jose Maria Celorio committed
27

28
  GladeWidgetPrivate *priv;
Jose Maria Celorio's avatar
Jose Maria Celorio committed
29 30
};

31
struct _GladeWidgetClass
32
{
33
  GInitiallyUnownedClass parent_class;
34

35 36 37
  void         (*add_child)               (GladeWidget *, GladeWidget *, gboolean);
  void         (*remove_child)            (GladeWidget *, GladeWidget *);
  void         (*replace_child)           (GladeWidget *, GObject *, GObject *);
38

39 40 41
  void         (*add_signal_handler)      (GladeWidget *, GladeSignal *);
  void         (*remove_signal_handler)   (GladeWidget *, GladeSignal *);
  void         (*change_signal_handler)   (GladeWidget *, GladeSignal *);
42

43 44 45 46 47 48 49 50 51 52 53 54 55 56
  gint         (*button_press_event)      (GladeWidget *, GdkEvent *);
  gint         (*button_release_event)    (GladeWidget *, GdkEvent *);
  gint         (*motion_notify_event)     (GladeWidget *, GdkEvent *);

  gboolean     (*event)                   (GladeWidget *, GdkEvent *);

  void   (* glade_reserved1)   (void);
  void   (* glade_reserved2)   (void);
  void   (* glade_reserved3)   (void);
  void   (* glade_reserved4)   (void);
  void   (* glade_reserved5)   (void);
  void   (* glade_reserved6)   (void);
  void   (* glade_reserved7)   (void);
  void   (* glade_reserved8)   (void);
57
};
Jose Maria Celorio's avatar
Jose Maria Celorio committed
58

59 60 61 62 63
/* Nameless widgets in fact have a name, except
 * that they are prefixed with this prefix
 */
#define GLADE_UNNAMED_PREFIX   "__glade_unnamed_"

64 65 66 67
#define IS_GLADE_WIDGET_EVENT(event)       \
        ((event) == GDK_BUTTON_PRESS ||    \
         (event) == GDK_BUTTON_RELEASE ||  \
         (event) == GDK_MOTION_NOTIFY)
68

69 70 71
/*******************************************************************************
                                  General api
 *******************************************************************************/
72

73
GType                   glade_widget_get_type               (void);
74

Tristan Van Berkom's avatar
Tristan Van Berkom committed
75
GladeWidget            *glade_widget_get_from_gobject       (gpointer          object);
76

77
gboolean                glade_widget_add_verify             (GladeWidget      *widget,
78 79
                                                             GladeWidget      *child,
                                                             gboolean          user_feedback);
80

81
void                    glade_widget_add_child              (GladeWidget      *parent,
82 83
                                                             GladeWidget      *child,
                                                             gboolean          at_mouse);
84

85
void                    glade_widget_remove_child           (GladeWidget      *parent,
86
                                                             GladeWidget      *child);
87

88
void                    glade_widget_replace                (GladeWidget      *parent,
89 90
                                                             GObject          *old_object,
                                                             GObject          *new_object);
91 92 93
 
void                    glade_widget_rebuild                (GladeWidget      *gwidget);
 
94
GladeWidget            *glade_widget_dup                    (GladeWidget      *template_widget,
95
                                                             gboolean          exact);
96 97 98

GList                  *glade_widget_get_signal_list        (GladeWidget      *widget);

99
void                    glade_widget_copy_signals           (GladeWidget      *widget,
100
                                                             GladeWidget      *template_widget);
101
void                    glade_widget_copy_properties        (GladeWidget      *widget,
102 103 104
                                                             GladeWidget      *template_widget,
                                                             gboolean          copy_parentless,
                                                             gboolean          exact);
105

106
void                    glade_widget_set_packing_properties (GladeWidget      *widget,
107
                                                             GladeWidget      *container);
108 109 110 111

GList                  *glade_widget_get_properties         (GladeWidget      *widget);
GList                  *glade_widget_get_packing_properties (GladeWidget      *widget);

112
GladeProperty          *glade_widget_get_property           (GladeWidget      *widget,
113
                                                             const gchar      *id_property);
114
 
115
GladeProperty          *glade_widget_get_pack_property      (GladeWidget      *widget,
116
                                                             const gchar      *id_property);
117

118
GList                  *glade_widget_dup_properties         (GladeWidget      *dest_widget,
119
                                                             GList            *template_props,
120
                                                             gboolean          as_load,
121 122
                                                             gboolean          copy_parentless,
                                                             gboolean          exact);
123

124
void                    glade_widget_remove_property        (GladeWidget      *widget,
125
                                                             const gchar      *id_property);
126
 
127
void                    glade_widget_show                   (GladeWidget      *widget);
128
 
129
void                    glade_widget_hide                   (GladeWidget      *widget);
130
 
131
void                    glade_widget_add_signal_handler     (GladeWidget      *widget,
132
                                                             const GladeSignal      *signal_handler);
133
 
134
void                    glade_widget_remove_signal_handler  (GladeWidget      *widget,
135
                                                             const GladeSignal      *signal_handler);
136
 
137
void                    glade_widget_change_signal_handler  (GladeWidget      *widget,
138 139
                                                             const GladeSignal      *old_signal_handler,
                                                             const GladeSignal      *new_signal_handler);
140
 
141
GPtrArray *             glade_widget_list_signal_handlers   (GladeWidget      *widget,
142
                                                             const gchar      *signal_name);
143
 
Tristan Van Berkom's avatar
Tristan Van Berkom committed
144
gboolean                glade_widget_has_decendant          (GladeWidget      *widget,
145
                                                             GType             type);
146
 
147
gboolean                glade_widget_event                  (GladeWidget      *gwidget,
148
                                                             GdkEvent         *event);
149

150
gboolean                glade_widget_placeholder_relation   (GladeWidget      *parent, 
151
                                                             GladeWidget      *widget);
152

153
GladeWidgetAction      *glade_widget_get_action             (GladeWidget *widget,
154
                                                             const gchar *action_path);
155

156
GladeWidgetAction      *glade_widget_get_pack_action        (GladeWidget *widget,
157
                                                             const gchar *action_path);
158

159 160 161
GList                  *glade_widget_get_actions            (GladeWidget *widget);
GList                  *glade_widget_get_pack_actions       (GladeWidget *widget);

162
gboolean                glade_widget_set_action_sensitive   (GladeWidget *widget,
163 164
                                                             const gchar *action_path,
                                                             gboolean     sensitive);
165 166

gboolean                glade_widget_set_pack_action_sensitive (GladeWidget *widget,
167 168
                                                                const gchar *action_path,
                                                                gboolean     sensitive);
169

170
gboolean                glade_widget_set_action_visible     (GladeWidget *widget,
171
                                                             const gchar *action_path,
172
                                                             gboolean     visible);
173

174
gboolean                glade_widget_set_pack_action_visible (GladeWidget *widget,
175
                                                              const gchar *action_path,
176
                                                              gboolean     visible);
177

178
void                    glade_widget_write                  (GladeWidget     *widget,
179 180
                                                             GladeXmlContext *context,
                                                             GladeXmlNode    *node);
181

182
void                    glade_widget_write_child            (GladeWidget     *widget,
183 184 185
                                                             GladeWidget     *child,
                                                             GladeXmlContext *context,
                                                             GladeXmlNode    *node);
186

187
void                    glade_widget_write_signals          (GladeWidget     *widget,
188 189
                                                             GladeXmlContext *context,
                                                             GladeXmlNode    *node);
190

191
void                    glade_widget_write_placeholder      (GladeWidget     *parent,
192 193 194 195
                                                             GObject         *object,
                                                             GladeXmlContext *context,
                                                             GladeXmlNode    *node);
        
196
GladeWidget            *glade_widget_read                   (GladeProject     *project,
197 198 199
                                                             GladeWidget      *parent,
                                                             GladeXmlNode     *node,
                                                             const gchar      *internal);
200

201
void                    glade_widget_read_child             (GladeWidget      *widget,
202
                                                             GladeXmlNode     *node);
203

204 205

void                    glade_widget_write_special_child_prop (GladeWidget     *parent, 
206 207 208
                                                               GObject         *object,
                                                               GladeXmlContext *context,
                                                               GladeXmlNode    *node);
209

210
void                    glade_widget_set_child_type_from_node (GladeWidget         *parent,
211 212
                                                               GObject             *child,
                                                               GladeXmlNode        *node);
213

214
GladeEditorProperty    *glade_widget_create_editor_property (GladeWidget      *widget,
215 216 217
                                                             const gchar      *property,
                                                             gboolean          packing,
                                                             gboolean          use_command);
218

219
gchar                  *glade_widget_generate_path_name     (GladeWidget      *widget);
220 221

gboolean                glade_widget_is_ancestor            (GladeWidget      *widget,
222
                                                             GladeWidget      *ancestor);
223 224

G_DEPRECATED
225
gboolean                glade_widget_depends                (GladeWidget      *widget,
226
                                                             GladeWidget      *other);
227

228
G_DEPRECATED
229 230
GdkDevice              *glade_widget_get_device_from_event  (GdkEvent *event);

231
void                    glade_widget_ensure_name            (GladeWidget      *widget,
232 233
                                                             GladeProject     *project,
                                                             gboolean          use_command);
234

235 236 237
/*******************************************************************************
                      Project, object property references
 *******************************************************************************/
238
 
239
void                    glade_widget_add_prop_ref           (GladeWidget      *widget,
240
                                                             GladeProperty    *property);
241
 
242
void                    glade_widget_remove_prop_ref        (GladeWidget      *widget,
243
                                                             GladeProperty    *property);
244

245
GList                  *glade_widget_list_prop_refs         (GladeWidget      *widget);
246
gboolean                glade_widget_has_prop_refs          (GladeWidget      *widget);
247

248 249
GladeProperty          *glade_widget_get_parentless_widget_ref (GladeWidget  *widget);

250 251 252

GList                  *glade_widget_get_parentless_reffed_widgets (GladeWidget *widget);

253 254 255
/*******************************************************************************
            Functions that deal with properties on the runtime object
 *******************************************************************************/
256

257
void                    glade_widget_object_set_property    (GladeWidget      *widget,
258 259
                                                             const gchar      *property_name,
                                                             const GValue     *value);
260

261
void                    glade_widget_object_get_property    (GladeWidget      *widget,
262 263
                                                             const gchar      *property_name,
                                                             GValue           *value);
264

265
void                    glade_widget_child_set_property     (GladeWidget      *widget,
266 267 268
                                                             GladeWidget      *child,
                                                             const gchar      *property_name,
                                                             const GValue     *value);
269

270
void                    glade_widget_child_get_property     (GladeWidget      *widget,
271 272 273
                                                             GladeWidget      *child,
                                                             const gchar      *property_name,
                                                             GValue           *value);
274

275 276 277
/*******************************************************************************
                   GladeProperty api convenience wrappers
 *******************************************************************************/
278
 
279
gboolean                glade_widget_property_get           (GladeWidget      *widget,
280 281
                                                             const gchar      *id_property,
                                                             ...);
282
 
283
gboolean                glade_widget_property_set           (GladeWidget      *widget,
284 285
                                                             const gchar      *id_property,
                                                             ...);
286
 
287
gboolean                glade_widget_pack_property_get      (GladeWidget      *widget,
288 289
                                                             const gchar      *id_property,
                                                             ...);
290
 
291
gboolean                glade_widget_pack_property_set      (GladeWidget      *widget,
292 293
                                                             const gchar      *id_property,
                                                             ...);
294
 
295
gboolean                glade_widget_property_reset         (GladeWidget      *widget,
296
                                                             const gchar      *id_property);
297
 
298
gboolean                glade_widget_pack_property_reset    (GladeWidget      *widget,
299
                                                             const gchar      *id_property);
300
 
301
gboolean                glade_widget_property_default       (GladeWidget      *widget,
302
                                                             const gchar      *id_property);
303
 
304
gboolean                glade_widget_property_original_default (GladeWidget      *widget,
305
                                                                const gchar      *id_property);
306
 
307
gboolean                glade_widget_pack_property_default  (GladeWidget      *widget,
308
                                                             const gchar      *id_property);
309
 
310
gboolean                glade_widget_property_set_sensitive (GladeWidget      *widget,
311 312 313
                                                             const gchar      *id_property,
                                                             gboolean          sensitive,
                                                             const gchar      *reason);
314
 
315
gboolean                glade_widget_pack_property_set_sensitive (GladeWidget      *widget,
316 317 318
                                                                  const gchar      *id_property,
                                                                  gboolean          sensitive,
                                                                  const gchar      *reason);
319
 
320
gboolean                glade_widget_property_set_enabled   (GladeWidget      *widget,
321 322
                                                             const gchar      *id_property,
                                                             gboolean          enabled);
323
 
324
gboolean                glade_widget_pack_property_set_enabled (GladeWidget      *widget,
325 326
                                                                const gchar      *id_property,
                                                                gboolean          enabled);
327

328
 
329
gboolean                glade_widget_property_set_save_always (GladeWidget      *widget,
330 331
                                                               const gchar      *id_property,
                                                               gboolean          setting);
332
 
333
gboolean                glade_widget_pack_property_set_save_always (GladeWidget      *widget,
334 335
                                                                    const gchar      *id_property,
                                                                    gboolean          setting);
336

337
gchar                  *glade_widget_property_string        (GladeWidget      *widget,
338 339
                                                             const gchar      *id_property,
                                                             const GValue     *value);
340 341 342


gchar                  *glade_widget_pack_property_string   (GladeWidget      *widget,
343 344
                                                             const gchar      *id_property,
                                                             const GValue     *value);
345

346 347 348
/*******************************************************************************
                                  Accessors
 *******************************************************************************/
349

350 351
void                    glade_widget_set_name               (GladeWidget      *widget,
                                                             const gchar      *name);
352
 
353
G_CONST_RETURN gchar   *glade_widget_get_name               (GladeWidget      *widget);
354 355
G_CONST_RETURN gchar   *glade_widget_get_display_name       (GladeWidget      *widget);
gboolean                glade_widget_has_name               (GladeWidget      *widget);
356

357
void                    glade_widget_set_is_composite       (GladeWidget      *widget,
358
                                                             gboolean          composite);
359 360 361

gboolean                glade_widget_get_is_composite       (GladeWidget      *widget);

362 363
void                    glade_widget_set_internal           (GladeWidget      *widget,
                                                             const gchar      *internal);
364
 
365
G_CONST_RETURN gchar   *glade_widget_get_internal           (GladeWidget      *widget);
366

367
GObject                *glade_widget_get_object             (GladeWidget      *widget);
368

369 370
void                    glade_widget_set_project            (GladeWidget      *widget,
                                                             GladeProject     *project);
371
 
372
GladeProject           *glade_widget_get_project            (GladeWidget      *widget);
373 374

void                    glade_widget_set_in_project         (GladeWidget      *widget,
375
                                                             gboolean          in_project);
376 377
gboolean                glade_widget_in_project             (GladeWidget      *widget);

378
GladeWidgetAdaptor     *glade_widget_get_adaptor            (GladeWidget      *widget);
379
 
380
GladeWidget            *glade_widget_get_parent             (GladeWidget      *widget);
381
 
382
void                    glade_widget_set_parent             (GladeWidget      *widget,
383
                                                             GladeWidget      *parent);
384

385
GList                  *glade_widget_get_children           (GladeWidget* widget);
386

387
GladeWidget            *glade_widget_get_toplevel           (GladeWidget      *widget);
388
 
389
gboolean                glade_widget_superuser              (void);
390
 
391
void                    glade_widget_push_superuser         (void);
392
 
393
void                    glade_widget_pop_superuser          (void);
394

395
void                    glade_widget_verify                 (GladeWidget      *widget);
396
void                    glade_widget_set_support_warning    (GladeWidget      *widget,
397
                                                             const gchar      *warning);
398
G_CONST_RETURN gchar   *glade_widget_support_warning        (GladeWidget      *widget);
399

400
void                    glade_widget_lock                   (GladeWidget      *widget,
401
                                                             GladeWidget      *locked);
402
void                    glade_widget_unlock                 (GladeWidget      *widget);
403

404 405 406 407
GladeWidget            *glade_widget_get_locker             (GladeWidget      *widget);

GList                  *glade_widget_list_locked_widgets    (GladeWidget      *widget);

408 409
void                    glade_widget_support_changed        (GladeWidget      *widget);

410 411
GtkTreeModel           *glade_widget_get_signal_model       (GladeWidget      *widget);

412
GladeWidget            *glade_widget_find_child             (GladeWidget *widget,
413
                                                             const gchar *name);
414

Jose Maria Celorio's avatar
Jose Maria Celorio committed
415 416
G_END_DECLS

417
#endif /* __GLADE_WIDGET_H__ */