[anjuta] am-project: Allow to change directory group properties
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: Allow to change directory group properties
- Date: Wed, 27 Apr 2011 20:26:02 +0000 (UTC)
commit 071ccc4c9e602cd20c6704b582a257113dc6f421
Author: Sébastien Granjoux <seb sfo free fr>
Date: Wed Apr 27 22:17:20 2011 +0200
am-project: Allow to change directory group properties
libanjuta/anjuta-project.c | 25 ++++++++++++++
libanjuta/anjuta-project.h | 1 +
libanjuta/anjuta-token.h | 1 +
plugins/am-project/am-project.c | 2 +-
plugins/am-project/am-properties.c | 38 +++++++++++++++++----
plugins/am-project/am-writer.c | 11 ++++++
plugins/am-project/tests/properties.at | 50 +++++++++++++++++++++++++++
plugins/project-manager/dialogs.c | 58 +++++++++++++++++++++++++++++--
8 files changed, 174 insertions(+), 12 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 38f64cc..3e33646 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -676,6 +676,31 @@ anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty
return found != NULL ? (AnjutaProjectProperty *)found->data : NULL;
}
+/* If name is specified, look for a property with the same name, useful for
+ * map properties */
+AnjutaProjectProperty *
+anjuta_project_node_get_map_property (AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *name)
+{
+ GList *found;
+
+ /* Search in custom properties */
+ found = g_list_find_custom (node->custom_properties, property, find_property);
+ if (name != NULL)
+ {
+ while ((found != NULL) && (strcmp (name, ((AnjutaProjectProperty *)found->data)->name) != 0))
+ {
+ found = g_list_find_custom (g_list_next (found), property, find_property);
+ }
+ }
+
+ if (found == NULL)
+ {
+ /* Search in native properties */
+ found = g_list_find_custom (node->native_properties, property, find_property);
+ }
+
+ return found != NULL ? (AnjutaProjectProperty *)found->data : NULL;
+}
/* Set functions
*---------------------------------------------------------------------------*/
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index e7aa3c3..75d9831 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -198,6 +198,7 @@ GFile *anjuta_project_node_get_file (const AnjutaProjectNode *node);
GList *anjuta_project_node_get_native_properties (AnjutaProjectNode *node);
GList *anjuta_project_node_get_custom_properties (AnjutaProjectNode *node);
AnjutaProjectProperty *anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
+AnjutaProjectProperty *anjuta_project_node_get_map_property (AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *name);
gboolean anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
diff --git a/libanjuta/anjuta-token.h b/libanjuta/anjuta-token.h
index 5c0399d..920268a 100644
--- a/libanjuta/anjuta-token.h
+++ b/libanjuta/anjuta-token.h
@@ -127,6 +127,7 @@ AnjutaToken *anjuta_token_prepend_items (AnjutaToken *list, AnjutaToken *item);
AnjutaToken *anjuta_token_insert_after (AnjutaToken *sibling, AnjutaToken *token);
AnjutaToken *anjuta_token_insert_before (AnjutaToken *sibling, AnjutaToken *token);
AnjutaToken *anjuta_token_delete_parent (AnjutaToken *parent);
+void anjuta_token_remove_item (AnjutaToken *item);
AnjutaToken *anjuta_token_merge (AnjutaToken *first, AnjutaToken *end);
AnjutaToken *anjuta_token_merge_own_children (AnjutaToken *first);
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index b3e93d1..75f0684 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -2144,7 +2144,7 @@ amp_set_property_work (PmJob *job)
}
else if (flags & AM_PROPERTY_IN_MAKEFILE)
{
- if (((AmpProperty *)job->property->native)->suffix != NULL)
+ if (((AnjutaProjectProperty *)job->property->native)->flags & ANJUTA_PROJECT_PROPERTY_READ_WRITE)
{
amp_project_update_am_property (AMP_PROJECT (job->user_data), job->node, job->property);
}
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 93d30f1..151ae69 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -176,7 +176,7 @@ static AmpProperty AmpGroupNodeProperties[] =
{
{N_("Installation directories:"),
ANJUTA_PROJECT_PROPERTY_MAP,
- ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+ ANJUTA_PROJECT_PROPERTY_READ_WRITE,
N_("List of custom installation directories used by targets in this group.")},
AM_TOKEN_DIR, 0, NULL,
AM_PROPERTY_IN_MAKEFILE
@@ -1000,18 +1000,42 @@ AnjutaProjectProperty *
amp_node_property_set (AnjutaProjectNode *node, AnjutaProjectProperty *prop, const gchar* value)
{
AnjutaProjectProperty *new_prop;
+ gchar *name;
+
- new_prop = anjuta_project_node_get_property (node, prop);
- if ((new_prop != NULL) && (new_prop->native != NULL))
+ if ((value != NULL) && (prop->type == ANJUTA_PROJECT_PROPERTY_MAP))
{
- if ((new_prop->value != NULL) && (new_prop->value != new_prop->native->value)) g_free (new_prop->value);
- new_prop->value = g_strdup (value);
+ name = strchr (value, '=');
+ if (name != NULL)
+ {
+ gsize len = name - value;
+
+ name = g_strndup (value, len);
+ value += len + 1;
+ }
}
else
{
- new_prop = amp_property_new (NULL, ((AmpProperty *)prop)->token_type, ((AmpProperty *)prop)->position, value, NULL);
- anjuta_project_node_insert_property (node, prop, new_prop);
+ name = NULL;
+ }
+
+ new_prop = anjuta_project_node_get_map_property (node, prop, name);
+ if (new_prop != NULL)
+ {
+ if (new_prop->native != NULL)
+ {
+ /* Custom property already exist, replace value */
+ if ((new_prop->value != NULL) && (new_prop->value != new_prop->native->value)) g_free (new_prop->value);
+ new_prop->value = g_strdup (value);
+ }
+ else
+ {
+ /* Add new custom property */
+ new_prop = amp_property_new (name, ((AmpProperty *)new_prop)->token_type, ((AmpProperty *)prop)->position, value, NULL);
+ anjuta_project_node_insert_property (node, prop, new_prop);
+ }
}
+ g_free (name);
return new_prop;
}
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index a8fb3aa..332f2bd 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -1634,6 +1634,7 @@ gboolean amp_project_update_am_property (AmpProject *project, AnjutaProjectNode
/* Other properties having their own variable */
GString *new_value;
AnjutaToken *arg;
+ AnjutaToken *token;
const gchar *value;
AnjutaTokenStyle *style;
@@ -1731,6 +1732,16 @@ gboolean amp_project_update_am_property (AmpProject *project, AnjutaProjectNode
property->value = g_string_free (new_value, FALSE);
break;
+ case ANJUTA_PROJECT_PROPERTY_MAP:
+
+ token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, property->value);
+ anjuta_token_insert_word_after (args, NULL, token);
+
+ for (token = anjuta_token_next_word (token); token != NULL; token = anjuta_token_next_word (token))
+ {
+ anjuta_token_remove_word (token);
+ }
+ break;
default:
break;
}
diff --git a/plugins/am-project/tests/properties.at b/plugins/am-project/tests/properties.at
index 735083b..f2d058d 100644
--- a/plugins/am-project/tests/properties.at
+++ b/plugins/am-project/tests/properties.at
@@ -714,4 +714,54 @@ AT_PARSER_CHECK([load empty18 \
list])
AT_CHECK([diff -b output expect])
+
+
+AT_DATA([expect],
+[[ GROUP (): empty19
+ PROPERTY (Installation directories): plugindir = @plugindir@
+ TARGET (): target1
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ SOURCE (): source2
+ TARGET (): target2
+ PROPERTY (Installation directory): bindir
+ PROPERTY (Libraries): $(GDL_LIBS)
+ SOURCE (): source1
+ TARGET (): library1.la
+ PROPERTY (Installation directory): plugindir
+ PROPERTY (Build for check only): true
+ PROPERTY (Libraries): $(GDL_LIBS)
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+ target2
+
+target1_SOURCES = \
+ source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES = \
+ source1
+
+target2_LDADD = $(GDL_LIBS)
+
+plugindir = @plugindir@
+check_plugin_LTLIBRARIES = \
+ library1.la
+
+library1_la_LIBADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty18 \
+ move empty19 \
+ set 0 instdir 'plugindir= plugindir@' \
+ list \
+ save])
+AT_CHECK([diff -b empty19/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty19 \
+ list])
+AT_CHECK([diff -b output expect])
+
+
AT_CLEANUP
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 60fc4c9..4946e10 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -71,6 +71,8 @@ typedef struct _PropertyValue
enum {
NAME_COLUMN,
VALUE_COLUMN,
+ EDITABLE_COLUMN,
+ PROPERTY_COLUMN,
LIST_COLUMNS_NB
};
@@ -257,6 +259,23 @@ entry_changed_cb (GtkEditable *editable, gpointer user_data)
}
static void
+on_value_edited (GtkCellRendererText *cell,
+ gchar *path_string,
+ gchar *text,
+ gpointer user_data)
+{
+ GtkTreeView *view = (GtkTreeView *)user_data;
+ GtkTreeIter iter;
+ GtkTreeModel * model;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+ if (gtk_tree_model_get_iter_from_string (model, &iter, path_string))
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, VALUE_COLUMN, text, -1);
+ }
+}
+
+static void
on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
{
GtkWidget* button = GTK_WIDGET(data);
@@ -345,7 +364,7 @@ add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProper
GtkWidget *entry = NULL;
GtkWidget *view;
static GType column_type[LIST_COLUMNS_NB] = {
- G_TYPE_STRING, G_TYPE_STRING};
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER};
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeModel *model;
@@ -418,12 +437,22 @@ add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProper
if (cust_prop->native == prop)
{
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, NAME_COLUMN, cust_prop->name, VALUE_COLUMN, cust_prop->value, -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ NAME_COLUMN, cust_prop->name,
+ VALUE_COLUMN, cust_prop->value,
+ EDITABLE_COLUMN, TRUE,
+ PROPERTY_COLUMN, cust_prop,
+ -1);
}
}
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, NAME_COLUMN, "", VALUE_COLUMN, "", -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ NAME_COLUMN, "",
+ VALUE_COLUMN, "",
+ EDITABLE_COLUMN, TRUE,
+ PROPERTY_COLUMN, NULL,
+ -1);
entry = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (entry), GTK_SHADOW_IN);
@@ -446,10 +475,13 @@ add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProper
renderer,
"text",
VALUE_COLUMN,
+ "editable",
+ EDITABLE_COLUMN,
NULL);
+ g_signal_connect(renderer, "edited", (GCallback) on_value_edited, view);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
-
+
gtk_container_add (GTK_CONTAINER (entry), view);
break;
@@ -655,7 +687,10 @@ on_properties_dialog_response (GtkWidget *dialog,
PropertyEntry *entry = (PropertyEntry *)item->data;
AnjutaProjectProperty *prop;
const gchar *text;
+ gboolean valid;
gboolean active;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
/* Get property value in node */
prop = anjuta_project_node_get_property (table->node, entry->property);
@@ -697,6 +732,21 @@ on_properties_dialog_response (GtkWidget *dialog,
}
break;
case ANJUTA_PROJECT_PROPERTY_MAP:
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (entry->entry))));
+ for (valid = gtk_tree_model_get_iter_first (model, &iter); valid; valid = gtk_tree_model_iter_next (model, &iter))
+ {
+ AnjutaProjectProperty *cust_prop;
+ gchar *value;
+
+ value = NULL;
+ gtk_tree_model_get (model, &iter, VALUE_COLUMN, &value, PROPERTY_COLUMN, &cust_prop, -1);
+ if ((cust_prop != NULL) && (g_strcmp0 (cust_prop->value, value) != 0))
+ {
+ /* Modified */
+ ianjuta_project_set_property (table->project->project, table->node, cust_prop, value, NULL);
+ }
+ g_free (value);
+ }
break;
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]