Re: Switch a CellRendererCombo's model



Torsten Schoenfeld wrote:

On Wed, 2005-07-06 at 09:18 +1000, Daniel Kasak wrote:

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?


You add

 model => $combo_model_column

to the new_with_attributes() call.


I'm still not getting anywhere. Sorry.

My main TreeStore has a column at the end ( 1 from the end anyway )
that's defined as a Gtk2::ListStore ( I've also tried with a
Glib::Scalar ). I'm not sure if either of these are correct.

Basically I'm populating the main TreeStore like this:

---

    while (my @row = $sth->fetchrow_array) {
       
        my @model_row;
        my $column = 0;
       
        # Append a new treeiter, and the status indicator
        push @model_row, $liststore->append, STATUS_COLUMN, UNCHANGED;
       
        for my $field (@{$self->{fields}}) {
           
            if ( $field->{renderer} eq "model" ) {
               
                # ie this column stores the model for a combo elsewhere
                push @model_row, $column + 1, $field->{model};
               
            } else {
               
                push @model_row, $column + 1, $row[$column];
               
            }
           
            $column++;
           
        }
       
        # Append the primary key to the end
        push @model_row, $column + 1, $row[$column];
       
        $liststore->set(@model_row);
       
    }

---

This code at least runs without any errors.

I'm setting up the CellRendererCombo like this:

---

    $renderer = Gtk2::CellRendererCombo->new;
   
    if ( ! $self->{readonly} ) {
        $renderer->set(
                editable    => TRUE,
                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,
                                            model   => $column_no_of_model,
                                        );
   
    $renderer->signal_connect( edited => sub {
$self->process_text_editing( @_ ); } );
   
    $self->{treeview}->append_column($self->{columns}[$column_no]);

---

When the main TreeStore is populated and gets rendered, I get a string of:

GLib-GObject-WARNING **: unable to set property `model' of type
`GtkTreeModel' from value of type `gint'

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