rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=88ee00e180771183705195751fbb7ef980d41d09
commit 88ee00e180771183705195751fbb7ef980d41d09 Author: Vyacheslav Reutskiy <v.reuts...@samsung.com> Date: Thu Oct 27 10:47:20 2016 +0300 project_close: rework save feature Early was added the two options --export-edj and --export-edc for Eflete. But this feature was not compleated, and was exported edj and edc on save only if application configured with --enable-tizen. This patch is complete this feature for both modes: normal and tizen. Now if set --export-edj or --export-edc project data will be exported by given path. Change-Id: Ic00f9922e84161dd5b5565e07a53504105a8a4d7 --- src/bin/main.c | 26 ++++++++++++- src/bin/ui/project_close.c | 89 ++++++++++++++++++++++++++++----------------- src/bin/ui/project_export.c | 46 +++-------------------- 3 files changed, 85 insertions(+), 76 deletions(-) diff --git a/src/bin/main.c b/src/bin/main.c index 62761d8..8592581 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -340,10 +340,32 @@ elm_main(int argc, char **argv) else if (widgets) _ERR_EXIT(_("widgets can be added only to new project.")); } + if (export_edj) + { + if (!eina_str_has_suffix(file, ".edj")) + _ERR_EXIT(_("--export-edj value have not extension '.edj'. Wrong value.")); + } run: - ap.path.export_edj = export_edj; - ap.path.export_edc = export_edc; + if (export_edj) + { + int i; + char *name = NULL; + char buf[BUFF_MAX]; + + char **arr = eina_str_split(export_edj, "/", 0); + for(i = 0; arr[i] != NULL; i++) + name = arr[i]; + strncpy(buf, export_edj, strlen(export_edj) - strlen(name)); + ecore_file_mkpath(buf); + + ap.path.export_edj = eina_stringshare_add(export_edj); + } + if (export_edc) + { + ecore_file_mkpath(export_edc); + ap.path.export_edc = eina_stringshare_add(export_edc); + } evas_object_show(ap.win); elm_run(); exit: diff --git a/src/bin/ui/project_close.c b/src/bin/ui/project_close.c index c16494c..146f004 100644 --- a/src/bin/ui/project_close.c +++ b/src/bin/ui/project_close.c @@ -21,8 +21,8 @@ #include "tabs.h" #include "project_manager2.h" #include "project_navigator.h" +#include "project_common.h" -#ifndef HAVE_TIZEN static Eina_Bool _progress_print(void *data __UNUSED__, Eina_Stringshare *progress_string) { @@ -32,35 +32,64 @@ _progress_print(void *data __UNUSED__, Eina_Stringshare *progress_string) } static void -_progress_end(void *data __UNUSED__, PM_Project_Result result, Project *project __UNUSED__) +_progress_export_edj_end(void *data __UNUSED__, PM_Project_Result result, Project *project __UNUSED__) { + char buf[BUFF_MAX]; - switch (result) + if (ap.path.export_edc) { - case PM_PROJECT_ERROR: - { - ERR(_("Error: project not saved.")); - break; - } - case PM_PROJECT_CANCEL: - { - INFO(_("Saving canceled.")); - break; - } - case PM_PROJECT_SUCCESS: - { - ap.project->changed = false; - break; - } - default: - { - ERR("Wrong result"); - abort(); - } + Eina_List *groups = tabs_open_groups_get(); + result = pm_group_source_code_export(ap.project, groups, ap.path.export_edc, + _progress_print, progress_end, NULL); + eina_list_free(groups); + if (PM_PROJECT_SUCCESS != result) + { + snprintf(buf, sizeof(buf), "Warning: %s", pm_project_result_string_get(result)); + popup_add(_("Export source code"), NULL, BTN_CANCEL, NULL, NULL); + } + return; } + progress_end(NULL, result, NULL); +} - splash_del(ap.splash); - ap.splash = NULL; +static void +_progress_save_end(void *data __UNUSED__, PM_Project_Result result, Project *project __UNUSED__) +{ + char buf[BUFF_MAX]; + + if (PM_PROJECT_SUCCESS == result) + { + ap.project->changed = false; + if (ap.path.export_edj) + { + Eina_List *groups = tabs_open_groups_get(); + result = pm_project_develop_export(ap.project, ap.path.export_edj, groups, + _progress_print, _progress_export_edj_end, NULL); + eina_list_free(groups); + if (PM_PROJECT_SUCCESS != result) + { + snprintf(buf, sizeof(buf), "Warning: %s", pm_project_result_string_get(result)); + popup_add(_("Export develop edj"), NULL, BTN_CANCEL, NULL, NULL); + } + return; + } + + if (ap.path.export_edc) + { + Eina_List *groups = tabs_open_groups_get(); + result = pm_group_source_code_export(ap.project, groups, ap.path.export_edc, + _progress_print, progress_end, NULL); + eina_list_free(groups); + if (PM_PROJECT_SUCCESS != result) + { + snprintf(buf, sizeof(buf), "Warning: %s", pm_project_result_string_get(result)); + popup_add(_("Export source code"), NULL, BTN_CANCEL, NULL, NULL); + return; + } + } + return; + } + progress_end(NULL, result, NULL); } static Eina_Bool @@ -71,7 +100,7 @@ _setup_save_splash(void *data, Splash_Status status __UNUSED__) result = pm_project_save(ap.project, _progress_print, - _progress_end, + _progress_save_end, data); if (PM_PROJECT_SUCCESS != result) { @@ -104,7 +133,6 @@ _teardown_save_splash(void *data __UNUSED__, Splash_Status status) return true; } -#endif /* HAVE_TIZEN */ void project_save(void) @@ -114,16 +142,9 @@ project_save(void) if (!ap.project->changed) return; if (ap.splash) return; -#ifndef HAVE_TIZEN ap.splash = splash_add(ap.win, _setup_save_splash, _teardown_save_splash, NULL, NULL); evas_object_focus_set(ap.splash, true); evas_object_show(ap.splash); -#else - if (ap.path.export_edj) - project_export_develop(); - if (ap.path.export_edc) - project_export_edc_project(tabs_open_groups_get()); -#endif /* HAVE_TIZEN */ ui_menu_disable_set(ap.menu, MENU_FILE_SAVE, true); } diff --git a/src/bin/ui/project_export.c b/src/bin/ui/project_export.c index 1b92d5c..18fce43 100644 --- a/src/bin/ui/project_export.c +++ b/src/bin/ui/project_export.c @@ -42,16 +42,11 @@ _export_develop_setup(void *data, Splash_Status status __UNUSED__) char buf[PATH_MAX]; PM_Project_Result result; const char *path = (const char *)data; - Eina_List *groups = NULL; assert(path != NULL); -#ifdef HAVE_TIZEN - groups = tabs_open_groups_get(); -#endif /* HAVE_TIZEN */ - result = pm_project_develop_export(ap.project, path, groups, + result = pm_project_develop_export(ap.project, path, NULL, progress_print, progress_end, NULL); - eina_list_free(groups); if (PM_PROJECT_SUCCESS != result) { snprintf(buf, sizeof(buf), "Warning: %s", pm_project_result_string_get(result)); @@ -78,8 +73,6 @@ _after_export_dev_check(void *data) ap.splash = splash_add(ap.win, _export_develop_setup, _export_teardown, NULL, data); evas_object_focus_set(ap.splash, true); evas_object_show(ap.splash); - if (!ap.path.export_edj) - popup_fileselector_helper_dismiss(); } static Eina_Bool @@ -114,8 +107,7 @@ _export_dev(void *data __UNUSED__, for(i = 0; arr[i] != NULL; i++) name = arr[i]; strncpy(pp, path, strlen(path) - strlen(name)); - if (ap.path.export_edj) - ecore_file_mkpath(pp); + ecore_file_mkpath(pp); exist_permission_check(pp, name, _("Export to develop edj-file"), @@ -133,15 +125,7 @@ project_export_develop(void) { Eina_Strbuf *buf; - if (!ap.path.export_edj) - popup_fileselector_edj_helper("Export to develop edj-file", NULL, NULL, _export_dev, NULL, false, true); - else - { - Eina_List *l = NULL; - l = eina_list_append(l, ap.path.export_edj); - _export_dev(NULL, NULL, l); - eina_list_free(l); - } + popup_fileselector_edj_helper("Export to develop edj-file", NULL, NULL, _export_dev, NULL, false, true); buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s-develop.edj", ap.project->name); @@ -176,8 +160,6 @@ _after_export_release_check(void *data) NULL, data); evas_object_focus_set(ap.splash, true); evas_object_show(ap.splash); - if (!ap.path.export_edj) - popup_fileselector_helper_dismiss(); } static Eina_Bool @@ -220,15 +202,7 @@ project_export_release(void) { Eina_Strbuf *buf; - if (!ap.path.export_edj) - popup_fileselector_edj_helper("Export to release edj-file", NULL, NULL, _export_release, NULL, false, true); - else - { - Eina_List *l = NULL; - l = eina_list_append(l, ap.path.export_edj); - _export_dev(NULL, NULL, l); - eina_list_free(l); - } + popup_fileselector_edj_helper("Export to release edj-file", NULL, NULL, _export_release, NULL, false, true); buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s-release.edj", ap.project->name); @@ -252,7 +226,7 @@ _export_source_code_setup(void *data, Splash_Status status __UNUSED__) if (PM_PROJECT_SUCCESS != result) { snprintf(buf, sizeof(buf), "Warning: %s", pm_project_result_string_get(result)); - popup_add(_("Export surce code"), NULL, BTN_CANCEL, NULL, NULL); + popup_add(_("Export source code"), NULL, BTN_CANCEL, NULL, NULL); return false; } return true; @@ -305,15 +279,7 @@ _export_source_code(void *data, void project_export_edc_project(Eina_List *groups) { - if (!ap.path.export_edc) - popup_fileselector_folder_helper("Export source code", NULL, NULL, _export_source_code, groups, false, false); - else - { - Eina_List *l = NULL; - l = eina_list_append(l, ap.path.export_edc); - _export_source_code(groups, NULL, l); - eina_list_free(l); - } + popup_fileselector_folder_helper("Export source code", NULL, NULL, _export_source_code, groups, false, false); } static Eina_Bool --