Re: Drag and drop mysteries
- From: Matthias Kaeppler <nospam digitalraid com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtkmm-list gnome org
- Subject: Re: Drag and drop mysteries
- Date: Thu, 19 May 2005 09:22:36 +0200
Chris Vine wrote:
On Wednesday 18 May 2005 09:57, Matthias Kaeppler wrote:
Okay, I have finished reading and I'm not really satisfied. My program
still doesn't work.
// 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,
Gdk::ModifierType( Gdk::BUTTON1_MASK | Gdk::BUTTON2_MASK ),
Gdk::DragAction( Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK )
);
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_get()
.connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_get ) );
m_view.signal_drag_data_received()
.connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_received ) );
[...]
##############################################################
The signal handlers:
##############################################################
void DirBrowser::on_drag_data_get
( const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData&,
guint, guint )
{
std::cout << "getting data" << std::endl;
}
void DirBrowser::on_drag_data_received
( const Glib::RefPtr<Gdk::DragContext>& context, int, int, const
Gtk::SelectionData& data, guint, guint time )
{
std::cout << "data received" << std::endl;
}
##############################################################
The on_drag_data_received is never called. Something is still wrong here.
It is quite difficult to comment on this as it is not complete. I assume you
have a tree model, and I assume you have tree view columns for the tree view.
Apart from that, what I can see is:
1. Your targets should be:
m_target_entries.push_back(Gtk::TargetEntry("STRING"));
m_target_entries.push_back(Gtk::TargetEntry("text/plain"));
2. If, as I assume, DirBrowser is derived from Gtk::Widget you have connected
signals to the virtual protected member functions which also dispatch those
signals.
Chris
at 1) How is one supposed to know this stuff with the "STRING" and
"text/plain"?
It's nowhere documented, it only appears in the examples without further
explanation,
so it looked completely random to me.
What other "types" are there for drag and drop targets?
at 2) I'm not sure what you mean here. I have a TreeView which is
supposed to be dnd enabled.
What does this have to do with the underlying window?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]