[anjuta/newproject] Change implementations of node properties
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Change implementations of node properties
- Date: Sun, 18 Apr 2010 10:53:00 +0000 (UTC)
commit 200ba55a04c4aecd987476986b31ca93e1547158
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Apr 18 12:51:48 2010 +0200
Change implementations of node properties
libanjuta/anjuta-project.c | 146 ++++++++++++++++++++++++++---------
libanjuta/anjuta-project.h | 7 +-
plugins/am-project/ac-writer.c | 3 +-
plugins/am-project/ac-writer.h | 2 +-
plugins/am-project/am-dialogs.c | 30 +++-----
plugins/am-project/am-dialogs.h | 8 +-
plugins/am-project/am-project.c | 76 ++++++++++--------
plugins/am-project/am-properties.c | 109 ++++++++++++++-------------
plugins/am-project/am-properties.h | 10 +-
plugins/am-project/projectparser.c | 81 +++++++++-----------
10 files changed, 272 insertions(+), 200 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index f7d6480..2933fe9 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -65,30 +65,15 @@ typedef struct {
*---------------------------------------------------------------------------*/
AnjutaProjectProperty *
-anjuta_project_property_first (AnjutaProjectProperty *list)
-{
- if (list != NULL)
- {
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)list->data;
-
- if (info->override != NULL)
- {
- list = g_list_first (info->override);
- }
- }
- return list;
-}
-
-AnjutaProjectProperty *
anjuta_project_property_next (AnjutaProjectProperty *list)
{
return g_list_next (list);
}
AnjutaProjectPropertyInfo *
-anjuta_project_property_get_info (AnjutaProjectProperty *list)
+anjuta_project_property_get_info (AnjutaProjectProperty *property)
{
- return (AnjutaProjectPropertyInfo *)list->data;
+ return (AnjutaProjectPropertyInfo *)property->data;
}
AnjutaProjectPropertyInfo *
@@ -411,42 +396,127 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
}
AnjutaProjectProperty *
-anjuta_project_node_get_property_list (AnjutaProjectNode *node)
+anjuta_project_node_first_property (AnjutaProjectNode *node)
+{
+ GList *first;
+
+ /* Get properties list */
+ first = g_list_first (NODE_DATA (node)->properties);
+ if (first != NULL)
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)first->data;
+
+ if (info->override == NULL)
+ {
+ first = NULL;
+ }
+ }
+
+ return first;
+}
+
+AnjutaProjectProperty *
+anjuta_project_node_first_valid_property (AnjutaProjectNode *node)
+{
+ GList *first;
+
+ /* Get properties list */
+ first = g_list_first (NODE_DATA (node)->properties);
+ if (first != NULL)
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)first->data;
+
+ if (info->override != NULL)
+ {
+ first = g_list_first (info->override);
+ }
+ }
+
+ return first;
+}
+
+AnjutaProjectProperty *
+anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property)
{
- GList *list = NULL;
GList *item;
- GList *new_item;
-
- for (item = g_list_last (NODE_DATA (node)->properties); item != NULL; item = g_list_previous (item))
+
+ /* Get properties list */
+ item = g_list_first (NODE_DATA (node)->properties);
+
+ for (; item != NULL; item = g_list_next (item))
{
AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
-
- if (info->override != NULL) break;
- list = g_list_prepend (list, item->data);
+ if (info->override == NULL)
+ {
+ item = NULL;
+ break;
+ }
+
+ if (info->override == property)
+ {
+ break;
+ }
}
- for (item = g_list_first (NODE_DATA (node)->properties); item != NULL; item = g_list_next (item))
+ return item;
+}
+
+AnjutaProjectProperty *
+anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *frame, AnjutaProjectProperty *property)
+{
+ GList **list;
+ GList *next;
+ AnjutaProjectPropertyInfo *info;
+
+ /* Fill missing information */
+ info = (AnjutaProjectPropertyInfo *)property->data;
+ if (info->name == NULL) info->name = ((AnjutaProjectPropertyInfo *)frame->data)->name;
+ info->type = ((AnjutaProjectPropertyInfo *)frame->data)->type;
+ info->override = frame;
+
+ /* Get properties list */
+ list = &(NODE_DATA (node)->properties);
+
+ next = ((AnjutaProjectPropertyInfo *)(*list)->data)->override;
+ if (next != NULL)
{
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+ next = *list;
+ }
+ *list = g_list_concat (next, property);
+
+ return property;
+}
+
+AnjutaProjectProperty *
+anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *prop)
+{
+ AnjutaProjectPropertyInfo *info;
+
+ info = (AnjutaProjectPropertyInfo *)prop->data;
- if (info->override == NULL) break;
+ if (info->override != NULL)
+ {
+ GList *list;
+
+ list = NODE_DATA (node)->properties;
- new_item = g_list_first (list);
- while ((new_item != NULL) && (new_item->data != NULL))
+ list = g_list_remove_link (list, prop);
+ if (list == NULL)
{
- if (new_item->data == info->override)
- {
- new_item->data = info;
- break;
- }
- new_item = g_list_next (new_item);
+ list = g_list_first (info->override);
}
+ NODE_DATA (node)->properties = list;
}
-
- return list;
+ else
+ {
+ prop = NULL;
+ }
+
+ return prop;
}
+
/*const gchar *
anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop)
{
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index cad9f21..d5d6857 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -141,7 +141,6 @@ typedef GNode AnjutaProjectSource;
typedef void (*AnjutaProjectNodeFunc) (AnjutaProjectNode *node, gpointer data);
-AnjutaProjectProperty *anjuta_project_property_first (AnjutaProjectProperty *list);
AnjutaProjectProperty *anjuta_project_property_next (AnjutaProjectProperty *list);
AnjutaProjectProperty *anjuta_project_property_override (AnjutaProjectProperty *list, AnjutaProjectProperty *prop);
AnjutaProjectProperty *anjuta_project_property_next_item (AnjutaProjectProperty *item);
@@ -177,7 +176,11 @@ 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);
-AnjutaProjectProperty *anjuta_project_node_get_property_list (AnjutaProjectNode *node);
+AnjutaProjectProperty *anjuta_project_node_first_property (AnjutaProjectNode *node);
+AnjutaProjectProperty *anjuta_project_node_first_valid_property (AnjutaProjectNode *node);
+AnjutaProjectProperty *anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
+AnjutaProjectProperty *anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *frame, AnjutaProjectProperty *property);
+AnjutaProjectProperty *anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
//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);
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index 503e56b..7524f00 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -121,12 +121,13 @@ skip_comment (AnjutaToken *token)
*---------------------------------------------------------------------------*/
gboolean
-amp_project_update_property (AmpProject *project, AmpPropertyInfo *info)
+amp_project_update_property (AmpProject *project, AnjutaProjectProperty *property)
{
AnjutaToken *token;
AnjutaToken *arg;
guint pos;
const gchar *value;
+ AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (property);
pos = info->position;
value = info->base.value;
diff --git a/plugins/am-project/ac-writer.h b/plugins/am-project/ac-writer.h
index f17bb9e..c136966 100644
--- a/plugins/am-project/ac-writer.h
+++ b/plugins/am-project/ac-writer.h
@@ -29,7 +29,7 @@
G_BEGIN_DECLS
-gboolean amp_project_update_property (AmpProject *project, AmpPropertyInfo *info);
+gboolean amp_project_update_property (AmpProject *project, AnjutaProjectProperty *property);
G_END_DECLS
diff --git a/plugins/am-project/am-dialogs.c b/plugins/am-project/am-dialogs.c
index 5740a8a..2389ce1 100644
--- a/plugins/am-project/am-dialogs.c
+++ b/plugins/am-project/am-dialogs.c
@@ -178,7 +178,7 @@ add_label (const gchar *display_name, const gchar *value, GtkWidget *table, gint
*---------------------------------------------------------------------------*/
GtkWidget *
-amp_configure_project_dialog (AmpProject *project, GError **error)
+amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
GtkBuilder *bxml = gtk_builder_new ();
AmpConfigureProjectDialog *dlg;
@@ -186,7 +186,6 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
gint pos;
gchar *name;
AnjutaProjectProperty *prop;
- AnjutaProjectProperty *list;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
if (!bxml) return NULL;
@@ -204,8 +203,7 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
add_label (_("Path:"), name, table, &pos);
g_free (name);
- list = amp_project_get_property_list (project);
- for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ for (prop = anjuta_project_node_first_valid_property (node); prop != NULL; prop = anjuta_project_property_next (prop))
{
add_entry (project, NULL, prop, table, &pos);
}
@@ -223,7 +221,7 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
}
GtkWidget *
-amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error)
+amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GError **error)
{
GtkBuilder *bxml = gtk_builder_new ();
GtkWidget *properties;
@@ -233,7 +231,6 @@ amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error
gint extra_pos;
AmpConfigureProjectDialog *dlg;
gchar *name;
- AnjutaProjectProperty *list;
AnjutaProjectProperty *prop;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
@@ -255,19 +252,18 @@ amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error
add_label (_("Name:"), name, main_table, &main_pos);
g_free (name);
- list = ANJUTA_PROJECT_NODE_DATA ((AnjutaProjectNode *)group)->properties;
- for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ for (prop = anjuta_project_node_first_valid_property (group); prop != NULL; prop = anjuta_project_property_next (prop))
{
AnjutaProjectProperty *item;
- item = anjuta_project_property_override (list, prop);
+ item = anjuta_project_node_get_property (group, prop);
if (item != NULL)
{
- add_entry (project, (AnjutaProjectNode *)group, item, main_table, &main_pos);
+ add_entry (project, group, item, main_table, &main_pos);
}
else
{
- add_entry (project, (AnjutaProjectNode *)group, prop, extra_table, &extra_pos);
+ add_entry (project, group, prop, extra_table, &extra_pos);
}
}
@@ -278,7 +274,7 @@ amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error
}
GtkWidget *
-amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **error)
+amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error)
{
GtkBuilder *bxml = gtk_builder_new ();
GtkWidget *properties;
@@ -289,7 +285,6 @@ amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **er
AmpConfigureProjectDialog *dlg;
AnjutaProjectTargetType type;
const gchar *name;
- AnjutaProjectProperty *list;
AnjutaProjectProperty *prop;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
@@ -312,19 +307,18 @@ amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **er
type = anjuta_project_target_get_type (target);
add_label (_("Type:"), anjuta_project_target_type_name (type), main_table, &main_pos);
- list = ANJUTA_PROJECT_NODE_DATA ((AnjutaProjectNode *)target)->properties;
- for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ for (prop = anjuta_project_node_first_valid_property (target); prop != NULL; prop = anjuta_project_property_next (prop))
{
AnjutaProjectProperty *item;
- item = anjuta_project_property_override (list, prop);
+ item = anjuta_project_node_get_property (target, prop);
if (item != NULL)
{
- add_entry (project, (AnjutaProjectNode *)target, item, main_table, &main_pos);
+ add_entry (project, target, item, main_table, &main_pos);
}
else
{
- add_entry (project, (AnjutaProjectNode *)target, prop, extra_table, &extra_pos);
+ add_entry (project, target, prop, extra_table, &extra_pos);
}
}
diff --git a/plugins/am-project/am-dialogs.h b/plugins/am-project/am-dialogs.h
index 99027d2..eba0cc3 100644
--- a/plugins/am-project/am-dialogs.h
+++ b/plugins/am-project/am-dialogs.h
@@ -27,10 +27,10 @@
G_BEGIN_DECLS
-GtkWidget *amp_configure_project_dialog (AmpProject *project, GError **error);
-GtkWidget *amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error);
-GtkWidget *amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **error);
-GtkWidget *amp_configure_source_dialog (AmpProject *project, AmpSource *target, GError **error);
+GtkWidget *amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GError **error);
+GtkWidget *amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GError **error);
+GtkWidget *amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error);
+GtkWidget *amp_configure_source_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error);
G_END_DECLS
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 639c376..d906f94 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -507,7 +507,7 @@ amp_target_property_buffer_free (AmpTargetPropertyBuffer *buffer)
{
g_list_foreach (buffer->sources, (GFunc)amp_source_free, NULL);
g_list_free (buffer->sources);
- g_list_foreach (buffer->properties, (GFunc)amp_property_free, NULL);
+ amp_property_free (buffer->properties);
g_list_free (buffer->properties);
g_free (buffer);
}
@@ -597,7 +597,7 @@ amp_root_free (AnjutaProjectNode *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);
+ amp_property_free (data->properties);
g_slice_free (AmpRootData, (AmpRootData *)data);
g_node_destroy (node);
@@ -640,8 +640,8 @@ amp_package_free (AmpPackage *node)
if (package->base.file) g_object_unref (package->base.file);
g_free (package->base.name);
- anjuta_project_property_foreach (package->base.properties, (GFunc)amp_property_free, NULL);
- g_slice_free (AmpPackageData, package);
+ amp_property_free (package->base.properties);
+ g_slice_free (AmpPackageData, package);
g_node_destroy (node);
}
@@ -794,7 +794,7 @@ amp_group_free (AmpGroup *node)
gint i;
if (group->base.file) g_object_unref (group->base.file);
- anjuta_project_property_foreach (group->base.properties, (GFunc)amp_property_free, NULL);
+ amp_property_free (group->base.properties);
if (group->tfile) anjuta_token_file_free (group->tfile);
if (group->makefile) g_object_unref (group->makefile);
for (i = 0; i < AM_GROUP_TOKEN_LAST; i++)
@@ -855,7 +855,7 @@ amp_target_free (AmpTarget *node)
AmpTargetData *target = AMP_TARGET_DATA (node);
g_free (target->base.name);
- anjuta_project_property_foreach (target->base.properties, (GFunc)amp_property_free, NULL);
+ amp_property_free (target->base.properties);
g_free (target->install);
g_slice_free (AmpTargetData, target);
@@ -884,7 +884,7 @@ amp_source_free (AmpSource *node)
AmpSourceData *source = AMP_SOURCE_DATA (node);
g_object_unref (source->base.file);
- anjuta_project_property_foreach (source->base.properties, (GFunc)amp_property_free, NULL);
+ amp_property_free (source->base.properties);
g_slice_free (AmpSourceData, source);
g_node_destroy (node);
@@ -1107,36 +1107,39 @@ project_node_new (AmpProject *project, AnjutaProjectNodeType type, GFile *file,
void
amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToken *args)
{
- AnjutaProjectProperty *list;
+ AnjutaProjectProperty *item;
//fprintf (stdout, "property list:\n");
//anjuta_token_dump (args);
project->ac_init = macro;
project->args = args;
-
- for (list = anjuta_project_property_first (project->properties); list != NULL; list = anjuta_project_property_next (list))
+
+ for (item = anjuta_project_node_first_valid_property (project->root_node); item != NULL; item = anjuta_project_property_next (item))
{
- AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
+ AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (item);
if (info->position >= 0)
{
- AnjutaProjectPropertyInfo *prop;
+ AnjutaProjectProperty *prop;
+ AnjutaProjectPropertyInfo *new_info;
AnjutaToken *arg;
- prop = anjuta_project_property_lookup (project->properties, list);
+ prop = anjuta_project_node_remove_property (project->root_node, item);
if (prop == NULL)
{
- prop = (AnjutaProjectPropertyInfo *)amp_property_new (NULL, info->token_type, info->position, NULL, macro);
-
- project->properties = anjuta_project_property_insert (project->properties, list, prop);
+ amp_property_free (prop);
}
-
+ prop = amp_property_new (NULL, info->token_type, info->position, NULL, macro);
+ anjuta_project_node_insert_property (project->root_node, item, prop);
+
+ new_info = anjuta_project_property_get_info (prop);
arg = anjuta_token_nth_word (args, info->position);
- if ((prop->value != NULL) && (prop->value != info->base.value)) g_free (prop->value);
- prop->value = anjuta_token_evaluate (arg);
+ if ((new_info->value != NULL) && (new_info->value != info->base.value)) g_free (new_info->value);
+ new_info->value = anjuta_token_evaluate (arg);
}
}
+ //g_message ("prop list %p get prop %p", *list, anjuta_project_node_get_property (project->root_node));
}
void
@@ -1355,32 +1358,32 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
/* Set target properties */
if (flags & AM_TARGET_NOBASE)
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 0, "1", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 0, "1", arg);
if (flags & AM_TARGET_NOTRANS)
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 1, "1", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 1, "1", arg);
if (flags & AM_TARGET_DIST)
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 2, "1", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 2, "1", arg);
if (flags & AM_TARGET_NODIST)
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 2, "0", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 2, "0", arg);
if (flags & AM_TARGET_NOINST)
{
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 3, "1", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 3, "1", arg);
}
else
{
gchar *instdir = g_strconcat ("$(", install, "dir)", NULL);
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 6, instdir, arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 6, instdir, arg);
g_free (instdir);
}
if (flags & AM_TARGET_CHECK)
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 4, "1", arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 4, "1", arg);
if (flags & AM_TARGET_MAN)
{
gchar section[] = "0";
section[0] += (flags >> 7) & 0x1F;
- amp_node_property_set (target, AM_TOKEN__PROGRAMS, 4, section, arg);
+ amp_node_property_load (target, AM_TOKEN__PROGRAMS, 4, section, arg);
}
g_free (canon_id);
@@ -1580,7 +1583,7 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
{
gpointer find;
gchar *value;
- AnjutaProjectPropertyInfo *prop;
+ AnjutaProjectProperty *prop;
AmpTargetPropertyBuffer *orphan = NULL;
find = target_id;
@@ -1641,7 +1644,7 @@ project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTo
AmpGroupData *group = AMP_GROUP_DATA (parent);
gchar *value;
gchar *name;
- AnjutaProjectPropertyInfo *prop;
+ AnjutaProjectProperty *prop;
/* Create property */
name = anjuta_token_evaluate (token);
@@ -1836,7 +1839,7 @@ amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenTy
/* Public functions
*---------------------------------------------------------------------------*/
-AnjutaProjectNode *
+static AnjutaProjectNode *
amp_project_load_root (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
AmpAcScanner *scanner;
@@ -1962,7 +1965,7 @@ list_all_children (GList **children, GFile *dir)
}
}
-AnjutaProjectNode *
+static AnjutaProjectNode *
amp_project_load_package (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
gchar *cmd;
@@ -2066,7 +2069,7 @@ amp_project_unload (AmpProject *project)
if (project->root_file) g_object_unref (project->root_file);
project->root_file = NULL;
- anjuta_project_property_foreach (project->properties, (GFunc)amp_property_free, NULL);
+ amp_property_free (project->properties);
project->properties = amp_get_project_property_list ();
/* shortcut hash tables */
@@ -3115,7 +3118,7 @@ iproject_add_target (IAnjutaProject *obj, AnjutaProjectNode *parent, const gcha
static GtkWidget*
iproject_configure (IAnjutaProject *obj, GError **err)
{
- return amp_configure_project_dialog (AMP_PROJECT (obj), err);
+ return amp_configure_project_dialog (AMP_PROJECT (obj), AMP_PROJECT (obj)->root_node, err);
}
static guint
@@ -3255,7 +3258,12 @@ iproject_set_boolean_property (IAnjutaProject *project, AnjutaProjectNode *node,
static AnjutaProjectProperty *
iproject_set_string_property (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *value, GError **err )
{
- return NULL;
+ AnjutaProjectProperty *new_prop;
+
+ new_prop = amp_node_property_set (node, property, value);
+ amp_project_update_property (AMP_PROJECT (project), new_prop);
+
+ return new_prop;
}
static AnjutaProjectProperty *
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index fdcf44c..70bb09c 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -127,35 +127,39 @@ amp_create_property_list (GList **list, AmpPropertyInfo *info)
/* Properties objects
*---------------------------------------------------------------------------*/
-AnjutaProjectPropertyInfo *
+AnjutaProjectProperty *
amp_property_new (const gchar *name, AnjutaTokenType type, gint position, const gchar *value, AnjutaToken *token)
{
- AmpPropertyInfo *prop;
+ AmpPropertyInfo *info;
- prop = g_slice_new0(AmpPropertyInfo);
- if (name != NULL) prop->base.name = g_strdup (name);
- prop->base.value = g_strdup (value);
- prop->token = token;
- prop->token_type = type;
- prop->position = position;
+ info = g_slice_new0(AmpPropertyInfo);
+ info->base.name = g_strdup (name);
+ info->base.value = g_strdup (value);
+ info->token = token;
+ info->token_type = type;
+ info->position = position;
- return (AnjutaProjectPropertyInfo *)prop;
+ return g_list_prepend (NULL, info);
}
void
-amp_property_free (AnjutaProjectPropertyInfo *prop)
+amp_property_free (AnjutaProjectProperty *prop)
{
- if (prop->override != NULL)
+ for (; prop != NULL; prop = g_list_delete_link (prop, prop))
{
- if ((prop->name != NULL) && (prop->name != ((AmpPropertyInfo *)(prop->override->data))->base.name))
+ AmpPropertyInfo *info = (AmpPropertyInfo *)prop->data;
+
+ if (info->base.override == NULL) break;
+
+ if ((info->base.name != NULL) && (info->base.name != ((AmpPropertyInfo *)(info->base.override->data))->base.name))
{
- g_free (prop->name);
+ g_free (info->base.name);
}
- if ((prop->value != NULL) && (prop->value != ((AmpPropertyInfo *)(prop->override->data))->base.value))
+ if ((info->base.value != NULL) && (info->base.value != ((AmpPropertyInfo *)(info->base.override->data))->base.value))
{
- g_free (prop->value);
+ g_free (info->base.value);
}
- g_slice_free (AmpPropertyInfo, (AmpPropertyInfo *)prop);
+ g_slice_free (AmpPropertyInfo, (AmpPropertyInfo *)info);
}
}
@@ -163,30 +167,30 @@ amp_property_free (AnjutaProjectPropertyInfo *prop)
*---------------------------------------------------------------------------*/
gboolean
-amp_node_property_set (AnjutaProjectNode *node, gint token_type, gint position, const gchar *value, AnjutaToken *token)
+amp_node_property_load (AnjutaProjectNode *node, gint token_type, gint position, const gchar *value, AnjutaToken *token)
{
- AnjutaProjectProperty **properties = &(ANJUTA_PROJECT_NODE_DATA(node)->properties);
- AnjutaProjectProperty *list;
+ AnjutaProjectProperty *item;
gboolean set = FALSE;
- for (list = anjuta_project_property_first (*properties); list != NULL; list = anjuta_project_property_next (list))
+ for (item = anjuta_project_node_first_valid_property (node); item != NULL; item = anjuta_project_property_next (item))
{
- AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
+ AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (item);
if ((info->token_type == token_type) && (info->position == position))
{
- AnjutaProjectPropertyInfo *prop;
+ AnjutaProjectProperty *prop;
+ AnjutaProjectPropertyInfo *new_info;
- prop = anjuta_project_property_lookup (*properties, list);
+ prop = anjuta_project_node_get_property (node, item);
if (prop == NULL)
{
- prop = (AnjutaProjectPropertyInfo *)amp_property_new (NULL, token_type, position, NULL, token);
-
- *properties = anjuta_project_property_insert (*properties, list, prop);
+ prop = amp_property_new (NULL, token_type, position, NULL, token);
+ anjuta_project_node_insert_property (node, item, prop);
}
+ new_info = anjuta_project_property_get_info (prop);
- if ((prop->value != NULL) && (prop->value != info->base.value)) g_free (prop->value);
- prop->value = g_strdup (value);
+ if ((new_info->value != NULL) && (new_info->value != info->base.value)) g_free (new_info->value);
+ new_info->value = g_strdup (value);
set = TRUE;
}
}
@@ -195,63 +199,64 @@ amp_node_property_set (AnjutaProjectNode *node, gint token_type, gint position,
}
gboolean
-amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *prop)
+amp_node_property_add (AnjutaProjectNode *node, AnjutaProjectProperty *prop)
{
- AnjutaProjectProperty **properties = &(ANJUTA_PROJECT_NODE_DATA(node)->properties);
- AnjutaProjectProperty *list;
+ AnjutaProjectProperty *item;
gboolean set = FALSE;
- for (list = anjuta_project_property_first (*properties); list != NULL; list = anjuta_project_property_next (list))
+ for (item = anjuta_project_node_first_valid_property (node); item != NULL; item = anjuta_project_property_next (item))
{
- AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
+ AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (item);
+ AmpPropertyInfo *new_info = (AmpPropertyInfo *)anjuta_project_property_get_info (prop);
- if ((info->token_type == prop->token_type) && (info->position == prop->position))
+ if ((info->token_type == new_info->token_type) && (info->position == new_info->position))
{
if (info->base.type != ANJUTA_PROJECT_PROPERTY_LIST)
{
/* Replace property */
- AnjutaProjectPropertyInfo *old_prop;
+ AnjutaProjectProperty *old_prop;
- old_prop = anjuta_project_property_lookup (*properties, list);
+ old_prop = anjuta_project_node_remove_property (node, item);
if (old_prop != NULL)
{
- *properties = anjuta_project_property_remove (*properties, list);
amp_property_free (old_prop);
}
}
- *properties = anjuta_project_property_insert (*properties, list, (AnjutaProjectPropertyInfo *)prop);
+ anjuta_project_node_insert_property (node, item, prop);
set = TRUE;
break;
}
}
- if (!set) amp_property_free ((AnjutaProjectPropertyInfo *)prop);
+ if (!set) amp_property_free (prop);
return set;
}
-gboolean
-amp_project_property_set (AmpProject *project, AnjutaProjectProperty *prop, const gchar* value)
+AnjutaProjectProperty *
+amp_node_property_set (AnjutaProjectNode *node, AnjutaProjectProperty *prop, const gchar* value)
{
- AnjutaProjectProperty **properties = &(project->properties);
AnjutaProjectProperty *item;
AmpPropertyInfo *info;
+ AnjutaProjectProperty *new_prop;
- item = anjuta_project_property_override (*properties, prop);
- if (item != NULL)
+ info = (AmpPropertyInfo *)anjuta_project_property_get_info (prop);
+ new_prop = anjuta_project_node_get_property (node, prop);
+ if (new_prop != NULL)
{
- info = (AmpPropertyInfo *)anjuta_project_property_get_info (item);
- if ((info->base.value != NULL) && (info->base.value != ((AnjutaProjectPropertyInfo *)(info->base.override->data))->value)) g_free (info->base.value);
- info->base.value = g_strdup (value);
+ AmpPropertyInfo *new_info;
+ new_info = (AmpPropertyInfo *)anjuta_project_property_get_info (new_prop);
+
+ if ((new_info->base.value != NULL) && (new_info->base.value != ((AnjutaProjectPropertyInfo *)(new_info->base.override->data))->value)) g_free (new_info->base.value);
+ new_info->base.value = g_strdup (value);
}
else
{
- info = (AmpPropertyInfo *)anjuta_project_property_get_info (prop);
- info = (AmpPropertyInfo *)amp_property_new (NULL, info->token_type, info->position, value, NULL);
- *properties = anjuta_project_property_insert (*properties, prop, (AnjutaProjectPropertyInfo *)info);
+ new_prop = amp_property_new (NULL, info->token_type, info->position, value, NULL);
+ anjuta_project_node_insert_property (node, prop, new_prop);
}
-
- return amp_project_update_property (project, info);
+
+ return new_prop;
}
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
index a9c6e6d..404c5f0 100644
--- a/plugins/am-project/am-properties.h
+++ b/plugins/am-project/am-properties.h
@@ -28,12 +28,12 @@
G_BEGIN_DECLS
-AnjutaProjectPropertyInfo *amp_property_new (const gchar *name, AnjutaTokenType type, gint position, const gchar *value, AnjutaToken *token);
-void amp_property_free (AnjutaProjectPropertyInfo *prop);
+AnjutaProjectProperty *amp_property_new (const gchar *name, AnjutaTokenType type, gint position, const gchar *value, AnjutaToken *token);
+void amp_property_free (AnjutaProjectProperty *prop);
-gboolean amp_node_property_set (AnjutaProjectNode *target, gint token_type, gint position, const gchar *value, AnjutaToken *token);
-gboolean amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *info);
-gboolean amp_project_property_set (AmpProject *project, AnjutaProjectProperty *prop, const gchar* value);
+gboolean amp_node_property_load (AnjutaProjectNode *target, gint token_type, gint position, const gchar *value, AnjutaToken *token);
+gboolean amp_node_property_add (AnjutaProjectNode *node, AnjutaProjectProperty *prop);
+AnjutaProjectProperty * amp_node_property_set (AnjutaProjectNode *node, AnjutaProjectProperty *prop, const gchar* value);
GList* amp_get_project_property_list (void);
GList* amp_get_group_property_list (void);
diff --git a/plugins/am-project/projectparser.c b/plugins/am-project/projectparser.c
index 22e8ab5..5b07ed1 100644
--- a/plugins/am-project/projectparser.c
+++ b/plugins/am-project/projectparser.c
@@ -137,49 +137,39 @@ list_module (IAnjutaProject *project, AnjutaProjectNode *module, gint indent, co
}
static void
-list_property (IAnjutaProject *project)
+list_property (IAnjutaProject *project, AnjutaProjectNode *parent, gint indent)
{
- if (AMP_IS_PROJECT (project))
+ AnjutaProjectProperty *list;
+ AnjutaProjectProperty *prop;
+
+ for (prop = anjuta_project_node_first_property (parent); prop != NULL; prop = anjuta_project_property_next (prop))
{
- AnjutaProjectProperty *list;
- AnjutaProjectProperty *prop;
+ AnjutaProjectPropertyInfo *info;
+ const gchar *msg = NULL;
- list = amp_project_get_property_list (AMP_PROJECT (project));
- for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ info = anjuta_project_property_get_info(prop);
+ if (strcmp (info->name, "Name:") == 0)
{
- AnjutaProjectProperty *item;
-
- item = anjuta_project_property_override (list, prop);
- if (item != NULL)
- {
- AnjutaProjectPropertyInfo *info;
- const gchar *msg = NULL;
-
- info = anjuta_project_property_get_info(item);
- if (strcmp (info->name, "Name:") == 0)
- {
- msg = "%*sNAME: %s";
- }
- else if (strcmp (info->name, "Version:") == 0)
- {
- msg = "%*sVERSION: %s";
- }
- else if (strcmp (info->name, "Bug report URL:") == 0)
- {
- msg = "%*sBUG_REPORT: %s";
- }
- else if (strcmp (info->name, "Package name:") == 0)
- {
- msg = "%*sTARNAME: %s";
- }
- else if (strcmp (info->name, "URL:") == 0)
- {
- msg = "%*sURL: %s";
- }
-
- if (msg && (info->value != NULL)) print (msg, INDENT, "", info->value);
- }
+ msg = "%*sNAME: %s";
+ }
+ else if (strcmp (info->name, "Version:") == 0)
+ {
+ msg = "%*sVERSION: %s";
+ }
+ else if (strcmp (info->name, "Bug report URL:") == 0)
+ {
+ msg = "%*sBUG_REPORT: %s";
}
+ else if (strcmp (info->name, "Package name:") == 0)
+ {
+ msg = "%*sTARNAME: %s";
+ }
+ else if (strcmp (info->name, "URL:") == 0)
+ {
+ msg = "%*sURL: %s";
+ }
+
+ if (msg && (info->value != NULL)) print (msg, (indent + 1) * INDENT, "", info->value);
}
}
@@ -255,6 +245,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *parent, gint indent,
static void
list_root (IAnjutaProject *project, AnjutaProjectNode *root)
{
+ list_property (project, root, 0);
list_children (project, root, 0, NULL);
}
@@ -331,15 +322,14 @@ get_type (IAnjutaProject *project, const char *id)
}
static AnjutaProjectProperty *
-get_project_property (AmpProject *project, const gchar *id)
+get_project_property (AmpProject *project, AnjutaProjectNode *parent, const gchar *id)
{
AnjutaProjectProperty *list;
AnjutaProjectProperty *item;
AnjutaProjectProperty *prop = NULL;
gint best = G_MAXINT;
- list = amp_project_get_property_list (project);
- for (item = anjuta_project_property_first (list); item != NULL; item = anjuta_project_property_next (item))
+ for (item = anjuta_project_node_first_valid_property (parent); item != NULL; item = anjuta_project_property_next (item))
{
AnjutaProjectPropertyInfo *info = anjuta_project_property_get_info (item);
const gchar *name = info->name;
@@ -442,8 +432,6 @@ main(int argc, char *argv[])
}
else if (g_ascii_strcasecmp (*command, "list") == 0)
{
- list_property (project);
-
list_root (project, root);
}
else if (g_ascii_strcasecmp (*command, "move") == 0)
@@ -541,8 +529,11 @@ main(int argc, char *argv[])
AnjutaProjectProperty *item;
AnjutaProjectPropertyInfo *info = NULL;
- item = get_project_property (AMP_PROJECT (project), command[1]);
- if (item != NULL) amp_project_property_set (AMP_PROJECT (project), item, command[2]);
+ item = get_project_property (project, root, command[1]);
+ if (item != NULL)
+ {
+ ianjuta_project_set_string_property (project, root, item, command[2], NULL);
+ }
}
command += 2;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]