Drag and Drop: watch out for the GtkSelectionData::set_text() contents


A few days ago I was confronted with a weird trouble. That my string that I used which has some typical french characters in it changed to ugly thing like \u009 instead of é. I also discovered that other people who used the serialize() function on GtkSelectionData also encountered some weird things.

So today I found the solution the GtkSelectiondata object works with URI strings. All you have to do is encode your string with the function urlencode($your_string);.

You don't have to decode it : when you do gtkselectiondata::get_text(), it converts back to a normal string.

This is done because of the compability with other programs if you drag and drop outside your program or from outside to inside your program everything is also in uri.

I hope this will help other people who encountered this problem.

Kind regards
Wim Stockman