Re: Switch a CellRendererCombo's model



muppet wrote:

On Jul 4, 2005, at 11:50 PM, Daniel Kasak wrote:

I'm having a really, *really* bad performance problem in a treeview 
that
has a CellRendererCombo with a large model.

How bad?

:)

Oh ... it's pretty bad. The model has locations and postcodes ( zip
codes ), and there are 15,000 of them in the table. If I populate a
TreeModel / TreeView with 15 records and use the postcodes model in one
of the cells, it takes about 5 seconds of 100% CPU usage just to draw
the TreeView. Other events:

- resize the TreeView - 5 seconds at 100% CPU
- click in a row - 2 second delay, CPU at 100%
- edit data in a cell - 3 to 4 second delay, CPU at 100%
- switch to another desktop and back - 5 second delay, CPU at 50%
- point mouse in general direction of TreeView, with small movements,
CPU constantly at 15%

Is there any way around this?

Store the appropriate combo model for each row in an extra column in 
the main treemodel, and use an attribute on the TreeViewColumn to 
tell the CellRendererCombo where to find the model.  Since this has 
potential to use obscene amounts of memory, you'll want to share 
models between rows.

That sounds like what I want, but I'm a little unclear on how to get
there. At the moment, I'm setting the model with:

---

$renderer = Gtk2::CellRendererCombo->new;

$renderer->set(
            editable    => TRUE,
            model       => $field->{model},
            text_column => 1,
            has_entry   => TRUE
);

$renderer->{column} = $column_no;

$self->{columns}[$column_no] = Gtk2::TreeViewColumn->new_with_attributes(
            $field->{name},
            $renderer,
            text    => $column_no
);

---

So in my $renderer->set() line, I'd remove the model => $field->{model}
bit. And I'd replace it with something in the above
Gtk2::TreeViewColumn->new_with_attributed() line? Assuming I have packed
a model into column $combo_model_column in the main TreeModel, how do I
tell the CellRendererCombo to use it?

-- 
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



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