Let's use the window callback to avoid elm_policy needs

devs/vitorsousa/csharp
Andy Williams 5 years ago
parent 36b64dfca1
commit c99595e00a
  1. 16
      apps/c/life/src/life_main.c
  2. 10
      apps/c/texteditor/src/texteditor_main.c
  3. 10
      tutorial/c/hello-gui/src/gui_main.c

@ -14,6 +14,13 @@ _life_win_resize(void *data EINA_UNUSED, const Efl_Event *event)
life_render_layout(win);
}
static void
_life_win_quit(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
// quit the mainloop
efl_exit(0);
}
static void
_life_win_touch(void *data EINA_UNUSED, const Efl_Event *event)
{
@ -59,10 +66,11 @@ _life_win_setup(void)
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
if (!win) return NULL;
// TODO
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
w = 10 * LIFE_BOARD_WIDTH * efl_ui_scale_get(win);
h = 10 * LIFE_BOARD_HEIGHT * efl_ui_scale_get(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, _life_win_quit, NULL);
w = 10 * LIFE_BOARD_WIDTH * efl_gfx_scale_get(win);
h = 10 * LIFE_BOARD_HEIGHT * efl_gfx_scale_get(win);
life_board_init();
life_render_init(win);

@ -14,7 +14,7 @@ _gui_new_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
}
static void
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
efl_exit(0);
}
@ -52,7 +52,7 @@ _gui_toolbar_setup(Efl_Ui_Box *parent)
efl_add(EFL_UI_BOX_CLASS, parent,
efl_pack(bar, efl_added),
efl_gfx_size_hint_weight_set(efl_added, 10, 0));
_gui_toolbar_button_add(bar, "Quit", "application-exit", _gui_quit_clicked_cb);
_gui_toolbar_button_add(bar, "Quit", "application-exit", _gui_quit_cb);
}
static void
@ -65,6 +65,9 @@ _gui_setup()
efl_text_set(efl_added, "Text Editor"),
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),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
@ -83,9 +86,6 @@ _gui_setup()
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
// TODO this to a efl_ui_policy method
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
_gui_setup();
}
EFL_MAIN()

@ -6,7 +6,7 @@
#include <Efl_Ui.h>
static void
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
efl_exit(0);
}
@ -21,6 +21,9 @@ _gui_setup()
efl_text_set(efl_added, "Hello World"),
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),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
@ -37,15 +40,12 @@ _gui_setup()
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
_gui_quit_cb, efl_added));
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
// TODO this to a efl_ui_policy method
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
_gui_setup();
}
EFL_MAIN()

Loading…
Cancel
Save