Elm entry: Call callbacks for undo/redo,request.
[framework/uifw/elementary.git] / src / lib / elm_entry.c
index 75395d8..b68a6ad 100644 (file)
@@ -19,7 +19,7 @@ typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
 
 struct _Widget_Data
 {
-   Evas_Object *ent, *scroller, *end, *icon;
+   Evas_Object *ent, *scroller;
    Evas_Object *hoversel;
    Ecore_Job *deferred_recalc_job;
    Ecore_Event_Handler *sel_notify_handler;
@@ -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,19 +791,24 @@ _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 */
+     {
+        Evas_Object *cswallow = edje_object_part_swallow_get(edje, part);
+        if (cswallow)
+           evas_object_del(cswallow);
+     }
+
    if (!strcmp(part, "elm.swallow.icon"))
      {
-        if (wd->icon)
-          evas_object_del(wd->icon);
-        wd->icon = content;
         edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
      }
    else if (!strcmp(part, "elm.swallow.end"))
      {
-        if (wd->end)
-          evas_object_del(wd->end);
-        wd->end = content;
         edje_object_signal_emit(edje, "elm,action,show,end", "elm");
      }
    evas_event_freeze(evas_object_evas_get(obj));
@@ -816,15 +826,17 @@ _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"))
      {
-        wd->icon = NULL;
         edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
      }
    else if (!strcmp(part, "elm.swallow.end"))
      {
-        wd->end = NULL;
         edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
      }
 
@@ -848,12 +860,11 @@ _content_get_hook(const Evas_Object *obj, const char *part)
    Evas_Object *content = NULL, *edje;
    if (!wd) return NULL;
 
-   if (!strcmp(part, "elm.swallow.icon"))
-     return wd->icon;
-   if (!strcmp(part, "elm.swallow.end"))
-     return wd->end;
+   if (wd->scroll)
+      edje = elm_smart_scroller_edje_object_get(wd->scroller);
+   else
+      edje = wd->ent;
 
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
    if (edje)
      content = edje_object_part_swallow_get(edje, part);
    return content;
@@ -931,16 +942,20 @@ _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 (sub == wd->icon)
+   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"))
      {
-        wd->icon = NULL;
+        edje_object_part_unswallow(edje, sub);
         if (edje)
           edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
      }
-   else if (sub == wd->end)
+   else if (sub == edje_object_part_swallow_get(edje, "elm.swallow.end"))
      {
-        wd->end = NULL;
+        edje_object_part_unswallow(edje, sub);
         if (edje)
           edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
      }
@@ -1446,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);
@@ -2059,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;
@@ -2257,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);
@@ -3158,9 +3194,13 @@ elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *edje;
-   if ((!wd) || (!wd->icon)) return;
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
-   if (!edje) return;
+   if (!wd) 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
@@ -3196,9 +3236,13 @@ elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *edje;
-   if ((!wd) || (!wd->end)) return;
-   edje = elm_smart_scroller_edje_object_get(wd->scroller);
-   if (!edje) return;
+   if (!wd) 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,end", "elm");
    else