From b2d2229fdcc2f1bede667eaad3e5072b52cb3e50 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Thu, 18 Aug 2011 19:11:34 +0000 Subject: [PATCH] e: show desktop according to XDG_DESKTOP_DIR if set SVN revision: 62572 --- AUTHORS | 1 + src/bin/e_fm.c | 52 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index 092004933..5a2578b6e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,3 +26,4 @@ Hannes Janetzek Mike Blumenkrantz (discomfitor/zmike) Leif Middelschulte yoz (Michael Bouchaud) +billiob (Boris Faure) diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 8b60e65f2..b863c366e 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -3229,21 +3229,55 @@ _e_fm2_dev_path_map(const char *dev, const char *path) } else if (strcmp(dev, "desktop") == 0) { + char *custom_desktop_dir = getenv("XDG_DESKTOP_DIR"); /* this is a virtual device - it's where your favorites list is * stored - a dir with .desktop files or symlinks (in fact anything * you like */ - if (strcmp(path, "/") == 0) - { - if (e_user_homedir_concat(buf, sizeof(buf), _("Desktop")) >= sizeof(buf)) + if (custom_desktop_dir) + { + int len; + + custom_desktop_dir = e_util_shell_env_path_eval(custom_desktop_dir); + len = strlen(custom_desktop_dir); + + if (len >= sizeof(buf)) + { + free(custom_desktop_dir); return NULL; - } - else - { - if (e_user_homedir_snprintf(buf, sizeof(buf), "%s/%s", _("Desktop"), path) >= sizeof(buf)) - return NULL; - } + } + + strncpy(buf, custom_desktop_dir, sizeof(buf)); + + if (strcmp(path, "/")) + { + if (len + 1 + strlen(path) >= sizeof(buf)) + { + free(custom_desktop_dir); + return NULL; + } + buf[len++] = '/'; + strncpy(buf + len, path, sizeof(buf) - len); + } + free(custom_desktop_dir); + } + else + { + if (strcmp(path, "/") == 0) + { + if (e_user_homedir_concat(buf, sizeof(buf), + _("Desktop")) >= sizeof(buf)) + return NULL; + } + else + { + if (e_user_homedir_snprintf(buf, sizeof(buf), "%s/%s", + _("Desktop"), path) + >= sizeof(buf)) + return NULL; + } + } ecore_file_mkpath(buf); } else if (strcmp(dev, "temp") == 0)