Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=5wPitBQG8oYZxNQwDxatYg3H4saGLWJdDXV/zz+c5+Q=; b=Zj5S+qGzGrCPl0TlHbWriBEgNH0eKWP6NTiy9a91669gX4ayWRcKjI/bRrTWqKaZdQ xZsU2XgF7ApgGFsajuc8Qk6st5rKaomO7ymQftj2IZJOOhMG5PwhVfOdvwrSeqC7EN0G tSlGtWyLZ/iGF3cBgg7U2YtEe9OoMd2FUTHCE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=N+p9/OQgirOVwf7y8vTXUSpotTpmOuPrIqi+94encK9Hh3ELjZj459A25zH9LvU8Fj 2FyvLcpUgI1K9AFS/zGltw21Uf9ACs8ezgd/y1cm03c2J2g6hCH9EV6lthtKxRh9Womj 1hkHhiYRDA4H4dbz38BX7brjVwLZ3IXa0eMJg= Date: Sun, 19 Dec 2010 19:30:26 -0600 From: Peter Groves To: Adrien Subject: Re: [Lablgtk] GTree.cell_renderer_toggle not activatable by user Message-Id: <20101219193026.b7da257b.pdgroves at gmail.com> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: lablgtk Status: U For reasons I've never understood, you have to monitor the 'toggled' events from the cell_renderer and in the monitoring function you have to 'set' the value in the model to be the opposite of the old value. Sorry to dump partial code on you, but I don't have time to give you a good writeup of what happens. Below is the code I have in my app that does what you're trying to do. This code snippet occurs when I'm building a GTree.view. Like you, I got it working using guess-and-check programming (which GTK development requires far too often) so I can't guarantee you everything in here is really necessary. (*************START**************) (** add the checkbox column to the view *) let checkBoxModelCol = localModel.checkBoxColumn in let renderOptionsCheckBox = [(`ACTIVATABLE true); (`ACTIVE true)] in let rendererCheckBox = GTree.cell_renderer_toggle renderOptionsCheckBox in let toggleMonitor = fun gtkTreePath -> begin Log.info "toggle monitor firing"; let modelIter = treeModel#get_iter gtkTreePath in let existingBoolVal = treeModel#get ~row:modelIter ~column:checkBoxModelCol in let newBoolVal = (not existingBoolVal) in treeModel#set ~row:modelIter ~column:checkBoxModelCol newBoolVal; end in ignore (rendererCheckBox#connect#toggled ~callback:toggleMonitor); let viewColumnCheckBox = GTree.view_column ~title:"Selected?" ~renderer:(rendererCheckBox, [("active",checkBoxModelCol)]) () in viewColumnCheckBox#set_sort_column_id 0; ignore (treeView#append_column(viewColumnCheckBox)); (*************END**************) On Mon, 20 Dec 2010 01:10:21 +0100 Adrien wrote: > Hi, > > I've been trying to get a treeview with checkboxes that the user can > toggle but they don't "react" in the interface. > I'm currently using > let renderer_toggle = GTree.cell_renderer_toggle [ `ACTIVATABLE > true ] in but in vain. > > I've made a pretty small reproducer (around 30 lines) which I've > attached. > > Compile with ocamlfind ocamlopt -linkpkg -package lablgtk2 > cell_renderer_toggle_activatable.ml -o > cell_renderer_toggle_activatable > > I'm not very confortable with treeviews so I may be doing something > pretty dumb but I really can't see what. Any help is appreciated. > > Thanks. :-) > > -- > > Adrien Nader > _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk