diff --git a/ChangeLog b/ChangeLog index efa48cdfaeb76391ef8a1f46494441a299dc2cbd..5370235943dc0633735b258020672383ce97ffc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-07-17 Benedikt Meurer <benny@xfce.org> + + * TODO: Add note to based the ThunarVfsJob communication on the GSignal + mechanism. + * configure.in.in: Set tarname to be "Thunar-threaded". + * thunar-vfs/thunar-vfs-info.{c,h}: Let thunar_vfs_info_list_free() + return NULL. + * thunar-vfs/thunar-vfs-job-listdir.c: Invoke the callback every two + seconds, so for large directories, the user does not need to wait for + the whole folder to be loaded. Also sort the item names prior to + loading the infos. + * thunar/thunar-local-folder.c: Support partial loading, as implemented + for ThunarVfsJobListdir. + 2005-07-17 Benedikt Meurer <benny@xfce.org> * thunar-vfs/thunar-vfs-volume-sysv.c: Fix compile warning with wrong diff --git a/TODO b/TODO index 5900ca3b63f340fc2bbeb77af50c89fe6efa5d2c..69045ccc8289f5439ef73676813d5a5ae135e242 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ Important for Thunar 1.0 ======================== + - Use GObject signals for the ThunarVfsJob communication. + - In thunar_standard_view_selection_changed(), the "Cut file(s)" action should only be sensitive if the current folder is writable. diff --git a/configure.in.in b/configure.in.in index 80aadc30b0fe421c5738e9fcf37c732a8de4288c..934798ca0cc09fb5362d7d590f30ef6574d497af 100644 --- a/configure.in.in +++ b/configure.in.in @@ -20,7 +20,7 @@ AC_COPYRIGHT([Copyright (c) 2004-2005 The Thunar development team. All rights reserved. Written for Thunar by Benedikt Meurer <benny@xfce.org>.]) -AC_INIT([Thunar], [thunar_version()], [benny@xfce.org]) +AC_INIT([Thunar], [thunar_version()], [benny@xfce.org], [Thunar-threaded]) AC_PREREQ([2.50]) AC_CANONICAL_TARGET() AC_REVISION([$Id$]) diff --git a/thunar-vfs/thunar-vfs-info.c b/thunar-vfs/thunar-vfs-info.c index 6723659347f9959461ed85306a0c27b7956febaf..110ef3555a827162186986e1b153d412027786dc 100644 --- a/thunar-vfs/thunar-vfs-info.c +++ b/thunar-vfs/thunar-vfs-info.c @@ -255,11 +255,20 @@ thunar_vfs_info_matches (const ThunarVfsInfo *a, * * Unrefs all #ThunarVfsInfo<!---->s in @info_list and * frees the list itself. + * + * This method always returns %NULL for the convenience of + * being able to do: + * <informalexample><programlisting> + * info_list = thunar_vfs_info_list_free (info_list); + * </programlisting></informalexample> + * + * Return value: the empty list (%NULL). **/ -void +GSList* thunar_vfs_info_list_free (GSList *info_list) { g_slist_foreach (info_list, (GFunc) thunar_vfs_info_unref, NULL); g_slist_free (info_list); + return NULL; } diff --git a/thunar-vfs/thunar-vfs-info.h b/thunar-vfs/thunar-vfs-info.h index 1f15ae651b28af6aca0f118092906af79a697e11..38e59e75515f32a13df3dacaefffe1fe61ded546 100644 --- a/thunar-vfs/thunar-vfs-info.h +++ b/thunar-vfs/thunar-vfs-info.h @@ -207,7 +207,7 @@ void thunar_vfs_info_unref (ThunarVfsInfo *info); gboolean thunar_vfs_info_matches (const ThunarVfsInfo *a, const ThunarVfsInfo *b); -void thunar_vfs_info_list_free (GSList *info_list); +GSList *thunar_vfs_info_list_free (GSList *info_list); G_END_DECLS; diff --git a/thunar-vfs/thunar-vfs-job-listdir.c b/thunar-vfs/thunar-vfs-job-listdir.c index 59e4f2ddd56fc3d2cf45e3cf3af08f9149527a7b..0640d8795e03de748c754c597f7b68e54f16442b 100644 --- a/thunar-vfs/thunar-vfs-job-listdir.c +++ b/thunar-vfs/thunar-vfs-job-listdir.c @@ -38,6 +38,9 @@ #ifdef HAVE_STRING_H #include <string.h> #endif +#ifdef HAVE_TIME_H +#include <time.h> +#endif #include <thunar-vfs/thunar-vfs-job-listdir.h> @@ -142,6 +145,8 @@ thunar_vfs_job_listdir_execute (ThunarVfsJob *job) ThunarVfsURI *file_uri; GSList *names; GSList *lp; + time_t last_check_time; + time_t current_time; DIR *dp; dp = opendir (thunar_vfs_uri_get_path (job_listdir->uri)); @@ -181,11 +186,13 @@ thunar_vfs_job_listdir_execute (ThunarVfsJob *job) if (G_UNLIKELY (d == NULL)) break; - names = g_slist_prepend (names, g_string_chunk_insert (names_chunk, d->d_name)); + names = g_slist_insert_sorted (names, g_string_chunk_insert (names_chunk, d->d_name), (GCompareFunc) strcmp); } closedir (dp); + last_check_time = time (NULL); + /* Next we query the info for each of the file names * queried in the loop above. */ @@ -200,6 +207,15 @@ thunar_vfs_job_listdir_execute (ThunarVfsJob *job) if (G_LIKELY (info != NULL)) job_listdir->infos = g_slist_prepend (job_listdir->infos, info); thunar_vfs_uri_unref (file_uri); + + current_time = time (NULL); + if (current_time - last_check_time > 2) + { + last_check_time = current_time; + thunar_vfs_job_callback (job); + thunar_vfs_info_list_free (job_listdir->infos); + job_listdir->infos = NULL; + } } /* free the names */ diff --git a/thunar/thunar-local-folder.c b/thunar/thunar-local-folder.c index 1050c252d08cea9039c2c7814f2f70b6367a79fe..e118a3b3c7fd3d35682ce01ff97d31d9a4f312cc 100644 --- a/thunar/thunar-local-folder.c +++ b/thunar/thunar-local-folder.c @@ -232,7 +232,6 @@ thunar_local_folder_callback (ThunarVfsJob *job, ThunarLocalFolder *local_folder = THUNAR_LOCAL_FOLDER (user_data); ThunarFile *file; GSList *nfiles = NULL; - GSList *ofiles; GSList *lp; g_return_if_fail (THUNAR_IS_LOCAL_FOLDER (local_folder)); @@ -246,40 +245,22 @@ thunar_local_folder_callback (ThunarVfsJob *job, } else { - /* remember the previously contained files (if any) */ - ofiles = local_folder->files; - local_folder->files = NULL; - - /* generate the new list of files */ + /* add the new files */ for (lp = infos; lp != NULL; lp = lp->next) { file = thunar_local_file_get_for_info (lp->data); nfiles = g_slist_prepend (nfiles, file); + local_folder->files = g_slist_prepend (local_folder->files, file); g_signal_connect_closure_by_id (G_OBJECT (file), local_folder->file_destroy_id, 0, local_folder->file_destroy_closure, TRUE); } - /* tell the consumers that the old files are gone */ - if (G_UNLIKELY (ofiles != NULL)) - { - thunar_folder_files_removed (THUNAR_FOLDER (local_folder), ofiles); - - for (lp = ofiles; lp != NULL; lp = lp->next) - { - g_signal_handlers_disconnect_matched (G_OBJECT (lp->data), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE, - local_folder->file_destroy_id, 0, local_folder->file_destroy_closure, - NULL, NULL); - g_object_unref (G_OBJECT (lp->data)); - } - g_slist_free (ofiles); - } - /* tell the consumers that we have new files */ if (G_LIKELY (nfiles != NULL)) { - local_folder->files = nfiles; thunar_folder_files_added (THUNAR_FOLDER (local_folder), nfiles); + g_slist_free (nfiles); } } @@ -305,7 +286,7 @@ thunar_local_folder_corresponding_file_changed (ThunarFile *file, g_return_if_fail (THUNAR_IS_LOCAL_FOLDER (local_folder)); g_return_if_fail (local_folder->corresponding_file == file); - /* rescan the directory */ + /* rescan the directory (FIXME) */ #if 0 if (!thunar_local_folder_rescan (local_folder, NULL)) gtk_object_destroy (GTK_OBJECT (local_folder));