glade-property.h 7.91 KB
Newer Older
Jose Maria Celorio's avatar
Jose Maria Celorio committed
1 2 3 4 5 6
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_PROPERTY_H__
#define __GLADE_PROPERTY_H__

G_BEGIN_DECLS

7 8
#define GLADE_TYPE_PROPERTY            (glade_property_get_type())
#define GLADE_PROPERTY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PROPERTY, GladeProperty))
9
#define GLADE_PROPERTY_KLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PROPERTY, GladePropertyKlass))
10
#define GLADE_IS_PROPERTY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROPERTY))
11 12
#define GLADE_IS_PROPERTY_KLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PROPERTY))
#define GLADE_PROPERTY_GET_KLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_PROPERTY, GladePropertyKlass))
13

14
typedef struct _GladePropertyKlass GladePropertyKlass;
Tristan Van Berkom's avatar
Tristan Van Berkom committed
15

Jose Maria Celorio's avatar
Jose Maria Celorio committed
16 17 18 19
/* A GladeProperty is an instance of a GladePropertyClass.
 * There will be one GladePropertyClass for "GtkLabel->label" but one
 * GladeProperty for each GtkLabel in the GladeProject.
 */
20 21
struct _GladeProperty
{
22 23
	GObject             parent_instance;

24
	GladePropertyClass *klass;     /* A pointer to the GladeProperty that this
25 26
					* setting specifies
					*/
27
	GladeWidget        *widget;    /* A pointer to the GladeWidget that this
28 29 30 31 32 33 34 35 36
					* GladeProperty is modifying
					*/
	
	GValue             *value;     /* The value of the property
					*/

	gboolean            sensitive; /* Whether this property is sensitive (if the
					* property is "optional" this takes precedence).
					*/
37 38 39
	gchar              *insensitive_tooltip; /* Tooltip to display when in insensitive state
						  * (used to explain why the property is insensitive)
						  */
40 41 42 43 44 45 46 47 48

	gboolean            enabled;   /* Enabled is a flag that is used for GladeProperties
					* that have the optional flag set to let us know
					* if this widget has this GladeSetting enabled or
					* not. (Like default size, it can be specified or
					* unspecified). This flag also sets the state
					* of the property->input state for the loaded
					* widget.
					*/
49

50 51 52 53 54
	/* Used only for translatable strings. */
	gboolean  i18n_translatable;
	gboolean  i18n_has_context;
	gchar    *i18n_comment;
		
55 56
	gboolean     syncing;    /* Avoid recursion while synchronizing object with value.
				  */
57 58 59
};


60
struct _GladePropertyKlass
61 62 63 64
{
	GObjectClass  parent_class;

	/* Class methods */
65
	GladeProperty *         (* dup)                   (GladeProperty *, GladeWidget *);
66
	gboolean                (* equals_value)          (GladeProperty *, const GValue *);
67
	void                    (* set_value)             (GladeProperty *, const GValue *);
68
	void                    (* get_value)             (GladeProperty *, GValue *);
69
	void                    (* get_default)           (GladeProperty *, GValue *);
70
	void                    (* sync)                  (GladeProperty *);
71
	void                    (* load)                  (GladeProperty *);
72
	gboolean                (* write)                 (GladeProperty *, GladeInterface *, GArray *);
73
	G_CONST_RETURN gchar *  (* get_tooltip)           (GladeProperty *);
74 75

	/* Signals */
76
	void             (* value_changed)         (GladeProperty *, GValue *, GValue *);
77
	void             (* tooltip_changed)       (GladeProperty *, const gchar *);
78
};
Chema Celorio's avatar
Chema Celorio committed
79

80
LIBGLADEUI_API
81
GType                   glade_property_get_type              (void) G_GNUC_CONST;
82
LIBGLADEUI_API
83
GladeProperty          *glade_property_new                   (GladePropertyClass *klass,
84
							      GladeWidget        *widget,
85
							      GValue             *value);
86
LIBGLADEUI_API
87
GladeProperty          *glade_property_dup                   (GladeProperty      *template_prop,
88 89 90 91
							      GladeWidget        *widget);
LIBGLADEUI_API
void                    glade_property_reset                 (GladeProperty      *property);
LIBGLADEUI_API
92 93
void                    glade_property_original_reset    (GladeProperty      *property);
LIBGLADEUI_API
94 95
gboolean                glade_property_default               (GladeProperty      *property);
LIBGLADEUI_API
96 97
gboolean                glade_property_original_default  (GladeProperty      *property);
LIBGLADEUI_API
98
gboolean                glade_property_equals_value          (GladeProperty      *property, 
99
							      const GValue       *value);
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
LIBGLADEUI_API
gboolean                glade_property_equals                (GladeProperty      *property, 
							      ...);
LIBGLADEUI_API
void                    glade_property_set_value             (GladeProperty      *property, 
							      const GValue       *value);
LIBGLADEUI_API
void                    glade_property_set_va_list           (GladeProperty      *property,
							      va_list             vl);
LIBGLADEUI_API
void                    glade_property_set                   (GladeProperty      *property,
							      ...);
LIBGLADEUI_API
void                    glade_property_get_value             (GladeProperty      *property, 
							      GValue             *value);
LIBGLADEUI_API
void                    glade_property_get_default           (GladeProperty      *property, 
							      GValue             *value);
LIBGLADEUI_API
void                    glade_property_get_va_list           (GladeProperty      *property,
							      va_list             vl);
LIBGLADEUI_API
void                    glade_property_get                   (GladeProperty      *property, 
							      ...);
LIBGLADEUI_API
Tristan Van Berkom's avatar
Tristan Van Berkom committed
125 126 127 128 129 130
void                    glade_property_add_object            (GladeProperty      *property,
							      GObject            *object);
LIBGLADEUI_API
void                    glade_property_remove_object         (GladeProperty      *property,
							      GObject            *object);
LIBGLADEUI_API
131 132
void                    glade_property_sync                  (GladeProperty      *property);
LIBGLADEUI_API
133 134
void                    glade_property_load                  (GladeProperty      *property);
LIBGLADEUI_API
Tristan Van Berkom's avatar
Tristan Van Berkom committed
135 136 137 138 139 140
GValue                 *glade_property_read                  (GladeProperty      *property,
							      GladePropertyClass *pclass,
							      GladeProject       *project,
							      gpointer            info,
							      gboolean            free_value);
LIBGLADEUI_API
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
gboolean                glade_property_write                 (GladeProperty      *property, 
							      GladeInterface     *interface, 
							      GArray             *props);
LIBGLADEUI_API
G_CONST_RETURN gchar   *glade_property_get_tooltip           (GladeProperty      *property);
LIBGLADEUI_API
void                    glade_property_set_sensitive         (GladeProperty      *property,
							      gboolean            sensitive,
							      const gchar        *reason);
LIBGLADEUI_API
gboolean                glade_property_get_sensitive         (GladeProperty      *property);
LIBGLADEUI_API
void                    glade_property_set_enabled           (GladeProperty      *property,
							      gboolean            enabled);
LIBGLADEUI_API
gboolean                glade_property_get_enabled           (GladeProperty      *property);

LIBGLADEUI_API
void                    glade_property_i18n_set_comment      (GladeProperty      *property, 
							      const gchar        *str);
LIBGLADEUI_API
G_CONST_RETURN gchar   *glade_property_i18n_get_comment      (GladeProperty      *property);
LIBGLADEUI_API
void                    glade_property_i18n_set_translatable (GladeProperty      *property,
							      gboolean            translatable);
LIBGLADEUI_API
gboolean                glade_property_i18n_get_translatable (GladeProperty      *property);
LIBGLADEUI_API
void                    glade_property_i18n_set_has_context  (GladeProperty      *property,
							      gboolean            has_context);
LIBGLADEUI_API
gboolean                glade_property_i18n_get_has_context  (GladeProperty      *property);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
173

174 175 176 177 178 179 180
LIBGLADEUI_API
void                    glade_property_push_superuser        (void);
LIBGLADEUI_API
void                    glade_property_pop_superuser         (void);
LIBGLADEUI_API
gboolean                glade_property_superuser             (void);

Jose Maria Celorio's avatar
Jose Maria Celorio committed
181 182 183
G_END_DECLS

#endif /* __GLADE_PROPERTY_H__ */