summaryrefslogtreecommitdiff
path: root/src/lib
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/lib
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/lib')
-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
3 files changed, 136 insertions, 179 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 *