hello-gui: Simplify gui basic example

devs/vitorsousa/csharp
Andy Williams 5 years ago
parent d4beab8013
commit 326f860e39
  1. 43
      tutorial/c/hello-gui/src/gui_main.c

@ -13,14 +13,6 @@ _gui_editor_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
printf("Change recorded: %s\n", efl_text_get(editor));
}
static void
_gui_about_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *button = data;
printf("Clicked About\n");
}
static void
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
@ -30,9 +22,8 @@ _gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
static void
_gui_setup()
{
Eo *win, *box, *hbox, *editor, *button;
Eo *win, *box, *editor;
// TODO can we have nicer methods like efl_ui_win_add?
win = efl_add(EFL_UI_WIN_CLASS, NULL,
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
@ -42,6 +33,18 @@ _gui_setup()
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
// TODO make this a single label with anewline in it
efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_set(efl_added, "Hello World."),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
efl_pack(box, efl_added));
efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_set(efl_added, "You can edit the text below to generate change events..."),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
efl_pack(box, efl_added));
editor = efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_set(efl_added, "Edit me"),
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
@ -50,20 +53,12 @@ _gui_setup()
efl_event_callback_add(editor, EFL_UI_TEXT_EVENT_CHANGED_USER,
_gui_editor_changed_cb, editor);
hbox = efl_add(EFL_UI_BOX_CLASS, box,
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added));
button = efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "About"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_about_clicked_cb, efl_added));
button = efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "Quit"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, box,
efl_text_set(efl_added, "Quit"),
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));
}
EAPI_MAIN void

Loading…
Cancel
Save