1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Efl_Ui.h>
5 #include <Elementary.h>
6 
7 static void
_changed_cb(void * data EINA_UNUSED,const Efl_Event * ev EINA_UNUSED)8 _changed_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
9 {
10    printf("Clock value is changed\n");
11 }
12 
13 static Evas_Object *
_create_indicator(void)14 _create_indicator(void)
15 {
16    const char *indi_name;
17 
18    Eo *win = efl_add_ref(EFL_UI_WIN_SOCKET_CLASS, NULL,
19 		     efl_text_set(efl_added, "indicator"),
20 		     efl_ui_win_autodel_set(efl_added, EINA_TRUE),
21 		     efl_ui_win_alpha_set(efl_added, EINA_TRUE));
22 
23    if (!win)
24      {
25         printf("fail to create a portrait indicator window\n");
26         return NULL;
27      }
28 
29    indi_name = "elm_indicator_portrait";
30 
31    if (!efl_ui_win_socket_listen(win, indi_name, 0, EINA_FALSE))
32      {
33         printf("failed to listen portrait window socket.\n");
34         efl_del(win);
35         return NULL;
36      }
37 
38    Eo *bx = efl_add(EFL_UI_BOX_CLASS, win,
39                     efl_content_set(win, efl_added));
40 
41    efl_add(EFL_UI_CLOCK_CLASS, bx,
42            efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
43            efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
44            efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_HOUR, EINA_FALSE),
45            efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_MINUTE, EINA_FALSE),
46            efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_AMPM, EINA_FALSE),
47            efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_SECOND, EINA_FALSE),
48            efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_DAY, EINA_FALSE),
49            efl_ui_clock_pause_set(efl_added, EINA_TRUE),
50            efl_event_callback_add(efl_added, EFL_UI_CLOCK_EVENT_CHANGED, _changed_cb, NULL),
51            efl_pack(bx, efl_added));
52 
53    efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 30));
54    return win;
55 }
56 
57 static void
_off_clicked(void * data,const Efl_Event * ev EINA_UNUSED)58 _off_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
59 {
60 	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_OFF);
61 }
62 
63 static void
_opaque_clicked(void * data,const Efl_Event * ev EINA_UNUSED)64 _opaque_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
65 {
66 	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_BG_OPAQUE);
67 }
68 
69 static void
_transparent_clicked(void * data,const Efl_Event * ev EINA_UNUSED)70 _transparent_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
71 {
72 	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_BG_TRANSPARENT);
73 }
74 
75 static void
_hidden_clicked(void * data,const Efl_Event * ev EINA_UNUSED)76 _hidden_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
77 {
78 	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_HIDDEN);
79 }
80 
81 static void
_win_del(void * data,const Efl_Event * ev EINA_UNUSED)82 _win_del(void *data, const Efl_Event *ev EINA_UNUSED)
83 {
84 	efl_del(data);
85 }
86 
87 void
test_win_indicator(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)88 test_win_indicator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
89 {
90    Eo *win, *indicator;
91 
92    indicator = _create_indicator();
93 
94    // FIXME: Resizing window should no cause sizing issues!
95    win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
96                                   efl_text_set(efl_added, "Efl.Win.Indicator"),
97                  efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(300, -1)),
98                  efl_ui_win_autodel_set(efl_added, EINA_TRUE));
99    efl_event_callback_add(win, EFL_EVENT_DEL, _win_del, indicator);
100    efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 360));
101 
102    Eo *bx = efl_add(EFL_UI_BOX_CLASS, win,
103                     efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(300, 0)),
104                     efl_content_set(win, efl_added));
105 
106    efl_add(EFL_UI_BUTTON_CLASS, win,
107            efl_text_set(efl_added, "Indicator Off"),
108            efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _off_clicked, win),
109            efl_pack(bx, efl_added));
110    efl_add(EFL_UI_BUTTON_CLASS, win,
111            efl_text_set(efl_added, "Bg Opaque"),
112            efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _opaque_clicked, win),
113            efl_pack(bx, efl_added));
114    efl_add(EFL_UI_BUTTON_CLASS, win,
115            efl_text_set(efl_added, "Bg Transparent"),
116            efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _transparent_clicked, win),
117            efl_pack(bx, efl_added));
118    efl_add(EFL_UI_BUTTON_CLASS, win,
119            efl_text_set(efl_added, "Hidden"),
120            efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _hidden_clicked, win),
121            efl_pack(bx, efl_added));
122 }
123