Re: simplelist and custom cell renderers



"Cristóvão B. B. Dalla Costa" said:
So at first I created a new column type to display the checkbox with the
inconsistent state base on the data placed on the simplelist:

    Gtk2::SimpleList->add_column_type('checkbox3',
          type     => 'Glib::Scalar',
          renderer => 'MyCheckboxCellRenderer',
          attr     => sub {
               my ($treecol, $cell, $model, $iter, $col_num) = @_;

           my $val = $model->get ($iter, $col_num);
           $cell->set (inconsistent => ($val < 0), active => $val > 0);
       }
     );

looks good.

Trouble is, now I couldn't toggle the checkboxes. So I headed off to
create a new cell renderer. I managed to make them togglable, but now I
can't figure out how to change the data back in the list. Actually, I
can't really toggle them properly since I'm using the hack of calling
$simplelist->get_selected_indices to find which row is selected, so I
can toggle only the row that I clicked previously.

There has to be a simpler way, but I can't figure out which of the rows
is being clicked on. How do I find that out?

if you look at Gtk2::SimpleList.pm around line 112 there's a bit of code that
sets up the toggle behavior. when you're custom added type above this code
won't happen since ref $column_info[$i]{attr} is 'CODE'.

the solution (probably) is to get the column's cell renderer after SimpleList
is done and set it up as the code ~ line 112 is doing for bool types indicated
by attr eq 'active'.

-rm



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