From: Jihoon Kim Date: Mon, 26 Jun 2017 04:44:58 +0000 (+0900) Subject: elm_entry: Add prediction hint API X-Git-Tag: upstream/1.20.0~433 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1dcf2c814c74e060f9424117690e5a9a72ef3b90;p=platform%2Fupstream%2Fefl.git elm_entry: Add prediction hint API prediction hint can be used to provide an intelligent reply suggestion. @feature --- diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index d215a7f..8dcc2af 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4557,6 +4557,23 @@ _edje_entry_imf_cursor_info_set(Entry *en) #endif } +void +_edje_entry_prediction_hint_set(Edje_Real_Part *rp, const char *prediction_hint) +{ + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return; + en = rp->typedata.text->entry_data; + if (!en) return; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + ecore_imf_context_prediction_hint_set(en->imf_context, prediction_hint); +#else + (void)prediction_hint; +#endif +} + #ifdef HAVE_ECORE_IMF static Edje_Real_Part * diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index c2613d1..42314c3 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -1120,6 +1120,19 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, ondemand: bool; [[If $true, the input panel will be shown in case of only Mouse up event. (Focus event will be ignored.)]] } } + @property part_text_prediction_hint { + set { + [[Sets the prediction hint to use an intelligent reply suggestion service. + + @since 1.20.0]] + } + keys { + part: string; [[The part name]] + } + values { + prediction_hint: string; [[Prediction hint]] + } + } /* TEXT PART APIS END ------------------------------------------------ */ @property seat { diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index e255358..1868f76 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2844,6 +2844,7 @@ void _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bo Eina_Bool _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp); void _edje_entry_input_panel_show_on_demand_set(Edje_Real_Part *rp, Eina_Bool ondemand); Eina_Bool _edje_entry_input_panel_show_on_demand_get(Edje_Real_Part *rp); +void _edje_entry_prediction_hint_set(Edje_Real_Part *rp, const char *prediction_hint); Eina_Bool _edje_entry_hide_visible_password(Edje *edje, Edje_Real_Part *rp); void _edje_external_init(void); diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index e76077e..7fd145c8 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -2672,6 +2672,20 @@ _edje_object_part_text_input_panel_show_on_demand_get(Eo *obj EINA_UNUSED, Edje return ret; } +EOLIAN void +_edje_object_part_text_prediction_hint_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *prediction_hint) +{ + Edje_Real_Part *rp; + + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_prediction_hint_set(rp, prediction_hint); + } +} + Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow) { diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index c3d36dc..0be4d08 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -907,6 +907,8 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) (sd->entry_edje, "elm.text", sd->input_panel_return_key_disabled); edje_object_part_text_input_panel_show_on_demand_set (sd->entry_edje, "elm.text", sd->input_panel_show_on_demand); + edje_object_part_text_prediction_hint_set + (sd->entry_edje, "elm.text", sd->prediction_hint); // elm_entry_cursor_pos_set -> cursor,changed -> widget_show_region_set // -> smart_objects_calculate will call all smart calculate functions, @@ -3915,6 +3917,12 @@ _elm_entry_efl_canvas_group_group_del(Eo *obj, Elm_Entry_Data *sd) } ELM_SAFE_FREE(sd->delay_write, ecore_timer_del); free(sd->input_panel_imdata); + + if (sd->prediction_hint) + { + ELM_SAFE_FREE(sd->prediction_hint, free); + } + eina_stringshare_del(sd->anchor_hover.hover_style); evas_event_thaw(evas_object_evas_get(obj)); @@ -5216,6 +5224,18 @@ _elm_entry_input_hint_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd) } EOLIAN static void +_elm_entry_prediction_hint_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char *prediction_hint) +{ + if (sd->prediction_hint) + free(sd->prediction_hint); + + sd->prediction_hint = strdup(prediction_hint); + + edje_object_part_text_prediction_hint_set + (sd->entry_edje, "elm.text", prediction_hint); +} + +EOLIAN static void _elm_entry_imf_context_reset(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd) { edje_object_part_text_imf_context_reset(sd->entry_edje, "elm.text"); diff --git a/src/lib/elementary/elm_entry.eo b/src/lib/elementary/elm_entry.eo index cb028fa..04b43ec 100644 --- a/src/lib/elementary/elm_entry.eo +++ b/src/lib/elementary/elm_entry.eo @@ -937,6 +937,12 @@ class Elm.Entry (Elm.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable, @in data: void_ptr @optional; [[User data to pass to $func.]] } } + prediction_hint_set { + [[Sets the prediction hint to use an intelligent reply suggestion service.]] + params { + prediction_hint: string; [[The prediction hint text.]] + } + } } implements { class.constructor; diff --git a/src/lib/elementary/elm_widget_entry.h b/src/lib/elementary/elm_widget_entry.h index e3edb8f..10aa893 100644 --- a/src/lib/elementary/elm_widget_entry.h +++ b/src/lib/elementary/elm_widget_entry.h @@ -43,6 +43,7 @@ struct _Elm_Entry_Data /* for deferred appending */ Ecore_Idler *append_text_idler; char *append_text_left; + char *prediction_hint; int append_text_position; int append_text_len; /* Only for clipboard */