jaehwan pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=514ddf88cce7115b5514543da320b4d9be0d8ca8

commit 514ddf88cce7115b5514543da320b4d9be0d8ca8
Author: Jaehwan Kim <jae.hwan....@samsung.com>
Date:   Wed Mar 30 11:04:02 2016 +0900

    import_edj: widget can be customized by using edj template theme file.
    
    When the template file is changed, edj file is more easy to change.
    It just reads another edj file. Then eflete loads and shows just checked
    widgets.
    
    Conflicts:
        src/bin/ui/tab_home_import_edj.c
    
    Change-Id: I059c6c6a55a092302aea8c59f644673df8e45868
---
 configure.ac                                 |   1 +
 data/Makefile.am                             |   6 +-
 data/themes/default/widgets/layouts/tabs.edc | 360 +--------------------------
 src/bin/project_manager/group_manager.c      |  48 +++-
 src/bin/project_manager/project_manager.c    |  26 +-
 src/bin/project_manager/project_manager.h    |   4 +
 src/bin/ui/tab_home_import_edj.c             | 249 +++++++++++++++++-
 7 files changed, 315 insertions(+), 379 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5841135..d7ed0e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,7 @@ EFLETE_DEFINE=" 
-DEFLETE_EDJ=\\\"${datadir}/eflete/layouts/eflete.edj\\\" "
 EFLETE_DEFINE+=" 
-DEFLETE_THEME=\\\"${datadir}/eflete/themes/default/eflete_elm.edj\\\" "
 EFLETE_DEFINE+=" -DEFLETE_EDJ_PATH=\\\"${datadir}/eflete/themes/default/\\\" "
 EFLETE_DEFINE+=" -DEFLETE_IMG_PATH=\\\"${datadir}/eflete/images/\\\" "
+EFLETE_DEFINE+=" 
-DEFLETE_TEMPLATE_EDJ_PATH=\\\"${datadir}/eflete/themes/default/template/edj\\\"
 "
 EFLETE_DEFINE+=" 
-DEFLETE_TEMPLATE_EDC_PATH=\\\"${datadir}/eflete/themes/default/template/edc\\\"
 "
 EFLETE_DEFINE+=" 
-DEFLETE_TEMPLATE_IMAGES_PATH=\\\"${datadir}/eflete/themes/default/template/images\\\"
 "
 EFLETE_DEFINE+=" 
-DEFLETE_TEMPLATE_SOUNDS_PATH=\\\"${datadir}/eflete/themes/default/template/sounds\\\"
 "
diff --git a/data/Makefile.am b/data/Makefile.am
index 7d80a03..20b0966 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -15,6 +15,10 @@ EDJE_FLAGS_RESOURCES = -id 
$(top_srcdir)/data/resources/images
 filesdir = $(datadir)/eflete/themes/default
 files_DATA = eflete_elm.edj
 
+template_edjdir = $(datadir)/eflete/themes/default/template/edj
+template_edj_DATA = \
+   $(top_srcdir)/data/template/edj/*.edj
+
 template_edcdir = $(datadir)/eflete/themes/default/template/edc
 template_edc_DATA = \
    $(top_srcdir)/data/template/widgets/*.edc \
@@ -105,4 +109,4 @@ clean-local:
        rm -f *.edj *.eet
 
 EXTRA_DIST = $(aimages_DATA) $(ewe_deps) $(eflete_deps) $(eflete_elm_deps) \
-       $(color_eet_deps) $(template_edc_DATA) $(template_img_DATA) 
$(template_snd_DATA)
+       $(color_eet_deps) $(template_edj_DATA) $(template_edc_DATA) 
$(template_img_DATA) $(template_snd_DATA)
diff --git a/data/themes/default/widgets/layouts/tabs.edc 
b/data/themes/default/widgets/layouts/tabs.edc
index 384f7b5..cfdc8ad 100644
--- a/data/themes/default/widgets/layouts/tabs.edc
+++ b/data/themes/default/widgets/layouts/tabs.edc
@@ -654,153 +654,14 @@ group { name: "elm/layout/tab_home/new_project";
       }
    }
 }
-
 group { name: "elm/layout/tab_home/import_edj";
-   images {
-      image: "separator-vertical.png" COMP;
-      image: "separator-horizontal.png" COMP;
-   }
+   inherit: "elm/layout/tab_home/new_project";
    parts {
-      part { name: "elm.swallow.btn_create";
-         type: SWALLOW;
-         description {
-            align: 1.0 1.0;
-            fixed: 1 1;
-            rel1 {
-               relative: 1.0 1.0;
-            }
-            rel2 {
-               relative: 1.0 1.0;
-            }
-         }
-      }
-      part { name: "separator_hor";
-         type: IMAGE;
-         description { state: "default" 0.0;
-            min: 0 2;
-            max: -1 2;
-            align: 0.5 1.0;
-            image {
-               normal: "separator-horizontal.png";
-               middle: DEFAULT;
-            }
-            rel2 {
-               to: "elm.swallow.btn_create";
-               relative: 1.0 0.0;
-               offset: -1 -7;
-            }
-         }
-      }
-      part { name: "separator";
-         type: IMAGE;
-         description { state: "default" 0.0;
-            min: 2 0;
-            max: 2 -1;
-            image {
-               normal: "separator-vertical.png";
-               middle: DEFAULT;
-            }
-            rel2 {
-               to: "separator_hor";
-               relative: 1.0 0.0;
-               offset: -1 -7;
-            }
-         }
-      }
-      part { name: "area.project_info";
-         type: SPACER;
-         description { state: "default" 0.0;
-            rel2 {
-               relative: 0.0 1.0;
-               offset: -7 -1;
-               to_x: "separator";
-            }
-         }
-      }
-      part { name: "label.name";
-         type: TEXT;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.5;
-            color_class: "main";
-            rel1 {
-               to_x: "area.project_info";
-               to_y: "swallow.name";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to_x: "area.project_info";
-               to_y: "swallow.name";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.5;
-            }
-         }
-      }
-      part { name: "swallow.name";
-         type: SWALLOW;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.5 0.0;
-            fixed: 1 1;
-            min: 0 19;
-            max: -1 19;
-            rel1 {
-               relative: 0.3 0.0;
-               to: "area.project_info";
-            }
-            rel2 {
-               to: "area.project_info";
-            }
-         }
-      }
-      part { name: "label.path";
-         type: TEXT;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.5;
-            color_class: "main";
-            rel1 {
-               to_x: "area.project_info";
-               to_y: "swallow.path";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to_x: "area.project_info";
-               to_y: "swallow.path";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.5;
-            }
-         }
-      }
-      part { name: "swallow.path";
-         type: SWALLOW;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.5 0.0;
-            min: 0 20;
-            max: -1 20;
-            rel1 {
-               relative: 0.3 1.0;
-               offset: 0 6;
-               to_x: "area.project_info";
-               to_y: "swallow.name";
-            }
-            rel2 {
-               to_x: "area.project_info";
-            }
-         }
-      }
       part { name: "label.edj";
          type: TEXT;
          scale: 1;
          description { state: "default" 0.0;
-            align: 0.0 0.5;
+            align: 0.0 0.0;
             color_class: "main";
             rel1 {
                to_x: "area.project_info";
@@ -836,228 +697,19 @@ group { name: "elm/layout/tab_home/import_edj";
             }
          }
       }
-      part { name: "area.project_details";
-         type: SPACER;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            rel1 {
-               relative: 1.0 0.0;
-               offset: 6 0;
-               to_x: "separator";
-            }
-            rel2 {
-               to_y: "separator";
-            }
-         }
-      }
-      part { name: "label.meta_version";
-         type: TEXT;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.5;
-            color_class: "main";
-            rel1 {
-               to_x: "area.project_details";
-               to_y: "swallow.meta_version";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to_x: "area.project_details";
-               to_y: "swallow.meta_version";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.5;
-            }
-         }
-      }
       part { name: "swallow.meta_version";
-         type: SWALLOW;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 1.0 0.0;
-            min: 0 19;
-            max: -1 19;
-            rel1 {
-               relative: 0.3 0.0;
-               to: "area.project_details";
-            }
-            rel2 {
-               to: "area.project_details";
-            }
-         }
-      }
-      part { name: "area.big_fields";
-         type: SPACER;
-         scale: 1;
-         description { state: "default" 0.0;
-            rel1 {
-               relative: 0.0 1.0;
-               offset: 0 6;
-               to_x: "area.project_details";
-               to_y: "swallow.meta_version";
-            }
-            rel2 {
-               to: "area.project_details";
-            }
-         }
-      }
-      part { name: "area.meta_authors";
-         type: SPACER;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            min: 0 26;
-            rel1 {
-               to: "area.big_fields";
-            }
-            rel2 {
-               relative: 1.0 0.33;
-               to: "area.big_fields";
-            }
-         }
-      }
-      part { name: "label.meta_authors";
-         type: TEXT;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            color_class: "main";
-            rel1 {
-               to: "area.meta_authors";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to: "area.meta_authors";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.0;
-            }
-         }
-      }
-      part { name: "swallow.meta_authors";
-         type: SWALLOW;
-         scale: 1;
-         description { state: "default" 0.0;
-            rel1 {
-               relative: 0.3 0.0;
-               to_x: "area.meta_authors";
-               to_y: "area.big_fields";
-            }
-            rel2 {
-               to: "area.meta_authors";
-            }
-         }
-      }
-      part { name: "area.meta_licenses";
-         type: SPACER;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            min: 0 26;
-            rel1 {
-               relative: 0.0 1.0;
-               offset: 0 6;
-               to_x: "area.big_fields";
-               to_y: "area.meta_authors";
-            }
-            rel2 {
-               relative: 1.0 2.0;
-               to_x: "area.big_fields";
-               to_y: "area.meta_authors";
-            }
-         }
-      }
-      part { name: "label.meta_licenses";
-         type: TEXT;
-         scale: 1;
          description { state: "default" 0.0;
-            align: 0.0 0.0;
-            color_class: "main";
-            rel1 {
-               to: "area.meta_licenses";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to: "area.meta_licenses";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.0;
-            }
-         }
-      }
-      part { name: "swallow.meta_licenses";
-         type: SWALLOW;
-         scale: 1;
-         description { state: "default" 0.0;
-            rel1 {
-               relative: 0.3 0.0;
-               to: "area.meta_licenses";
-            }
-            rel2 {
-               to: "area.meta_licenses";
-            }
+            rel1.to_y: "swallow.edj";
          }
       }
-      part { name: "area.meta_comment";
-         type: SPACER;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            min: 0 26;
-            rel1 {
-               relative: 0.0 1.0;
-               offset: 0 6;
-               to_x: "area.big_fields";
-               to_y: "area.meta_licenses";
-            }
-            rel2 {
-               to: "area.big_fields";
-            }
-         }
-      }
-      part { name: "label.meta_comment";
-         type: TEXT;
-         scale: 1;
-         description { state: "default" 0.0;
-            align: 0.0 0.0;
-            color_class: "main";
-            rel1 {
-               to: "area.meta_comment";
-            }
-            rel2 {
-               relative: 0.3 1.0;
-               to: "area.meta_comment";
-            }
-            text {
-               font: "PT";
-               size: 12;
-               align: 0.0 0.0;
-            }
-         }
-      }
-      part { name: "swallow.meta_comment";
-         type: SWALLOW;
-         scale: 1;
+      part { name: "area.large_items";
          description { state: "default" 0.0;
-            rel1 {
-               relative: 0.3 0.0;
-               to: "area.meta_comment";
-            }
-            rel2 {
-               to: "area.meta_comment";
-            }
+            rel1.to_y: "swallow.meta_version";
          }
       }
    }
 }
-
+   
 group { name: "elm/layout/tab_home/import_edc";
    images {
       image: "separator-vertical.png" COMP;
diff --git a/src/bin/project_manager/group_manager.c 
b/src/bin/project_manager/group_manager.c
index 0877338..c9bdb00 100644
--- a/src/bin/project_manager/group_manager.c
+++ b/src/bin/project_manager/group_manager.c
@@ -282,6 +282,12 @@ _group_load(Project *pro, Group *group)
      {
         main_group_name = edje_edit_group_aliased_get(group->edit_object, 
group->name);
         group->main_group = pm_resource_get(pro->groups, main_group_name);
+        if (!(group->main_group))
+          {
+             group->main_group = mem_calloc(1, sizeof(Group));
+             group->main_group->name = eina_stringshare_add(main_group_name);
+             pro->groups = eina_list_append(pro->groups, group->main_group);
+          }
         group->main_group->aliases = 
eina_list_sorted_insert(group->main_group->aliases, 
(Eina_Compare_Cb)resource_cmp, group);
         edje_edit_string_free(main_group_name);
      }
@@ -419,12 +425,37 @@ gm_group_del(Project *pro, Group *group)
    free(group);
 }
 
+char *
+_get_widget_name(const Eina_Stringshare *group_name)
+{
+    int len = strlen(group_name);
+    int i;
+    char str[32];
+
+    if (group_name[0] != 'e') return NULL;
+    if (group_name[1] != 'l') return NULL;
+    if (group_name[2] != 'm') return NULL;
+    if (group_name[3] != '/') return NULL;
+
+    for (i = 4; i < len; i++)
+    {
+        if (group_name[i] == '/') break;
+        str[i - 4] = group_name[i];
+    }
+    str[i - 4] = '\0';
+
+    return strdup(str);
+}
+
 void
 gm_groups_load(Project *pro)
 {
-   Eina_List *collections, *l;
+   Eina_List *collections, *l, *wl;
    Eina_Stringshare *group_name;
+   const char *widget_name;
+   const char *checked_widget;
    Group *group;
+   Eina_Bool check;
 
    assert(pro != NULL);
    assert(pro->dev != NULL);
@@ -437,8 +468,23 @@ gm_groups_load(Project *pro)
    collections = eina_list_sort(collections, eina_list_count(collections), 
(Eina_Compare_Cb) strcmp);
    EINA_LIST_FOREACH(collections, l, group_name)
      {
+        check = false;
         if (!strcmp(group_name, EFLETE_INTERNAL_GROUP_NAME)) continue;
 
+        if (pro->widgets)
+          {
+             widget_name = _get_widget_name(group_name);
+             if (!widget_name) continue;
+             EINA_LIST_FOREACH(pro->widgets, wl, checked_widget)
+               {
+                  if (!strcmp(checked_widget, widget_name))
+                    {
+                       check = true;
+                       break;
+                    }
+               }
+             if (!check) continue;
+          }
         group = mem_calloc(1, sizeof(Group));
         group->name = eina_stringshare_add(group_name);
         pro->groups = eina_list_append(pro->groups, group);
diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index 346ce5e..978f7ae 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -66,6 +66,8 @@ typedef struct
    const char *edc;
    /** edje_cc options. Used for 'new project' and 'import from edc'. */
    const char *build_options;
+   /** The checked widgets. Used for loading just checked widgets. */
+   Eina_List *widgets;
 } Project_Thread;
 
 
@@ -73,7 +75,7 @@ typedef struct
 
 static Project_Thread worker;
 #define WORKER_CREATE(FUNC_PROGRESS, FUNC_END, DATA, PROJECT, \
-                      NAME, PATH, EDJ, EDC, BUILD_OPTIONS) \
+                      NAME, PATH, EDJ, EDC, BUILD_OPTIONS, WIDGET_LIST) \
 { \
    worker.func_progress = FUNC_PROGRESS; \
    worker.func_end = FUNC_END; \
@@ -85,6 +87,7 @@ static Project_Thread worker;
    worker.edj = eina_stringshare_add(EDJ); \
    worker.edc = eina_stringshare_add(EDC); \
    worker.build_options = eina_stringshare_add(BUILD_OPTIONS); \
+   worker.widgets = WIDGET_LIST; \
 }
 
 #define WORKER_FREE() \
@@ -165,6 +168,7 @@ _project_descriptor_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(eed_project, Project, "saved_edj", saved_edj, 
EET_T_STRING);
    EET_DATA_DESCRIPTOR_ADD_BASIC(eed_project, Project, "develop_path", 
develop_path, EET_T_STRING);
    EET_DATA_DESCRIPTOR_ADD_BASIC(eed_project, Project, "release_options", 
release_options, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_LIST_STRING(eed_project, Project, "widgets", 
widgets);
    EET_DATA_DESCRIPTOR_ADD_LIST_STRING(eed_project, Project, "images", 
res.images);
    EET_DATA_DESCRIPTOR_ADD_LIST_STRING(eed_project, Project, "sounds", 
res.sounds);
    EET_DATA_DESCRIPTOR_ADD_LIST_STRING(eed_project, Project, "fonts", 
res.fonts);
@@ -282,6 +286,7 @@ _project_files_create(void)
    pro->dev = eina_stringshare_printf("%s/%s.dev", folder_path, worker.name);
    pro->saved_edj = eina_stringshare_printf("%s/%s.edj", folder_path, 
worker.name);
    pro->develop_path = eina_stringshare_printf("%s/develop", folder_path);
+   pro->widgets = worker.widgets;
 
    pro_path = eina_stringshare_printf("%s/%s.pro", folder_path, worker.name);
    ecore_file_mkdir(pro->develop_path);
@@ -458,6 +463,7 @@ void
 pm_project_import_edj(const char *name,
                       const char *path,
                       const char *edj,
+                      Eina_List *list,
                       PM_Project_Progress_Cb func_progress,
                       PM_Project_End_Cb func_end ,
                       const void *data)
@@ -467,7 +473,7 @@ pm_project_import_edj(const char *name,
    assert(edj != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, NULL,
-                 name, path, edj, NULL, NULL);
+                 name, path, edj, NULL, NULL, list);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_project_import_edj, NULL))
@@ -574,7 +580,7 @@ pm_project_import_edc(const char *name,
    assert(edc != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, NULL,
-                 name, path, NULL, edc, import_options);
+                 name, path, NULL, edc, import_options, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_project_import_edc, NULL))
@@ -714,7 +720,7 @@ pm_project_open(const char *path,
    assert(path != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, NULL,
-                 NULL, NULL, NULL, NULL, NULL);
+                 NULL, NULL, NULL, NULL, NULL, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_project_open, eina_stringshare_add(path)))
@@ -759,7 +765,7 @@ pm_project_save(Project *project,
    assert(project != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, NULL, NULL, NULL, NULL);
+                 NULL, NULL, NULL, NULL, NULL, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_project_save, NULL))
@@ -1423,7 +1429,7 @@ pm_group_source_code_export(Project *project,
    assert(path != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, path, NULL, NULL, data);
+                 NULL, path, NULL, NULL, data, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_group_source_code_export, (void *)group))
@@ -1522,7 +1528,7 @@ pm_project_source_code_export(Project *project,
    assert(path != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, path, NULL, NULL, data);
+                 NULL, path, NULL, NULL, data, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_source_code_export, NULL))
@@ -1604,7 +1610,7 @@ pm_project_release_export(Project *project,
    assert(path != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, NULL, path, NULL, data);
+                 NULL, NULL, path, NULL, data, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_release_export, NULL))
@@ -1641,7 +1647,7 @@ pm_project_develop_export(Project *project,
    assert(path != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, NULL, path, NULL, data);
+                 NULL, NULL, path, NULL, data, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_develop_export, NULL))
@@ -1764,7 +1770,7 @@ pm_project_enventor_save(Project *project,
    assert(project != NULL);
 
    WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, NULL, NULL, NULL, NULL);
+                 NULL, NULL, NULL, NULL, NULL, NULL);
 
    if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
                            (void *)_enventor_save, NULL))
diff --git a/src/bin/project_manager/project_manager.h 
b/src/bin/project_manager/project_manager.h
index c3dc1bc..e22f909 100644
--- a/src/bin/project_manager/project_manager.h
+++ b/src/bin/project_manager/project_manager.h
@@ -73,6 +73,9 @@ struct _Project
    /** compile options for release edj file. see edje_cc reference */
    Eina_Stringshare *release_options;
 
+   /** The checked widgets. Used for loading just checked widgets. */
+   Eina_List *widgets;
+
    Eina_List *groups;
    Eina_List *images;
    Eina_List *sounds;
@@ -215,6 +218,7 @@ void
 pm_project_import_edj(const char *name,
                       const char *path,
                       const char *edj,
+                      Eina_List *list,
                       PM_Project_Progress_Cb func_progress,
                       PM_Project_End_Cb func_end,
                       const void *data) EINA_ARG_NONNULL(1, 2, 3);
diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c
index 5ebc1bc..8ccca06 100644
--- a/src/bin/ui/tab_home_import_edj.c
+++ b/src/bin/ui/tab_home_import_edj.c
@@ -26,6 +26,72 @@
 #include "project_common.h"
 #include "config.h"
 
+struct _Widget_Item_Data
+{
+   const char *name;
+   Eina_Bool check;
+};
+typedef struct _Widget_Item_Data Widget_Item_Data;
+
+static Widget_Item_Data widget_item_data[] =
+   {
+     { N_("access"),           false },
+     { N_("actionslider"),     false },
+     { N_("bg"),               false },
+     { N_("border"),           false },
+     { N_("bubble"),           false },
+     { N_("button"),           false },
+     { N_("calendar"),         false },
+     { N_("check"),            false },
+     { N_("clock"),            false },
+     { N_("colorsel"),         false },
+     { N_("conform"),          false },
+     { N_("ctxpopup"),         false },
+     { N_("cursor"),           false },
+     { N_("datetime"),         false },
+     { N_("dayselector"),      false },
+     { N_("diskselector"),     false },
+     { N_("entry"),            false },
+     { N_("fileselector"),     false },
+     { N_("flipselector"),     false },
+     { N_("focus"),            false },
+     { N_("frame"),            false },
+     { N_("gengrid"),          false },
+     { N_("genlist"),          false },
+     { N_("hover"),            false },
+     { N_("icon"),             false },
+     { N_("index"),            false },
+     { N_("label"),            false },
+     { N_("layout"),           false },
+     { N_("list"),             false },
+     { N_("map"),              false },
+     { N_("menu"),             false },
+     { N_("multibuttonentry"), false },
+     { N_("naviframe"),        false },
+     { N_("notify"),           false },
+     { N_("panel"),            false },
+     { N_("panes"),            false },
+     { N_("photo"),            false },
+     { N_("photocam"),         false },
+     { N_("player"),           false },
+     { N_("pointer"),          false },
+     { N_("popup"),            false },
+     { N_("progress"),         false },
+     { N_("radio"),            false },
+     { N_("scroller"),         false },
+     { N_("segment_control"),  false },
+     { N_("separator"),        false },
+     { N_("slider"),           false },
+     { N_("slideshow"),        false },
+     { N_("spinner"),          false },
+     { N_("thumb"),            false },
+     { N_("toolbar"),          false },
+     { N_("tooltip"),          false },
+     { N_("video"),            false },
+     { N_("win"),              false },
+     { NULL,                   false }
+   };
+
 struct _Tab_Home_Edj
 {
    Evas_Object *layout;
@@ -36,11 +102,134 @@ struct _Tab_Home_Edj
    Evas_Object *path;
    Evas_Object *edj;
    Meta_Data_Controls meta;
+
+   Evas_Object *ch_all;
+   Evas_Object *genlist;
 };
 
 typedef struct _Tab_Home_Edj Tab_Home_Edj;
 static Tab_Home_Edj tab_edj;
 
+/* CHECK ALL AND NOT ALL */
+static void
+_checks_set(Eina_Bool check_val)
+{
+   Widget_Item_Data *widget_item_data_iterator = widget_item_data;
+
+   while (widget_item_data_iterator->name)
+     {
+        if (widget_item_data_iterator->check != check_val)
+          widget_item_data_iterator->check = check_val;
+        widget_item_data_iterator++;
+     }
+   elm_genlist_realized_items_update(tab_edj.genlist);
+}
+
+static Eina_Bool
+_checked_get(void)
+{
+   Widget_Item_Data *widget_item_data_iterator = widget_item_data;
+
+   while (widget_item_data_iterator->name)
+     {
+        if (widget_item_data_iterator->check == EINA_TRUE)
+           return EINA_TRUE;
+        widget_item_data_iterator++;
+     }
+   return EINA_FALSE;
+}
+
+static void
+_validate(void *data __UNUSED__,
+          Evas_Object *obj __UNUSED__,
+          void *event_info __UNUSED__)
+{
+   if ((elm_validator_regexp_status_get(tab_edj.name_validator) != 
ELM_REG_NOERROR) ||
+       ((!eina_str_has_extension(elm_entry_entry_get(tab_edj.edj), ".edj") ||
+       !ecore_file_exists(elm_entry_entry_get(tab_edj.edj))) &&
+       !_checked_get()))
+     elm_object_disabled_set(tab_edj.btn_create, true);
+   else
+     elm_object_disabled_set(tab_edj.btn_create, false);
+
+}
+
+static void
+_edj_set()
+{
+   Eina_Bool checked = _checked_get();
+
+   if (checked) elm_entry_entry_set(tab_edj.edj, 
EFLETE_TEMPLATE_EDJ_PATH"/default.edj");
+   else elm_entry_entry_set(tab_edj.edj, "");
+   elm_object_disabled_set(tab_edj.edj, checked);
+
+   _validate(NULL, NULL, NULL);
+}
+
+static void
+_on_check_all(void *data __UNUSED__,
+              Evas_Object *obj,
+              void *event_info __UNUSED__)
+{
+   _checks_set(elm_check_state_get(obj));
+   _edj_set();
+}
+
+/*  GENLIST  */
+static void
+_check_widget(void *data,
+              Evas_Object *obj,
+              void *event_info __UNUSED__)
+{
+   Widget_Item_Data *widget_data = (Widget_Item_Data *)data;
+   assert(widget_data != NULL);
+   widget_data->check = elm_check_state_get(obj);
+   _edj_set();
+}
+
+static char *
+_genlist_label_get(void *data,
+                   Evas_Object *obj __UNUSED__,
+                   const char  *part __UNUSED__)
+{
+   Widget_Item_Data *widget_data = (Widget_Item_Data *)data;
+   assert(widget_data != NULL);
+   return strdup(widget_data->name);
+}
+
+static Evas_Object *
+_genlist_content_get(void *data,
+                     Evas_Object *obj __UNUSED__,
+                     const char *part)
+{
+   Evas_Object *check;
+   Widget_Item_Data *widget_data = (Widget_Item_Data *)data;
+   if (strcmp(part, "elm.swallow.icon")) return NULL;
+
+   /* the old hack. sometimes edje get wrong style, from system defalt theme,
+    * for changed widget if widget is hidden */
+   TODO("find why load wrong style");
+   CHECK_ADD(ap.win, check);
+   elm_object_focus_allow_set(check, false);
+   elm_check_state_set(check, widget_data->check);
+   evas_object_smart_callback_add(check, "changed", _check_widget, data);
+   return check;
+}
+
+static void
+_on_item_activated(void *data __UNUSED__,
+                   Evas_Object *obj __UNUSED__,
+                   void *event_info)
+{
+   Elm_Object_Item *it = (Elm_Object_Item *)event_info;
+   Widget_Item_Data *widget_data = elm_object_item_data_get(it);
+
+   assert(widget_data != NULL);
+
+   widget_data->check = !widget_data->check;
+   elm_genlist_item_update(it);
+}
+
 static void
 _progress_end(void *data, PM_Project_Result result)
 {
@@ -58,12 +247,33 @@ _progress_end(void *data, PM_Project_Result result)
    _tabs_progress_end(data, result);
 }
 
+Eina_List *
+_checked_widget_list_get()
+{
+   Widget_Item_Data *widget_item_data_iterator = widget_item_data;
+   Eina_List *list = NULL;
+
+   while (widget_item_data_iterator->name)
+     {
+        if (widget_item_data_iterator->check)
+          {
+             list = eina_list_append(list, widget_item_data_iterator->name);
+          }
+        widget_item_data_iterator++;
+     }
+
+     return list;
+}
+
 static Eina_Bool
 _setup_open_splash(void *data __UNUSED__, Splash_Status status __UNUSED__)
 {
+   Eina_List *checked_widgets = _checked_widget_list_get();
+
    pm_project_import_edj(elm_entry_entry_get(tab_edj.name),
                          elm_entry_entry_get(tab_edj.path),
                          elm_entry_entry_get(tab_edj.edj),
+                         checked_widgets,
                          progress_print,
                          _progress_end,
                          &tab_edj.meta);
@@ -123,19 +333,6 @@ _import(void *data __UNUSED__,
 }
 
 static void
-_validate(void *data __UNUSED__,
-          Evas_Object *obj __UNUSED__,
-          void *event_info __UNUSED__)
-{
-   if ((elm_validator_regexp_status_get(tab_edj.name_validator) != 
ELM_REG_NOERROR) ||
-       !eina_str_has_extension(elm_entry_entry_get(tab_edj.edj), ".edj") ||
-       !ecore_file_exists(elm_entry_entry_get(tab_edj.edj)))
-     elm_object_disabled_set(tab_edj.btn_create, true);
-   else
-     elm_object_disabled_set(tab_edj.btn_create, false);
-}
-
-static void
 _elipsis(void *data __UNUSED__,
          Evas_Object *obj __UNUSED__,
          void *event_info __UNUSED__)
@@ -166,6 +363,9 @@ _elipsis_edj(void *data __UNUSED__,
 Evas_Object *
 _tab_import_edj_add(void)
 {
+   Elm_Genlist_Item_Class *itc = NULL;
+   Widget_Item_Data *widget_item_data_iterator = widget_item_data;
+
    tab_edj.name_validator = elm_validator_regexp_new(NAME_REGEX, NULL);
 
    tab_edj.layout = elm_layout_add(ap.win);
@@ -200,6 +400,29 @@ _tab_import_edj_add(void)
 
    evas_object_event_callback_add(tab_edj.layout, EVAS_CALLBACK_SHOW, 
_tab_default_focus, tab_edj.name);
 
+   /* check all */
+   CHECK_ADD(tab_edj.layout, tab_edj.ch_all);
+   evas_object_smart_callback_add(tab_edj.ch_all, "changed", _on_check_all, 
NULL);
+   elm_object_part_content_set(tab_edj.layout, "swallow.all_widgets_check", 
tab_edj.ch_all);
+   elm_object_part_text_set(tab_edj.layout, "label.widgets", _("Widgets:"));
+
+   /* genlist */
+   tab_edj.genlist = elm_genlist_add(ap.win);
+   evas_object_smart_callback_add(tab_edj.genlist, "activated", 
_on_item_activated, NULL);
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default";
+   itc->func.text_get = _genlist_label_get;
+   itc->func.content_get = _genlist_content_get;
+
+   while (widget_item_data_iterator->name)
+     {
+        elm_genlist_item_append(tab_edj.genlist, itc, 
widget_item_data_iterator,
+                                NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+        widget_item_data_iterator++;
+     }
+   elm_genlist_item_class_free(itc);
+   elm_object_part_content_set(tab_edj.layout, "swallow.widgets", 
tab_edj.genlist);
+
    return tab_edj.layout;
 }
 

-- 


Reply via email to