1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * anjuta-project.h
4  * Copyright (C) Sébastien Granjoux 2009 <seb.sfo@free.fr>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef _ANJUTA_PROJECT_H_
21 #define _ANJUTA_PROJECT_H_
22 
23 #include <glib.h>
24 #include <gio/gio.h>
25 
26 G_BEGIN_DECLS
27 
28 #define ANJUTA_TYPE_PROJECT_PROPERTY		(anjuta_project_property_get_type ())
29 #define ANJUTA_IS_PROJECT_PROPERTY
30 
31 typedef struct _AnjutaProjectProperty AnjutaProjectProperty;
32 typedef struct _AnjutaProjectPropertyInfo AnjutaProjectPropertyInfo;
33 
34 typedef enum
35 {
36 	ANJUTA_PROJECT_PROPERTY_STRING = 1,
37 	ANJUTA_PROJECT_PROPERTY_LIST,
38 	ANJUTA_PROJECT_PROPERTY_BOOLEAN,
39 	ANJUTA_PROJECT_PROPERTY_MAP
40 } AnjutaProjectValueType;
41 
42 typedef enum
43 {
44 	ANJUTA_PROJECT_PROPERTY_READ_ONLY = 1 << 0,
45 	ANJUTA_PROJECT_PROPERTY_READ_WRITE = 1 << 1,
46 	ANJUTA_PROJECT_PROPERTY_HIDDEN = 1 << 2,
47 	ANJUTA_PROJECT_PROPERTY_STATIC = 1 << 3,
48 } AnjutaProjectPropertyFlags;
49 
50 struct _AnjutaProjectProperty
51 {
52 	gchar *name;
53 	gchar *value;
54 	AnjutaProjectPropertyInfo *info;
55 	gpointer user_data;
56 };
57 
58 GType anjuta_project_property_get_type (void);
59 AnjutaProjectProperty *anjuta_project_property_new (const gchar *value, const gchar *name, gpointer user_data);
60 AnjutaProjectProperty * anjuta_project_property_copy (AnjutaProjectProperty *prop);
61 void anjuta_project_property_free (AnjutaProjectProperty *prop);
62 
63 
64 struct _AnjutaProjectPropertyInfo
65 {
66     gchar *id;
67 	gchar *name;
68     AnjutaProjectValueType type;
69     AnjutaProjectPropertyFlags flags;
70     gchar *description;
71     AnjutaProjectProperty *default_value;
72 	gpointer user_data;
73 };
74 
75 GType anjuta_project_property_info_get_type (void);
76 AnjutaProjectPropertyInfo *anjuta_project_property_info_new (const gchar *id, const gchar *name, AnjutaProjectValueType type, AnjutaProjectPropertyFlags flags, const gchar *description, AnjutaProjectProperty *default_value, gpointer user_data);
77 AnjutaProjectPropertyInfo * anjuta_project_property_info_copy (AnjutaProjectPropertyInfo *info);
78 void anjuta_project_property_info_free (AnjutaProjectPropertyInfo *info);
79 
80 
81 #define ANJUTA_TYPE_PROJECT_NODE 			(anjuta_project_node_get_type ())
82 #define ANJUTA_PROJECT_NODE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNode))
83 #define ANJUTA_PROJECT_NODE_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
84 #define ANJUTA_IS_PROJECT_NODE(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PROJECT_NODE))
85 #define ANJUTA_IS_PROJECT_NODE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_PROJECT_NODE))
86 #define ANJUTA_PROJECT_NODE_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
87 
88 typedef struct _AnjutaProjectNode		AnjutaProjectNode;
89 typedef struct _AnjutaProjectNodeClass	AnjutaProjectNodeClass;
90 
91 typedef enum
92 {
93 	ANJUTA_PROJECT_UNKNOWN = 0,
94 	ANJUTA_PROJECT_SHAREDLIB,
95 	ANJUTA_PROJECT_STATICLIB,
96 	ANJUTA_PROJECT_PROGRAM,
97 	ANJUTA_PROJECT_PYTHON,
98 	ANJUTA_PROJECT_JAVA,
99 	ANJUTA_PROJECT_LISP,
100 	ANJUTA_PROJECT_HEADER,
101 	ANJUTA_PROJECT_MAN,
102 	ANJUTA_PROJECT_INFO,
103 	ANJUTA_PROJECT_GENERIC,
104 	ANJUTA_PROJECT_DATA,
105 	ANJUTA_PROJECT_EXTRA,
106 	ANJUTA_PROJECT_INTLTOOL,
107 	ANJUTA_PROJECT_CONFIGURE,
108 	ANJUTA_PROJECT_IDL,
109 	ANJUTA_PROJECT_MKENUMS,
110 	ANJUTA_PROJECT_GENMARSHAL,
111 	ANJUTA_PROJECT_SCRIPT,
112 	ANJUTA_PROJECT_ROOT_GROUP,
113 	ANJUTA_PROJECT_LT_MODULE,
114 	ANJUTA_PROJECT_PROXY = 1 << 16,
115 	ANJUTA_PROJECT_PROJECT = 1 << 17,
116 	ANJUTA_PROJECT_PRIMARY = 1 << 18,
117 	ANJUTA_PROJECT_EXECUTABLE = 1 << 19,
118 	ANJUTA_PROJECT_READ_ONLY = 1 << 20,	 /* Node cannot be created by the backend */
119 	ANJUTA_PROJECT_FRAME= 1 << 21,		/* Project configuration file */
120 	ANJUTA_PROJECT_ID_MASK = 0xFFFF << 0,
121 	ANJUTA_PROJECT_FLAG_MASK = 0xFF << 16,
122 	ANJUTA_PROJECT_TYPE_MASK = 0xFF << 24,
123 	ANJUTA_PROJECT_ROOT = 1 << 24,
124 	ANJUTA_PROJECT_GROUP = 2 << 24,
125 	ANJUTA_PROJECT_TARGET = 3 << 24,
126 	ANJUTA_PROJECT_SOURCE = 4 << 24,
127 	ANJUTA_PROJECT_MODULE = 5 << 24,
128 	ANJUTA_PROJECT_PACKAGE = 6 << 24,
129 	ANJUTA_PROJECT_VARIABLE = 7 << 24,
130 	ANJUTA_PROJECT_OBJECT = 8 << 24,
131 } AnjutaProjectNodeType;
132 
133 typedef enum
134 {
135 	ANJUTA_PROJECT_OK = 0,
136 	ANJUTA_PROJECT_MODIFIED = 1 << 0,		/* Node has been modified */
137 	ANJUTA_PROJECT_INCOMPLETE = 1 << 1,	/* Node is not fully loaded */
138 	ANJUTA_PROJECT_LOADING = 1 << 2,	/* Node is send to the worker thread */
139 	ANJUTA_PROJECT_REMOVED = 1 << 3,		/* Node has been removed */
140 	ANJUTA_PROJECT_CAN_ADD_GROUP = 1 << 8,
141 	ANJUTA_PROJECT_CAN_ADD_TARGET = 1 << 9,
142 	ANJUTA_PROJECT_CAN_ADD_SOURCE = 1 << 10,
143 	ANJUTA_PROJECT_CAN_ADD_MODULE = 1 << 11,
144 	ANJUTA_PROJECT_CAN_ADD_PACKAGE = 1 << 12,
145 	ANJUTA_PROJECT_CAN_REMOVE = 1 << 16,
146 	ANJUTA_PROJECT_CAN_SAVE = 1 << 17,
147 	ANJUTA_PROJECT_REMOVE_FILE = 1 << 18
148 } AnjutaProjectNodeState;
149 
150 /**
151  * AnjutaProjectNode:
152  *
153  * The #AnjutaProjectNode struct contains private data only, and should
154  * accessed using the functions below.
155  */
156 struct _AnjutaProjectNode
157 {
158 	GInitiallyUnowned parent_instance;
159 
160 	/*< private >*/
161 	AnjutaProjectNode	*next;
162 	AnjutaProjectNode *prev;
163 	AnjutaProjectNode	*parent;
164 	AnjutaProjectNode *children;
165 
166 	AnjutaProjectNodeType type;
167 	AnjutaProjectNodeState state;
168 
169 	GList *properties_info;
170 	GList *properties;
171 	GFile *file;
172 	gchar *name;
173 };
174 
175 struct _AnjutaProjectNodeClass
176 {
177 	GInitiallyUnownedClass parent_class;
178 
179 	void				(*updated)			(GError *error);
180 	void				(*loaded)			(GError *error);
181 };
182 
183 
184 
185 typedef gboolean (*AnjutaProjectNodeTraverseFunc) (AnjutaProjectNode *node, gpointer data);
186 /**
187  * AnjutaProjectNodeForeachFunc:
188  * @data: (closure):
189  */
190 typedef void (*AnjutaProjectNodeForeachFunc) (AnjutaProjectNode *node, gpointer data);
191 
192 
193 GType      anjuta_project_node_get_type (void) G_GNUC_CONST;
194 
195 AnjutaProjectNode *anjuta_project_node_root (AnjutaProjectNode *node);
196 AnjutaProjectNode *anjuta_project_node_parent (AnjutaProjectNode *node);
197 AnjutaProjectNode *anjuta_project_node_first_child (AnjutaProjectNode *node);
198 AnjutaProjectNode *anjuta_project_node_last_child (AnjutaProjectNode *node);
199 AnjutaProjectNode *anjuta_project_node_next_sibling (AnjutaProjectNode *node);
200 AnjutaProjectNode *anjuta_project_node_prev_sibling (AnjutaProjectNode *node);
201 AnjutaProjectNode *anjuta_project_node_nth_child (AnjutaProjectNode *node, guint n);
202 AnjutaProjectNode *anjuta_project_node_parent_type (AnjutaProjectNode *node, AnjutaProjectNodeType type);
203 
204 void anjuta_project_node_foreach (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeForeachFunc func, gpointer data);
205 void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data);
206 AnjutaProjectNode *anjuta_project_node_traverse (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeTraverseFunc func, gpointer data);
207 AnjutaProjectNode *anjuta_project_node_children_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data);
208 
209 void anjuta_project_node_check (AnjutaProjectNode *parent);
210 void anjuta_project_node_dump (AnjutaProjectNode *parent);
211 
212 AnjutaProjectNode *anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
213 AnjutaProjectNode *anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
214 AnjutaProjectNode *anjuta_project_node_remove (AnjutaProjectNode *node);
215 AnjutaProjectNode *anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node);
216 AnjutaProjectNode *anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node);
217 
218 AnjutaProjectNodeType anjuta_project_node_get_node_type (const AnjutaProjectNode *node);
219 AnjutaProjectNodeType anjuta_project_node_get_full_type (const AnjutaProjectNode *node);
220 AnjutaProjectNodeState anjuta_project_node_get_state (const AnjutaProjectNode *node);
221 const gchar *anjuta_project_node_get_name (const AnjutaProjectNode *node);
222 GFile *anjuta_project_node_get_file (const AnjutaProjectNode *node);
223 
224 GList *anjuta_project_node_get_properties_info (AnjutaProjectNode *node);
225 GList *anjuta_project_node_get_properties (AnjutaProjectNode *node);
226 AnjutaProjectPropertyInfo *anjuta_project_node_get_property_info (AnjutaProjectNode *node, const gchar *id);
227 AnjutaProjectProperty *anjuta_project_node_get_property (AnjutaProjectNode *node, const gchar *id);
228 AnjutaProjectProperty *anjuta_project_node_get_map_property (AnjutaProjectNode *node, const gchar *id, const gchar *name);
229 
230 
231 AnjutaProjectPropertyInfo *anjuta_project_node_insert_property_info (AnjutaProjectNode *node, AnjutaProjectPropertyInfo *info);
232 AnjutaProjectProperty *anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectPropertyInfo *info, AnjutaProjectProperty *property);
233 AnjutaProjectProperty *anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
234 
235 gboolean anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
236 gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
237 
238 AnjutaProjectNode *anjuta_project_node_get_group_from_file (const AnjutaProjectNode *root, GFile *directory);
239 AnjutaProjectNode *anjuta_project_target_get_node_from_name (const AnjutaProjectNode *parent, const gchar *name);
240 AnjutaProjectNode *anjuta_project_node_get_source_from_file (const AnjutaProjectNode *parent, GFile *file);
241 
242 
243 
244 #define ANJUTA_TYPE_PROJECT_NODE_INFO (anjuta_project_node_info_get_type ())
245 
246 typedef struct _AnjutaProjectNodeInfo  AnjutaProjectNodeInfo;
247 
248 struct _AnjutaProjectNodeInfo
249 {
250 	AnjutaProjectNodeType type;
251 	gchar *name;
252 	gchar *mime_type;
253 	gchar *property_help_id;
254 };
255 
256 GType anjuta_project_node_info_get_type (void);
257 
258 AnjutaProjectNodeInfo *anjuta_project_node_info_new (AnjutaProjectNodeType type, const gchar *name, const gchar *mime_type);
259 AnjutaProjectNodeInfo *anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info);
260 void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info);
261 
262 const gchar *anjuta_project_node_info_name (const AnjutaProjectNodeInfo *info);
263 const gchar *anjuta_project_node_info_mime (const AnjutaProjectNodeInfo *info);
264 AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info);
265 const gchar *anjuta_project_node_info_property_help_id (const AnjutaProjectNodeInfo *info);
266 
267 G_END_DECLS
268 
269 #endif
270