Elm entry: Call callbacks for undo/redo,request.
[framework/uifw/elementary.git] / src / lib / elm_entry.c
index ff10a27..b68a6ad 100644 (file)
@@ -147,6 +147,8 @@ static const char SIG_ANCHOR_UP[] = "anchor,up";
 static const char SIG_ANCHOR_IN[] = "anchor,in";
 static const char SIG_ANCHOR_OUT[] = "anchor,out";
 static const char SIG_PREEDIT_CHANGED[] = "preedit,changed";
+static const char SIG_UNDO_REQUEST[] = "undo,request";
+static const char SIG_REDO_REQUEST[] = "redo,request";
 static const Evas_Smart_Cb_Description _signals[] = {
        {SIG_CHANGED, ""},
        {SIG_ACTIVATED, ""},
@@ -171,6 +173,8 @@ static const Evas_Smart_Cb_Description _signals[] = {
        {SIG_ANCHOR_OUT, ""},
        {SIG_PREEDIT_CHANGED, ""},
        {SIG_CHANGED_USER, ""},
+       {SIG_UNDO_REQUEST, ""},
+       {SIG_REDO_REQUEST, ""},
        {NULL, NULL}
 };
 
@@ -595,8 +599,9 @@ _elm_deferred_recalc_job(void *data)
 
    evas_object_geometry_get(wd->ent, NULL, NULL, &resw, NULL);
    edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
-   elm_coords_finger_size_adjust(1, &minw, 1, &minh);
-   wd->entmw = minw;
+   edje_object_size_min_restricted_calc(wd->ent, &fw, &fh, 0, 0);
+   elm_coords_finger_size_adjust(1, &fw, 1, &minh);
+   wd->entmw = fw;
    wd->entmh = minh;
    /* This is a hack to workaround the way min size hints are treated.
     * If the minimum width is smaller than the restricted width, it means
@@ -786,7 +791,10 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
    Evas_Object *edje;
    if ((!wd) || (!content)) return;
 
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
 
    /* Delete the currently swallowed object */
      {
@@ -818,7 +826,11 @@ _content_unset_hook(Evas_Object *obj, const char *part)
    Evas_Object *content, *edje;
    if (!wd) return NULL;
 
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
+
    if (!strcmp(part, "elm.swallow.icon"))
      {
         edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
@@ -848,7 +860,11 @@ _content_get_hook(const Evas_Object *obj, const char *part)
    Evas_Object *content = NULL, *edje;
    if (!wd) return NULL;
 
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
+
    if (edje)
      content = edje_object_part_swallow_get(edje, part);
    return content;
@@ -926,7 +942,11 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
    Evas_Object *sub = event_info;
    Evas_Object *edje;
 
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
+
    if (sub == edje_object_part_swallow_get(edje, "elm.swallow.icon"))
      {
         edje_object_part_unswallow(edje, sub);
@@ -1441,6 +1461,18 @@ _signal_preedit_changed(void *data, Evas_Object *obj __UNUSED__, const char *emi
 }
 
 static void
+_signal_undo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   evas_object_smart_callback_call(data, SIG_UNDO_REQUEST, NULL);
+}
+
+static void
+_signal_redo_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
+{
+   evas_object_smart_callback_call(data, SIG_REDO_REQUEST, NULL);
+}
+
+static void
 _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
@@ -2054,11 +2086,16 @@ _elm_entry_text_set(Evas_Object *obj, const char *item, const char *entry)
 {
    int len = 0;
    ELM_CHECK_WIDTYPE(obj, widtype);
-   if (item && strcmp(item, "default")) return;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    evas_event_freeze(evas_object_evas_get(obj));
    if (!entry) entry = "";
+   if (item && strcmp(item, "default"))
+     {
+        edje_object_part_text_set(wd->ent, item, entry);
+        return;
+     }
+
    if (wd->text) eina_stringshare_del(wd->text);
    wd->text = NULL;
    wd->changed = EINA_TRUE;
@@ -2252,6 +2289,10 @@ elm_entry_add(Evas_Object *parent)
                                    _signal_mouse_double, obj);
    edje_object_signal_callback_add(wd->ent, "mouse,down,1,triple", "elm.text",
                                    _signal_mouse_triple, obj);
+   edje_object_signal_callback_add(wd->ent, "entry,undo,request", "elm.text",
+                                   _signal_undo_request, obj);
+   edje_object_signal_callback_add(wd->ent, "entry,redo,request", "elm.text",
+                                   _signal_redo_request, obj);
    edje_object_part_text_set(wd->ent, "elm.text", "");
    if (_elm_config->desktop_entry)
      edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
@@ -3154,9 +3195,12 @@ elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *edje;
    if (!wd) return;
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
-   if (!edje_object_part_swallow_get(edje, "elm.swallow.icon")) return;
-   if (!edje) return;
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
+
+   if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
    if (setting)
      edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
    else
@@ -3193,10 +3237,12 @@ elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *edje;
    if (!wd) return;
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
-   if (!edje_object_part_swallow_get(edje, "elm.swallow.end")) return;
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
 
-   if (!edje) return;
+   if ((!edje) || (!edje_object_part_swallow_get(edje, "elm.swallow.icon"))) return;
    if (setting)
      edje_object_signal_emit(edje, "elm,action,show,end", "elm");
    else