aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/elementary/test_win_indicator.c
blob: 0ebb30bf0f81a154d5ce40d88a7b6642e9a032e0 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Efl_Ui.h>
#include <Elementary.h>

static void
_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   printf("Clock value is changed\n");
}

static Evas_Object *
_create_indicator(void)
{
   const char *indi_name;

   Eo *win = efl_add_ref(EFL_UI_WIN_SOCKET_CLASS, NULL,
		     efl_text_set(efl_added, "indicator"),
		     efl_ui_win_autodel_set(efl_added, EINA_TRUE),
		     efl_ui_win_alpha_set(efl_added, EINA_TRUE));

   if (!win)
     {
        printf("fail to create a portrait indicator window\n");
        return NULL;
     }

   indi_name = "elm_indicator_portrait";

   if (!efl_ui_win_socket_listen(win, indi_name, 0, EINA_FALSE))
     {
        printf("failed to listen portrait window socket.\n");
        efl_del(win);
        return NULL;
     }

   Eo *bx = efl_add(EFL_UI_BOX_CLASS, win,
                    efl_content_set(win, efl_added));

   efl_add(EFL_UI_CLOCK_CLASS, bx,
           efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
           efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
           efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_HOUR, EINA_FALSE),
           efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_MINUTE, EINA_FALSE),
           efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_AMPM, EINA_FALSE),
           efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_SECOND, EINA_FALSE),
           efl_ui_clock_field_visible_set(efl_added, EFL_UI_CLOCK_TYPE_DAY, EINA_FALSE),
           efl_ui_clock_pause_set(efl_added, EINA_TRUE),
           efl_event_callback_add(efl_added, EFL_UI_CLOCK_EVENT_CHANGED, _changed_cb, NULL),
           efl_pack(bx, efl_added));

   efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 30));
   return win;
}

static void
_off_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_OFF);
}

static void
_opaque_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_BG_OPAQUE);
}

static void
_transparent_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_BG_TRANSPARENT);
}

static void
_hidden_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
	efl_ui_win_indicator_mode_set(data, EFL_UI_WIN_INDICATOR_MODE_HIDDEN);
}

static void
_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
{
	efl_del(data);
}

void
test_win_indicator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Eo *win, *indicator;

   indicator = _create_indicator();

   // FIXME: Resizing window should no cause sizing issues!
   win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
                 efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
                 efl_text_set(efl_added, "Efl.Win.Indicator"),
                 efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(300, -1)),
                 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
   efl_event_callback_add(win, EFL_EVENT_DEL, _win_del, indicator);
   efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 360));

   Eo *bx = efl_add(EFL_UI_BOX_CLASS, win,
                    efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(300, 0)),
                    efl_content_set(win, efl_added));

   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_text_set(efl_added, "Indicator Off"),
           efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _off_clicked, win),
           efl_pack(bx, efl_added));
   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_text_set(efl_added, "Bg Opaque"),
           efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _opaque_clicked, win),
           efl_pack(bx, efl_added));
   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_text_set(efl_added, "Bg Transparent"),
           efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _transparent_clicked, win),
           efl_pack(bx, efl_added));
   efl_add(EFL_UI_BUTTON_CLASS, win,
           efl_text_set(efl_added, "Hidden"),
           efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _hidden_clicked, win),
           efl_pack(bx, efl_added));
}