[anjuta/newproject: 114/114] pm: Display package and module in project tree view
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject: 114/114] pm: Display package and module in project tree view
- Date: Wed, 17 Mar 2010 21:21:30 +0000 (UTC)
commit 45091c45abf09bfca49ed4391d01f969cdbad3b5
Author: Sébastien Granjoux <seb sfo free fr>
Date: Wed Mar 17 22:16:05 2010 +0100
pm: Display package and module in project tree view
libanjuta/anjuta-project.c | 12 +-
libanjuta/anjuta-project.h | 2 +
plugins/am-project/am-project-private.h | 10 --
plugins/am-project/am-project.c | 181 +++++++++++++++++----------
plugins/am-project/am-project.h | 3 +-
plugins/am-project/am-properties.c | 12 ++
plugins/am-project/am-properties.h | 2 +
plugins/dir-project/dir-project.c | 36 +++---
plugins/dir-project/dir-project.h | 6 +-
plugins/project-manager/gbf-project-model.c | 64 +++++++++-
plugins/project-manager/gbf-project-util.c | 14 +-
plugins/project-manager/gbf-project-util.h | 6 +-
plugins/project-manager/gbf-project-view.h | 4 +-
plugins/project-manager/gbf-tree-data.c | 47 ++++++--
plugins/project-manager/gbf-tree-data.h | 10 +-
plugins/project-manager/plugin.c | 18 ++--
16 files changed, 282 insertions(+), 145 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 5f11b3b..9710607 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -314,10 +314,12 @@ anjuta_project_node_get_name (const AnjutaProjectNode *node)
{
case ANJUTA_PROJECT_GROUP:
return g_file_get_basename (NODE_DATA (node)->file);
- case ANJUTA_PROJECT_TARGET:
- return g_strdup (NODE_DATA (node)->name);
case ANJUTA_PROJECT_SOURCE:
return g_file_get_basename (NODE_DATA (node)->file);
+ case ANJUTA_PROJECT_TARGET:
+ case ANJUTA_PROJECT_MODULE:
+ case ANJUTA_PROJECT_PACKAGE:
+ return g_strdup (NODE_DATA (node)->name);
default:
return NULL;
}
@@ -360,14 +362,14 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
switch (NODE_DATA (node)->type)
{
- case ANJUTA_PROJECT_GROUP:
- file = g_object_ref (NODE_DATA (node)->file);
- break;
case ANJUTA_PROJECT_TARGET:
parent = anjuta_project_node_parent (node);
file = g_file_get_child (anjuta_project_group_get_directory (parent), anjuta_project_target_get_name (node));
break;
+ case ANJUTA_PROJECT_GROUP:
case ANJUTA_PROJECT_SOURCE:
+ case ANJUTA_PROJECT_MODULE:
+ case ANJUTA_PROJECT_PACKAGE:
file = g_object_ref (NODE_DATA (node)->file);
break;
default:
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 6998495..7e05543 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -35,6 +35,8 @@ typedef enum
ANJUTA_PROJECT_GROUP,
ANJUTA_PROJECT_TARGET,
ANJUTA_PROJECT_SOURCE,
+ ANJUTA_PROJECT_MODULE,
+ ANJUTA_PROJECT_PACKAGE,
ANJUTA_PROJECT_VARIABLE
} AnjutaProjectNodeType;
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 0bf2375..0fb893f 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -26,16 +26,6 @@
G_BEGIN_DECLS
-struct _AmpPackage {
- gchar *name;
- gchar *version;
-};
-
-struct _AmpModule {
- GList *packages;
- AnjutaToken *module;
-};
-
#if 0
struct _AmpProperty {
AnjutaToken *ac_init; /* AC_INIT macro */
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 0b345d8..07ead8d 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -67,14 +67,16 @@ static const gchar *valid_am_makefiles[] = {"GNUmakefile.am", "makefile.am", "Ma
#define AMP_GROUP_DATA(node) ((node) != NULL ? (AmpGroupData *)((node)->data) : NULL)
#define AMP_TARGET_DATA(node) ((node) != NULL ? (AmpTargetData *)((node)->data) : NULL)
#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 STR_REPLACE(target, source) \
{ g_free (target); target = source == NULL ? NULL : g_strdup (source);}
-typedef struct _AmpPackage AmpPackage;
+/*typedef struct _AmpPackage AmpPackage;
-typedef struct _AmpModule AmpModule;
+typedef struct _AmpModule AmpModule;*/
typedef enum {
AM_GROUP_TOKEN_CONFIGURE,
@@ -123,6 +125,20 @@ struct _AmpSourceData {
AnjutaToken* token;
};
+typedef struct _AmpModuleData AmpModuleData;
+
+struct _AmpModuleData {
+ AnjutaProjectNodeData base;
+ AnjutaToken *module;
+};
+
+typedef struct _AmpPackageData AmpPackageData;
+
+struct _AmpPackageData {
+ AnjutaProjectNodeData base;
+ gchar *version;
+};
+
typedef struct _AmpConfigFile AmpConfigFile;
struct _AmpConfigFile {
@@ -553,8 +569,10 @@ amp_config_file_free (AmpConfigFile *config)
*---------------------------------------------------------------------------*/
static void
-amp_package_set_version (AmpPackage *package, const gchar *compare, const gchar *version)
+amp_package_set_version (AmpPackage *node, const gchar *compare, const gchar *version)
{
+ AmpPackageData *package= AMP_PACKAGE_DATA (node);
+
g_return_if_fail (package != NULL);
g_return_if_fail ((version == NULL) || (compare != NULL));
@@ -565,25 +583,29 @@ amp_package_set_version (AmpPackage *package, const gchar *compare, const gchar
static AmpPackage*
amp_package_new (const gchar *name)
{
- AmpPackage *package;
+ AmpPackageData *package = NULL;
g_return_val_if_fail (name != NULL, NULL);
- package = g_slice_new0(AmpPackage);
- package->name = g_strdup (name);
+ package = g_slice_new0(AmpPackageData);
+ package->base.type = ANJUTA_PROJECT_PACKAGE;
+ package->base.properties = amp_get_package_property_list();
+ package->base.name = g_strdup (name);
- return package;
+ return g_node_new (package);
}
static void
-amp_package_free (AmpPackage *package)
+amp_package_free (AmpPackage *node)
{
- if (package)
- {
- g_free (package->name);
- g_free (package->version);
- g_slice_free (AmpPackage, package);
- }
+ AmpPackageData *package = AMP_PACKAGE_DATA (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);
+
+ g_node_destroy (node);
}
/* Module objects
@@ -592,28 +614,34 @@ amp_package_free (AmpPackage *package)
static AmpModule*
amp_module_new (AnjutaToken *token)
{
- AmpModule *module;
+ AmpModuleData *module;
- module = g_slice_new0(AmpModule);
+ module = g_slice_new0(AmpModuleData);
+ module->base.type = ANJUTA_PROJECT_MODULE;
+ module->base.properties = amp_get_module_property_list();
+ module->base.name = anjuta_token_evaluate (token);
module->module = token;
- return module;
+ return g_node_new (module);
}
static void
-amp_module_free (AmpModule *module)
+amp_module_free (AmpModule *node)
{
- if (module)
- {
- g_list_foreach (module->packages, (GFunc)amp_package_free, NULL);
- g_slice_free (AmpModule, module);
- }
+ AmpModuleData *module = AMP_MODULE_DATA (node);
+
+ if (module->base.file) g_object_unref (module->base.file);
+ g_free (module->base.name);
+
+ g_slice_free (AmpModuleData, module);
+
+ g_node_destroy (node);
}
static void
amp_project_new_module_hash (AmpProject *project)
{
- project->modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)amp_module_free);
+ project->modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
static void
@@ -972,6 +1000,12 @@ foreach_node_destroy (AnjutaProjectNode *g_node,
//g_hash_table_remove (project->sources, AMP_NODE (g_node)->id);
amp_source_free (g_node);
break;
+ case ANJUTA_PROJECT_MODULE:
+ amp_module_free (g_node);
+ break;
+ case ANJUTA_PROJECT_PACKAGE:
+ amp_package_free (g_node);
+ break;
default:
g_assert_not_reached ();
break;
@@ -1030,30 +1064,27 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
}
void
-amp_project_load_module (AmpProject *project, AnjutaToken *module)
+amp_project_load_module (AmpProject *project, AnjutaToken *module_token)
{
AmpAcScanner *scanner = NULL;
- if (module != NULL)
+ if (module_token != NULL)
{
AnjutaToken *arg;
AnjutaToken *list;
AnjutaToken *item;
gchar *value;
- AmpModule *mod;
- AmpPackage *pack;
+ AmpModule *module;
+ AmpPackage *package;
gchar *compare;
- //fprintf(stdout, "Load module\n");
- //anjuta_token_dump (module);
-
/* Module name */
- arg = anjuta_token_first_item (module);
+ arg = anjuta_token_first_item (module_token);
value = anjuta_token_evaluate (arg);
- mod = amp_module_new (arg);
- mod->packages = NULL;
- g_hash_table_insert (project->modules, value, mod);
+ module = amp_module_new (arg);
+ anjuta_project_node_append (project->root_node, module);
+ if (value != NULL) g_hash_table_insert (project->modules, value, module);
/* Package list */
arg = anjuta_token_next_word (arg);
@@ -1064,7 +1095,7 @@ amp_project_load_module (AmpProject *project, AnjutaToken *module)
anjuta_token_prepend_items (arg, list);
amp_ac_scanner_free (scanner);
- pack = NULL;
+ package = NULL;
compare = NULL;
for (item = anjuta_token_first_word (arg); item != NULL; item = anjuta_token_next_word (item))
{
@@ -1075,34 +1106,27 @@ amp_project_load_module (AmpProject *project, AnjutaToken *module)
g_free (value);
continue;
}
- if (strcmp (value, "$VTE_NEW_REQUIRED") == 0)
- {
- int i = 0;
- i++;
- i++;
- }
- if ((pack != NULL) && (compare != NULL))
+ if ((package != NULL) && (compare != NULL))
{
- amp_package_set_version (pack, compare, value);
+ amp_package_set_version (package, compare, value);
g_free (value);
g_free (compare);
- pack = NULL;
+ package = NULL;
compare = NULL;
}
- else if ((pack != NULL) && (anjuta_token_get_type (item) == ANJUTA_TOKEN_OPERATOR))
+ else if ((package != NULL) && (anjuta_token_get_type (item) == ANJUTA_TOKEN_OPERATOR))
{
compare = value;
}
else
{
- pack = amp_package_new (value);
- mod->packages = g_list_prepend (mod->packages, pack);
+ package = amp_package_new (value);
+ anjuta_project_node_append (module, package);
g_free (value);
compare = NULL;
}
}
- mod->packages = g_list_reverse (mod->packages);
}
}
@@ -1546,7 +1570,6 @@ project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTo
name = anjuta_token_evaluate (token);
value = anjuta_token_evaluate (list);
- //g_message ("group_name %s", name);
prop = amp_property_new (name, type, 0, value, list);
amp_node_property_add (parent, prop);
@@ -1619,15 +1642,15 @@ project_load_makefile (AmpProject *project, GFile *file, AnjutaProjectNode *pare
GFile *makefile = NULL;
/* Create group */
- group = amp_group_new (file, dist_only);
- g_hash_table_insert (project->groups, g_file_get_uri (file), group);
- if (parent == NULL)
+ if (parent != NULL)
{
- project->root_node = group;
+ group = amp_group_new (file, dist_only);
+ g_hash_table_insert (project->groups, g_file_get_uri (file), group);
+ anjuta_project_node_append (parent, group);
}
else
{
- anjuta_project_node_append (parent, group);
+ group = project->root_node;
}
/* Find makefile name
@@ -1781,6 +1804,10 @@ amp_project_reload (AmpProject *project, GError **error)
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);
@@ -2499,33 +2526,53 @@ amp_project_remove_source (AmpProject *project,
GList *
amp_project_get_config_modules (AmpProject *project, GError **error)
{
- return project->modules == NULL ? NULL : g_hash_table_get_keys (project->modules);
+ AmpModule *module;
+ GList *modules = NULL;
+
+ g_return_val_if_fail (project != NULL, NULL);
+ g_return_val_if_fail (module != NULL, NULL);
+
+ for (module = anjuta_project_node_first_child (project->root_node); module != NULL; module = anjuta_project_node_next_sibling (module))
+ {
+ if (anjuta_project_node_get_type(module) == ANJUTA_PROJECT_MODULE)
+ {
+ modules = g_list_prepend (modules, anjuta_project_node_get_name (module));
+ }
+ }
+ modules = g_list_reverse (modules);
+
+ return modules;
}
GList *
amp_project_get_config_packages (AmpProject *project,
- const gchar* module,
+ const gchar* module_name,
GError **error)
{
- AmpModule *mod;
+ AmpModule *module;
GList *packages = NULL;
g_return_val_if_fail (project != NULL, NULL);
g_return_val_if_fail (module != NULL, NULL);
-
- mod = g_hash_table_lookup (project->modules, module);
-
- if (mod != NULL)
+
+ for (module = anjuta_project_node_first_child (project->root_node); module != NULL; module = anjuta_project_node_next_sibling (module))
{
- GList *node;
+ gchar *name = anjuta_project_node_get_name (module);
- for (node = mod->packages; node != NULL; node = g_list_next (node))
+ if ((anjuta_project_node_get_type(module) == ANJUTA_PROJECT_MODULE) && (strcmp (name, module_name) == 0))
{
- packages = g_list_prepend (packages, ((AmpPackage *)node->data)->name);
- }
+ AmpPackage *package;
- packages = g_list_reverse (packages);
+ for (package = anjuta_project_node_first_child (module); package != NULL; package = anjuta_project_node_next_sibling (package))
+ {
+ if (anjuta_project_node_get_type (package) == ANJUTA_PROJECT_PACKAGE)
+ {
+ packages = g_list_prepend (packages, anjuta_project_node_get_name (package));
+ }
+ }
+ }
}
+ packages = g_list_reverse (packages);
return packages;
}
diff --git a/plugins/am-project/am-project.h b/plugins/am-project/am-project.h
index 8667d9c..54fe4d3 100644
--- a/plugins/am-project/am-project.h
+++ b/plugins/am-project/am-project.h
@@ -52,6 +52,8 @@ struct _AmpProjectClass {
typedef AnjutaProjectNode AmpGroup;
typedef AnjutaProjectNode AmpTarget;
typedef AnjutaProjectNode AmpSource;
+typedef AnjutaProjectNode AmpModule;
+typedef AnjutaProjectNode AmpPackage;
typedef struct _AmpProperty AmpProperty;
typedef enum {
@@ -112,7 +114,6 @@ AmpSource* amp_project_add_source (AmpProject *project, AmpTarget *parent, GFil
AmpSource* amp_project_add_sibling_source (AmpProject *project, AmpTarget *parent, GFile *file, gboolean after, AmpSource *sibling, GError **error);
void amp_project_remove_source (AmpProject *project, AmpSource *source, GError **error);
-
GList *amp_project_get_config_modules (AmpProject *project, GError **error);
GList *amp_project_get_config_packages (AmpProject *project, const gchar* module, GError **error);
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 8e9fe85..829b579 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -288,3 +288,15 @@ amp_get_source_property_list (void)
{
return NULL;
}
+
+GList*
+amp_get_module_property_list (void)
+{
+ return NULL;
+}
+
+GList*
+amp_get_package_property_list (void)
+{
+ return NULL;
+}
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
index 702e552..fa2187c 100644
--- a/plugins/am-project/am-properties.h
+++ b/plugins/am-project/am-properties.h
@@ -39,6 +39,8 @@ GList* amp_get_project_property_list (void);
GList* amp_get_group_property_list (void);
GList* amp_get_target_property_list (AnjutaProjectTargetType type);
GList* amp_get_source_property_list (void);
+GList* amp_get_module_property_list (void);
+GList* amp_get_package_property_list (void);
G_END_DECLS
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index b618bd2..62e5598 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -49,7 +49,7 @@ struct _DirProject {
GFile *root_file;
- AnjutaProjectGroup *root_node;
+ AnjutaProjectNode *root_node;
/* shortcut hash tables, mapping id -> GNode from the tree above */
GHashTable *groups;
@@ -71,19 +71,19 @@ struct _DirProject {
typedef struct _DirGroupData DirGroupData;
struct _DirGroupData {
- AnjutaProjectGroupData base;
+ AnjutaProjectNodeData base;
};
typedef struct _DirTargetData DirTargetData;
struct _DirTargetData {
- AnjutaProjectTargetData base;
+ AnjutaProjectNodeData base;
};
typedef struct _DirSourceData DirSourceData;
struct _DirSourceData {
- AnjutaProjectSourceData base;
+ AnjutaProjectNodeData base;
};
/* A file or directory name part of a path */
@@ -214,7 +214,7 @@ group_hash_foreach_monitor (gpointer key,
DirGroup *group_node = value;
DirProject *project = user_data;
- monitor_add (project, DIR_GROUP_DATA(group_node)->base.directory);
+ monitor_add (project, DIR_GROUP_DATA(group_node)->base.file);
}
static void
@@ -242,8 +242,8 @@ dir_group_new (GFile *file)
g_return_val_if_fail (file != NULL, NULL);
group = g_slice_new0(DirGroupData);
- group->base.node.type = ANJUTA_PROJECT_GROUP;
- group->base.directory = g_object_ref (file);
+ group->base.type = ANJUTA_PROJECT_GROUP;
+ group->base.file = g_object_ref (file);
return g_node_new (group);
}
@@ -253,7 +253,7 @@ dir_group_free (DirGroup *node)
{
DirGroupData *group = (DirGroupData *)node->data;
- if (group->base.directory) g_object_unref (group->base.directory);
+ if (group->base.file) g_object_unref (group->base.file);
g_slice_free (DirGroupData, group);
g_node_destroy (node);
@@ -282,7 +282,7 @@ dir_source_new (GFile *file)
DirSourceData *source = NULL;
source = g_slice_new0(DirSourceData);
- source->base.node.type = ANJUTA_PROJECT_SOURCE;
+ source->base.type = ANJUTA_PROJECT_SOURCE;
source->base.file = g_object_ref (file);
return g_node_new (source);
@@ -616,7 +616,7 @@ dir_project_list_directory (DirProject *project, DirGroup* parent, GError **erro
gboolean ok;
GFileEnumerator *enumerator;
- enumerator = g_file_enumerate_children (DIR_GROUP_DATA (parent)->base.directory,
+ enumerator = g_file_enumerate_children (DIR_GROUP_DATA (parent)->base.file,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL,
@@ -633,7 +633,7 @@ dir_project_list_directory (DirProject *project, DirGroup* parent, GError **erro
GFile *file;
name = g_file_info_get_name (info);
- file = g_file_get_child (DIR_GROUP_DATA (parent)->base.directory, name);
+ file = g_file_get_child (DIR_GROUP_DATA (parent)->base.file, name);
g_object_unref (info);
/* Check if file is a source */
@@ -824,20 +824,20 @@ dir_project_new (void)
/* Implement IAnjutaProject
*---------------------------------------------------------------------------*/
-static AnjutaProjectGroup*
-iproject_add_group (IAnjutaProject *obj, AnjutaProjectGroup *parent, const gchar *name, GError **err)
+static AnjutaProjectNode*
+iproject_add_group (IAnjutaProject *obj, AnjutaProjectNode *parent, const gchar *name, GError **err)
{
return dir_project_add_group (DIR_PROJECT (obj), parent, name, err);
}
-static AnjutaProjectSource*
-iproject_add_source (IAnjutaProject *obj, AnjutaProjectGroup *parent, GFile *file, GError **err)
+static AnjutaProjectNode*
+iproject_add_source (IAnjutaProject *obj, AnjutaProjectNode *parent, GFile *file, GError **err)
{
return dir_project_add_source (DIR_PROJECT (obj), parent, file, err);
}
-static AnjutaProjectTarget*
-iproject_add_target (IAnjutaProject *obj, AnjutaProjectGroup *parent, const gchar *name, AnjutaProjectTargetType type, GError **err)
+static AnjutaProjectNode*
+iproject_add_target (IAnjutaProject *obj, AnjutaProjectNode *parent, const gchar *name, AnjutaProjectTargetType type, GError **err)
{
return dir_project_add_target (DIR_PROJECT (obj), parent, name, type, err);
}
@@ -860,7 +860,7 @@ iproject_get_packages (IAnjutaProject *obj, GError **err)
return NULL;
}
-static AnjutaProjectGroup*
+static AnjutaProjectNode*
iproject_get_root (IAnjutaProject *obj, GError **err)
{
return dir_project_get_root (DIR_PROJECT (obj));
diff --git a/plugins/dir-project/dir-project.h b/plugins/dir-project/dir-project.h
index b7202df..86b2e62 100644
--- a/plugins/dir-project/dir-project.h
+++ b/plugins/dir-project/dir-project.h
@@ -46,9 +46,9 @@ struct _DirProjectClass {
GObjectClass parent_class;
};
-typedef AnjutaProjectGroup DirGroup;
-typedef AnjutaProjectTarget DirTarget;
-typedef AnjutaProjectSource DirSource;
+typedef AnjutaProjectNode DirGroup;
+typedef AnjutaProjectNode DirTarget;
+typedef AnjutaProjectNode DirSource;
GType dir_project_get_type (void);
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index f3ec7a9..3cff8ea 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -351,10 +351,7 @@ default_sort_func (GtkTreeModel *model,
} else {
/* assume a->b and check for the opposite cases */
retval = -1;
- if (data_a->type == GBF_TREE_NODE_TARGET &&
- data_b->type == GBF_TREE_NODE_GROUP) {
- retval = 1;
- }
+ retval = data_a->type < data_b->type ? -1 : 1;
}
return retval;
@@ -363,7 +360,7 @@ default_sort_func (GtkTreeModel *model,
static void
add_source (GbfProjectModel *model,
- AnjutaProjectSource *source,
+ AnjutaProjectNode *source,
GtkTreeIter *parent)
{
GtkTreeIter iter;
@@ -491,8 +488,51 @@ move_target_shortcut (GbfProjectModel *model,
}
static void
+add_package (GbfProjectModel *model,
+ AnjutaProjectNode *package,
+ GtkTreeIter *parent)
+{
+ GtkTreeIter iter;
+ GbfTreeData *data;
+
+ if ((!package) || (anjuta_project_node_get_type (package) != ANJUTA_PROJECT_PACKAGE))
+ return;
+
+ data = gbf_tree_data_new_package (package);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ GBF_PROJECT_MODEL_COLUMN_DATA, data,
+ -1);
+}
+
+static void
+add_module (GbfProjectModel *model,
+ AnjutaProjectNode *module,
+ GtkTreeIter *parent)
+{
+ AnjutaProjectNode *l;
+ GtkTreeIter iter;
+ GbfTreeData *data;
+
+ if ((!module) || (anjuta_project_node_get_type (module) != ANJUTA_PROJECT_MODULE))
+ return;
+
+ data = gbf_tree_data_new_package (module);
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ GBF_PROJECT_MODEL_COLUMN_DATA, data,
+ -1);
+
+ /* add package */
+ for (l = anjuta_project_node_first_child (module); l; l = anjuta_project_node_next_sibling (l))
+ {
+ add_package (model, l, &iter);
+ }
+}
+
+static void
add_target (GbfProjectModel *model,
- AnjutaProjectTarget *target,
+ AnjutaProjectNode *target,
GtkTreeIter *parent)
{
AnjutaProjectNode *l;
@@ -535,7 +575,7 @@ add_target (GbfProjectModel *model,
static void
add_target_group (GbfProjectModel *model,
- AnjutaProjectGroup *group,
+ AnjutaProjectNode *group,
GtkTreeIter *parent)
{
GtkTreeIter iter;
@@ -565,6 +605,10 @@ 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);
@@ -640,6 +684,12 @@ update_tree (GbfProjectModel *model, AnjutaProjectNode *parent, GtkTreeIter *ite
case ANJUTA_PROJECT_SOURCE:
add_source (model, node->data, iter);
break;
+ case ANJUTA_PROJECT_MODULE:
+ add_module (model, node->data, iter);
+ break;
+ case ANJUTA_PROJECT_PACKAGE:
+ add_package (model, node->data, iter);
+ break;
default:
break;
}
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index 078f092..c54f8e6 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -160,7 +160,7 @@ entry_changed_cb (GtkEditable *editable, gpointer user_data)
g_free (text);
}
-AnjutaProjectGroup*
+AnjutaProjectNode*
gbf_project_util_new_group (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_group,
@@ -172,7 +172,7 @@ gbf_project_util_new_group (GbfProjectModel *model,
gint response;
IAnjutaProject *project;
gboolean finished = FALSE;
- AnjutaProjectGroup *new_group = NULL;
+ AnjutaProjectNode *new_group = NULL;
g_return_val_if_fail (model != NULL, NULL);
@@ -300,7 +300,7 @@ build_types_store (IAnjutaProject *project)
return store;
}
-AnjutaProjectTarget*
+AnjutaProjectNode*
gbf_project_util_new_target (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_group,
@@ -314,7 +314,7 @@ gbf_project_util_new_target (GbfProjectModel *model,
gint response;
IAnjutaProject *project;
gboolean finished = FALSE;
- AnjutaProjectTarget *new_target = NULL;
+ AnjutaProjectNode *new_target = NULL;
g_return_val_if_fail (model != NULL, NULL);
@@ -568,7 +568,7 @@ on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpoint
gtk_widget_set_sensitive(button, FALSE);
}
-AnjutaProjectSource*
+AnjutaProjectNode*
gbf_project_util_add_source (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_target,
@@ -590,7 +590,7 @@ gbf_project_util_add_source (GbfProjectModel *model,
if (new_sources && g_list_length (new_sources))
{
- AnjutaProjectSource *new_source = new_sources->data;
+ AnjutaProjectNode *new_source = new_sources->data;
g_list_free (new_sources);
return new_source;
}
@@ -711,7 +711,7 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
do
{
GError *err = NULL;
- AnjutaProjectSource* new_source;
+ AnjutaProjectNode* new_source;
gchar* uri;
GFile* source_file;
diff --git a/plugins/project-manager/gbf-project-util.h b/plugins/project-manager/gbf-project-util.h
index bb929b9..9b864ba 100644
--- a/plugins/project-manager/gbf-project-util.h
+++ b/plugins/project-manager/gbf-project-util.h
@@ -30,17 +30,17 @@
G_BEGIN_DECLS
-AnjutaProjectGroup* gbf_project_util_new_group (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_new_group (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_group_name_to_add);
-AnjutaProjectTarget* gbf_project_util_new_target (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_new_target (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_target_name_to_add);
-AnjutaProjectSource* gbf_project_util_add_source (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_add_source (GbfProjectModel *model,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_uri_to_add);
diff --git a/plugins/project-manager/gbf-project-view.h b/plugins/project-manager/gbf-project-view.h
index 855a860..a36e2da 100644
--- a/plugins/project-manager/gbf-project-view.h
+++ b/plugins/project-manager/gbf-project-view.h
@@ -53,9 +53,9 @@ struct _GbfProjectViewClass {
const char *uri);
void (* target_selected) (GbfProjectView *project_view,
- AnjutaProjectTarget *target);
+ AnjutaProjectNode *target);
void (* group_selected) (GbfProjectView *project_view,
- AnjutaProjectGroup *group);
+ AnjutaProjectNode *group);
};
GType gbf_project_view_get_type (void);
diff --git a/plugins/project-manager/gbf-tree-data.c b/plugins/project-manager/gbf-tree-data.c
index bc5a864..784985f 100644
--- a/plugins/project-manager/gbf-tree-data.c
+++ b/plugins/project-manager/gbf-tree-data.c
@@ -59,9 +59,9 @@ gbf_tree_data_get_node (GbfTreeData *data, IAnjutaProject *project)
if (data != NULL)
{
- AnjutaProjectGroup *root = NULL;
- AnjutaProjectGroup *group = NULL;
- AnjutaProjectTarget *target = NULL;
+ AnjutaProjectNode *root = NULL;
+ AnjutaProjectNode *group = NULL;
+ AnjutaProjectNode *target = NULL;
root = ianjuta_project_get_root (project, NULL);
if ((root != NULL) && (data->group != NULL))
@@ -329,6 +329,10 @@ gbf_tree_data_new_for_file (GFile *file, GbfTreeNodeType type)
data->name = g_file_get_parse_name (file);
file = NULL;
break;
+ case GBF_TREE_NODE_MODULE:
+ case GBF_TREE_NODE_PACKAGE:
+ g_slice_free (GbfTreeData, data);
+ return NULL;
}
if (file != NULL)
@@ -380,7 +384,7 @@ gbf_tree_data_new_shortcut (GbfTreeData *src)
}
GbfTreeData *
-gbf_tree_data_new_group (AnjutaProjectGroup *group)
+gbf_tree_data_new_group (AnjutaProjectNode *group)
{
GbfTreeData *data = g_slice_new0 (GbfTreeData);
GFileInfo *ginfo;
@@ -407,15 +411,15 @@ gbf_tree_data_new_group (AnjutaProjectGroup *group)
}
GbfTreeData *
-gbf_tree_data_new_target (AnjutaProjectTarget *target)
+gbf_tree_data_new_target (AnjutaProjectNode *target)
{
GbfTreeData *data = g_slice_new0 (GbfTreeData);
- AnjutaProjectGroup *group;
+ AnjutaProjectNode *group;
data->type = GBF_TREE_NODE_TARGET;
data->name = g_strdup (anjuta_project_target_get_name (target));
- group = (AnjutaProjectGroup *)anjuta_project_node_parent (target);
+ group = anjuta_project_node_parent (target);
data->group = g_object_ref (anjuta_project_group_get_directory (group));
data->target = g_strdup (anjuta_project_target_get_name (target));
@@ -423,7 +427,7 @@ gbf_tree_data_new_target (AnjutaProjectTarget *target)
}
GbfTreeData *
-gbf_tree_data_new_source (AnjutaProjectSource *source)
+gbf_tree_data_new_source (AnjutaProjectNode *source)
{
GbfTreeData *data = g_slice_new0 (GbfTreeData);
GFileInfo *ginfo;
@@ -454,9 +458,9 @@ gbf_tree_data_new_source (AnjutaProjectSource *source)
}
else
{
- AnjutaProjectGroup *group;
+ AnjutaProjectNode *group;
- group = (AnjutaProjectGroup *)anjuta_project_node_parent (parent);
+ group = anjuta_project_node_parent (parent);
data->group = g_object_ref (anjuta_project_group_get_directory (group));
data->target = g_strdup (anjuta_project_target_get_name (parent));
}
@@ -464,6 +468,29 @@ gbf_tree_data_new_source (AnjutaProjectSource *source)
return data;
}
+GbfTreeData *
+gbf_tree_data_new_module (AnjutaProjectNode *module)
+{
+ GbfTreeData *data = g_slice_new0 (GbfTreeData);
+
+ data->type = GBF_TREE_NODE_MODULE;
+ data->name = g_strdup (anjuta_project_node_get_name (module));
+
+ return data;
+}
+
+GbfTreeData *
+gbf_tree_data_new_package (AnjutaProjectNode *package)
+{
+ GbfTreeData *data = g_slice_new0 (GbfTreeData);
+
+ data->type = GBF_TREE_NODE_PACKAGE;
+ data->name = g_strdup (anjuta_project_node_get_name (package));
+
+ return data;
+}
+
+
void
gbf_tree_data_free (GbfTreeData *data)
{
diff --git a/plugins/project-manager/gbf-tree-data.h b/plugins/project-manager/gbf-tree-data.h
index 0354154..0bd5d64 100644
--- a/plugins/project-manager/gbf-tree-data.h
+++ b/plugins/project-manager/gbf-tree-data.h
@@ -36,6 +36,8 @@ typedef enum {
GBF_TREE_NODE_STRING,
GBF_TREE_NODE_GROUP,
GBF_TREE_NODE_TARGET,
+ GBF_TREE_NODE_MODULE,
+ GBF_TREE_NODE_PACKAGE,
GBF_TREE_NODE_SOURCE,
GBF_TREE_NODE_SHORTCUT
} GbfTreeNodeType;
@@ -68,9 +70,11 @@ GbfTreeData *gbf_tree_data_new_for_file (GFile *file,
GbfTreeNodeType type);
GbfTreeData *gbf_tree_data_new_string (const gchar *string);
GbfTreeData *gbf_tree_data_new_shortcut (GbfTreeData *src);
-GbfTreeData *gbf_tree_data_new_group (AnjutaProjectGroup *group);
-GbfTreeData *gbf_tree_data_new_target (AnjutaProjectTarget *target);
-GbfTreeData *gbf_tree_data_new_source (AnjutaProjectSource *source);
+GbfTreeData *gbf_tree_data_new_group (AnjutaProjectNode *group);
+GbfTreeData *gbf_tree_data_new_target (AnjutaProjectNode *target);
+GbfTreeData *gbf_tree_data_new_source (AnjutaProjectNode *source);
+GbfTreeData *gbf_tree_data_new_module (AnjutaProjectNode *module);
+GbfTreeData *gbf_tree_data_new_package (AnjutaProjectNode *package);
void gbf_tree_data_free (GbfTreeData *data);
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 7128160..e682696 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -625,7 +625,7 @@ static void
on_popup_add_group (GtkAction *action, ProjectManagerPlugin *plugin)
{
GtkTreeIter selected_group;
- AnjutaProjectGroup *new_group;
+ AnjutaProjectNode *new_group;
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
@@ -640,7 +640,7 @@ static void
on_popup_add_target (GtkAction *action, ProjectManagerPlugin *plugin)
{
GtkTreeIter selected_group;
- AnjutaProjectTarget *new_target;
+ AnjutaProjectNode *new_target;
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
@@ -656,7 +656,7 @@ static void
on_popup_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
{
GtkTreeIter selected_target;
- AnjutaProjectSource *new_source;
+ AnjutaProjectNode *new_source;
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
@@ -1988,7 +1988,7 @@ iproject_manager_get_target_type (IAnjutaProjectManager *project_manager,
GError **err)
{
ProjectManagerPlugin *plugin;
- AnjutaProjectTarget *target;
+ AnjutaProjectNode *target;
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager),
ANJUTA_TARGET_UNKNOWN);
@@ -2150,7 +2150,7 @@ iproject_manager_add_source (IAnjutaProjectManager *project_manager,
ProjectManagerPlugin *plugin;
GtkTreeIter target_iter;
GtkTreeIter *iter = NULL;
- AnjutaProjectSource *source_id;
+ AnjutaProjectNode *source_id;
GFile* source;
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
@@ -2181,9 +2181,9 @@ iproject_manager_add_source_quiet (IAnjutaProjectManager *project_manager,
GError **err)
{
ProjectManagerPlugin *plugin;
- AnjutaProjectSource *source_id;
+ AnjutaProjectNode *source_id;
GFile *source_file;
- AnjutaProjectTarget *target = NULL;
+ AnjutaProjectNode *target = NULL;
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
@@ -2254,7 +2254,7 @@ iproject_manager_add_target (IAnjutaProjectManager *project_manager,
GtkTreeIter group_iter;
GtkTreeIter *iter = NULL;
GFile *target = NULL;
- AnjutaProjectTarget *target_id;
+ AnjutaProjectNode *target_id;
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
@@ -2288,7 +2288,7 @@ iproject_manager_add_group (IAnjutaProjectManager *project_manager,
GtkTreeIter group_iter;
GtkTreeIter *iter = NULL;
GFile *group = NULL;
- AnjutaProjectGroup *group_id;
+ AnjutaProjectNode *group_id;
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]