elm_fileselector: display directory from HOME on Windows.

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>
This commit is contained in:
michelle legrand 2015-02-11 14:57:44 +01:00 committed by Cedric BAIL
parent 949e0f5e9c
commit ce1d59bcbe
1 changed files with 11 additions and 1 deletions

View 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");