elm_fileselector: display directory from HOME on Windows.
authormichelle legrand <michelle.legrand@openwide.fr>
Wed, 11 Feb 2015 13:57:44 +0000 (14:57 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 26 Mar 2015 17:12:57 +0000 (18:12 +0100)
Summary:
On Windows, if we are running the application from Msys or Cygwin, we will
get the HOME environment variable. Otherwise we need to use Windows environment variables
"HOMEDRIVE" and "HOMEPATH" to get the home path.

@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
legacy/elementary/src/bin/test_fileselector.c

index 18dcae6..28fb30d 100644 (file)
@@ -517,6 +517,8 @@ test_fileselector(void *data       EINA_UNUSED,
                   void *event_info EINA_UNUSED)
 {
    Evas_Object *win, *fs, *box, *vbox, *sep;
+   char * home_env;
+   char win_home_env[PATH_MAX];
 
    /* Set the locale according to the system pref.
     * If you don't do so the file selector will order the files list in
@@ -548,7 +550,15 @@ test_fileselector(void *data       EINA_UNUSED,
    /* make the file list a tree with dir expandable in place */
    elm_fileselector_expandable_set(fs, EINA_FALSE);
    /* start the fileselector in the home dir */
-   elm_fileselector_path_set(fs, getenv("HOME"));
+   home_env = getenv("HOME");
+#ifdef _WIN32
+   if (!home_env)
+          {
+             snprintf(win_home_env, sizeof(win_home_env), "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
+             home_env = strdup(win_home_env);
+          }
+#endif
+   elm_fileselector_path_set(fs, home_env);
 
    /* provides suggested name (just for showing) */
    elm_fileselector_current_name_set(fs, "No name");