From 77183d838ef3dad95fa521d32a93967071163118 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Thu, 17 Jun 2010 12:14:48 +0000 Subject: [PATCH] Refactor get_doc_parent(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5030 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- src/sidebar.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/sidebar.c b/src/sidebar.c index 20859e3b..68d2d7a4 100644 --- a/src/sidebar.c +++ b/src/sidebar.c @@ -340,22 +340,19 @@ static gboolean find_tree_iter_dir(GtkTreeIter *iter, const gchar *dir) } -static GtkTreeIter *get_doc_parent(GeanyDocument *doc) +static gchar *get_doc_folder(GeanyDocument *doc) { gchar *tmp_dirname; gchar *project_base_path; gchar *dirname = NULL; const gchar *home_dir = g_get_home_dir(); - static GtkTreeIter parent; - GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles); const gchar *rest; - if (!documents_show_paths) - return NULL; - tmp_dirname = g_path_get_dirname(DOC_FILENAME(doc)); + /* replace the project base path with the project name */ project_base_path = project_get_base_path(); + if (project_base_path != NULL) { gsize len = strlen(project_base_path); @@ -392,6 +389,21 @@ static GtkTreeIter *get_doc_parent(GeanyDocument *doc) else g_free(tmp_dirname); + return dirname; +} + + +static GtkTreeIter *get_doc_parent(GeanyDocument *doc) +{ + gchar *dirname = NULL; + static GtkTreeIter parent; + GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles); + + if (!documents_show_paths) + return NULL; + + dirname = get_doc_folder(doc); + if (gtk_tree_model_get_iter_first(model, &parent)) { do