From ffb3401b191ff69259bdd7a92e5647cb0d3fb612 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Wed, 2 Apr 2014 19:31:31 +0300 Subject: [PATCH] Fix for moving icons into folders on the desktop (Bug 10785) When monitoring folders with g_file_monitor GIO sends move notifications instead of delete to our file_icon_manager file monitor rather than just a delete like before. We need to update the monitor to check if the icon has been moved off the desktop to handle this. --- common/xfdesktop-common.c | 17 +++++++++++++++++ common/xfdesktop-common.h | 2 ++ src/xfdesktop-file-icon-manager.c | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/common/xfdesktop-common.c b/common/xfdesktop-common.c index f36c500..f272861 100644 --- a/common/xfdesktop-common.c +++ b/common/xfdesktop-common.c @@ -54,6 +54,23 @@ #include "xfce-backdrop.h" /* for XfceBackdropImageStyle */ +gint +xfdesktop_compare_basenames(GFile *a, GFile *b) +{ + gchar *path_a, *path_b; + gboolean ret; + + path_a = g_file_get_basename(a); + path_b = g_file_get_basename(b); + + ret = g_strcmp0(path_a, path_b); + + g_free(path_a); + g_free(path_b); + + return ret; +} + gchar * xfdesktop_get_file_mimetype(const gchar *file) { diff --git a/common/xfdesktop-common.h b/common/xfdesktop-common.h index 0c4c6fc..6001ce8 100644 --- a/common/xfdesktop-common.h +++ b/common/xfdesktop-common.h @@ -87,6 +87,8 @@ G_BEGIN_DECLS +gint xfdesktop_compare_basenames(GFile *a, GFile *b); + gboolean xfdesktop_image_file_is_valid(const gchar *filename); gchar *xfdesktop_get_file_mimetype(const gchar *file); diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c index 35e08fd..82e96ca 100644 --- a/src/xfdesktop-file-icon-manager.c +++ b/src/xfdesktop-file-icon-manager.c @@ -2419,6 +2419,15 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor *monitor, xfdesktop_file_icon_manager_remove_icon(fmanager, moved_icon); } + if(xfdesktop_compare_basenames(other_file, fmanager->priv->folder) != 0) { + DBG("icon moved off the desktop"); + /* Nothing moved, this is actually a delete */ + if(file_info) + g_object_unref(file_info); + + return; + } + if(file_info) { gboolean is_hidden; -- 1.9.1