[anjuta/newproject] Handle project node properties in a more general way
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Handle project node properties in a more general way
- Date: Sun, 7 Feb 2010 20:43:32 +0000 (UTC)
commit a461a5b96462110b9d2cbdd6ef65b7e192a38cc7
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Feb 7 21:42:48 2010 +0100
Handle project node properties in a more general way
libanjuta/anjuta-project.c | 151 ++++++++++++++++++++++++++++
libanjuta/anjuta-project.h | 37 +++++++-
plugins/am-project/Makefile.am | 4 +-
plugins/am-project/ac-writer.c | 3 +-
plugins/am-project/am-dialogs.c | 75 ++++++++++++--
plugins/am-project/am-project-private.h | 31 ++++++-
plugins/am-project/am-project.c | 167 ++++++++++++++++++++++---------
plugins/am-project/am-project.h | 5 +-
plugins/am-project/am-project.plugin.in | 2 +-
plugins/am-project/am-properties.c | 136 +++++++++++++++++++++++++
plugins/am-project/am-properties.h | 38 +++++++
plugins/dir-project/dir-project.c | 2 +-
plugins/mk-project/mk-project.c | 2 +-
13 files changed, 585 insertions(+), 68 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index aa7c394..2063706 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -55,6 +55,102 @@
#define SOURCE_DATA(node) ((node) != NULL ? (AnjutaProjectSourceData *)((node)->data) : NULL)
+/* Properties functions
+ *---------------------------------------------------------------------------*/
+
+AnjutaProjectPropertyList *
+anjuta_project_property_first (AnjutaProjectPropertyList *list)
+{
+ if (list != NULL)
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)list->data;
+
+ if (info->override != NULL)
+ {
+ list = g_list_first (info->override);
+ }
+ }
+ return list;
+}
+
+AnjutaProjectPropertyItem *
+anjuta_project_property_next (AnjutaProjectPropertyItem *list)
+{
+ return g_list_next (list);
+}
+
+AnjutaProjectPropertyInfo *
+anjuta_project_property_get_info (AnjutaProjectPropertyItem *list)
+{
+ return (AnjutaProjectPropertyInfo *)list->data;
+}
+
+AnjutaProjectPropertyInfo *
+anjuta_project_property_lookup (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop)
+{
+ AnjutaProjectPropertyInfo *info;
+
+ for (; list != NULL; list = g_list_next (list))
+ {
+ info = (AnjutaProjectPropertyInfo *)list->data;
+
+ if (info->override == NULL)
+ {
+ info = NULL;
+ break;
+ }
+ else if (info->override == prop)
+ {
+ break;
+ }
+ info = NULL;
+ }
+
+ return info;
+}
+
+AnjutaProjectPropertyList *
+anjuta_project_property_insert (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop, AnjutaProjectPropertyInfo *info)
+{
+ GList *next;
+
+ info->name = ((AnjutaProjectPropertyInfo *)prop->data)->name;
+ info->type = ((AnjutaProjectPropertyInfo *)prop->data)->type;
+ info->override = prop;
+
+ next = ((AnjutaProjectPropertyInfo *)list->data)->override;
+ if (next != NULL)
+ {
+ next = list;
+ }
+ list = g_list_prepend (next, info);
+
+ return list;
+}
+
+AnjutaProjectPropertyList *
+anjuta_project_property_remove (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop)
+{
+ AnjutaProjectPropertyInfo *info;
+ GList *link;
+
+ for (link = list; link != NULL; link = g_list_next (link))
+ {
+ info = (AnjutaProjectPropertyInfo *)link->data;
+ if (info->override == NULL)
+ {
+ break;
+ }
+ else if ((info == prop->data) || (info->override == prop))
+ {
+ list = g_list_delete_link (list, link);
+ break;
+ }
+ }
+
+ return list;
+}
+
/* Node access functions
*---------------------------------------------------------------------------*/
@@ -227,6 +323,61 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
return file;
}
+AnjutaProjectPropertyList *
+anjuta_project_node_get_property_list (AnjutaProjectNode *node)
+{
+ GList *list = NULL;
+ GList *item;
+ GList *new_item;
+
+ for (item = g_list_last (NODE_DATA (node)->properties); item != NULL; item = g_list_previous (item))
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+
+ if (info->override != NULL) break;
+
+ list = g_list_prepend (list, item->data);
+ }
+
+ new_item = g_list_first (list);
+ for (item = g_list_first (NODE_DATA (node)->properties); item != NULL; item = g_list_next (item))
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+
+ if (info->override == NULL) break;
+
+ while (new_item->data != NULL)
+ {
+ if (new_item->data == info->override)
+ {
+ new_item->data = info;
+ break;
+ }
+ new_item = g_list_next (new_item);
+ }
+ }
+
+ return list;
+}
+
+const gchar *
+anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop)
+{
+ GList *item;
+
+ for (item = g_list_first (NODE_DATA (node)->properties); item != NULL; item = g_list_next (item))
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+
+ if ((info == prop) || ((info->override != NULL) && (info->override->data == prop)))
+ {
+ return info->value;
+ }
+ }
+
+ return NULL;
+}
+
/* Group access functions
*---------------------------------------------------------------------------*/
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 2776e6d..1934ec8 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -65,13 +65,34 @@ typedef struct
gchar *name;
AnjutaProjectTargetClass base;
gchar *mime_type;
-} AnjutaProjectTargetInformation;
+} AnjutaProjectTargetInfo;
+
+typedef AnjutaProjectTargetInfo* AnjutaProjectTargetType;
+
+typedef enum
+{
+ ANJUTA_PROJECT_PROPERTY_STRING = 1,
+ ANJUTA_PROJECT_PROPERTY_BOOLEAN
+} AnjutaProjectPropertyType;
+
+typedef struct
+{
+ gchar *name;
+ AnjutaProjectPropertyType type;
+ gchar *value;
+ GList *override;
+} AnjutaProjectPropertyInfo;
+
+typedef AnjutaProjectPropertyInfo* AnjutaProjectProperty;
+
+typedef GList AnjutaProjectPropertyList;
+typedef GList AnjutaProjectPropertyItem;
-typedef AnjutaProjectTargetInformation* AnjutaProjectTargetType;
typedef struct
{
AnjutaProjectNodeType type;
+ AnjutaProjectPropertyList *properties;
} AnjutaProjectNodeData;
typedef struct {
@@ -95,10 +116,19 @@ typedef GNode AnjutaProjectGroup;
typedef GNode AnjutaProjectTarget;
typedef GNode AnjutaProjectSource;
+
#define ANJUTA_PROJECT_NODE_DATA(node) ((node) != NULL ? (AnjutaProjectNodeData *)((node)->data) : NULL)
typedef void (*AnjutaProjectNodeFunc) (AnjutaProjectNode *node, gpointer data);
+AnjutaProjectPropertyItem *anjuta_project_property_first (AnjutaProjectPropertyList *list);
+AnjutaProjectPropertyItem *anjuta_project_property_next (AnjutaProjectPropertyItem *list);
+AnjutaProjectPropertyInfo *anjuta_project_property_get_info (AnjutaProjectPropertyItem *list);
+AnjutaProjectPropertyInfo *anjuta_project_property_lookup (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop);
+AnjutaProjectPropertyList *anjuta_project_property_insert (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop, AnjutaProjectPropertyInfo *info);
+AnjutaProjectPropertyList *anjuta_project_property_remove (AnjutaProjectPropertyList *list, AnjutaProjectPropertyItem *prop);
+
+
AnjutaProjectNode *anjuta_project_node_parent (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_first_child (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_last_child (AnjutaProjectNode *node);
@@ -119,6 +149,9 @@ 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);
+AnjutaProjectPropertyList *anjuta_project_node_get_property_list (AnjutaProjectNode *node);
+const gchar *anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop);
+
AnjutaProjectGroup *anjuta_project_group_get_node_from_file (const AnjutaProjectGroup *root, GFile *directory);
AnjutaProjectTarget *anjuta_project_target_get_node_from_name (const AnjutaProjectGroup *parent, const gchar *name);
AnjutaProjectSource *anjuta_project_source_get_node_from_file (const AnjutaProjectNode *parent, GFile *file);
diff --git a/plugins/am-project/Makefile.am b/plugins/am-project/Makefile.am
index f2a678b..cb5fbf6 100644
--- a/plugins/am-project/Makefile.am
+++ b/plugins/am-project/Makefile.am
@@ -44,7 +44,9 @@ libam_project_la_SOURCES = \
am-writer.c \
am-project-private.h \
am-dialogs.h \
- am-dialogs.c
+ am-dialogs.c \
+ am-properties.c \
+ am-properties.h
libam_project_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index 2aa583a..3c15199 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -120,6 +120,7 @@ skip_comment (AnjutaToken *token)
/* Public functions
*---------------------------------------------------------------------------*/
+#if 0
gboolean
amp_project_update_property (AmpProject *project, AmpPropertyType type)
{
@@ -199,4 +200,4 @@ amp_project_update_property (AmpProject *project, AmpPropertyType type)
return TRUE;
}
-
+#endif
diff --git a/plugins/am-project/am-dialogs.c b/plugins/am-project/am-dialogs.c
index 441da27..81d0052 100644
--- a/plugins/am-project/am-dialogs.c
+++ b/plugins/am-project/am-dialogs.c
@@ -58,22 +58,21 @@ on_project_widget_destroy (GtkWidget *wid, AmpConfigureProjectDialog *dlg)
}
static void
-add_entry (AmpProject *project, const gchar *id, const gchar *display_name, AmpPropertyType type, GtkWidget *table, gint position)
+add_entry (AmpProject *project, AnjutaProjectNode *node, AnjutaProjectPropertyInfo *info, GtkWidget *table, gint position)
{
GtkWidget *label;
GtkWidget *entry;
- gchar *value;
+ const gchar *value;
- label = gtk_label_new (display_name);
+ label = gtk_label_new (_(info->name));
gtk_misc_set_alignment (GTK_MISC (label), 0, -1);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, position, position+1,
GTK_FILL, GTK_FILL, 5, 3);
entry = gtk_entry_new ();
- value = amp_project_get_property (project, type);
+ value = info->value;
gtk_entry_set_text (GTK_ENTRY (entry), value);
- g_free (value);
gtk_misc_set_alignment (GTK_MISC (entry), 0, -1);
gtk_widget_show (entry);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, position, position+1,
@@ -108,7 +107,10 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
GtkWidget *top_level;
AmpConfigureProjectDialog *dlg;
GtkWidget *table;
+ gint pos;
gchar *name;
+ AnjutaProjectPropertyItem *prop;
+ AnjutaProjectPropertyList *list;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
if (!bxml) return NULL;
@@ -126,17 +128,26 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
add_label (_("Path:"), name, table, 0);
g_free (name);
- add_entry (project, NULL, _("Name:"), AMP_PROPERTY_NAME, table, 1);
+ pos = 1;
+ list = amp_project_get_property_list (project);
+ for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ {
+ AnjutaProjectPropertyInfo *info;
+
+ info = anjuta_project_property_lookup (list, prop);
+ if (info == NULL) info = anjuta_project_property_get_info (prop);
+ add_entry (project, NULL, info, table, pos++);
+ }
+
+ /*add_entry (project, NULL, _("Name:"), AMP_PROPERTY_NAME, table, 1);
add_entry (project, NULL, _("Version:"), AMP_PROPERTY_VERSION, table, 2);
add_entry (project, NULL, _("Bug report URL:"), AMP_PROPERTY_BUG_REPORT, table, 3);
add_entry (project, NULL, _("Package name:"), AMP_PROPERTY_TARNAME, table, 4);
- add_entry (project, NULL, _("URL:"), AMP_PROPERTY_URL, table, 5);
+ add_entry (project, NULL, _("URL:"), AMP_PROPERTY_URL, table, 5);*/
gtk_widget_show_all (top_level);
g_object_unref (bxml);
- g_message ("get config dialog %p", top_level);
-
return top_level;
}
@@ -146,9 +157,13 @@ amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error
GtkBuilder *bxml = gtk_builder_new ();
GtkWidget *properties;
GtkWidget *main_table;
+ gint main_pos;
GtkWidget *extra_table;
+ gint extra_pos;
AmpConfigureProjectDialog *dlg;
gchar *name;
+ AnjutaProjectPropertyList *list;
+ AnjutaProjectPropertyItem *prop;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
if (!bxml) return NULL;
@@ -166,6 +181,25 @@ amp_configure_group_dialog (AmpProject *project, AmpGroup *group, GError **error
name = g_file_get_parse_name (amp_group_get_directory (group));
add_label (_("Name:"), name, main_table, 0);
g_free (name);
+
+ main_pos = 1;
+ extra_pos = 0;
+ list = amp_project_get_property_list (project);
+ for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ {
+ AnjutaProjectPropertyInfo *info;
+
+ info = anjuta_project_property_lookup (list, prop);
+ if (info != NULL)
+ {
+ add_entry (project, (AnjutaProjectNode *)group, info, extra_table, extra_pos++);
+ }
+ else
+ {
+ info = anjuta_project_property_get_info (prop);
+ add_entry (project, (AnjutaProjectNode *)group, info, main_table, main_pos++);
+ }
+ }
gtk_widget_show_all (properties);
g_object_unref (bxml);
@@ -179,10 +213,14 @@ amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **er
GtkBuilder *bxml = gtk_builder_new ();
GtkWidget *properties;
GtkWidget *main_table;
+ gint main_pos;
GtkWidget *extra_table;
+ gint extra_pos;
AmpConfigureProjectDialog *dlg;
AnjutaProjectTargetType type;
const gchar *name;
+ AnjutaProjectPropertyList *list;
+ AnjutaProjectPropertyItem *prop;
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
if (!bxml) return NULL;
@@ -201,6 +239,25 @@ amp_configure_target_dialog (AmpProject *project, AmpTarget *target, GError **er
add_label (_("Name:"), name, main_table, 0);
type = anjuta_project_target_get_type (target);
add_label (_("Type:"), anjuta_project_target_type_name (type), main_table, 1);
+
+ main_pos = 2;
+ extra_pos = 0;
+ list = amp_project_get_property_list (project);
+ for (prop = anjuta_project_property_first (list); prop != NULL; prop = anjuta_project_property_next (prop))
+ {
+ AnjutaProjectPropertyInfo *info;
+
+ info = anjuta_project_property_lookup (list, prop);
+ if (info != NULL)
+ {
+ add_entry (project, (AnjutaProjectNode *)target, info, extra_table, extra_pos++);
+ }
+ else
+ {
+ info = anjuta_project_property_get_info (prop);
+ add_entry (project, (AnjutaProjectNode *)target, info, main_table, main_pos++);
+ }
+ }
gtk_widget_show_all (properties);
g_object_unref (bxml);
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 641a2b9..1b3d302 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -36,6 +36,7 @@ struct _AmpModule {
AnjutaToken *module;
};
+#if 0
struct _AmpProperty {
AnjutaToken *ac_init; /* AC_INIT macro */
AnjutaToken *args;
@@ -45,6 +46,33 @@ struct _AmpProperty {
gchar *tarname;
gchar *url;
};
+#endif
+
+struct _AmpProjectPropertyInfo {
+ AnjutaProjectPropertyInfo base;
+ AnjutaToken *ac_init;
+ gint position;
+};
+
+typedef struct _AmpProjectPropertyInfo AmpProjectPropertyInfo;
+
+struct _AmpGroupPropertyInfo {
+ AnjutaProjectPropertyInfo base;
+ AnjutaToken *ac_init;
+ gint position;
+};
+
+typedef struct _AmpGroupPropertyInfo AmpGroupPropertyInfo;
+
+struct _AmpTargetPropertyInfo {
+ AnjutaProjectPropertyInfo base;
+ AnjutaToken *ac_init;
+ gint position;
+};
+
+typedef struct _AmpTargetPropertyInfo AmpTargetPropertyInfo;
+
+
struct _AmpProject {
GObject parent;
@@ -57,7 +85,8 @@ struct _AmpProject {
AnjutaTokenFile *configure_file; /* configure.in file */
AnjutaToken *configure_token;
- AmpProperty *property;
+ //AmpProperty *property;
+ GList *properties;
AmpGroup *root_node; /* tree containing project data;
* each GNode's data is a
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 2583099..fcad899 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -133,7 +133,7 @@ struct _AmpConfigFile {
typedef struct _AmpTargetInformation AmpTargetInformation;
struct _AmpTargetInformation {
- AnjutaProjectTargetInformation base;
+ AnjutaProjectTargetInfo base;
AnjutaTokenType token;
const gchar *prefix;
const gchar *install;
@@ -222,6 +222,11 @@ static AmpTargetInformation AmpTargetTypes[] = {
NULL}
};
+/* Properties
+ *---------------------------------------------------------------------------*/
+
+
+
/* ----- Standard GObject types and variables ----- */
@@ -468,7 +473,6 @@ amp_config_file_new (const gchar *pathname, GFile *project_root, AnjutaToken *to
config = g_slice_new0(AmpConfigFile);
config->file = g_file_resolve_relative_path (project_root, pathname);
- g_message ("new config file =%s= token %p group %p", pathname, token, anjuta_token_list (token));
config->token = token;
return config;
@@ -561,46 +565,6 @@ amp_project_free_module_hash (AmpProject *project)
}
}
-/* Property objects
- *---------------------------------------------------------------------------*/
-
-static AmpProperty*
-amp_property_new (AnjutaToken *macro, AnjutaToken *list)
-{
- AmpProperty *prop;
- AnjutaToken *arg;
-
- prop = g_slice_new0(AmpProperty);
- prop->ac_init = macro;
- prop->args = list;
-
- if (list != NULL)
- {
- arg = anjuta_token_nth_word (list, 0);
- prop->name = anjuta_token_evaluate (arg);
- arg = anjuta_token_nth_word (list, 1);
- prop->version = anjuta_token_evaluate (arg);
- arg = anjuta_token_nth_word (list, 2);
- prop->bug_report = anjuta_token_evaluate (arg);
- arg = anjuta_token_nth_word (list, 3);
- prop->tarname = anjuta_token_evaluate (arg);
- arg = anjuta_token_nth_word (list, 4);
- prop->url = anjuta_token_evaluate (arg);
- }
-
- return prop;
-}
-
-static void
-amp_property_free (AmpProperty *prop)
-{
- g_free (prop->name);
- g_free (prop->version);
- g_free (prop->bug_report);
- g_free (prop->tarname);
- g_slice_free (AmpProperty, prop);
-}
-
/* Group objects
*---------------------------------------------------------------------------*/
@@ -792,6 +756,79 @@ amp_source_free (AmpSource *node)
g_node_destroy (node);
}
+/* Properties objects
+ *---------------------------------------------------------------------------*/
+
+static AmpProjectPropertyInfo *
+amp_project_property_new (AnjutaToken *ac_init)
+{
+ AmpProjectPropertyInfo *prop;
+
+ prop = g_slice_new0(AmpProjectPropertyInfo);
+ prop->ac_init = ac_init;
+
+ return prop;
+}
+
+static void
+amp_project_property_free (AmpProjectPropertyInfo *prop)
+{
+ if (prop->base.override != NULL)
+ {
+ if ((prop->base.value != NULL) && (prop->base.value != ((AmpProjectPropertyInfo *)(prop->base.override->data))->base.value))
+ {
+ g_free (prop->base.value);
+ }
+ g_slice_free (AmpProjectPropertyInfo, prop);
+ }
+}
+
+static AmpGroupPropertyInfo *
+amp_group_property_new (void)
+{
+ AmpGroupPropertyInfo *prop;
+
+ prop = g_slice_new0(AmpGroupPropertyInfo);
+
+ return prop;
+}
+
+static void
+amp_group_property_free (AmpGroupPropertyInfo *prop)
+{
+ if (prop->base.override != NULL)
+ {
+ if ((prop->base.value != NULL) && (prop->base.value != ((AmpGroupPropertyInfo *)(prop->base.override->data))->base.value))
+ {
+ g_free (prop->base.value);
+ }
+ g_slice_free (AmpGroupPropertyInfo, prop);
+ }
+}
+
+static AmpTargetPropertyInfo *
+amp_target_property_new (void)
+{
+ AmpTargetPropertyInfo *prop;
+
+ prop = g_slice_new0(AmpTargetPropertyInfo);
+
+ return prop;
+}
+
+static void
+amp_target_property_free (AmpTargetPropertyInfo *prop)
+{
+ if (prop->base.override != NULL)
+ {
+ if ((prop->base.value != NULL) && (prop->base.value != ((AmpTargetPropertyInfo *)(prop->base.override->data))->base.value))
+ {
+ g_free (prop->base.value);
+ }
+ g_slice_free (AmpTargetPropertyInfo, prop);
+ }
+}
+
/*
* File monitoring support --------------------------------
* FIXME: review these
@@ -963,11 +1000,35 @@ project_node_destroy (AmpProject *project, AnjutaProjectNode *g_node)
}
void
-amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToken *list)
+amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToken *args)
{
+ AnjutaProjectPropertyItem *list;
+
fprintf (stdout, "property list:\n");
- anjuta_token_dump (list);
- project->property = amp_property_new (macro, list);
+ anjuta_token_dump (args);
+
+ for (list = anjuta_project_property_first (project->properties); list != NULL; list = anjuta_project_property_next (list))
+ {
+ AmpProjectPropertyInfo *info = anjuta_project_property_get_info (list);
+
+ if (info->position >= 0)
+ {
+ AmpProjectPropertyInfo *prop;
+ AnjutaToken *arg;
+
+ prop = anjuta_project_property_lookup (project->properties, list);
+ if (prop == NULL)
+ {
+ prop = amp_project_property_new (macro);
+
+ project->properties = anjuta_project_property_insert (project->properties, list, prop);
+ }
+
+ arg = anjuta_token_nth_word (args, info->position);
+ if ((prop->base.value != NULL) && (prop->base.value != info->base.value)) g_free (prop->base.value);
+ prop->base.value = anjuta_token_evaluate (arg);
+ }
+ }
}
void
@@ -1637,8 +1698,8 @@ amp_project_unload (AmpProject *project)
if (project->root_file) g_object_unref (project->root_file);
project->root_file = NULL;
- if (project->property) amp_property_free (project->property);
- project->property = NULL;
+ g_list_foreach (project->properties, (GFunc)amp_project_property_free, NULL);
+ project->properties = amp_get_project_property_list ();
/* shortcut hash tables */
if (project->groups) g_hash_table_destroy (project->groups);
@@ -2574,7 +2635,14 @@ amp_project_get_file (AmpProject *project)
return project->root_file;
}
-
+
+AnjutaProjectPropertyList *
+amp_project_get_property_list (AmpProject *project)
+{
+ return project->properties;
+}
+
+#if 0
gchar *
amp_project_get_property (AmpProject *project, AmpPropertyType type)
{
@@ -2634,6 +2702,7 @@ amp_project_set_property (AmpProject *project, AmpPropertyType type, const gchar
return amp_project_update_property (project, type);
}
+#endif
/* Implement IAnjutaProject
*---------------------------------------------------------------------------*/
@@ -2842,7 +2911,7 @@ amp_project_instance_init (AmpProject *project)
project->configure_file = NULL;
project->configure_token = NULL;
project->root_node = NULL;
- project->property = NULL;
+ project->properties = amp_get_project_property_list ();
project->am_space_list = NULL;
project->ac_space_list = NULL;
diff --git a/plugins/am-project/am-project.h b/plugins/am-project/am-project.h
index cd56897..d91b65a 100644
--- a/plugins/am-project/am-project.h
+++ b/plugins/am-project/am-project.h
@@ -106,8 +106,9 @@ GList *amp_project_get_config_packages (AmpProject *project, const gchar* modul
GList *amp_project_get_target_types (AmpProject *project, GError **error);
-gchar* amp_project_get_property (AmpProject *project, AmpPropertyType type);
-gboolean amp_project_set_property (AmpProject *project, AmpPropertyType type, const gchar* value);
+AnjutaProjectPropertyList *amp_project_get_property_list (AmpProject *project);
+//gchar* amp_project_get_property (AmpProject *project, AmpPropertyType type);
+//gboolean amp_project_set_property (AmpProject *project, AmpPropertyType type, const gchar* value);
gchar * amp_project_get_node_id (AmpProject *project, const gchar *path);
diff --git a/plugins/am-project/am-project.plugin.in b/plugins/am-project/am-project.plugin.in
index 87a82bc..9dd63b3 100644
--- a/plugins/am-project/am-project.plugin.in
+++ b/plugins/am-project/am-project.plugin.in
@@ -1,6 +1,6 @@
[Anjuta Plugin]
_Name=Autotools backend
-_Description=Autotools backend for project manager
+_Description=New Autotools backend for project manager
Location=am-project:AmpPlugin
Icon=gbf-am-plugin-48.png
Interfaces=IAnjutaProjectBackend
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
new file mode 100644
index 0000000..ba0a90d
--- /dev/null
+++ b/plugins/am-project/am-properties.c
@@ -0,0 +1,136 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
+/* am-properties.c
+ *
+ * Copyright (C) 2010 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "am-properties.h"
+
+#include "am-project-private.h"
+
+#include <glib/gi18n.h>
+
+
+/* Types
+ *---------------------------------------------------------------------------*/
+
+/* Constants
+ *---------------------------------------------------------------------------*/
+
+static AmpProjectPropertyInfo AmpProjectProperties[] = {
+ {{N_("Name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0},
+ {{N_("Version:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 1},
+ {{N_("Bug report URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 2},
+ {{N_("Package name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 3},
+ {{N_("URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0}};
+
+static GList* AmpProjectPropertyList = NULL;
+
+
+static AmpGroupPropertyInfo AmpGroupProperties[] = {
+ {{N_("Name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0},
+ {{N_("Version:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 1},
+ {{N_("Bug report URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 2},
+ {{N_("Package name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 3},
+ {{N_("URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0}};
+
+static GList* AmpGroupPropertyList = NULL;
+
+
+static AmpTargetPropertyInfo AmpTargetProperties[] = {
+ {{N_("Name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0},
+ {{N_("Version:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 1},
+ {{N_("Bug report URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 2},
+ {{N_("Package name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 3},
+ {{N_("URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0}};
+
+static GList* AmpTargetPropertyList = NULL;
+
+/* Helper functions
+ *---------------------------------------------------------------------------*/
+
+/* Private functions
+ *---------------------------------------------------------------------------*/
+
+/* Public functions
+ *---------------------------------------------------------------------------*/
+
+GList*
+amp_get_project_property_list (void)
+{
+ if (AmpProjectPropertyList == NULL)
+ {
+ AmpProjectPropertyInfo *prop;
+
+ for (prop = AmpProjectProperties; prop->base.name != NULL; prop++)
+ {
+ AmpProjectPropertyList = g_list_prepend (AmpProjectPropertyList, prop);
+ }
+ AmpProjectPropertyList = g_list_reverse (AmpProjectPropertyList);
+ }
+
+ return AmpProjectPropertyList;
+}
+
+GList*
+amp_get_group_property_list (void)
+{
+ if (AmpGroupPropertyList == NULL)
+ {
+ AmpGroupPropertyInfo *prop;
+
+ for (prop = AmpGroupProperties; prop->base.name != NULL; prop++)
+ {
+ AmpGroupPropertyList = g_list_prepend (AmpGroupPropertyList, prop);
+ }
+ AmpGroupPropertyList = g_list_reverse (AmpGroupPropertyList);
+ }
+
+ return AmpGroupPropertyList;
+}
+
+GList*
+amp_get_target_property_list (void)
+{
+ if (AmpTargetPropertyList == NULL)
+ {
+ AmpTargetPropertyInfo *prop;
+
+ for (prop = AmpTargetProperties; prop->base.name != NULL; prop++)
+ {
+ AmpTargetPropertyList = g_list_prepend (AmpTargetPropertyList, prop);
+ }
+ AmpTargetPropertyList = g_list_reverse (AmpTargetPropertyList);
+ }
+
+ return AmpTargetPropertyList;
+}
+
+GList*
+amp_get_source_property_list (void)
+{
+ return NULL;
+}
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
new file mode 100644
index 0000000..e6c1005
--- /dev/null
+++ b/plugins/am-project/am-properties.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
+/* am-properties.h
+ *
+ * Copyright (C) 2010 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _AM_PROPERTIES_H_
+#define _AM_PROPERTIES_H_
+
+#include "am-project.h"
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+GList* amp_get_project_property_list (void);
+GList* amp_get_group_property_list (void);
+GList* amp_get_target_property_list (void);
+GList* amp_get_source_property_list (void);
+
+G_END_DECLS
+
+#endif /* _AM_PROPERTIES_H_ */
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index 60c6f3b..4101d93 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -834,7 +834,7 @@ dir_project_add_source (DirProject *project,
static GList *
dir_project_get_target_types (DirProject *project, GError **error)
{
- static AnjutaProjectTargetInformation unknown_type = {N_("Unknown"), ANJUTA_TARGET_UNKNOWN,"text/plain"};
+ static AnjutaProjectTargetInfo unknown_type = {N_("Unknown"), ANJUTA_TARGET_UNKNOWN,"text/plain"};
return g_list_prepend (NULL, &unknown_type);
}
diff --git a/plugins/mk-project/mk-project.c b/plugins/mk-project/mk-project.c
index d0d9c9d..496994f 100644
--- a/plugins/mk-project/mk-project.c
+++ b/plugins/mk-project/mk-project.c
@@ -118,7 +118,7 @@ struct _MkpSourceData {
typedef struct _MkpTargetInformation MkpTargetInformation;
struct _MkpTargetInformation {
- AnjutaProjectTargetInformation base;
+ AnjutaProjectTargetInfo base;
AnjutaTokenType token;
const gchar *prefix;
const gchar *install;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]