Fixes to dnd. Summary:

- Konqueror: dnd works, classic copypaste konq->efiler works, efiler->konq 
wants to create a text file
- Nautilus: dnd works both ways, copy/paste buffer is incompatible (neither 
side sees anything in the buffer)
- Rox-filer: dnd works both ways, rox apparently has no copy/paste buffer
This commit is contained in:
Vedran Ljubovic 2007-08-03 20:18:09 +00:00
parent fe60a7a9cb
commit 817e0cd918
3 changed files with 11 additions and 6 deletions

View File

@ -412,8 +412,10 @@ fprintf (stderr, "value: %s\n", value.c_str());
edelib::String selected_items;
for (int i=1; i<=size(); i++)
if (selected(i)==1) {
if (selected_items != "") selected_items += "\n";
// if (selected_items != "") selected_items += "\r\n";
selected_items += "file://";
selected_items += (char*)data(i);
selected_items += "\r\n";
}
Fl::copy(selected_items.c_str(),selected_items.length(),0);
Fl::dnd();
@ -426,12 +428,13 @@ fprintf (stderr, "value: %s\n", value.c_str());
if (Fl::event_y()<y() || Fl::event_y()>y()+h()) return 1;
// ^^ this can be a source of crashes in Fl::dnd()
fprintf(stderr, "FL_DND_RELEASE\n");
fprintf(stderr, "FL_DND_RELEASE '%s'\n", Fl::event_text());
// Sometimes drag is accidental
if (abs(Fl::event_x()-dragx)>10 || abs(Fl::event_y()-dragy)>10) {
dndrelease=true;
Fl::paste(*this,0);
}
return 1;
}
if (e==FL_PASTE) {
fprintf(stderr, "FL_PASTE\n");

View File

@ -1,4 +1,3 @@
- Fix dnd (and if possible copy&paste) with other popular file managers
- Add dnd to directory tree
- Add notify support from edelib
- Add support for fd.o Trash protocol

View File

@ -103,12 +103,13 @@ void do_cut_copy(bool m_copy) {
return;
}
char* p = (char*)view->path(i);
while (strlen(buf)+strlen(p) >= bufsize) {
while (strlen(buf)+strlen(p)+8 >= bufsize) {
bufsize+=10000;
buf = (char*)realloc(buf,sizeof(char)*bufsize);
}
if (buf[0] != '\0') strncat(buf, "\n", 1);
strncat(buf, "file://", 7);
strncat(buf,p,strlen(p));
strncat(buf, "\r\n", 1);
if (operation == CUT) view->gray(i);
nselected++;
}
@ -429,10 +430,12 @@ fprintf (stderr, "PASTE from '%s', to '%s', type=%d\n",(char*)Fl::event_text(),t
tmp2 = strchr(tmp,'\n');
int len=tmp2-tmp;
if (!tmp2) len=strlen(tmp);
if (len<2) { tmp=tmp2+1; count--; continue; }
from[k] = (char*)malloc(sizeof(char) * (len+2));
strncpy(from[k],tmp,len);
from[k][len]='\0';
// Paste from file managers with a vfs
if (from[k][len-1] == '\r') { len--; from[k][len]='\0'; }
// We accept both URIs (beginning with file://) and plain filename
if (strncmp(from[k],"file://",7)==0)
for (int i=0; i<=len-7; i++)
from[k][i]=from[k][i+7];