[anjuta/newproject] Create a new IAnjutaProject interface
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Create a new IAnjutaProject interface
- Date: Mon, 5 Apr 2010 09:25:54 +0000 (UTC)
commit a0aea1081c362c083edce23bd43261e6220da822
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Apr 4 16:34:51 2010 +0200
Create a new IAnjutaProject interface
Only the autotools project is using it, the directory and makefile project are not working
libanjuta/anjuta-project.c | 19 ++-
libanjuta/anjuta-project.h | 18 +-
libanjuta/interfaces/libanjuta.idl | 78 +++++++
plugins/am-project/am-project.c | 304 +++++++++++++++++++--------
plugins/am-project/am-project.h | 2 +-
plugins/project-manager/gbf-project-model.c | 40 +++-
plugins/project-manager/gbf-tree-data.h | 3 +-
plugins/project-manager/project.c | 23 ++-
plugins/project-manager/project.h | 3 +
9 files changed, 380 insertions(+), 110 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 9710607..0a9ba86 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -304,13 +304,19 @@ anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node)
AnjutaProjectNodeType
anjuta_project_node_get_type (const AnjutaProjectNode *node)
{
+ return node == NULL ? ANJUTA_PROJECT_UNKNOWN : (NODE_DATA (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;
}
gchar *
anjuta_project_node_get_name (const AnjutaProjectNode *node)
{
- switch (NODE_DATA (node)->type)
+ switch (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK)
{
case ANJUTA_PROJECT_GROUP:
return g_file_get_basename (NODE_DATA (node)->file);
@@ -332,7 +338,7 @@ anjuta_project_node_get_uri (AnjutaProjectNode *node)
GFile *file;
gchar *uri;
- switch (NODE_DATA (node)->type)
+ switch (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK)
{
case ANJUTA_PROJECT_GROUP:
uri = g_file_get_uri (NODE_DATA (node)->file);
@@ -360,7 +366,7 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
AnjutaProjectNode *parent;
GFile *file;
- switch (NODE_DATA (node)->type)
+ switch (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK)
{
case ANJUTA_PROJECT_TARGET:
parent = anjuta_project_node_parent (node);
@@ -370,6 +376,7 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
case ANJUTA_PROJECT_SOURCE:
case ANJUTA_PROJECT_MODULE:
case ANJUTA_PROJECT_PACKAGE:
+ case ANJUTA_PROJECT_ROOT:
file = g_object_ref (NODE_DATA (node)->file);
break;
default:
@@ -449,7 +456,7 @@ anjuta_project_group_compare (GNode *node, gpointer data)
{
GFile *file = *(GFile **)data;
- if ((NODE_DATA(node)->type == ANJUTA_PROJECT_GROUP) && g_file_equal (NODE_DATA(node)->file, file))
+ if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_GROUP) && g_file_equal (NODE_DATA(node)->file, file))
{
*(AnjutaProjectNode **)data = node;
@@ -489,7 +496,7 @@ anjuta_project_target_compare (GNode *node, gpointer data)
{
const gchar *name = *(gchar **)data;
- if ((NODE_DATA(node)->type == ANJUTA_PROJECT_TARGET) && (strcmp (NODE_DATA(node)->name, name) == 0))
+ if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET) && (strcmp (NODE_DATA(node)->name, name) == 0))
{
*(AnjutaProjectNode **)data = node;
@@ -517,7 +524,7 @@ anjuta_project_source_compare (GNode *node, gpointer data)
{
GFile *file = *(GFile **)data;
- if ((NODE_DATA(node)->type == ANJUTA_PROJECT_SOURCE) && g_file_equal (NODE_DATA(node)->file, file))
+ if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_SOURCE) && g_file_equal (NODE_DATA(node)->file, file))
{
*(AnjutaProjectNode **)data = node;
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 7e05543..3bc83dc 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -31,13 +31,16 @@ G_BEGIN_DECLS
typedef enum
{
- ANJUTA_PROJECT_UNKNOWN,
- ANJUTA_PROJECT_GROUP,
- ANJUTA_PROJECT_TARGET,
- ANJUTA_PROJECT_SOURCE,
- ANJUTA_PROJECT_MODULE,
- ANJUTA_PROJECT_PACKAGE,
- ANJUTA_PROJECT_VARIABLE
+ ANJUTA_PROJECT_UNKNOWN = 0,
+ ANJUTA_PROJECT_EXECUTABLE = 1 << 15,
+ ANJUTA_PROJECT_TYPE_MASK = 0xFFFF << 16,
+ ANJUTA_PROJECT_ROOT = 1 << 16,
+ ANJUTA_PROJECT_GROUP = 2 << 16,
+ ANJUTA_PROJECT_TARGET = 3 << 16,
+ ANJUTA_PROJECT_SOURCE = 4 << 16 ,
+ ANJUTA_PROJECT_MODULE = 5 << 16,
+ ANJUTA_PROJECT_PACKAGE = 6 << 16,
+ ANJUTA_PROJECT_VARIABLE = 7 << 16
} AnjutaProjectNodeType;
typedef enum
@@ -157,6 +160,7 @@ void anjuta_project_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNode
void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
AnjutaProjectNodeType anjuta_project_node_get_type (const AnjutaProjectNode *node);
+AnjutaProjectNodeType anjuta_project_node_get_full_type (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);
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 16581d4..16e3943 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3084,6 +3084,84 @@ interface IAnjutaProject
void ::project_updated ();
/**
+ * ianjuta_project_load_node:
+ * @obj: Self
+ * @node: Project node to reload
+ * @err: Error propagation and reporting
+ *
+ * Reload a project node
+ *
+ * Return value: The newly loaded node, NULL if error
+ */
+ AnjutaProjectNode *load_node (AnjutaProjectNode *node);
+
+ /**
+ * ianjuta_project_save_node:
+ * @obj: Self
+ * @node: Project node to save
+ * @err: Error propagation and reporting
+ *
+ * Save a project node
+ *
+ * Return value: The saved node, NULL if error
+ */
+ AnjutaProjectNode *save_node (AnjutaProjectNode *node);
+
+ /**
+ * ianjuta_project_new_root:
+ * @obj: Self
+ * @file: Project file or directory
+ * @err: Error propagation and reporting
+ *
+ * Create a new node representing the project root.
+ *
+ * Return value: The newly created node, NULL if error
+ */
+ AnjutaProjectNode *new_root (GFile *file);
+
+ /**
+ * ianjuta_project_new_file:
+ * @obj: Self
+ * @parent: Parent node
+ * @sibling: Sibling node or NULL
+ * @type: Node type
+ * @file: Node file or directory
+ * @err: Error propagation and reporting
+ *
+ * Create a new node as a child of parent after sibling or as the last
+ * child if sibling is NULL.
+ *
+ * Return value: The newly created node, NULL if error
+ */
+ AnjutaProjectNode *new_file (GFile *file);
+
+ /**
+ * ianjuta_project_new_name:
+ * @obj: Self
+ * @parent: Parent node
+ * @sibling: Sibling node or NULL
+ * @type: Node type
+ * @name: Node name
+ * @err: Error propagation and reporting
+ *
+ * Create a new node as a child of parent after sibling or as the last
+ * child if sibling is NULL.
+ *
+ * Return value: The newly created node, NULL if error
+ */
+ AnjutaProjectNode *new_name (const gchar *name);
+
+ /**
+ * ianjuta_project_free_node:
+ * @obj: Self
+ * @node: Node
+ * @err: Error propagation and reporting
+ *
+ * Free a node and its children.
+ */
+ void free_node (AnjutaProjectNode *node);
+
+ /**
* ianjuta_project_load:
* @obj: Self
* @file: Project directory
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 07ead8d..80b180d 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -69,6 +69,7 @@ static const gchar *valid_am_makefiles[] = {"GNUmakefile.am", "makefile.am", "Ma
#define AMP_SOURCE_DATA(node) ((node) != NULL ? (AmpSourceData *)((node)->data) : NULL)
#define AMP_PACKAGE_DATA(node) ((node) != NULL ? (AmpPackageData *)((node)->data) : NULL)
#define AMP_MODULE_DATA(node) ((node) != NULL ? (AmpModuleData *)((node)->data) : NULL)
+#define AMP_ROOT_DATA(node) ((node) != NULL ? (AmpRootData *)((node)->data) : NULL)
#define STR_REPLACE(target, source) \
{ g_free (target); target = source == NULL ? NULL : g_strdup (source);}
@@ -86,6 +87,12 @@ typedef enum {
AM_GROUP_TOKEN_LAST
} AmpGroupTokenCategory;
+typedef struct _AmpRootData AmpRootData;
+
+struct _AmpRootData {
+ AnjutaProjectNodeData base; /* Common node data */
+};
+
typedef struct _AmpGroupData AmpGroupData;
struct _AmpGroupData {
@@ -565,6 +572,37 @@ amp_config_file_free (AmpConfigFile *config)
}
}
+/* Root node object
+ *---------------------------------------------------------------------------*/
+
+static AnjutaProjectNode*
+amp_root_new (GFile *file)
+{
+ AmpRootData *root = NULL;
+
+ g_return_val_if_fail (file != NULL, NULL);
+
+ root = g_slice_new0(AmpRootData);
+ root->base.type = ANJUTA_PROJECT_ROOT;
+ root->base.properties = amp_get_project_property_list();
+ root->base.file = g_file_dup (file);
+
+ return g_node_new (root);
+}
+
+static void
+amp_root_free (AnjutaProjectNode *node)
+{
+ AnjutaProjectNodeData *data = AMP_NODE_DATA (node);
+
+ if (data->file != NULL) g_object_unref (data->file);
+ g_free (data->name);
+ anjuta_project_property_foreach (data->properties, (GFunc)amp_property_free, NULL);
+ g_slice_free (AmpRootData, (AmpRootData *)data);
+
+ g_node_destroy (node);
+}
+
/* Package objects
*---------------------------------------------------------------------------*/
@@ -871,7 +909,7 @@ monitor_cb (GFileMonitor *monitor,
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_DELETED:
/* monitor will be removed here... is this safe? */
- amp_project_reload (project, NULL);
+ //amp_project_reload (project, NULL);
g_signal_emit_by_name (G_OBJECT (project), "project-updated");
break;
default:
@@ -964,7 +1002,7 @@ amp_dump_node (AnjutaProjectNode *g_node)
{
gchar *name = NULL;
- switch (AMP_NODE_DATA (g_node)->type) {
+ switch (AMP_NODE_DATA (g_node)->type & ANJUTA_PROJECT_TYPE_MASK) {
case ANJUTA_PROJECT_GROUP:
name = g_file_get_uri (AMP_GROUP_DATA (g_node)->base.file);
DEBUG_PRINT ("GROUP: %s", name);
@@ -988,7 +1026,7 @@ static void
foreach_node_destroy (AnjutaProjectNode *g_node,
gpointer data)
{
- switch (AMP_NODE_DATA (g_node)->type) {
+ switch (AMP_NODE_DATA (g_node)->type & ANJUTA_PROJECT_TYPE_MASK) {
case ANJUTA_PROJECT_GROUP:
//g_hash_table_remove (project->groups, g_file_get_uri (AMP_GROUP_NODE (g_node)->file));
amp_group_free (g_node);
@@ -1006,6 +1044,9 @@ foreach_node_destroy (AnjutaProjectNode *g_node,
case ANJUTA_PROJECT_PACKAGE:
amp_package_free (g_node);
break;
+ case ANJUTA_PROJECT_ROOT:
+ amp_root_free (g_node);
+ break;
default:
g_assert_not_reached ();
break;
@@ -1028,6 +1069,40 @@ project_node_destroy (AmpProject *project, AnjutaProjectNode *g_node)
}
}
+static AnjutaProjectNode *
+project_node_new (AmpProject *project, AnjutaProjectNodeType type, GFile *file, const gchar *name)
+{
+ AnjutaProjectNode *node = NULL;
+
+ switch (type & ANJUTA_PROJECT_TYPE_MASK) {
+ case ANJUTA_PROJECT_GROUP:
+ node = amp_group_new (file, FALSE);
+ break;
+ case ANJUTA_PROJECT_TARGET:
+ node = amp_target_new (name, 0, NULL, 0);
+ break;
+ case ANJUTA_PROJECT_SOURCE:
+ node = amp_source_new (file);
+ break;
+ case ANJUTA_PROJECT_MODULE:
+ node = amp_module_new (NULL);
+ break;
+ case ANJUTA_PROJECT_PACKAGE:
+ node = amp_package_new (name);
+ break;
+ case ANJUTA_PROJECT_ROOT:
+ node = amp_root_new (file);
+ g_message ("root node file %s file %s", g_file_get_path (anjuta_project_node_get_file (node)), g_file_get_path (file));
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ if (node != NULL) AMP_NODE_DATA (node)->type = type;
+
+ return node;
+}
+
void
amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToken *args)
{
@@ -1170,7 +1245,7 @@ amp_project_load_config (AmpProject *project, AnjutaToken *arg_list)
static void
find_target (AnjutaProjectNode *node, gpointer data)
{
- if (AMP_NODE_DATA (node)->type == ANJUTA_PROJECT_TARGET)
+ if ((AMP_NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET)
{
if (strcmp (AMP_TARGET_DATA (node)->base.name, *(gchar **)data) == 0)
{
@@ -1185,7 +1260,7 @@ find_target (AnjutaProjectNode *node, gpointer data)
static void
find_canonical_target (AnjutaProjectNode *node, gpointer data)
{
- if (AMP_NODE_DATA (node)->type == ANJUTA_PROJECT_TARGET)
+ if ((AMP_NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET)
{
gchar *canon_name = canonicalize_automake_variable (AMP_TARGET_DATA (node)->base.name);
DEBUG_PRINT ("compare canon %s vs %s node %p", canon_name, *(gchar **)data, node);
@@ -1759,93 +1834,107 @@ amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenTy
/* Public functions
*---------------------------------------------------------------------------*/
-gboolean
-amp_project_reload (AmpProject *project, GError **error)
+AnjutaProjectNode *
+amp_project_load_node (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
AmpAcScanner *scanner;
AnjutaToken *arg;
+ AnjutaProjectNode *group;
GFile *root_file;
GFile *configure_file;
gboolean ok = TRUE;
GError *err = NULL;
- /* Unload current project */
- root_file = g_object_ref (project->root_file);
- amp_project_unload (project);
- project->root_file = root_file;
- DEBUG_PRINT ("reload project %p root file %p", project, project->root_file);
+ switch (anjuta_project_node_get_type (node))
+ {
+ case ANJUTA_PROJECT_ROOT:
- /* shortcut hash tables */
- project->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- project->files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, g_object_unref);
- project->configs = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, NULL, (GDestroyNotify)amp_config_file_free);
- amp_project_new_module_hash (project);
+ /* Unload current project */
+ amp_project_unload (project);
+ DEBUG_PRINT ("reload project %p root file %p", project, root_file);
+
+ root_file = anjuta_project_node_get_file (node);
+ g_message ("reload project %s", g_file_get_path (root_file));
+ project->root_file = root_file;
+ project->root_node = node;
- /* Initialize list styles */
- project->ac_space_list = anjuta_token_style_new (NULL, " ", "\n", NULL, 0);
- project->am_space_list = anjuta_token_style_new (NULL, " ", " \\\n", NULL, 0);
- project->arg_list = anjuta_token_style_new (NULL, ", ", ", ", ")", 0);
+ /* shortcut hash tables */
+ project->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ project->files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, g_object_unref);
+ project->configs = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, NULL, (GDestroyNotify)amp_config_file_free);
+ amp_project_new_module_hash (project);
+
+ /* Initialize list styles */
+ project->ac_space_list = anjuta_token_style_new (NULL, " ", "\n", NULL, 0);
+ project->am_space_list = anjuta_token_style_new (NULL, " ", " \\\n", NULL, 0);
+ project->arg_list = anjuta_token_style_new (NULL, ", ", ", ", ")", 0);
- /* Find configure file */
- if (file_type (root_file, "configure.ac") == G_FILE_TYPE_REGULAR)
- {
- configure_file = g_file_get_child (root_file, "configure.ac");
- }
- else if (file_type (root_file, "configure.in") == G_FILE_TYPE_REGULAR)
- {
- configure_file = g_file_get_child (root_file, "configure.in");
- }
- else
- {
- g_set_error (error, IANJUTA_PROJECT_ERROR,
- IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
- _("Project doesn't exist or invalid path"));
+ /* Find configure file */
+ if (file_type (root_file, "configure.ac") == G_FILE_TYPE_REGULAR)
+ {
+ configure_file = g_file_get_child (root_file, "configure.ac");
+ }
+ else if (file_type (root_file, "configure.in") == G_FILE_TYPE_REGULAR)
+ {
+ configure_file = g_file_get_child (root_file, "configure.in");
+ }
+ else
+ {
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
+ _("Project doesn't exist or invalid path"));
- return FALSE;
- }
-
- /* Create root node */
- project->root_node = amp_group_new (project->root_file, FALSE);
- g_hash_table_insert (project->groups, g_file_get_uri (project->root_file), project->root_node);
-
- /* Parse configure */
- project->configure_file = anjuta_token_file_new (configure_file);
- g_hash_table_insert (project->files, configure_file, project->configure_file);
- g_object_add_toggle_ref (G_OBJECT (project->configure_file), remove_config_file, project);
- arg = anjuta_token_file_load (project->configure_file, NULL);
- //fprintf (stdout, "AC file before parsing\n");
- //anjuta_token_dump (arg);
- //fprintf (stdout, "\n");
- scanner = amp_ac_scanner_new (project);
- project->configure_token = amp_ac_scanner_parse_token (scanner, arg, 0, &err);
- //fprintf (stdout, "AC file after parsing\n");
- //anjuta_token_check (arg);
- //anjuta_token_dump (project->configure_token);
- //fprintf (stdout, "\n");
- amp_ac_scanner_free (scanner);
- if (project->configure_token == NULL)
- {
- g_set_error (error, IANJUTA_PROJECT_ERROR,
- IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED,
- err == NULL ? _("Unable to parse project file") : err->message);
- if (err != NULL) g_error_free (err);
+ return NULL;
+ }
+
+
+ /* Create first group */
+ /*group = amp_group_new (root_file, FALSE);
+ anjuta_project_node_append (node, group);
+ g_hash_table_insert (project->groups, g_file_get_uri (root_file), group);*/
+
+ /* Parse configure */
+ project->configure_file = anjuta_token_file_new (configure_file);
+ g_hash_table_insert (project->files, configure_file, project->configure_file);
+ g_object_add_toggle_ref (G_OBJECT (project->configure_file), remove_config_file, project);
+ arg = anjuta_token_file_load (project->configure_file, NULL);
+ //fprintf (stdout, "AC file before parsing\n");
+ //anjuta_token_dump (arg);
+ //fprintf (stdout, "\n");
+ scanner = amp_ac_scanner_new (project);
+ project->configure_token = amp_ac_scanner_parse_token (scanner, arg, 0, &err);
+ //fprintf (stdout, "AC file after parsing\n");
+ //anjuta_token_check (arg);
+ //anjuta_token_dump (project->configure_token);
+ //fprintf (stdout, "\n");
+ amp_ac_scanner_free (scanner);
+ if (project->configure_token == NULL)
+ {
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED,
+ err == NULL ? _("Unable to parse project file") : err->message);
+ if (err != NULL) g_error_free (err);
- return FALSE;
- }
+ return NULL;
+ }
- monitors_setup (project);
+ monitors_setup (project);
- /* Load all makefiles recursively */
- if (project_load_makefile (project, project->root_file, NULL, FALSE) == NULL)
- {
- g_set_error (error, IANJUTA_PROJECT_ERROR,
- IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
- _("Project doesn't exist or invalid path"));
+ /* Load all makefiles recursively */
+ if (project_load_makefile (project, project->root_file, node, FALSE) == NULL)
+ {
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
+ _("Project doesn't exist or invalid path"));
- ok = FALSE;
+ return NULL;
+ }
+ break;
+ default:
+ break;
}
- return ok;
+ return node;
}
gboolean
@@ -1856,11 +1945,11 @@ amp_project_load (AmpProject *project,
g_return_val_if_fail (directory != NULL, FALSE);
project->root_file = g_object_ref (directory);
- if (!amp_project_reload (project, error))
+ /*if (!amp_project_reload (project, error))
{
g_object_unref (project->root_file);
project->root_file = NULL;
- }
+ }*/
return project->root_file != NULL;
}
@@ -2058,7 +2147,7 @@ amp_project_add_sibling_group (AmpProject *project,
if (sibling == NULL)
{
/* Find a sibling before */
- for (last = anjuta_project_node_prev_sibling (child); (last != NULL) && (AMP_NODE_DATA (last)->type != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_prev_sibling (last));
+ for (last = anjuta_project_node_prev_sibling (child); (last != NULL) && (anjuta_project_node_get_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_prev_sibling (last));
if (last != NULL)
{
sibling = last;
@@ -2067,7 +2156,7 @@ amp_project_add_sibling_group (AmpProject *project,
else
{
/* Find a sibling after */
- for (last = anjuta_project_node_next_sibling (child); (last != NULL) && (AMP_NODE_DATA (last)->type != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_next_sibling (last));
+ for (last = anjuta_project_node_next_sibling (child); (last != NULL) && (anjuta_project_node_get_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_next_sibling (last));
if (last != NULL)
{
sibling = last;
@@ -2194,7 +2283,7 @@ amp_project_remove_group (AmpProject *project,
{
GList *token_list;
- if (AMP_NODE_DATA (group)->type != ANJUTA_PROJECT_GROUP) return;
+ if (anjuta_project_node_get_type (group) != ANJUTA_PROJECT_GROUP) return;
for (token_list = amp_group_get_token (group, AM_GROUP_TOKEN_CONFIGURE); token_list != NULL; token_list = g_list_next (token_list))
{
@@ -2400,7 +2489,7 @@ amp_project_remove_target (AmpProject *project,
{
GList *token_list;
- if (AMP_NODE_DATA (target)->type != ANJUTA_PROJECT_TARGET) return;
+ if (anjuta_project_node_get_type (target) != ANJUTA_PROJECT_TARGET) return;
for (token_list = amp_target_get_token (target); token_list != NULL; token_list = g_list_next (token_list))
{
@@ -2423,7 +2512,7 @@ amp_project_add_sibling_source (AmpProject *project, AmpTarget *target, GFile *
g_return_val_if_fail (file != NULL, NULL);
g_return_val_if_fail (target != NULL, NULL);
- if (AMP_NODE_DATA (target)->type != ANJUTA_PROJECT_TARGET) return NULL;
+ if (anjuta_project_node_get_type (target) != ANJUTA_PROJECT_TARGET) return NULL;
group = (AmpGroup *)(target->parent);
relative_name = g_file_get_relative_path (AMP_GROUP_DATA (group)->base.file, file);
@@ -2516,7 +2605,7 @@ amp_project_remove_source (AmpProject *project,
GError **error)
{
amp_dump_node (source);
- if (AMP_NODE_DATA (source)->type != ANJUTA_PROJECT_SOURCE) return;
+ if (anjuta_project_node_get_type (source) != ANJUTA_PROJECT_SOURCE) return;
anjuta_token_remove_word (AMP_SOURCE_DATA (source)->token, NULL);
@@ -2631,7 +2720,7 @@ foreach_node_move (AnjutaProjectNode *g_node, gpointer data)
GFile *relative;
GFile *new_file;
- switch (AMP_NODE_DATA (g_node)->type)
+ switch (anjuta_project_node_get_type (g_node))
{
case ANJUTA_PROJECT_GROUP:
relative = get_relative_path (old_root_file, AMP_GROUP_DATA (g_node)->base.file);
@@ -2811,7 +2900,7 @@ amp_project_get_node_id (AmpProject *project, const gchar *path)
}
}
- switch (AMP_NODE_DATA (node)->type)
+ switch (anjuta_project_node_get_type (node))
{
case ANJUTA_PROJECT_GROUP:
return g_file_get_uri (AMP_GROUP_DATA (node)->base.file);
@@ -2991,7 +3080,8 @@ iproject_load (IAnjutaProject *obj, GFile *file, GError **err)
static gboolean
iproject_refresh (IAnjutaProject *obj, GError **err)
{
- return amp_project_reload (AMP_PROJECT (obj), err);
+ //return amp_project_reload (AMP_PROJECT (obj), err);
+ return NULL;
}
static gboolean
@@ -3003,7 +3093,7 @@ iproject_remove_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err
static GtkWidget*
iproject_configure_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
{
- switch (AMP_NODE_DATA (node)->type)
+ switch (anjuta_project_node_get_type (node))
{
case ANJUTA_PROJECT_GROUP:
return amp_configure_group_dialog (AMP_PROJECT (obj), AMP_GROUP (node), err);
@@ -3016,6 +3106,42 @@ iproject_configure_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **
}
}
+static AnjutaProjectNode *
+iproject_load_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
+{
+ return amp_project_load_node (AMP_PROJECT (obj), node, err);
+}
+
+static AnjutaProjectNode *
+iproject_save_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
+{
+ return NULL;
+}
+
+static AnjutaProjectNode *
+iproject_new_root (IAnjutaProject *obj, GFile *file, GError **err)
+{
+ return project_node_new (AMP_PROJECT (obj), ANJUTA_PROJECT_ROOT, file, NULL);
+}
+
+static AnjutaProjectNode *
+iproject_new_file (IAnjutaProject *obj, AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNodeType type, GFile *file, GError **err)
+{
+ return NULL;
+}
+
+static AnjutaProjectNode *
+iproject_new_name (IAnjutaProject *obj, AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNodeType type, const gchar *name, GError **err)
+{
+ return NULL;
+}
+
+static void
+iproject_free_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
+{
+ return project_node_destroy (AMP_PROJECT (obj), node);
+}
+
static void
iproject_iface_init(IAnjutaProjectIface* iface)
{
@@ -3031,6 +3157,12 @@ iproject_iface_init(IAnjutaProjectIface* iface)
iface->refresh = iproject_refresh;
iface->remove_node = iproject_remove_node;
iface->configure_node = iproject_configure_node;
+ iface->load_node = iproject_load_node;
+ iface->save_node = iproject_save_node;
+ iface->new_root = iproject_new_root;
+ iface->new_file = iproject_new_file;
+ iface->new_name = iproject_new_name;
+ iface->free_node = iproject_free_node;
}
/* Group access functions
diff --git a/plugins/am-project/am-project.h b/plugins/am-project/am-project.h
index 54fe4d3..70c890e 100644
--- a/plugins/am-project/am-project.h
+++ b/plugins/am-project/am-project.h
@@ -82,7 +82,7 @@ GList *amp_target_property_buffer_steal_properties (AmpTargetPropertyBuffer *buf
gint amp_project_probe (GFile *directory, GError **error);
gboolean amp_project_load (AmpProject *project, GFile *directory, GError **error);
-gboolean amp_project_reload (AmpProject *project, GError **error);
+AnjutaProjectNode *amp_project_load_node (AmpProject *project, AnjutaProjectNode *node, GError **error);
void amp_project_unload (AmpProject *project);
void amp_project_load_config (AmpProject *project, AnjutaToken *arg_list);
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 36cc432..9f61c6e 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -519,6 +519,7 @@ add_module (GbfProjectModel *model,
if ((!module) || (anjuta_project_node_get_type (module) != ANJUTA_PROJECT_MODULE))
return;
+ g_message ("new module");
data = gbf_tree_data_new_module (module);
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
@@ -607,10 +608,6 @@ add_target_group (GbfProjectModel *model,
for (node = anjuta_project_node_first_child (group); node; node = anjuta_project_node_next_sibling (node))
add_target_group (model, node, &iter);
- /* ... and module */
- for (node = anjuta_project_node_first_child (group); node; node = anjuta_project_node_next_sibling (node))
- add_module (model, node, &iter);
-
/* ... and targets */
for (node = anjuta_project_node_first_child (group); node; node = anjuta_project_node_next_sibling (node))
add_target (model, node, &iter);
@@ -621,6 +618,34 @@ add_target_group (GbfProjectModel *model,
}
static void
+add_root (GbfProjectModel *model,
+ AnjutaProjectNode *root,
+ GtkTreeIter *parent)
+{
+ GtkTreeIter iter;
+ AnjutaProjectNode *node;
+ GtkTreePath *root_path;
+
+ if ((!root) || (anjuta_project_node_get_type (root) != ANJUTA_PROJECT_ROOT))
+ return;
+
+ /* create root reference */
+ /*root_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+ model->priv->root_row = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), root_path);
+ gtk_tree_path_free (root_path);*/
+
+ g_message ("add group");
+ /* add groups ... */
+ for (node = anjuta_project_node_first_child (root); node; node = anjuta_project_node_next_sibling (node))
+ add_target_group (model, node, NULL);
+
+ g_message ("add module");
+ /* ... and module */
+ for (node = anjuta_project_node_first_child (root); node; node = anjuta_project_node_next_sibling (node))
+ add_module (model, node, NULL);
+}
+
+static void
update_tree (GbfProjectModel *model, AnjutaProjectNode *parent, GtkTreeIter *iter)
{
GtkTreeIter child;
@@ -632,6 +657,7 @@ update_tree (GbfProjectModel *model, AnjutaProjectNode *parent, GtkTreeIter *ite
/* Get all new nodes */
nodes = gbf_project_util_all_child (parent, ANJUTA_PROJECT_UNKNOWN);
+ g_message ("get all nodes %d", g_list_length (nodes));
/* walk the tree nodes */
if (gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &child, iter)) {
@@ -692,6 +718,9 @@ update_tree (GbfProjectModel *model, AnjutaProjectNode *parent, GtkTreeIter *ite
case ANJUTA_PROJECT_PACKAGE:
add_package (model, node->data, iter);
break;
+ case ANJUTA_PROJECT_ROOT:
+ add_root (model, node->data, iter);
+ break;
default:
break;
}
@@ -713,7 +742,8 @@ load_project (GbfProjectModel *model, AnjutaPmProject *proj)
/* to get rid of the empty node */
gbf_project_model_clear (model);
- add_target_group (model, anjuta_pm_project_get_root (proj), NULL);
+ add_root (model, anjuta_pm_project_get_root (proj), NULL);
+ //add_target_group (model, anjuta_pm_project_get_root (proj), NULL);
model->priv->project_updated_handler =
g_signal_connect (anjuta_pm_project_get_project (model->priv->proj), "project-updated",
diff --git a/plugins/project-manager/gbf-tree-data.h b/plugins/project-manager/gbf-tree-data.h
index 3b2a9d9..46517a6 100644
--- a/plugins/project-manager/gbf-tree-data.h
+++ b/plugins/project-manager/gbf-tree-data.h
@@ -38,12 +38,13 @@ typedef enum {
GBF_TREE_NODE_MODULE,
GBF_TREE_NODE_PACKAGE,
GBF_TREE_NODE_SOURCE,
+ GBF_TREE_NODE_ROOT,
GBF_TREE_NODE_SHORTCUT
} GbfTreeNodeType;
struct _GbfTreeData
{
- GbfTreeNodeType type;
+ GbfTreeNodeType type;
gchar *name;
GFile *group;
gchar *target;
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index e67a138..2a4db5d 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -113,12 +113,25 @@ pm_project_thread_main_loop (AnjutaPmProject *project)
for (;;)
{
+ AnjutaProjectNode *root;
+ AnjutaProjectNode *node;
+
job = (PmJob *)g_async_queue_pop (project->job_queue);
switch (job->command)
{
case LOAD:
- ianjuta_project_load (project->project, job->file, &(job->error));
+ root = ianjuta_project_new_root (project->project, job->file, NULL);
+ node = ianjuta_project_load_node (project->project, root, &(job->error));
+ g_message ("load get root %p node %p, error %p", root, node, job->error);
+ if (job->error == NULL)
+ {
+ job->node = node;
+ }
+ else
+ {
+ ianjuta_project_free_node (project->project, root, NULL);
+ }
break;
case EXIT:
do
@@ -229,6 +242,10 @@ on_pm_project_loaded (AnjutaPmProject *project, PmJob *job)
}
else
{
+ g_message ("project loaded project root %p node %p", anjuta_pm_project_get_root (project), job->node);
+ g_message ("root child %d", g_node_n_children (job->node));
+ g_message ("root all nodes %d", g_node_n_nodes (job->node, G_TRAVERSE_ALL));
+ project->root = job->node;
g_object_set (G_OBJECT (project->model), "project", project, NULL);
}
g_signal_emit (G_OBJECT (project), signals[UPDATED], 0, job->error);
@@ -381,9 +398,7 @@ anjuta_pm_project_get_target_types (AnjutaPmProject *project)
AnjutaProjectNode *
anjuta_pm_project_get_root (AnjutaPmProject *project)
{
- if (project->project == NULL) return NULL;
-
- return ianjuta_project_get_root (project->project, NULL);
+ return project->root;
}
GList *
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 1dccf06..2b4ca6b 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -59,6 +59,9 @@ struct _AnjutaPmProject
IAnjutaProject *project;
GbfProjectModel *model;
+ AnjutaProjectNode *root;
+
+ /* Thread queue */
GAsyncQueue *job_queue;
GAsyncQueue *done_queue;
GThread *worker;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]