Passing a column number to a cell renderer's edited signal



I'm setting up a sub for processing entry in CellRendererText objects. I
set up the renderers and columns like this:

for my $field (@{$self->{fields}}) {
   
    if (!$field->{renderer} || $field->{renderer} eq "text") {
       
        $renderer = Gtk2::CellRendererText->new;
        $renderer->set( editable => 1 );
       
        $column = Gtk2::TreeViewColumn->new_with_attributes(
                                    $field->{display},
                                    $renderer,
                                    'text'    => $column_no
                                   );
    }
   
    $self->{treeview}->append_column($column);
   
    $renderer->signal_connect (edited => sub {
$self->process_text_editing( @_, $column_no ); } );
   
    push @{$self->{ts_def}}, "Glib::String";
   
    $column_no ++;
   
}

However the $column_no received when the 'edited' signal is fired is
always the last value of $column_no from when I set things up -
$column_no is being interpreted each time. I understand why. I just
can't think of a way around it. How do I 'hard code' the column number
into the sub ... without having to have a separate signal_connect line
for each column?

Dan



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