Message-ID: <33077.81.185.33.44.1147254210.squirrel at webmail.nerim.net> In-Reply-To: <4461A1A1.30508 at laposte.net> References: <4461A1A1.30508 at laposte.net> Date: Wed, 10 May 2006 11:43:30 +0200 (CEST) Subject: Re: GTree.view: use of attributes From: "Olivier Andrieu" To: matthieu.dubuget at laposte.net Cc: lablgtk at math.nagoya-u.ac.jp MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Importance: Normal Content-Type: text/plain;charset=iso-8859-1 Content-Length: 1655 Hi, > I'm trying to display datas using GTree. > > I would like to be able to adapt every row, depending on some values > stored in different columns of the model. I achieved this using the > set_cell_data_func method of view_column. > > Is there something more direct, to achieve the same effect? > > I tried to use: > > val view_column : > ?title:string -> > ?renderer:(#cell_renderer * (string * 'a column) list) -> > unit -> view_column > > but it does not work if the columns I try to connect to the renderer > properties are heterogeneous: for example, I was not able to connect the > `FOREGROUND_SET property to one column, and in the same time, the `TEXT > property to another, because the types of the two columns differs. Indeed. > Inside view_column class, there is > > method add_attribute : > 'a 'b. (#cell_renderer as 'a) -> string -> 'b column -> unit = > fun crr attr col -> > TreeViewColumn.add_attribute obj crr#as_renderer attr col.index > > that (if I understand well) should help to do what I need? Yes, in the optional 'renderer' argument of the view_column constructor this #add_attribute method is applied to the elements of the list. You get the same behaviour when you do it "manually", and that's what you'll have to do since your columns have different types. > Is there any good reason not to export this function in gTree.mli? It is exported ! (You can't hide public methods in signatures in OCaml anyway). That's because in the .ml the method is declared directly in the object whereas in the .mli it is inherited from the GTree.cell_layout class type. Indeed it's a bit unusual. -- Olivier