diff options
author | monsta <[email protected]> | 2017-04-18 11:50:02 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2017-04-18 11:50:02 +0300 |
commit | 21668de5806ce71ceecd7470b717412bfa3bd01c (patch) | |
tree | b575285b32d2db44b4182a902c9fe67998d48639 | |
parent | ed842baac4f438a90bd6214020d2363241171545 (diff) | |
download | caja-21668de5806ce71ceecd7470b717412bfa3bd01c.tar.bz2 caja-21668de5806ce71ceecd7470b717412bfa3bd01c.tar.xz |
don't parse .hidden files manually - GIO does it since 2.36
taken from:
https://git.gnome.org/browse/nautilus/commit/?id=ace6d2c2170028148785f3fa87eedf883f20f1dd
GIO commit for reference:
https://git.gnome.org/browse/glib/commit/?id=510ba9b4efe1813e24c6dfa7405c3547bf9efdd7
-rw-r--r-- | libcaja-private/caja-directory-async.c | 119 | ||||
-rw-r--r-- | libcaja-private/caja-directory-private.h | 6 | ||||
-rw-r--r-- | libcaja-private/caja-directory.c | 5 | ||||
-rw-r--r-- | libcaja-private/caja-file.c | 11 |
4 files changed, 2 insertions, 139 deletions
diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c index 5bab5858..d90d3e76 100644 --- a/libcaja-private/caja-directory-async.c +++ b/libcaja-private/caja-directory-async.c @@ -194,9 +194,6 @@ static GHashTable *waiting_directories; static GHashTable *async_jobs; #endif -/* Hide kde trashcan directory */ -static char *kde_trash_dir_name = NULL; - /* Forward declarations for functions that need them. */ static void deep_count_load (DeepCountState *state, GFile *location); @@ -220,13 +217,6 @@ static void move_file_to_extension_queue (CajaDirectory static void caja_directory_invalidate_file_attributes (CajaDirectory *directory, CajaFileAttributes file_attributes); -void -caja_set_kde_trash_name (const char *trash_dir) -{ - g_free (kde_trash_dir_name); - kde_trash_dir_name = g_strdup (trash_dir); -} - /* Some helpers for case-insensitive strings. * Move to caja-glib-extensions? */ @@ -930,10 +920,7 @@ should_skip_file (CajaDirectory *directory, GFileInfo *info) if (!show_hidden_files && (g_file_info_get_is_hidden (info) || - g_file_info_get_is_backup (info) || - (directory != NULL && directory->details->hidden_file_hash != NULL && - g_hash_table_lookup (directory->details->hidden_file_hash, - g_file_info_get_name (info)) != NULL))) + g_file_info_get_is_backup (info))) { return TRUE; } @@ -1178,11 +1165,6 @@ file_list_cancel (CajaDirectory *directory) g_list_free_full (directory->details->pending_file_info, g_object_unref); directory->details->pending_file_info = NULL; } - - if (directory->details->hidden_file_hash) - { - g_hash_table_remove_all (directory->details->hidden_file_hash); - } } static void @@ -2181,86 +2163,6 @@ mark_all_files_unconfirmed (CajaDirectory *directory) } static void -read_dot_hidden_file (CajaDirectory *directory) -{ - gsize file_size; - char *file_contents; - GFile *child; - GFileInfo *info; - GFileType type; - int i; - - - /* FIXME: We only support .hidden on file: uri's for the moment. - * Need to figure out if we should do this async or sync to extend - * it to all types of uris. - */ - if (directory->details->location == NULL || - !g_file_is_native (directory->details->location)) - { - return; - } - - child = g_file_get_child (directory->details->location, ".hidden"); - - type = G_FILE_TYPE_UNKNOWN; - - info = g_file_query_info (child, G_FILE_ATTRIBUTE_STANDARD_TYPE, 0, NULL, NULL); - if (info != NULL) - { - type = g_file_info_get_file_type (info); - g_object_unref (info); - } - - if (type != G_FILE_TYPE_REGULAR) - { - g_object_unref (child); - return; - } - - if (!g_file_load_contents (child, NULL, &file_contents, &file_size, NULL, NULL)) - { - g_object_unref (child); - return; - } - - g_object_unref (child); - - if (directory->details->hidden_file_hash == NULL) - { - directory->details->hidden_file_hash = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - } - - /* Now parse the data */ - i = 0; - while (i < file_size) - { - int start; - - start = i; - while (i < file_size && file_contents[i] != '\n') - { - i++; - } - - if (i > start) - { - char *hidden_filename; - - hidden_filename = g_strndup (file_contents + start, i - start); - g_hash_table_insert (directory->details->hidden_file_hash, - hidden_filename, hidden_filename); - } - - i++; - - } - - g_free (file_contents); -} - -static void directory_load_state_free (DirectoryLoadState *state) { if (state->enumerator) @@ -2422,25 +2324,6 @@ start_monitoring_file_list (CajaDirectory *directory) caja_directory_get_corresponding_file (directory); state->load_directory_file->details->loading_directory = TRUE; - read_dot_hidden_file (directory); - - /* Hack to work around kde trash dir */ - if (kde_trash_dir_name != NULL && caja_directory_is_desktop_directory (directory)) - { - char *fn; - - if (directory->details->hidden_file_hash == NULL) - { - directory->details->hidden_file_hash = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - } - - fn = g_strdup (kde_trash_dir_name); - g_hash_table_insert (directory->details->hidden_file_hash, - fn, fn); - } - - #ifdef DEBUG_LOAD_DIRECTORY g_message ("load_directory called to monitor file list of %p", directory->details->location); #endif diff --git a/libcaja-private/caja-directory-private.h b/libcaja-private/caja-directory-private.h index 4ea4e1b6..cee75c98 100644 --- a/libcaja-private/caja-directory-private.h +++ b/libcaja-private/caja-directory-private.h @@ -136,8 +136,6 @@ struct CajaDirectoryDetails GList *file_operations_in_progress; /* list of FileOperation * */ - GHashTable *hidden_file_hash; - guint64 free_space; /* (guint)-1 for unknown */ time_t free_space_read; /* The time free_space was updated, or 0 for never */ }; @@ -237,9 +235,5 @@ void caja_directory_add_file_to_work_queue (CajaDirectory void caja_directory_remove_file_from_work_queue (CajaDirectory *directory, CajaFile *file); -/* KDE compatibility hacks */ - -void caja_set_kde_trash_name (const char *trash_dir); - /* debugging functions */ int caja_directory_number_outstanding (void); diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c index e9292e3b..fa6b6252 100644 --- a/libcaja-private/caja-directory.c +++ b/libcaja-private/caja-directory.c @@ -201,11 +201,6 @@ caja_directory_finalize (GObject *object) g_assert (directory->details->file_list == NULL); g_hash_table_destroy (directory->details->file_hash); - if (directory->details->hidden_file_hash) - { - g_hash_table_destroy (directory->details->hidden_file_hash); - } - caja_file_queue_destroy (directory->details->high_priority_queue); caja_file_queue_destroy (directory->details->low_priority_queue); caja_file_queue_destroy (directory->details->extension_queue); diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 85f7aa2f..6e6603b2 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -3389,15 +3389,6 @@ caja_file_is_hidden_file (CajaFile *file) return file->details->is_hidden; } -static gboolean -is_file_hidden (CajaFile *file) -{ - return file->details->directory->details->hidden_file_hash != NULL && - g_hash_table_lookup (file->details->directory->details->hidden_file_hash, - eel_ref_str_peek (file->details->name)) != NULL; - -} - /** * caja_file_should_show: * @file: the file to check. @@ -3417,7 +3408,7 @@ caja_file_should_show (CajaFile *file, if (caja_file_is_in_trash (file)) { return TRUE; } else { - return (show_hidden || (!caja_file_is_hidden_file (file) && !is_file_hidden (file))) && + return (show_hidden || !caja_file_is_hidden_file (file)) && (show_foreign || !(caja_file_is_in_desktop (file) && caja_file_is_foreign_link (file))); } } |