Index: thunar/thunar-file.c =================================================================== --- thunar/thunar-file.c (révision 27451) +++ thunar/thunar-file.c (copie de travail) @@ -170,6 +170,70 @@ +gboolean +thunar_file_is_in_point_hidden_file (const ThunarFile *file) +{ + gboolean is_hidden = FALSE; + + /* get the file name */ + gchar *basename = + g_strdup (thunar_vfs_path_get_name (THUNAR_FILE ((file))->info->path)); + + /* get the name of the folder containing the file */ + gchar *parent = NULL; + + if (thunar_file_has_parent (THUNAR_FILE ((file)))) + { + parent = + thunar_vfs_path_dup_string (thunar_vfs_path_get_parent (THUNAR_FILE ((file))->info->path)); + } + else + { + ThunarVfsPath *parent_path; + + parent_path = thunar_vfs_path_get_for_root (); + parent = + thunar_vfs_path_dup_string (parent_path); + thunar_vfs_path_unref (parent_path); + } + + gchar *hidden_file = g_build_filename (parent, ".hidden", NULL); + + /* If there is a .hidden file in the parent folder, we check if the filename is + in the .hidden file. */ + if (g_file_test (hidden_file, G_FILE_TEST_IS_REGULAR)) + { + gchar *hidden_contents; + + if (g_file_get_contents (hidden_file, &hidden_contents, NULL, NULL)) + { + /* We want to find out if the filename "basename" matches one of the + lines of .hidden. To do so we get the contents of .hidden, add "\n" at + the beginning (to avoid a separate test for the first line) and proceed + to the comparison. */ + gchar *search_data = g_strconcat ("\n", hidden_contents, NULL); + basename = g_strconcat ("\n", basename, "\n", NULL); + + is_hidden = (g_strrstr (search_data, basename ) != NULL); + + g_free (search_data); + g_free (hidden_contents); + } + else + { + is_hidden = FALSE; + } + } + + g_free (hidden_file); + g_free (parent); + g_free (basename); + + return is_hidden; +} + + + #ifdef G_ENABLE_DEBUG static gboolean thunar_file_atexit_registered = FALSE; Index: thunar/thunar-file.h =================================================================== --- thunar/thunar-file.h (révision 27451) +++ thunar/thunar-file.h (copie de travail) @@ -163,6 +163,8 @@ gboolean thunar_file_is_chmodable (const ThunarFile *file); gboolean thunar_file_is_renameable (const ThunarFile *file); +gboolean thunar_file_is_in_point_hidden_file (const ThunarFile *file); + GList *thunar_file_get_emblem_names (ThunarFile *file); void thunar_file_set_emblem_names (ThunarFile *file, GList *emblem_names); @@ -437,7 +439,8 @@ * * Return value: %TRUE if @file is a hidden file, else %FALSE. **/ -#define thunar_file_is_hidden(file) ((THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_HIDDEN) != 0) +#define thunar_file_is_hidden(file) ((thunar_file_is_in_point_hidden_file (THUNAR_FILE ((file)))) \ + || ((THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_HIDDEN) != 0)) /** * thunar_file_is_home: Index: ChangeLog =================================================================== --- ChangeLog (révision 27451) +++ ChangeLog (copie de travail) @@ -1,3 +1,9 @@ +2008-08-16 Jérôme Guelfucci + + * thunar/thunar-file.{c,h}: add function to detect if a file + is in the .hidden file of the parent directory to set it as hidden. + Modify the hidden detection to use this new function. Bug #3189. + 2007-12-11 Benedikt Meurer * thunar/thunar-shortcuts-view.c, thunar/thunar-tree-view.c: