80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
#define EFL_EO_API_SUPPORT 1
|
|
#define EFL_BETA_API_SUPPORT 1
|
|
|
|
#include <Eina.h>
|
|
#include <Elementary.h>
|
|
#include <Efl_Ui.h>
|
|
|
|
Efl_Ui_Text *_editor;
|
|
|
|
static void
|
|
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
|
{
|
|
efl_exit(0);
|
|
}
|
|
|
|
static void
|
|
_gui_toolbar_button_add(Efl_Ui_Box *toolbar, const char *name,
|
|
const char *icon_name, Efl_Event_Cb func)
|
|
{
|
|
Efl_Ui_Button *button;
|
|
|
|
button = efl_add(EFL_UI_BUTTON_CLASS, toolbar,
|
|
efl_text_set(efl_added, name),
|
|
efl_pack(toolbar, efl_added),
|
|
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
|
|
func, efl_added));
|
|
// TODO actually show the icon in the button
|
|
efl_add(EFL_UI_IMAGE_CLASS, toolbar,
|
|
efl_ui_image_icon_set(efl_added, icon_name),
|
|
efl_content_set(efl_part(button, "icon"), efl_added));
|
|
}
|
|
|
|
static void
|
|
_gui_toolbar_setup(Efl_Ui_Box *parent)
|
|
{
|
|
Efl_Ui_Box *bar;
|
|
|
|
bar = efl_add(EFL_UI_BOX_CLASS, parent,
|
|
efl_pack(parent, efl_added),
|
|
efl_gfx_size_hint_max_set(efl_added, EINA_SIZE2D(10000, 40)),
|
|
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL));
|
|
|
|
_gui_toolbar_button_add(bar, "Quit", "application-exit", _gui_quit_clicked_cb);
|
|
}
|
|
|
|
static void
|
|
_gui_setup()
|
|
{
|
|
Eo *win, *box;
|
|
|
|
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
|
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
|
|
efl_text_set(efl_added, "Text Editor"),
|
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
|
|
|
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)));
|
|
|
|
_gui_toolbar_setup(box);
|
|
|
|
_editor = efl_add(EFL_UI_TEXT_CLASS, box,
|
|
efl_text_set(efl_added, "Edit me"),
|
|
efl_text_font_set(efl_added, "Mono", 14),
|
|
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
|
|
efl_ui_text_scrollable_set(efl_added, EINA_TRUE),
|
|
efl_pack(box, 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()
|
|
|