Re: FW: [gtkmm] drag and drop with multiple targets



Callum Prentice writes:
 >
 > std::list < Gtk::TargetEntry > dndList;
 > dndList.push_back ( Gtk::TargetEntry ( "WIDGET1", 101, 1 ) );
 > dndList.push_back ( Gtk::TargetEntry ( "WIDGET2", 102, 2 ) );
 > dndList.push_back ( Gtk::TargetEntry ( "WIDGET3", 103, 3 ) );
 >
[snip]
 > 
 > I think I'm missing something. I don't really want a separate std::list <> for each widget
 > since there will eventually be a large number of them.

If I understand correctly, you want to give them all a single target
entry / drag source, say "CALLUM_BTN2BTN".  All drag and drop operations
between the buttons will be of this "type".

The data you are using the flags, and info parameters of TargetEntry
will actually be retrieved in the siganl_drag_data_get() signal handler.
Think of the target entry as a *type* of drag and drop data.  The "CALLUM_BTN2BTN"
type is just something the source button has to offer, and the destination
button is able to receive. It just ensures source and destination widget
dnd compatibility ... So

1) you initiate a dnd operation on the source widget has been registered
   as a source of "CALLUM_BTN2BTN"

2) the destination widget (through the "CALLUM_BTN2BTN" target entry)
   proclaims it can accept data of this type, and allows you to drop

[ everything up to this point has pretty much been protocol ... and
  here is the part you're missing ]

3) the source widget's signal_drag_data_get() signal is now triggered,
   so the event handler put the actual data to be transferred into the
   GtkSelectionData structure

4) the destination widget's signal_drag_data_received() is called with
   the GtkSelectionData structure the source widget populated (it should
   process and free this data)


consider drag and dropping 3 megabytes chunks of Gtk::TargetEntry("BIG_STUFF") ...

it would be a shame to allocate the space, just so the user drops it on his
window manager after changing her mind ...

steps 1 and 2 make sure "BIG_STUFF" can and will be transfered
steps 3 and 4 perform the transfer


What goes into the GtkSelectionData for the "CALLUM_BTN2BTN" type?

   you decide ;)



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