[anjuta] dir-project: Fix project view when having several level of directories
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] dir-project: Fix project view when having several level of directories
- Date: Sun, 19 Dec 2010 21:48:20 +0000 (UTC)
commit 2effac103f26e92bfcfbaec2ca03cf60fbb14511
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Dec 19 22:41:18 2010 +0100
dir-project: Fix project view when having several level of directories
libanjuta/anjuta-project.c | 27 +++++++++++++++++++++++++++
libanjuta/anjuta-project.h | 2 +-
plugins/dir-project/dir-project.c | 12 +++++++++---
plugins/project-manager/project-view.c | 29 +++++++++++++++++++++++++++--
4 files changed, 64 insertions(+), 6 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 0555a2f..4337dab 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -395,6 +395,33 @@ anjuta_project_node_check (AnjutaProjectNode *parent)
}
+static void
+anjuta_project_node_show (AnjutaProjectNode *node, gint indent)
+{
+ g_message("%*s %p: %s", indent, "", node, node != NULL ? anjuta_project_node_get_name (node) : NULL);
+}
+
+static void
+anjuta_project_node_dump_child (AnjutaProjectNode *parent, gint indent)
+{
+ AnjutaProjectNode *child;
+
+ anjuta_project_node_show (parent, indent);
+ indent += 4;
+
+ for (child = anjuta_project_node_first_child (parent); child != NULL; child = anjuta_project_node_next_sibling (child))
+ {
+ anjuta_project_node_dump_child (child, indent);
+ }
+}
+
+void
+anjuta_project_node_dump (AnjutaProjectNode *parent)
+{
+ anjuta_project_node_dump_child (parent, 0);
+}
+
+
/* Adding node functions
*---------------------------------------------------------------------------*/
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 5bbb554..2949fa1 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -179,6 +179,7 @@ AnjutaProjectNode *anjuta_project_node_traverse (AnjutaProjectNode *node, GTrave
AnjutaProjectNode *anjuta_project_node_children_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data);
void anjuta_project_node_check (AnjutaProjectNode *parent);
+void anjuta_project_node_dump (AnjutaProjectNode *parent);
AnjutaProjectNode *anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
@@ -202,7 +203,6 @@ gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProject
AnjutaProjectProperty *anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *native, AnjutaProjectProperty *property);
AnjutaProjectProperty *anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
-
AnjutaProjectNode *anjuta_project_group_get_node_from_file (const AnjutaProjectNode *root, GFile *directory);
AnjutaProjectNode *anjuta_project_target_get_node_from_name (const AnjutaProjectNode *parent, const gchar *name);
AnjutaProjectNode *anjuta_project_source_get_node_from_file (const AnjutaProjectNode *parent, GFile *file);
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index aae7611..5aee9dc 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -508,8 +508,15 @@ dir_project_load_directory_callback (GObject *source_object,
g_object_unref (remove);
}
}
- anjuta_project_node_clear_state (data->parent, ANJUTA_PROJECT_INCOMPLETE);
- g_signal_emit_by_name (data->proj, "node-loaded", data->parent, NULL);
+ if (anjuta_project_node_parent (data->parent) == data->proj->root)
+ {
+ /* Emit signal on root node instead of the first group */
+ g_signal_emit_by_name (data->proj, "node-loaded", data->proj->root, NULL);
+ }
+ else
+ {
+ g_signal_emit_by_name (data->proj, "node-loaded", data->parent, NULL);
+ }
}
g_object_unref (data->parent);
g_slice_free (DirData, data);
@@ -834,7 +841,6 @@ static gboolean
iproject_load_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
{
node = dir_project_load_node (DIR_PROJECT (obj), node, err);
- g_signal_emit_by_name (obj, "node-loaded", node, NULL);
return node != NULL;
}
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index 858f207..f7ecf05 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -848,6 +848,7 @@ gbf_project_view_update_tree (GbfProjectView *view, AnjutaProjectNode *parent, G
GtkTreeIter child;
GList *node;
GList *nodes;
+ GbfTreeData *data = NULL;
/* Get all new nodes */
nodes = gbf_project_util_all_child (parent, ANJUTA_PROJECT_UNKNOWN);
@@ -858,7 +859,7 @@ gbf_project_view_update_tree (GbfProjectView *view, AnjutaProjectNode *parent, G
gboolean valid = TRUE;
while (valid) {
- GbfTreeData *data = NULL;
+ data = NULL;
AnjutaProjectNode* data_node = NULL;
/* Look for current node */
@@ -874,7 +875,7 @@ gbf_project_view_update_tree (GbfProjectView *view, AnjutaProjectNode *parent, G
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (view->model), &child);
continue;
}
-
+
if (data->type == GBF_TREE_NODE_UNKNOWN)
{
node = g_list_find_custom (nodes, data->name, compare_node_name);
@@ -921,6 +922,7 @@ gbf_project_view_update_tree (GbfProjectView *view, AnjutaProjectNode *parent, G
gtk_tree_path_free (path);
}
}
+ data->expanded = expanded;
if (expanded)
{
filter = GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
@@ -986,6 +988,29 @@ gbf_project_view_update_tree (GbfProjectView *view, AnjutaProjectNode *parent, G
break;
}
}
+
+ /* Expand parent, needed if the parent hasn't any children when it was created */
+ if (iter != NULL)
+ {
+ /* Check parent data */
+ gtk_tree_model_get (GTK_TREE_MODEL (view->model), iter,
+ GBF_PROJECT_MODEL_COLUMN_DATA, &data,
+ -1);
+ if (data->expanded)
+ {
+ GtkTreePath *path;
+ GtkTreePath *child_path;
+ GtkTreeModelFilter *filter;
+
+ filter = GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->model), iter);
+ child_path = gtk_tree_model_filter_convert_child_path_to_path (filter, path);
+ gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), child_path);
+ gtk_tree_path_free (child_path);
+ gtk_tree_path_free (path);
+ data->expanded = FALSE;
+ }
+ }
}
/* Shorcuts functions
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]