OK - I am now handling drag_data_get and drag_data_received. The data is 
passed using set_text, get_text in the SelectionData. This makes more 
logical sense and presumably would work between applications. I still 
have the same basic code as before though (with the same bugs). I still 
look up what is selected in the list to work out what to pass, and 
translate the drop coordinates, insert the row and set it up on the 
other end. Is this what I am supposed to do, or is there a neater way 
that which lets GTK do most of the work?


[EMAIL PROTECTED] wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Tue, Oct 17, 2006 at 03:42:35PM +0100, Christopher Backhouse wrote:
>> Hi
>>
>> I have two Treeviews (just lists, they use Liststore) and I want to be 
>> able to drag entries from one into the other. What is the correct way to 
>> do this?
>> I call enable_model_drag_source on one list and enable_model_drag_dest 
>> on the other - the gui behaves as if drag-and-drop will work and then 
>> doesn't actually do it. Fair enough, I wasn't expecting it to be that 
>> easy. So, I hook up to some of the more likely-looking signals and hack 
>> this together
>>
>> def on_drag_data_recieved(self,widget,context,x,y,selection,myno,dunno):     
>>      
>> (junk,paths)=context.get_source_widget().get_selection().get_selected_rows()
> 
> I have no clue about the Python bindings, but in C you have to implement
> at least the "other side" (that is, the source) as a callback for the event
> "drag_data_get", which then makes the content available (dispatching on
> the content type, that's how source and destination negotiate what type
> to use). You register those same content types in the call to
> gtk_tree_view_enable_model_drag_source().
> 
> Note that whithin the same app you can pass (pointers to) internal data
> structures, whereas for cross-app drag-and-drop you have to convert the
> thing somehow. But maybe the Python bindings handle the marshalling for
> you.
> 
> HTH
> - -- tomás
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> 
> iD8DBQFFNdvUBcgs9XrR2kYRAlNyAJ4tPXA0dstB01BlykqLPHFi6ysN4ACfULdi
> m2a8hcBmOqJ8JgMwkfWowok=
> =V9wk
> -----END PGP SIGNATURE-----
> 
> 
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to