rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=fd69709fee385c1af9d5ca2fd15968ebeea03eef
commit fd69709fee385c1af9d5ca2fd15968ebeea03eef Author: Mykyta Biliavskyi <[email protected]> Date: Fri Jul 1 17:19:54 2016 +0300 Popup: change signature of popup_want_action. Param "to_focus" removed from signature of popup_want_action. Because now content for popup creates in separated function and that function can return Evas_Object, which should be focused. Apply to that signature into all places where popup_want_action function is used. --- src/bin/ui/colorclass_manager.c | 7 ++- src/bin/ui/main_window.c | 4 +- src/bin/ui/main_window.h | 5 +-- src/bin/ui/popup.c | 16 +++---- src/bin/ui/project_close.c | 2 +- src/bin/ui/project_common.c | 6 +-- src/bin/ui/project_export.c | 6 ++- src/bin/ui/project_navigator.c | 17 +++++--- src/bin/ui/sound_manager.c | 7 ++- src/bin/ui/style_manager.c | 13 ++++-- src/bin/ui/tab_home_common.c | 6 ++- src/bin/ui/tab_home_import_edc.c | 2 +- src/bin/ui/tab_home_import_edj.c | 4 +- src/bin/ui/tab_home_new.c | 2 +- src/bin/ui/tab_home_open.c | 6 +-- src/bin/ui/workspace/group_navigator.c | 80 ++++++++++++++++++++++++---------- 16 files changed, 116 insertions(+), 67 deletions(-) diff --git a/src/bin/ui/colorclass_manager.c b/src/bin/ui/colorclass_manager.c index 635838f..d033c9a 100644 --- a/src/bin/ui/colorclass_manager.c +++ b/src/bin/ui/colorclass_manager.c @@ -70,7 +70,7 @@ _validation(void *data __UNUSED__, } Evas_Object * -_add_colorclass_content_get(void *data __UNUSED__) +_add_colorclass_content_get(void *data __UNUSED__, Evas_Object **to_focus) { Evas_Object *item = NULL; @@ -81,6 +81,9 @@ _add_colorclass_content_get(void *data __UNUSED__) elm_object_part_text_set(mng.entry, "guide", _("Type new color class name here")); elm_object_part_content_set(item, "elm.swallow.content", mng.entry); mng.item = item; + if (to_focus) *to_focus = mng.entry; + popup_buttons_disabled_set(BTN_OK, true); + return mng.item; } @@ -100,7 +103,7 @@ _colorclass_add_cb(void *data __UNUSED__, 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, - mng.entry, BTN_OK|BTN_CANCEL, + BTN_OK|BTN_CANCEL, NULL, mng.entry); if (BTN_CANCEL == btn_res) goto end; diff --git a/src/bin/ui/main_window.c b/src/bin/ui/main_window.c index dc586a4..48f3094 100644 --- a/src/bin/ui/main_window.c +++ b/src/bin/ui/main_window.c @@ -165,7 +165,7 @@ ui_main_window_add(void) } Evas_Object * -_about_window_content_get(void *data) +_about_window_content_get(void *data, Evas_Object **to_focus __UNUSED__) { Evas_Object *label = (Evas_Object *) data; elm_object_text_set(label, @@ -202,7 +202,7 @@ Evas_Object * about_window_add(void) { Evas_Object *content = elm_label_add(ap.win); - popup_want_action(_("About"), NULL, _about_window_content_get, NULL, BTN_CANCEL, NULL, content); + popup_want_action(_("About"), NULL, _about_window_content_get, BTN_CANCEL, NULL, content); evas_object_del(content); return NULL; } diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h index e2fd922..2c56780 100644 --- a/src/bin/ui/main_window.h +++ b/src/bin/ui/main_window.h @@ -116,10 +116,11 @@ typedef Eina_Bool(* Popup_Validator_Func)(void *data); * inside popup window. * * @param data The user data + * @param to_focus Evas_Object, which should be focused * * @ingroup Window */ -typedef Evas_Object *(* Popup_Content_Get_Func)(void *data); +typedef Evas_Object *(* Popup_Content_Get_Func)(void *data, Evas_Object **to_focus); /** * The fileselector helper callback. @@ -319,7 +320,6 @@ project_close(void); * @param title The Popup title; * @param msg The Popup message, formated text; * @param content_get The func, that return content Evas_Object to popup; - * @param to_focus The object what be focused after popup show; * @param p_btns The flags for set the popup buttons; * @param func The validation func, if returned EINA_FALSE popup not be closed; * @param data The user data for validation and content_get funcutions. @@ -330,7 +330,6 @@ Popup_Button popup_want_action(const char *title, const char *msg, Popup_Content_Get_Func content_get, - Evas_Object *to_focus, Popup_Button p_btns, Popup_Validator_Func func, void *data); diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index efab951..c8d3d60 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -88,13 +88,13 @@ Popup_Button popup_want_action(const char *title, const char *msg, Popup_Content_Get_Func content_get, - Evas_Object *to_focus, Popup_Button popup_btns, Popup_Validator_Func func, void *data) { Evas_Object *btn; + Evas_Object *to_focus = NULL; /* only one content will be setted to ap.popup: or message, or used content */ assert((msg != NULL) != (content_get != NULL)); @@ -107,13 +107,6 @@ popup_want_action(const char *title, elm_popup_orient_set(ap.popup, ELM_POPUP_ORIENT_CENTER); elm_object_part_text_set(ap.popup, "title,text", title); elm_popup_content_text_wrap_type_set(ap.popup, ELM_WRAP_WORD); - if (msg) elm_object_text_set(ap.popup, msg); - if (content_get) - { - Evas_Object *content = content_get(data); - elm_object_content_set(ap.popup, content); - } - if (popup_btns & BTN_OK) BTN_ADD(_("Ok"), "button1", &_btn_ok) @@ -131,6 +124,13 @@ popup_want_action(const char *title, else if (popup_btns & BTN_CANCEL) BTN_ADD(_("Cancel"), "button2", &_btn_cancel) + if (msg) elm_object_text_set(ap.popup, msg); + if (content_get) + { + Evas_Object *content = content_get(data, &to_focus); + elm_object_content_set(ap.popup, content); + } + if (to_focus) elm_object_focus_set(to_focus, true); evas_object_show(ap.popup); diff --git a/src/bin/ui/project_close.c b/src/bin/ui/project_close.c index 372334d..a827d42 100644 --- a/src/bin/ui/project_close.c +++ b/src/bin/ui/project_close.c @@ -156,7 +156,7 @@ project_close(void) { title = eina_stringshare_printf(_("Close project %s"), ap.project->name); btn_res = popup_want_action(title, _("Do you want to save changes?"), NULL, - NULL, BTN_OK|BTN_DONT_SAVE|BTN_CANCEL, + BTN_OK|BTN_DONT_SAVE|BTN_CANCEL, NULL, NULL); switch (btn_res) { diff --git a/src/bin/ui/project_common.c b/src/bin/ui/project_common.c index e6f1531..cac3780 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, NULL, BTN_OK, NULL, NULL); + popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, BTN_OK, NULL, NULL); eina_strbuf_free(buf_msg); return false; } @@ -45,13 +45,13 @@ exist_permission_check(const char *path, const char *name, 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, - NULL, BTN_REPLACE | BTN_CANCEL, NULL, NULL); + BTN_REPLACE | BTN_CANCEL, NULL, NULL); if (btn_res == BTN_CANCEL) return false; 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); + popup_want_action(title, eina_strbuf_string_get(buf_msg), NULL, 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 f71b596..6c8af49 100644 --- a/src/bin/ui/project_export.c +++ b/src/bin/ui/project_export.c @@ -55,7 +55,8 @@ _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, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("Export to develop edj-file"), eina_strbuf_string_get(buf), + NULL, BTN_OK, NULL, NULL); eina_strbuf_free(buf); return false; } @@ -118,7 +119,8 @@ _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, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("Export to develop edj-file"), eina_strbuf_string_get(buf), + NULL, 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 0a01574..43d171f 100644 --- a/src/bin/ui/project_navigator.c +++ b/src/bin/ui/project_navigator.c @@ -466,7 +466,7 @@ _group_validate(void *data __UNUSED__, } Evas_Object * -_add_group_content_get(void *data __UNUSED__) +_add_group_content_get(void *data __UNUSED__, Evas_Object **to_focus) { Evas_Object *item; Group *group; @@ -520,6 +520,9 @@ _add_group_content_get(void *data __UNUSED__) } elm_object_text_set(layout_p.combobox, _("None")); + if (to_focus) *to_focus = layout_p.entry; + popup_buttons_disabled_set(BTN_OK, true); + return layout_p.box; } @@ -537,7 +540,7 @@ _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, - layout_p.entry, BTN_OK|BTN_CANCEL, + BTN_OK|BTN_CANCEL, NULL, layout_p.entry); if (BTN_CANCEL == btn_res) goto close; @@ -578,7 +581,7 @@ _folder_del(const char *prefix) else { msg = eina_stringshare_printf(_("Can't delete layout \"%s\""), group->name); - popup_want_action(_("Error"), msg, NULL, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("Error"), msg, NULL, BTN_OK, NULL, NULL); eina_stringshare_del(msg); } eina_stringshare_del(tmp); @@ -656,7 +659,7 @@ _btn_del_group_cb(void *data __UNUSED__, btn_res = popup_want_action(_("Confirm delete layouts"), _("Are you sure you want to delete the selected layouts?<br>" "All aliases will be delete too."), - NULL, NULL, BTN_OK|BTN_CANCEL, NULL, NULL); + NULL, BTN_OK|BTN_CANCEL, NULL, NULL); if (BTN_CANCEL == btn_res) return; _folder_del(elm_object_item_data_get(glit)); } @@ -670,13 +673,13 @@ _btn_del_group_cb(void *data __UNUSED__, popup_want_action(_("Warning: Delete layout"), _("Cann't delete the opened layout. Please, " "close the layout tab before delete it."), - NULL, NULL, BTN_CANCEL, NULL, NULL); + NULL, BTN_CANCEL, NULL, NULL); return; } btn_res = popup_want_action(_("Confirm delete layout"), _("Are you sure you want to delete the selected layout?<br>" "All aliases will be delete too."), - NULL, NULL, BTN_OK|BTN_CANCEL, NULL, NULL); + NULL, BTN_OK|BTN_CANCEL, NULL, NULL); if (BTN_CANCEL == btn_res) return; tmp = eina_stringshare_add(group->name); if (editor_group_del(ap.project->global_object, tmp)) @@ -684,7 +687,7 @@ _btn_del_group_cb(void *data __UNUSED__, else { msg = eina_stringshare_printf(_("Can't delete layout \"%s\""), group->name); - popup_want_action(_("Error"), msg, NULL, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("Error"), msg, NULL, BTN_OK, NULL, NULL); eina_stringshare_del(msg); } eina_stringshare_del(tmp); diff --git a/src/bin/ui/sound_manager.c b/src/bin/ui/sound_manager.c index 511ad4f..dda4500 100644 --- a/src/bin/ui/sound_manager.c +++ b/src/bin/ui/sound_manager.c @@ -327,7 +327,7 @@ _validation(void *data __UNUSED__, } Evas_Object * -_add_tone_content_get(void *data __UNUSED__) +_add_tone_content_get(void *data __UNUSED__, Evas_Object **to_focus) { Evas_Object *item, *box; @@ -354,6 +354,9 @@ _add_tone_content_get(void *data __UNUSED__) elm_box_pack_end(box, item); mng.box = box; + if (to_focus) *to_focus = mng.tone_entry; + popup_buttons_disabled_set(BTN_OK, true); + return box; } @@ -374,7 +377,7 @@ _tone_add_cb(void *data __UNUSED__, popup_buttons_disabled_set(BTN_OK, true); btn_res = popup_want_action(_("Create a new layout"), NULL, _add_tone_content_get, - mng.tone_entry, BTN_OK|BTN_CANCEL, + BTN_OK|BTN_CANCEL, NULL, mng.tone_entry); if (BTN_CANCEL == btn_res) goto close; _tone_add(); diff --git a/src/bin/ui/style_manager.c b/src/bin/ui/style_manager.c index 66a7912..c6bd474 100644 --- a/src/bin/ui/style_manager.c +++ b/src/bin/ui/style_manager.c @@ -163,7 +163,7 @@ _validate(void *data __UNUSED__, } Evas_Object * -_add_style_content_get(void *data __UNUSED__) +_add_style_content_get(void *data __UNUSED__, Evas_Object **to_focus) { Evas_Object *item; @@ -178,6 +178,9 @@ _add_style_content_get(void *data __UNUSED__) elm_object_part_text_set(mng.popup.name, "guide", _("Type a new style name")); elm_object_part_content_set(mng.popup.item, "elm.swallow.content", mng.popup.name); + if (to_focus) *to_focus = mng.popup.name; + popup_buttons_disabled_set(BTN_OK, true); + return mng.popup.item; } @@ -192,7 +195,7 @@ _style_add_cb(void *data __UNUSED__, Elm_Object_Item *glit; btn_res = popup_want_action(_("Add textblock style"), NULL, _add_style_content_get, - mng.popup.name, BTN_OK|BTN_CANCEL, + BTN_OK|BTN_CANCEL, NULL, mng.popup.name); if (BTN_CANCEL == btn_res) goto close; @@ -227,7 +230,7 @@ close: } Evas_Object * -_add_tag_content_get(void *data __UNUSED__) +_add_tag_content_get(void *data __UNUSED__, Evas_Object **to_focus) { Evas_Object *item; @@ -239,6 +242,8 @@ _add_tag_content_get(void *data __UNUSED__) elm_object_part_content_set(item, "elm.swallow.content", mng.popup.name); mng.popup.item = item; + if (to_focus) *to_focus = mng.popup.name; + popup_buttons_disabled_set(BTN_OK, true); return item; } @@ -282,7 +287,7 @@ _tag_add_cb(void *data __UNUSED__, buf = eina_stringshare_printf(_("Add tag for style: %s"), style_name); btn_res = popup_want_action(buf, NULL, _add_tag_content_get, - mng.popup.name, BTN_OK|BTN_CANCEL, + BTN_OK|BTN_CANCEL, NULL, mng.popup.name); if (BTN_CANCEL == btn_res) goto close; diff --git a/src/bin/ui/tab_home_common.c b/src/bin/ui/tab_home_common.c index c0d112b..434a852 100644 --- a/src/bin/ui/tab_home_common.c +++ b/src/bin/ui/tab_home_common.c @@ -133,14 +133,16 @@ _tabs_progress_end(void *data, PM_Project_Result result, Eina_List *widgets) if (PM_PROJECT_LOCKED == result) { progress_end(data, result, NULL); - popup_want_action(_("File is locked"), _("File locked by another application"), NULL, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("File is locked"), _("File locked by another application"), + NULL, BTN_OK, NULL, NULL); return; } if (PM_PROJECT_ERROR == result) { progress_end(data, result, NULL); popup_want_action(_("File opening error"), _("Unknown problem with file appeared.<br>" - "(wrong file, filesystem error, no memory, etc)"), NULL, NULL, BTN_OK, NULL, NULL); + "(wrong file, filesystem error, no memory, etc)"), + NULL, 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 5b3171c..a063c51 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -430,7 +430,7 @@ _import(void *data __UNUSED__, if (!pm_lock_check(eina_strbuf_string_get(buf))) { popup_want_action(_("Import EDC-file"), _("The given file is locked by another application"), - NULL, NULL, BTN_OK, NULL, NULL); + NULL, 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 e76c433..f4ad9d4 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -513,7 +513,7 @@ _import(void *data __UNUSED__, if (!pm_lock_check(eina_strbuf_string_get(buf))) { popup_want_action(_("Import EDJ-file"), _("The given file is locked by another application"), - NULL, NULL, BTN_OK, NULL, NULL); + NULL, BTN_OK, NULL, NULL); return; } @@ -660,7 +660,7 @@ static void _delayed_popup(void *data) { char *msg = data; - popup_want_action(_("Import edj-file"), msg, NULL, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("Import edj-file"), msg, NULL, 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 449582d..0072ddd 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -635,7 +635,7 @@ static void _delayed_popup(void *data) { char *msg = data; - popup_want_action(_("New project"), msg, NULL, NULL, BTN_OK, NULL, NULL); + popup_want_action(_("New project"), msg, NULL, 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 97b79af..de9ccd9 100644 --- a/src/bin/ui/tab_home_open.c +++ b/src/bin/ui/tab_home_open.c @@ -85,7 +85,7 @@ _open(void *data __UNUSED__, if (!pm_lock_check(selected)) { popup_want_action(_("Open project"), _("The given file is locked by another application"), - NULL, NULL, BTN_OK, NULL, NULL); + NULL, BTN_OK, NULL, NULL); return; } @@ -129,7 +129,7 @@ _recent_clear(void *data __UNUSED__, btn_res = popup_want_action(_("Confirm clear recent list"), _("Are you sure you want to clear list of " "recently opened projects?<br>"), - NULL, NULL, BTN_OK|BTN_CANCEL, NULL, NULL); + NULL, BTN_OK|BTN_CANCEL, NULL, NULL); if (BTN_CANCEL == btn_res) return; config_recent_list_clear(); @@ -185,7 +185,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, NULL, BTN_OK, NULL, NULL); + NULL, BTN_OK, NULL, NULL); return; } diff --git a/src/bin/ui/workspace/group_navigator.c b/src/bin/ui/workspace/group_navigator.c index 5d89700..823ebbb 100644 --- a/src/bin/ui/workspace/group_navigator.c +++ b/src/bin/ui/workspace/group_navigator.c @@ -761,9 +761,9 @@ _on_part_name_changed(void *data, assert(pl != NULL); if (resource_name_validator_status_get(pl->part_name_validator) != ELM_REG_NOERROR) - elm_object_disabled_set(pl->popup.btn_add, true); + popup_buttons_disabled_set(BTN_OK, true); else - elm_object_disabled_set(pl->popup.btn_add, false); + popup_buttons_disabled_set(BTN_OK, false); } static void @@ -781,11 +781,12 @@ _state_validate(void *data, name = elm_entry_entry_get(pl->popup.entry_name); val = elm_spinner_value_get(pl->popup.spinner_value); val = ((int) (val * 100)) / 100.0; /* only first two digets after point are used */ + if ((elm_validator_regexp_status_get(pl->name_validator) != ELM_REG_NOERROR) || (edje_edit_state_exist(pl->group->edit_object, pl->part->name, name, val))) - elm_object_disabled_set(pl->popup.btn_add, true); + popup_buttons_disabled_set(BTN_OK, true); else - elm_object_disabled_set(pl->popup.btn_add, false); + popup_buttons_disabled_set(BTN_OK, false); } static void @@ -813,7 +814,7 @@ _item_validate(void *data, EINA_LIST_FOREACH(pl->part->items, l, item) valid = valid && strcmp(item->name, name); - elm_object_disabled_set(pl->popup.btn_add, !valid); + popup_buttons_disabled_set(BTN_OK, !valid); } static void @@ -826,9 +827,9 @@ _program_validate(void *data, assert(pl != NULL); if (resource_name_validator_status_get(pl->program_name_validator) != ELM_REG_NOERROR) - elm_object_disabled_set(pl->popup.btn_add, true); + popup_buttons_disabled_set(BTN_OK, true); else - elm_object_disabled_set(pl->popup.btn_add, false); + popup_buttons_disabled_set(BTN_OK, false); } static void @@ -844,7 +845,8 @@ _popup_add_part_ok_clicked(void *data, assert(pl != NULL); - if (elm_object_disabled_get(pl->popup.btn_add)) return; + if (resource_name_validator_status_get(pl->part_name_validator) != ELM_REG_NOERROR) + return; if (pl->popup.copy_part) { @@ -905,7 +907,10 @@ _popup_add_part_ok_clicked(void *data, Eina_Bool _popup_add_part_validator(void *data) { + Part_List *pl = (Part_List *) data; _popup_add_part_ok_clicked(data, NULL, NULL); + if (resource_name_validator_status_get(pl->part_name_validator) != ELM_REG_NOERROR) + return false; return true; } @@ -1017,7 +1022,7 @@ _combobox_item_pressed_cb(void *data __UNUSED__, Evas_Object *obj, } Evas_Object * -_add_part_content_get(void *data) +_add_part_content_get(void *data, Evas_Object **to_focus) { Combobox_Item *combobox_item; unsigned int i = 0; @@ -1085,6 +1090,8 @@ _add_part_content_get(void *data) evas_object_smart_callback_add(pl->popup.combobox_copy, "item,selected", _part_selected_cb, pl); elm_box_pack_end(box, item); + if (to_focus) *to_focus = pl->popup.entry_name; + popup_buttons_disabled_set(BTN_OK, true); pl->popup.box = box; return box; } @@ -1101,7 +1108,7 @@ _on_menu_add_part_clicked(void *data __UNUSED__, title = eina_stringshare_printf(_("Add New Part to Group \"%s\""), pl->group->name); Popup_Button button = popup_want_action(title, NULL, _add_part_content_get, - NULL, BTN_OK | BTN_CANCEL, + BTN_OK | BTN_CANCEL, _popup_add_part_validator, pl); if (BTN_CANCEL == button) evas_object_del(pl->popup.box); @@ -1118,9 +1125,9 @@ _on_group_data_name_changed(void *data, assert(pl != NULL); if (resource_name_validator_status_get(pl->group_data_name_validator) != ELM_REG_NOERROR) - elm_object_disabled_set(pl->popup.btn_add, true); + popup_buttons_disabled_set(BTN_OK, true); else - elm_object_disabled_set(pl->popup.btn_add, false); + popup_buttons_disabled_set(BTN_OK, false); } static void @@ -1135,7 +1142,8 @@ _popup_add_group_data_ok_clicked(void *data, assert(pl != NULL); - if (elm_object_disabled_get(pl->popup.btn_add)) return; + if (resource_name_validator_status_get(pl->group_data_name_validator) != ELM_REG_NOERROR) + return; name = elm_entry_entry_get(pl->popup.entry_name); msg = eina_stringshare_printf(_("added new data item \"%s\""), name); @@ -1150,12 +1158,15 @@ _popup_add_group_data_ok_clicked(void *data, Eina_Bool _popup_add_group_data_validator(void *data) { + Part_List *pl = (Part_List *) data; _popup_add_group_data_ok_clicked(data, NULL, NULL); + if (resource_name_validator_status_get(pl->group_data_name_validator) != ELM_REG_NOERROR) + return false; return true; } Evas_Object * -_add_group_data_content_get(void *data) +_add_group_data_content_get(void *data, Evas_Object **to_focus) { Part_List *pl = (Part_List *) data; Evas_Object *box, *item; @@ -1174,6 +1185,8 @@ _add_group_data_content_get(void *data) elm_object_focus_set(pl->popup.entry_name, true); pl->popup.box = box; + if (to_focus) *to_focus = pl->popup.entry_name; + popup_buttons_disabled_set(BTN_OK, true); return pl->popup.box; } @@ -1191,7 +1204,7 @@ _on_menu_add_group_data_clicked(void *data __UNUSED__, title = eina_stringshare_printf(_("Add New Data Item to Group \"%s\""), pl->group->name); Popup_Button button = popup_want_action(title, NULL, _add_group_data_content_get, - NULL, BTN_OK | BTN_CANCEL, + BTN_OK | BTN_CANCEL, _popup_add_group_data_validator, pl); if (button == BTN_CANCEL) evas_object_del(pl->popup.box); @@ -1214,7 +1227,8 @@ _popup_add_state_ok_clicked(void *data, assert(pl != NULL); assert(pl->part != NULL); - if (elm_object_disabled_get(pl->popup.btn_add)) return; + if (elm_validator_regexp_status_get(pl->name_validator) != ELM_REG_NOERROR) + return; name = elm_entry_entry_get(pl->popup.entry_name); val = elm_spinner_value_get(pl->popup.spinner_value); @@ -1250,7 +1264,11 @@ _popup_add_state_ok_clicked(void *data, Eina_Bool _popup_add_state_validator(void *data) { + Part_List *pl = (Part_List *) data; _popup_add_state_ok_clicked(data, NULL, NULL); + + if (elm_validator_regexp_status_get(pl->name_validator) != ELM_REG_NOERROR) + return false; return true; } @@ -1292,7 +1310,7 @@ group_navigator_part_state_add(Evas_Object *obj, Part *part, State *state) } Evas_Object * -_add_state_content_get(void *data) +_add_state_content_get(void *data, Evas_Object **to_focus) { Part_List *pl = (Part_List *)data; Evas_Object *box, *item; @@ -1353,6 +1371,8 @@ _add_state_content_get(void *data) elm_object_part_content_set(item, "elm.swallow.content", pl->popup.combobox); elm_box_pack_end(box, item); + if (to_focus) *to_focus = pl->popup.entry_name; + popup_buttons_disabled_set(BTN_OK, true); pl->popup.box = box; return box; } @@ -1369,7 +1389,7 @@ _on_menu_add_state_clicked(void *data __UNUSED__, title = eina_stringshare_printf(_("Add New State to Part \"%s\""), pl->part->name); Popup_Button button = popup_want_action(title, NULL, _add_state_content_get, - NULL, BTN_OK | BTN_CANCEL, + BTN_OK | BTN_CANCEL, _popup_add_state_validator, pl); if (button == BTN_CANCEL) @@ -1389,7 +1409,8 @@ _popup_add_item_ok_clicked(void *data, assert(pl != NULL); - if (elm_object_disabled_get(pl->popup.btn_add)) return; + if (elm_validator_regexp_status_get(pl->name_validator) != ELM_REG_NOERROR) + return; assert(pl->part != NULL); @@ -1407,7 +1428,10 @@ _popup_add_item_ok_clicked(void *data, Eina_Bool _popup_add_item_validator(void *data) { + Part_List *pl = (Part_List *) data; _popup_add_item_ok_clicked(data, NULL, NULL); + if (elm_validator_regexp_status_get(pl->name_validator) != ELM_REG_NOERROR) + return false; return true; } @@ -1449,7 +1473,7 @@ group_navigator_part_item_add(Evas_Object *obj, Part *part, Eina_Stringshare * i } Evas_Object * -_add_item_content_get(void *data) +_add_item_content_get(void *data, Evas_Object **to_focus) { Part_List *pl = (Part_List *)data; Combobox_Item *combobox_item; @@ -1496,6 +1520,8 @@ _add_item_content_get(void *data) elm_box_pack_end(box, item); pl->popup.box = box; + if (to_focus) *to_focus = pl->popup.entry_name; + popup_buttons_disabled_set(BTN_OK, true); return pl->popup.box; } @@ -1512,7 +1538,7 @@ _on_menu_add_item_clicked(void *data __UNUSED__, title = eina_stringshare_printf(_("Add New Item to Part \"%s\""), pl->part->name); Popup_Button button = popup_want_action(title, NULL, _add_item_content_get, - NULL, BTN_OK | BTN_CANCEL, + BTN_OK | BTN_CANCEL, _popup_add_item_validator, pl); if (button == BTN_CANCEL) @@ -1533,7 +1559,8 @@ _popup_add_program_ok_clicked(void *data, assert(pl != NULL); - if (elm_object_disabled_get(pl->popup.btn_add)) return; + if (resource_name_validator_status_get(pl->program_name_validator) != ELM_REG_NOERROR) + return; switch (pl->popup.program_selected) { @@ -1580,12 +1607,15 @@ _popup_add_program_ok_clicked(void *data, Eina_Bool _popup_add_program_validator(void *data) { + Part_List *pl = (Part_List *) data; _popup_add_program_ok_clicked(data, NULL, NULL); + if (resource_name_validator_status_get(pl->program_name_validator) != ELM_REG_NOERROR) + return false; return true; } Evas_Object * -_add_program_content_get(void *data) +_add_program_content_get(void *data, Evas_Object **to_focus) { Part_List *pl = (Part_List *) data; Evas_Object *box, *item; @@ -1625,6 +1655,8 @@ _add_program_content_get(void *data) elm_box_pack_end(box, item); pl->popup.box = box; + if (to_focus) *to_focus = pl->popup.entry_name; + popup_buttons_disabled_set(BTN_OK, true); return pl->popup.box; } @@ -1641,7 +1673,7 @@ _on_menu_add_program_clicked(void *data __UNUSED__, title = eina_stringshare_add(_("Add New Program")); Popup_Button button = popup_want_action(title, NULL, _add_program_content_get, - NULL, BTN_OK | BTN_CANCEL, + BTN_OK | BTN_CANCEL, _popup_add_program_validator, pl); if (button == BTN_CANCEL) --
