Drag and drop mysteries



Hello,

I want to implement drag and drop for my filemanager application. I have two treeviews of the filesystem, now I want to be able to drag e.g. a file from the left to right, but the drag and drop mechanics in gtkmm are a complete mystery to me, and the documentation is not very giving in this part.

Okay, first question would be:
Where comes this TargetEntry class into play? I don't get what I have to specify there. The examples in the documentation are rather odd and pretty meaningless to me (what are "STRING" and "text/plain" supposed to be?).

Say I want to separate between dragging directories and files, would I then have to create two TargetEntries, one called "dir" and the other called "file", for example, or what?

Furthermore, although I have set my treeview widget to be both destination and source for dnd events, it never accepts any "drops", at least not visually (the dragged entry always "flies back" to the source widget).

How come?

And what are the singal_drag_data_get and signal_drag_data_received events and when are they fired?

So many questions :)

Here is some code, I don't know if it's sane or not...

    // enable drag and drop
    m_target_entries.push_back( Gtk::TargetEntry("FILE") );
    m_target_entries.push_back( Gtk::TargetEntry("DIR") );

    m_view.drag_source_set( m_target_entries );
    m_view.drag_dest_set(
	m_target_entries,
	Gtk::DEST_DEFAULT_ALL,
	Gdk::DragAction( GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK )
	);

    m_view.signal_drag_data_received()
	.connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_received ) );


The event is never fired when I drag around things.

--
Matthias Kaeppler




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