Re: passing non-string data in drag and drop




On 20 Jul 2000, Havoc Pennington wrote:

> 
> WAN Hing Wah <50191914@ee.cityu.edu.hk> writes:
> > How can I pass non-string data,such as pointer in drag and drop?
> > The GtkSelectionData can only pass string data...
> 
> GtkSelectionData can pass any array of bytes, it doesn't have to be a
> string. The idea is that for a given target (such as text/plain), 
> the contents of the byte array are defined. So you can make up your
> own target and define the byte array to contain whatever you want,
> such as image data.
>
How?would u mind giving me an example source code?
from the GtkSelectionData structure seen in gtkdnd.h
the data field is of type guchar *
looking the source code of gtk_selection_set_data..
it will try to duplicate the string and store in the structure..instead
of using the original pointer....in that way,I can't pass a pointer to
the structure..moreover,even I use "data->data=widget" manually...
after the drag and drop event have ended.the data->data will be freed..so
the gtkwidget structure will be freed  and lead to serious error..
Can u give me example source code to handle it? 
> > Moreover.the GdkDragContext can only get the source GdkWindow...so I can't 
> > transfer data using gtk_object_set_data too...
> 
> There's another problem with using set_data(), which is drags between
> processes, though you may not always want to support that. (But, it
> may be useful to know that the "user_data" field of a GdkWindow is the
> widget that the window belongs to, if any.)
> 





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