Re: Adding a customer cell renderer to a simplelist




On Aug 26, 2004, at 9:24 PM, Daniel Kasak wrote:

So far, I've got:

---

[create simplelist with 6 columns (2 hidden)]
...
[create new column with custom renderer class and no attribute, and append that to the view]

The column gets added to the simplelist, and the spinbutton renderer appears when I edit the cell, but data that I load into the simplelist doesn't get into the cellrenderer.


you're seeing no data in your added column because you haven't told the view column from which model column to retrieve its data.

in cellrenderer_spinbutton.pl, we add the columns with this statement:

  my $column = Gtk2::TreeViewColumn -> new_with_attributes ("no digits",
                                                            $renderer,
                                                            value => 0);

"value" is the name of the CellRendererSpinButton property that contains the value that will be displayed. "0" is the index of the model column containing the data we want the view column to display. the model column 0 is created with the type Glib::Double. it's the all-important "value => $model_column_index" that is missing from your new_with_attributes() call.



note that in the cellrenderer_popup.pl example's driver code, the list data column is created as 'Glib::Scalar', and i used a custom cell data callback to format the list for display.

Unfortunately I didn't completely understand what this meant at the time, and still don't. What does it mean that I have to use a 'scalar' column type when I create the simplelist? Is this referring to the line:

$column = Gtk2::TreeViewColumn->new_with_attributes(
                                                        "Postcode",
                                                        $renderer
                                                   );

not at all. you're getting confused between view columns, into which you pack cell renderers, and model columns, which have a data type and contain data. view columns display data from one or more (indeed, as you have found, possibly zero) model columns. further blurring the distinction between view and model columns, simplelist tries to keep them aligned for you; in the simplelist constructor you specify what simplelist column type you want, and it creates a model column with a corresponding type and a view column with an appropriate renderer.

what that previous message meant was that the data column in the *model* needed to have a scalar type.



--
Our enemies are innovative and resourceful, and so are we. They never stop thinking about new ways to harm our country and our people, and neither do we.
  -- President George W. Bush




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]