wtf? stray escape chars! fix!
[framework/uifw/elementary.git] / src / lib / elm_cnp.c
index ea06156..cf08189 100644 (file)
@@ -390,7 +390,7 @@ elm_selection_selection_has_owner(void)
 }
 
 EAPI Eina_Bool
-elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj,
+elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
                       Elm_Sel_Format format, const void *selbuf, size_t buflen)
 {
 #ifdef HAVE_ELEMENTARY_X
@@ -417,7 +417,8 @@ elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj,
      {
         if (format == ELM_SEL_FORMAT_IMAGE)
           {
-             sel->selbuf = malloc(buflen+1);
+             // selbuf is actual image data, not text/string
+             sel->selbuf = malloc(buflen);
              memcpy(sel->selbuf, selbuf, buflen);
           }
         else
@@ -463,8 +464,8 @@ elm_object_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type selection)
 }
 
 EAPI Eina_Bool
-elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format,
-                      Evas_Object *obj, Elm_Drop_Cb datacb, void *udata)
+elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection,
+                      Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata)
 {
 #ifdef HAVE_ELEMENTARY_X
    Evas_Object *top;
@@ -715,7 +716,7 @@ notify_handler_targets(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notif
                   if ((j == CNP_ATOM_text_uri) ||
                       (j == CNP_ATOM_text_urilist))
                     {
-                      if(!is_uri_type_data(sel, notify)) continue;
+                      if (!is_uri_type_data(sel, notify)) continue;
                     }
                   cnp_debug("Atom %s matches\n",atoms[j].name);
                   goto done;
@@ -775,8 +776,13 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify)
 {
    Ecore_X_Selection_Data *data;
    char *str;
+   char *mkupstr;
 
    data = notify->data;
+   str = malloc(sizeof(char) * (data->length + 1));
+   if (!str) return 0;
+   strncpy(str, (char *)data->data, data->length);
+   str[data->length] = '\0';
 
    if (sel->datacb)
      {
@@ -787,14 +793,17 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify)
         ddata.data = data->data;
         ddata.len = data->length;
         sel->datacb(sel->udata, sel->widget, &ddata);
+        free(str);
         return 0;
      }
 
-   cnp_debug("Notify handler text %d %d %p\n", data->format,data->length, data->data);
-   str = _elm_util_text_to_mkup((const char *) data->data);
+   cnp_debug("Notify handler text %d %d %p\n", data->format,
+             data->length, data->data);
+   mkupstr = _elm_util_text_to_mkup((const char *)str);
    cnp_debug("String is %s (from %s)\n", str, data->data);
-   _elm_entry_entry_paste(sel->requestwidget, str);
+   _elm_entry_entry_paste(sel->requestwidget, mkupstr);
    free(str);
+   free(mkupstr);
    return 0;
 }