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

5 6
#include <glib-object.h>

Jose Maria Celorio's avatar
Jose Maria Celorio committed
7 8
G_BEGIN_DECLS

9 10
#define GLADE_TYPE_PROPERTY            (glade_property_get_type())
#define GLADE_PROPERTY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PROPERTY, GladeProperty))
11
#define GLADE_PROPERTY_KLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PROPERTY, GladePropertyKlass))
12
#define GLADE_IS_PROPERTY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROPERTY))
13 14
#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))
15

16
typedef struct _GladePropertyKlass GladePropertyKlass;
Tristan Van Berkom's avatar
Tristan Van Berkom committed
17

18
typedef enum {
19 20 21 22
	GLADE_STATE_NORMAL              = 0,
	GLADE_STATE_CHANGED             = (1 << 0),
	GLADE_STATE_UNSUPPORTED         = (1 << 1),
	GLADE_STATE_SUPPORT_DISABLED    = (1 << 2)
23 24
} GladePropertyState;

Jose Maria Celorio's avatar
Jose Maria Celorio committed
25 26 27 28
/* 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.
 */
29 30
struct _GladeProperty
{
31 32
	GObject             parent_instance;

33
	GladePropertyClass *klass;     /* A pointer to the GladeProperty that this
34 35
					* setting specifies
					*/
36
	GladeWidget        *widget;    /* A pointer to the GladeWidget that this
37 38
					* GladeProperty is modifying
					*/
39 40 41

	GladePropertyState  state;     /* Current property state, used by editing widgets.
					*/
42 43 44 45 46 47 48
	
	GValue             *value;     /* The value of the property
					*/

	gboolean            sensitive; /* Whether this property is sensitive (if the
					* property is "optional" this takes precedence).
					*/
49
	gchar              *insensitive_tooltip; /* Tooltip to display when in insensitive state
50 51
						  * (used to explain why the property is 
						  *  insensitive)
52
						  */
53

54 55 56 57 58
	gchar              *support_warning; /* Tooltip to display when the property
					      * has format problems
					      * (used to explain why the property is 
					      *  insensitive)
					      */
59 60 61
	gboolean            support_disabled; /* Whether this property is disabled due
					       * to format conflicts
					       */
62

63 64
	gboolean            enabled;   /* Enabled is a flag that is used for GladeProperties
					* that have the optional flag set to let us know
65
					* if this widget has this setting enabled or
66 67 68 69 70
					* 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.
					*/
71

72 73 74 75 76 77 78
	gboolean            save_always; /* Used to make a special case exception and always
					  * save this property regardless of what the default
					  * value is (used for some special cases like properties
					  * that are assigned initial values in composite widgets
					  * or derived widget code).
					  */

79 80 81 82 83
	/* Used only for translatable strings. */
	gboolean  i18n_translatable;
	gboolean  i18n_has_context;
	gchar    *i18n_comment;
		
84 85
	gboolean     syncing;    /* Avoid recursion while synchronizing object with value.
				  */
86 87 88
};


89
struct _GladePropertyKlass
90 91 92 93
{
	GObjectClass  parent_class;

	/* Class methods */
94
	GladeProperty *         (* dup)                   (GladeProperty *, GladeWidget *);
95
	gboolean                (* equals_value)          (GladeProperty *, const GValue *);
96
	gboolean                (* set_value)             (GladeProperty *, const GValue *);
97
	void                    (* get_value)             (GladeProperty *, GValue *);
98
	void                    (* sync)                  (GladeProperty *);
99
	void                    (* load)                  (GladeProperty *);
100 101

	/* Signals */
102
	void             (* value_changed)         (GladeProperty *, GValue *, GValue *);
103 104
	void             (* tooltip_changed)       (GladeProperty *, const gchar *, 
						    const gchar   *, const gchar *);
105
};
Chema Celorio's avatar
Chema Celorio committed
106

107

108
GType                   glade_property_get_type              (void) G_GNUC_CONST;
109

110
GladeProperty          *glade_property_new                   (GladePropertyClass *klass,
111
							      GladeWidget        *widget,
112
							      GValue             *value);
113

114
GladeProperty          *glade_property_dup                   (GladeProperty      *template_prop,
115
							      GladeWidget        *widget);
116

117
void                    glade_property_reset                 (GladeProperty      *property);
118

119
void                    glade_property_original_reset        (GladeProperty      *property);
120

121
gboolean                glade_property_default               (GladeProperty      *property);
122

123
gboolean                glade_property_original_default      (GladeProperty      *property);
124

125
gboolean                glade_property_equals_value          (GladeProperty      *property, 
126
							      const GValue       *value);
127

128 129
gboolean                glade_property_equals                (GladeProperty      *property, 
							      ...);
130

131
gboolean                glade_property_set_value             (GladeProperty      *property, 
132
							      const GValue       *value);
133

134
gboolean                glade_property_set_va_list           (GladeProperty      *property,
135
							      va_list             vl);
136

137
gboolean                glade_property_set                   (GladeProperty      *property,
138
							      ...);
139

140 141
void                    glade_property_get_value             (GladeProperty      *property, 
							      GValue             *value);
142

143 144
void                    glade_property_get_default           (GladeProperty      *property, 
							      GValue             *value);
145

146 147
void                    glade_property_get_va_list           (GladeProperty      *property,
							      va_list             vl);
148

149 150
void                    glade_property_get                   (GladeProperty      *property, 
							      ...);
151

Tristan Van Berkom's avatar
Tristan Van Berkom committed
152 153
void                    glade_property_add_object            (GladeProperty      *property,
							      GObject            *object);
154

Tristan Van Berkom's avatar
Tristan Van Berkom committed
155 156
void                    glade_property_remove_object         (GladeProperty      *property,
							      GObject            *object);
157

158
void                    glade_property_sync                  (GladeProperty      *property);
159

160
void                    glade_property_load                  (GladeProperty      *property);
161

162
void                    glade_property_read                  (GladeProperty      *property,
Tristan Van Berkom's avatar
Tristan Van Berkom committed
163
							      GladeProject       *project,
164
							      GladeXmlNode       *node);
165

166 167 168
void                    glade_property_write                 (GladeProperty      *property,	
							      GladeXmlContext    *context,
							      GladeXmlNode       *node);
169

170 171 172
void                    glade_property_set_sensitive         (GladeProperty      *property,
							      gboolean            sensitive,
							      const gchar        *reason);
173

174
void                    glade_property_set_support_warning   (GladeProperty      *property,
175
							      gboolean            disable,
176 177
							      const gchar        *reason);

178
gboolean                glade_property_get_sensitive         (GladeProperty      *property);
179

180

181 182
void                    glade_property_set_save_always       (GladeProperty      *property,
							      gboolean            setting);
183

184 185
gboolean                glade_property_get_save_always       (GladeProperty      *property);

186

187 188
void                    glade_property_set_enabled           (GladeProperty      *property,
							      gboolean            enabled);
189

190 191
gboolean                glade_property_get_enabled           (GladeProperty      *property);

192

193 194
void                    glade_property_i18n_set_comment      (GladeProperty      *property, 
							      const gchar        *str);
195

196
G_CONST_RETURN gchar   *glade_property_i18n_get_comment      (GladeProperty      *property);
197

198 199
void                    glade_property_i18n_set_translatable (GladeProperty      *property,
							      gboolean            translatable);
200

201
gboolean                glade_property_i18n_get_translatable (GladeProperty      *property);
202

203 204
void                    glade_property_i18n_set_has_context  (GladeProperty      *property,
							      gboolean            has_context);
205

206
gboolean                glade_property_i18n_get_has_context  (GladeProperty      *property);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
207

208

209
void                    glade_property_push_superuser        (void);
210

211
void                    glade_property_pop_superuser         (void);
212

213 214
gboolean                glade_property_superuser             (void);

Jose Maria Celorio's avatar
Jose Maria Celorio committed
215 216 217
G_END_DECLS

#endif /* __GLADE_PROPERTY_H__ */