From 9ee01f789cf8f80a2abeb4a90fd29d1759bc458c Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Wed, 25 Mar 2015 17:42:45 +0100 Subject: Refactor code for moving thumbnail cache file on renames/moves --- thunar/thunar-file.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 4bd3b2b..c789fc3 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -692,22 +692,36 @@ thunar_file_monitor_update (GFile *path, static void -thunar_file_monitor_moved (ThunarFile *file, - GFile *renamed_file) +thunar_file_move_thumbnail_cache_file (GFile *old_file, + GFile *new_file) { ThunarApplication *application; ThunarThumbnailCache *thumbnail_cache; - GFile *previous_file; - /* ref the old location */ - previous_file = g_object_ref (G_OBJECT (file->gfile)); + _thunar_return_if_fail (G_IS_FILE (old_file)); + _thunar_return_if_fail (G_IS_FILE (new_file)); - /* notify the thumbnail cache that we can now also move the thumbnail */ application = thunar_application_get (); thumbnail_cache = thunar_application_get_thumbnail_cache (application); - thunar_thumbnail_cache_move_file (thumbnail_cache, previous_file, renamed_file); + thunar_thumbnail_cache_move_file (thumbnail_cache, old_file, new_file); + g_object_unref (thumbnail_cache); g_object_unref (application); +} + + + +static void +thunar_file_monitor_moved (ThunarFile *file, + GFile *renamed_file) +{ + GFile *previous_file; + + /* ref the old location */ + previous_file = g_object_ref (G_OBJECT (file->gfile)); + + /* notify the thumbnail cache that we can now also move the thumbnail */ + thunar_file_move_thumbnail_cache_file (previous_file, renamed_file); /* set the new file */ file->gfile = g_object_ref (G_OBJECT (renamed_file)); @@ -803,6 +817,9 @@ thunar_file_monitor (GFileMonitor *monitor, if (!other_file) return; + /* notify the thumbnail cache that we can now also move the thumbnail */ + thunar_file_move_thumbnail_cache_file (event_path, other_path); + /* reload the containing target folder */ thunar_file_reload_parent (other_file); -- 2.3.3