summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-11-03 11:59:31 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2016-11-03 11:59:32 +0530
commitb0d2e987f3a37291cd1e1090ba0812c3b4a0ed67 (patch)
tree0580d724badc2f6c1bb67670bc5d595c630cfd06
parentc425140a67745adfecc34c849a895a039705ef26 (diff)
Efl.Ui.Clock: Add elm module & theme
Summary: depends on D3938 Reviewers: yashu21985, bu5hm4n, woohyun, Hermet, raster, jpeg Subscribers: gohwoon.jeong, cedric, seoz, jpeg Differential Revision: https://phab.enlightenment.org/D3939
-rw-r--r--data/elementary/themes/default.edc1
-rw-r--r--data/elementary/themes/edc/elm/uiclock.edc207
-rw-r--r--src/Makefile_Elementary.am28
-rw-r--r--src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c399
4 files changed, 635 insertions, 0 deletions
diff --git a/data/elementary/themes/default.edc b/data/elementary/themes/default.edc
index a15732994f..701aba09ca 100644
--- a/data/elementary/themes/default.edc
+++ b/data/elementary/themes/default.edc
@@ -37,6 +37,7 @@ collections {
37#include "edc/elm/photo.edc" 37#include "edc/elm/photo.edc"
38#include "edc/elm/focus.edc" 38#include "edc/elm/focus.edc"
39#include "edc/elm/datetime.edc" 39#include "edc/elm/datetime.edc"
40#include "edc/elm/uiclock.edc"
40#include "edc/elm/player.edc" 41#include "edc/elm/player.edc"
41#include "edc/elm/thumb.edc" 42#include "edc/elm/thumb.edc"
42#include "edc/elm/pointer.edc" 43#include "edc/elm/pointer.edc"
diff --git a/data/elementary/themes/edc/elm/uiclock.edc b/data/elementary/themes/edc/elm/uiclock.edc
new file mode 100644
index 0000000000..348c2f221f
--- /dev/null
+++ b/data/elementary/themes/edc/elm/uiclock.edc
@@ -0,0 +1,207 @@
1#define DATETIME_FIELD(_pos) \
2 part { \
3 name: "field"#_pos; type: SWALLOW; \
4 scale: 1; \
5 clip_to: "clip"; \
6 description { state: "default" 0.0; \
7 visible: 0; \
8 min: 0 0; \
9 align: 0.0 0.5; \
10 fixed: 1 1; \
11 rel1.relative: 1.0 0.0; \
12 rel1.to: "separator"#_pos; \
13 rel2.relative: 1.0 1.0; \
14 rel2.to: "separator"#_pos; \
15 } \
16 description { state: "enable" 0.0; \
17 inherit: "default" 0.0; \
18 visible: 1; \
19 min: 8 10; \
20 } \
21 } \
22 programs{ \
23 program { name: "field_"#_pos"enabled"; \
24 signal: "field"#_pos",enable"; source: "elm"; \
25 action: STATE_SET "enable" 0.0; \
26 target: "field"#_pos; \
27 } \
28 program { name: "field_"#_pos"disabled"; \
29 signal: "field"#_pos",disable"; source: "elm"; \
30 action: STATE_SET "default" 0.0; \
31 target: "field"#_pos; \
32 } \
33 }
34#define DATETIME_SEPARATOR(_pos, _after) \
35 part { \
36 name: "separator"#_pos; type: TEXT; \
37 scale: 1; \
38 effect: SHADOW BOTTOM; \
39 clip_to: "disclip"; \
40 description { state: "default" 0.0; \
41 visible: 0; \
42 min: 0 0; \
43 align: 0.0 0.5; \
44 fixed: 1 0; \
45 rel1 { \
46 relative: 1.0 0.0; \
47 to: "field"#_after; \
48 } \
49 rel2 { \
50 relative: 1.0 1.0; \
51 to: "field"#_after; \
52 } \
53 color_class: "datetime_separator_text"; \
54 text { \
55 font: "Sans"; size: 10; \
56 min: 1 0; \
57 ellipsis: -1; \
58 align: 0.5 0.5; \
59 text_class: "datetime_separator_text"; \
60 } \
61 } \
62 description { state: "enable" 0.0; \
63 inherit: "default" 0.0; \
64 visible: 1; \
65 min: 8 10; \
66 } \
67 } \
68 part { \
69 name: "separator"#_pos"d"; type: TEXT; \
70 scale: 1; \
71 effect: SHADOW BOTTOM; \
72 clip_to: "disclip2"; \
73 description { state: "default" 0.0; \
74 visible: 0; \
75 rel1.to: "separator"#_pos; \
76 rel2.to: "separator"#_pos; \
77 color_class: "datetime_separator_text_disabled"; \
78 text { \
79 text_source: "separator"#_pos; \
80 font: "Sans"; size: 10; \
81 text_class: "datetime_separator_text_disabled"; \
82 } \
83 } \
84 description { state: "enable" 0.0; \
85 inherit: "default" 0.0; \
86 visible: 1; \
87 } \
88 } \
89 programs { \
90 program { \
91 signal: "field"#_after",enable"; source: "elm"; \
92 action: STATE_SET "enable" 0.0; \
93 target: "separator"#_pos; \
94 target: "separator"#_pos"d"; \
95 } \
96 program { \
97 signal: "field"#_after",disable"; source: "elm"; \
98 action: STATE_SET "default" 0.0; \
99 target: "separator"#_pos; \
100 target: "separator"#_pos"d"; \
101 } \
102 }
103group { name: "elm/uiclock/base/default";
104 parts {
105 part { name: "bg"; type: RECT;
106 description { state: "default" 0.0;
107 color_class: "datetime_bg";
108 }
109 }
110 part { name: "clip"; type: RECT;
111 description { state: "default" 0.0;
112 rel1.to: "separator0";
113 rel2.to: "separator7";
114 }
115 }
116 part { name: "disclip"; type: RECT;
117 clip_to: "clip";
118 description { state: "default" 0.0;
119 rel1.to: "separator0";
120 rel2.to: "separator7";
121 }
122 description { state: "disabled" 0.0;
123 inherit: "default" 0.0;
124 visible: 0;
125 }
126 }
127 part { name: "disclip2"; type: RECT;
128 clip_to: "clip";
129 description { state: "default" 0.0;
130 rel1.to: "separator0";
131 rel2.to: "separator7";
132 visible: 0;
133 }
134 description { state: "disabled" 0.0;
135 inherit: "default" 0.0;
136 visible: 1;
137 }
138 }
139 part { name: "separator0"; type: SPACER;
140 scale: 1;
141 description { state: "default" 0.0;
142 min: 8 10;
143 align: 0.0 0.5;
144 fixed: 1 0;
145 rel2.relative: 0.0 1.0;
146 }
147 }
148 DATETIME_FIELD(0)
149 DATETIME_SEPARATOR(1,0)
150 DATETIME_FIELD(1)
151 DATETIME_SEPARATOR(2,1)
152 DATETIME_FIELD(2)
153 DATETIME_SEPARATOR(3,2)
154 DATETIME_FIELD(3)
155 DATETIME_SEPARATOR(4,3)
156 DATETIME_FIELD(4)
157 DATETIME_SEPARATOR(5,4)
158 DATETIME_FIELD(5)
159 DATETIME_SEPARATOR(6,5)
160 DATETIME_FIELD(6)
161 DATETIME_SEPARATOR(7,6)
162 DATETIME_FIELD(7)
163 DATETIME_SEPARATOR(8,7)
164 part { name: "separator9"; type: SPACER;
165 description { state: "default" 0.0;
166 rel1.to: "separator7";
167 rel1.relative: 1.0 0.0;
168 min: 8 10;
169 }
170 }
171 part { name: "discover"; type: RECT;
172 description { state: "default" 0.0;
173 rel1.to: "separator0";
174 rel2.to: "separator7";
175 visible: 0;
176 color: 0 0 0 0;
177 }
178 description { state: "disabled" 0.0;
179 inherit: "default" 0.0;
180 visible: 1;
181 }
182 }
183 part { name: "elm.access"; type: RECT; repeat_events: 1;
184 description { state: "default" 0.0;
185 color: 0 0 0 0;
186 }
187 }
188 }
189 programs {
190 program {
191 signal: "elm,state,disabled"; source: "elm";
192 action: STATE_SET "disabled" 0.0;
193 target: "disclip";
194 target: "disclip2";
195 target: "discover";
196 }
197 program {
198 signal: "elm,state,enabled"; source: "elm";
199 action: STATE_SET "default" 0.0;
200 target: "disclip";
201 target: "disclip2";
202 target: "discover";
203 }
204 }
205}
206#undef DATETIME_SEPARATOR
207#undef DATETIME_FIELD
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index fec21c2a6d..dd7813423d 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -992,6 +992,34 @@ modules_elementary_datetime_input_ctxpopup_module_la_DEPENDENCIES = @USE_ELEMENT
992modules_elementary_datetime_input_ctxpopup_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ 992modules_elementary_datetime_input_ctxpopup_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
993modules_elementary_datetime_input_ctxpopup_module_la_LIBTOOLFLAGS = --tag=disable-static 993modules_elementary_datetime_input_ctxpopup_module_la_LIBTOOLFLAGS = --tag=disable-static
994 994
995## clock_input_ctxpopup
996
997moduleclock_input_ctxpopuppkgdir = $(libdir)/elementary/modules/clock_input_ctxpopup/$(MODULE_ARCH)
998moduleclock_input_ctxpopuppkg_LTLIBRARIES = modules/elementary/clock_input_ctxpopup/module.la
999
1000# Workaround for broken parallel install support in automake (relink issue)
1001# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7328
1002install_moduleclock_input_ctxpopuppkgLTLIBRARIES = install-moduleclock_input_ctxpopuppkgLTLIBRARIES
1003$(install_moduleclock_input_ctxpopuppkgLTLIBRARIES): install-libLTLIBRARIES
1004
1005modules_elementary_clock_input_ctxpopup_module_la_SOURCES = \
1006modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
1007modules_elementary_clock_input_ctxpopup_module_la_CPPFLAGS = \
1008-DELM_INTERNAL_API_ARGESFSDFEFC=1 \
1009-I. \
1010-I$(top_builddir) \
1011-I$(top_srcdir) \
1012-I$(top_srcdir)/src/lib/elementary \
1013-I$(top_builddir)/src/lib/elementary \
1014-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
1015-DPACKAGE_LIB_DIR=\"$(libdir)\" \
1016-DELEMENTARY_BUILD \
1017@ELEMENTARY_CFLAGS@
1018modules_elementary_clock_input_ctxpopup_module_la_LIBADD = @USE_ELEMENTARY_LIBS@
1019modules_elementary_clock_input_ctxpopup_module_la_DEPENDENCIES = @USE_ELEMENTARY_INTERNAL_LIBS@
1020modules_elementary_clock_input_ctxpopup_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
1021modules_elementary_clock_input_ctxpopup_module_la_LIBTOOLFLAGS = --tag=disable-static
1022
995## prefs 1023## prefs
996 1024
997moduleprefspkgdir = $(libdir)/elementary/modules/prefs/$(MODULE_ARCH) 1025moduleprefspkgdir = $(libdir)/elementary/modules/prefs/$(MODULE_ARCH)
diff --git a/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c b/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
new file mode 100644
index 0000000000..95f123224b
--- /dev/null
+++ b/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
@@ -0,0 +1,399 @@
1#ifdef HAVE_CONFIG_H
2#include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_widget.h"
7#include "efl_ui_clock_private.h"
8
9#define CLOCK_FIELD_COUNT 8
10#define FIELD_FORMAT_LEN 3
11#define DISKSELECTOR_MIN_ITEMS 4
12#define BUFF_SIZE 1024
13
14typedef struct _Ctxpopup_Module_Data Ctxpopup_Module_Data;
15typedef struct _DiskItem_Data DiskItem_Data;
16
17struct _Ctxpopup_Module_Data
18{
19 Efl_Ui_Clock_Module_Data mod_data;
20 Evas_Object *ctxpopup;
21};
22
23struct _DiskItem_Data
24{
25 Ctxpopup_Module_Data *ctx_mod;
26 Efl_Ui_Clock_Type sel_field_type;
27 unsigned int sel_field_value;
28};
29
30static void
31_diskselector_item_free_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
32{
33 free(data);
34}
35
36static void
37_ctxpopup_dismissed_cb(void *data, const Efl_Event *event)
38{
39 Ctxpopup_Module_Data *ctx_mod;
40 ctx_mod = (Ctxpopup_Module_Data *)data;
41 evas_object_del(event->object);
42 ctx_mod->ctxpopup = NULL;
43}
44
45static void
46_clock_resize_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED,
47 void *event_info EINA_UNUSED)
48{
49 Ctxpopup_Module_Data *ctx_mod;
50
51 ctx_mod = (Ctxpopup_Module_Data *)data;
52 if (!ctx_mod || !ctx_mod->ctxpopup) return;
53
54 evas_object_hide(ctx_mod->ctxpopup);
55}
56
57static void
58_clock_move_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED,
59 void *event_info EINA_UNUSED)
60{
61 Ctxpopup_Module_Data *ctx_mod;
62
63 ctx_mod = (Ctxpopup_Module_Data *)data;
64 if (!ctx_mod || !ctx_mod->ctxpopup) return;
65
66 evas_object_hide(ctx_mod->ctxpopup);
67}
68
69static void
70_field_value_set(struct tm *tim, Efl_Ui_Clock_Type field_type, int val)
71{
72 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return;
73
74 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
75 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
76 *timearr[field_type] = val;
77}
78
79static int
80_field_value_get(struct tm *tim, Efl_Ui_Clock_Type field_type)
81{
82 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return -1;
83
84 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
85 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
86 return (*timearr[field_type]);
87}
88
89static void
90_diskselector_cb(void *data EINA_UNUSED, const Efl_Event *event)
91{
92 DiskItem_Data *disk_data;
93 struct tm curr_time;
94 const char *fmt;
95
96 disk_data = (DiskItem_Data *)elm_object_item_data_get(event->info);
97 if (!disk_data || !(disk_data->ctx_mod)) return;
98
99 efl_ui_clock_value_get(disk_data->ctx_mod->mod_data.base, &curr_time);
100 fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type);
101 if ((disk_data->sel_field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) ||
102 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12))
103 disk_data->sel_field_value += 12;
104 _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value);
105 efl_ui_clock_value_set(disk_data->ctx_mod->mod_data.base, &curr_time);
106 evas_object_hide(disk_data->ctx_mod->ctxpopup);
107}
108
109static void
110_ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
111{
112 Ctxpopup_Module_Data *ctx_mod;
113 struct tm curr_time;
114
115 ctx_mod = (Ctxpopup_Module_Data *)data;
116 if (!ctx_mod) return;
117
118 efl_ui_clock_value_get(ctx_mod->mod_data.base, &curr_time);
119 if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12;
120 else curr_time.tm_hour += 12;
121 efl_ui_clock_value_set(ctx_mod->mod_data.base, &curr_time);
122}
123
124static void
125_field_clicked_cb(void *data, const Efl_Event *event)
126{
127 Ctxpopup_Module_Data *ctx_mod;
128 Evas_Object *diskselector;
129 Elm_Object_Item *item;
130 DiskItem_Data *disk_data;
131 Efl_Ui_Clock_Type field_type;
132 time_t t;
133 struct tm time1;
134 char buf[BUFF_SIZE], label[BUFF_SIZE];
135 const char *fmt;
136 int idx, min, max, val;
137 unsigned int display_item_num, text_len = 0;
138 Evas_Coord x = 0, y = 0, w = 0, h = 0, width;
139
140 ctx_mod = (Ctxpopup_Module_Data *)data;
141 if (!ctx_mod) return;
142
143 if (!efl_ui_clock_edit_mode_get(ctx_mod->mod_data.base))
144 return;
145
146 snprintf(buf, sizeof(buf), "datetime/%s", elm_object_style_get(event->object));
147
148 if (ctx_mod->ctxpopup)
149 evas_object_del(ctx_mod->ctxpopup);
150 ctx_mod->ctxpopup = elm_ctxpopup_add(event->object);
151 elm_object_style_set(ctx_mod->ctxpopup, buf);
152 elm_ctxpopup_horizontal_set(ctx_mod->ctxpopup, EINA_TRUE);
153 evas_object_size_hint_weight_set(ctx_mod->ctxpopup, EVAS_HINT_EXPAND,
154 EVAS_HINT_EXPAND);
155 evas_object_size_hint_align_set(ctx_mod->ctxpopup, EVAS_HINT_FILL, 0.5);
156 efl_event_callback_add
157 (ctx_mod->ctxpopup, ELM_CTXPOPUP_EVENT_DISMISSED, _ctxpopup_dismissed_cb, ctx_mod);
158 elm_ctxpopup_hover_parent_set(ctx_mod->ctxpopup, elm_widget_top_get(event->object));
159
160 diskselector = elm_diskselector_add(elm_widget_top_get(ctx_mod->mod_data.base));
161 efl_event_callback_add
162 (diskselector, EFL_UI_EVENT_CLICKED, _diskselector_cb, NULL);
163 elm_object_style_set(diskselector, buf);
164 elm_object_content_set(ctx_mod->ctxpopup, diskselector);
165
166 t = time(NULL);
167 localtime_r(&t, &time1);
168
169 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(event->object, "_field_type");
170 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
171 efl_ui_clock_value_get(ctx_mod->mod_data.base, &time1);
172 val = _field_value_get(&time1, field_type);
173 ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max);
174
175 time1.tm_mday = 1; // To avoid month wrapping, set the first day of the month to start with.
176
177 if ((field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) ||
178 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))))
179 {
180 if (max >= 12) max -= 12;
181 if (val >= 12) val -= 12;
182 if (min >= 12) min -= 12;
183 }
184 for (idx = min; idx <= max; idx++)
185 {
186 _field_value_set(&time1, field_type, idx);
187 strftime(label, BUFF_SIZE, fmt, &time1);
188 if (strlen(label) > text_len) text_len = strlen(label);
189 if (idx == val)
190 {
191 item = elm_diskselector_item_append(diskselector, label, NULL, NULL, NULL);
192 elm_diskselector_item_selected_set(item, EINA_TRUE);
193 }
194 else
195 {
196 disk_data = (DiskItem_Data *) malloc (sizeof(DiskItem_Data));
197 disk_data->ctx_mod = ctx_mod;
198 disk_data->sel_field_type = field_type;
199 disk_data->sel_field_value = idx;
200 item = elm_diskselector_item_append(diskselector, label, NULL, NULL, disk_data);
201 elm_object_item_del_cb_set(item, _diskselector_item_free_cb);
202 }
203 }
204 elm_diskselector_side_text_max_length_set(diskselector, text_len);
205
206 evas_object_geometry_get(event->object, &x, &y, &w, &h);
207 evas_object_geometry_get(elm_widget_top_get(ctx_mod->mod_data.base), NULL, NULL, &width, NULL);
208 evas_object_size_hint_min_set(ctx_mod->ctxpopup, width, -1);
209 display_item_num = width / (w + elm_config_finger_size_get());
210 // always display even number of items to avoid autoselection
211 if (display_item_num % 2) display_item_num -= 1;
212 if (display_item_num < DISKSELECTOR_MIN_ITEMS)
213 display_item_num = DISKSELECTOR_MIN_ITEMS;
214 elm_diskselector_display_item_num_set(diskselector, display_item_num);
215 elm_diskselector_round_enabled_set(diskselector, EINA_TRUE);
216
217 elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN,
218 ELM_CTXPOPUP_DIRECTION_UP, -1, -1);
219 evas_object_move(ctx_mod->ctxpopup, (x+w/2), (y+h));
220
221 // if the direction of Ctxpopup is upwards, move it to the top of datetime
222 if (elm_ctxpopup_direction_get(ctx_mod->ctxpopup) == ELM_CTXPOPUP_DIRECTION_UP)
223 {
224 elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
225 ELM_CTXPOPUP_DIRECTION_DOWN, -1, -1);
226 evas_object_move(ctx_mod->ctxpopup, (x + w / 2), y);
227 }
228 evas_object_show(ctx_mod->ctxpopup);
229}
230
231static void
232_access_set(Evas_Object *obj, Efl_Ui_Clock_Type field_type)
233{
234 const char* type = NULL;
235
236 switch (field_type)
237 {
238 case EFL_UI_CLOCK_TYPE_YEAR:
239 type = "datetime field, year";
240 break;
241
242 case EFL_UI_CLOCK_TYPE_MONTH:
243 type = "datetime field, month";
244 break;
245
246 case EFL_UI_CLOCK_TYPE_DATE:
247 type = "datetime field, date";
248 break;
249
250 case EFL_UI_CLOCK_TYPE_HOUR:
251 type = "datetime field, hour";
252 break;
253
254 case EFL_UI_CLOCK_TYPE_MINUTE:
255 type = "datetime field, minute";
256 break;
257
258 case EFL_UI_CLOCK_TYPE_AMPM:
259 type = "datetime field, AM PM";
260 break;
261
262 default:
263 break;
264 }
265
266 _elm_access_text_set
267 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type);
268 _elm_access_callback_set
269 (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL);
270}
271
272// module funcs for the specific module type
273EAPI void
274field_value_display(Efl_Ui_Clock_Module_Data *module_data, Evas_Object *obj)
275{
276 Ctxpopup_Module_Data *ctx_mod;
277 Efl_Ui_Clock_Type field_type;
278 struct tm tim;
279 char buf[BUFF_SIZE];
280 const char *fmt;
281
282 ctx_mod = (Ctxpopup_Module_Data *)module_data;
283 if (!ctx_mod || !obj) return;
284
285 efl_ui_clock_value_get(ctx_mod->mod_data.base, &tim);
286 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(obj, "_field_type");
287 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
288 buf[0] = 0;
289 strftime(buf, sizeof(buf), fmt, &tim);
290 if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P"))))
291 {
292 // yes BUFF_SIZE is more than 2 bytes!
293 if (tim.tm_hour < 12) strcpy(buf, "AM");
294 else strcpy(buf, "PM");
295 }
296 elm_object_text_set(obj, buf);
297}
298
299EAPI Evas_Object *
300field_create(Efl_Ui_Clock_Module_Data *module_data, Efl_Ui_Clock_Type field_type)
301{
302 Ctxpopup_Module_Data *ctx_mod;
303 Evas_Object *field_obj;
304
305 ctx_mod = (Ctxpopup_Module_Data *)module_data;
306 if (!ctx_mod) return NULL;
307
308 if (field_type == EFL_UI_CLOCK_TYPE_AMPM)
309 {
310 field_obj = elm_button_add(ctx_mod->mod_data.base);
311 efl_event_callback_add
312 (field_obj, EFL_UI_EVENT_CLICKED, _ampm_clicked_cb, ctx_mod);
313 }
314 else
315 {
316 field_obj = elm_entry_add(ctx_mod->mod_data.base);
317 elm_entry_single_line_set(field_obj, EINA_TRUE);
318 elm_entry_editable_set(field_obj, EINA_FALSE);
319 elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE);
320 elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE);
321 efl_event_callback_add
322 (field_obj, EFL_UI_EVENT_CLICKED, _field_clicked_cb, ctx_mod);
323 }
324 evas_object_data_set(field_obj, "_field_type", (void *)field_type);
325
326 // ACCESS
327 _access_set(field_obj, field_type);
328
329 return field_obj;
330}
331
332EAPI Efl_Ui_Clock_Module_Data *
333obj_hook(Evas_Object *obj)
334{
335 Ctxpopup_Module_Data *ctx_mod;
336 ctx_mod = calloc(1, sizeof(Ctxpopup_Module_Data));
337 if (!ctx_mod) return NULL;
338
339 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
340 _clock_resize_cb, ctx_mod);
341 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
342 _clock_move_cb, ctx_mod);
343
344 return ((Efl_Ui_Clock_Module_Data*)ctx_mod);
345}
346
347EAPI void
348obj_unhook(Efl_Ui_Clock_Module_Data *module_data)
349{
350 Ctxpopup_Module_Data *ctx_mod;
351
352 ctx_mod = (Ctxpopup_Module_Data *)module_data;
353 if (!ctx_mod) return;
354
355 if (ctx_mod->ctxpopup)
356 evas_object_del(ctx_mod->ctxpopup);
357
358 free(ctx_mod);
359 ctx_mod = NULL;
360}
361
362EAPI void
363obj_hide(Efl_Ui_Clock_Module_Data *module_data)
364{
365 Ctxpopup_Module_Data *ctx_mod;
366
367 ctx_mod = (Ctxpopup_Module_Data *)module_data;
368 if (!ctx_mod) return;
369
370 if (ctx_mod->ctxpopup)
371 evas_object_hide(ctx_mod->ctxpopup);
372}
373
374// module api funcs needed
375EAPI int
376elm_modapi_init(void *m EINA_UNUSED)
377{
378 return 1; // succeed always
379}
380
381EAPI int
382elm_modapi_shutdown(void *m EINA_UNUSED)
383{
384 return 1; // succeed always
385}
386
387static Eina_Bool
388_module_init(void)
389{
390 return EINA_TRUE;
391}
392
393static void
394_module_shutdown(void)
395{
396}
397
398EINA_MODULE_INIT(_module_init);
399EINA_MODULE_SHUTDOWN(_module_shutdown);