bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=fcfc9959c2356bdd93e3fecb357bb4d5fe82ea36

commit fcfc9959c2356bdd93e3fecb357bb4d5fe82ea36
Author: Marcel Hollerbach <[email protected]>
Date:   Fri Sep 23 22:00:11 2016 +0200

    elm_cnp: handle format of a drop correctly
    
    the format can also be the result of mutliple or“ed values.
    The new code now also uses the same mimetypes to format type relation
    than the selection code.
    
    This fixes dragging onto a container with multiple formats.
    Spotted by ApBBB while dragging from ephoto to terminology.
    
    This also fixes T3320
---
 src/lib/elementary/elm_cnp.c | 45 +++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)

diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c
index 7362996..fa379de 100644
--- a/src/lib/elementary/elm_cnp.c
+++ b/src/lib/elementary/elm_cnp.c
@@ -3041,11 +3041,15 @@ typedef struct _Format_Translation{
 char *markup[] = {"application/x-elementary-markup", "", NULL};
 char *text[] = {"text/plain;charset=utf-8", "text/plain", NULL};
 char *html[] = {"text/html;charset=utf-8", "text/html", NULL};
+char *vcard[] = {"text/x-vcard", NULL};
+char *image[] = {"image/", "text/uri-list", NULL};
 
 Format_Translation convertion[] = {
   {ELM_SEL_FORMAT_MARKUP, markup},
   {ELM_SEL_FORMAT_TEXT, text},
   {ELM_SEL_FORMAT_HTML, html},
+  {ELM_SEL_FORMAT_VCARD, vcard},
+  {ELM_SEL_FORMAT_IMAGE, image},
   {ELM_SEL_FORMAT_NONE, NULL},
 };
 
@@ -3907,40 +3911,25 @@ _wl_drops_accept(const char *type)
    Dropable *drop;
    Eina_Bool will_accept = EINA_FALSE;
 
+   if (!type) return EINA_FALSE;
+
    EINA_LIST_FOREACH(drops, l, drop)
      {
         Dropable_Cbs *cbs;
         EINA_INLIST_FOREACH(drop->cbs_list, cbs)
           {
-             switch (cbs->types)
+             for (int i = 0; convertion[i].translates ; ++i)
                {
-                case ELM_SEL_FORMAT_TARGETS:
-                case ELM_SEL_FORMAT_IMAGE:
-                   if (!strncmp(type, "image/", 6))
-                     {
-                        wl_cnp_selection.requestwidget = drop->obj;
-                        return EINA_TRUE;
-                     }
-                   break;
-                case ELM_SEL_FORMAT_NONE:
-                   break;
-                case ELM_SEL_FORMAT_MARKUP:
-                case ELM_SEL_FORMAT_TEXT:
-                  if (eina_streq(type, "application/x-elementary-markup") ||
-                      eina_streq(type, "text/plain") ||
-                      eina_streq(type, "text/plain;charset=utf-8") ||
-                      eina_streq(type, "UTF8_STRING") ||
-                      eina_streq(type, "STRING") ||
-                      eina_streq(type, "TEXT"))
-                    return EINA_TRUE;
-                  break;
-                case ELM_SEL_FORMAT_VCARD:
-                   break;
-                case ELM_SEL_FORMAT_HTML:
-                  if (eina_streq(type, "text/html") ||
-                      eina_streq(type, "text/html;charset=utf-8"))
-                    return EINA_TRUE;
-                  break;
+                  if (!(convertion[i].format & cbs->types)) continue;
+
+                  for (int j = 0; convertion[i].translates[j]; ++j)
+                    {
+                       if (!strncmp(type, convertion[i].translates[j], 
strlen(convertion[i].translates[j])))
+                         {
+                            wl_cnp_selection.requestwidget = drop->obj;
+                            return EINA_TRUE;
+                         }
+                    }
                }
           }
      }

-- 


Reply via email to