summaryrefslogtreecommitdiff
path: root/gladeui/glade-command.h
blob: f71dfdce3902f9d879a2e10e550906abc5092390 (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#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 _GCSetPropData     GCSetPropData;

struct _GCSetPropData {
	GladeProperty *property;
	GValue        *new_value;
	GValue        *old_value;
};

struct _GladeCommand
{
	GObject parent;

	gchar *description; /* a string describing the command.
			     * It's used in the undo/redo menu entry.
			     */

	gint   group_id;    /* If this is part of a command group, this is
			     * the group id (id is needed only to ensure that
			     * consecutive groups dont get merged).
			     */
};

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);
};



GType          glade_command_get_type      (void);

void           glade_command_push_group    (const gchar       *fmt,
					    ...);

void           glade_command_pop_group     (void);


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);

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

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);


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

void           glade_command_delete        (GList              *widgets);

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

/************************ cut/copy/paste ******************************/

void           glade_command_cut           (GList             *widgets);

void           glade_command_copy          (GList             *widgets);

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

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, 
					    const GladeSignal *new_signal);

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

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


G_END_DECLS

#endif /* __GLADE_COMMAND_H__ */