apps: Add a first app WiP - texteditor

devs/vitorsousa/csharp
Andy Williams 5 years ago
parent bc275959dd
commit 6be0a68c19
  1. 13
      apps/c/texteditor/meson.build
  2. 12
      apps/c/texteditor/src/meson.build
  3. 79
      apps/c/texteditor/src/texteditor_main.c

@ -0,0 +1,13 @@
project(
'efl-example-texteditor', 'c',
version : '0.0.1',
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
meson_version : '>= 0.38.0')
eina = dependency('eina', version : '>=1.20.99')
efl = dependency('efl-ui', version : '>=1.20.99')
elm = dependency('elementary', version : '>=1.20.99')
inc = include_directories('.')
subdir('src')

@ -0,0 +1,12 @@
src = files([
'texteditor_main.c',
])
deps = [eina, efl, elm]
executable('efl_example_texteditor', src,
dependencies : deps,
include_directories : inc,
install : true
)

@ -0,0 +1,79 @@
#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()
Loading…
Cancel
Save