See my reply embedded below:

matthiasm wrote:

> 
> On 19.12.2007, at 19:48, Alvin wrote:
> 
>> I have created a little application that uses libmtp to communicate
>> with my
>> Samsung T10 mp3 player. The app supports dropping files onto in
>> order to
>> upload audio and video files to the device.
> 
> 
> 
> Um, the Subject of your mail seems to ask a different question than
> the text of your mail?! Anyway, this is how you do either:

The part of the message you are referring to was my poor attempt at
providing background information. In the future I will ask my question then
give any background information below the question. My bad.

> if you want your app to be a dnd source (dragging items from your app
> to somewhere else), you can use Fl::dnd(). You can use any reason to
> initiate a dnd operation, but normally it would be an FL_DRAG with
> Fl::event_is_click() returning 0. So here we go:
> 
> - write a new handle() function for some widget.
> - on FL_PUSH, return 1, so you will receive subsequend FL_DRAG events
> - on FL_DRAG, test Fl::event_is_click()
> - as soon as the user draggs the mouse more than a few pixels,
> is_click() will return 0. This should initiate your dnd event
> - fill the clipboard with the text you want to send
>    <http://www.fltk.org/documentation.php/doc-1.1/Fl.html#Fl.copy>
> + FLTK has a limitation here. Whatever is in the clipboard is always
> sent as text. So sending the path to a file might not actually send
> the file, but just the path and filename. Some apps interprete that
> correctly, some don't. On Unix, you may have better luck prepending
> the word "file:" to the pathname.
> - call Fl::dnd() and let the OS do the rest
>    <http://www.fltk.org/documentation.php/doc-1.1/Fl.html#Fl.dnd>

Thanks for the steps. I will try it and see what happens. My only
concern/unknown is that the DND destination will no nothing about MTP.
Basically, I do not want to send the path to the file as the file sits on
an unmountable USB device. The file, AFAIK, can only be downloaded via the
MTP protocol as provided by the libmtp library.

I think I will eventually need to do as Kai-Uwe Behrmann suggests and read
the file from the device and store it in a temporary location. Then the DND
destination/receiver will hopefully copy the file from there. When the DND
receiver is done, the FLTK app will delete the temporary file.

My ideal scenario would be for the FLTK app to detect when the DND drop has
occurred. Then the FLTK app would "known" where the dropped occurred (e.g.
into which directory) and use that as the location to store the file. Alas,
I don't think this is possible though.

> if a widget in your app is supposed to receive dnd data, you again
> override the handle() methood and implement a few handlers for the DND
> events. Again, step by step:
> <snipped>

The app does this part as you have written. I used a Fl_DND_Box widget I
created a while back. I thought I had made an article on fltk.org but I
can't find it. Perhaps I forgot or got distracted. Anyway, the Fl_DND_Box
widget is an invisible widget that is placed on top of any other widget (I
use fluid). The Fl_DND_Box handles the appropriate event responding
(FL_DND_ENTER, etc.) so that when a DND Drop event finally occurs occurrs,
the Fl_DND_Box calls its callback. This effectively creates DND Drop zones
on an application. It's my quick way of adding DND dropping support to any
application. I currently use it to drag a file from Konqueror onto a
Fl_Table_Group.


-- 
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to