I'm writing a GUI app on gtk2 perl. There is a table which show rows from database, when an user click on a checkbox. And when he click on it again then rows with defined column value must be hidden.
I have this code:
# ListStore to stores model
my $list_store = Gtk2::ListStore->new(("Glib::String") x 3);
my $rows = &get_row($st); # arrayref on rows from a db
sub set_columns {
my ($store, $rows) = @_;
foreach my $row (@$rows) {
my ($num, $name, $status) = @$row;
$store->set($store->append,
0 => $num,
1 => $name,
2 => $status,
);
}
} # ---------- end of subroutine set_columns ----------
...
sub show_columns {
my ($names) = @_; # reference to @name_columns
my $i = 0; # number of columns within ListStore
foreach (@$names) {
# TreeViewColumn is a column for TreeView
my $col = Gtk2::TreeViewColumn->new;
$col->set_title($_);
$col->set_alignment(0.5); # alignment of header
$col->set_clickable(1); # can click on header
$tree_view->append_column($col);
my $rend = Gtk2::CellRendererText->new;
$col->pack_start($rend, TRUE);
# Link column of TreeViewColumn's renderer to column of ListStore
$col->add_attribute($rend, 'text', $i++);
}
}
...
my @name_columns = qw(№ Name Status);
&set_columns($store, $rows);
&show_columns(\@name_columns);
And I have a checkbox:
$ch->signal_connect(toggled => sub {
my $self = shift;
if ($self->get_active) {
print "Yes\n";
my $st = 'Good'; # status
&global_view($list_store, $st); # function which call set and show_columns
} else {
print "No\n";
# TO-DO here!!!!!
}
});
Well, how can I hide rows with defined $st(status) from TreeViewColumn so as to hide them from users when they click on the checkbox one more time(deactivate)?