elm_entry: Add prediction hint API

prediction hint can be used to provide an intelligent reply suggestion.

@feature
This commit is contained in:
Jihoon Kim 2017-06-26 13:44:58 +09:00
parent 06d2d04092
commit 1dcf2c814c
7 changed files with 72 additions and 0 deletions

View File

@ -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 *

View File

@ -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 {

View File

@ -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);

View File

@ -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)
{

View File

@ -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));
@ -5215,6 +5223,18 @@ _elm_entry_input_hint_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd)
return sd->input_hints;
}
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)
{

View File

@ -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;

View File

@ -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 */