rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=1de7b7ef5951231cae052d5ef4c9d595d73399e5
commit 1de7b7ef5951231cae052d5ef4c9d595d73399e5 Author: Vyacheslav Reutskiy <v.reuts...@samsung.com> Date: Mon Oct 12 12:25:22 2015 +0300 project_common: move to common module exist_permission_check Do this, because exist_permission_check will be used not only in tab module --- src/bin/Makefile.am | 1 + src/bin/ui/connector.c | 1 - src/bin/ui/project_common.c | 50 ++++++++++++++++++++++++++++++++++++++++ src/bin/ui/project_common.h | 26 +++++++++++++++++++++ src/bin/ui/tab_home_common.c | 32 ------------------------- src/bin/ui/tab_home_import_edc.c | 16 +++++++++++-- src/bin/ui/tab_home_import_edj.c | 17 ++++++++++++-- src/bin/ui/tab_home_new.c | 16 ++++++++++++- src/bin/ui/tabs_private.h | 3 --- 9 files changed, 121 insertions(+), 41 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 281e744..4e55a3d 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -31,6 +31,7 @@ libete_a_SOURCES = \ ../../src/bin/ui/main_window.c \ ../../src/bin/ui/popup.c \ ../../src/bin/ui/project_close.c \ +../../src/bin/ui/project_common.c \ ../../src/bin/ui/connector.c \ ../../src/bin/ui/splash.c \ ../../src/bin/ui/shortcuts/shortcuts.c \ diff --git a/src/bin/ui/connector.c b/src/bin/ui/connector.c index 38878b2..e84b939 100644 --- a/src/bin/ui/connector.c +++ b/src/bin/ui/connector.c @@ -655,7 +655,6 @@ export_warning(Evas_Object *parent, const char *title, const char *msg) return result; } - static Eina_Bool _export_splash_setup(void *data, Splash_Status status __UNUSED__) { diff --git a/src/bin/ui/project_common.c b/src/bin/ui/project_common.c new file mode 100644 index 0000000..360f238 --- /dev/null +++ b/src/bin/ui/project_common.c @@ -0,0 +1,50 @@ +/* + * Edje Theme Editor + * Copyright (C) 2013-2015 Samsung Electronics. + * + * This file is part of Edje Theme Editor. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; If not, see www.gnu.org/licenses/lgpl.html. + */ + +#include "main_window.h" + +void +exist_permission_check(const char *path, const char *name, + const char *title, const char *msg) +{ + Eina_Strbuf *buf, *buf_msg; + Popup_Button btn_res; + + assert(path != NULL); + assert(name != NULL); + assert(title != NULL); + /* we alwayes imported and exported project to folder by given path, means + * that we alwayes create a new folder for project or exported source. + * So need to check there is the folder "path/name" */ + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, "%s/%s", path, name); + if (!ecore_file_exists(eina_strbuf_string_get(buf))) return; + btn_res = popup_want_action(title, msg, NULL, + NULL, BTN_REPLACE | BTN_CANCEL, NULL, NULL); + if (btn_res == BTN_CANCEL) return; + if (!ecore_file_can_write(eina_strbuf_string_get(buf))) + { + buf_msg = eina_strbuf_new(); + eina_strbuf_append_printf(buf_msg, _("Haven't permision to overwrite '%s' in '%s'"), name, path); + popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, NULL, BTN_OK, NULL, NULL); + eina_strbuf_free(buf_msg); + } + ecore_file_recursive_rm(eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); +} diff --git a/src/bin/ui/project_common.h b/src/bin/ui/project_common.h new file mode 100644 index 0000000..d370e09 --- /dev/null +++ b/src/bin/ui/project_common.h @@ -0,0 +1,26 @@ +/* + * Edje Theme Editor + * Copyright (C) 2013-2015 Samsung Electronics. + * + * This file is part of Edje Theme Editor. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; If not, see www.gnu.org/licenses/lgpl.html. + */ + +#ifndef COMMON_H +#define COMMON_H + +void +exist_permission_check(const char *path, const char *name, const char *title, const char *msg); + +#endif /* COMMON_H */ diff --git a/src/bin/ui/tab_home_common.c b/src/bin/ui/tab_home_common.c index a0cf180..1215755 100644 --- a/src/bin/ui/tab_home_common.c +++ b/src/bin/ui/tab_home_common.c @@ -131,38 +131,6 @@ elipsis_btn_add(Evas_Object *entry, Evas_Smart_Cb cb_func, void *data) } void -exist_permission_check(const char *path, const char *name, const char *title) -{ - Eina_Strbuf *buf, *buf_msg; - Popup_Button btn_res; - - /* we alwayes imported and exported project to folder by given path, means - * that we alwayes create a new folder for project or exported source. - * So need to check there is the folder "path/name" */ - buf = eina_strbuf_new(); - eina_strbuf_append_printf(buf, "%s/%s", path, name); - if (!ecore_file_exists(eina_strbuf_string_get(buf))) return; - buf_msg = eina_strbuf_new(); - eina_strbuf_append_printf(buf_msg, - _("<font_size=16>A project folder named '%s' already exist." - "Do you want to replace it?</font_size><br>" - "The project folder '%s' already exist in '%s'. Replacing it will overwrite" - "<b>all</b> contents."), name, name, path); - btn_res = popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, - NULL, BTN_REPLACE | BTN_CANCEL, NULL, NULL); - if (btn_res == BTN_CANCEL) return; - if (!ecore_file_can_write(eina_strbuf_string_get(buf))) - { - eina_strbuf_reset(buf_msg); - eina_strbuf_append_printf(buf_msg, _("Haven't permision to overwrite '%s' in '%s'"), name, path); - popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, NULL, BTN_OK, NULL, NULL); - } - ecore_file_recursive_rm(eina_strbuf_string_get(buf)); - eina_strbuf_free(buf_msg); - eina_strbuf_free(buf); -} - -void entry_path_set(void *data, Evas_Object *obj __UNUSED__, void *event_info) diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c index 4ea6775..d0cb27a 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -23,6 +23,7 @@ #include "tabs_private.h" #include "tabs.h" #include "main_window.h" +#include "project_common.h" struct _Dir_Data { @@ -412,14 +413,25 @@ _import(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + Eina_Strbuf *buf; + if (ap.project) if (!project_close()) return; + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, + _("<font_size=16>A project folder named '%s' already exist." + "Do you want to replace it?</font_size><br>" + "The project folder '%s' already exist in '%s'. Replacing it will overwrite" + "<b>all</b> contents."), + elm_entry_entry_get(tab_edc.name), + elm_entry_entry_get(tab_edc.name), + elm_entry_entry_get(tab_edc.path)); exist_permission_check(elm_entry_entry_get(tab_edc.path), elm_entry_entry_get(tab_edc.name), - _("Import edc-file")); - + _("Import edc-file"), eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); ap.splash = splash_add(ap.win, _setup_open_splash, _teardown_open_splash, diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index 851499f..5c2d3ff 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -23,6 +23,7 @@ #include "tabs_private.h" #include "tabs.h" #include "main_window.h" +#include "project_common.h" struct _Tab_Home_Edj { @@ -88,14 +89,26 @@ _import(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + Eina_Strbuf *buf; + if (ap.project) if (!project_close()) return; + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, + _("<font_size=16>A project folder named '%s' already exist." + "Do you want to replace it?</font_size><br>" + "The project folder '%s' already exist in '%s'. Replacing it will overwrite" + "<b>all</b> contents."), + elm_entry_entry_get(tab_edj.name), + elm_entry_entry_get(tab_edj.name), + elm_entry_entry_get(tab_edj.path)); + exist_permission_check(elm_entry_entry_get(tab_edj.path), elm_entry_entry_get(tab_edj.name), - _("Import edj-file")); - + _("Import edj-file"), eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); ap.splash = splash_add(ap.win, _setup_open_splash, _teardown_open_splash, diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index f27900b..1818cd4 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -23,6 +23,7 @@ #include "tabs_private.h" #include "tabs.h" #include "main_window.h" +#include "project_common.h" struct _Widget_Item_Data { @@ -504,13 +505,26 @@ _on_create(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + Eina_Strbuf *buf; + if (ap.project) if (!project_close()) return; + buf = eina_strbuf_new(); + eina_strbuf_append_printf(buf, + _("<font_size=16>A project folder named '%s' already exist." + "Do you want to replace it?</font_size><br>" + "The project folder '%s' already exist in '%s'. Replacing it will overwrite" + "<b>all</b> contents."), + elm_entry_entry_get(tab_new.name), + elm_entry_entry_get(tab_new.name), + elm_entry_entry_get(tab_new.path)); + exist_permission_check(elm_entry_entry_get(tab_new.path), elm_entry_entry_get(tab_new.name), - _("New project")); + _("New project"), eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); ap.splash = splash_add(ap.win, _setup_open_splash, _teardown_open_splash, diff --git a/src/bin/ui/tabs_private.h b/src/bin/ui/tabs_private.h index d9df544..089d84e 100644 --- a/src/bin/ui/tabs_private.h +++ b/src/bin/ui/tabs_private.h @@ -67,9 +67,6 @@ void elipsis_btn_add(Evas_Object *entry, Evas_Smart_Cb cb_func, void *data); void -exist_permission_check(const char *path, const char *name, const char *title); - -void entry_path_set(void *data, Evas_Object *obj, void *event_info); --