for those who are interested, or need to have file drag and drop support in your apps, this is a first stab at XDND support (treating linux component peer as target only, not source… since juce doesn’t support sending drop messages to others apps).
juce_linux_Windowing.cpp
hope to see cleaned and merged in the next juce version !
…dropped file names are escaped. I mean special characters and non-english characters are escaped. You must unescape file names yourself before sending them to a component or provide a function to let programmers unecape them by themselves.
i’ve not figured out much this as i’ve tried dropping files with regular names only (my mistake then)… i don’t think this will be difficult, but won’t look at it unless is merged in the juce trunk, i don’t want to work on something that probably have changed by jules over time…
probably in the handleDragAndDropSelection we should convert the char* droppedData to be utf8 instead… don’t know how at the moment, so if you want to look in it by yourself it will be appreciated here: we are working togheter, isn’t that the goal of the linux community ?
The escaped file names are escaped like a regular URL link in a browser. Also, the escaped file names are already UTF-8 encoded and escaped characters are UTF-8 escaped characters. So, I’ve found the utility function (from POCO library) that unescapes escaped strings (I’ve adopted it to JUCE a little bit). And it works for me!
[code]String unescape(const String& str)
{
std::string instr(str);
std::string::const_iterator it = instr.begin();
std::string::const_iterator end = instr.end();
std::string decodedStr;
while (it != end)
{
char c = *it++;
if (c == '%')
{
if (it == end) break;
char hi = *it++;
if (it == end) break;
char lo = *it++;
if (hi >= '0' && hi <= '9')
c = hi - '0';
else if (hi >= 'A' && hi <= 'F')
c = hi - 'A' + 10;
else if (hi >= 'a' && hi <= 'f')
c = hi - 'a' + 10;
else break;
c *= 16;
if (lo >= '0' && lo <= '9')
c += lo - '0';
else if (lo >= 'A' && lo <= 'F')
c += lo - 'A' + 10;
else if (lo >= 'a' && lo <= 'f')
c += lo - 'a' + 10;
else break;
}
decodedStr += c;
}
#if defined(POSIX)
return String::fromUTF8((const uint8*)decodedStr.c_str());
#elif defined(WINDOWS)
return String(decodedStr.c_str());
#endif
}[/code]
ah the names was escaped, not encoded !
i’ve not understaood that when i read your post…
my mind’s blowing !