Re: Adding a customer cell renderer to a simplelist



muppet wrote:


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.

Still no joy here :(

I'm a little unsure of how the columns are numbered ( whether hidden columns count or not ). I started out by assuming that they *do* count, so I used:

    my $renderer = Gtk2::CellRendererSpinButton->new();
$renderer->set(
                        mode    => "editable",
                        min     => 0,
                        max     => 1000,
                        step    => 1,
                        digits  => 0
                  );
$renderer->signal_connect(edited => \&locations_postcode_cell_edited); $column = Gtk2::TreeViewColumn->new_with_attributes(
                                                            "Postcode",
                                                            $renderer,
                                                            value   => 6
                                                       );
$locations_slist->{widget}->append_column($column);

That gave me:

can't set value for column 6, model only has 6 columns at /usr/lib/perl5/vendor_perl/5.8.4/i686-linux/Gtk2/SimpleList.pm line 238. can't set value for column 6, model only has 6 columns at /usr/lib/perl5/vendor_perl/5.8.4/i686-linux/Gtk2/SimpleList.pm line 238.

and then a ( long ) string of:

Gtk-CRITICAL **: file gtkliststore.c: line 569 (gtk_list_store_get_value): assertion `column < GTK_LIST_STORE (tree_model)->n_columns' failed at /home/dan/sales/sales.pl line 5097. GLib-GObject-CRITICAL **: file gobject.c: line 1239 (g_object_set_property): assertion `G_IS_VALUE (value)' failed at /home/dan/sales/sales.pl line 5097. GLib-GObject-CRITICAL **: file gvalue.c: line 149 (g_value_unset): assertion `G_IS_VALUE (value)' failed at /home/dan/sales/sales.pl line 5097.

errors.

If I set value to 5 ( or less ), I get:

can't set value for column 6, model only has 6 columns at /usr/lib/perl5/vendor_perl/5.8.4/i686-linux/Gtk2/SimpleList.pm line 238. can't set value for column 6, model only has 6 columns at /usr/lib/perl5/vendor_perl/5.8.4/i686-linux/Gtk2/SimpleList.pm line 238.

and then a string of:

GLib-GObject-WARNING **: unable to set property `value' of type `gdouble' from value of type `gchararray' at /home/dan/sales/sales.pl line 5097.

errors.

It still doesn't seem like my new column is being 'registered' as far as the SimpleList is concerned...

I've just had an idea now: am I supposed to have *another* column with the value to be used for the custom cellrenderer to look at ( ie am I supposed to define the 'PostCode' column when I first create the SimpleList and then just set it's width to zero? )? I've tried mucking around with this for a little while but it doesn't seem to help either. I drop the:

can't set value for column 6, model only has 6 columns at /usr/lib/perl5/vendor_perl/5.8.4/i686-linux/Gtk2/SimpleList.pm line 238.

errors, but still can't get my custom column to display anything.

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
Title: CanIt Vote for ID 91376

The following links have been inserted by the NUS Consulting internal spam filter and are for NUS Consulting staff only
Spam
Not spam
Forget previous vote


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