diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index 3df54f43b2..581e2f9eb9 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -2732,6 +2732,35 @@ EAPI Eina_Bool edje_object_part_text_input_panel_show_on_demand_get(const Evas_O */ EAPI void edje_object_part_text_prediction_hint_set(Evas_Object *obj, const char *part, const char *prediction_hint); +/** + * @brief Sets the prediction hint data at the specified key. + * + * @param[in] part The part name + * @param[in] key The key of the prediction hint + * @param[in] value The data to replace + * + * @return @c true on success, @c false otherwise + * + * @since 1.21.0 + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_prediction_hint_hash_set(Evas_Object *obj, const char *part, const char *key, const char *value); + +/** + * @brief Removes the prediction hint data identified by a key + * + * @param[in] part The part name + * @param[in] key The key of the prediction hint + * + * @return @c true on success, @c false otherwise + * + * @since 1.21.0 + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_text_prediction_hint_hash_del(Evas_Object *obj, const char *part, const char *key); + /** * @brief Starts selecting at current cursor position * diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index a4c35ceaa5..6c1f8960ff 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4584,6 +4584,45 @@ _edje_entry_prediction_hint_set(Edje_Real_Part *rp, const char *prediction_hint) #endif } +Eina_Bool +_edje_entry_prediction_hint_hash_set(Edje_Real_Part *rp, const char *key, const char *value) +{ + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + return ecore_imf_context_prediction_hint_hash_set(en->imf_context, key, value); +#else + (void)key; + (void)value; +#endif + + return EINA_FALSE; +} + +Eina_Bool +_edje_entry_prediction_hint_hash_del(Edje_Real_Part *rp, const char *key) +{ + Entry *en; + + if ((rp->type != EDJE_RP_TYPE_TEXT) || + (!rp->typedata.text)) return EINA_FALSE; + en = rp->typedata.text->entry_data; + if (!en) return EINA_FALSE; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + return ecore_imf_context_prediction_hint_hash_del(en->imf_context, key); +#else + (void)key; +#endif + + return EINA_FALSE; +} + #ifdef HAVE_ECORE_IMF static Edje_Real_Part * diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index ec5b9161d3..2c12ea6a51 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2882,6 +2882,8 @@ 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_prediction_hint_hash_set(Edje_Real_Part *rp, const char *key, const char *value); +Eina_Bool _edje_entry_prediction_hint_hash_del(Edje_Real_Part *rp, const char *key); 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 e96a7609f4..ea3b62799e 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -3085,6 +3085,44 @@ _edje_box_layout_part_external_find(const char *name) NULL); } +EAPI Eina_Bool +edje_object_part_text_prediction_hint_hash_set(Eo *obj, const char *part, const char *key, const char *value) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = _edje_fetch(obj); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_prediction_hint_hash_set(rp, key, value); + } + else + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_prediction_hint_hash_del(Eo *obj, const char *part, const char *key) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = _edje_fetch(obj); + + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_prediction_hint_hash_del(rp, key); + } + else + return EINA_FALSE; +} + Eina_Bool _edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void(**free_data) (void *data)) { diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index c00e843abe..26fe5942a8 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -5314,6 +5314,20 @@ _elm_entry_prediction_hint_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const ch (sd->entry_edje, "elm.text", prediction_hint); } +EOLIAN static Eina_Bool +_elm_entry_prediction_hint_hash_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char *key, const char *value) +{ + return edje_object_part_text_prediction_hint_hash_set + (sd->entry_edje, "elm.text", key, value); +} + +EOLIAN static Eina_Bool +_elm_entry_prediction_hint_hash_del(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char *key) +{ + return edje_object_part_text_prediction_hint_hash_del + (sd->entry_edje, "elm.text", key); +} + EOLIAN static void _elm_entry_imf_context_reset(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd) { diff --git a/src/lib/elementary/elm_entry.eo b/src/lib/elementary/elm_entry.eo index 5f7ce5f1ae..c86d752ab9 100644 --- a/src/lib/elementary/elm_entry.eo +++ b/src/lib/elementary/elm_entry.eo @@ -830,6 +830,27 @@ class Elm.Entry (Efl.Ui.Layout.Object, Elm.Interface_Scrollable, Efl.Ui.Clickabl prediction_hint: string; [[The prediction hint text.]] } } + prediction_hint_hash_set { + [[Sets the prediction hint data at the specified key. + + @since 1.21 + ]] + return: bool; [[$true on success, $false otherwise]] + params { + key: string; [[The key of the prediction hint.]] + value: string; [[The data to replace.]] + } + } + prediction_hint_hash_del { + [[Removes the prediction hint data identified by a key. + + @since 1.21 + ]] + return: bool; [[$true on success, $false otherwise]] + params { + key: string; [[The key of the prediction hint.]] + } + } } implements { class.constructor;