e: show desktop according to XDG_DESKTOP_DIR if set
authorBoris Faure <billiob@gmail.com>
Thu, 18 Aug 2011 19:11:34 +0000 (19:11 +0000)
committerBoris Faure <billiob@gmail.com>
Thu, 18 Aug 2011 19:11:34 +0000 (19:11 +0000)
SVN revision: 62572

AUTHORS
src/bin/e_fm.c

diff --git a/AUTHORS b/AUTHORS
index 0920049..5a2578b 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -26,3 +26,4 @@ Hannes Janetzek <hannes.janetzek@gmail.com>
 Mike Blumenkrantz (discomfitor/zmike) <mike@zentific.com>
 Leif Middelschulte <leif.middelschulte@gmail.com>
 yoz (Michael Bouchaud) <michael.bouchaud@gmail.com>
+billiob (Boris Faure) <billiob@gmail.com>
index 8b60e65..b863c36 100644 (file)
@@ -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))
-                      return NULL;
-                 }
-               else
-                 {
-                    if (e_user_homedir_snprintf(buf, sizeof(buf), "%s/%s", _("Desktop"), path) >= 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;
-                 }
+                   }
+
+                 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)