1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Sébastien Granjoux 2009 <seb.sfo@free.fr>
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.
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.
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/>.
20 #ifndef _ANJUTA_PROJECT_H_
21 #define _ANJUTA_PROJECT_H_
28 #define ANJUTA_TYPE_PROJECT_PROPERTY (anjuta_project_property_get_type ())
29 #define ANJUTA_IS_PROJECT_PROPERTY
31 typedef struct _AnjutaProjectProperty AnjutaProjectProperty
;
32 typedef struct _AnjutaProjectPropertyInfo AnjutaProjectPropertyInfo
;
36 ANJUTA_PROJECT_PROPERTY_STRING
= 1,
37 ANJUTA_PROJECT_PROPERTY_LIST
,
38 ANJUTA_PROJECT_PROPERTY_BOOLEAN
,
39 ANJUTA_PROJECT_PROPERTY_MAP
40 } AnjutaProjectValueType
;
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
;
50 struct _AnjutaProjectProperty
54 AnjutaProjectPropertyInfo
*info
;
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
);
64 struct _AnjutaProjectPropertyInfo
68 AnjutaProjectValueType type
;
69 AnjutaProjectPropertyFlags flags
;
71 AnjutaProjectProperty
*property
;
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
*property
, gpointer user_data
);
77 AnjutaProjectPropertyInfo
* anjuta_project_property_info_copy (AnjutaProjectPropertyInfo
*info
);
78 void anjuta_project_property_info_free (AnjutaProjectPropertyInfo
*info
);
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))
88 typedef struct _AnjutaProjectNode AnjutaProjectNode
;
89 typedef struct _AnjutaProjectNodeClass AnjutaProjectNodeClass
;
93 ANJUTA_PROJECT_UNKNOWN
= 0,
94 ANJUTA_PROJECT_SHAREDLIB
,
95 ANJUTA_PROJECT_STATICLIB
,
96 ANJUTA_PROJECT_PROGRAM
,
97 ANJUTA_PROJECT_PYTHON
,
100 ANJUTA_PROJECT_HEADER
,
103 ANJUTA_PROJECT_GENERIC
,
105 ANJUTA_PROJECT_EXTRA
,
106 ANJUTA_PROJECT_INTLTOOL
,
107 ANJUTA_PROJECT_CONFIGURE
,
109 ANJUTA_PROJECT_MKENUMS
,
110 ANJUTA_PROJECT_GENMARSHAL
,
111 ANJUTA_PROJECT_SCRIPT
,
112 ANJUTA_PROJECT_PROXY
= 1 << 16,
113 ANJUTA_PROJECT_PROJECT
= 1 << 17,
114 ANJUTA_PROJECT_PRIMARY
= 1 << 18,
115 ANJUTA_PROJECT_EXECUTABLE
= 1 << 19,
116 ANJUTA_PROJECT_READ_ONLY
= 1 << 20, /* Node cannot be created by the backend */
117 ANJUTA_PROJECT_ID_MASK
= 0xFFFF << 0,
118 ANJUTA_PROJECT_FLAG_MASK
= 0xFF << 16,
119 ANJUTA_PROJECT_TYPE_MASK
= 0xFF << 24,
120 ANJUTA_PROJECT_ROOT
= 1 << 24,
121 ANJUTA_PROJECT_GROUP
= 2 << 24,
122 ANJUTA_PROJECT_TARGET
= 3 << 24,
123 ANJUTA_PROJECT_SOURCE
= 4 << 24,
124 ANJUTA_PROJECT_MODULE
= 5 << 24,
125 ANJUTA_PROJECT_PACKAGE
= 6 << 24,
126 ANJUTA_PROJECT_VARIABLE
= 7 << 24,
127 ANJUTA_PROJECT_OBJECT
= 8 << 24,
128 } AnjutaProjectNodeType
;
132 ANJUTA_PROJECT_OK
= 0,
133 ANJUTA_PROJECT_MODIFIED
= 1 << 0, /* Node has been modified */
134 ANJUTA_PROJECT_INCOMPLETE
= 1 << 1, /* Node is not fully loaded */
135 ANJUTA_PROJECT_LOADING
= 1 << 2, /* Node is send to the worker thread */
136 ANJUTA_PROJECT_REMOVED
= 1 << 3, /* Node has been removed */
137 ANJUTA_PROJECT_CAN_ADD_GROUP
= 1 << 8,
138 ANJUTA_PROJECT_CAN_ADD_TARGET
= 1 << 9,
139 ANJUTA_PROJECT_CAN_ADD_SOURCE
= 1 << 10,
140 ANJUTA_PROJECT_CAN_ADD_MODULE
= 1 << 11,
141 ANJUTA_PROJECT_CAN_ADD_PACKAGE
= 1 << 12,
142 ANJUTA_PROJECT_CAN_REMOVE
= 1 << 16,
143 ANJUTA_PROJECT_CAN_SAVE
= 1 << 17,
144 ANJUTA_PROJECT_REMOVE_FILE
= 1 << 18
145 } AnjutaProjectNodeState
;
150 * The #AnjutaProjectNode struct contains private data only, and should
151 * accessed using the functions below.
153 struct _AnjutaProjectNode
155 GInitiallyUnowned parent_instance
;
158 AnjutaProjectNode
*next
;
159 AnjutaProjectNode
*prev
;
160 AnjutaProjectNode
*parent
;
161 AnjutaProjectNode
*children
;
163 AnjutaProjectNodeType type
;
164 AnjutaProjectNodeState state
;
166 GList
*properties_info
;
172 struct _AnjutaProjectNodeClass
174 GInitiallyUnownedClass parent_class
;
176 void (*updated
) (GError
*error
);
177 void (*loaded
) (GError
*error
);
182 typedef gboolean (*AnjutaProjectNodeTraverseFunc
) (AnjutaProjectNode
*node
, gpointer data
);
184 * AnjutaProjectNodeForeachFunc:
187 typedef void (*AnjutaProjectNodeForeachFunc
) (AnjutaProjectNode
*node
, gpointer data
);
190 GType
anjuta_project_node_get_type (void) G_GNUC_CONST
;
192 AnjutaProjectNode
*anjuta_project_node_root (AnjutaProjectNode
*node
);
193 AnjutaProjectNode
*anjuta_project_node_parent (AnjutaProjectNode
*node
);
194 AnjutaProjectNode
*anjuta_project_node_first_child (AnjutaProjectNode
*node
);
195 AnjutaProjectNode
*anjuta_project_node_last_child (AnjutaProjectNode
*node
);
196 AnjutaProjectNode
*anjuta_project_node_next_sibling (AnjutaProjectNode
*node
);
197 AnjutaProjectNode
*anjuta_project_node_prev_sibling (AnjutaProjectNode
*node
);
198 AnjutaProjectNode
*anjuta_project_node_nth_child (AnjutaProjectNode
*node
, guint n
);
199 AnjutaProjectNode
*anjuta_project_node_parent_type (AnjutaProjectNode
*node
, AnjutaProjectNodeType type
);
201 void anjuta_project_node_foreach (AnjutaProjectNode
*node
, GTraverseType order
, AnjutaProjectNodeForeachFunc func
, gpointer data
);
202 void anjuta_project_node_children_foreach (AnjutaProjectNode
*node
, AnjutaProjectNodeForeachFunc func
, gpointer data
);
203 AnjutaProjectNode
*anjuta_project_node_traverse (AnjutaProjectNode
*node
, GTraverseType order
, AnjutaProjectNodeTraverseFunc func
, gpointer data
);
204 AnjutaProjectNode
*anjuta_project_node_children_traverse (AnjutaProjectNode
*node
, AnjutaProjectNodeTraverseFunc func
, gpointer data
);
206 void anjuta_project_node_check (AnjutaProjectNode
*parent
);
207 void anjuta_project_node_dump (AnjutaProjectNode
*parent
);
209 AnjutaProjectNode
*anjuta_project_node_insert_before (AnjutaProjectNode
*parent
, AnjutaProjectNode
*sibling
, AnjutaProjectNode
*node
);
210 AnjutaProjectNode
*anjuta_project_node_insert_after (AnjutaProjectNode
*parent
, AnjutaProjectNode
*sibling
, AnjutaProjectNode
*node
);
211 AnjutaProjectNode
*anjuta_project_node_remove (AnjutaProjectNode
*node
);
212 AnjutaProjectNode
*anjuta_project_node_append (AnjutaProjectNode
*parent
, AnjutaProjectNode
*node
);
213 AnjutaProjectNode
*anjuta_project_node_prepend (AnjutaProjectNode
*parent
, AnjutaProjectNode
*node
);
215 AnjutaProjectNodeType
anjuta_project_node_get_node_type (const AnjutaProjectNode
*node
);
216 AnjutaProjectNodeType
anjuta_project_node_get_full_type (const AnjutaProjectNode
*node
);
217 AnjutaProjectNodeState
anjuta_project_node_get_state (const AnjutaProjectNode
*node
);
218 const gchar
*anjuta_project_node_get_name (const AnjutaProjectNode
*node
);
219 GFile
*anjuta_project_node_get_file (const AnjutaProjectNode
*node
);
221 GList
*anjuta_project_node_get_properties_info (AnjutaProjectNode
*node
);
222 GList
*anjuta_project_node_get_properties (AnjutaProjectNode
*node
);
223 AnjutaProjectPropertyInfo
*anjuta_project_node_get_property_info (AnjutaProjectNode
*node
, const gchar
*id
);
224 AnjutaProjectProperty
*anjuta_project_node_get_property (AnjutaProjectNode
*node
, const gchar
*id
);
225 AnjutaProjectProperty
*anjuta_project_node_get_map_property (AnjutaProjectNode
*node
, const gchar
*id
, const gchar
*name
);
228 AnjutaProjectPropertyInfo
*anjuta_project_node_insert_property_info (AnjutaProjectNode
*node
, AnjutaProjectPropertyInfo
*info
);
229 AnjutaProjectProperty
*anjuta_project_node_insert_property (AnjutaProjectNode
*node
, AnjutaProjectPropertyInfo
*info
, AnjutaProjectProperty
*property
);
230 AnjutaProjectProperty
*anjuta_project_node_remove_property (AnjutaProjectNode
*node
, AnjutaProjectProperty
*property
);
232 gboolean
anjuta_project_node_set_state (AnjutaProjectNode
*node
, AnjutaProjectNodeState state
);
233 gboolean
anjuta_project_node_clear_state (AnjutaProjectNode
*node
, AnjutaProjectNodeState state
);
235 AnjutaProjectNode
*anjuta_project_node_get_group_from_file (const AnjutaProjectNode
*root
, GFile
*directory
);
236 AnjutaProjectNode
*anjuta_project_target_get_node_from_name (const AnjutaProjectNode
*parent
, const gchar
*name
);
237 AnjutaProjectNode
*anjuta_project_node_get_source_from_file (const AnjutaProjectNode
*parent
, GFile
*file
);
241 #define ANJUTA_TYPE_PROJECT_NODE_INFO (anjuta_project_node_info_get_type ())
243 typedef struct _AnjutaProjectNodeInfo AnjutaProjectNodeInfo
;
245 struct _AnjutaProjectNodeInfo
247 AnjutaProjectNodeType type
;
252 GType
anjuta_project_node_info_get_type (void);
254 AnjutaProjectNodeInfo
*anjuta_project_node_info_new (AnjutaProjectNodeType type
, const gchar
*name
, const gchar
*mime_type
);
255 AnjutaProjectNodeInfo
*anjuta_project_node_info_copy (AnjutaProjectNodeInfo
*info
);
256 void anjuta_project_node_info_free (AnjutaProjectNodeInfo
*info
);
258 const gchar
*anjuta_project_node_info_name (const AnjutaProjectNodeInfo
*info
);
259 const gchar
*anjuta_project_node_info_mime (const AnjutaProjectNodeInfo
*info
);
260 AnjutaProjectNodeType
anjuta_project_node_info_type (const AnjutaProjectNodeInfo
*info
);