From 187184116607669601a3017abd99cbacf0be841f Mon Sep 17 00:00:00 2001 From: SangHyeon Jade Lee Date: Mon, 18 May 2020 18:52:16 +0900 Subject: [PATCH] genlist: apply l10n translation for langauge change Change-Id: Ia2cf7fb3484a7157bfb47aa00d6e04fc6728d4d6 --- src/lib/elementary/elm_genlist.c | 32 ++++++++++++++++++++++++++++++++ src/lib/elementary/elm_genlist_eo.c | 4 ++++ src/lib/elementary_tizen/elm_genlist.c | 13 ++++++------- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index 24e7c76..dd92838 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -11,6 +11,7 @@ // #define EFL_ACCESS_WIDGET_ACTION_PROTECTED #define ELM_WIDGET_ITEM_PROTECTED +#define EFL_UI_L10N_PROTECTED #define EFL_UI_FOCUS_COMPOSITION_PROTECTED #include @@ -3754,6 +3755,37 @@ _elm_genlist_efl_ui_focus_object_on_focus_update(Eo *obj, Elm_Genlist_Data *sd) return EINA_TRUE; } +EOLIAN static void +_elm_genlist_efl_ui_l10n_translation_update(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd) +{ + Item_Block *itb; + Eina_List *l; + Elm_Gen_Item *it; + + // FIXME: We should change item's height if lang is changed?? + EINA_INLIST_FOREACH(sd->blocks, itb) + { + EINA_LIST_FOREACH(itb->items, l, it) + { + if (it->realized) + { + elm_genlist_item_fields_update(EO_OBJ(it), + NULL, + ELM_GENLIST_ITEM_FIELD_TEXT | + ELM_GENLIST_ITEM_FIELD_CONTENT); + } + else it->item->mincalcd = EINA_FALSE; + } + itb->changed = EINA_TRUE; + } + + eina_hash_free_buckets(sd->size_caches); + sd->pan_changed = EINA_TRUE; + + efl_ui_l10n_translation_update(efl_super(obj, MY_CLASS)); +} + + static Eina_Bool _elm_genlist_smart_focus_next_enable = EINA_FALSE; //TIZEN_ONLY(20180607): Restore legacy focus diff --git a/src/lib/elementary/elm_genlist_eo.c b/src/lib/elementary/elm_genlist_eo.c index eb3cf54..57366a4 100644 --- a/src/lib/elementary/elm_genlist_eo.c +++ b/src/lib/elementary/elm_genlist_eo.c @@ -487,6 +487,9 @@ Eina_Rect _elm_genlist_efl_ui_widget_focus_highlight_geometry_get(const Eo *obj, Eina_Bool _elm_genlist_efl_ui_focus_object_on_focus_update(Eo *obj, Elm_Genlist_Data *pd); +void _elm_genlist_efl_ui_l10n_translation_update(Eo *obj, Elm_Genlist_Data *pd); + + Eina_Bool _elm_genlist_efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Genlist_Data *pd, Efl_Canvas_Object *sub_obj); @@ -644,6 +647,7 @@ _elm_genlist_class_initializer(Efl_Class *klass) EFL_OBJECT_OP_FUNC(efl_ui_widget_on_access_update, _elm_genlist_efl_ui_widget_on_access_update), EFL_OBJECT_OP_FUNC(efl_ui_widget_focus_highlight_geometry_get, _elm_genlist_efl_ui_widget_focus_highlight_geometry_get), EFL_OBJECT_OP_FUNC(efl_ui_focus_object_on_focus_update, _elm_genlist_efl_ui_focus_object_on_focus_update), + EFL_OBJECT_OP_FUNC(efl_ui_l10n_translation_update, _elm_genlist_efl_ui_l10n_translation_update), EFL_OBJECT_OP_FUNC(efl_ui_widget_sub_object_del, _elm_genlist_efl_ui_widget_widget_sub_object_del), EFL_OBJECT_OP_FUNC(efl_ui_widget_input_event_handler, _elm_genlist_efl_ui_widget_widget_input_event_handler), EFL_OBJECT_OP_FUNC(elm_widget_item_container_focused_item_get, _elm_genlist_elm_widget_item_container_focused_item_get), diff --git a/src/lib/elementary_tizen/elm_genlist.c b/src/lib/elementary_tizen/elm_genlist.c index 92014e6..270e95c 100644 --- a/src/lib/elementary_tizen/elm_genlist.c +++ b/src/lib/elementary_tizen/elm_genlist.c @@ -11,6 +11,7 @@ // #define EFL_ACCESS_WIDGET_ACTION_PROTECTED #define ELM_WIDGET_ITEM_PROTECTED +#define EFL_UI_L10N_PROTECTED #define EFL_UI_FOCUS_COMPOSITION_PROTECTED #include @@ -5694,11 +5695,12 @@ _show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rect r) elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h); } -#if 0 -EOLIAN static Eina_Bool -_elm_genlist_efl_ui_widget_translate(Eo *obj, Elm_Genlist_Data *sd) +EOLIAN static void +_elm_genlist_efl_ui_l10n_translation_update(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd) { Item_Block *itb; + Eina_List *l; + Elm_Gen_Item *it; // Before calling text_get, inform user first. evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL); @@ -5706,8 +5708,6 @@ _elm_genlist_efl_ui_widget_translate(Eo *obj, Elm_Genlist_Data *sd) // FIXME: We should change item's height if lang is changed?? EINA_INLIST_FOREACH(sd->blocks, itb) { - Eina_List *l; - Elm_Gen_Item *it; EINA_LIST_FOREACH(itb->items, l, it) { if (it->realized) @@ -5725,9 +5725,8 @@ _elm_genlist_efl_ui_widget_translate(Eo *obj, Elm_Genlist_Data *sd) eina_hash_free_buckets(sd->size_caches); sd->calc_done = EINA_FALSE; - return EINA_TRUE; + efl_ui_l10n_translation_update(efl_super(obj, MY_CLASS)); } -#endif EOLIAN static void _elm_genlist_elm_interface_scrollable_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, Eina_Bool enable) -- 2.7.4