From 03dcfc561f9e31218bf3ea8b59af9048151ce322 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 16 Jan 2002 17:58:45 +0000 Subject: [PATCH] r1099: Allow '~' in globicons file. --- ROX-Filer/Help/Changes | 1 + ROX-Filer/Help/TODO | 2 +- ROX-Filer/src/icon.c | 27 --------------------------- ROX-Filer/src/icon.h | 1 - ROX-Filer/src/support.c | 27 +++++++++++++++++++++++++++ ROX-Filer/src/support.h | 1 + ROX-Filer/src/usericons.c | 7 ++++++- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 247473cb..8e910ff0 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -6,6 +6,7 @@ ~~~~~~~~~~~ Converter for old-format config files now stops if the file looks like XML (probably from a failed conversion). +Allow '~' in globicons file. Bugfix: When using spring-opening or following symlinks, trying to open a non-existant directory could cause a crash. diff --git a/ROX-Filer/Help/TODO b/ROX-Filer/Help/TODO index b70bdbe3..181a9d04 100644 --- a/ROX-Filer/Help/TODO +++ b/ROX-Filer/Help/TODO @@ -10,7 +10,7 @@ BUGS When files are converted to XML they are labelled as UTF-8, even though they aren't. Also, older versions of Gtk don't expect UTF-8 text. -Dragging to the Home icon in a deleted directory causes odd effects! +Using spring-opening with a missing directory has grab problems. Use doubles in find.c to cope with large files. diff --git a/ROX-Filer/src/icon.c b/ROX-Filer/src/icon.c index de6a4e42..805e9012 100644 --- a/ROX-Filer/src/icon.c +++ b/ROX-Filer/src/icon.c @@ -175,33 +175,6 @@ void icon_init(void) tooltips = gtk_tooltips_new(); } -/* Removes trailing / chars and converts a leading '~/' (if any) to - * the user's home dir. g_free() the result. - */ -guchar *icon_convert_path(guchar *path) -{ - guchar *retval; - int path_len; - - g_return_val_if_fail(path != NULL, NULL); - - path_len = strlen(path); - while (path_len > 1 && path[path_len - 1] == '/') - path_len--; - - retval = g_strndup(path, path_len); - - if (path[0] == '~' && (path[1] == '\0' || path[1] == '/')) - { - guchar *tmp = retval; - - retval = g_strconcat(home_dir, retval + 1, NULL); - g_free(tmp); - } - - return retval; -} - /* The icons_hash table allows us to convert from a path to a list * of icons that use that path. * Add this icon to the list for its path. diff --git a/ROX-Filer/src/icon.h b/ROX-Filer/src/icon.h index ed965acb..f844ad35 100644 --- a/ROX-Filer/src/icon.h +++ b/ROX-Filer/src/icon.h @@ -41,7 +41,6 @@ struct _Icon { }; void icon_init(void); -guchar *icon_convert_path(guchar *path); void icon_hash_path(Icon *icon); void icon_unhash_path(Icon *icon); gboolean icons_require(guchar *path); diff --git a/ROX-Filer/src/support.c b/ROX-Filer/src/support.c index 07924c85..c77c5bf0 100644 --- a/ROX-Filer/src/support.c +++ b/ROX-Filer/src/support.c @@ -1272,6 +1272,33 @@ char *md5_hash(char *message) } #endif /* GTK2 or THUMBS_USE_LIBPNG */ +/* Removes trailing / chars and converts a leading '~/' (if any) to + * the user's home dir. g_free() the result. + */ +gchar *icon_convert_path(gchar *path) +{ + guchar *retval; + int path_len; + + g_return_val_if_fail(path != NULL, NULL); + + path_len = strlen(path); + while (path_len > 1 && path[path_len - 1] == '/') + path_len--; + + retval = g_strndup(path, path_len); + + if (path[0] == '~' && (path[1] == '\0' || path[1] == '/')) + { + guchar *tmp = retval; + + retval = g_strconcat(home_dir, retval + 1, NULL); + g_free(tmp); + } + + return retval; +} + /**************************************************************** * INTERNAL FUNCTIONS * ****************************************************************/ diff --git a/ROX-Filer/src/support.h b/ROX-Filer/src/support.h index 0876ee29..592473d9 100644 --- a/ROX-Filer/src/support.h +++ b/ROX-Filer/src/support.h @@ -48,6 +48,7 @@ guchar *get_relative_path(guchar *from, guchar *to); int text_to_boolean(const char *text, int defvalue); void set_to_null(gpointer *data); char *readlink_dup(char *path); +gchar *icon_convert_path(gchar *path); #if defined(GTK2) || defined(THUMBS_USE_LIBPNG) char *md5_hash(char *message); diff --git a/ROX-Filer/src/usericons.c b/ROX-Filer/src/usericons.c index 6997135b..25da55cb 100644 --- a/ROX-Filer/src/usericons.c +++ b/ROX-Filer/src/usericons.c @@ -117,6 +117,8 @@ void read_globicons() /* Handle the new XML file format */ for (node = root->xmlChildrenNode; node; node = node->next) { + gchar *path; + if (node->type != XML_ELEMENT_NODE) continue; if (strcmp(node->name, "rule") != 0) @@ -128,7 +130,10 @@ void read_globicons() if (!match) continue; - g_hash_table_insert(glob_icons, match, + path = icon_convert_path(match); + g_free(match); + + g_hash_table_insert(glob_icons, path, xmlNodeGetContent(icon)); } -- 2.11.4.GIT