summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-05 12:14:48 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-06 09:26:34 +0200
commit88910d6a65cd6d803dcb06bcf9b8112d2f44f26a (patch)
tree72b7ecd52bd6336344f176439765c1fd519fafe8 /src/modules
parentc1b76d3008ecb7c558ad4ad8de02f1e03ffddf68 (diff)
efl_ui/clock: remove module interface
this was overly complex and never actually used ref T7868 Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9499
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c407
-rw-r--r--src/modules/elementary/clock_input_ctxpopup/meson.build10
-rw-r--r--src/modules/elementary/meson.build1
3 files changed, 0 insertions, 418 deletions
diff --git a/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c b/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
deleted file mode 100644
index d92a08618d..0000000000
--- a/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
+++ /dev/null
@@ -1,407 +0,0 @@
1#ifdef HAVE_CONFIG_H
2#include "elementary_config.h"
3#endif
4
5#include "Elementary.h"
6#include "elm_module_helper.h"
7#include "elm_widget.h"
8#include "efl_ui_clock_private.h"
9#include "elm_ctxpopup_item_eo.h"
10#include "elm_ctxpopup_eo.h"
11
12#ifndef EFL_BUILD
13# define EFL_BUILD
14#endif
15#undef ELM_MODULE_HELPER_H
16#include "elm_module_helper.h"
17
18#define CLOCK_FIELD_COUNT 8
19#define FIELD_FORMAT_LEN 3
20#define DISKSELECTOR_MIN_ITEMS 4
21#define BUFF_SIZE 1024
22
23typedef struct _Ctxpopup_Module_Data Ctxpopup_Module_Data;
24typedef struct _DiskItem_Data DiskItem_Data;
25
26struct _Ctxpopup_Module_Data
27{
28 Efl_Ui_Clock_Module_Data mod_data;
29 Evas_Object *ctxpopup;
30};
31
32struct _DiskItem_Data
33{
34 Ctxpopup_Module_Data *ctx_mod;
35 Efl_Ui_Clock_Type sel_field_type;
36 unsigned int sel_field_value;
37};
38
39static void
40_diskselector_item_free_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
41{
42 free(data);
43}
44
45static void
46_ctxpopup_dismissed_cb(void *data, const Efl_Event *event)
47{
48 Ctxpopup_Module_Data *ctx_mod;
49 ctx_mod = (Ctxpopup_Module_Data *)data;
50 evas_object_del(event->object);
51 ctx_mod->ctxpopup = NULL;
52}
53
54static void
55_clock_resize_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED,
56 void *event_info EINA_UNUSED)
57{
58 Ctxpopup_Module_Data *ctx_mod;
59
60 ctx_mod = (Ctxpopup_Module_Data *)data;
61 if (!ctx_mod || !ctx_mod->ctxpopup) return;
62
63 evas_object_hide(ctx_mod->ctxpopup);
64}
65
66static void
67_clock_move_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED,
68 void *event_info EINA_UNUSED)
69{
70 Ctxpopup_Module_Data *ctx_mod;
71
72 ctx_mod = (Ctxpopup_Module_Data *)data;
73 if (!ctx_mod || !ctx_mod->ctxpopup) return;
74
75 evas_object_hide(ctx_mod->ctxpopup);
76}
77
78static void
79_field_value_set(struct tm *tim, Efl_Ui_Clock_Type field_type, int val)
80{
81 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return;
82
83 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
84 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
85 *timearr[field_type] = val;
86}
87
88static int
89_field_value_get(struct tm *tim, Efl_Ui_Clock_Type field_type)
90{
91 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return -1;
92
93 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
94 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
95 return (*timearr[field_type]);
96}
97
98static void
99_diskselector_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
100{
101 DiskItem_Data *disk_data;
102 struct tm curr_time;
103 const char *fmt;
104
105 disk_data = (DiskItem_Data *)elm_object_item_data_get(event_info);
106 if (!disk_data || !(disk_data->ctx_mod)) return;
107
108 curr_time = efl_ui_clock_time_get(disk_data->ctx_mod->mod_data.base);
109 fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type);
110 if ((disk_data->sel_field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) ||
111 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12))
112 disk_data->sel_field_value += 12;
113 _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value);
114 efl_ui_clock_time_set(disk_data->ctx_mod->mod_data.base, curr_time);
115 evas_object_hide(disk_data->ctx_mod->ctxpopup);
116}
117
118static void
119_ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
120{
121 Ctxpopup_Module_Data *ctx_mod;
122 struct tm curr_time;
123
124 ctx_mod = (Ctxpopup_Module_Data *)data;
125 if (!ctx_mod) return;
126
127 curr_time = efl_ui_clock_time_get(ctx_mod->mod_data.base);
128 if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12;
129 else curr_time.tm_hour += 12;
130 efl_ui_clock_time_set(ctx_mod->mod_data.base, curr_time);
131}
132
133static void
134_field_clicked_cb(void *data, const Efl_Event *event)
135{
136 Ctxpopup_Module_Data *ctx_mod;
137 Evas_Object *diskselector;
138 Elm_Object_Item *item;
139 DiskItem_Data *disk_data;
140 Efl_Ui_Clock_Type field_type;
141 time_t t;
142 struct tm time1;
143 char buf[BUFF_SIZE], label[BUFF_SIZE];
144 const char *fmt;
145 int idx, min, max, val;
146 unsigned int display_item_num, text_len = 0;
147 Evas_Coord x = 0, y = 0, w = 0, h = 0, width;
148
149 ctx_mod = (Ctxpopup_Module_Data *)data;
150 if (!ctx_mod) return;
151
152 if (!efl_ui_clock_edit_mode_get(ctx_mod->mod_data.base))
153 return;
154
155 snprintf(buf, sizeof(buf), "datetime/%s", elm_object_style_get(event->object));
156
157 if (ctx_mod->ctxpopup)
158 evas_object_del(ctx_mod->ctxpopup);
159 ctx_mod->ctxpopup = elm_ctxpopup_add(event->object);
160 elm_object_style_set(ctx_mod->ctxpopup, buf);
161 elm_ctxpopup_horizontal_set(ctx_mod->ctxpopup, EINA_TRUE);
162 evas_object_size_hint_weight_set(ctx_mod->ctxpopup, EVAS_HINT_EXPAND,
163 EVAS_HINT_EXPAND);
164 evas_object_size_hint_align_set(ctx_mod->ctxpopup, EVAS_HINT_FILL, 0.5);
165 efl_event_callback_add
166 (ctx_mod->ctxpopup, ELM_CTXPOPUP_EVENT_DISMISSED, _ctxpopup_dismissed_cb, ctx_mod);
167 elm_ctxpopup_hover_parent_set(ctx_mod->ctxpopup, elm_widget_top_get(event->object));
168
169 diskselector = elm_diskselector_add(elm_widget_top_get(ctx_mod->mod_data.base));
170 evas_object_smart_callback_add(diskselector, "clicked", _diskselector_cb, NULL);
171 elm_object_style_set(diskselector, buf);
172 elm_object_content_set(ctx_mod->ctxpopup, diskselector);
173
174 t = time(NULL);
175 localtime_r(&t, &time1);
176
177 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(event->object, "_field_type");
178 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
179 time1 = efl_ui_clock_time_get(ctx_mod->mod_data.base);
180 val = _field_value_get(&time1, field_type);
181 ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max);
182
183 time1.tm_mday = 1; // To avoid month wrapping, set the first day of the month to start with.
184
185 if ((field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) ||
186 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))))
187 {
188 if (max >= 12) max -= 12;
189 if (val >= 12) val -= 12;
190 if (min >= 12) min -= 12;
191 }
192 for (idx = min; idx <= max; idx++)
193 {
194 _field_value_set(&time1, field_type, idx);
195 strftime(label, BUFF_SIZE, fmt, &time1);
196 if (strlen(label) > text_len) text_len = strlen(label);
197 if (idx == val)
198 {
199 item = elm_diskselector_item_append(diskselector, label, NULL, NULL, NULL);
200 elm_diskselector_item_selected_set(item, EINA_TRUE);
201 }
202 else
203 {
204 disk_data = (DiskItem_Data *) malloc (sizeof(DiskItem_Data));
205 disk_data->ctx_mod = ctx_mod;
206 disk_data->sel_field_type = field_type;
207 disk_data->sel_field_value = idx;
208 item = elm_diskselector_item_append(diskselector, label, NULL, NULL, disk_data);
209 elm_object_item_del_cb_set(item, _diskselector_item_free_cb);
210 }
211 }
212 elm_diskselector_side_text_max_length_set(diskselector, text_len);
213
214 evas_object_geometry_get(event->object, &x, &y, &w, &h);
215 evas_object_geometry_get(elm_widget_top_get(ctx_mod->mod_data.base), NULL, NULL, &width, NULL);
216 evas_object_size_hint_min_set(ctx_mod->ctxpopup, width, -1);
217 display_item_num = width / (w + elm_config_finger_size_get());
218 // always display even number of items to avoid autoselection
219 if (display_item_num % 2) display_item_num -= 1;
220 if (display_item_num < DISKSELECTOR_MIN_ITEMS)
221 display_item_num = DISKSELECTOR_MIN_ITEMS;
222 elm_diskselector_display_item_num_set(diskselector, display_item_num);
223 elm_diskselector_round_enabled_set(diskselector, EINA_TRUE);
224
225 elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN,
226 ELM_CTXPOPUP_DIRECTION_UP, -1, -1);
227 evas_object_move(ctx_mod->ctxpopup, (x+w/2), (y+h));
228
229 // if the direction of Ctxpopup is upwards, move it to the top of datetime
230 if (elm_ctxpopup_direction_get(ctx_mod->ctxpopup) == ELM_CTXPOPUP_DIRECTION_UP)
231 {
232 elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
233 ELM_CTXPOPUP_DIRECTION_DOWN, -1, -1);
234 evas_object_move(ctx_mod->ctxpopup, (x + w / 2), y);
235 }
236 evas_object_show(ctx_mod->ctxpopup);
237}
238
239static void
240_access_set(Evas_Object *obj, Efl_Ui_Clock_Type field_type)
241{
242 const char* type = NULL;
243
244 switch (field_type)
245 {
246 case EFL_UI_CLOCK_TYPE_YEAR:
247 type = "datetime field, year";
248 break;
249
250 case EFL_UI_CLOCK_TYPE_MONTH:
251 type = "datetime field, month";
252 break;
253
254 case EFL_UI_CLOCK_TYPE_DATE:
255 type = "datetime field, date";
256 break;
257
258 case EFL_UI_CLOCK_TYPE_HOUR:
259 type = "datetime field, hour";
260 break;
261
262 case EFL_UI_CLOCK_TYPE_MINUTE:
263 type = "datetime field, minute";
264 break;
265
266 case EFL_UI_CLOCK_TYPE_AMPM:
267 type = "datetime field, AM PM";
268 break;
269
270 default:
271 break;
272 }
273
274 _elm_access_text_set
275 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type);
276 _elm_access_callback_set
277 (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL);
278}
279
280// module funcs for the specific module type
281EAPI void
282field_value_display(Efl_Ui_Clock_Module_Data *module_data, Evas_Object *obj)
283{
284 Ctxpopup_Module_Data *ctx_mod;
285 Efl_Ui_Clock_Type field_type;
286 struct tm tim;
287 char buf[BUFF_SIZE];
288 const char *fmt;
289
290 ctx_mod = (Ctxpopup_Module_Data *)module_data;
291 if (!ctx_mod || !obj) return;
292
293 tim = efl_ui_clock_time_get(ctx_mod->mod_data.base);
294 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(obj, "_field_type");
295 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
296 buf[0] = 0;
297 strftime(buf, sizeof(buf), fmt, &tim);
298 if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P"))))
299 {
300 // yes BUFF_SIZE is more than 2 bytes!
301 if (tim.tm_hour < 12) strcpy(buf, "AM");
302 else strcpy(buf, "PM");
303 }
304 elm_object_text_set(obj, buf);
305}
306
307EAPI Evas_Object *
308field_create(Efl_Ui_Clock_Module_Data *module_data, Efl_Ui_Clock_Type field_type)
309{
310 Ctxpopup_Module_Data *ctx_mod;
311 Evas_Object *field_obj;
312
313 ctx_mod = (Ctxpopup_Module_Data *)module_data;
314 if (!ctx_mod) return NULL;
315
316 if (field_type == EFL_UI_CLOCK_TYPE_AMPM)
317 {
318 field_obj = elm_button_add(ctx_mod->mod_data.base);
319 efl_event_callback_add
320 (field_obj, EFL_INPUT_EVENT_CLICKED, _ampm_clicked_cb, ctx_mod);
321 }
322 else
323 {
324 field_obj = elm_entry_add(ctx_mod->mod_data.base);
325 elm_entry_single_line_set(field_obj, EINA_TRUE);
326 elm_entry_editable_set(field_obj, EINA_FALSE);
327 elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE);
328 elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE);
329 efl_event_callback_add
330 (field_obj, EFL_INPUT_EVENT_CLICKED, _field_clicked_cb, ctx_mod);
331 }
332 evas_object_data_set(field_obj, "_field_type", (void *)field_type);
333
334 // ACCESS
335 _access_set(field_obj, field_type);
336
337 return field_obj;
338}
339
340EAPI Efl_Ui_Clock_Module_Data *
341obj_hook(Evas_Object *obj)
342{
343 Ctxpopup_Module_Data *ctx_mod;
344 ctx_mod = calloc(1, sizeof(Ctxpopup_Module_Data));
345 if (!ctx_mod) return NULL;
346
347 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
348 _clock_resize_cb, ctx_mod);
349 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
350 _clock_move_cb, ctx_mod);
351
352 return ((Efl_Ui_Clock_Module_Data*)ctx_mod);
353}
354
355EAPI void
356obj_unhook(Efl_Ui_Clock_Module_Data *module_data)
357{
358 Ctxpopup_Module_Data *ctx_mod;
359
360 ctx_mod = (Ctxpopup_Module_Data *)module_data;
361 if (!ctx_mod) return;
362
363 if (ctx_mod->ctxpopup)
364 evas_object_del(ctx_mod->ctxpopup);
365
366 free(ctx_mod);
367 ctx_mod = NULL;
368}
369
370EAPI void
371obj_hide(Efl_Ui_Clock_Module_Data *module_data)
372{
373 Ctxpopup_Module_Data *ctx_mod;
374
375 ctx_mod = (Ctxpopup_Module_Data *)module_data;
376 if (!ctx_mod) return;
377
378 if (ctx_mod->ctxpopup)
379 evas_object_hide(ctx_mod->ctxpopup);
380}
381
382// module api funcs needed
383EAPI int
384elm_modapi_init(void *m EINA_UNUSED)
385{
386 return 1; // succeed always
387}
388
389EAPI int
390elm_modapi_shutdown(void *m EINA_UNUSED)
391{
392 return 1; // succeed always
393}
394
395static Eina_Bool
396_module_init(void)
397{
398 return EINA_TRUE;
399}
400
401static void
402_module_shutdown(void)
403{
404}
405
406EINA_MODULE_INIT(_module_init);
407EINA_MODULE_SHUTDOWN(_module_shutdown);
diff --git a/src/modules/elementary/clock_input_ctxpopup/meson.build b/src/modules/elementary/clock_input_ctxpopup/meson.build
deleted file mode 100644
index 04435773fe..0000000000
--- a/src/modules/elementary/clock_input_ctxpopup/meson.build
+++ /dev/null
@@ -1,10 +0,0 @@
1src = files([
2 'clock_input_ctxpopup.c',
3])
4
5shared_module(mod,
6 src,
7 dependencies: [elementary],
8 install: true,
9 install_dir : mod_install_dir
10)
diff --git a/src/modules/elementary/meson.build b/src/modules/elementary/meson.build
index ed77fe240e..8be55960e5 100644
--- a/src/modules/elementary/meson.build
+++ b/src/modules/elementary/meson.build
@@ -1,6 +1,5 @@
1mods = [ 1mods = [
2 'access_output', 2 'access_output',
3 'clock_input_ctxpopup',
4 'prefs', 3 'prefs',
5 'test_entry', 4 'test_entry',
6 'test_map', 5 'test_map',