[anjuta] am-project: Allow to have sub directories in a group
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: Allow to have sub directories in a group
- Date: Sat, 31 Mar 2012 20:55:05 +0000 (UTC)
commit 39c09ec010c9a350e0d7c6c27a73f7ba80614b9b
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sat Mar 31 22:48:10 2012 +0200
am-project: Allow to have sub directories in a group
A directory name like "subdir/group1" is accepted now and create a Makefile.am only in subdir/group1, not in subdir.
plugins/am-project/am-project.c | 2 +-
plugins/am-project/amp-group.c | 15 ++++++---------
plugins/am-project/amp-group.h | 4 ++--
plugins/am-project/amp-node.c | 2 +-
plugins/am-project/amp-root.c | 16 ++++++++++++++--
plugins/am-project/tests/empty.at | 19 +++++++++++++++++++
6 files changed, 43 insertions(+), 15 deletions(-)
---
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 45408f6..ccafe26 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1365,7 +1365,7 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AnjutaProjectNode
else
{
/* Create new group */
- group = amp_group_node_new (subdir, dist_only);
+ group = amp_group_node_new (subdir, value, dist_only);
/* Group can be NULL if the name is not valid */
if (group != NULL)
diff --git a/plugins/am-project/amp-group.c b/plugins/am-project/amp-group.c
index 759347b..7d50e41 100644
--- a/plugins/am-project/amp-group.c
+++ b/plugins/am-project/amp-group.c
@@ -518,12 +518,13 @@ amp_group_node_set_file (AmpGroupNode *group, GFile *new_file)
}
AmpGroupNode*
-amp_group_node_new (GFile *file, gboolean dist_only)
+amp_group_node_new (GFile *file, const gchar *name, gboolean dist_only)
{
AmpGroupNode *node = NULL;
node = g_object_new (AMP_TYPE_GROUP_NODE, NULL);
node->base.file = g_object_ref (file);
+ node->base.name = g_strdup (name);
node->dist_only = dist_only;
memset (node->tokens, 0, sizeof (node->tokens));
@@ -531,12 +532,9 @@ amp_group_node_new (GFile *file, gboolean dist_only)
}
AmpGroupNode*
-amp_group_node_new_valid (GFile *file, gboolean dist_only, GError **error)
+amp_group_node_new_valid (GFile *file, const gchar *name, gboolean dist_only, GError **error)
{
- gchar *name;
-
/* Validate group name */
- name = g_file_get_basename (file);
if (!name || strlen (name) <= 0)
{
g_free (name);
@@ -548,20 +546,19 @@ amp_group_node_new_valid (GFile *file, gboolean dist_only, GError **error)
gboolean failed = FALSE;
const gchar *ptr = name;
while (*ptr) {
- if (!isalnum (*ptr) && (strchr ("#$:%+,- = ^_`~", *ptr) == NULL))
+ if (!isalnum (*ptr) && (strchr ("#$:%+,- = ^_`~/", *ptr) == NULL))
failed = TRUE;
ptr++;
}
if (failed) {
g_free (name);
error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Group name can only contain alphanumeric or \"#$:%+,- = ^_`~\" characters"));
+ _("Group name can only contain alphanumeric or \"#$:%+,- = ^_`~/\" characters"));
return NULL;
}
}
- g_free (name);
- return amp_group_node_new (file, dist_only);
+ return amp_group_node_new (file, name, dist_only);
}
void
diff --git a/plugins/am-project/amp-group.h b/plugins/am-project/amp-group.h
index 4b46d2c..bc86469 100644
--- a/plugins/am-project/amp-group.h
+++ b/plugins/am-project/amp-group.h
@@ -87,8 +87,8 @@ gchar *amp_group_node_get_makefile_name (AmpGroupNode *group);
gboolean amp_group_node_update_makefile (AmpGroupNode *group, AnjutaToken *token);
void amp_group_node_update_variable (AmpGroupNode *group, AnjutaToken *variable);
AnjutaToken* amp_group_node_get_variable_token (AmpGroupNode *group, const gchar *name);
-AmpGroupNode* amp_group_node_new_valid (GFile *file, gboolean dist_only, GError **error);
-AmpGroupNode* amp_group_node_new (GFile *file, gboolean dist_only);
+AmpGroupNode* amp_group_node_new_valid (GFile *file, const gchar *name, gboolean dist_only, GError **error);
+AmpGroupNode* amp_group_node_new (GFile *file, const gchar *name, gboolean dist_only);
void amp_group_node_free (AmpGroupNode *node);
void amp_group_node_update_node (AmpGroupNode *node, AmpGroupNode *new_node);
gboolean amp_group_node_set_file (AmpGroupNode *group, GFile *new_file);
diff --git a/plugins/am-project/amp-node.c b/plugins/am-project/amp-node.c
index 7827010..67af6ac 100644
--- a/plugins/am-project/amp-node.c
+++ b/plugins/am-project/amp-node.c
@@ -99,7 +99,7 @@ amp_node_new_valid(AnjutaProjectNode *parent, AnjutaProjectNodeType type, GFile
/* We can create group named . to create a root node in an empty project */
if (!g_file_equal (anjuta_project_node_get_file (parent), file))
{
- node = ANJUTA_PROJECT_NODE (amp_group_node_new_valid (file, FALSE, error));
+ node = ANJUTA_PROJECT_NODE (amp_group_node_new_valid (file, name, FALSE, error));
if (node != NULL) node->type = type;
}
else
diff --git a/plugins/am-project/amp-root.c b/plugins/am-project/amp-root.c
index 93e49fc..2ef885f 100644
--- a/plugins/am-project/amp-root.c
+++ b/plugins/am-project/amp-root.c
@@ -60,13 +60,25 @@ amp_root_node_set_file (AmpRootNode *root, GFile *new_file)
AnjutaProjectNode*
amp_root_node_new (GFile *file)
{
- return (AnjutaProjectNode *)amp_group_node_new (file, FALSE);
+ gchar *name = g_file_get_basename (file);
+ AnjutaProjectNode *node;
+
+ node = (AnjutaProjectNode *)amp_group_node_new (file, name, FALSE);
+ g_free (name);
+
+ return node;
}
AnjutaProjectNode*
amp_root_node_new_valid (GFile *file, GError **error)
{
- return (AnjutaProjectNode *)amp_group_node_new_valid (file, FALSE, error);
+ gchar *name = g_file_get_basename (file);
+ AnjutaProjectNode *node;
+
+ node = (AnjutaProjectNode *)amp_group_node_new_valid (file, name, FALSE, error);
+ g_free (name);
+
+ return node;
}
void
diff --git a/plugins/am-project/tests/empty.at b/plugins/am-project/tests/empty.at
index b9f1497..c26541c 100644
--- a/plugins/am-project/tests/empty.at
+++ b/plugins/am-project/tests/empty.at
@@ -76,4 +76,23 @@ AT_CHECK([diff output expect])
+AT_DATA([expect],
+[[ROOT (): empty7
+ GROUP (): subdir/group1
+ SOURCE (): subdir/group1/Makefile.am
+ SOURCE (): configure.ac
+ SOURCE (): Makefile.am
+]])
+AT_PARSER_CHECK([load empty6 \
+ move empty7 \
+ add group 0 subdir/group1 \
+ save \
+ list])
+AT_CHECK([diff output expect])
+AT_PARSER_CHECK([load empty7 \
+ list])
+AT_CHECK([diff output expect])
+
+
+
AT_CLEANUP
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]