glade-command.h 7.78 KB
Newer Older
1 2 3
#ifndef __GLADE_COMMAND_H__
#define __GLADE_COMMAND_H__

4 5 6 7 8
#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>
9 10
#include <glib-object.h>

11 12
G_BEGIN_DECLS

13

14 15 16 17 18 19 20
#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))

21 22 23 24
typedef struct _GladeCommand        GladeCommand;
typedef struct _GladeCommandClass   GladeCommandClass;
typedef struct _GladeCommandPrivate GladeCommandPrivate;
typedef struct _GCSetPropData       GCSetPropData;
25

26 27 28 29 30 31 32 33 34 35
/**
 * 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.
 */
36
struct _GCSetPropData {
37 38 39
  GladeProperty *property;
  GValue        *new_value;
  GValue        *old_value;
40
};
41 42 43

struct _GladeCommand
{
44
  GObject parent;
45

46
  GladeCommandPrivate *priv;
47 48 49 50
};

struct _GladeCommandClass
{
51
  GObjectClass parent_class;
52

53 54 55 56
  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);
57

58 59 60 61 62
  void   (* glade_reserved1)   (void);
  void   (* glade_reserved2)   (void);
  void   (* glade_reserved3)   (void);
  void   (* glade_reserved4)   (void);
};
63

64 65


66
GType                 glade_command_get_type             (void);
67

68
void                  glade_command_push_group           (const gchar       *fmt,
69
                                                          ...) G_GNUC_PRINTF (1, 2);
70 71
void                  glade_command_pop_group            (void);
gint                  glade_command_get_group_depth      (void);
72

73 74 75 76 77
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,
78
                                                          GladeCommand      *other);
79
void                  glade_command_collapse             (GladeCommand      *command,
80
                                                          GladeCommand      *other);
81

82
/************************ project ******************************/
83
void           glade_command_set_project_target  (GladeProject *project,
84 85 86
                                                  const gchar  *catalog,
                                                  gint          major,
                                                  gint          minor);
87

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

91
void           glade_command_set_project_template(GladeProject *project,     
92
                                                  GladeWidget  *widget);
93

94 95 96 97 98 99
void           glade_command_set_project_license (GladeProject *project,
                                                  const gchar  *license);

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

100
/************************** properties *********************************/
101

102
void           glade_command_set_property_enabled(GladeProperty *property,
103
                                                  gboolean       enabled);
104 105

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

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

111
void           glade_command_set_properties      (GladeProperty *property,
112 113 114
                                                  const GValue  *old_value,
                                                  const GValue  *new_value,
                                                  ...);
115

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

119
/************************** name ******************************/
120

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

123

124 125
/************************ protection ******************************/

126
void           glade_command_lock_widget   (GladeWidget   *widget, 
127
                                            GladeWidget   *lock);
128

129
void           glade_command_unlock_widget (GladeWidget   *widget);
130

131 132 133 134

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

void           glade_command_add           (GList              *widgets,
135 136 137 138
                                            GladeWidget        *parent,
                                            GladePlaceholder   *placeholder, 
                                            GladeProject       *project,
                                            gboolean            pasting);
139

140
void           glade_command_delete        (GList              *widgets);
141

142
GladeWidget   *glade_command_create        (GladeWidgetAdaptor *adaptor,
143 144 145
                                            GladeWidget        *parent,
                                            GladePlaceholder   *placeholder,
                                            GladeProject       *project);
146

147
/************************ cut/paste/dnd ******************************/
148

149
void           glade_command_cut           (GList             *widgets);
150

151
void           glade_command_paste         (GList             *widgets,
152 153 154
                                            GladeWidget       *parent,
                                            GladePlaceholder  *placeholder,
                                            GladeProject      *project);
155

156
void           glade_command_dnd           (GList             *widgets,
157 158
                                            GladeWidget       *parent,
                                            GladePlaceholder  *placeholder);
159

160
/************************ signals ******************************/
161

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

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

168
void           glade_command_change_signal (GladeWidget       *glade_widget, 
169 170
                                            const GladeSignal *old_signal, 
                                            const GladeSignal *new_signal);
171

172
/************************ set i18n ******************************/
173

174
void           glade_command_set_i18n      (GladeProperty     *property,
175 176 177
                                            gboolean translatable,
                                            const gchar *context,
                                            const gchar *comment);
178

179

180 181
G_END_DECLS

182
#endif /* __GLADE_COMMAND_H__ */