diff options
author | Mike Blumenkrantz <zmike@samsung.com> | 2019-08-05 12:14:48 -0400 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-08-06 09:26:34 +0200 |
commit | 88910d6a65cd6d803dcb06bcf9b8112d2f44f26a (patch) | |
tree | 72b7ecd52bd6336344f176439765c1fd519fafe8 | |
parent | c1b76d3008ecb7c558ad4ad8de02f1e03ffddf68 (diff) | |
download | efl-88910d6a65cd6d803dcb06bcf9b8112d2f44f26a.tar.gz |
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.c | 255 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_clock.eo | 1 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_clock.h | 59 | ||||
-rw-r--r-- | src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c | 407 | ||||
-rw-r--r-- | src/modules/elementary/clock_input_ctxpopup/meson.build | 10 | ||||
-rw-r--r-- | src/modules/elementary/meson.build | 1 |
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 @@ #define MAX_SEPARATOR_LEN 6 #define MIN_DAYS_IN_MONTH 28 #define BUFFER_SIZE 1024 +#define CLOCK_FIELD_COUNT 8 /* interface between EDC & C code (field & signal names). values 0 to * 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, snprintf(buffer, buffer_size, template + 4, n); } -static Elm_Module * -_dt_mod_find(void) +static void +_field_value_set(struct tm *tim, Efl_Ui_Clock_Type field_type, int val) +{ + if (field_type >= (CLOCK_FIELD_COUNT - 1)) return; + + int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, + &tim->tm_min, &tim->tm_sec, &tim->tm_wday }; + *timearr[field_type] = val; +} + +static int +_field_value_get(struct tm *tim, Efl_Ui_Clock_Type field_type) +{ + if (field_type >= (CLOCK_FIELD_COUNT - 1)) return -1; + + int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, + &tim->tm_min, &tim->tm_sec, &tim->tm_wday }; + return (*timearr[field_type]); +} + +static void +_ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED) +{ + struct tm curr_time; + + curr_time = efl_ui_clock_time_get(data); + if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12; + else curr_time.tm_hour += 12; + efl_ui_clock_time_set(data, curr_time); +} + +static void +_access_set(Evas_Object *obj, Efl_Ui_Clock_Type field_type) +{ + const char* type = NULL; + + switch (field_type) + { + case EFL_UI_CLOCK_TYPE_YEAR: + type = "datetime field, year"; + break; + + case EFL_UI_CLOCK_TYPE_MONTH: + type = "datetime field, month"; + break; + + case EFL_UI_CLOCK_TYPE_DATE: + type = "datetime field, date"; + break; + + case EFL_UI_CLOCK_TYPE_HOUR: + type = "datetime field, hour"; + break; + + case EFL_UI_CLOCK_TYPE_MINUTE: + type = "datetime field, minute"; + break; + + case EFL_UI_CLOCK_TYPE_AMPM: + type = "datetime field, AM PM"; + break; + + default: + break; + } + + _elm_access_text_set + (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type); + _elm_access_callback_set + (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL); +} + +static const char * +_field_format_get(Evas_Object *obj, + Efl_Ui_Clock_Type field_type) { - static int tried_fallback = 0; - Elm_Module *mod = _elm_module_find_as("clock/api"); + Clock_Field *field; + + if (field_type > EFL_UI_CLOCK_TYPE_AMPM) return NULL; - if (mod) return mod; - if (!tried_fallback && - (!_elm_config->modules || !strstr(_elm_config->modules, "clock/api"))) + EFL_UI_CLOCK_DATA_GET(obj, sd); + + field = sd->field_list + field_type; + + return field->fmt; +} + +static void +field_value_display(Eo *obj, Evas_Object *item_obj) +{ + Efl_Ui_Clock_Type field_type; + struct tm tim; + char buf[BUFFER_SIZE]; + const char *fmt; + + tim = efl_ui_clock_time_get(obj); + field_type = (Efl_Ui_Clock_Type )evas_object_data_get(item_obj, "_field_type"); + fmt = _field_format_get(obj, field_type); + buf[0] = 0; + strftime(buf, sizeof(buf), fmt, &tim); + if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P")))) { - // See also _config_update(): we hardcode here the default module - ERR("Elementary config does not contain the required module " - "name for the clock widget! Verify your installation."); - _elm_module_add("clock_input_ctxpopup", "clock/api"); - mod = _elm_module_find_as("clock/api"); - tried_fallback = EINA_TRUE; + // yes BUFFER_SIZE is more than 2 bytes! + if (tim.tm_hour < 12) strcpy(buf, "AM"); + else strcpy(buf, "PM"); } - return mod; + elm_object_text_set(item_obj, buf); } -static Clock_Mod_Api * -_dt_mod_init() +static Evas_Object * +field_create(Eo *obj, Efl_Ui_Clock_Type field_type) { - Elm_Module *mod; - - mod = _dt_mod_find(); - if (!mod) return NULL; - if (mod->api) return mod->api; - mod->api = malloc(sizeof(Clock_Mod_Api)); - if (!mod->api) return NULL; - - ((Clock_Mod_Api *)(mod->api))->obj_hook = - _elm_module_symbol_get(mod, "obj_hook"); - ((Clock_Mod_Api *)(mod->api))->obj_unhook = - _elm_module_symbol_get(mod, "obj_unhook"); - ((Clock_Mod_Api *)(mod->api))->obj_hide = - _elm_module_symbol_get(mod, "obj_hide"); - ((Clock_Mod_Api *)(mod->api))->field_create = - _elm_module_symbol_get(mod, "field_create"); - ((Clock_Mod_Api *)(mod->api))->field_value_display = - _elm_module_symbol_get(mod, "field_value_display"); - - return mod->api; + Evas_Object *field_obj; + + if (field_type == EFL_UI_CLOCK_TYPE_AMPM) + { + field_obj = elm_button_add(obj); + efl_event_callback_add + (field_obj, EFL_INPUT_EVENT_CLICKED, _ampm_clicked_cb, obj); + } + else + { + field_obj = elm_entry_add(obj); + elm_entry_single_line_set(field_obj, EINA_TRUE); + elm_entry_editable_set(field_obj, EINA_FALSE); + elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE); + elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE); + } + evas_object_data_set(field_obj, "_field_type", (void *)field_type); + + // ACCESS + _access_set(field_obj, field_type); + + return field_obj; } static void @@ -145,18 +237,14 @@ _field_list_display(Evas_Object *obj) { Clock_Field *field; unsigned int idx = 0; - Clock_Mod_Api *dt_mod; EFL_UI_CLOCK_DATA_GET(obj, sd); - dt_mod = _dt_mod_init(); - if (!dt_mod || !dt_mod->field_value_display) return; - for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) { field = sd->field_list + idx; if (field->fmt_exist && field->visible) - dt_mod->field_value_display(sd->mod_data, field->item_obj); + field_value_display(obj, field->item_obj); } } @@ -483,24 +571,6 @@ _efl_ui_clock_edit_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd) return sd->edit_mode; } -EOLIAN static Eina_Bool -_efl_ui_clock_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Clock_Data *sd) -{ - Eina_Bool int_ret = EINA_FALSE; - - int_ret = efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS)); - if (!int_ret) return EINA_FALSE; - - if (!efl_ui_focus_object_focus_get(obj)) - { - Clock_Mod_Api *dt_mod = _dt_mod_init(); - if ((dt_mod) && (dt_mod->obj_hide)) - dt_mod->obj_hide(sd->mod_data); - } - - return EINA_TRUE; -} - EOLIAN static void _efl_ui_clock_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Clock_Data *sd) { @@ -517,16 +587,12 @@ _efl_ui_clock_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Clock_Data *sd) Clock_Field *field; char buf[BUFFER_SIZE]; unsigned int idx; - Clock_Mod_Api *dt_mod; ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; - dt_mod = _dt_mod_init(); - if ((!dt_mod) || (!dt_mod->field_value_display)) return EINA_TRUE; - for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) { field = sd->field_list + idx; @@ -548,7 +614,7 @@ _efl_ui_clock_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Clock_Data *sd) elm_layout_text_set(obj, buf, field->separator); } - dt_mod->field_value_display(sd->mod_data, field->item_obj); + field_value_display(obj, field->item_obj); } else { @@ -699,21 +765,6 @@ _apply_range_restrictions(struct tm *tim) } } -static const char * -_field_format_get(Evas_Object *obj, - Efl_Ui_Clock_Type field_type) -{ - Clock_Field *field; - - if (field_type > EFL_UI_CLOCK_TYPE_AMPM) return NULL; - - EFL_UI_CLOCK_DATA_GET(obj, sd); - - field = sd->field_list + field_type; - - return field->fmt; -} - static void _field_limit_get(Evas_Object *obj, Efl_Ui_Clock_Type field_type, @@ -822,11 +873,9 @@ _ticker(void *data) if (sd->curr_time.tm_sec > 0) { - Clock_Mod_Api *dt_mod = _dt_mod_init(); field = sd->field_list + EFL_UI_CLOCK_TYPE_SECOND; - if (field->fmt_exist && field->visible && - dt_mod && dt_mod->field_value_display) - dt_mod->field_value_display(sd->mod_data, field->item_obj); + if (field->fmt_exist && field->visible) + field_value_display(data, field->item_obj); } else _field_list_display(data); @@ -842,7 +891,6 @@ EOLIAN static void _efl_ui_clock_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Clock_Data *priv) { Clock_Field *field; - Clock_Mod_Api *dt_mod; int idx; ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -856,33 +904,11 @@ _efl_ui_clock_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Clock_Data *priv) elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC) CRI("Failed to set layout!"); - // module - initialise module for clock - dt_mod = _dt_mod_init(); - if (dt_mod) + for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) { - if (dt_mod->obj_hook) - { - priv->mod_data = dt_mod->obj_hook(obj); - - // update module data - if (priv->mod_data) - { - priv->mod_data->base = obj; - priv->mod_data->field_limit_get = _field_limit_get; - priv->mod_data->field_format_get = _field_format_get; - } - } - - if (dt_mod->field_create) - { - for (idx = 0; idx < EFL_UI_CLOCK_TYPE_COUNT; idx++) - { - field = priv->field_list + idx; - field->item_obj = dt_mod->field_create(priv->mod_data, idx); - } - } + field = priv->field_list + idx; + field->item_obj = field_create(obj, idx); } - else WRN("Failed to load clock module, clock widget may not show properly!"); priv->freeze_sizing = EINA_TRUE; @@ -916,7 +942,6 @@ _efl_ui_clock_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Clock_Data *sd) { Clock_Field *tmp; unsigned int idx; - Clock_Mod_Api *dt_mod; ecore_timer_del(sd->ticker); 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) eina_stringshare_del(tmp->separator); } - dt_mod = _dt_mod_init(); - if ((dt_mod) && (dt_mod->obj_unhook)) - dt_mod->obj_unhook(sd->mod_data); // module - unhook - efl_canvas_group_del(efl_super(obj, MY_CLASS)); } @@ -1037,11 +1058,7 @@ _efl_ui_clock_field_visible_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Ui_Clock_Typ efl_canvas_group_change(obj); if (!visible) return; - { - Clock_Mod_Api *dt_mod = _dt_mod_init(); - if (!dt_mod || !dt_mod->field_value_display) return; - dt_mod->field_value_display(sd->mod_data, field->item_obj); - } + field_value_display(obj, field->item_obj); } EOLIAN 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 Efl.Object.constructor; Efl.Canvas.Group.group_calculate; Efl.Ui.Widget.theme_apply; - Efl.Ui.Focus.Object.on_focus_update; Efl.Ui.L10n.translation_update; } 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 @@ * the corresponding user format. * * Clock supports six fields: Year, Month, Date, Hour, Minute, AM/PM. - * Depending on the Clock module that is loaded, the user can see - * different UI to select the individual field values. * * The individual fields of Clock can be arranged in any order according to the format * set by application. @@ -117,63 +115,6 @@ * The whole widget is left aligned and its size grows horizontally depending * on the current format and each field's visible/disabled state. * - * Clock individual field selection is implemented in a modular style. - * Module can be implemented as a Ctxpopup based selection or an ISE based - * selection or even a spinner like selection etc. - * - * <b>Clock Module design:</b> - * - * The following functions are expected to be implemented in a Clock module: - * - * <b>Field creation:</b> - * <pre> - * - * __________ __________ - * | |----- obj_hook() ---------------------->>>| | - * | |<<<----------------returns Mod_data ------| | - * | Clock |_______ | | - * | widget | |Assign module call backs | Module | - * | base |<<<____| | | - * | | | | - * | |----- field_create() ------------------>>>| | - * |__________|<<<----------------returns field_obj -----|__________| - * - * </pre> - * - * <b>Field value setting:</b> - * <pre> - * - * __________ __________ - * | | | | - * | Clock |<<<----------efl_ui_clock_time_set()----| | - * | widget | | Module | - * | base |----display_field_value()------------>>>| | - * |__________| |__________| - * - * </pre> - * - * <b>del_hook:</b> - * <pre> - * __________ __________ - * | | | | - * | Clock |----obj_unhook()-------------------->>>>| | - * | widget | | Module | - * | base | <<<-----frees mod_data---------| | - * |__________| |__________| - * - * </pre> - * - * - * Any module can use the following shared functions that are implemented in efl_ui_clock.c : - * - * <b>field_format_get()</b> - gives the field format. - * - * <b>field_limit_get()</b> - gives the field minimum, maximum limits. - * - * To enable a module, set the ELM_MODULES environment variable as shown: - * - * <b>export ELM_MODULES="clock_input_ctxpopup>clock/api"</b> - * * This widget inherits from the @ref Layout one, so that all the * functions acting on it also work for Clock objects. * 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 @@ -#ifdef HAVE_CONFIG_H -#include "elementary_config.h" -#endif - -#include "Elementary.h" -#include "elm_module_helper.h" -#include "elm_widget.h" -#include "efl_ui_clock_private.h" -#include "elm_ctxpopup_item_eo.h" -#include "elm_ctxpopup_eo.h" - -#ifndef EFL_BUILD -# define EFL_BUILD -#endif -#undef ELM_MODULE_HELPER_H -#include "elm_module_helper.h" - -#define CLOCK_FIELD_COUNT 8 -#define FIELD_FORMAT_LEN 3 -#define DISKSELECTOR_MIN_ITEMS 4 -#define BUFF_SIZE 1024 - -typedef struct _Ctxpopup_Module_Data Ctxpopup_Module_Data; -typedef struct _DiskItem_Data DiskItem_Data; - -struct _Ctxpopup_Module_Data -{ - Efl_Ui_Clock_Module_Data mod_data; - Evas_Object *ctxpopup; -}; - -struct _DiskItem_Data -{ - Ctxpopup_Module_Data *ctx_mod; - Efl_Ui_Clock_Type sel_field_type; - unsigned int sel_field_value; -}; - -static void -_diskselector_item_free_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - free(data); -} - -static void -_ctxpopup_dismissed_cb(void *data, const Efl_Event *event) -{ - Ctxpopup_Module_Data *ctx_mod; - ctx_mod = (Ctxpopup_Module_Data *)data; - evas_object_del(event->object); - ctx_mod->ctxpopup = NULL; -} - -static void -_clock_resize_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - Ctxpopup_Module_Data *ctx_mod; - - ctx_mod = (Ctxpopup_Module_Data *)data; - if (!ctx_mod || !ctx_mod->ctxpopup) return; - - evas_object_hide(ctx_mod->ctxpopup); -} - -static void -_clock_move_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - Ctxpopup_Module_Data *ctx_mod; - - ctx_mod = (Ctxpopup_Module_Data *)data; - if (!ctx_mod || !ctx_mod->ctxpopup) return; - - evas_object_hide(ctx_mod->ctxpopup); -} - -static void -_field_value_set(struct tm *tim, Efl_Ui_Clock_Type field_type, int val) -{ - if (field_type >= (CLOCK_FIELD_COUNT - 1)) return; - - int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, - &tim->tm_min, &tim->tm_sec, &tim->tm_wday }; - *timearr[field_type] = val; -} - -static int -_field_value_get(struct tm *tim, Efl_Ui_Clock_Type field_type) -{ - if (field_type >= (CLOCK_FIELD_COUNT - 1)) return -1; - - int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, - &tim->tm_min, &tim->tm_sec, &tim->tm_wday }; - return (*timearr[field_type]); -} - -static void -_diskselector_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - DiskItem_Data *disk_data; - struct tm curr_time; - const char *fmt; - - disk_data = (DiskItem_Data *)elm_object_item_data_get(event_info); - if (!disk_data || !(disk_data->ctx_mod)) return; - - curr_time = efl_ui_clock_time_get(disk_data->ctx_mod->mod_data.base); - fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type); - if ((disk_data->sel_field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) || - (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12)) - disk_data->sel_field_value += 12; - _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value); - efl_ui_clock_time_set(disk_data->ctx_mod->mod_data.base, curr_time); - evas_object_hide(disk_data->ctx_mod->ctxpopup); -} - -static void -_ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED) -{ - Ctxpopup_Module_Data *ctx_mod; - struct tm curr_time; - - ctx_mod = (Ctxpopup_Module_Data *)data; - if (!ctx_mod) return; - - curr_time = efl_ui_clock_time_get(ctx_mod->mod_data.base); - if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12; - else curr_time.tm_hour += 12; - efl_ui_clock_time_set(ctx_mod->mod_data.base, curr_time); -} - -static void -_field_clicked_cb(void *data, const Efl_Event *event) -{ - Ctxpopup_Module_Data *ctx_mod; - Evas_Object *diskselector; - Elm_Object_Item *item; - DiskItem_Data *disk_data; - Efl_Ui_Clock_Type field_type; - time_t t; - struct tm time1; - char buf[BUFF_SIZE], label[BUFF_SIZE]; - const char *fmt; - int idx, min, max, val; - unsigned int display_item_num, text_len = 0; - Evas_Coord x = 0, y = 0, w = 0, h = 0, width; - - ctx_mod = (Ctxpopup_Module_Data *)data; - if (!ctx_mod) return; - - if (!efl_ui_clock_edit_mode_get(ctx_mod->mod_data.base)) - return; - - snprintf(buf, sizeof(buf), "datetime/%s", elm_object_style_get(event->object)); - - if (ctx_mod->ctxpopup) - evas_object_del(ctx_mod->ctxpopup); - ctx_mod->ctxpopup = elm_ctxpopup_add(event->object); - elm_object_style_set(ctx_mod->ctxpopup, buf); - elm_ctxpopup_horizontal_set(ctx_mod->ctxpopup, EINA_TRUE); - evas_object_size_hint_weight_set(ctx_mod->ctxpopup, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ctx_mod->ctxpopup, EVAS_HINT_FILL, 0.5); - efl_event_callback_add - (ctx_mod->ctxpopup, ELM_CTXPOPUP_EVENT_DISMISSED, _ctxpopup_dismissed_cb, ctx_mod); - elm_ctxpopup_hover_parent_set(ctx_mod->ctxpopup, elm_widget_top_get(event->object)); - - diskselector = elm_diskselector_add(elm_widget_top_get(ctx_mod->mod_data.base)); - evas_object_smart_callback_add(diskselector, "clicked", _diskselector_cb, NULL); - elm_object_style_set(diskselector, buf); - elm_object_content_set(ctx_mod->ctxpopup, diskselector); - - t = time(NULL); - localtime_r(&t, &time1); - - field_type = (Efl_Ui_Clock_Type )evas_object_data_get(event->object, "_field_type"); - fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); - time1 = efl_ui_clock_time_get(ctx_mod->mod_data.base); - val = _field_value_get(&time1, field_type); - ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max); - - time1.tm_mday = 1; // To avoid month wrapping, set the first day of the month to start with. - - if ((field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) || - (!strncmp(fmt, "%l", FIELD_FORMAT_LEN)))) - { - if (max >= 12) max -= 12; - if (val >= 12) val -= 12; - if (min >= 12) min -= 12; - } - for (idx = min; idx <= max; idx++) - { - _field_value_set(&time1, field_type, idx); - strftime(label, BUFF_SIZE, fmt, &time1); - if (strlen(label) > text_len) text_len = strlen(label); - if (idx == val) - { - item = elm_diskselector_item_append(diskselector, label, NULL, NULL, NULL); - elm_diskselector_item_selected_set(item, EINA_TRUE); - } - else - { - disk_data = (DiskItem_Data *) malloc (sizeof(DiskItem_Data)); - disk_data->ctx_mod = ctx_mod; - disk_data->sel_field_type = field_type; - disk_data->sel_field_value = idx; - item = elm_diskselector_item_append(diskselector, label, NULL, NULL, disk_data); - elm_object_item_del_cb_set(item, _diskselector_item_free_cb); - } - } - elm_diskselector_side_text_max_length_set(diskselector, text_len); - - evas_object_geometry_get(event->object, &x, &y, &w, &h); - evas_object_geometry_get(elm_widget_top_get(ctx_mod->mod_data.base), NULL, NULL, &width, NULL); - evas_object_size_hint_min_set(ctx_mod->ctxpopup, width, -1); - display_item_num = width / (w + elm_config_finger_size_get()); - // always display even number of items to avoid autoselection - if (display_item_num % 2) display_item_num -= 1; - if (display_item_num < DISKSELECTOR_MIN_ITEMS) - display_item_num = DISKSELECTOR_MIN_ITEMS; - elm_diskselector_display_item_num_set(diskselector, display_item_num); - elm_diskselector_round_enabled_set(diskselector, EINA_TRUE); - - elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN, - ELM_CTXPOPUP_DIRECTION_UP, -1, -1); - evas_object_move(ctx_mod->ctxpopup, (x+w/2), (y+h)); - - // if the direction of Ctxpopup is upwards, move it to the top of datetime - if (elm_ctxpopup_direction_get(ctx_mod->ctxpopup) == ELM_CTXPOPUP_DIRECTION_UP) - { - elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, - ELM_CTXPOPUP_DIRECTION_DOWN, -1, -1); - evas_object_move(ctx_mod->ctxpopup, (x + w / 2), y); - } - evas_object_show(ctx_mod->ctxpopup); -} - -static void -_access_set(Evas_Object *obj, Efl_Ui_Clock_Type field_type) -{ - const char* type = NULL; - - switch (field_type) - { - case EFL_UI_CLOCK_TYPE_YEAR: - type = "datetime field, year"; - break; - - case EFL_UI_CLOCK_TYPE_MONTH: - type = "datetime field, month"; - break; - - case EFL_UI_CLOCK_TYPE_DATE: - type = "datetime field, date"; - break; - - case EFL_UI_CLOCK_TYPE_HOUR: - type = "datetime field, hour"; - break; - - case EFL_UI_CLOCK_TYPE_MINUTE: - type = "datetime field, minute"; - break; - - case EFL_UI_CLOCK_TYPE_AMPM: - type = "datetime field, AM PM"; - break; - - default: - break; - } - - _elm_access_text_set - (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type); - _elm_access_callback_set - (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL); -} - -// module funcs for the specific module type -EAPI void -field_value_display(Efl_Ui_Clock_Module_Data *module_data, Evas_Object *obj) -{ - Ctxpopup_Module_Data *ctx_mod; - Efl_Ui_Clock_Type field_type; - struct tm tim; - char buf[BUFF_SIZE]; - const char *fmt; - - ctx_mod = (Ctxpopup_Module_Data *)module_data; - if (!ctx_mod || !obj) return; - - tim = efl_ui_clock_time_get(ctx_mod->mod_data.base); - field_type = (Efl_Ui_Clock_Type )evas_object_data_get(obj, "_field_type"); - fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); - buf[0] = 0; - strftime(buf, sizeof(buf), fmt, &tim); - if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P")))) - { - // yes BUFF_SIZE is more than 2 bytes! - if (tim.tm_hour < 12) strcpy(buf, "AM"); - else strcpy(buf, "PM"); - } - elm_object_text_set(obj, buf); -} - -EAPI Evas_Object * -field_create(Efl_Ui_Clock_Module_Data *module_data, Efl_Ui_Clock_Type field_type) -{ - Ctxpopup_Module_Data *ctx_mod; - Evas_Object *field_obj; - - ctx_mod = (Ctxpopup_Module_Data *)module_data; - if (!ctx_mod) return NULL; - - if (field_type == EFL_UI_CLOCK_TYPE_AMPM) - { - field_obj = elm_button_add(ctx_mod->mod_data.base); - efl_event_callback_add - (field_obj, EFL_INPUT_EVENT_CLICKED, _ampm_clicked_cb, ctx_mod); - } - else - { - field_obj = elm_entry_add(ctx_mod->mod_data.base); - elm_entry_single_line_set(field_obj, EINA_TRUE); - elm_entry_editable_set(field_obj, EINA_FALSE); - elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE); - elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE); - efl_event_callback_add - (field_obj, EFL_INPUT_EVENT_CLICKED, _field_clicked_cb, ctx_mod); - } - evas_object_data_set(field_obj, "_field_type", (void *)field_type); - - // ACCESS - _access_set(field_obj, field_type); - - return field_obj; -} - -EAPI Efl_Ui_Clock_Module_Data * -obj_hook(Evas_Object *obj) -{ - Ctxpopup_Module_Data *ctx_mod; - ctx_mod = calloc(1, sizeof(Ctxpopup_Module_Data)); - if (!ctx_mod) return NULL; - - evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, - _clock_resize_cb, ctx_mod); - evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, - _clock_move_cb, ctx_mod); - - return ((Efl_Ui_Clock_Module_Data*)ctx_mod); -} - -EAPI void -obj_unhook(Efl_Ui_Clock_Module_Data *module_data) -{ - Ctxpopup_Module_Data *ctx_mod; - - ctx_mod = (Ctxpopup_Module_Data *)module_data; - if (!ctx_mod) return; - - if (ctx_mod->ctxpopup) - evas_object_del(ctx_mod->ctxpopup); - - free(ctx_mod); - ctx_mod = NULL; -} - -EAPI void -obj_hide(Efl_Ui_Clock_Module_Data *module_data) -{ - Ctxpopup_Module_Data *ctx_mod; - - ctx_mod = (Ctxpopup_Module_Data *)module_data; - if (!ctx_mod) return; - - if (ctx_mod->ctxpopup) - evas_object_hide(ctx_mod->ctxpopup); -} - -// module api funcs needed -EAPI int -elm_modapi_init(void *m EINA_UNUSED) -{ - return 1; // succeed always -} - -EAPI int -elm_modapi_shutdown(void *m EINA_UNUSED) -{ - return 1; // succeed always -} - -static Eina_Bool -_module_init(void) -{ - return EINA_TRUE; -} - -static void -_module_shutdown(void) -{ -} - -EINA_MODULE_INIT(_module_init); -EINA_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 @@ -src = files([ - 'clock_input_ctxpopup.c', -]) - -shared_module(mod, - src, - dependencies: [elementary], - install: true, - install_dir : mod_install_dir -) 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 @@ mods = [ 'access_output', - 'clock_input_ctxpopup', 'prefs', 'test_entry', 'test_map', |