Subject: Re: Reorderable tree view From: Gabriel de Perthuis To: pascal.brisset at enac.fr Cc: lablgtk at math.nagoya-u.ac.jp In-Reply-To: <20050520.175617.104029881.andrieu at ijm.jussieu.fr> References: <428D8905.7070008 at recherche.enac.fr> <20050520.175617.104029881.andrieu@ijm.jussieu.fr> Content-Type: text/plain; charset=UTF-8 Date: Fri, 20 May 2005 21:53:03 +0200 Message-Id: <1116618783.23464.18.camel at localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Le vendredi 20 mai 2005 à 17:56 +0200, Olivier Andrieu a écrit : > Pascal Brisset [Fri, 20 May 2005]: > > Hi, > > > > I'm looking for a way to constraint the drag and drop actions in a > > GTree.view. Is it possible to get the "drop" event to check it and > > possibly forbid it ? > > What do you want to drag ? rows or columns ? > > - for columns you have gtk_tree_view_set_column_drag_function() (not > wrapped in lablgtk though) > > - for rows, it's more involved and has to be done in C. You'll have to > redefine the row_drop_possible method in the GtkTreeDragDest interface > (which is implemented by GtkTreeStore and GtkListStore). (I think, > I've never done this before !) Unless there's a tree view specific quirk (maybe you want to check which line will be the drop): method realize () = view#drag#dest_set ~flags:[] [] method can_drop () = ... method update_highlight () = if self#can_drop () then view#drag#highlight () else view#drag#unhighlight () method drag_motion = fun context ~x ~y ~time -> update_highlight (); if self#can_drop () then c#status ~time (Some `DEFAULT) else c#status None; The call to dest_set with [] as flags gives you more control than gtk's target-based (mime types) filtering, but you must control the highlighting yourself.