[Xfce4-commits] <thunar:jannis/thumbnailer-improvements> Use Move(), Copy() and Delete() cache methods in transfer jobs.

Jannis Pohlmann noreply at xfce.org
Mon Feb 7 21:58:01 CET 2011


Updating branch refs/heads/jannis/thumbnailer-improvements
         to ee3d81ed900dfd3e23b374504f34cc264abb3d2f (commit)
       from 4f6e985763adc4c6dfed5153aaa5ec973f498f82 (commit)

commit ee3d81ed900dfd3e23b374504f34cc264abb3d2f
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Feb 7 21:54:58 2011 +0100

    Use Move(), Copy() and Delete() cache methods in transfer jobs.
    
    This probably has to be improved (at least Copy() sometimes causes weird
    icon view behavior when copying a lot of files to an open window).
    Move transfer jobs work fine.

 thunar/thunar-transfer-job.c |  126 ++++++++++++++++++++++++++++--------------
 1 files changed, 84 insertions(+), 42 deletions(-)

diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c
index 364bd4e..801f98e 100644
--- a/thunar/thunar-transfer-job.c
+++ b/thunar/thunar-transfer-job.c
@@ -1,22 +1,22 @@
-/* vi:set sw=2 sts=2 ts=2 et ai: */
+/* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
  * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
  * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
- * This program is free software; you can redistribute it and/or modify 
- * it under the terms of the GNU General Public License as published by 
- * the Free Software Foundation; either version 2 of the License, or (at 
- * your option) any later version.
+ * This program is free software; you can redistribute it and/or 
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of 
+ * the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
- * MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public 
+ * License along with this program; if not, write to the Free 
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -25,11 +25,13 @@
 
 #include <gio/gio.h>
 
+#include <thunar/thunar-application.h>
 #include <thunar/thunar-gio-extensions.h>
 #include <thunar/thunar-io-scan-directory.h>
 #include <thunar/thunar-io-jobs-util.h>
 #include <thunar/thunar-job.h>
 #include <thunar/thunar-private.h>
+#include <thunar/thunar-thumbnail-cache.h>
 #include <thunar/thunar-transfer-job.h>
 
 
@@ -481,11 +483,13 @@ thunar_transfer_job_copy_node (ThunarTransferJob  *job,
                                GList             **target_file_list_return,
                                GError            **error)
 {
-  ThunarJobResponse response;
-  GFileInfo        *info;
-  GError           *err = NULL;
-  GFile            *real_target_file = NULL;
-  gchar            *base_name;
+  ThunarThumbnailCache *thumbnail_cache;
+  ThunarApplication    *application;
+  ThunarJobResponse     response;
+  GFileInfo            *info;
+  GError               *err = NULL;
+  GFile                *real_target_file = NULL;
+  gchar                *base_name;
 
   _thunar_return_if_fail (THUNAR_IS_TRANSFER_JOB (job));
   _thunar_return_if_fail (node != NULL && G_IS_FILE (node->source_file));
@@ -536,6 +540,14 @@ retry_copy:
           /* node->source_file == real_target_file means to skip the file */
           if (G_LIKELY (node->source_file != real_target_file))
             {
+              /* notify the thumbnail cache of the copy operation */
+              application = thunar_application_get ();
+              thumbnail_cache = thunar_application_get_thumbnail_cache (application);
+              thunar_thumbnail_cache_copy_file (thumbnail_cache, node->source_file, 
+                                                real_target_file);
+              g_object_unref (thumbnail_cache);
+              g_object_unref (application);
+
               /* check if we have children to copy */
               if (node->children != NULL)
                 {
@@ -558,22 +570,42 @@ retry_copy:
 
               /* add the real target file to the return list */
               if (G_LIKELY (target_file_list_return != NULL))
-                *target_file_list_return = thunar_g_file_list_prepend (*target_file_list_return, real_target_file);
+                {
+                  *target_file_list_return = 
+                    thunar_g_file_list_prepend (*target_file_list_return, 
+                                                real_target_file);
+                }
 
 retry_remove:
               /* try to remove the source directory if we are on copy+remove fallback for move */
-              if (job->type == THUNAR_TRANSFER_JOB_MOVE && 
-                  !g_file_delete (node->source_file, exo_job_get_cancellable (EXO_JOB (job)), &err))
+              if (job->type == THUNAR_TRANSFER_JOB_MOVE)
                 {
-                  /* ask the user to retry */
-                  response = thunar_job_ask_skip (THUNAR_JOB (job), "%s", err->message);
+                  if (g_file_delete (node->source_file, 
+                                     exo_job_get_cancellable (EXO_JOB (job)), 
+                                     &err))
+                    {
+                      /* notify the thumbnail cache of the delete operation */
+                      application = thunar_application_get ();
+                      thumbnail_cache = 
+                        thunar_application_get_thumbnail_cache (application);
+                      thunar_thumbnail_cache_delete_file (thumbnail_cache, 
+                                                          node->source_file);
+                      g_object_unref (thumbnail_cache);
+                      g_object_unref (application);
+                    }
+                  else
+                    {
+                      /* ask the user to retry */
+                      response = thunar_job_ask_skip (THUNAR_JOB (job), "%s", 
+                                                      err->message);
 
-                  /* reset the error */
-                  g_clear_error (&err);
+                      /* reset the error */
+                      g_clear_error (&err);
 
-                  /* check whether to retry */
-                  if (G_UNLIKELY (response == THUNAR_JOB_RESPONSE_RETRY))
-                    goto retry_remove;
+                      /* check whether to retry */
+                      if (G_UNLIKELY (response == THUNAR_JOB_RESPONSE_RETRY))
+                        goto retry_remove;
+                    }
                 }
             }
 
@@ -614,20 +646,22 @@ static gboolean
 thunar_transfer_job_execute (ExoJob  *job,
                              GError **error)
 {
-  ThunarTransferNode *node;
-  ThunarJobResponse   response;
-  ThunarTransferJob  *transfer_job = THUNAR_TRANSFER_JOB (job);
-  GFileInfo          *info;
-  gboolean            parent_exists;
-  GError             *err = NULL;
-  GList              *new_files_list = NULL;
-  GList              *snext;
-  GList              *sp;
-  GList              *tnext;
-  GList              *tp;
-  GFile              *target_parent;
-  gchar              *base_name;
-  gchar              *parent_display_name;
+  ThunarThumbnailCache *thumbnail_cache;
+  ThunarTransferNode   *node;
+  ThunarApplication    *application;
+  ThunarJobResponse     response;
+  ThunarTransferJob    *transfer_job = THUNAR_TRANSFER_JOB (job);
+  GFileInfo            *info;
+  gboolean              parent_exists;
+  GError               *err = NULL;
+  GList                *new_files_list = NULL;
+  GList                *snext;
+  GList                *sp;
+  GList                *tnext;
+  GList                *tp;
+  GFile                *target_parent;
+  gchar                *base_name;
+  gchar                *parent_display_name;
 
   _thunar_return_val_if_fail (THUNAR_IS_TRANSFER_JOB (job), FALSE);
   _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -742,6 +776,14 @@ thunar_transfer_job_execute (ExoJob  *job,
                            exo_job_get_cancellable (job),
                            NULL, NULL, &err))
             {
+              /* notify the thumbnail cache of the move operation */
+              application = thunar_application_get ();
+              thumbnail_cache = thunar_application_get_thumbnail_cache (application);
+              thunar_thumbnail_cache_move_file (thumbnail_cache, 
+                                                node->source_file, tp->data);
+              g_object_unref (thumbnail_cache);
+              g_object_unref (application);
+
               /* add the target file to the new files list */
               new_files_list = thunar_g_file_list_prepend (new_files_list, tp->data);
 



More information about the Xfce4-commits mailing list