Re: Filechooser dragging



On Sun, 2006-01-15 at 18:30 +0000, Bartek Kostrzewa wrote:
> I have a filechooser widget from which I want to drag filenames into my
> application (not using OK or Cancel buttons, just dragging folders and
> files)...
> 
> I've got the file filters all set up but I don't understand how to do
> the dragging. The tutorial is way too simple (and wrong I believe, at
> least SigC::slot does not even exist in my installation). Is there any

you are reading an old document that covers earlier versions of gtkmm. 

> documentation on what data the filechooserwidget actually drags around
> and how to access it, further I really don't understand how to set up
> the callbacks for signal_drag_data_get (this works more or less) and
> signal_drag_data_received !
> 
> Could a kind soul help me out?

typically (from nautilus and konqueror) you will get a drag target of
type "text/plain" or "text/uri-list" (the former seems more common). the
text will be a series of URI's of form:

	file:///path

separated by (and here is where it gets painful) either '\n', or '\r' or
'\n\r' (depending on the birth month of the programmer in question).

unfortunately, in my experience, even though this is actually a URI-
list-like format, nautilus for one does send a 100% compliant URI-list,
and admits as much by saying its "text/plain". hence you cannot use the
handy Glib functions to convert the string to a list of files.

if your widget is only the dropsite, not a drag source,
drag_data_received is the only signal you need to handle. you also need
to set up your potential drag targets to include text/plain.

there is a reasonably helpful (C) tutorial:

http://scentric.net/tutorial/sec-dnd.html

--p





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]