summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/lib/elementary/efl_ui_clock.c255
-rw-r--r--src/lib/elementary/efl_ui_clock.eo1
-rw-r--r--src/lib/elementary/efl_ui_clock.h59
-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
6 files changed, 136 insertions, 597 deletions
diff --git a/src/lib/elementary/efl_ui_clock.c b/src/lib/elementary/efl_ui_clock.c
index 02dd9b82c6..63b9e17618 100644
--- a/src/lib/elementary/efl_ui_clock.c
+++ b/src/lib/elementary/efl_ui_clock.c
@@ -29,6 +29,7 @@
29#define MAX_SEPARATOR_LEN 6 29#define MAX_SEPARATOR_LEN 6
30#define MIN_DAYS_IN_MONTH 28 30#define MIN_DAYS_IN_MONTH 28
31#define BUFFER_SIZE 1024 31#define BUFFER_SIZE 1024
32#define CLOCK_FIELD_COUNT 8
32 33
33/* interface between EDC & C code (field & signal names). values 0 to 34/* interface between EDC & C code (field & signal names). values 0 to
34 * EFL_UI_CLOCK_TYPE_COUNT are in the valid range, and must get in the 35 * EFL_UI_CLOCK_TYPE_COUNT are in the valid range, and must get in the
@@ -95,49 +96,140 @@ static void _part_name_snprintf(char *buffer, int buffer_size,
95 snprintf(buffer, buffer_size, template + 4, n); 96 snprintf(buffer, buffer_size, template + 4, n);
96} 97}
97 98
98static Elm_Module * 99static void
99_dt_mod_find(void) 100_field_value_set(struct tm *tim, Efl_Ui_Clock_Type field_type, int val)
101{
102 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return;
103
104 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
105 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
106 *timearr[field_type] = val;
107}
108
109static int
110_field_value_get(struct tm *tim, Efl_Ui_Clock_Type field_type)
111{
112 if (field_type >= (CLOCK_FIELD_COUNT - 1)) return -1;
113
114 int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour,
115 &tim->tm_min, &tim->tm_sec, &tim->tm_wday };
116 return (*timearr[field_type]);
117}
118
119static void
120_ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
121{
122 struct tm curr_time;
123
124 curr_time = efl_ui_clock_time_get(data);
125 if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12;
126 else curr_time.tm_hour += 12;
127 efl_ui_clock_time_set(data, curr_time);
128}
129
130static void
131_access_set(Evas_Object *obj, Efl_Ui_Clock_Type field_type)
132{
133 const char* type = NULL;
134
135 switch (field_type)
136 {
137 case EFL_UI_CLOCK_TYPE_YEAR:
138 type = "datetime field, year";
139 break;
140
141 case EFL_UI_CLOCK_TYPE_MONTH:
142 type = "datetime field, month";
143 break;
144
145 case EFL_UI_CLOCK_TYPE_DATE:
146 type = "datetime field, date";
147 break;
148
149 case EFL_UI_CLOCK_TYPE_HOUR:
150 type = "datetime field, hour";
151 break;
152
153 case EFL_UI_CLOCK_TYPE_MINUTE:
154 type = "datetime field, minute";
155 break;
156
157 case EFL_UI_CLOCK_TYPE_AMPM:
158 type = "datetime field, AM PM";
159 break;
160
161 default:
162 break;
163 }
164
165 _elm_access_text_set
166 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type);
167 _elm_access_callback_set
168 (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL);
169}
170
171static const char *
172_field_format_get(Evas_Object *obj,
173 Efl_Ui_Clock_Type field_type)
100{ 174{
101 static int tried_fallback = 0; 175 Clock_Field *field;
102 Elm_Module *mod = _elm_module_find_as("clock/api"); 176
177 if (field_type > EFL_UI_CLOCK_TYPE_AMPM) return NULL;
103 178
104 if (mod) return mod; 179 EFL_UI_CLOCK_DATA_GET(obj, sd);
105 if (!tried_fallback && 180
106 (!_elm_config->modules || !strstr(_elm_config->modules, "clock/api"))) 181 field = sd->field_list + field_type;
182
183 return field->fmt;
184}
185
186static void
187field_value_display(Eo *obj, Evas_Object *item_obj)
188{
189 Efl_Ui_Clock_Type field_type;
190 struct tm tim;
191 char buf[BUFFER_SIZE];
192 const char *fmt;
193
194 tim = efl_ui_clock_time_get(obj);
195 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(item_obj, "_field_type");
196 fmt = _field_format_get(obj, field_type);
197 buf[0] = 0;
198 strftime(buf, sizeof(buf), fmt, &tim);
199 if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P"))))
107 { 200 {
108 // See also _config_update(): we hardcode here the default module 201 // yes BUFFER_SIZE is more than 2 bytes!
109 ERR("Elementary config does not contain the required module " 202 if (tim.tm_hour < 12) strcpy(buf, "AM");
110 "name for the clock widget! Verify your installation."); 203 else strcpy(buf, "PM");
111 _elm_module_add("clock_input_ctxpopup", "clock/api");
112 mod = _elm_module_find_as("clock/api");
113 tried_fallback = EINA_TRUE;
114 } 204 }
115 return mod; 205 elm_object_text_set(item_obj, buf);
116} 206}
117 207
118static Clock_Mod_Api * 208static Evas_Object *
119_dt_mod_init() 209field_create(Eo *obj, Efl_Ui_Clock_Type field_type)
120{ 210{
121 Elm_Module *mod; 211 Evas_Object *field_obj;
122 212
123 mod = _dt_mod_find(); 213 if (field_type == EFL_UI_CLOCK_TYPE_AMPM)
124 if (!mod) return NULL; 214 {
125 if (mod->api) return mod->api; 215 field_obj = elm_button_add(obj);
126 mod->api = malloc(sizeof(Clock_Mod_Api)); 216 efl_event_callback_add
127 if (!mod->api) return NULL; 217 (field_obj, EFL_INPUT_EVENT_CLICKED, _ampm_clicked_cb, obj);
128 218 }
129 ((Clock_Mod_Api *)(mod->api))->obj_hook = 219 else
130 _elm_module_symbol_get(mod, "obj_hook"); 220 {
131 ((Clock_Mod_Api *)(mod->api))->obj_unhook = 221 field_obj = elm_entry_add(obj);
132 _elm_module_symbol_get(mod, "obj_unhook"); 222 elm_entry_single_line_set(field_obj, EINA_TRUE);
133 ((Clock_Mod_Api *)(mod->api))->obj_hide = 223 elm_entry_editable_set(field_obj, EINA_FALSE);
134 _elm_module_symbol_get(mod, "obj_hide"); 224 elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE);
135 ((Clock_Mod_Api *)(mod->api))->field_create = 225 elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE);
136 _elm_module_symbol_get(mod, "field_create"); 226 }
137 ((Clock_Mod_Api *)(mod->api))->field_value_display = 227 evas_object_data_set(field_obj, "_field_type", (void *)field_type);
138 _elm_module_symbol_get(mod, "field_value_display"); 228
139 229 // ACCESS
140 return mod->api; 230 _access_set(field_obj, field_type);
231
232 return field_obj;
141} 233}
142 234
143static void 235static void
@@ -145,18 +237,14 @@ _field_list_display(Evas_Object *obj)
145{ 237{
146 Clock_Field *field; 238 Clock_Field *field;
147 unsigned int idx = 0; 239 unsigned int idx = 0;
148 Clock_Mod_Api *dt_mod;
149 240
150 EFL_UI_CLOCK_DATA_GET(obj, sd); 241 EFL_UI_CLOCK_DATA_GET(obj, sd);
151 242
152 dt_mod = _dt_mod_init();
153 if (!dt_mod || !dt_mod->field_value_display) return;
154
155 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) 243 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++)
156 { 244 {
157 field = sd->field_list + idx; 245 field = sd->field_list + idx;
158 if (field->fmt_exist && field->visible) 246 if (field->fmt_exist && field->visible)
159 dt_mod->field_value_display(sd->mod_data, field->item_obj); 247 field_value_display(obj, field->item_obj);
160 } 248 }
161} 249}
162 250
@@ -483,24 +571,6 @@ _efl_ui_clock_edit_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd)
483 return sd->edit_mode; 571 return sd->edit_mode;
484} 572}
485 573
486EOLIAN static Eina_Bool
487_efl_ui_clock_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Clock_Data *sd)
488{
489 Eina_Bool int_ret = EINA_FALSE;
490
491 int_ret = efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS));
492 if (!int_ret) return EINA_FALSE;
493
494 if (!efl_ui_focus_object_focus_get(obj))
495 {
496 Clock_Mod_Api *dt_mod = _dt_mod_init();
497 if ((dt_mod) && (dt_mod->obj_hide))
498 dt_mod->obj_hide(sd->mod_data);
499 }
500
501 return EINA_TRUE;
502}
503
504EOLIAN static void 574EOLIAN static void
505_efl_ui_clock_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Clock_Data *sd) 575_efl_ui_clock_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Clock_Data *sd)
506{ 576{
@@ -517,16 +587,12 @@ _efl_ui_clock_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Clock_Data *sd)
517 Clock_Field *field; 587 Clock_Field *field;
518 char buf[BUFFER_SIZE]; 588 char buf[BUFFER_SIZE];
519 unsigned int idx; 589 unsigned int idx;
520 Clock_Mod_Api *dt_mod;
521 590
522 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 591 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
523 592
524 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 593 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
525 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; 594 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
526 595
527 dt_mod = _dt_mod_init();
528 if ((!dt_mod) || (!dt_mod->field_value_display)) return EINA_TRUE;
529
530 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) 596 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++)
531 { 597 {
532 field = sd->field_list + idx; 598 field = sd->field_list + idx;
@@ -548,7 +614,7 @@ _efl_ui_clock_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Clock_Data *sd)
548 elm_layout_text_set(obj, buf, field->separator); 614 elm_layout_text_set(obj, buf, field->separator);
549 } 615 }
550 616
551 dt_mod->field_value_display(sd->mod_data, field->item_obj); 617 field_value_display(obj, field->item_obj);
552 } 618 }
553 else 619 else
554 { 620 {
@@ -699,21 +765,6 @@ _apply_range_restrictions(struct tm *tim)
699 } 765 }
700} 766}
701 767
702static const char *
703_field_format_get(Evas_Object *obj,
704 Efl_Ui_Clock_Type field_type)
705{
706 Clock_Field *field;
707
708 if (field_type > EFL_UI_CLOCK_TYPE_AMPM) return NULL;
709
710 EFL_UI_CLOCK_DATA_GET(obj, sd);
711
712 field = sd->field_list + field_type;
713
714 return field->fmt;
715}
716
717static void 768static void
718_field_limit_get(Evas_Object *obj, 769_field_limit_get(Evas_Object *obj,
719 Efl_Ui_Clock_Type field_type, 770 Efl_Ui_Clock_Type field_type,
@@ -822,11 +873,9 @@ _ticker(void *data)
822 873
823 if (sd->curr_time.tm_sec > 0) 874 if (sd->curr_time.tm_sec > 0)
824 { 875 {
825 Clock_Mod_Api *dt_mod = _dt_mod_init();
826 field = sd->field_list + EFL_UI_CLOCK_TYPE_SECOND; 876 field = sd->field_list + EFL_UI_CLOCK_TYPE_SECOND;
827 if (field->fmt_exist && field->visible && 877 if (field->fmt_exist && field->visible)
828 dt_mod && dt_mod->field_value_display) 878 field_value_display(data, field->item_obj);
829 dt_mod->field_value_display(sd->mod_data, field->item_obj);
830 } 879 }
831 else 880 else
832 _field_list_display(data); 881 _field_list_display(data);
@@ -842,7 +891,6 @@ EOLIAN static void
842_efl_ui_clock_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Clock_Data *priv) 891_efl_ui_clock_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Clock_Data *priv)
843{ 892{
844 Clock_Field *field; 893 Clock_Field *field;
845 Clock_Mod_Api *dt_mod;
846 int idx; 894 int idx;
847 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 895 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
848 896
@@ -856,33 +904,11 @@ _efl_ui_clock_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Clock_Data *priv)
856 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC) 904 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
857 CRI("Failed to set layout!"); 905 CRI("Failed to set layout!");
858 906
859 // module - initialise module for clock 907 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++)
860 dt_mod = _dt_mod_init();
861 if (dt_mod)
862 { 908 {
863 if (dt_mod->obj_hook) 909 field = priv->field_list + idx;
864 { 910 field->item_obj = field_create(obj, idx);
865 priv->mod_data = dt_mod->obj_hook(obj);
866
867 // update module data
868 if (priv->mod_data)
869 {
870 priv->mod_data->base = obj;
871 priv->mod_data->field_limit_get = _field_limit_get;
872 priv->mod_data->field_format_get = _field_format_get;
873 }
874 }
875
876 if (dt_mod->field_create)
877 {
878 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++)
879 {
880 field = priv->field_list + idx;
881 field->item_obj = dt_mod->field_create(priv->mod_data, idx);
882 }
883 }
884 } 911 }
885 else WRN("Failed to load clock module, clock widget may not show properly!");
886 912
887 priv->freeze_sizing = EINA_TRUE; 913 priv->freeze_sizing = EINA_TRUE;
888 914
@@ -916,7 +942,6 @@ _efl_ui_clock_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Clock_Data *sd)
916{ 942{
917 Clock_Field *tmp; 943 Clock_Field *tmp;
918 unsigned int idx; 944 unsigned int idx;
919 Clock_Mod_Api *dt_mod;
920 945
921 ecore_timer_del(sd->ticker); 946 ecore_timer_del(sd->ticker);
922 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) 947 for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++)
@@ -926,10 +951,6 @@ _efl_ui_clock_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Clock_Data *sd)
926 eina_stringshare_del(tmp->separator); 951 eina_stringshare_del(tmp->separator);
927 } 952 }
928 953
929 dt_mod = _dt_mod_init();
930 if ((dt_mod) && (dt_mod->obj_unhook))
931 dt_mod->obj_unhook(sd->mod_data); // module - unhook
932
933 efl_canvas_group_del(efl_super(obj, MY_CLASS)); 954 efl_canvas_group_del(efl_super(obj, MY_CLASS));
934} 955}
935 956
@@ -1037,11 +1058,7 @@ _efl_ui_clock_field_visible_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Ui_Clock_Typ
1037 efl_canvas_group_change(obj); 1058 efl_canvas_group_change(obj);
1038 1059
1039 if (!visible) return; 1060 if (!visible) return;
1040 { 1061 field_value_display(obj, field->item_obj);
1041 Clock_Mod_Api *dt_mod = _dt_mod_init();
1042 if (!dt_mod || !dt_mod->field_value_display) return;
1043 dt_mod->field_value_display(sd->mod_data, field->item_obj);
1044 }
1045} 1062}
1046 1063
1047EOLIAN static void 1064EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_clock.eo b/src/lib/elementary/efl_ui_clock.eo
index 715c494aae..6b92a3cf67 100644
--- a/src/lib/elementary/efl_ui_clock.eo
+++ b/src/lib/elementary/efl_ui_clock.eo
@@ -225,7 +225,6 @@ class @beta Efl.Ui.Clock extends Efl.Ui.Layout_Base
225 Efl.Object.constructor; 225 Efl.Object.constructor;
226 Efl.Canvas.Group.group_calculate; 226 Efl.Canvas.Group.group_calculate;
227 Efl.Ui.Widget.theme_apply; 227 Efl.Ui.Widget.theme_apply;
228 Efl.Ui.Focus.Object.on_focus_update;
229 Efl.Ui.L10n.translation_update; 228 Efl.Ui.L10n.translation_update;
230 } 229 }
231 events { 230 events {
diff --git a/src/lib/elementary/efl_ui_clock.h b/src/lib/elementary/efl_ui_clock.h
index 1115faaf45..c883db2eee 100644
--- a/src/lib/elementary/efl_ui_clock.h
+++ b/src/lib/elementary/efl_ui_clock.h
@@ -97,8 +97,6 @@
97 * the corresponding user format. 97 * the corresponding user format.
98 * 98 *
99 * Clock supports six fields: Year, Month, Date, Hour, Minute, AM/PM. 99 * Clock supports six fields: Year, Month, Date, Hour, Minute, AM/PM.
100 * Depending on the Clock module that is loaded, the user can see
101 * different UI to select the individual field values.
102 * 100 *
103 * The individual fields of Clock can be arranged in any order according to the format 101 * The individual fields of Clock can be arranged in any order according to the format
104 * set by application. 102 * set by application.
@@ -117,63 +115,6 @@
117 * The whole widget is left aligned and its size grows horizontally depending 115 * The whole widget is left aligned and its size grows horizontally depending
118 * on the current format and each field's visible/disabled state. 116 * on the current format and each field's visible/disabled state.
119 * 117 *
120 * Clock individual field selection is implemented in a modular style.
121 * Module can be implemented as a Ctxpopup based selection or an ISE based
122 * selection or even a spinner like selection etc.
123 *
124 * <b>Clock Module design:</b>
125 *
126 * The following functions are expected to be implemented in a Clock module:
127 *
128 * <b>Field creation:</b>
129 * <pre>
130 *
131 * __________ __________
132 * | |----- obj_hook() ---------------------->>>| |
133 * | |<<<----------------returns Mod_data ------| |
134 * | Clock |_______ | |
135 * | widget | |Assign module call backs | Module |
136 * | base |<<<____| | |
137 * | | | |
138 * | |----- field_create() ------------------>>>| |
139 * |__________|<<<----------------returns field_obj -----|__________|
140 *
141 * </pre>
142 *
143 * <b>Field value setting:</b>
144 * <pre>
145 *
146 * __________ __________
147 * | | | |
148 * | Clock |<<<----------efl_ui_clock_time_set()----| |
149 * | widget | | Module |
150 * | base |----display_field_value()------------>>>| |
151 * |__________| |__________|
152 *
153 * </pre>
154 *
155 * <b>del_hook:</b>
156 * <pre>
157 * __________ __________
158 * | | | |
159 * | Clock |----obj_unhook()-------------------->>>>| |
160 * | widget | | Module |
161 * | base | <<<-----frees mod_data---------| |
162 * |__________| |__________|
163 *
164 * </pre>
165 *
166 *
167 * Any module can use the following shared functions that are implemented in efl_ui_clock.c :
168 *
169 * <b>field_format_get()</b> - gives the field format.
170 *
171 * <b>field_limit_get()</b> - gives the field minimum, maximum limits.
172 *
173 * To enable a module, set the ELM_MODULES environment variable as shown:
174 *
175 * <b>export ELM_MODULES="clock_input_ctxpopup>clock/api"</b>
176 *
177 * This widget inherits from the @ref Layout one, so that all the 118 * This widget inherits from the @ref Layout one, so that all the
178 * functions acting on it also work for Clock objects. 119 * functions acting on it also work for Clock objects.
179 * 120 *
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',