Greg Ercolano wrote: > Alvin wrote: >> I welcome any comments or suggestions. > > Nice -- thanks for that! > > I gave it a try on my fedora 3 system with 1.1.x. > Example compiled fine, and shows much promise. > > Didn't work for me when I tried to drag a local image from Firefox > while browsing a local directory; when I dropped the image, it said > "Invalid number of files being dropped: 0." > > I think this is because Firefox is sending 2 bytes per character > (wide chars). I dumped the first 10 bytes of 'urls' to stdout and > piped it through 'od -x', and found it was getting the hex sequence: > 68 00 74 00 74 00 70 00 3a 00 > ..which is the first part of "http:" with a null after every character. > > So to support Firefox, possibly just checking to see if a) the string > length is greater than 2, and urls[1] == 0, and if so, assume wide chars, > and just skip every other byte to accumulate the string. > > Tried also with default konqueror (3.3.0-8) for fedora3 browsing /tmp. > Konqueror always seems to change my typing of /tmp into "file:/tmp", > so when I drag an image over, I get a dialog saying: > > Unsupported URL: file:/tmp/foo.jpg^M > > That's probably an easy fix to just recognize the "file:" prefix > and just strip it off to get the actual filename. > But I can tell it should probably work fine with that small mod. > > Good article.. makes me want to add more D+D features to my apps.
Thanks for comments. I agree, the actual handling of the URL is severely flawed in the example. I was debating on whether I should make it truely robust, but by doing so would complicate the example of receiving the DND events themselves. As for the wide-character strings you found with firefox, I wonder if that's a fltk's ASCII limitation? Would the UTF-8 that Ian MacArthur implicitly handle that? I haven't come across wide-characters in my work (yet), so I'm unfamiliar with them. For the file:/ issue, the problem is that each URL in the string is checked to see if it starts with "file://". So that can be easily fixed. But a better, more robust solution I think, would be to use something like libcurl or the library behind wget (I'm not sure if there is one though). If I understand the homepage, http://curl.haxx.se/libcurl/, libcurl supports a wide range of protocols file:// , http:// https:// ftp:// etc. I have (very) briefly looked at some of the examples using libcurl found here http://curl.haxx.se/libcurl/c/example.html and it looks like libcurl may be useful in this regard? Thank you for the comments and feedback! -- Alvin _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

