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



Callum,
	I created a class called DnDProxy that encapsulated the needed
object type information as well as a pointer to the object instance.  The
code that put a new'ed DnDProxy looks like this:

void <classname>::drag_data_get(
        const Glib::RefPtr<Gdk::DragContext>&   context,
        GtkSelectionData*
selection_data,
        guint
info,
        guint                                                           time
)
{
	<objectclass>*  ptr    = object_ptr;
	DnDProxy*       proxy   = NULL;

	proxy = new DnDProxy( object_ptr );
      gtk_selection_data_set( selection_data,
                              selection_data->target,
                              8,                     	// data format
                              (const guchar*)&proxy,  // data
                              sizeof( proxy ) );      // data size
}

    Hope that this helps.

	Erik.

> -----Original Message-----
> From: gtkmm-list-admin gnome org 
> [mailto:gtkmm-list-admin gnome org] On Behalf Of Callum Prentice
> Sent: Thursday, February 05, 2004 6:54 PM
> To: gtkmm-list gnome org
> Subject: Re: FW: [gtkmm] drag and drop with multiple targets
> 
> 
> okay - understood up to this point thanks to your clear description.
> 
> > 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
> 
> in the example i have, the data is set in the event handler 
> method using gtk_selection_data_set () but all widgets 
> trigger the same method and (as far as i can tell) there is 
> nothing passed in that allows me to differentiate between widgets.
> 
> if i could for instance, get the address of the source widget 
> and store that instead of a piece of text, i could get it 
> back in my signal_drag_data_received() handler method.
> 
> > 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)
> 
> i am able to retrieve the source widget here by virtue of 
> Gtk::Widget::drag_get_source_widget
> () method but there is no drag_get_dest_widget () or similar 
> - i really need to know which widget was dropped onto so the 
> rest of my logic can decide how to proceed.
> 
> i can see how to do it with a different handler method for 
> each widget but since there will be lots - perhaps hundreds - 
> of them, that really isn't an option.
> 
> once i have the source and destination widgets, my code will 
> rearrange the widgets visually (it's for a "face" based 
> address book that allows you to shuffle the entries manually).
> 
> callum.
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 




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