From 2013dbd206434ae076d7f7ec75fb36d95af18975 Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Fri, 26 Apr 2019 23:33:06 +0200 Subject: [PATCH] Desktop icons order resets (Bug #11266) - Added link to last used configuration as fallback --- src/xfdesktop-file-icon-manager.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c index 9787cceb..36052585 100644 --- a/src/xfdesktop-file-icon-manager.c +++ b/src/xfdesktop-file-icon-manager.c @@ -48,6 +48,10 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif + #ifndef PATH_MAX #define PATH_MAX 4096 #endif @@ -1897,7 +1901,7 @@ static gboolean xfdesktop_file_icon_manager_save_icons(gpointer user_data) { XfdesktopFileIconManager *fmanager = XFDESKTOP_FILE_ICON_MANAGER(user_data); - gchar relpath[PATH_MAX], *tmppath, *path; + gchar relpath[PATH_MAX], *tmppath, *path, *last_path; XfceRc *rcfile; gint x = 0, y = 0, width = 0, height = 0; @@ -1967,6 +1971,14 @@ xfdesktop_file_icon_manager_save_icons(gpointer user_data) strerror(errno)); unlink(tmppath); } + else { + last_path = xfce_resource_save_location(XFCE_RESOURCE_CONFIG, "xfce4/desktop/icons.screen.latest.rc", TRUE); + if(last_path != NULL) { + unlink(last_path); + symlink(path, last_path); + g_free(last_path); + } + } } else { XF_DEBUG("didn't write anything in the RC file, desktop is probably empty"); } @@ -2051,6 +2063,11 @@ xfdesktop_file_icon_manager_get_cached_icon_position(XfdesktopFileIconManager *f filename = xfce_resource_lookup(XFCE_RESOURCE_CONFIG, relpath); } + /* Still nothing ? Just use the latest available file as fallback */ + if(filename == NULL) { + filename = xfce_resource_lookup(XFCE_RESOURCE_CONFIG, "xfce4/desktop/icons.screen.latest.rc"); + } + if(filename != NULL) { XfceRc *rcfile; const gchar *icon_name; -- 2.11.0