elm_entry: Add prediction hint API
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 26 Jun 2017 04:44:58 +0000 (13:44 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 26 Jun 2017 04:44:58 +0000 (13:44 +0900)
prediction hint can be used to provide an intelligent reply suggestion.

@feature

src/lib/edje/edje_entry.c
src/lib/edje/edje_object.eo
src/lib/edje/edje_private.h
src/lib/edje/edje_util.c
src/lib/elementary/elm_entry.c
src/lib/elementary/elm_entry.eo
src/lib/elementary/elm_widget_entry.h

index d215a7f..8dcc2af 100644 (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 *
index c2613d1..42314c3 100644 (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 {
index e255358..1868f76 100644 (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);
index e76077e..7fd145c 100644 (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)
 {
index c3d36dc..0be4d08 100644 (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));
@@ -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");
index cb028fa..04b43ec 100644 (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;
index e3edb8f..10aa893 100644 (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 */