rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=14dd16ea8a2ddfeda518e8ea3a1fddb9b0bcdc84

commit 14dd16ea8a2ddfeda518e8ea3a1fddb9b0bcdc84
Author: Vyacheslav Reutskiy <v.reuts...@samsung.com>
Date:   Tue Jan 5 10:01:23 2016 +0200

    project_manager: implement the group source code export
    
    Do export to given folder, and create folder with group name, but
    all symbols '/' are replaced to '_'. This folder consist the
    generated.edc file with group source code, also folders 'images',
    'sounds, 'fonts' if it's used in group.
    
    Change-Id: I14699e792739de90f01c006e9b84ea6f7ee28a7e
---
 src/bin/project_manager/project_manager.c | 149 +++++++++++++++++++++++-------
 src/bin/project_manager/project_manager.h |  22 +++--
 2 files changed, 131 insertions(+), 40 deletions(-)

diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index d13f383..6b7e9e0 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -1370,37 +1370,6 @@ pm_project_resource_export(Project *pro __UNUSED__, 
const char* dir_path __UNUSE
    return false;
 }
 
-TODO("rewrite this")
-/*
-Eina_Bool
-pm_project_style_source_code_export(Project *pro, Style *style, const char 
*file)
-{
-   Eina_Stringshare *code = NULL;
-   Eina_Stringshare *path = NULL;
-   FILE *f;
-
-   assert(pro != NULL);
-   assert(style != NULL);
-   assert(style->obj != NULL);
-
-   if (file) path = eina_stringshare_add(file);
-   else path = eina_stringshare_printf("%s/tmp.edc", pro->develop_path);
-   f = fopen(path, "w");
-   if (!f)
-     {
-        ERR("Could't open file '%s'", path);
-        eina_stringshare_del(path);
-        return false;
-     }
-   code = edje_edit_source_generate(style->obj);
-   fputs(code, f);
-   fclose(f);
-
-   eina_stringshare_del(code);
-   eina_stringshare_del(path);
-   return true;
-}
-*/
 static void
 _external_resources_export(Eina_List *resources, const char *dst)
 {
@@ -1440,6 +1409,124 @@ _external_resource_export(Eina_List *resources, 
Eina_Stringshare *name, const ch
 }
 
 static void *
+_group_source_code_export(void *data, Eina_Thread *thread __UNUSED__)
+{
+   Eina_Stringshare *code;
+   FILE *f;
+   Group *group = (Group *)data;
+   Part *part;
+   State *state;
+   Eina_List *l, *ls;
+   Eina_Stringshare *resource;
+   Resource *res;
+   Eina_Strbuf *buf;
+   char *name;
+
+   PROGRESS_SEND(_("Generate group '%s' source code ..."), group->name);
+
+   name = strdup(group->name);
+   string_char_replace(name, '/', '_');
+   buf = eina_strbuf_new();
+   eina_strbuf_append_printf(buf, "%s/%s", worker.path, name);
+   ecore_file_mkdir(eina_strbuf_string_get(buf));
+   eina_strbuf_reset(buf);
+
+   /* create and open file for collect the group source code */
+   eina_strbuf_append_printf(buf, "%s/%s/generated.edc", worker.path, name);
+   f = fopen(eina_strbuf_string_get(buf), "w");
+   if (!f)
+     {
+        ERR("Could't open file '%s'", eina_strbuf_string_get(buf))
+        END_SEND(PM_PROJECT_ERROR);
+        goto exit;
+     }
+
+   /* get the full source code of given project */
+   ecore_thread_main_loop_begin();
+   code = edje_edit_source_generate(group->edit_object);
+   ecore_thread_main_loop_end();
+
+   fputs(code, f);
+   edje_edit_string_free(code);
+   fclose(f);
+
+   /* export images and fonts in accordance with parts  */
+   EINA_LIST_FOREACH(group->parts, l, part)
+     {
+        if (part->type == EDJE_PART_TYPE_IMAGE)
+          {
+             PROGRESS_SEND(_("Export images ..."));
+             eina_strbuf_reset(buf);
+             eina_strbuf_append_printf(buf, "%s/%s/images/", worker.path, 
name);
+             ecore_file_mkdir(eina_strbuf_string_get(buf));
+             EINA_LIST_FOREACH(part->states, ls, state)
+               {
+                  resource = edje_edit_state_image_get(group->edit_object, 
part->name, state->parsed_name, state->parsed_val);
+                  PROGRESS_SEND(_("Export image '%s'"), resource);
+                  _external_resource_export(worker.project->images, resource, 
eina_strbuf_string_get(buf));
+                  eina_stringshare_del(resource);
+               }
+          }
+        if (part->type == EDJE_PART_TYPE_TEXT)
+          {
+             PROGRESS_SEND(_("Export fonts ..."));
+             eina_strbuf_reset(buf);
+             eina_strbuf_append_printf(buf, "%s/%s/fonts/", worker.path, name);
+             ecore_file_mkdir(eina_strbuf_string_get(buf));
+             EINA_LIST_FOREACH(part->states, ls, state)
+               {
+                  resource = edje_edit_state_font_get(group->edit_object, 
part->name, state->parsed_name, state->parsed_val);
+                  PROGRESS_SEND(_("Export font '%s'"), resource);
+                  _external_resource_export(worker.project->fonts, resource, 
eina_strbuf_string_get(buf));
+                  eina_stringshare_del(resource);
+               }
+          }
+     }
+   PROGRESS_SEND(_("Export sounds ..."));
+   EINA_LIST_FOREACH(group->programs, l, res)
+     {
+        resource = edje_edit_program_sample_name_get(group->edit_object, 
res->name);
+        if (!resource) continue;
+
+        eina_strbuf_reset(buf);
+        eina_strbuf_append_printf(buf, "%s/%s/sounds/", worker.path, name);
+        ecore_file_mkdir(eina_strbuf_string_get(buf));
+        PROGRESS_SEND(_("Export sound '%s'"), res->name);
+        _external_resource_export(worker.project->sounds, resource, 
eina_strbuf_string_get(buf));
+        eina_stringshare_del(resource);
+     }
+
+   END_SEND(PM_PROJECT_SUCCESS);
+exit:
+   eina_strbuf_free(buf);
+   free(name);
+   return NULL;
+}
+
+void
+pm_group_source_code_export(Project *project,
+                            Group *group,
+                            const char *path,
+                            PM_Project_Progress_Cb func_progress,
+                            PM_Project_End_Cb func_end,
+                            const void *data)
+{
+   assert(project != NULL);
+   assert(group != NULL);
+   assert(path != NULL);
+
+   WORKER_CREATE(func_progress, func_end, data, project,
+                 NULL, path, NULL, NULL, data);
+
+   if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
+                           (void *)_group_source_code_export, (void *)group))
+     {
+        ERR("System error: can't create thread");
+        abort();
+     }
+}
+
+static void *
 _source_code_export(void *data __UNUSED__, Eina_Thread *thread __UNUSED__)
 {
    Eina_Stringshare *code;
diff --git a/src/bin/project_manager/project_manager.h 
b/src/bin/project_manager/project_manager.h
index 2f064e4..e35aab9 100644
--- a/src/bin/project_manager/project_manager.h
+++ b/src/bin/project_manager/project_manager.h
@@ -416,20 +416,24 @@ Eina_Bool
 pm_project_resource_export(Project *pro, const char* dir_path);
 
 /**
- * Export the source code of Style (edje object) to file.
- * If file is NULL, file will be saved to develop folder of project by name
- * "tmp.edc"
+ * Export the source code of Group (edje object) to file.
  *
  * @param pro The opened project;
- * @param style The style to save the source code;
- * @param file The file for save.
- *
- * @return EINA_TRUE on success, otherwise EINA_FALSE.
+ * @param group The group to save the source code;
+ * @param path The path for export source code;
+ * @param func_progress The user func for print export progress;
+ * @param func_end The user func for handle the end of export;
+ * @param data The user data;
  *
  * @ingroup ProjectManager.
  */
-//Eina_Bool
-//pm_project_style_source_code_export(Project *pro, Style *style, const char 
*file);
+void
+pm_group_source_code_export(Project *project,
+                            Group *group,
+                            const char *path,
+                            PM_Project_Progress_Cb func_progress,
+                            PM_Project_End_Cb func_end,
+                            const void *data);
 
 /**
  * Export the source code of Project (for each style edje objects) to a 
directory

-- 


Reply via email to