Revision: 5663 http://geany.svn.sourceforge.net/geany/?rev=5663&view=rev Author: ntrel Date: 2011-03-31 17:58:01 +0000 (Thu, 31 Mar 2011)
Log Message: ----------- Don't hide directories matching hidden file extensions e.g. foo.o. Refactor with check_object().
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/filebrowser.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-31 17:28:03 UTC (rev 5662) +++ trunk/ChangeLog 2011-03-31 17:58:01 UTC (rev 5663) @@ -9,6 +9,9 @@ * plugins/filebrowser.c: Fix optimization for filter check when pattern is '*'. Use foreach_strv() instead of foreach_c_array(). + * plugins/filebrowser.c: + Don't hide directories matching hidden file extensions e.g. foo.o. + Refactor with check_object().
2011-03-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2011-03-31 17:28:03 UTC (rev 5662) +++ trunk/plugins/filebrowser.c 2011-03-31 17:58:01 UTC (rev 5663) @@ -122,12 +122,8 @@ /* Returns: whether name should be hidden. */ static gboolean check_hidden(const gchar *filename, const gchar *base_name) { - gboolean ret = FALSE; gsize len;
- if (G_UNLIKELY(! NZV(base_name))) - return FALSE; - #ifdef G_OS_WIN32 if (win32_check_hidden(filename)) return TRUE; @@ -137,24 +133,25 @@ #endif
len = strlen(base_name); - if (base_name[len - 1] == '~') - return TRUE; + return base_name[len - 1] == '~'; +}
- if (hide_object_files) - { - gchar **ptr; - gchar **exts = g_strsplit(hidden_file_extensions, " ", -1);
- foreach_strv(ptr, exts) +static gboolean check_object(const gchar *base_name) +{ + gboolean ret = FALSE; + gchar **ptr; + gchar **exts = g_strsplit(hidden_file_extensions, " ", -1); + + foreach_strv(ptr, exts) + { + if (g_str_has_suffix(base_name, *ptr)) { - if (g_str_has_suffix(base_name, *ptr)) - { - ret = TRUE; - break; - } + ret = TRUE; + break; } - g_strfreev(exts); } + g_strfreev(exts); return ret; }
@@ -186,6 +183,10 @@ const gchar *sep; gboolean dir;
+ if (G_UNLIKELY(! NZV(name))) + return; + + /* root directory doesn't need separator */ sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S; fname = g_strconcat(current_dir, sep, name, NULL); dir = g_file_test(fname, G_FILE_TEST_IS_DIR); @@ -193,12 +194,8 @@ utf8_name = utils_get_utf8_from_locale(name); g_free(fname);
- if (! show_hidden_files && check_hidden(utf8_fullname, name)) - { - g_free(utf8_name); - g_free(utf8_fullname); - return; - } + if (! show_hidden_files && check_hidden(utf8_fullname, utf8_name)) + goto done;
if (dir) { @@ -213,12 +210,11 @@ } else { + if (! show_hidden_files && hide_object_files && check_object(utf8_name)) + goto done; if (check_filtered(utf8_name)) - { - g_free(utf8_name); - g_free(utf8_fullname); - return; - } + goto done; + gtk_list_store_append(file_store, &iter); } gtk_list_store_set(file_store, &iter, @@ -226,6 +222,7 @@ FILEVIEW_COLUMN_NAME, utf8_name, FILEVIEW_COLUMN_FILENAME, utf8_fullname, -1); +done: g_free(utf8_name); g_free(utf8_fullname); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.