SF.net SVN: geany:[3710] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Apr 16 17:55:42 UTC 2009


Revision: 3710
          http://geany.svn.sourceforge.net/geany/?rev=3710&view=rev
Author:   eht16
Date:     2009-04-16 17:55:42 +0000 (Thu, 16 Apr 2009)

Log Message:
-----------
When a project is loaded, replace the project base path with the project name in the Documents sidebar for parent items (closes #2723679).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/project.c
    trunk/src/treeviews.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-04-16 17:55:26 UTC (rev 3709)
+++ trunk/ChangeLog	2009-04-16 17:55:42 UTC (rev 3710)
@@ -4,6 +4,10 @@
    Add some missing 'void's in function definitions.
    If the project base path is './', just use the path of the project
    config file instead of appending './'.
+ * src/treeviews.c, src/project.c:
+   When a project is loaded, replace the project base path with the
+   project name in the Documents sidebar for parent items
+   (closes #2723679).
 
 
 2009-04-15  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c	2009-04-16 17:55:26 UTC (rev 3709)
+++ trunk/src/project.c	2009-04-16 17:55:42 UTC (rev 3710)
@@ -48,6 +48,7 @@
 #include "interface.h"
 #include "editor.h"
 #include "stash.h"
+#include "treeviews.h"
 
 
 ProjectPrefs project_prefs = { NULL, FALSE, FALSE };
@@ -313,6 +314,7 @@
 {
 	ui_set_window_title(NULL);
 	build_menu_update(NULL);
+	treeviews_openfiles_update_all();
 }
 
 

Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c	2009-04-16 17:55:26 UTC (rev 3709)
+++ trunk/src/treeviews.c	2009-04-16 17:55:42 UTC (rev 3710)
@@ -39,6 +39,7 @@
 #include "ui_utils.h"
 #include "symbols.h"
 #include "navqueue.h"
+#include "project.h"
 
 #include <gdk/gdkkeysyms.h>
 
@@ -290,11 +291,34 @@
 
 static GtkTreeIter *get_doc_parent(GeanyDocument *doc)
 {
-	gchar *dirname;
+	gchar *tmp_dirname;
+	gchar *project_base_path;
+	gchar *dirname = NULL;
 	static GtkTreeIter parent;
 	GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles);
 
-	dirname = g_path_get_dirname(DOC_FILENAME(doc));
+	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);
+		const gchar *rest;
+		/* check whether the dir name starts with the project base path */
+		if (strncmp(tmp_dirname, project_base_path, len) == 0)
+		{
+			rest = tmp_dirname + len;
+			dirname = g_strdup_printf("%s%s%s",
+				app->project->name,
+				(*rest != G_DIR_SEPARATOR && *rest != '\0') ? G_DIR_SEPARATOR_S : "",
+				rest);
+		}
+		g_free(project_base_path);
+	}
+	if (dirname == NULL)
+		dirname = tmp_dirname;
+	else
+		g_free(tmp_dirname);
 
 	if (gtk_tree_model_get_iter_first(model, &parent))
 	{
@@ -776,7 +800,9 @@
 		gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc,
 			DOCUMENTS_SHORTNAME, &shortname, -1);
 	}
-	path = NZV(shortname) && g_path_is_absolute(shortname);
+	path = NZV(shortname) &&
+		(g_path_is_absolute(shortname) ||
+		(app->project && g_str_has_prefix(shortname, app->project->name)));
 
 	/* can close all, save all (except shortname), but only reload individually ATM */
 	gtk_widget_set_sensitive(doc_items.close, sel);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list