ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/tools/examples.git/commit/?id=eabdff1f2731c680f08e31b3a07d06ecc0d23036
commit eabdff1f2731c680f08e31b3a07d06ecc0d23036 Author: Andy Williams <a...@andywilliams.me> Date: Wed Dec 13 12:53:11 2017 +0000 ui: Fix close callbacks for the UI reference examples --- reference/c/ui/src/ui_container.c | 14 +++++++++++++- reference/c/ui/src/ui_sizing.c | 10 ++++++++++ reference/c/ui/src/ui_translation.c | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/reference/c/ui/src/ui_container.c b/reference/c/ui/src/ui_container.c index 8ded077..2dd3b0c 100644 --- a/reference/c/ui/src/ui_container.c +++ b/reference/c/ui/src/ui_container.c @@ -21,6 +21,13 @@ * TODO - still ELM Table */ +// quit the app, called if the user clicks the Quit button or the window is deleted +static void +_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) +{ + efl_exit(0); +} + // Load a simple grid layout into the window static Efl_Ui_Grid * _ui_grid_setup(Efl_Ui_Win *win) @@ -99,7 +106,9 @@ _ui_panes_setup(Efl_Ui_Win *win) efl_add(EFL_UI_BUTTON_CLASS, win, efl_text_set(efl_added, "Quit"), - efl_content_set(efl_part(horiz_split, "second"), efl_added)); + efl_content_set(efl_part(horiz_split, "second"), efl_added), + efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, + _gui_quit_cb, efl_added)); } EAPI_MAIN void @@ -114,6 +123,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) // _ui_panes_setup(win); _ui_boxes_setup(win); + // when the user clicks "close" on a window there is a request to delete + efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL); + efl_gfx_size_set(win, EINA_SIZE2D(350, 250)); } diff --git a/reference/c/ui/src/ui_sizing.c b/reference/c/ui/src/ui_sizing.c index f21ffdf..8815466 100644 --- a/reference/c/ui/src/ui_sizing.c +++ b/reference/c/ui/src/ui_sizing.c @@ -15,6 +15,13 @@ * and the last has a min size. Try resizing the window to see how this changes. */ +// quit the app, called if the window is deleted +static void +_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) +{ + efl_exit(0); +} + EAPI_MAIN void efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) { @@ -25,6 +32,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) efl_text_set(efl_added, "Size Control"), efl_ui_win_autodel_set(efl_added, EINA_TRUE)); + // when the user clicks "close" on a window there is a request to delete + efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL); + box = efl_add(EFL_UI_BOX_CLASS, win, efl_content_set(win, efl_added)); diff --git a/reference/c/ui/src/ui_translation.c b/reference/c/ui/src/ui_translation.c index 70f383c..8b4dc4c 100644 --- a/reference/c/ui/src/ui_translation.c +++ b/reference/c/ui/src/ui_translation.c @@ -21,6 +21,13 @@ */ #define _TEXT_DOMAIN "example_translation" +// quit the app, called if the user clicks the Quit button or the window is deleted +static void +_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) +{ + efl_exit(0); +} + EAPI_MAIN void efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) { @@ -32,6 +39,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) _TEXT_DOMAIN), efl_ui_win_autodel_set(efl_added, EINA_TRUE)); + // when the user clicks "close" on a window there is a request to delete + efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL); + box = efl_add(EFL_UI_BOX_CLASS, win, efl_content_set(win, efl_added)); @@ -46,7 +56,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) efl_add(EFL_UI_BUTTON_CLASS, win, efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN), efl_pack_end(box, efl_added), - efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100))); + efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)), + efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, + _gui_quit_cb, efl_added)); efl_gfx_size_set(win, EINA_SIZE2D(320, 320)); } --