summaryrefslogtreecommitdiff
path: root/gladeui/glade-command.h
blob: 44a5f09a72a03ca3b70d17ee4781f26c8eec484e (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
#ifndef __GLADE_COMMAND_H__
#define __GLADE_COMMAND_H__

#include <gladeui/glade-placeholder.h>
#include <gladeui/glade-widget.h>
#include <gladeui/glade-signal.h>
#include <gladeui/glade-property.h>
#include <gladeui/glade-project.h>
#include <glib-object.h>

G_BEGIN_DECLS


#define GLADE_TYPE_COMMAND            (glade_command_get_type ())
#define GLADE_COMMAND(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_COMMAND, GladeCommand))
#define GLADE_COMMAND_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_COMMAND, GladeCommandClass))
#define GLADE_IS_COMMAND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_COMMAND))
#define GLADE_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_COMMAND))
#define GLADE_COMMAND_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_COMMAND, GladeCommandClass))

typedef struct _GladeCommand        GladeCommand;
typedef struct _GladeCommandClass   GladeCommandClass;
typedef struct _GladeCommandPrivate GladeCommandPrivate;
typedef struct _GCSetPropData       GCSetPropData;

/**
 * GCSetPropData
 * @property: A #GladeProperty to set
 * @new_value: The new #GValue to assign to @property
 * @old_value: The old #GValue of @property
 *
 * #GladeProperties can be set in a list as one command,
 * for Undo purposes; we store the list of #GCSetPropData with
 * their old and new #GValue.
 */
struct _GCSetPropData {
  GladeProperty *property;
  GValue        *new_value;
  GValue        *old_value;
};

struct _GladeCommand
{
  GObject parent;

  GladeCommandPrivate *priv;
};

struct _GladeCommandClass
{
  GObjectClass parent_class;

  gboolean (* execute)     (GladeCommand *this_cmd);
  gboolean (* undo)        (GladeCommand *this_cmd);
  gboolean (* unifies)     (GladeCommand *this_cmd, GladeCommand *other_cmd);
  void     (* collapse)    (GladeCommand *this_cmd, GladeCommand *other_cmd);

  void   (* glade_reserved1)   (void);
  void   (* glade_reserved2)   (void);
  void   (* glade_reserved3)   (void);
  void   (* glade_reserved4)   (void);
};



GType                 glade_command_get_type             (void);

void                  glade_command_push_group           (const gchar       *fmt,
							  ...) G_GNUC_PRINTF (1, 2);
void                  glade_command_pop_group            (void);
gint                  glade_command_get_group_depth      (void);

G_CONST_RETURN gchar *glade_command_description          (GladeCommand      *command);
gint                  glade_command_group_id             (GladeCommand      *command);
gboolean              glade_command_execute              (GladeCommand      *command);
gboolean              glade_command_undo                 (GladeCommand      *command);
gboolean              glade_command_unifies              (GladeCommand      *command,
							  GladeCommand      *other);
void                  glade_command_collapse             (GladeCommand      *command,
							  GladeCommand      *other);

/************************ project ******************************/
void           glade_command_set_project_target  (GladeProject *project,
						  const gchar  *catalog,
						  gint          major,
						  gint          minor);

void           glade_command_set_project_domain  (GladeProject *project,     
					          const gchar  *domain);

void           glade_command_set_project_template(GladeProject *project,     
					          GladeWidget  *widget);

void           glade_command_set_project_license (GladeProject *project,
                                                  const gchar  *license);

void           glade_command_set_project_resource_path (GladeProject *project,
                                                        const gchar  *path);

/************************** properties *********************************/

void           glade_command_set_property_enabled(GladeProperty *property,
					          gboolean       enabled);

void           glade_command_set_property        (GladeProperty *property,
					          ...);

void           glade_command_set_property_value  (GladeProperty *property,
						  const GValue  *value);

void           glade_command_set_properties      (GladeProperty *property,
					          const GValue  *old_value,
					          const GValue  *new_value,
						  ...);

void           glade_command_set_properties_list (GladeProject  *project, 
						  GList         *props); /* list of GCSetPropData */

/************************** name ******************************/

void           glade_command_set_name      (GladeWidget       *glade_widget, const gchar  *name);


/************************ protection ******************************/

void           glade_command_lock_widget   (GladeWidget   *widget, 
					    GladeWidget   *lock);

void           glade_command_unlock_widget (GladeWidget   *widget);


/************************ create/add/delete ******************************/

void           glade_command_add           (GList              *widgets,
					    GladeWidget        *parent,
					    GladePlaceholder   *placeholder, 
					    GladeProject       *project,
					    gboolean            pasting);

void           glade_command_delete        (GList              *widgets);

GladeWidget   *glade_command_create        (GladeWidgetAdaptor *adaptor,
					    GladeWidget        *parent,
					    GladePlaceholder   *placeholder,
					    GladeProject       *project);

/************************ cut/paste/dnd ******************************/

void           glade_command_cut           (GList             *widgets);

void           glade_command_paste         (GList             *widgets,
					    GladeWidget       *parent,
					    GladePlaceholder  *placeholder,
					    GladeProject      *project);

void           glade_command_dnd           (GList             *widgets,
					    GladeWidget       *parent,
					    GladePlaceholder  *placeholder);

/************************ signals ******************************/

void           glade_command_add_signal    (GladeWidget       *glade_widget, 
					    const GladeSignal *signal);

void           glade_command_remove_signal (GladeWidget       *glade_widget, 
					    const GladeSignal *signal);

void           glade_command_change_signal (GladeWidget       *glade_widget, 
					    const GladeSignal *old_signal, 
					    const GladeSignal *new_signal);

/************************ set i18n ******************************/

void           glade_command_set_i18n      (GladeProperty     *property,
					    gboolean translatable,
					    const gchar *context,
					    const gchar *comment);


G_END_DECLS

#endif /* __GLADE_COMMAND_H__ */