summaryrefslogtreecommitdiff
path: root/reference/c/ui/src/ui_translation.c
blob: 33e8041d1d735dc72431e527c5c86469f488f67c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define EFL_BETA_API_SUPPORT 1

#include <stdio.h>

#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>

/*
 * Efl.Ui translation exmaples.
 *
 * Efl.Ui contains a way to manage translations provided by gettext or
 * other translation provider. This example shows how to set it up and to
 * extract strings for translation. (see src/meson.build).
 *
 * The gettext extraction command is:
 * "xgettext --keyword=efl_ui_translatable_text_set:2 --from-code=utf-8 --foreign-user"
 *
 * In this project you can go to build/ and execute "ninja example_translation-pot"
 */
#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)
{
   Efl_Ui_Win *win, *box;

   win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
                 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
                 efl_text_set(efl_added, "Translations"),
                 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_add(EFL_UI_BUTTON_CLASS, win,
           efl_ui_l10n_text_set(efl_added, "Translations", _TEXT_DOMAIN),
           efl_pack_end(box, efl_added));

   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_ui_l10n_text_set(efl_added, "Help", _TEXT_DOMAIN),
           efl_pack_end(box, efl_added));

   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_ui_l10n_text_set(efl_added, "Quit", _TEXT_DOMAIN),
           efl_pack_end(box, efl_added),
           efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
           efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
                                  _gui_quit_cb, efl_added));

   efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));
}
EFL_MAIN()