jaehwan pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=d67c52be9a51d0736f5f02dd97332b57a15a06ea
commit d67c52be9a51d0736f5f02dd97332b57a15a06ea Author: Jaehwan Kim <jae.hwan....@samsung.com> Date: Thu Jul 7 17:36:01 2016 +0900 export: export edj with only used groups and add append feature. export edj file with only used groups. If any group is not used in current project, it isn't included in saved edj. And if we set the exist file name to export, it is possible that current groups are appended into the edj file. @feature --- src/bin/project_manager/project_manager.c | 64 +++++++++++++++++++++++++++++-- src/bin/ui/main_window.h | 3 +- src/bin/ui/popup.c | 13 ++++++- src/bin/ui/project_common.c | 13 +++++-- src/bin/ui/project_common.h | 2 +- src/bin/ui/project_export.c | 8 ++-- src/bin/ui/tab_home_import_edc.c | 2 +- src/bin/ui/tab_home_import_edj.c | 2 +- src/bin/ui/tab_home_new.c | 2 +- 9 files changed, 91 insertions(+), 18 deletions(-) diff --git a/src/bin/project_manager/project_manager.c b/src/bin/project_manager/project_manager.c index ab86e0d..48d9bfd 100644 --- a/src/bin/project_manager/project_manager.c +++ b/src/bin/project_manager/project_manager.c @@ -374,6 +374,7 @@ _project_edj_file_copy(void) src = eina_stringshare_ref(worker.edj); dst = eina_stringshare_ref(worker.project->saved_edj); result = ecore_file_cp(src, dst); + DBG("Copy the .edj file to project folder."); eina_stringshare_del(src); eina_stringshare_del(dst); @@ -1658,12 +1659,69 @@ static void * _develop_export(void *data __UNUSED__, Eina_Thread *thread __UNUSED__) { + Ecore_Event_Handler *cb_msg_stdout = NULL, + *cb_msg_stderr = NULL; + Ecore_Exe_Flags flags = ECORE_EXE_PIPE_READ | + ECORE_EXE_PIPE_READ_LINE_BUFFERED | + ECORE_EXE_PIPE_ERROR | + ECORE_EXE_PIPE_ERROR_LINE_BUFFERED; + Eina_Tmpstr *tmp_filename = NULL; + Eina_Stringshare *cmd; + Eina_List *l; + Group *group; + Ecore_Exe *exe_cmd; + pid_t exe_pid; + int edje_pick_res = 0, waitpid_res = 0; + PROGRESS_SEND(_("Export project as develop file")); PROGRESS_SEND(_("Export to file '%s'"), worker.edj); CRIT_ON_FAIL(editor_save_all(worker.project->global_object)); - eina_file_copy(worker.project->dev, worker.edj, - EINA_FILE_COPY_PERMISSION | EINA_FILE_COPY_XATTR, - NULL, NULL); + + if (worker.func_progress) + { + cb_msg_stdout = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _exe_data, NULL); + cb_msg_stderr = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_data, NULL); + } + + if (!ecore_file_exists(worker.edj)) + cmd = eina_stringshare_printf("edje_pick -o %s", worker.edj); + else + { + eina_file_mkstemp("eflete_export_XXXXXX", &tmp_filename); + cmd = eina_stringshare_printf("edje_pick -o %s", tmp_filename); + cmd = eina_stringshare_printf("%s -a %s", cmd, worker.edj); + } + cmd = eina_stringshare_printf("%s -i %s", cmd, worker.project->dev); + + EINA_LIST_FOREACH(worker.project->groups, l, group) + { + cmd = eina_stringshare_printf("%s -g %s", cmd, group->name); + } + DBG("Run command for export: %s", cmd); + exe_cmd = ecore_exe_pipe_run(cmd, flags, NULL); + exe_pid = ecore_exe_pid_get(exe_cmd); + THREAD_TESTCANCEL; + waitpid_res = waitpid(exe_pid, &edje_pick_res, 0); + + if (worker.func_progress) + { + ecore_event_handler_del(cb_msg_stdout); + ecore_event_handler_del(cb_msg_stderr); + } + + if ((waitpid_res == -1) || + (WIFEXITED(edje_pick_res) && (WEXITSTATUS(edje_pick_res) != 0 ))) + { + END_SEND(PM_PROJECT_ERROR); + return NULL; + } + + if (tmp_filename) + { + ecore_file_recursive_rm(worker.edj); + ecore_file_mv(tmp_filename, worker.edj); + } + PROGRESS_SEND("Export done"); END_SEND(PM_PROJECT_SUCCESS); diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h index 2c56780..6de173a 100644 --- a/src/bin/ui/main_window.h +++ b/src/bin/ui/main_window.h @@ -143,7 +143,8 @@ typedef enum _Popup_Button BTN_CANCEL = (1 << 1), BTN_SAVE = (1 << 2), BTN_DONT_SAVE = (1 << 3), - BTN_REPLACE = (1 << 4) + BTN_REPLACE = (1 << 4), + BTN_APPEND = (1 << 5) } Popup_Button; /** diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index 39b5ce2..0f8cf8d 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -31,6 +31,7 @@ static void* func_data; static const Popup_Button _btn_ok = BTN_OK; static const Popup_Button _btn_save = BTN_SAVE; +static const Popup_Button _btn_append = BTN_APPEND; static const Popup_Button _btn_replace = BTN_REPLACE; static const Popup_Button _btn_dont_save = BTN_DONT_SAVE; static const Popup_Button _btn_cancel = BTN_CANCEL; @@ -73,7 +74,8 @@ _btn_cb(void *data, void *ei __UNUSED__) { btn_pressed = *((Popup_Button *)data); - if ((BTN_OK == btn_pressed) || (BTN_SAVE == btn_pressed) || (BTN_REPLACE == btn_pressed)) + if ((BTN_OK == btn_pressed) || (BTN_SAVE == btn_pressed) || + (BTN_REPLACE == btn_pressed) || (BTN_APPEND == btn_pressed)) if (validator && (!validator(user_data))) return; eflete_main_loop_quit(); } @@ -114,7 +116,12 @@ popup_want_action(const char *title, if (popup_btns & BTN_SAVE) BTN_ADD(_("Save"), "button1", &_btn_save) - if (popup_btns & BTN_REPLACE) + if (popup_btns & BTN_APPEND) + BTN_ADD(_("Append"), "button1", &_btn_append) + + if ((popup_btns & BTN_REPLACE) && (popup_btns & BTN_APPEND)) + BTN_ADD(_("Replace"), "button2", &_btn_replace) + else if (popup_btns & BTN_REPLACE) BTN_ADD(_("Replace"), "button1", &_btn_replace) if (popup_btns & BTN_DONT_SAVE) @@ -122,6 +129,8 @@ popup_want_action(const char *title, if ((popup_btns & BTN_CANCEL) && (popup_btns & BTN_DONT_SAVE)) BTN_ADD(_("Cancel"), "button3", &_btn_cancel) + else if ((popup_btns & BTN_CANCEL) && (popup_btns & BTN_APPEND)) + BTN_ADD(_("Cancel"), "button3", &_btn_cancel) else if (popup_btns & BTN_CANCEL) BTN_ADD(_("Cancel"), "button2", &_btn_cancel) diff --git a/src/bin/ui/project_common.c b/src/bin/ui/project_common.c index cac3780..08efce3 100644 --- a/src/bin/ui/project_common.c +++ b/src/bin/ui/project_common.c @@ -22,7 +22,7 @@ Eina_Bool exist_permission_check(const char *path, const char *name, - const char *title, const char *msg) + const char *title, const char *msg, Eina_Bool append) { Eina_Strbuf *buf, *buf_msg; Popup_Button btn_res; @@ -44,8 +44,12 @@ exist_permission_check(const char *path, const char *name, buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s/%s", path, name); if (!ecore_file_exists(eina_strbuf_string_get(buf))) return true; - btn_res = popup_want_action(title, msg, NULL, - BTN_REPLACE | BTN_CANCEL, NULL, NULL); + if (!append) + btn_res = popup_want_action(title, msg, NULL, + BTN_REPLACE | BTN_CANCEL, NULL, NULL); + else + btn_res = popup_want_action(title, msg, NULL, + BTN_APPEND | BTN_REPLACE | BTN_CANCEL, NULL, NULL); if (btn_res == BTN_CANCEL) return false; if (!ecore_file_can_write(eina_strbuf_string_get(buf))) { @@ -55,7 +59,8 @@ exist_permission_check(const char *path, const char *name, eina_strbuf_free(buf_msg); return false; } - ecore_file_recursive_rm(eina_strbuf_string_get(buf)); + if (btn_res == BTN_REPLACE) + ecore_file_recursive_rm(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return true; } diff --git a/src/bin/ui/project_common.h b/src/bin/ui/project_common.h index 33e17f7..65aa1fc 100644 --- a/src/bin/ui/project_common.h +++ b/src/bin/ui/project_common.h @@ -21,7 +21,7 @@ #define PROJECT_COMMON_H Eina_Bool -exist_permission_check(const char *path, const char *name, const char *title, const char *msg); +exist_permission_check(const char *path, const char *name, const char *title, const char *msg, Eina_Bool append); Eina_Bool progress_print(void *data, Eina_Stringshare *progress_string); diff --git a/src/bin/ui/project_export.c b/src/bin/ui/project_export.c index 6c8af49..8d57cf6 100644 --- a/src/bin/ui/project_export.c +++ b/src/bin/ui/project_export.c @@ -68,7 +68,7 @@ _export_dev(void *data __UNUSED__, if (!exist_permission_check(elm_fileselector_path_get(obj), elm_fileselector_current_name_get(obj), _("Export to develop edj-file"), - eina_strbuf_string_get(buf))) + eina_strbuf_string_get(buf), EINA_TRUE)) return false; eina_strbuf_free(buf); @@ -132,7 +132,7 @@ _export_release(void *data __UNUSED__, if (!exist_permission_check(elm_fileselector_path_get(obj), elm_fileselector_current_name_get(obj), _("Export to release edj-file"), - eina_strbuf_string_get(buf))) + eina_strbuf_string_get(buf), EINA_FALSE)) return false; eina_strbuf_free(buf); @@ -186,7 +186,7 @@ _export_source_code(void *data __UNUSED__, if (!exist_permission_check(path, ap.project->name, _("Export to develop edj-file"), - eina_strbuf_string_get(buf))) + eina_strbuf_string_get(buf), EINA_FALSE)) return false; eina_strbuf_free(buf); @@ -244,7 +244,7 @@ _export_group_source_code(void *data __UNUSED__, path, name); if (!exist_permission_check(path, name, _("Export group source code"), - eina_strbuf_string_get(buf))) + eina_strbuf_string_get(buf), EINA_FALSE)) return false; eina_strbuf_free(buf); free(name); diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c index a063c51..10276a3 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -446,7 +446,7 @@ _import(void *data __UNUSED__, if (!exist_permission_check(elm_entry_entry_get(tab_edc.path), elm_entry_entry_get(tab_edc.name), - _("Import edc-file"), eina_strbuf_string_get(buf))) + _("Import edc-file"), eina_strbuf_string_get(buf), EINA_FALSE)) return; eina_strbuf_free(buf); ap.splash = splash_add(ap.win, diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index f969274..8442c75 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -527,7 +527,7 @@ _import(void *data __UNUSED__, if (!exist_permission_check(elm_entry_entry_get(tab_edj.path), elm_entry_entry_get(tab_edj.name), - _("Import edj-file"), eina_strbuf_string_get(buf))) + _("Import edj-file"), eina_strbuf_string_get(buf), EINA_FALSE)) return; eina_strbuf_free(buf); ap.splash = splash_add(ap.win, diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index 0072ddd..d52e05d 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -534,7 +534,7 @@ _on_create(void *data __UNUSED__, if (!exist_permission_check(elm_entry_entry_get(tab_new.path), elm_entry_entry_get(tab_new.name), - _("New project"), eina_strbuf_string_get(buf))) + _("New project"), eina_strbuf_string_get(buf), EINA_FALSE)) return; eina_strbuf_free(buf); ap.splash = splash_add(ap.win, --