Don't hide directories matching hidden file extensions e.g. foo.o.
Refactor with check_object(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5663 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
e6c579c624
commit
07fed6de1e
@ -9,6 +9,9 @@
|
|||||||
* plugins/filebrowser.c:
|
* plugins/filebrowser.c:
|
||||||
Fix optimization for filter check when pattern is '*'.
|
Fix optimization for filter check when pattern is '*'.
|
||||||
Use foreach_strv() instead of foreach_c_array().
|
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>
|
2011-03-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||||
|
@ -122,12 +122,8 @@ static gboolean win32_check_hidden(const gchar *filename)
|
|||||||
/* Returns: whether name should be hidden. */
|
/* Returns: whether name should be hidden. */
|
||||||
static gboolean check_hidden(const gchar *filename, const gchar *base_name)
|
static gboolean check_hidden(const gchar *filename, const gchar *base_name)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
gsize len;
|
gsize len;
|
||||||
|
|
||||||
if (G_UNLIKELY(! NZV(base_name)))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
if (win32_check_hidden(filename))
|
if (win32_check_hidden(filename))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -137,24 +133,25 @@ static gboolean check_hidden(const gchar *filename, const gchar *base_name)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
len = strlen(base_name);
|
len = strlen(base_name);
|
||||||
if (base_name[len - 1] == '~')
|
return base_name[len - 1] == '~';
|
||||||
return TRUE;
|
}
|
||||||
|
|
||||||
if (hide_object_files)
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
gchar **ptr;
|
if (g_str_has_suffix(base_name, *ptr))
|
||||||
gchar **exts = g_strsplit(hidden_file_extensions, " ", -1);
|
|
||||||
|
|
||||||
foreach_strv(ptr, exts)
|
|
||||||
{
|
{
|
||||||
if (g_str_has_suffix(base_name, *ptr))
|
ret = TRUE;
|
||||||
{
|
break;
|
||||||
ret = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g_strfreev(exts);
|
|
||||||
}
|
}
|
||||||
|
g_strfreev(exts);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +183,10 @@ static void add_item(const gchar *name)
|
|||||||
const gchar *sep;
|
const gchar *sep;
|
||||||
gboolean dir;
|
gboolean dir;
|
||||||
|
|
||||||
|
if (G_UNLIKELY(! NZV(name)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* root directory doesn't need separator */
|
||||||
sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S;
|
sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S;
|
||||||
fname = g_strconcat(current_dir, sep, name, NULL);
|
fname = g_strconcat(current_dir, sep, name, NULL);
|
||||||
dir = g_file_test(fname, G_FILE_TEST_IS_DIR);
|
dir = g_file_test(fname, G_FILE_TEST_IS_DIR);
|
||||||
@ -193,12 +194,8 @@ static void add_item(const gchar *name)
|
|||||||
utf8_name = utils_get_utf8_from_locale(name);
|
utf8_name = utils_get_utf8_from_locale(name);
|
||||||
g_free(fname);
|
g_free(fname);
|
||||||
|
|
||||||
if (! show_hidden_files && check_hidden(utf8_fullname, name))
|
if (! show_hidden_files && check_hidden(utf8_fullname, utf8_name))
|
||||||
{
|
goto done;
|
||||||
g_free(utf8_name);
|
|
||||||
g_free(utf8_fullname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dir)
|
if (dir)
|
||||||
{
|
{
|
||||||
@ -213,12 +210,11 @@ static void add_item(const gchar *name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (! show_hidden_files && hide_object_files && check_object(utf8_name))
|
||||||
|
goto done;
|
||||||
if (check_filtered(utf8_name))
|
if (check_filtered(utf8_name))
|
||||||
{
|
goto done;
|
||||||
g_free(utf8_name);
|
|
||||||
g_free(utf8_fullname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gtk_list_store_append(file_store, &iter);
|
gtk_list_store_append(file_store, &iter);
|
||||||
}
|
}
|
||||||
gtk_list_store_set(file_store, &iter,
|
gtk_list_store_set(file_store, &iter,
|
||||||
@ -226,6 +222,7 @@ static void add_item(const gchar *name)
|
|||||||
FILEVIEW_COLUMN_NAME, utf8_name,
|
FILEVIEW_COLUMN_NAME, utf8_name,
|
||||||
FILEVIEW_COLUMN_FILENAME, utf8_fullname,
|
FILEVIEW_COLUMN_FILENAME, utf8_fullname,
|
||||||
-1);
|
-1);
|
||||||
|
done:
|
||||||
g_free(utf8_name);
|
g_free(utf8_name);
|
||||||
g_free(utf8_fullname);
|
g_free(utf8_fullname);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user