rimmed pushed a commit to branch eflete-1.18. http://git.enlightenment.org/tools/eflete.git/commit/?id=d4a568fff772ef124cb8dc287177bd1a6aad7588
commit d4a568fff772ef124cb8dc287177bd1a6aad7588 Author: Andrii Kroitor <an.kroi...@samsung.com> Date: Mon Sep 5 11:47:57 2016 +0300 replace popup_want_action with popup_add in simple cases --- src/bin/ui/colorclass_manager.c | 61 +++++++++++++++++++----------------- src/bin/ui/project_common.c | 4 +-- src/bin/ui/project_export.c | 6 ++-- src/bin/ui/project_navigator.c | 67 +++++++++++++++++++++++----------------- src/bin/ui/sound_manager.c | 30 +++++++++++------- src/bin/ui/style_manager.c | 28 +++++++++++------ src/bin/ui/tab_home_common.c | 9 +++--- src/bin/ui/tab_home_import_edc.c | 3 +- src/bin/ui/tab_home_import_edj.c | 6 ++-- src/bin/ui/tab_home_new.c | 3 +- src/bin/ui/tab_home_open.c | 30 +++++++++++------- 11 files changed, 140 insertions(+), 107 deletions(-) diff --git a/src/bin/ui/colorclass_manager.c b/src/bin/ui/colorclass_manager.c index 35185b0..21be2dd 100644 --- a/src/bin/ui/colorclass_manager.c +++ b/src/bin/ui/colorclass_manager.c @@ -94,52 +94,57 @@ _add_colorclass_content_get(void *data __UNUSED__, Evas_Object **to_focus) } static void -_colorclass_add_cb(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_colorclass_add_popup_close_cb(void *data, + Evas_Object *obj __UNUSED__, + void *event_info) { Attribute attribute = ATTRIBUTE_STATE_COLOR_CLASS; Colorclasses_Manager *edit = (Colorclasses_Manager *)data; Colorclass_Item *it = NULL; Elm_Object_Item *glit_ccl = NULL; Colorclass_Resource *res; - Popup_Button btn_res; + Popup_Button btn_res = (Popup_Button)event_info; assert(edit != NULL); - mng.name_validator = resource_name_validator_new(NAME_REGEX, NULL); - resource_name_validator_list_set(mng.name_validator, &ap.project->colorclasses, true); - btn_res = popup_want_action(_("Create a new layout"), NULL, _add_colorclass_content_get, - BTN_OK|BTN_CANCEL, - NULL, mng.entry); - - if (BTN_CANCEL == btn_res) goto end; - - it = (Colorclass_Item *)mem_calloc(1, sizeof(Colorclass_Item)); - it->name = elm_entry_entry_get(mng.entry); - - res = (Colorclass_Resource *)resource_add(it->name, RESOURCE_TYPE_COLORCLASS); - resource_insert(&ap.project->colorclasses, (Resource *)res); - edje_edit_color_class_add(ap.project->global_object, eina_stringshare_add(it->name)); + if (BTN_OK == btn_res) + { + it = (Colorclass_Item *)mem_calloc(1, sizeof(Colorclass_Item)); + it->name = elm_entry_entry_get(mng.entry); - glit_ccl = elm_genlist_item_append(mng.genlist, _itc_ccl, it, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_selected_set(glit_ccl, EINA_TRUE); + res = (Colorclass_Resource *)resource_add(it->name, RESOURCE_TYPE_COLORCLASS); + resource_insert(&ap.project->colorclasses, (Resource *)res); + edje_edit_color_class_add(ap.project->global_object, eina_stringshare_add(it->name)); - evas_object_del(mng.popup); - mng.popup = NULL; + glit_ccl = elm_genlist_item_append(mng.genlist, _itc_ccl, it, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_selected_set(glit_ccl, EINA_TRUE); - CRIT_ON_FAIL(editor_save(ap.project->global_object)); - TODO("Remove this line once edje_edit_colorclass API would be added into Editor Module and saving would work properly") - ap.project->changed = true; - evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); + evas_object_del(mng.popup); + mng.popup = NULL; -end: + CRIT_ON_FAIL(editor_save(ap.project->global_object)); + TODO("Remove this line once edje_edit_colorclass API would be added into Editor Module and saving would work properly") + ap.project->changed = true; + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); + } resource_name_validator_free(mng.name_validator); evas_object_del(mng.item); } static void +_colorclass_add_cb(void *data, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Evas_Object *popup; + mng.name_validator = resource_name_validator_new(NAME_REGEX, NULL); + resource_name_validator_list_set(mng.name_validator, &ap.project->colorclasses, true); + popup = popup_add(_("Create a new layout"), NULL, BTN_OK|BTN_CANCEL, _add_colorclass_content_get, mng.entry); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _colorclass_add_popup_close_cb, data); +} + +static void _colorclass_del_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) diff --git a/src/bin/ui/project_common.c b/src/bin/ui/project_common.c index 3be3043..5c41351 100644 --- a/src/bin/ui/project_common.c +++ b/src/bin/ui/project_common.c @@ -37,7 +37,7 @@ exist_permission_check(const char *path, const char *name, { buf_msg = eina_strbuf_new(); eina_strbuf_append_printf(buf_msg, _("Haven't permision to write '%s'"), path); - popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, BTN_OK, NULL, NULL); + popup_add(title, eina_strbuf_string_get(buf_msg), BTN_OK, NULL, NULL); eina_strbuf_free(buf_msg); return false; } @@ -55,7 +55,7 @@ exist_permission_check(const char *path, const char *name, { 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, BTN_OK, NULL, NULL); + popup_add(title, eina_strbuf_string_get(buf_msg), BTN_OK, NULL, NULL); eina_strbuf_free(buf_msg); return false; } diff --git a/src/bin/ui/project_export.c b/src/bin/ui/project_export.c index 1e9e4d5..0fa37c8 100644 --- a/src/bin/ui/project_export.c +++ b/src/bin/ui/project_export.c @@ -55,8 +55,7 @@ _export_dev(void *data __UNUSED__, { buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, _("Please type in actual .edj file")); - popup_want_action(_("Export to develop edj-file"), eina_strbuf_string_get(buf), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Export to develop edj-file"), eina_strbuf_string_get(buf), BTN_OK, NULL, NULL); eina_strbuf_free(buf); return false; } @@ -128,8 +127,7 @@ _export_release(void *data __UNUSED__, { buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, _("Please type in actual .edj file")); - popup_want_action(_("Export to develop edj-file"), eina_strbuf_string_get(buf), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Export to develop edj-file"), eina_strbuf_string_get(buf), BTN_OK, NULL, NULL); eina_strbuf_free(buf); return false; } diff --git a/src/bin/ui/project_navigator.c b/src/bin/ui/project_navigator.c index 2ae3320..11b335e 100644 --- a/src/bin/ui/project_navigator.c +++ b/src/bin/ui/project_navigator.c @@ -446,11 +446,39 @@ _add_group_content_get(void *data __UNUSED__, Evas_Object **to_focus) } static void +_add_group_popup_close_cb(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) +{ + Popup_Button btn_res = (Popup_Button) event_info; + + if (BTN_OK == btn_res) + { + if ((!layout_p.selected) || (layout_p.selected->index == 0)) + CRIT_ON_FAIL(editor_group_add(ap.project->global_object, elm_entry_entry_get(layout_p.entry))); + else + { + if (!elm_check_state_get(layout_p.check)) + CRIT_ON_FAIL(editor_group_copy(ap.project->global_object, layout_p.selected->data, elm_entry_entry_get(layout_p.entry))); + else + CRIT_ON_FAIL(editor_group_alias_add(ap.project->global_object, layout_p.selected->data, elm_entry_entry_get(layout_p.entry))); + } + gm_group_add(ap.project, elm_entry_entry_get(layout_p.entry), true); + } + + evas_object_del(layout_p.box); + resource_name_validator_free(validator); + validator = NULL; + layout_p.selected = NULL; +} + + +static void _btn_add_group_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Popup_Button btn_res; + Evas_Object *popup; if (!ap.project) return; /* when pressing ctrl + n without open project */ @@ -458,27 +486,8 @@ _btn_add_group_cb(void *data __UNUSED__, validator = resource_name_validator_new(LAYOUT_NAME_REGEX, NULL); resource_name_validator_list_set(validator, &ap.project->groups, false); - btn_res = popup_want_action(_("Create a new layout"), NULL, _add_group_content_get, - BTN_OK|BTN_CANCEL, - NULL, layout_p.entry); - if (BTN_CANCEL == btn_res) goto close; - - if ((!layout_p.selected) || (layout_p.selected->index == 0)) - CRIT_ON_FAIL(editor_group_add(ap.project->global_object, elm_entry_entry_get(layout_p.entry))); - else - { - if (!elm_check_state_get(layout_p.check)) - CRIT_ON_FAIL(editor_group_copy(ap.project->global_object, layout_p.selected->data, elm_entry_entry_get(layout_p.entry))); - else - CRIT_ON_FAIL(editor_group_alias_add(ap.project->global_object, layout_p.selected->data, elm_entry_entry_get(layout_p.entry))); - } - gm_group_add(ap.project, elm_entry_entry_get(layout_p.entry), true); - -close: - evas_object_del(layout_p.box); - resource_name_validator_free(validator); - validator = NULL; - layout_p.selected = NULL; + popup = popup_add(_("Create a new layout"), NULL, BTN_OK|BTN_CANCEL, _add_group_content_get, layout_p.entry); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _add_group_popup_close_cb, NULL); } static void @@ -505,7 +514,8 @@ _folder_del(const char *prefix) else { msg = eina_stringshare_printf(_("Can't delete alias layout \"%s\""), alias->name); - popup_want_action(_("Error"), msg, NULL, BTN_OK, NULL, NULL); + TODO("Check if it's correct to ignore error"); + popup_add(_("Error"), msg, BTN_OK, NULL, NULL); eina_stringshare_del(msg); } eina_stringshare_del(tmp); @@ -518,7 +528,8 @@ _folder_del(const char *prefix) { msg = eina_stringshare_printf(_("Can't delete layout \"%s\". " "Please close a tab with given group."), group->name); - popup_want_action(_("Error"), msg, NULL, BTN_OK, NULL, NULL); + TODO("Check if it's correct to ignore error"); + popup_add(_("Error"), msg, BTN_OK, NULL, NULL); eina_stringshare_del(msg); } eina_stringshare_del(tmp); @@ -607,10 +618,10 @@ _btn_del_group_cb(void *data __UNUSED__, * and delete it */ if (group->edit_object) { - popup_want_action(_("Warning: Delete layout"), - _("Cann't delete the opened layout. Please, " - "close the layout tab before delete it."), - NULL, BTN_CANCEL, NULL, NULL); + popup_add(_("Warning: Delete layout"), + _("Cann't delete the opened layout. Please, " + "close the layout tab before delete it."), + BTN_CANCEL, NULL, NULL); return; } btn_res = popup_want_action(_("Confirm delete layout"), diff --git a/src/bin/ui/sound_manager.c b/src/bin/ui/sound_manager.c index 96dfb59..bbded0c 100644 --- a/src/bin/ui/sound_manager.c +++ b/src/bin/ui/sound_manager.c @@ -391,27 +391,33 @@ _add_tone_content_get(void *data __UNUSED__, Evas_Object **to_focus) } static void +_tone_add_popup_close_cb(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) +{ + Popup_Button btn_res = (Popup_Button) event_info; + + if (BTN_CANCEL != btn_res) + _tone_add(); + + resource_name_validator_free(mng.tone_validator); + elm_validator_regexp_free(mng.frq_validator); + evas_object_del(mng.box); +} + +static void _tone_add_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Popup_Button btn_res; - + Evas_Object *popup; mng.tone_validator = resource_name_validator_new(NAME_REGEX, NULL); resource_name_validator_list_set(mng.tone_validator, &ap.project->tones, true); mng.frq_validator = elm_validator_regexp_new(FREQUENCY_REGEX, NULL); popup_buttons_disabled_set(BTN_OK, true); - btn_res = popup_want_action(_("Create a new layout"), NULL, _add_tone_content_get, - BTN_OK|BTN_CANCEL, - NULL, mng.tone_entry); - if (BTN_CANCEL == btn_res) goto close; - _tone_add(); - -close: - resource_name_validator_free(mng.tone_validator); - elm_validator_regexp_free(mng.frq_validator); - evas_object_del(mng.box); + popup = popup_add(_("Create a new layout"), NULL, BTN_OK|BTN_CANCEL, _add_tone_content_get, mng.tone_entry); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _tone_add_popup_close_cb, NULL); } #undef INFO_ADD diff --git a/src/bin/ui/style_manager.c b/src/bin/ui/style_manager.c index 49164f0..11c7b73 100644 --- a/src/bin/ui/style_manager.c +++ b/src/bin/ui/style_manager.c @@ -174,21 +174,16 @@ _add_style_content_get(void *data __UNUSED__, Evas_Object **to_focus) } static void -_style_add_cb(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_style_add_popup_close_cb_cb(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { Attribute attribute = ATTRIBUTE_STATE_TEXT_STYLE; Resource *res; - Popup_Button btn_res; const char *style_name; Elm_Object_Item *glit; - mng.popup.validator = resource_name_validator_new(NAME_REGEX, NULL); - resource_name_validator_list_set(mng.popup.validator, &ap.project->styles, true); + Popup_Button btn_res = (Popup_Button) event_info; - btn_res = popup_want_action(_("Add textblock style"), NULL, _add_style_content_get, - BTN_OK|BTN_CANCEL, - NULL, mng.popup.name); if (BTN_CANCEL == btn_res) goto close; style_name = elm_entry_entry_get(mng.popup.name); @@ -215,7 +210,7 @@ _style_add_cb(void *data __UNUSED__, CRIT_ON_FAIL(editor_save(ap.project->global_object)); TODO("Remove this line once edje_edit API would be added into Editor Module and saving would work properly") - ap.project->changed = true; + ap.project->changed = true; evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); close: @@ -223,6 +218,19 @@ close: evas_object_del(mng.popup.item); } +static void +_style_add_cb(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Evas_Object *popup; + mng.popup.validator = resource_name_validator_new(NAME_REGEX, NULL); + resource_name_validator_list_set(mng.popup.validator, &ap.project->styles, true); + + popup = popup_add(_("Add textblock style"), NULL, BTN_OK|BTN_CANCEL, _add_style_content_get, mng.popup.name); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _style_add_popup_close_cb_cb, NULL); +} + Evas_Object * _add_tag_content_get(void *data __UNUSED__, Evas_Object **to_focus) { diff --git a/src/bin/ui/tab_home_common.c b/src/bin/ui/tab_home_common.c index 580e54a..d578d86 100644 --- a/src/bin/ui/tab_home_common.c +++ b/src/bin/ui/tab_home_common.c @@ -135,16 +135,15 @@ _tabs_progress_end(void *data, PM_Project_Result result, Project *project) if (PM_PROJECT_LOCKED == result) { progress_end(data, result, project); - popup_want_action(_("File is locked"), _("File locked by another application"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("File is locked"), _("File locked by another application"), BTN_OK, NULL, NULL); return; } if (PM_PROJECT_ERROR == result) { progress_end(data, result, project); - popup_want_action(_("File opening error"), _("Unknown problem with file appeared.<br>" - "(wrong file, filesystem error, no memory, etc)"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("File opening error"), _("Unknown problem with file appeared.<br>" + "(wrong file, filesystem error, no memory, etc)"), + BTN_OK, NULL, NULL); return; } if (PM_PROJECT_SUCCESS != result) return; diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c index ccd5d26..b477d93 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -428,8 +428,7 @@ _import(void *data __UNUSED__, elm_entry_entry_get(tab_edc.name)); if (!pm_lock_check(eina_strbuf_string_get(buf))) { - popup_want_action(_("Import EDC-file"), _("The given file is locked by another application"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Import EDC-file"), _("The given file is locked by another application"), BTN_OK, NULL, NULL); return; } diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index 87a0bd5..d2a1ee1 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -479,8 +479,7 @@ _import(void *data __UNUSED__, elm_entry_entry_get(tab_edj.name)); if (!pm_lock_check(eina_strbuf_string_get(buf))) { - popup_want_action(_("Import EDJ-file"), _("The given file is locked by another application"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Import EDJ-file"), _("The given file is locked by another application"), BTN_OK, NULL, NULL); return; } @@ -611,7 +610,8 @@ static void _delayed_popup(void *data) { char *msg = data; - popup_want_action(_("Import edj-file"), msg, NULL, BTN_OK, NULL, NULL); + TODO("check and comment why delayed popup is needed here"); + popup_add(_("Import edj-file"), msg, BTN_OK, NULL, NULL); free(msg); } diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index d5dc0f1..2fe913e 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -644,7 +644,8 @@ static void _delayed_popup(void *data) { char *msg = data; - popup_want_action(_("New project"), msg, NULL, BTN_OK, NULL, NULL); + TODO("check and comment why delayed popup is needed here"); + popup_add(_("New project"), msg, BTN_OK, NULL, NULL); free(msg); } diff --git a/src/bin/ui/tab_home_open.c b/src/bin/ui/tab_home_open.c index 97744a0..86f24bc 100644 --- a/src/bin/ui/tab_home_open.c +++ b/src/bin/ui/tab_home_open.c @@ -83,8 +83,7 @@ _open_done(void *data __UNUSED__, if (!pm_lock_check(selected)) { - popup_want_action(_("Open project"), _("The given file is locked by another application"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Open project"), _("The given file is locked by another application"), BTN_OK, NULL, NULL); return; } @@ -120,21 +119,29 @@ _unselected(void *data __UNUSED__, } static void -_recent_clear(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_recent_clear_popup_close_cb(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { - Popup_Button btn_res; - btn_res = popup_want_action(_("Confirm clear recent list"), - _("Are you sure you want to clear list of " - "recently opened projects?<br>"), - NULL, BTN_OK|BTN_CANCEL, NULL, NULL); + Popup_Button btn_res = (Popup_Button) event_info; if (BTN_CANCEL == btn_res) return; config_recent_list_clear(); _tab_open_project_recents_update(); } +static void +_recent_clear(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Evas_Object *popup = popup_add(_("Confirm clear recent list"), + _("Are you sure you want to clear list of " + "recently opened projects?<br>"), + BTN_OK|BTN_CANCEL, NULL, NULL); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _recent_clear_popup_close_cb, NULL); +} + Evas_Object * _tab_open_project_add(void) { @@ -183,8 +190,7 @@ _open_recent(void *data, if (!pm_lock_check(r->path)) { - popup_want_action(_("Open project"), _("The given file is locked by another application"), - NULL, BTN_OK, NULL, NULL); + popup_add(_("Open project"), _("The given file is locked by another application"), BTN_OK, NULL, NULL); return; } --