[anjuta] libanjuta: anjuta-project clean up
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] libanjuta: anjuta-project clean up
- Date: Sun, 21 Nov 2010 11:57:29 +0000 (UTC)
commit 26e5b9c33ef1085e10df4ca39387bd073fb6b47d
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Nov 20 22:53:49 2010 +0100
libanjuta: anjuta-project clean up
libanjuta/anjuta-project.c | 551 ++++++++++++++---------------------
libanjuta/anjuta-project.h | 173 +++++-------
libanjuta/interfaces/libanjuta.idl | 2 +-
plugins/am-project/ac-writer.c | 3 +-
plugins/am-project/am-node.c | 82 +++---
plugins/am-project/am-node.h | 1 +
plugins/am-project/am-project.c | 9 +-
plugins/am-project/am-writer.c | 6 +-
plugins/am-project/projectparser.c | 6 +-
plugins/dir-project/dir-project.c | 6 +-
plugins/project-manager/dialogs.c | 52 +---
plugins/project-manager/plugin.c | 26 +--
plugins/project-manager/project.c | 22 +--
plugins/project-manager/project.h | 2 -
plugins/project-manager/tree-data.c | 55 +---
plugins/project-manager/tree-data.h | 2 -
16 files changed, 365 insertions(+), 633 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 5fc1fab..9f85934 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -32,28 +32,92 @@
* @stability: Unstable
* @include: libanjuta/anjuta-project.h
*
- * A project in Anjuta is represented by a tree. There are three kinds of node.
+ * A project in Anjuta is represented by a tree. There are six kinds of node.
+ *
+ * The root node is the parent of all other nodes, it can implement
+ * IAnjutaProject interface and represent the project itself but it is not
+ * mandatory.
*
- * A source node represents a source file. These are lead of the tree, a source
- * node cannot have children.
+ * A module node represents a module in autotools project, it is a group of
+ * packages.
+ *
+ * A package node represents a package in autotools project, it is library.
+ *
+ * A group node is used to group several target or source, it can represent
+ * a directory by example.
*
* A target node represents an object file defined explicitely.
* There are different kinds of target: program, library...
* A target have as children all source needed to build it.
*
- * A group node is used to group several target or source, it can represent
- * a directory by example. The root node of the project is a group node
- * representing the project directory.
+ * A source node represents a source file. These are lead of the tree, a source
+ * node cannot have children.
*
* All these nodes are base objects. They have derived in each project backend
* to provide more specific information.
*/
-/* convenient shortcut macro the get the AnjutaProjectNode from a GNode */
-#define NODE_DATA(node) node
-#define PROXY_DATA(node) ((node) != NULL ? (AnjutaProjectProxyData *)((node)->data) : NULL)
+/* Node properties
+ *---------------------------------------------------------------------------*/
-/* Node access functions
+/* Implement Boxed type
+ *---------------------------------------------------------------------------*/
+
+/**
+ * anjuta_project_property_new:
+ * name: (transfer none):
+ * value: (transfer none):
+ * native: (allow-none) (transfer none):
+ *
+ * Returns: (transfer full):
+ */
+AnjutaProjectProperty *
+anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type,
+ const gchar *value, AnjutaProjectProperty *native)
+{
+ AnjutaProjectProperty *prop = g_slice_new0(AnjutaProjectProperty);
+ prop->name = g_strdup (name);
+ prop->type = type;
+ prop->value = g_strdup (value);
+ prop->native = native;
+ return prop;
+}
+
+AnjutaProjectProperty *
+anjuta_project_property_copy (AnjutaProjectProperty *prop)
+{
+ return anjuta_project_property_new (prop->name, prop->type,
+ prop->value, prop->native);
+}
+
+void
+anjuta_project_property_free (AnjutaProjectProperty *prop)
+{
+ g_free (prop->name);
+ g_free (prop->value);
+ g_slice_free (AnjutaProjectProperty, prop);
+}
+
+GType
+anjuta_project_property_get_type (void)
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("AnjutaProjectProperty",
+ (GBoxedCopyFunc) anjuta_project_property_copy,
+ (GBoxedFreeFunc) anjuta_project_property_free);
+
+ return type_id;
+}
+
+
+
+/* Node
+ *---------------------------------------------------------------------------*/
+
+
+/* Moving in tree functions
*---------------------------------------------------------------------------*/
AnjutaProjectNode *
@@ -292,11 +356,8 @@ anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNode
}
}
-AnjutaProjectNode *
-anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node)
-{
- return anjuta_project_node_insert_before (parent, NULL, node);
-}
+/* Adding node functions
+ *---------------------------------------------------------------------------*/
/**
* anjuta_project_node_insert_before:
@@ -423,210 +484,96 @@ anjuta_project_node_remove (AnjutaProjectNode *node)
node->next->prev = node->prev;
node->next = NULL;
}
- node->prev = NULL;
+ node->prev = NULL;
return node;
}
AnjutaProjectNode *
-anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replacement)
-{
- AnjutaProjectNode *child;
- AnjutaProjectNode *sibling;
- AnjutaProjectNode *next;
-
- if (node->parent != NULL)
- {
- anjuta_project_node_insert_after (node->parent, node, replacement);
- anjuta_project_node_remove (node);
- }
-
- /* Move all children from node to replacement */
- sibling = NULL;
- for (child = anjuta_project_node_first_child (node); child != NULL; child = next)
- {
- next = anjuta_project_node_next_sibling (child);
- anjuta_project_node_remove (child);
- sibling = anjuta_project_node_insert_after (replacement, sibling, child);
- child = next;
- }
-
- /* Move all children from replacement to node */
- child = anjuta_project_node_next_sibling (sibling);
- sibling = NULL;
- for (; child != NULL; child = next)
- {
- next = anjuta_project_node_next_sibling (child);
- anjuta_project_node_remove (child);
- sibling = anjuta_project_node_insert_after (node, sibling, child);
- child = next;
- }
-
- return replacement;
-}
-
-AnjutaProjectNode *
-anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement)
-{
- AnjutaProjectNode *marker = g_object_new (ANJUTA_TYPE_PROJECT_NODE, NULL);
-
- if (node->parent != NULL)
- {
- anjuta_project_node_insert_after (node->parent, node, marker);
- anjuta_project_node_remove (node);
- }
- if (replacement->parent != NULL)
- {
- anjuta_project_node_insert_after (replacement->parent, replacement, node);
- anjuta_project_node_remove (replacement);
- }
- if (marker->parent != NULL)
- {
- anjuta_project_node_insert_after (marker->parent, marker, replacement);
- anjuta_project_node_remove (marker);
- }
- g_object_unref (marker);
-
- return replacement;
-}
-
-AnjutaProjectNode *
-anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode *node)
-{
- AnjutaProjectNode *child;
- AnjutaProjectNode *sibling;
-
- sibling = anjuta_project_node_last_child (parent);
-
- for (child = anjuta_project_node_first_child (node); child != NULL;)
- {
- AnjutaProjectNode *remove;
-
- remove = child;
- child = anjuta_project_node_next_sibling (child);
- anjuta_project_node_remove (remove);
- sibling = anjuta_project_node_insert_after (parent, sibling, remove);
- }
-
- return parent;
-}
-
-
-AnjutaProjectNode *
anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node)
{
return anjuta_project_node_insert_before (parent, parent->children, node);
}
-gboolean
-anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state)
-{
- if (node == NULL) return FALSE;
- NODE_DATA (node)->state |= state;
- return TRUE;
-}
-
-gboolean
-anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state)
-{
- if (node == NULL) return FALSE;
- NODE_DATA (node)->state &= ~state;
- return TRUE;
+AnjutaProjectNode *
+anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node)
+{
+ return anjuta_project_node_insert_before (parent, NULL, node);
}
-AnjutaProjectNodeState
-anjuta_project_node_get_state (const AnjutaProjectNode *node)
-{
- return node == NULL ? ANJUTA_PROJECT_OK : (NODE_DATA (node)->state);
-}
+/* Access functions
+ *---------------------------------------------------------------------------*/
AnjutaProjectNodeType
anjuta_project_node_get_node_type (const AnjutaProjectNode *node)
{
- return node == NULL ? ANJUTA_PROJECT_UNKNOWN : (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK);
+ return node == NULL ? ANJUTA_PROJECT_UNKNOWN : (node->type & ANJUTA_PROJECT_TYPE_MASK);
}
AnjutaProjectNodeType
anjuta_project_node_get_full_type (const AnjutaProjectNode *node)
{
- return node == NULL ? ANJUTA_PROJECT_UNKNOWN : NODE_DATA (node)->type;
+ return node == NULL ? ANJUTA_PROJECT_UNKNOWN : node->type;
}
-gchar *
-anjuta_project_node_get_name (const AnjutaProjectNode *node)
+
+AnjutaProjectNodeState
+anjuta_project_node_get_state (const AnjutaProjectNode *node)
{
- switch (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK)
- {
- case ANJUTA_PROJECT_GROUP:
- return g_file_get_basename (NODE_DATA (node)->file);
- case ANJUTA_PROJECT_SOURCE:
- return g_file_get_basename (NODE_DATA (node)->file);
- case ANJUTA_PROJECT_TARGET:
- case ANJUTA_PROJECT_MODULE:
- case ANJUTA_PROJECT_PACKAGE:
- return g_strdup (NODE_DATA (node)->name);
- default:
- return NULL;
- }
+ return node == NULL ? ANJUTA_PROJECT_OK : (node->state);
}
-gchar*
-anjuta_project_node_get_uri (AnjutaProjectNode *node)
+const gchar *
+anjuta_project_node_get_name (const AnjutaProjectNode *node)
{
- AnjutaProjectNode *parent;
- GFile *file;
- gchar *uri;
-
- switch (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK)
+ if ((node->name == NULL) && (node->file != NULL))
{
- case ANJUTA_PROJECT_GROUP:
- uri = g_file_get_uri (NODE_DATA (node)->file);
- break;
- case ANJUTA_PROJECT_TARGET:
- parent = anjuta_project_node_parent (node);
- file = g_file_get_child (anjuta_project_group_get_directory (parent), anjuta_project_target_get_name (node));
- uri = g_file_get_uri (file);
- g_object_unref (file);
- break;
- case ANJUTA_PROJECT_SOURCE:
- uri = g_file_get_uri (NODE_DATA (node)->file);
- break;
- default:
- uri = NULL;
- break;
+ ((AnjutaProjectNode *)node)->name = g_file_get_basename (node->file);
}
- return uri;
+ return node->name;
}
GFile*
-anjuta_project_node_get_file (AnjutaProjectNode *node)
+anjuta_project_node_get_file (const AnjutaProjectNode *node)
{
- if ((NODE_DATA (node)->file == NULL) && (NODE_DATA (node)->name != NULL))
+ switch (node->type & ANJUTA_PROJECT_TYPE_MASK)
{
- /* Try to create a file */
- AnjutaProjectNode *parent;
-
- parent = anjuta_project_node_parent (node);
- if ((parent != NULL) && (NODE_DATA (parent)->file != NULL))
+ case ANJUTA_PROJECT_TARGET:
+ if ((node->name) && (node->parent != NULL) && (node->parent->file != NULL))
{
- NODE_DATA (node)->file = g_file_get_child (NODE_DATA (parent)->file, NODE_DATA (node)->name);
+ GFile *file = g_file_get_child (node->parent->file, node->name);
+
+ if ((node->file != NULL) && g_file_equal (node->file, file))
+ {
+ /* Keep the same file */
+ g_object_unref (file);
+ }
+ else
+ {
+ /* Parent has been updated, update file */
+ if (node->file != NULL) g_object_unref (node->file);
+ ((AnjutaProjectNode *)node)->file = file;
+ }
}
+ break;
+ default:
+ break;
}
-
- return NODE_DATA (node)->file;
+
+ return node->file;
}
GList *
anjuta_project_node_get_custom_properties (AnjutaProjectNode *node)
{
- return NODE_DATA (node)->custom_properties;
+ return node->custom_properties;
}
GList *
anjuta_project_node_get_native_properties (AnjutaProjectNode *node)
{
- return NODE_DATA (node)->native_properties;
+ return node->native_properties;
}
static gint
@@ -658,6 +605,26 @@ anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty
return found != NULL ? (AnjutaProjectProperty *)found->data : NULL;
}
+
+/* Set functions
+ *---------------------------------------------------------------------------*/
+
+gboolean
+anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state)
+{
+ if (node == NULL) return FALSE;
+ node->state |= state;
+ return TRUE;
+}
+
+gboolean
+anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state)
+{
+ if (node == NULL) return FALSE;
+ node->state &= ~state;
+ return TRUE;
+}
+
AnjutaProjectProperty *
anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *native, AnjutaProjectProperty *property)
{
@@ -697,69 +664,16 @@ anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectPrope
return removed;
}
-/**
- * anjuta_project_property_new:
- * name: (transfer none):
- * value: (transfer none):
- * native: (allow-none) (transfer none):
- *
- * Returns: (transfer full):
- */
-AnjutaProjectProperty *
-anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type,
- const gchar *value, AnjutaProjectProperty *native)
-{
- AnjutaProjectProperty *prop = g_slice_new0(AnjutaProjectProperty);
- prop->name = g_strdup (name);
- prop->type = type;
- prop->value = g_strdup (value);
- prop->native = native;
- return prop;
-}
-
-AnjutaProjectProperty *
-anjuta_project_property_copy (AnjutaProjectProperty *prop)
-{
- return anjuta_project_property_new (prop->name, prop->type,
- prop->value, prop->native);
-}
-void
-anjuta_project_property_free (AnjutaProjectProperty *prop)
-{
- g_free (prop->name);
- g_free (prop->value);
- g_slice_free (AnjutaProjectProperty, prop);
-}
-
-GType
-anjuta_project_property_get_type (void)
-{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static ("AnjutaProjectProperty",
- (GBoxedCopyFunc) anjuta_project_property_copy,
- (GBoxedFreeFunc) anjuta_project_property_free);
-
- return type_id;
-}
-
-/* Group access functions
+/* Get node from file functions
*---------------------------------------------------------------------------*/
-GFile*
-anjuta_project_group_get_directory (const AnjutaProjectNode *group)
-{
- return NODE_DATA (group)->file;
-}
-
static gboolean
anjuta_project_group_compare (AnjutaProjectNode *node, gpointer data)
{
GFile *file = (GFile *)data;
- if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_GROUP) && g_file_equal (NODE_DATA(node)->file, file))
+ if (((node->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_GROUP) && g_file_equal (node->file, file))
{
return TRUE;
}
@@ -779,24 +693,12 @@ anjuta_project_group_get_node_from_file (const AnjutaProjectNode *root, GFile *d
return node;
}
-AnjutaProjectNode *
-anjuta_project_group_get_node_from_uri (const AnjutaProjectNode *root, const gchar *uri)
-{
- GFile *file = g_file_new_for_uri (uri);
- AnjutaProjectNode *node;
-
- node = anjuta_project_group_get_node_from_file (root, file);
- g_object_unref (file);
-
- return node;
-}
-
static gboolean
anjuta_project_target_compare (AnjutaProjectNode *node, gpointer data)
{
const gchar *name = (gchar *)data;
- if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET) && (strcmp (NODE_DATA(node)->name, name) == 0))
+ if (((node->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET) && (strcmp (node->name, name) == 0))
{
return TRUE;
}
@@ -821,7 +723,7 @@ anjuta_project_source_compare (AnjutaProjectNode *node, gpointer data)
{
GFile *file = (GFile *)data;
- if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_SOURCE) && g_file_equal (NODE_DATA(node)->file, file))
+ if (((node->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_SOURCE) && g_file_equal (node->file, file))
{
return TRUE;
}
@@ -842,100 +744,6 @@ anjuta_project_source_get_node_from_file (const AnjutaProjectNode *parent, GFile
return node;
}
-AnjutaProjectNode *
-anjuta_project_source_get_node_from_uri (const AnjutaProjectNode *parent, const gchar *uri)
-{
- GFile *file = g_file_new_for_uri (uri);
- AnjutaProjectNode *node;
-
- node = anjuta_project_source_get_node_from_file (parent, file);
- g_object_unref (file);
-
- return node;
-}
-
-/* Target access functions
- *---------------------------------------------------------------------------*/
-
-const gchar *
-anjuta_project_target_get_name (const AnjutaProjectNode *target)
-{
- return NODE_DATA (target)->name;
-}
-
-/* Source access functions
- *---------------------------------------------------------------------------*/
-
-GFile*
-anjuta_project_source_get_file (const AnjutaProjectNode *source)
-{
- return NODE_DATA (source)->file;
-}
-
-/* Node information functions
- *---------------------------------------------------------------------------*/
-
-const gchar *
-anjuta_project_node_info_name (const AnjutaProjectNodeInfo *info)
-{
- return info->name;
-}
-
-const gchar *
-anjuta_project_node_info_mime (const AnjutaProjectNodeInfo *info)
-{
- return info->mime_type;
-}
-
-AnjutaProjectNodeType
-anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info)
-{
- return info->type;
-}
-
-/**
- * anjuta_project_node_info_new:
- * name: (transfer none):
- * mime_type: (transfer none):
- *
- * Returns: (transfer full):
- */
-AnjutaProjectNodeInfo *
-anjuta_project_node_info_new (AnjutaProjectNodeType type,
- const gchar *name,
- const gchar *mime_type)
-{
- AnjutaProjectNodeInfo *info = g_slice_new0 (AnjutaProjectNodeInfo);
- info->type = type;
- info->name = g_strdup (name);
- info->mime_type = g_strdup (mime_type);
-
- return info;
-}
-
-AnjutaProjectNodeInfo *
-anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info)
-{
- return anjuta_project_node_info_new (info->type, info->name, info->mime_type);
-}
-
-void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info)
-{
- g_slice_free (AnjutaProjectNodeInfo, info);
-}
-
-GType
-anjuta_project_node_info_get_type ()
-{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static ("AnjutaProjectNodeInfo",
- (GBoxedCopyFunc) anjuta_project_node_info_copy,
- (GBoxedFreeFunc) anjuta_project_node_info_free);
-
- return type_id;
-}
/* Implement GObject
*---------------------------------------------------------------------------*/
@@ -982,8 +790,6 @@ anjuta_project_node_dispose (GObject *object)
{
AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
- //g_message ("anjuta_project_node_dispose node %p children %p parent %p prev %p name %s file %s", node, node->children, node->parent, node->prev, node->name, node->file != NULL ? g_file_get_path (node->file) : "no file");
-
anjuta_project_node_remove (node);
if (node->file != NULL) g_object_unref (node->file);
@@ -1111,3 +917,76 @@ anjuta_project_node_class_init (AnjutaProjectNodeClass *klass)
G_PARAM_READWRITE));
}
+
+
+
+/* Node information
+ *---------------------------------------------------------------------------*/
+
+/* Public functions
+ *---------------------------------------------------------------------------*/
+
+const gchar *
+anjuta_project_node_info_name (const AnjutaProjectNodeInfo *info)
+{
+ return info->name;
+}
+
+const gchar *
+anjuta_project_node_info_mime (const AnjutaProjectNodeInfo *info)
+{
+ return info->mime_type;
+}
+
+AnjutaProjectNodeType
+anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info)
+{
+ return info->type;
+}
+
+/**
+ * anjuta_project_node_info_new:
+ * name: (transfer none):
+ * mime_type: (transfer none):
+ *
+ * Returns: (transfer full):
+ */
+AnjutaProjectNodeInfo *
+anjuta_project_node_info_new (AnjutaProjectNodeType type,
+ const gchar *name,
+ const gchar *mime_type)
+{
+ AnjutaProjectNodeInfo *info = g_slice_new0 (AnjutaProjectNodeInfo);
+ info->type = type;
+ info->name = g_strdup (name);
+ info->mime_type = g_strdup (mime_type);
+
+ return info;
+}
+
+AnjutaProjectNodeInfo *
+anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info)
+{
+ return anjuta_project_node_info_new (info->type, info->name, info->mime_type);
+}
+
+void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info)
+{
+ g_slice_free (AnjutaProjectNodeInfo, info);
+}
+
+/* Implement Boxed type
+ *---------------------------------------------------------------------------*/
+
+GType
+anjuta_project_node_info_get_type ()
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("AnjutaProjectNodeInfo",
+ (GBoxedCopyFunc) anjuta_project_node_info_copy,
+ (GBoxedFreeFunc) anjuta_project_node_info_free);
+
+ return type_id;
+}
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 6c67078..5277db0 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -25,18 +25,52 @@
G_BEGIN_DECLS
-#define ANJUTA_TYPE_PROJECT_NODE (anjuta_project_node_get_type ())
-#define ANJUTA_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNode))
-#define ANJUTA_PROJECT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
-#define ANJUTA_IS_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PROJECT_NODE))
+#define ANJUTA_TYPE_PROJECT_PROPERTY (anjuta_project_property_get_type ())
+#define ANJUTA_IS_PROJECT_PROPERTY
+
+typedef struct _AnjutaProjectProperty AnjutaProjectProperty;
+
+typedef enum
+{
+ ANJUTA_PROJECT_PROPERTY_STRING = 1,
+ ANJUTA_PROJECT_PROPERTY_LIST,
+ ANJUTA_PROJECT_PROPERTY_BOOLEAN,
+ ANJUTA_PROJECT_PROPERTY_MAP
+} AnjutaProjectValueType;
+
+typedef enum
+{
+ ANJUTA_PROJECT_PROPERTY_READ_ONLY = 1 << 0,
+ ANJUTA_PROJECT_PROPERTY_READ_WRITE = 1 << 1,
+} AnjutaProjectPropertyFlags;
+
+struct _AnjutaProjectProperty
+{
+ gchar *name;
+ AnjutaProjectValueType type;
+ AnjutaProjectPropertyFlags flags;
+ gchar *value;
+ AnjutaProjectProperty *native;
+};
+
+GType anjuta_project_property_get_type (void);
+
+AnjutaProjectProperty *anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type, const gchar *value, AnjutaProjectProperty *native);
+AnjutaProjectProperty * anjuta_project_property_copy (AnjutaProjectProperty *prop);
+void anjuta_project_property_free (AnjutaProjectProperty *prop);
+
+
+
+#define ANJUTA_TYPE_PROJECT_NODE (anjuta_project_node_get_type ())
+#define ANJUTA_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNode))
+#define ANJUTA_PROJECT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
+#define ANJUTA_IS_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PROJECT_NODE))
#define ANJUTA_IS_PROJECT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_PROJECT_NODE))
#define ANJUTA_PROJECT_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
-
-typedef struct _AnjutaProjectNode AnjutaProjectNode;
+typedef struct _AnjutaProjectNode AnjutaProjectNode;
typedef struct _AnjutaProjectNodeClass AnjutaProjectNodeClass;
-
typedef enum
{
ANJUTA_PROJECT_UNKNOWN = 0,
@@ -91,68 +125,6 @@ typedef enum
ANJUTA_PROJECT_REMOVE_FILE = 1 << 18
} AnjutaProjectNodeState;
-typedef struct _AnjutaProjectTargetInformation
-{
- AnjutaProjectNodeType type;
- gchar *name;
- gchar *mime_type;
-} AnjutaProjectNodeInfo;
-
-#define ANJUTA_TYPE_PROJECT_NODE_INFO (anjuta_project_node_info_get_type ())
-
-typedef enum
-{
- ANJUTA_PROJECT_PROPERTY_STRING = 1,
- ANJUTA_PROJECT_PROPERTY_LIST,
- ANJUTA_PROJECT_PROPERTY_BOOLEAN,
- ANJUTA_PROJECT_PROPERTY_MAP
-} AnjutaProjectValueType;
-
-typedef enum
-{
- ANJUTA_PROJECT_PROPERTY_READ_ONLY = 1 << 0,
- ANJUTA_PROJECT_PROPERTY_READ_WRITE = 1 << 1,
-} AnjutaProjectPropertyFlags;
-
-
-typedef struct _AnjutaProjectProperty AnjutaProjectProperty;
-
-struct _AnjutaProjectProperty
-{
- gchar *name;
- AnjutaProjectValueType type;
- AnjutaProjectPropertyFlags flags;
- gchar *value;
- AnjutaProjectProperty *native;
-};
-
-#define ANJUTA_IS_PROJECT_PROPERTY
-#define ANJUTA_TYPE_PROJECT_PROPERTY (anjuta_project_property_get_type ())
-
-typedef struct
-{
- AnjutaProjectProperty *property;
- gchar *value;
-} AnjutaProjectPropertyValue;
-
-typedef struct _AnjutaProjectTargetInformation* AnjutaProjectTargetType;
-
-typedef struct
-{
- AnjutaProjectNodeType type;
- AnjutaProjectProperty *properties;
- GFile *file;
- gchar *name;
- AnjutaProjectNodeState state;
-} AnjutaProjectNodeData;
-
-
-#define ANJUTA_PROJECT_NODE_DATA(node) (node)
-
-typedef gboolean (*AnjutaProjectNodeTraverseFunc) (AnjutaProjectNode *node, gpointer data);
-typedef void (*AnjutaProjectNodeForeachFunc) (AnjutaProjectNode *node, gpointer data);
-
-
/**
* AnjutaProjectNode:
*
@@ -180,14 +152,18 @@ struct _AnjutaProjectNode
struct _AnjutaProjectNodeClass
{
GInitiallyUnownedClass parent_class;
-
- void (*updated) (GError *error);
- void (*loaded) (GError *error);
+
+ void (*updated) (GError *error);
+ void (*loaded) (GError *error);
};
-GType anjuta_project_node_get_type (void) G_GNUC_CONST;
+typedef gboolean (*AnjutaProjectNodeTraverseFunc) (AnjutaProjectNode *node, gpointer data);
+typedef void (*AnjutaProjectNodeForeachFunc) (AnjutaProjectNode *node, gpointer data);
+
+
+GType anjuta_project_node_get_type (void) G_GNUC_CONST;
AnjutaProjectNode *anjuta_project_node_root (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_parent (AnjutaProjectNode *node);
@@ -197,61 +173,56 @@ AnjutaProjectNode *anjuta_project_node_next_sibling (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_prev_sibling (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_nth_child (AnjutaProjectNode *node, guint n);
-AnjutaProjectNode *anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replacement);
-AnjutaProjectNode *anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement);
-AnjutaProjectNode *anjuta_project_node_remove (AnjutaProjectNode *node);
-
void anjuta_project_node_foreach (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeForeachFunc func, gpointer data);
void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data);
AnjutaProjectNode *anjuta_project_node_traverse (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeTraverseFunc func, gpointer data);
AnjutaProjectNode *anjuta_project_node_children_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data);
-gboolean anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
-gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
+AnjutaProjectNode *anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_node_remove (AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node);
+
AnjutaProjectNodeType anjuta_project_node_get_node_type (const AnjutaProjectNode *node);
AnjutaProjectNodeType anjuta_project_node_get_full_type (const AnjutaProjectNode *node);
AnjutaProjectNodeState anjuta_project_node_get_state (const AnjutaProjectNode *node);
-gchar *anjuta_project_node_get_name (const AnjutaProjectNode *node);
-gchar *anjuta_project_node_get_uri (AnjutaProjectNode *node);
-GFile *anjuta_project_node_get_file (AnjutaProjectNode *node);
+const gchar *anjuta_project_node_get_name (const AnjutaProjectNode *node);
+GFile *anjuta_project_node_get_file (const AnjutaProjectNode *node);
-//AnjutaProjectProperty *anjuta_project_node_first_property (AnjutaProjectNode *node);
-//AnjutaProjectProperty *anjuta_project_node_first_valid_property (AnjutaProjectNode *node);
GList *anjuta_project_node_get_native_properties (AnjutaProjectNode *node);
GList *anjuta_project_node_get_custom_properties (AnjutaProjectNode *node);
AnjutaProjectProperty *anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
+
+gboolean anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
+gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
+
AnjutaProjectProperty *anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *native, AnjutaProjectProperty *property);
AnjutaProjectProperty *anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
-AnjutaProjectProperty *anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type, const gchar *value, AnjutaProjectProperty *native);
-AnjutaProjectProperty * anjuta_project_property_copy (AnjutaProjectProperty *prop);
-void anjuta_project_property_free (AnjutaProjectProperty *prop);
-GType anjuta_project_property_get_type (void);
-//const gchar *anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop);
-
AnjutaProjectNode *anjuta_project_group_get_node_from_file (const AnjutaProjectNode *root, GFile *directory);
AnjutaProjectNode *anjuta_project_target_get_node_from_name (const AnjutaProjectNode *parent, const gchar *name);
AnjutaProjectNode *anjuta_project_source_get_node_from_file (const AnjutaProjectNode *parent, GFile *file);
-AnjutaProjectNode *anjuta_project_group_get_node_from_uri (const AnjutaProjectNode *root, const gchar *uri);
-AnjutaProjectNode *anjuta_project_source_get_node_from_uri (const AnjutaProjectNode *parent, const gchar *uri);
-GFile *anjuta_project_group_get_directory (const AnjutaProjectNode *group);
-const gchar *anjuta_project_target_get_name (const AnjutaProjectNode *target);
-GFile *anjuta_project_source_get_file (const AnjutaProjectNode *source);
+#define ANJUTA_TYPE_PROJECT_NODE_INFO (anjuta_project_node_info_get_type ())
+
+typedef struct _AnjutaProjectNodeInfo
+{
+ AnjutaProjectNodeType type;
+ gchar *name;
+ gchar *mime_type;
+} AnjutaProjectNodeInfo;
+
+GType anjuta_project_node_info_get_type (void);
AnjutaProjectNodeInfo *anjuta_project_node_info_new (AnjutaProjectNodeType type, const gchar *name, const gchar *mime_type);
AnjutaProjectNodeInfo *anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info);
void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info);
-GType anjuta_project_node_info_get_type (void);
+
const gchar *anjuta_project_node_info_name (const AnjutaProjectNodeInfo *info);
const gchar *anjuta_project_node_info_mime (const AnjutaProjectNodeInfo *info);
AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info);
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index e03f9c0..863b737 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3257,7 +3257,7 @@ interface IAnjutaProject
* Return value: (element-type Anjuta.ProjectNodeInfo) (transfer none): TRUE if the property has been successfully removed
* else FALSE
*/
- const List<AnjutaProjectNodeInformation *> get_node_info();
+ const List<AnjutaProjectNodeInfo *> get_node_info();
}
/**
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index e0a15e6..1b1d484 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -393,14 +393,13 @@ amp_package_create_token (AmpProject *project, AnjutaAmPackageNode *package, GE
if (args != NULL)
{
AnjutaTokenStyle *style;
- gchar *name;
+ const gchar *name;
name = anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (package));
style = anjuta_token_style_new_from_base (project->ac_space_list);
//anjuta_token_style_update (style, args);
token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, name);
- g_free (name);
if (after)
{
diff --git a/plugins/am-project/am-node.c b/plugins/am-project/am-node.c
index f759d3b..7172a5a 100644
--- a/plugins/am-project/am-node.c
+++ b/plugins/am-project/am-node.c
@@ -206,14 +206,7 @@ amp_root_new (GFile *file, GError **error)
AnjutaAmRootNode *root = NULL;
root = g_object_new (ANJUTA_TYPE_AM_ROOT_NODE, NULL);
- root->base.type = ANJUTA_PROJECT_ROOT;
- root->base.native_properties = amp_get_project_property_list();
- root->base.custom_properties = NULL;
root->base.file = g_file_dup (file);
- root->base.name = NULL;
- root->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
- ANJUTA_PROJECT_CAN_ADD_PACKAGE,
- ANJUTA_PROJECT_CAN_SAVE;
return root;
@@ -351,6 +344,11 @@ G_DEFINE_TYPE (AnjutaAmRootNode, anjuta_am_root_node, ANJUTA_TYPE_PROJECT_NODE);
static void
anjuta_am_root_node_init (AnjutaAmRootNode *node)
{
+ node->base.type = ANJUTA_PROJECT_ROOT;
+ node->base.native_properties = amp_get_project_property_list();
+ node->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
+ ANJUTA_PROJECT_CAN_ADD_PACKAGE,
+ ANJUTA_PROJECT_CAN_SAVE;
node->configure_file = NULL;
node->configure_token = NULL;
}
@@ -423,14 +421,7 @@ amp_module_new (const gchar *name, GError **error)
AnjutaAmModuleNode *module = NULL;
module = g_object_new (ANJUTA_TYPE_AM_MODULE_NODE, NULL);
- module->base.type = ANJUTA_PROJECT_MODULE;
- module->base.native_properties = amp_get_module_property_list();
- module->base.custom_properties = NULL;
- module->base.file = NULL;
module->base.name = g_strdup (name);;
- module->base.state = ANJUTA_PROJECT_CAN_ADD_PACKAGE |
- ANJUTA_PROJECT_CAN_REMOVE;
- module->module = NULL;
return module;
}
@@ -456,6 +447,11 @@ G_DEFINE_TYPE (AnjutaAmModuleNode, anjuta_am_module_node, ANJUTA_TYPE_PROJECT_NO
static void
anjuta_am_module_node_init (AnjutaAmModuleNode *node)
{
+ node->base.type = ANJUTA_PROJECT_MODULE;
+ node->base.native_properties = amp_get_module_property_list();
+ node->base.state = ANJUTA_PROJECT_CAN_ADD_PACKAGE |
+ ANJUTA_PROJECT_CAN_REMOVE;
+ node->module = NULL;
}
static void
@@ -488,13 +484,7 @@ amp_package_new (const gchar *name, GError **error)
AnjutaAmPackageNode *node = NULL;
node = g_object_new (ANJUTA_TYPE_AM_PACKAGE_NODE, NULL);
- node->base.type = ANJUTA_PROJECT_PACKAGE;
- node->base.native_properties = amp_get_package_property_list();
- node->base.custom_properties = NULL;
- node->base.file = NULL;
node->base.name = g_strdup (name);
- node->base.state = ANJUTA_PROJECT_CAN_REMOVE;
- node->version = NULL;
return node;
}
@@ -551,6 +541,10 @@ G_DEFINE_TYPE (AnjutaAmPackageNode, anjuta_am_package_node, ANJUTA_TYPE_PROJECT_
static void
anjuta_am_package_node_init (AnjutaAmPackageNode *node)
{
+ node->base.type = ANJUTA_PROJECT_PACKAGE;
+ node->base.native_properties = amp_get_package_property_list();
+ node->base.state = ANJUTA_PROJECT_CAN_REMOVE;
+ node->version = NULL;
}
static void
@@ -774,16 +768,7 @@ amp_group_new (GFile *file, gboolean dist_only, GError **error)
g_free (name);
node = g_object_new (ANJUTA_TYPE_AM_GROUP_NODE, NULL);
- node->base.type = ANJUTA_PROJECT_GROUP;
- node->base.native_properties = amp_get_group_property_list();
- node->base.custom_properties = NULL;
node->base.file = g_object_ref (file);
- node->base.name = NULL;
- node->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
- ANJUTA_PROJECT_CAN_ADD_TARGET |
- ANJUTA_PROJECT_CAN_ADD_SOURCE |
- ANJUTA_PROJECT_CAN_REMOVE |
- ANJUTA_PROJECT_CAN_SAVE;
node->dist_only = dist_only;
node->variables = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)amp_variable_free);
@@ -812,6 +797,15 @@ G_DEFINE_TYPE (AnjutaAmGroupNode, anjuta_am_group_node, ANJUTA_TYPE_PROJECT_NODE
static void
anjuta_am_group_node_init (AnjutaAmGroupNode *node)
{
+ node->base.type = ANJUTA_PROJECT_GROUP;
+ node->base.native_properties = amp_get_group_property_list();
+ node->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
+ ANJUTA_PROJECT_CAN_ADD_TARGET |
+ ANJUTA_PROJECT_CAN_ADD_SOURCE |
+ ANJUTA_PROJECT_CAN_REMOVE |
+ ANJUTA_PROJECT_CAN_SAVE;
+ node->dist_only = FALSE;
+ node->variables = NULL;
node->makefile = NULL;
node->variables = NULL;
node->monitor = NULL;
@@ -867,6 +861,12 @@ anjuta_am_group_node_class_init (AnjutaAmGroupNodeClass *klass)
*---------------------------------------------------------------------------*/
+void
+amp_target_set_type (AnjutaAmTargetNode *target, AmTokenType type)
+{
+ target->base.type = ANJUTA_PROJECT_TARGET | type;
+ target->base.native_properties = amp_get_target_property_list(type);
+}
void
amp_target_add_token (AnjutaAmTargetNode *target, AmTokenType type, AnjutaToken *token)
@@ -959,16 +959,10 @@ amp_target_new (const gchar *name, AnjutaProjectNodeType type, const gchar *inst
}
node = g_object_new (ANJUTA_TYPE_AM_TARGET_NODE, NULL);
- node->base.type = ANJUTA_PROJECT_TARGET | type;
- node->base.native_properties = amp_get_target_property_list(type);
- node->base.custom_properties = NULL;
+ amp_target_set_type (node, type);
node->base.name = g_strdup (name);
- node->base.file = NULL;
- node->base.state = ANJUTA_PROJECT_CAN_ADD_SOURCE |
- ANJUTA_PROJECT_CAN_REMOVE;
node->install = g_strdup (install);
node->flags = flags;
- node->tokens = NULL;
return node;
}
@@ -994,6 +988,12 @@ G_DEFINE_TYPE (AnjutaAmTargetNode, anjuta_am_target_node, ANJUTA_TYPE_PROJECT_NO
static void
anjuta_am_target_node_init (AnjutaAmTargetNode *node)
{
+ node->base.type = ANJUTA_PROJECT_TARGET;
+ node->base.state = ANJUTA_PROJECT_CAN_ADD_SOURCE |
+ ANJUTA_PROJECT_CAN_REMOVE;
+ node->install = NULL;
+ node->flags = 0;
+ node->tokens = NULL;
}
static void
@@ -1046,13 +1046,7 @@ amp_source_new (GFile *file, GError **error)
AnjutaAmSourceNode *node = NULL;
node = g_object_new (ANJUTA_TYPE_AM_SOURCE_NODE, NULL);
- node->base.type = ANJUTA_PROJECT_SOURCE;
- node->base.native_properties = amp_get_source_property_list();
- node->base.custom_properties = NULL;
- node->base.name = NULL;
node->base.file = g_object_ref (file);
- node->base.state = ANJUTA_PROJECT_CAN_REMOVE;
- node->token = NULL;
return ANJUTA_PROJECT_NODE (node);
}
@@ -1078,6 +1072,10 @@ G_DEFINE_TYPE (AnjutaAmSourceNode, anjuta_am_source_node, ANJUTA_TYPE_PROJECT_NO
static void
anjuta_am_source_node_init (AnjutaAmSourceNode *node)
{
+ node->base.type = ANJUTA_PROJECT_SOURCE;
+ node->base.native_properties = amp_get_source_property_list();
+ node->base.state = ANJUTA_PROJECT_CAN_REMOVE;
+ node->token = NULL;
}
static void
diff --git a/plugins/am-project/am-node.h b/plugins/am-project/am-node.h
index 8279807..32de4a1 100644
--- a/plugins/am-project/am-node.h
+++ b/plugins/am-project/am-node.h
@@ -94,6 +94,7 @@ typedef enum _AmpTargetFlag
void amp_target_add_token (AnjutaAmTargetNode *target, AmTokenType type, AnjutaToken *token);
GList * amp_target_get_token (AnjutaAmTargetNode *target, AmTokenType type);
+void amp_target_set_type (AnjutaAmTargetNode *target, AmTokenType type);
AnjutaTokenType amp_target_get_first_token_type (AnjutaAmTargetNode *target);
AnjutaTokenType amp_target_get_next_token_type (AnjutaAmTargetNode *target, AnjutaTokenType type);
AnjutaAmTargetNode* amp_target_new (const gchar *name, AnjutaProjectNodeType type, const gchar *install, gint flags, GError **error);
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 4642481..457485f 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1408,8 +1408,8 @@ amp_project_set_am_variable (AmpProject* project, AnjutaAmGroupNode* group, Anju
static gint
amp_project_compare_node (AnjutaProjectNode *old_node, AnjutaProjectNode *new_node)
{
- gchar *name1;
- gchar *name2;
+ const gchar *name1;
+ const gchar *name2;
GFile *file1;
GFile *file2;
@@ -1558,7 +1558,10 @@ amp_project_duplicate_node (AnjutaProjectNode *old_node)
new_node = g_object_new (G_TYPE_FROM_INSTANCE (old_node), NULL);
if (old_node->file != NULL) new_node->file = g_file_dup (old_node->file);
if (old_node->name != NULL) new_node->name = g_strdup (old_node->name);
- new_node->type = old_node->type;
+ if (anjuta_project_node_get_node_type (old_node) == ANJUTA_PROJECT_TARGET)
+ {
+ amp_target_set_type (ANJUTA_AM_TARGET_NODE (new_node), anjuta_project_node_get_full_type (old_node));
+ }
new_node->parent = old_node->parent;
return new_node;
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index e7fa76c..cbbf1e3 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -139,7 +139,7 @@ amp_group_create_token (AmpProject *project, AnjutaAmGroupNode *group, GError *
AnjutaProjectNode *sibling;
AnjutaAmGroupNode *parent;
gboolean after;
- gchar *name;
+ const gchar *name;
/* Get parent target */
parent = ANJUTA_AM_GROUP_NODE (anjuta_project_node_parent(ANJUTA_PROJECT_NODE (group)));
@@ -284,7 +284,6 @@ amp_group_create_token (AmpProject *project, AnjutaAmGroupNode *group, GError *
amp_group_add_token (group, token, AM_GROUP_TOKEN_SUBDIRS);
}
- g_free (name);
tfile = amp_group_set_makefile (group, makefile, G_OBJECT (project));
amp_project_add_file (project, makefile, tfile);
@@ -415,7 +414,7 @@ amp_target_create_token (AmpProject *project, AnjutaAmTargetNode *target, GErro
AnjutaToken *prev;
AmpNodeInfo *info;
gchar *targetname;
- gchar *name;
+ const gchar *name;
GList *last;
AnjutaAmTargetNode *sibling;
AnjutaAmGroupNode *parent;
@@ -536,7 +535,6 @@ amp_target_create_token (AmpProject *project, AnjutaAmTargetNode *target, GErro
amp_target_add_token (target, ANJUTA_TOKEN_ARGUMENT, token);
}
- g_free (name);
return TRUE;
}
diff --git a/plugins/am-project/projectparser.c b/plugins/am-project/projectparser.c
index f6ae097..c535c87 100644
--- a/plugins/am-project/projectparser.c
+++ b/plugins/am-project/projectparser.c
@@ -173,14 +173,14 @@ list_group (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNode
GFile *root;
root = g_file_get_parent (anjuta_project_node_get_file (parent));
- rel_path = g_file_get_relative_path (root, anjuta_project_group_get_directory (group));
+ rel_path = g_file_get_relative_path (root, anjuta_project_node_get_file (group));
g_object_unref (root);
}
else
{
GFile *root;
root = anjuta_project_node_get_file (parent);
- rel_path = g_file_get_relative_path (root, anjuta_project_group_get_directory (group));
+ rel_path = g_file_get_relative_path (root, anjuta_project_node_get_file (group));
}
print ("%*sGROUP (%s): %s", indent * INDENT, "", path, rel_path);
g_free (rel_path);
@@ -331,7 +331,7 @@ get_file (AnjutaProjectNode *target, const char *id)
{
AnjutaProjectNode *group = (AnjutaProjectNode *)anjuta_project_node_parent (target);
- return g_file_resolve_relative_path (anjuta_project_group_get_directory (group), id);
+ return g_file_resolve_relative_path (anjuta_project_node_get_file (group), id);
}
static AnjutaProjectNodeType
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index 9af9bfb..ec9a801 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -178,8 +178,8 @@ project_node_new (DirProject *project, AnjutaProjectNode *parent, AnjutaProjectN
}
if (node != NULL)
{
- ANJUTA_PROJECT_NODE_DATA (node)->type = type;
- ANJUTA_PROJECT_NODE_DATA (node)->parent = parent;
+ node->type = type;
+ node->parent = parent;
}
return node;
@@ -895,7 +895,7 @@ iproject_get_root (IAnjutaProject *obj, GError **error)
return DIR_PROJECT (obj)->root;
}
-static GList*
+static const GList*
iproject_get_node_info (IAnjutaProject *obj, GError **err)
{
return dir_project_get_node_info (DIR_PROJECT (obj), err);
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 25c9d66..b8e5143 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -138,24 +138,6 @@ pm_property_entry_free (PropertyEntry *prop)
g_slice_free (PropertyEntry, prop);
}
-static PropertyValue*
-pm_property_value_new (AnjutaProjectProperty *property, const gchar *value)
-{
- PropertyValue *prop;
-
- prop = g_slice_new0(PropertyValue);
- prop->property = property;
- prop->value = value;
-
- return prop;
-}
-
-static void
-pm_property_value_free (PropertyValue *prop)
-{
- g_slice_free (PropertyValue, prop);
-}
-
static gboolean
parent_filter_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
{
@@ -609,7 +591,6 @@ on_properties_dialog_response (GtkWidget *dialog,
if (id == GTK_RESPONSE_APPLY)
{
GList *item;
- GList *modified = NULL;
/* Get all modified properties */
for (item = g_list_first (table->properties); item != NULL; item = g_list_next (item))
@@ -633,10 +614,7 @@ on_properties_dialog_response (GtkWidget *dialog,
if ((prop->value != NULL) && (*prop->value != '\0'))
{
/* Remove */
- PropertyValue *value;
-
- value = pm_property_value_new (prop, NULL);
- modified = g_list_prepend (modified, value);
+ ianjuta_project_set_property (table->project->project, table->node, prop, NULL, NULL);
}
}
else
@@ -644,10 +622,7 @@ on_properties_dialog_response (GtkWidget *dialog,
if (g_strcmp0 (prop->value, text) != 0)
{
/* Modified */
- PropertyValue *value;
-
- value = pm_property_value_new (prop, text);
- modified = g_list_prepend (modified, value);
+ ianjuta_project_set_property (table->project->project, table->node, prop, text, NULL);
}
}
break;
@@ -658,10 +633,7 @@ on_properties_dialog_response (GtkWidget *dialog,
if (active != (*text == '1'))
{
/* Modified */
- PropertyValue *value;
-
- value = pm_property_value_new (prop, text);
- modified = g_list_prepend (modified, value);
+ ianjuta_project_set_property (table->project->project, table->node, prop, text, NULL);
}
break;
case ANJUTA_PROJECT_PROPERTY_MAP:
@@ -670,21 +642,6 @@ on_properties_dialog_response (GtkWidget *dialog,
break;
}
}
-
- /* Update all modified properties */
- anjuta_pm_project_set_properties (table->project, table->node, modified, NULL);
-
- /* Display modified properties */
- /*for (item = g_list_first (modified); item != NULL; item = g_list_next (item))
- {
- PropertyValue *value = (PropertyValue *)item->data;
- AnjutaProjectPropertyInfo *info;
-
- info = anjuta_project_property_get_info (value->property);
-
- }*/
-
- g_list_foreach (modified, (GFunc)pm_property_value_free, NULL);
}
g_list_foreach (table->properties, (GFunc)pm_property_entry_free, NULL);
g_free (table);
@@ -1549,12 +1506,11 @@ anjuta_pm_project_new_package (AnjutaPmProject *project,
if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_MODULE)
{
GtkTreeIter list_iter;
- gchar *name;
+ const gchar *name;
name = anjuta_project_node_get_name (node);
gtk_list_store_append (store, &list_iter);
gtk_list_store_set (store, &list_iter, 0, name, -1);
- g_free (name);
if (node == module)
{
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index cf400a8..62d8959 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -753,7 +753,7 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
anjuta_pm_project_remove (plugin->project, node, &err);
if (err)
{
- gchar *name;
+ const gchar *name;
update_operation_end (plugin, TRUE);
update = FALSE;
@@ -761,7 +761,6 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
anjuta_util_dialog_error (get_plugin_parent_window (plugin),
_("Failed to remove '%s':\n%s"),
name, err->message);
- g_free (name);
g_error_free (err);
}
}
@@ -1877,28 +1876,13 @@ get_element_file_from_node (ProjectManagerPlugin *plugin, AnjutaProjectNode *nod
NULL);
}
- switch (anjuta_project_node_get_node_type (node))
- {
- case ANJUTA_PROJECT_GROUP:
- file = g_object_ref (anjuta_project_group_get_directory (node));
- break;
- case ANJUTA_PROJECT_TARGET:
- file = anjuta_project_group_get_directory (anjuta_project_node_parent (node));
- file = g_file_get_child (file, anjuta_project_target_get_name (node));
- break;
- case ANJUTA_PROJECT_SOURCE:
- file = g_object_ref (anjuta_project_source_get_file (node));
- break;
- default:
- file = NULL;
- break;
- }
+ file = g_object_ref (anjuta_project_node_get_file (node));
if ((file != NULL) && (project_root != NULL))
{
gchar *rel_path;
- rel_path = g_file_get_relative_path (anjuta_project_group_get_directory (anjuta_pm_project_get_root (plugin->project)), file);
+ rel_path = g_file_get_relative_path (anjuta_project_node_get_file (anjuta_pm_project_get_root (plugin->project)), file);
if (rel_path)
{
@@ -2049,7 +2033,7 @@ iproject_manager_get_selected (IAnjutaProjectManager *project_manager,
ANJUTA_PROJECT_SOURCE);
if (node && anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_SOURCE)
{
- return g_object_ref (anjuta_project_source_get_file (node));
+ return g_object_ref (anjuta_project_node_get_file (node));
}
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
@@ -2063,7 +2047,7 @@ iproject_manager_get_selected (IAnjutaProjectManager *project_manager,
ANJUTA_PROJECT_GROUP);
if (node && anjuta_project_node_get_node_type (node) == GBF_TREE_NODE_GROUP)
{
- return g_object_ref (anjuta_project_group_get_directory (node));
+ return g_object_ref (anjuta_project_node_get_file (node));
}
return NULL;
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 697da90..627455c 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -326,7 +326,7 @@ anjuta_pm_project_get_packages (AnjutaPmProject *project)
{
if (anjuta_project_node_get_node_type (package) == ANJUTA_PROJECT_PACKAGE)
{
- g_hash_table_replace (all, anjuta_project_node_get_name (package), NULL);
+ g_hash_table_replace (all, (gpointer)anjuta_project_node_get_name (package), NULL);
}
}
}
@@ -383,23 +383,6 @@ anjuta_pm_project_remove (AnjutaPmProject *project, AnjutaProjectNode *node, GEr
}
gboolean
-anjuta_pm_project_set_properties (AnjutaPmProject *project, AnjutaProjectNode *node, GList *properties, GError **error)
-{
- GList *item;
- gboolean valid = FALSE;
-
- for (item = g_list_first (properties); item != NULL; item = g_list_next (item))
- {
- AnjutaProjectPropertyValue *prop = (AnjutaProjectPropertyValue *)item->data;
-
- valid = ianjuta_project_set_property (project->project, node, prop->property, prop->value, error) != NULL;
- if (!valid) break;
- }
-
- return valid;
-}
-
-gboolean
anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *data, GError **error)
{
GtkTreeIter iter;
@@ -489,10 +472,9 @@ find_module (AnjutaProjectNode *node, gpointer data)
if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_MODULE)
{
- gchar *name = anjuta_project_node_get_name (node);
+ const gchar *name = anjuta_project_node_get_name (node);
found = g_strcmp0 (name, (const gchar *)data) == 0;
- g_free (name);
}
return found;
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 7f9d921..a84bdde 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -91,8 +91,6 @@ AnjutaProjectNode *anjuta_pm_project_get_root (AnjutaPmProject *project);
gboolean anjuta_pm_project_remove (AnjutaPmProject *project, AnjutaProjectNode *node, GError **error);
gboolean anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *data, GError **error);
-gboolean anjuta_pm_project_set_properties (AnjutaPmProject *project, AnjutaProjectNode *node, GList *properties, GError **error);
-
gboolean anjuta_pm_project_is_open (AnjutaPmProject *project);
diff --git a/plugins/project-manager/tree-data.c b/plugins/project-manager/tree-data.c
index 6bd4c9b..cb7ce21 100644
--- a/plugins/project-manager/tree-data.c
+++ b/plugins/project-manager/tree-data.c
@@ -56,35 +56,11 @@ gchar *
gbf_tree_data_get_uri (GbfTreeData *data)
{
return data->node ? g_file_get_uri (anjuta_project_node_get_file (data->node)) : NULL;
- /*
- //return g_file_get_uri (anjuta_project_node_get_file (data->node));
- if (data->source != NULL)
- {
- return g_file_get_uri (data->source);
- }
- else if (data->target != NULL)
- {
- GFile *target;
- gchar *uri;
-
- target = g_file_get_child (data->group, data->target);
- uri = g_file_get_uri (target);
- g_object_unref (target);
-
- return uri;
- }
- else if (data->group != NULL)
- {
- return g_file_get_uri (data->group);
- }
-
- return NULL;*/
}
GFile *
gbf_tree_data_get_file (GbfTreeData *data)
{
- //return g_object_ref (anjuta_project_node_get_file (data->node));
if (data->source != NULL)
{
return g_object_ref (g_file_get_uri (data->source));
@@ -123,17 +99,6 @@ gbf_tree_data_get_node (GbfTreeData *data)
return data->node;
}
-void
-gbf_tree_data_replace_node (GbfTreeData *data, AnjutaProjectNode *node)
-{
- GFile *file = ANJUTA_PROJECT_NODE_DATA(node)->file;
-
- /* Replace file to keep the same interface */
- ANJUTA_PROJECT_NODE_DATA(node)->file = ANJUTA_PROJECT_NODE_DATA(data->node)->file;
- ANJUTA_PROJECT_NODE_DATA(data->node)->file = file;
- data->node = node;
-}
-
gboolean
gbf_tree_data_equal (GbfTreeData *data_a, GbfTreeData *data_b)
{
@@ -270,7 +235,7 @@ gbf_tree_data_new_group (AnjutaProjectNode *group)
data->type = GBF_TREE_NODE_GROUP;
data->node = group;
- ginfo = g_file_query_info (anjuta_project_group_get_directory (group),
+ ginfo = g_file_query_info (anjuta_project_node_get_file (group),
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
@@ -281,10 +246,10 @@ gbf_tree_data_new_group (AnjutaProjectNode *group)
}
else
{
- data->name = g_file_get_basename (anjuta_project_group_get_directory (group));
+ data->name = g_strdup (anjuta_project_node_get_name (group));
}
- data->group = g_object_ref (anjuta_project_group_get_directory (group));
+ data->group = g_object_ref (anjuta_project_node_get_file (group));
return data;
}
@@ -297,11 +262,11 @@ gbf_tree_data_new_target (AnjutaProjectNode *target)
data->type = GBF_TREE_NODE_TARGET;
data->node = target;
- data->name = g_strdup (anjuta_project_target_get_name (target));
+ data->name = g_strdup (anjuta_project_node_get_name (target));
group = anjuta_project_node_parent (target);
- data->group = g_object_ref (anjuta_project_group_get_directory (group));
- data->target = g_strdup (anjuta_project_target_get_name (target));
+ data->group = g_object_ref (anjuta_project_node_get_file (group));
+ data->target = g_strdup (anjuta_project_node_get_name (target));
return data;
}
@@ -316,7 +281,7 @@ gbf_tree_data_new_source (AnjutaProjectNode *source)
data->type = GBF_TREE_NODE_SOURCE;
data->node = source;
- data->source = g_object_ref (anjuta_project_source_get_file (source));
+ data->source = g_object_ref (anjuta_project_node_get_file (source));
ginfo = g_file_query_info (data->source,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
@@ -335,15 +300,15 @@ gbf_tree_data_new_source (AnjutaProjectNode *source)
parent = anjuta_project_node_parent (source);
if (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_GROUP)
{
- data->group = g_object_ref (anjuta_project_group_get_directory (parent));
+ data->group = g_object_ref (anjuta_project_node_get_file (parent));
}
else if (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_TARGET)
{
AnjutaProjectNode *group;
group = anjuta_project_node_parent (parent);
- data->group = g_object_ref (anjuta_project_group_get_directory (group));
- data->target = g_strdup (anjuta_project_target_get_name (parent));
+ data->group = g_object_ref (anjuta_project_node_get_file (group));
+ data->target = g_strdup (anjuta_project_node_get_name (parent));
}
return data;
diff --git a/plugins/project-manager/tree-data.h b/plugins/project-manager/tree-data.h
index 415aecf..974e182 100644
--- a/plugins/project-manager/tree-data.h
+++ b/plugins/project-manager/tree-data.h
@@ -60,8 +60,6 @@ gchar *gbf_tree_data_get_uri (GbfTreeData *data);
GFile *gbf_tree_data_get_file (GbfTreeData *data);
const gchar *gbf_tree_data_get_name (GbfTreeData *data);
AnjutaProjectNode *gbf_tree_data_get_node (GbfTreeData *data);
-void gbf_tree_data_replace_node (GbfTreeData *data,
- AnjutaProjectNode *node);
gchar *gbf_tree_data_get_path (GbfTreeData *data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]