Entry: add markup cnp handlers 58/54758/1
authorDaniel Hirt <daniel.hirt@samsung.com>
Mon, 30 Nov 2015 13:29:06 +0000 (15:29 +0200)
committerThiep Ha <thiep.ha@samsung.com>
Fri, 18 Dec 2015 07:40:08 +0000 (07:40 +0000)
In Elm_Cnp, a markup data preparer was missing, which resulted
in _x11_notify_handler_targets not requesting
"application/x-elementary-markup" (requested "UTF8_STRING" instead) when
trying to paste markup text from one entry to another (or itself).

Also, there was a missing handling in the selection data callback for
ELM_SEL_FORMAT_MARKUP data format.

This fixes issues like not being able to paste "item" formats to the
entry widget.

@fix

Change-Id: Ia21165a783c0fe986547b4cf9b70c03435e8d73f

src/lib/elm_cnp.c
src/lib/elm_entry.c

index fb3f2ae864da7a92f803e7839da32adce080acbe..070105746a99fae7d6095b5e3e7f798c0bd9af1b 100644 (file)
@@ -218,6 +218,7 @@ static Eina_Bool      _x11_vcard_send               (char *target, void *data, i
 static Eina_Bool      _x11_is_uri_type_data         (X11_Cnp_Selection *sel EINA_UNUSED, Ecore_X_Event_Selection_Notify *notify);
 static Eina_Bool      _x11_notify_handler_targets   (X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify);
 static Eina_Bool      _x11_data_preparer_text       (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
+static Eina_Bool      _x11_data_preparer_markup     (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
 static Eina_Bool      _x11_data_preparer_image      (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
 static Eina_Bool      _x11_data_preparer_uri        (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
 //static int            _x11_notify_handler_html      (X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify);
@@ -451,6 +452,7 @@ static Cnp_Atom _atoms[CNP_N_ATOMS] = {
         .formats = ELM_SEL_FORMAT_MARKUP,
 #ifdef HAVE_ELEMENTARY_X
         .x_converter = _x11_general_converter,
+        .x_data_preparer = _x11_data_preparer_markup,
 #endif
    },
    ARRAYINIT(CNP_ATOM_text_urilist) {
@@ -956,6 +958,17 @@ _x11_data_preparer_text(Ecore_X_Event_Selection_Notify *notify,
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_x11_data_preparer_markup(Ecore_X_Event_Selection_Notify *notify,
+      Elm_Selection_Data *ddata, Tmp_Info **tmp_info EINA_UNUSED)
+{
+   Ecore_X_Selection_Data *data = notify->data;
+   ddata->format = ELM_SEL_FORMAT_MARKUP;
+   ddata->data = eina_memdup(data->data, data->length, EINA_TRUE);
+   ddata->len = data->length;
+   return EINA_TRUE;
+}
+
 /**
  * So someone is pasting an image into my entry or widget...
  */
index 23e3aabcc5878b07563c9bdb6818ee1dee07a05a..d6ae735316f9e91723f844edfb74afbe4c7dd6cc 100644 (file)
@@ -673,6 +673,10 @@ _selection_data_cb(void *data EINA_UNUSED,
         snprintf(entry_tag, len + 1, tag_string, buf);
         _edje_entry_user_insert(obj, entry_tag);
      }
+   else if (sel_data->format & ELM_SEL_FORMAT_MARKUP)
+     {
+        _edje_entry_user_insert(obj, buf);
+     }
    else
      {
         char *txt = _elm_util_text_to_mkup(buf);