[Xfce4-commits] <thunar:master> Instantly emit a change event on the parent folder in the trash job.

Jannis Pohlmann noreply at xfce.org
Fri Nov 19 16:28:01 CET 2010


Updating branch refs/heads/master
         to 043c6301aa0285a313db159d5366e66fd77ced0a (commit)
       from 68924ba2595fe733b7282d7b35795d4bd767c99c (commit)

commit 043c6301aa0285a313db159d5366e66fd77ced0a
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Fri Nov 19 16:25:44 2010 +0100

    Instantly emit a change event on the parent folder in the trash job.
    
    This will make trashing files feel much more responsive.

 thunar/thunar-io-jobs.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/thunar/thunar-io-jobs.c b/thunar/thunar-io-jobs.c
index 6caaa02..4799807 100644
--- a/thunar/thunar-io-jobs.c
+++ b/thunar/thunar-io-jobs.c
@@ -657,9 +657,11 @@ _thunar_io_jobs_trash (ThunarJob   *job,
                        GValueArray *param_values,
                        GError     **error)
 {
-  GError *err = NULL;
-  GList  *file_list;
-  GList  *lp;
+  ThunarFile *parent_file;
+  GError     *err = NULL;
+  GFile      *parent;
+  GList      *file_list;
+  GList      *lp;
 
   _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE);
   _thunar_return_val_if_fail (param_values != NULL, FALSE);
@@ -674,7 +676,26 @@ _thunar_io_jobs_trash (ThunarJob   *job,
   for (lp = file_list; err == NULL && lp != NULL; lp = lp->next)
     {
       _thunar_assert (G_IS_FILE (lp->data));
-      g_file_trash (lp->data, exo_job_get_cancellable (EXO_JOB (job)), &err);
+      
+      if (g_file_trash (lp->data, exo_job_get_cancellable (EXO_JOB (job)), &err))
+        {
+          /* determine the parent folder of the file if there is any */
+          parent = g_file_get_parent (lp->data);
+          if (parent != NULL)
+            {
+              /* obtain the thunar file for this folder from the cache */
+              parent_file = thunar_file_cache_lookup (parent);
+              if (parent_file != NULL)
+                {
+                  /* Feed a change event so that the delete event is 
+                   * picked up immediately */
+                  thunar_file_monitor_file_changed (parent_file);
+                }
+
+              /* release the parent */
+              g_object_unref (parent);
+            }
+        }
     }
 
   if (err != NULL)



More information about the Xfce4-commits mailing list