Re: Help with CellRendererPopup




On Jul 11, 2004, at 7:01 PM, Daniel Kasak wrote:

I've been trying in vain for more hours than I'd care to admit to get a modified example working ... the Mup::CellRendererPopup.

then you're not going to like how simple the problem is. ;-) short answer: the column type is wrong.


This is what I've got so far ( please excuse what Mozilla does to my formatting ):

$slist = Gtk2::SimpleList->new_from_treeview(
$prospects->get_widget('TelecomAccounts_SList'), 'ID' => 'hidden', 'AccountNo' => 'text', 'Supplier_index' => 'int', 'Notes' => 'text', 'Need Itemisation' => 'bool', 'Suppliers' => 'text'
                                            );
...
$column = Gtk2::TreeViewColumn->new_with_attributes (
                                                        'Supplier',
                                                        $renderer,
list => 5, 'index' => 2,
                                                    );

you're telling the column to set the Mup::CellRendererPopup object's 'list' property from the value in the model's column 5. the popup's 'list' property is defined as a boxed type of 'Glib::Scalar', because you're supposed to put a list reference in it; however, your model's column 5 is defined to contain 'Glib::String' data (that's what SimpleList uses for the 'text' column type). 'Glib::String' means 'char*'.

so, two problems arise from this:

1) your list reference, created with

push @list_data, [ $rec[0], $rec[1], $rec[2], $rec[3], $rec[4], [ sort(@telecom_suppliers) ] ];

gets stringified, which isn't what you want.


2) when the column is asked to set the data for the popup render, it fetches the data from the model as a string (char*, known to the glib type system as 'gchararray'), and passes that value to the popup cell renderer, but the type system sees that the cell renderer wants a boxed object of type 'Glib::Scalar', which is registered with the C type system as 'GPerlSV'. there is no way to convert that, so you get this warning:

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

and the set operation aborts, leaving the cell to be rendered with empty data.


Anyone know what I'm doing wrong?

maybe.  ;-)


use a 'scalar' column type when you create the simplelist.

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.


--
elysse (pregnant): are your hands cold?
me: uh, i suppose so.
elysse: will you put them on me?




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