summaryrefslogtreecommitdiff
path: root/src/glade-widget-class.h
blob: 779fc068d6caf8715a761e5cdbe480ba2a7d1abd (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_WIDGET_CLASS_H__
#define __GLADE_WIDGET_CLASS_H__

#include <gmodule.h>

G_BEGIN_DECLS

typedef enum {
	GLADE_TOPLEVEL        = 1 << 2,
	GLADE_ADD_PLACEHOLDER = 1 << 3,
} GladeWidgetClassFlags;

#define GLADE_WIDGET_CLASS(gwc) ((GladeWidgetClass *) gwc)
#define GLADE_IS_WIDGET_CLASS(gwc) (gwc != NULL)

#define GLADE_WIDGET_FLAGS(gw)           ((GLADE_WIDGET(gw)->class)->flags)
#define GLADE_WIDGET_IS_TOPLEVEL(gw)     ((GLADE_WIDGET_FLAGS(gw) & GLADE_TOPLEVEL) != 0)
#define GLADE_WIDGET_ADD_PLACEHOLDER(gw) ((GLADE_WIDGET_FLAGS(gw) & GLADE_ADD_PLACEHOLDER) != 0)

#define GLADE_WIDGET_CLASS_FLAGS(gwc)           ((GLADE_WIDGET_CLASS(gwc)->flags))
#define GLADE_WIDGET_CLASS_TOPLEVEL(gwc)        ((GLADE_WIDGET_CLASS_FLAGS(gwc) & GLADE_TOPLEVEL) != 0)
#define GLADE_WIDGET_CLASS_ADD_PLACEHOLDER(gwc) ((GLADE_WIDGET_CLASS_FLAGS(gwc) & GLADE_ADD_PLACEHOLDER) != 0)

#define GLADE_WIDGET_CLASS_SET_FLAGS(gwc,flag)	  G_STMT_START{ (GLADE_WIDGET_CLASS_FLAGS (gwc) |= (flag)); }G_STMT_END
#define GLADE_WIDGET_CLASS_UNSET_FLAGS(gwc,flag)  G_STMT_START{ (GLADE_WIDGET_CLASS_FLAGS (gwc) &= ~(flag)); }G_STMT_END

/* GladeWidgetClass contains all the information we need regarding an widget
 * type. It is also used to store information that has been loaded to memory
 * for that object like the icon/mask.
 */
struct _GladeWidgetClass
{
	GType type;          /* GType of the widget */

	gchar *name;         /* Name of the widget, for example GtkButton */
	gchar *xml_file;     /* Name of the xml file for this type without a path */

	GtkWidget *icon;     /* The GtkImage icon for the widget */

	gchar *generic_name; /* Use to generate names of new widgets, for
			      * example "button" so that we generate button1,
			      * button2, buttonX ..
			      */

	gint flags;          /* See GladeWidgetClassFlags above */

	GList *properties;   /* List of GladePropertyClass objects.
			      * [see glade-property.h ] this list contains
			      * properties about the widget that we are going
			      * to modify. Like "title", "label", "rows" .
			      * Each property creates an input in the propety
			      * editor.
			      */

	GList *signals;     /* List of GladeWidgetClassSignal objects */

	GList *child_properties;   /* List of GladePropertyClass objects
				    * representing child_properties of a
				    * GtkContainer (the list is empty if the
				    * class isn't a container).
				    * Note that the actual GladeProperty
				    * corresponding to each class end up
				    * in the packing_properties list of
				    * each _child_ of the container and thus
				    * are edited when the _child_ is selected.
				    */

	GModule *module;	/* Module with the (optional) special functions
				 * needed for placeholder_replace, post_create_function
				 * and the set & get functions of the properties
				 * of this class */

	void (*placeholder_replace) (GtkWidget *current,
				     GtkWidget *new,
				     GtkWidget *container);

	void (*post_create_function) (GObject *gobject);

	void (*fill_empty) (GtkWidget *widget);

	gboolean in_palette;
};

/* GladeWidgetClassSignal contains all the info we need for a given signal, such as
 * the signal name, and maybe more in the future 
 */
struct _GladeWidgetClassSignal
{
	gchar *name;         /* Name of the signal, eg clicked */
	gchar *type;         /* Name of the object class that this signal belongs to
			      * eg GtkButton */
};

GladeWidgetClass *glade_widget_class_new (const char *name, const char *generic_name, const char *base_filename, const char *base_library);
GladeWidgetClass *glade_widget_class_new_from_node (GladeXmlNode *node);
void glade_widget_class_free (GladeWidgetClass *widget_class);
GladeWidgetClass *glade_widget_class_get_by_name (const char *name);

const gchar *glade_widget_class_get_name (GladeWidgetClass *class);
GType 	     glade_widget_class_get_type (GladeWidgetClass *class);
gboolean     glade_widget_class_has_queries (GladeWidgetClass *class);

gboolean     glade_widget_class_is (GladeWidgetClass *class, const char *name);

void        glade_widget_class_dump_param_specs (GladeWidgetClass *class);
gboolean    glade_widget_class_has_property (GladeWidgetClass *class, const gchar *name);


G_END_DECLS

#endif /* __GLADE_WIDGET_CLASS_H__ */