summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2015-05-10 16:31:50 +0900
committerThiep Ha <thiepha@gmail.com>2015-06-02 21:50:24 +0900
commitf20cd755c0de567793228ed2b35224da02c861f9 (patch)
tree17910e04f29bdd6947dc993d0f4c48c288724e38
parent639063ef6c8435d56805233a9601603842a961fd (diff)
CnP/Wl: Set selection for all data types
Currently, we hardcode selection types when we do selection set. Besides, not all selection data types are set. This patch sets selection for all suitable types that we supported.
-rw-r--r--src/lib/elm_cnp.c66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 0284e71bc..55f916144 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -2532,6 +2532,21 @@ struct _Wl_Cnp_Selection
2532}; 2532};
2533 2533
2534static Eina_Bool 2534static Eina_Bool
2535_wl_is_uri_type_data(const void *data, int len)
2536{
2537 char *p;
2538 if (len < 6) return EINA_FALSE;
2539
2540 p = (char *)data;
2541 if (!p) return EINA_FALSE;
2542 if (strncmp(p, "file:/", 6))
2543 {
2544 if (*p != '/') return EINA_FALSE;
2545 }
2546 return EINA_TRUE;
2547}
2548
2549static Eina_Bool
2535_wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret) 2550_wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret)
2536{ 2551{
2537 cnp_debug("in\n"); 2552 cnp_debug("in\n");
@@ -3149,6 +3164,10 @@ _wl_elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Form
3149 3164
3150 if (selbuf) 3165 if (selbuf)
3151 { 3166 {
3167 int i = 0, count = 0;
3168 Eina_Bool is_uri = EINA_FALSE;
3169 const char **types;
3170
3152 if (format & ELM_SEL_FORMAT_IMAGE) 3171 if (format & ELM_SEL_FORMAT_IMAGE)
3153 { 3172 {
3154 /* FIXME */ 3173 /* FIXME */
@@ -3164,33 +3183,42 @@ _wl_elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Form
3164 } 3183 }
3165 else 3184 else
3166 { 3185 {
3167 const char *types[10] = {0, }; 3186 free(sel->selbuf);
3168 int i = -1; 3187 sel->buflen = buflen;
3188 sel->selbuf = strdup((char*)selbuf);
3189 }
3169 3190
3170 if ((format & ELM_SEL_FORMAT_MARKUP) || 3191 is_uri = _wl_is_uri_type_data(selbuf, buflen);
3171 (format & ELM_SEL_FORMAT_TEXT)) 3192 for (i = 0, count = 0; i < CNP_N_ATOMS ; i++)
3193 {
3194 if (format & _atoms[i].formats)
3172 { 3195 {
3173 types[++i] = "application/x-elementary-markup"; 3196 if ((is_uri) || ((!is_uri) &&
3174 types[++i] = "text/plain"; 3197 (strcmp(_atoms[i].name, "text/uri") &&
3175 types[++i] = "text/plain;charset=utf-8"; 3198 strcmp(_atoms[i].name, "text/uri-list"))))
3199 count++;
3176 } 3200 }
3177 3201 }
3178 if (format & ELM_SEL_FORMAT_HTML) 3202 types = calloc(1, sizeof(char *) * (count + 1));
3203 if (!types) return EINA_FALSE;
3204 for (i = 0, count = 0; i < CNP_N_ATOMS; i++)
3205 {
3206 if (format & _atoms[i].formats)
3179 { 3207 {
3180 types[++i] = "text/html"; 3208 if ((is_uri) || (!is_uri &&
3181 types[++i] = "text/html;charset=utf-8"; 3209 (strcmp(_atoms[i].name, "text/uri") &&
3210 strcmp(_atoms[i].name, "text/uri-list"))))
3211 {
3212 types[count++] = _atoms[i].name;
3213 }
3182 } 3214 }
3215 }
3183 3216
3184 if (i < 0) return EINA_FALSE; 3217 ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
3185
3186 ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
3187 3218
3188 free(sel->selbuf); 3219 free(types);
3189 sel->buflen = buflen;
3190 sel->selbuf = strdup((char*)selbuf);
3191 3220
3192 return EINA_TRUE; 3221 return EINA_TRUE;
3193 }
3194 } 3222 }
3195 else 3223 else
3196 sel->selbuf = NULL; 3224 sel->selbuf = NULL;