elm_panel: display directory from HOME on Windows.
authormichelle legrand <michelle.legrand@openwide.fr>
Wed, 11 Feb 2015 13:53:40 +0000 (14:53 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 26 Mar 2015 17:11:56 +0000 (18:11 +0100)
Summary:
On Windows we can get the HOME environment variable if we launch the application
from Msys or Cygwin, otherwise we need to use "HOMEDRIVE" and "HOMEPATH" to get
windows home path.

@fix

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

index b98bc76..a413702 100644 (file)
@@ -92,11 +92,19 @@ _fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
    Eina_List *l;
    char *real;
    char *home_env = NULL;
+   char win_home_env[PATH_MAX];
    unsigned int x = 0;
 
    if (!dirs)
      {
         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
         if (!home_env) return;
         if (!(d = opendir(home_env))) return;
         while ((de = readdir(d)) && (x < LIST_ITEM_MAX))
@@ -104,7 +112,8 @@ _fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
              char buff[PATH_MAX];
 
              if (de->d_name[0] == '.') continue;
-             snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name);
+             snprintf(buff, sizeof(buff), "%s/%s", home_env, de->d_name);
+
              if (!ecore_file_is_dir(buff)) continue;
              x++;
              real = ecore_file_realpath(buff);