rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=ee1c2d0fdf3fddce0e84016411e03f3eb44712c4
commit ee1c2d0fdf3fddce0e84016411e03f3eb44712c4 Author: Vyacheslav Reutskiy <[email protected]> Date: Fri Oct 28 11:01:58 2016 +0300 popup: add user callback for popup We have a problem with popups, its not sync. So if we need to manage the reaction on popup buttons need to use callbacks from popup buttons. Firstly this need if need to show several popups successibly. This patch make it posible Fixes 4672 Change-Id: Id22a7169c01ff73966149d282e3171d3804163e9 --- src/bin/ui/main_window.c | 23 ++++++++++++++------ src/bin/ui/main_window.h | 6 +++++- src/bin/ui/menu.c | 6 +----- src/bin/ui/popup.c | 2 +- src/bin/ui/project_close.c | 6 ++++-- src/bin/ui/tab_home_import_edc.c | 23 ++++++++++++++------ src/bin/ui/tab_home_import_edj.c | 25 ++++++++++++++++------ src/bin/ui/tab_home_new.c | 24 +++++++++++++++------ src/bin/ui/tab_home_open.c | 46 +++++++++++++++++++++++++++++----------- 9 files changed, 116 insertions(+), 45 deletions(-) diff --git a/src/bin/ui/main_window.c b/src/bin/ui/main_window.c index f90ec20..2fded4d 100644 --- a/src/bin/ui/main_window.c +++ b/src/bin/ui/main_window.c @@ -54,13 +54,14 @@ _help(void *data __UNUSED__, shortcuts_window_add(); } -Eina_Bool -ui_main_window_del(void) +static void +_after_popup_close(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { - ap.exit_in_progress = true; - if (ap.project) - if (!project_close()) - return false; + Popup_Button pbtn = (Popup_Button) event_info; + + if (BTN_CANCEL == pbtn) return; #ifdef HAVE_ENVENTOR code_edit_mode_switch(false); @@ -74,7 +75,17 @@ ui_main_window_del(void) evas_object_del(ap.property.group); INFO("%s %s - Finished...", PACKAGE_NAME, VERSION); elm_exit(); +} + +Eina_Bool +ui_main_window_del(void) +{ + ap.exit_in_progress = true; + if (ap.project) + if (!project_close(_after_popup_close, NULL)) + return false; + _after_popup_close(NULL, NULL, (void *)BTN_OK); return true; } diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h index ea893b8..c817e2b 100644 --- a/src/bin/ui/main_window.h +++ b/src/bin/ui/main_window.h @@ -316,12 +316,16 @@ project_save(void); * This function will ask user what to do with opened project * (if it is changed). * + * @param func The Evas_Smart_Cb will be call on popup close. Popup_button is a + * event info for this callback + * @param data The user data for callback + * * @return EINA_TRUE on success, otherwise EINA_FALSE. * * @ingroup Window */ Eina_Bool -project_close(void); +project_close(Evas_Smart_Cb func, void *data); /** * Create and show popup with given title and content. Only one - Evas_Object or diff --git a/src/bin/ui/menu.c b/src/bin/ui/menu.c index ac18cf1..f39b2e9 100644 --- a/src/bin/ui/menu.c +++ b/src/bin/ui/menu.c @@ -124,11 +124,7 @@ _menu_cb(void *data __UNUSED__, break; case MENU_FILE_CLOSE_PROJECT: { - if (!project_close()) break; - //tabs_menu_tab_open(TAB_HOME_OPEN_PROJECT); - ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_BASE, true); - ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_STYLE_ONLY, true); - ui_menu_disable_set(ap.menu, MENU_FILE_SAVE, true); + if (!project_close(NULL, NULL)) break; } break; case MENU_FILE_EXIT: diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index 5bb0032..e093c68 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -81,7 +81,6 @@ static void _popup_del_job(void *data) { Popup_Data *pd= data; - shortcuts_object_check_pop(pd->popup); evas_object_del(pd->popup); free(pd); } @@ -97,6 +96,7 @@ _popup_btn_cb(void *data, assert(pd->popup != NULL); ecore_job_add(_popup_del_job, pd); + shortcuts_object_check_pop(pd->popup); evas_object_smart_callback_call(pd->popup, POPUP_CLOSE_CB, data); /* menu clould be deleted in POPUP_CLOSE_CB in exit confirmation popup */ if (ap.menu) diff --git a/src/bin/ui/project_close.c b/src/bin/ui/project_close.c index 146f004..df9377f 100644 --- a/src/bin/ui/project_close.c +++ b/src/bin/ui/project_close.c @@ -175,12 +175,12 @@ _popup_close_cb(void *data __UNUSED__, if (ap.exit_in_progress) ui_main_window_del(); else - project_close(); + project_close(NULL, NULL); } #endif Eina_Bool -project_close(void) +project_close(Evas_Smart_Cb func, void *data) { char buf[PATH_MAX]; PM_Project_Result result; @@ -200,6 +200,7 @@ project_close(void) NULL, NULL); evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _popup_close_cb, NULL); + evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, func, data); eina_stringshare_del(title); return false; } @@ -216,6 +217,7 @@ project_close(void) ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_BASE, true); ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_STYLE_ONLY, true); + ui_menu_disable_set(ap.menu, MENU_FILE_SAVE, true); project_navigator_project_unset(); /* some code in close project callback checks ap.project for NULL, so we need to diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c index 955e9b0..89608e4 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -433,15 +433,14 @@ _after_import_check(void *data __UNUSED__) } static void -_import(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_after_popup_close(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { Eina_Strbuf *buf; + Popup_Button pbtn = (Popup_Button) event_info; - if (ap.project) - if (!project_close()) - return; + if (BTN_CANCEL == pbtn) return; buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s/%s/%s.pro", @@ -471,6 +470,18 @@ _import(void *data __UNUSED__, eina_strbuf_free(buf); } +static void +_import(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + if (ap.project) + if (!project_close(_after_popup_close, NULL)) + return; + + _after_popup_close(NULL, NULL, (void *)BTN_OK); +} + void _tab_import_edc_del(void *data __UNUSED__, Evas *e __UNUSED__, diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index 4f63eb3..affa96d 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -488,16 +488,17 @@ _after_import_check(void *data __UNUSED__) elm_object_focus_set(ap.splash, true); evas_object_show(ap.splash); } + + static void -_import(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_after_popup_close(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { Eina_Strbuf *buf; + Popup_Button pbtn = (Popup_Button) event_info; - if (ap.project) - if (!project_close()) - return; + if (BTN_CANCEL == pbtn) return; buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "%s/%s/%s.pro", @@ -527,6 +528,18 @@ _import(void *data __UNUSED__, } static void +_import(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + if (ap.project) + if (!project_close(_after_popup_close, NULL)) + return; + + _after_popup_close(NULL, NULL, (void *)BTN_OK); +} + +static void _elipsis(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index 9588f58..c82a3e1 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -535,16 +535,16 @@ _after_on_create_check(void *data __UNUSED__) evas_object_show(ap.splash); elm_check_state_set(tab_new.ch_all, false); } + static void -_on_create(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_after_popup_close(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) { Eina_Strbuf *buf; + Popup_Button pbtn = (Popup_Button) event_info; - if (ap.project) - if (!project_close()) - return; + if (BTN_CANCEL == pbtn) return; buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, @@ -564,6 +564,18 @@ _on_create(void *data __UNUSED__, } static void +_on_create(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + if (ap.project) + if (!project_close(_after_popup_close, NULL)) + return; + + _after_popup_close(NULL, NULL, (void *)BTN_OK); +} + +static void _validate(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) diff --git a/src/bin/ui/tab_home_open.c b/src/bin/ui/tab_home_open.c index 53adaf2..3eaa1a5 100644 --- a/src/bin/ui/tab_home_open.c +++ b/src/bin/ui/tab_home_open.c @@ -77,16 +77,14 @@ _cancel_open_splash(void *data __UNUSED__, Splash_Status status __UNUSED__) return true; } + static void -_open_done(void *data __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_open_after_popup_close(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) { const char *selected; - if (ap.project) - if (!project_close()) - return; selected = elm_fileselector_selected_get(tab.fs); if ((!selected) || !eina_str_has_suffix(selected, ".pro")) return; @@ -106,6 +104,18 @@ _open_done(void *data __UNUSED__, } static void +_open_done(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + if (ap.project) + if (!project_close(_open_after_popup_close, NULL)) + return; + + _open_after_popup_close(NULL, NULL, (void *)BTN_OK); +} + +static void _selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) @@ -187,15 +197,14 @@ _tab_open_project_add(void) } static void -_open_recent(void *data, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_recent_after_popup_close(void *data, + Evas_Object *obj __UNUSED__, + void *event_info) { Recent *r = (Recent *)data; + Popup_Button pbtn = (Popup_Button) event_info; - if (ap.project) - if (!project_close()) - return; + if (BTN_CANCEL == pbtn) return; if (!pm_lock_check(r->path)) { @@ -212,6 +221,19 @@ _open_recent(void *data, evas_object_show(ap.splash); } +static void +_open_recent(void *data, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + + if (ap.project) + if (!project_close(_recent_after_popup_close, data)) + return; + + _recent_after_popup_close(data, NULL, (void *)BTN_OK); +} + void _tab_open_project_recents_update(void) { --
