static int notify_handler_uri(struct _elm_cnp_selection *sel,
Ecore_X_Event_Selection_Notify *notify);
-static struct pasteimage *pasteimage_alloc(const char *file);
+static struct pasteimage *pasteimage_alloc(const char *file, int pathlen);
static bool pasteimage_append(struct pasteimage *pi, Evas_Object *entry);
static void pasteimage_free(struct pasteimage *pi);
if (!(atoms[j].formats & sel->requestformat)) continue;
for (i = 0 ; i < targets->data.length ; i ++)
{
- if (atoms[j].atom == atomlist[i])
+ if (atoms[j].atom == atomlist[i] && atoms[j].notify)
{
cnp_debug("Atom %s matches\n",atoms[j].name);
goto done;
if (savedtypes.pi) pasteimage_free(savedtypes.pi);
- pi = pasteimage_alloc(p);
+ pi = pasteimage_alloc(p, data->length);
if (savedtypes.textreq)
{
/* FIXME: Add to paste image data to clean up */
- pi = pasteimage_alloc(fname);
+ pi = pasteimage_alloc(fname, data->length);
pasteimage_append(pi, sel->requestwidget);
return 0;
static struct pasteimage *
-pasteimage_alloc(const char *file)
+pasteimage_alloc(const char *file, int pathlen)
{
struct pasteimage *pi;
int len;
- char *buf;
+ char *buf, *filebuf;
+ int prefixlen = strlen("file://");
pi = calloc(1,sizeof(struct pasteimage));
if (!pi) return NULL;
if (file)
{
- if (strstr(file,"file://")) file += strlen("file://");
- pi->file = strdup(file);
+ if (strstr(file,"file://")) file += prefixlen;
+ filebuf = malloc(sizeof(char)*(pathlen-prefixlen+1));
+ strncpy(filebuf, file, pathlen-prefixlen);
+ filebuf[pathlen-prefixlen] = '\0';
+ pi->file = strdup(filebuf);
+ free(filebuf);
}
return pi;