summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elm_cnp.c56
-rw-r--r--src/lib/elm_entry.c72
-rw-r--r--src/lib/elm_priv.h3
3 files changed, 3 insertions, 128 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 55bec4287..6dd18acf1 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -200,7 +200,6 @@ static Eina_Bool _local_elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format fo
200static Ecore_X_Window _x11_elm_widget_xwin_get(const Evas_Object *obj); 200static Ecore_X_Window _x11_elm_widget_xwin_get(const Evas_Object *obj);
201static Tmp_Info *_tempfile_new (int size); 201static Tmp_Info *_tempfile_new (int size);
202static int _tmpinfo_free (Tmp_Info *tmp); 202static int _tmpinfo_free (Tmp_Info *tmp);
203static Eina_Bool _pasteimage_append (char *file, Evas_Object *entry);
204 203
205typedef struct _X11_Cnp_Selection X11_Cnp_Selection; 204typedef struct _X11_Cnp_Selection X11_Cnp_Selection;
206 205
@@ -3013,15 +3012,7 @@ _wl_notify_handler_uri(Wl_Cnp_Selection *sel, Ecore_Wl_Event_Selection_Data_Read
3013 ddata.action = sel->action; 3012 ddata.action = sel->action;
3014 sel->datacb(sel->udata, sel->requestwidget, &ddata); 3013 sel->datacb(sel->udata, sel->requestwidget, &ddata);
3015 } 3014 }
3016 else 3015 else cnp_debug("Paste request\n");
3017 {
3018 char *mkupstr;
3019
3020 mkupstr = _elm_util_text_to_mkup((const char *)stripstr);
3021 /* TODO BUG: should never NEVER assume it's an elm_entry! */
3022 _elm_entry_entry_paste(sel->requestwidget, mkupstr);
3023 free(mkupstr);
3024 }
3025 3016
3026 return 0; 3017 return 0;
3027} 3018}
@@ -3129,17 +3120,7 @@ _wl_notify_handler_image(Wl_Cnp_Selection *sel, Ecore_Wl_Event_Selection_Data_Re
3129 ddata.action = sel->action; 3120 ddata.action = sel->action;
3130 sel->datacb(sel->udata, sel->requestwidget, &ddata); 3121 sel->datacb(sel->udata, sel->requestwidget, &ddata);
3131 } 3122 }
3132 else 3123 else cnp_debug("Paste request\n");
3133 {
3134 cnp_debug("no datacb\n");
3135 tmp = _tempfile_new(ev->len);
3136 if (!tmp) return 0;
3137 memcpy(tmp->map, ev->data, ev->len);
3138 munmap(tmp->map, ev->len);
3139 /* FIXME: Add to paste image data to clean up */
3140 _pasteimage_append(tmp->filename, sel->requestwidget);
3141 _tmpinfo_free(tmp);
3142 }
3143 3124
3144 return 0; 3125 return 0;
3145} 3126}
@@ -3188,21 +3169,7 @@ _wl_notify_handler_text(Wl_Cnp_Selection *sel, Ecore_Wl_Event_Selection_Data_Rea
3188 ddata.action = sel->action; 3169 ddata.action = sel->action;
3189 sel->datacb(sel->udata, sel->requestwidget, &ddata); 3170 sel->datacb(sel->udata, sel->requestwidget, &ddata);
3190 } 3171 }
3191 else 3172 else cnp_debug("Paste request\n");
3192 {
3193 cnp_debug("no datacb\n");
3194 char *stripstr, *mkupstr;
3195
3196 stripstr = malloc(ev->len + 1);
3197 if (!stripstr) return 0;
3198 strncpy(stripstr, (char *)ev->data, ev->len);
3199 stripstr[ev->len] = '\0';
3200 mkupstr = _elm_util_text_to_mkup((const char *)stripstr);
3201 /* TODO BUG: should never NEVER assume it's an elm_entry! */
3202 _elm_entry_entry_paste(sel->requestwidget, mkupstr);
3203 free(stripstr);
3204 free(mkupstr);
3205 }
3206 3173
3207 return 0; 3174 return 0;
3208} 3175}
@@ -4611,23 +4578,6 @@ _tmpinfo_free(Tmp_Info *info)
4611 return 0; 4578 return 0;
4612} 4579}
4613 4580
4614static Eina_Bool
4615_pasteimage_append(char *file, Evas_Object *entry)
4616{
4617 char *entrytag;
4618 int len;
4619 /* TODO BUG: shouldn't define absize=240x180. Prefer data:// instead of href:// -- may need support for evas. See http://dataurl.net/ */
4620 static const char *tagstring = "<item absize=240x180 href=file://%s></item>";
4621
4622 if ((!file) || (!entry)) return EINA_FALSE;
4623 len = strlen(tagstring)+strlen(file);
4624 entrytag = alloca(len + 1);
4625 snprintf(entrytag, len + 1, tagstring, file);
4626 /* TODO BUG: should never NEVER assume it's an elm_entry! */
4627 _elm_entry_entry_paste(entry, entrytag);
4628 return EINA_TRUE;
4629}
4630
4631//////////////////////////////////////////////////////////////////////////// 4581////////////////////////////////////////////////////////////////////////////
4632//////////////////////////////////////////////////////////////////////////// 4582////////////////////////////////////////////////////////////////////////////
4633//////////////////////////////////////////////////////////////////////////// 4583////////////////////////////////////////////////////////////////////////////
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index 44f430c4d..96752d9b3 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -1295,78 +1295,6 @@ _hover_selected_cb(void *data,
1295 elm_widget_scroll_hold_push(data); 1295 elm_widget_scroll_hold_push(data);
1296} 1296}
1297 1297
1298static char *
1299_item_tags_remove(const char *str)
1300{
1301 char *ret;
1302 Eina_Strbuf *buf;
1303
1304 if (!str)
1305 return NULL;
1306
1307 buf = eina_strbuf_new();
1308 if (!buf)
1309 return NULL;
1310
1311 if (!eina_strbuf_append(buf, str))
1312 {
1313 eina_strbuf_free(buf);
1314 return NULL;
1315 }
1316
1317 while (EINA_TRUE)
1318 {
1319 const char *temp = eina_strbuf_string_get(buf);
1320 char *start_tag = NULL;
1321 char *end_tag = NULL;
1322 size_t sindex;
1323 size_t eindex;
1324
1325 start_tag = strstr(temp, "<item");
1326 if (!start_tag)
1327 start_tag = strstr(temp, "</item");
1328 if (start_tag)
1329 end_tag = strstr(start_tag, ">");
1330 else
1331 break;
1332 if (!end_tag || start_tag > end_tag)
1333 break;
1334
1335 sindex = start_tag - temp;
1336 eindex = end_tag - temp + 1;
1337 if (!eina_strbuf_remove(buf, sindex, eindex))
1338 break;
1339 }
1340
1341 ret = eina_strbuf_string_steal(buf);
1342 eina_strbuf_free(buf);
1343
1344 return ret;
1345}
1346
1347void
1348_elm_entry_entry_paste(Evas_Object *obj,
1349 const char *entry)
1350{
1351 char *str = NULL;
1352
1353 ELM_ENTRY_CHECK(obj);
1354 ELM_ENTRY_DATA_GET(obj, sd);
1355
1356 if (sd->cnp_mode == ELM_CNP_MODE_NO_IMAGE)
1357 {
1358 str = _item_tags_remove(entry);
1359 if (!str) str = strdup(entry);
1360 }
1361 else
1362 str = strdup(entry);
1363 if (!str) str = (char *)entry;
1364
1365 edje_object_part_text_user_insert(sd->entry_edje, "elm.text", str);
1366
1367 if (str != entry) free(str);
1368}
1369
1370static void 1298static void
1371_paste_cb(void *data, 1299_paste_cb(void *data,
1372 Evas_Object *obj EINA_UNUSED, 1300 Evas_Object *obj EINA_UNUSED,
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 9e7bc42ba..cd3746eda 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -572,9 +572,6 @@ _elm_dgettext(const char *string)
572 572
573#endif 573#endif
574 574
575/* Used by the paste handler */
576void _elm_entry_entry_paste(Evas_Object *obj, const char *entry);
577
578double _elm_atof(const char *s); 575double _elm_atof(const char *s);
579 576
580#endif 577#endif