jaehyun pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=2be4e6c3d32ab30d43e666d833218c782d01410e

commit 2be4e6c3d32ab30d43e666d833218c782d01410e
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Fri Apr 15 19:36:27 2016 +0900

    file_browser: Show workspace directory.
    
    File browser shows workspace directory and its sub files.
    Workspace directory is set with argument "-w" and directory path.
    (e.g. enventor -w ./workspace)
    
    This commit implements T3389.
---
 README                                     |   5 +-
 data/about/ABOUT                           |   5 +-
 data/themes/default/images.edc             |   4 +
 data/themes/default/images/Makefile.am     |   2 +
 data/themes/default/images/icon_file.png   | Bin 0 -> 2454 bytes
 data/themes/default/images/icon_folder.png | Bin 0 -> 4145 bytes
 src/bin/base_gui.c                         |   1 +
 src/bin/config_data.c                      |  12 +++
 src/bin/file_browser.c                     | 154 ++++++++++++++++++++++++++---
 src/bin/main.c                             |  18 +++-
 src/include/config_data.h                  |   3 +-
 11 files changed, 183 insertions(+), 21 deletions(-)

diff --git a/README b/README
index d2bb4fa..95e8a25 100644
--- a/README
+++ b/README
@@ -74,7 +74,7 @@ Ctrl+Space - Search candidate keywords in the context
 [Command Line Usage]
 
 enventor --help
-enventor [input file] [output file] [-t] [-i image path] [-s sound path] [-f 
font path] [-d data path]
+enventor [input file] [output file] [-t] [-i image path] [-s sound path] [-f 
font path] [-d data path] [-w workspace path]
 
 input file = EDC file to open. If input file is skipped, Enventor will open a 
default template code with a temporary file.
 output file = EDJ file to store compiled file. If output file is skipped, 
Enventor will store the binary file to the temporary directory.
@@ -83,12 +83,13 @@ output file = EDJ file to store compiled file. If output 
file is skipped, Envent
 -s = path to sound resources that the edc includes
 -f = path to font resources that the edc includes
 -d = path to data resources that the edc includes
+-w = workspace directory path that contains group edc files
 
 Examples of Enventor command line usage:
 $ enventor
 $ enventor -t
 $ enventor newfile.edc -t
-$ enventor sample.edc output.edj -i ./images -s ./sounds
+$ enventor sample.edc output.edj -i ./images -s ./sounds -w ./workspace
 
 
 [Developers]
diff --git a/data/about/ABOUT b/data/about/ABOUT
index d2f5bf7..868391f 100644
--- a/data/about/ABOUT
+++ b/data/about/ABOUT
@@ -56,7 +56,7 @@ Ctrl+Space - Search candidate keywords in the context</br>
 <font_size=11><b>[Command Line Usage]</b></font_size></br>
 </br>
 enventor --help</br>
-enventor [input file] [output file] [-t] [-i image path] [-s sound path] [-f 
font path] [-d data path]</br>
+enventor [input file] [output file] [-t] [-i image path] [-s sound path] [-f 
font path] [-d data path] [-w workspace path]</br>
 </br>
 input file = EDC file to open. If input file is skipped, Enventor will open a 
default template code with a temporary file.</br>
 output file = EDJ file to store compiled file. If output file is skipped, 
Enventor will store the binary file to the temporary directory.</br>
@@ -65,12 +65,13 @@ output file = EDJ file to store compiled file. If output 
file is skipped, Envent
 -s = path to sound resources that the edc includes</br>
 -f = path to font resources that the edc includes</br>
 -d = path to data resources that the edc includes</br>
+-w = workspace directory path that contains group edc files</br>
 </br>
 Examples of Enventor command line usage:</br>
 $ enventor</br>
 $ enventor -t</br>
 $ enventor newfile.edc -t</br>
-$ enventor sample.edc output.edj -i ./images -s ./sounds</br>
+$ enventor sample.edc output.edj -i ./images -s ./sounds -w ./workspace</br>
 </br>
 </br>
 <font_size=11><b>[Developers]</b></font_size></br>
diff --git a/data/themes/default/images.edc b/data/themes/default/images.edc
index 38661db..cf18c1c 100644
--- a/data/themes/default/images.edc
+++ b/data/themes/default/images.edc
@@ -1,5 +1,7 @@
 images {
    image: "icon_close.png" COMP;
+   image: "icon_file.png" COMP;
+   image: "icon_folder.png" COMP;
    image: "slider_up.png" COMP;
    image: "slider_down.png" COMP;
    image: "menu.png" COMP;
@@ -69,6 +71,8 @@ ICON_GROUP("Swallow", "live_swallow.png")
 ICON_GROUP("Text", "live_text.png")
 ICON_GROUP("Textblock", "live_textblock.png")
 ICON_GROUP("close", "icon_close.png")
+ICON_GROUP("file", "icon_file.png")
+ICON_GROUP("folder", "icon_folder.png")
 ICON_GROUP("file_browser", "file_browser.png")
 ICON_GROUP("edc_navigator", "edc_navigator.png")
 ICON_GROUP("navi_group", "navi_group.png")
diff --git a/data/themes/default/images/Makefile.am 
b/data/themes/default/images/Makefile.am
index 4376181..9db2492 100644
--- a/data/themes/default/images/Makefile.am
+++ b/data/themes/default/images/Makefile.am
@@ -70,6 +70,8 @@ EXTRA_DIST = \
    expand.png \
    invert.png \
    icon_close.png \
+   icon_file.png \
+   icon_folder.png \
    file_browser.png \
    edc_navigator.png \
    cursor_arrow.png \
diff --git a/data/themes/default/images/icon_file.png 
b/data/themes/default/images/icon_file.png
new file mode 100644
index 0000000..a3fc236
Binary files /dev/null and b/data/themes/default/images/icon_file.png differ
diff --git a/data/themes/default/images/icon_folder.png 
b/data/themes/default/images/icon_folder.png
new file mode 100644
index 0000000..b99006b
Binary files /dev/null and b/data/themes/default/images/icon_folder.png differ
diff --git a/src/bin/base_gui.c b/src/bin/base_gui.c
index 1df657f..1282f8e 100644
--- a/src/bin/base_gui.c
+++ b/src/bin/base_gui.c
@@ -346,6 +346,7 @@ base_gui_init(void)
    elm_object_part_content_set(layout, "elm.swallow.file_browser",
                                file_browser);
    file_browser_edc_file_set(config_input_path_get());
+   file_browser_workspace_set(config_workspace_path_get());
 
    //EDC Navigator
    Evas_Object *edc_navigator = edc_navigator_init(layout);
diff --git a/src/bin/config_data.c b/src/bin/config_data.c
index e7008c9..6b3b98e 100644
--- a/src/bin/config_data.c
+++ b/src/bin/config_data.c
@@ -4,6 +4,7 @@ typedef struct config_s
 {
    const char *input_path;
    const char *output_path;
+   const char *workspace_path;
    const char *font_name;
    const char *font_style;
 
@@ -321,6 +322,7 @@ config_input_path_set(const char *input_path)
 
 Eina_Bool
 config_init(const char *input_path, const char *output_path,
+            const char *workspace_path,
             Eina_List *img_path, Eina_List *snd_path,
             Eina_List *fnt_path, Eina_List *dat_path)
 {
@@ -332,6 +334,8 @@ config_init(const char *input_path, const char *output_path,
 
    if (input_path[0]) config_input_path_set(input_path);
    if (output_path[0]) eina_stringshare_replace(&cd->output_path, output_path);
+   if (workspace_path[0])
+     eina_stringshare_replace(&cd->workspace_path, workspace_path);
 
    if (img_path)
      g_cd->img_path_list = img_path;
@@ -357,6 +361,7 @@ config_term(void)
 
    eina_stringshare_del(cd->input_path);
    eina_stringshare_del(cd->output_path);
+   eina_stringshare_del(cd->workspace_path);
 
    Eina_Stringshare *str;
    EINA_LIST_FREE(cd->img_path_list, str) eina_stringshare_del(str);
@@ -624,6 +629,13 @@ config_output_path_get(void)
    return cd->output_path;
 }
 
+const char *
+config_workspace_path_get(void)
+{
+   config_data *cd = g_cd;
+   return cd->workspace_path;
+}
+
 void
 config_syntax_color_set(Enventor_Syntax_Color_Type color_type,
                         const char *val)
diff --git a/src/bin/file_browser.c b/src/bin/file_browser.c
index de9e744..0e044cf 100644
--- a/src/bin/file_browser.c
+++ b/src/bin/file_browser.c
@@ -22,6 +22,7 @@ struct file_browser_file_s
 typedef struct file_browser_s
 {
    brows_file *col_edc;   //collections edc
+   brows_file *workspace; //workspace directory
 
    Evas_Object *genlist;
    Elm_Genlist_Item_Class *itc;
@@ -44,23 +45,29 @@ gl_file_selected_cb(void *data, Evas_Object *obj 
EINA_UNUSED, void *event_info)
 }
 
 static Elm_Object_Item *
-file_genlist_item_append(char *file_name, Elm_Object_Item *parent_it,
-                         Elm_Genlist_Item_Type it_type, brows_file *file)
+file_genlist_item_append(brows_file *file, Elm_Object_Item *parent_it,
+                         Elm_Genlist_Item_Type it_type)
 {
    brows_data *bd = g_bd;
    if (!bd) return NULL;
 
-   if (!file_name) return NULL;
    if (!file) return NULL;
 
    Elm_Object_Item *it =
       elm_genlist_item_append(bd->genlist,
                               bd->itc,             /* item class */
-                              file_name,           /* item data */
+                              file,                /* item data */
                               parent_it,           /* parent */
                               it_type,             /* item type */
                               gl_file_selected_cb, /* select cb */
                               file);               /* select cb data */
+
+   char it_str[EINA_PATH_MAX];
+   snprintf(it_str, EINA_PATH_MAX, "%p", it);
+   evas_object_data_set(bd->genlist, it_str, file);
+
+   elm_genlist_item_expanded_set(it, EINA_FALSE);
+
    return it;
 }
 
@@ -68,11 +75,89 @@ static char *
 gl_file_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
                     const char *part EINA_UNUSED)
 {
+   brows_file *file = data;
+   return strdup(file->name);
+}
+
+static Evas_Object *
+gl_file_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+   brows_file *file = data;
+
+   if (!strcmp(part, "elm.swallow.icon"))
+     {
+        Evas_Object *img = elm_image_add(obj);
+
+        if (ecore_file_is_dir(file->path))
+          elm_image_file_set(img, EDJE_PATH, "folder");
+        else
+          elm_image_file_set(img, EDJE_PATH, "file");
+
+        return img;
+     }
+   else return NULL;
+}
+
+static char *
+gl_group_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                     const char *part EINA_UNUSED)
+{
    char *file_name = data;
    return strdup(file_name);
 }
 
-/* Find including sub edc files and Create a list of brows_file. */
+static void
+gl_exp_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+{
+   Elm_Object_Item *it = event_info;
+   elm_genlist_item_expanded_set(it, EINA_TRUE);
+}
+
+static void
+gl_con_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+{
+   Elm_Object_Item *it = event_info;
+   elm_genlist_item_expanded_set(it, EINA_FALSE);
+}
+
+static void
+gl_exp(void *data, Evas_Object *obj, void *event_info)
+{
+   brows_data *bd = data;
+   if (!bd) return;
+
+   Elm_Object_Item *it = event_info;
+
+   char it_str[EINA_PATH_MAX];
+   snprintf(it_str, EINA_PATH_MAX, "%p", it);
+   brows_file *file = evas_object_data_get(obj, it_str);
+   if (!file) return;
+
+   if (file->sub_file_list)
+     {
+        Eina_List *l = NULL;
+        brows_file *sub_file = NULL;
+        EINA_LIST_FOREACH(file->sub_file_list, l, sub_file)
+          {
+             Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE;
+             if (sub_file->sub_file_list)
+               type = ELM_GENLIST_ITEM_TREE;
+             sub_file->it = file_genlist_item_append(sub_file, file->it, type);
+
+             if (type == ELM_GENLIST_ITEM_TREE)
+               gl_exp_req(NULL, NULL, sub_file->it);
+          }
+     }
+}
+
+static void
+gl_con(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+   Elm_Object_Item *it = event_info;
+   elm_genlist_item_subitems_clear(it);
+}
+
+/* Find sub files and Create a list of brows_file. */
 static Eina_List *
 sub_file_list_create(brows_file *file)
 {
@@ -90,9 +175,6 @@ sub_file_list_create(brows_file *file)
    char *dir_path = file->path;
    EINA_LIST_FOREACH(sub_file_name_list, l, sub_file_name)
      {
-        if (!strcmp(".", sub_file_name) || !strcmp("..", sub_file_name))
-          continue;
-
         brows_file *sub_file = calloc(1, sizeof(brows_file));
 
         int sub_file_path_len = strlen(dir_path) + strlen(sub_file_name) + 2;
@@ -174,7 +256,7 @@ file_set_internal(const char *file_path, 
File_Browser_File_Type file_type)
    Elm_Genlist_Item_Type it_type = ELM_GENLIST_ITEM_NONE;
    if (file->sub_file_list)
      it_type = ELM_GENLIST_ITEM_TREE;
-   file->it = file_genlist_item_append(file->name, NULL, it_type, file);
+   file->it = file_genlist_item_append(file, NULL, it_type);
 
    return file;
 }
@@ -183,6 +265,46 @@ file_set_internal(const char *file_path, 
File_Browser_File_Type file_type)
 /* Externally accessible calls                                               */
 /*****************************************************************************/
 
+/* Set workspace directory. */
+void
+file_browser_workspace_set(const char *workspace_path)
+{
+   brows_data *bd = g_bd;
+   if (!bd) return;
+
+   if (!workspace_path) return;
+   if (!ecore_file_exists(workspace_path)) return;
+   if (!ecore_file_is_dir(workspace_path)) return;
+
+   if (bd->workspace)
+     {
+        if (!strcmp(workspace_path, bd->workspace->path))
+          return;
+
+        brows_file_free(bd->workspace);
+        bd->workspace = NULL;
+     }
+
+   Elm_Object_Item *group_it =
+      elm_genlist_item_append(bd->genlist,
+                              bd->group_itc,         /* item class */
+                              "Workspace",           /* item data */
+                              NULL,                  /* parent */
+                              ELM_GENLIST_ITEM_NONE, /* item type */
+                              NULL,                  /* select_cb */
+                              NULL);                 /* select_cb data */
+   elm_genlist_item_select_mode_set(group_it,
+                                    ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+   brows_file *workspace = file_set_internal(workspace_path,
+                                             FILE_BROWSER_FILE_TYPE_DIR);
+   if (!workspace) return;
+   bd->workspace = workspace;
+
+   if (workspace->sub_file_list)
+     gl_exp_req(NULL, NULL, workspace->it);
+}
+
 /* Set "collections" edc file. */
 void
 file_browser_edc_file_set(const char *edc_file)
@@ -209,7 +331,7 @@ file_browser_edc_file_set(const char *edc_file)
    Elm_Object_Item *group_it =
       elm_genlist_item_append(bd->genlist,
                               bd->group_itc,         /* item class */
-                              "Collections",         /* item data */
+                              "Collections EDC",     /* item data */
                               NULL,                  /* parent */
                               ELM_GENLIST_ITEM_NONE, /* item type */
                               NULL,                  /* select_cb */
@@ -236,18 +358,25 @@ file_browser_init(Evas_Object *parent)
    Evas_Object *genlist = elm_genlist_add(parent);
    elm_object_focus_allow_set(genlist, EINA_FALSE);
 
+   evas_object_smart_callback_add(genlist, "expand,request", gl_exp_req, NULL);
+   evas_object_smart_callback_add(genlist, "contract,request", gl_con_req,
+                                  NULL);
+   evas_object_smart_callback_add(genlist, "expanded", gl_exp, bd);
+   evas_object_smart_callback_add(genlist, "contracted", gl_con, NULL);
+
    //Item Class
    Elm_Genlist_Item_Class *itc;
    itc = elm_genlist_item_class_new();
-   itc->item_style = "no_icon";
+   itc->item_style = "default";
    itc->func.text_get = gl_file_text_get_cb;
+   itc->func.content_get = gl_file_content_get_cb;
    bd->itc = itc;
 
    //Group Index Item Class
    Elm_Genlist_Item_Class *group_itc;
    group_itc = elm_genlist_item_class_new();
    group_itc->item_style = "group_index";
-   group_itc->func.text_get = gl_file_text_get_cb;
+   group_itc->func.text_get = gl_group_text_get_cb;
    bd->group_itc = group_itc;
 
    bd->genlist = genlist;
@@ -262,6 +391,7 @@ file_browser_term(void)
    if (!bd) return;
 
    if (bd->col_edc) brows_file_free(bd->col_edc);
+   if (bd->workspace) brows_file_free(bd->workspace);
 
    elm_genlist_item_class_free(bd->itc);
    elm_genlist_item_class_free(bd->group_itc);
diff --git a/src/bin/main.c b/src/bin/main.c
index 1a03a32..c2124c1 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -223,7 +223,8 @@ tools_set(void)
 }
 
 static void
-args_dispatch(int argc, char **argv, char *edc_path, char *edj_path,
+args_dispatch(int argc, char **argv,
+              char *edc_path, char *edj_path, char *workspace_path,
               Eina_List **img_path, Eina_List **snd_path,
               Eina_List **fnt_path, Eina_List **dat_path,
               Eina_Bool *default_edc, Eina_Bool *template,
@@ -235,6 +236,8 @@ args_dispatch(int argc, char **argv, char *edc_path, char 
*edj_path,
    Eina_List *sd = NULL;
    Eina_List *dd = NULL;
 
+   char *wd = NULL;
+
    Eina_Bool quit = EINA_FALSE;
    Eina_Bool help = EINA_FALSE;
 
@@ -259,6 +262,8 @@ args_dispatch(int argc, char **argv, char *edc_path, char 
*edj_path,
                                       "path", ECORE_GETOPT_TYPE_STR),
           ECORE_GETOPT_APPEND_METAVAR('d', "dd", "Data path",
                                       "path", ECORE_GETOPT_TYPE_STR),
+          ECORE_GETOPT_STORE('w', "wd", "Workspace path",
+                             ECORE_GETOPT_TYPE_STR),
           ECORE_GETOPT_VERSION('v', "version"),
           ECORE_GETOPT_COPYRIGHT('c', "copyright"),
           ECORE_GETOPT_LICENSE('l', "license"),
@@ -273,6 +278,7 @@ args_dispatch(int argc, char **argv, char *edc_path, char 
*edj_path,
       ECORE_GETOPT_VALUE_LIST(sd),
       ECORE_GETOPT_VALUE_LIST(fd),
       ECORE_GETOPT_VALUE_LIST(dd),
+      ECORE_GETOPT_VALUE_STR(wd),
       ECORE_GETOPT_VALUE_BOOL(quit),
       ECORE_GETOPT_VALUE_BOOL(quit),
       ECORE_GETOPT_VALUE_BOOL(quit),
@@ -336,6 +342,7 @@ defaults:
           *dat_path = eina_list_append(*dat_path, eina_stringshare_add(s));
           free(s);
        }
+     if (wd) sprintf(workspace_path, "%s", wd);
 
    ecore_getopt_list_free(id);
    ecore_getopt_list_free(fd);
@@ -349,14 +356,17 @@ config_data_set(app_data *ad, int argc, char **argv, 
Eina_Bool *default_edc,
 {
    char edc_path[PATH_MAX] = { 0, };
    char edj_path[PATH_MAX] = { 0, };
+   char workspace_path[PATH_MAX] = { 0, };
    Eina_List *img_path = NULL;
    Eina_List *snd_path = NULL;
    Eina_List *fnt_path = NULL;
    Eina_List *dat_path = NULL;
 
-   args_dispatch(argc, argv, edc_path, edj_path, &img_path, &snd_path,
-                 &fnt_path, &dat_path, default_edc, template, PATH_MAX);
-   if (!config_init(edc_path, edj_path, img_path, snd_path, fnt_path, 
dat_path))
+   args_dispatch(argc, argv, edc_path, edj_path, workspace_path,
+                 &img_path, &snd_path, &fnt_path, &dat_path,
+                 default_edc, template, PATH_MAX);
+   if (!config_init(edc_path, edj_path, workspace_path,
+                    img_path, snd_path, fnt_path, dat_path))
      return EINA_FALSE;
    config_update_cb_set(config_update_cb, ad);
 
diff --git a/src/include/config_data.h b/src/include/config_data.h
index 562a6b5..3e0ca07 100644
--- a/src/include/config_data.h
+++ b/src/include/config_data.h
@@ -3,10 +3,11 @@
 #define MAX_VIEW_SCALE 5.0
 #define MIN_VIEW_SCALE 0.1
 
-Eina_Bool config_init(const char *input_path, const char *output_path, 
Eina_List *img_path, Eina_List *snd_path, Eina_List *fnt_path, Eina_List 
*dat_path);
+Eina_Bool config_init(const char *input_path, const char *output_path, const 
char *workspace_path, Eina_List *img_path, Eina_List *snd_path, Eina_List 
*fnt_path, Eina_List *dat_path);
 void config_term(void);
 const char *config_input_path_get(void);
 const char *config_output_path_get(void);
+const char *config_workspace_path_get(void);
 const char *config_img_path_get(void);
 const char *config_snd_path_get(void);
 const char *config_fnt_path_get(void);

-- 


Reply via email to