Replace /home/user with ~ in the documents list (patch by Jon

Strait, thanks).



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5028 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2010-06-17 12:03:00 +00:00
parent b902af6749
commit f86deb0a03
2 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2010-06-17 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/sidebar.c:
Replace /home/user with ~ in the documents list (patch by Jon
Strait, thanks).
2010-06-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/notebook.c:

View File

@ -345,8 +345,10 @@ static GtkTreeIter *get_doc_parent(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;
@ -357,7 +359,6 @@ static GtkTreeIter *get_doc_parent(GeanyDocument *doc)
if (project_base_path != NULL)
{
gsize len = strlen(project_base_path);
const gchar *rest;
if (project_base_path[len-1] == G_DIR_SEPARATOR)
project_base_path[len-1] = '\0';
@ -367,12 +368,27 @@ static GtkTreeIter *get_doc_parent(GeanyDocument *doc)
{
rest = tmp_dirname + len;
if (*rest == G_DIR_SEPARATOR || *rest == '\0')
{
dirname = g_strdup_printf("%s%s", app->project->name, rest);
}
}
g_free(project_base_path);
}
if (dirname == NULL)
{
dirname = tmp_dirname;
/* If matches home dir, replace with tilde */
if (home_dir && *home_dir != 0 && g_str_has_prefix(dirname, home_dir))
{
rest = dirname + strlen(home_dir);
if (*rest == G_DIR_SEPARATOR || *rest == '\0')
{
dirname = g_strdup_printf("~%s", rest);
g_free(tmp_dirname);
}
}
}
else
g_free(tmp_dirname);