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() (path,)=paths[0] it=self.list1.store.get_iter_from_string(repr(path)) title=self.list1.store.get_value(it,1) where=widget.get_dest_row_at_pos(x,y) if where!=None: ((row,),pos)=where else: row=0 it=self.list2.store.insert(row+1) self.list2.store.set(it,1,title) I am aware that there are lots of things wrong with this: - it doesn't check where the drag is coming from - I have to specialcase the empty list - it ignores 'pos' so things don't always drop exactly where you expect - it doesn't make any attempt at handling the multiselection case - it breaks the ability of the list to be reordered (just setting it reorderable in glade used to work, now it doesn't) - this method would never work between applications (not that I want it to) With a little more code I could probably fix all these things but it is fairly obvious that this isn't the right way to do it. So how is it supposed to be done? - I would expect that gtk can handle all the dropping it in the correct place stuff itself, shouldn't I just have to handle translating what was in one list into the form the other list needs? Sorry this question ended up being so long - Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list