Struggling with TreeModelFilter
- From: Mike Martin <mike redtux org uk>
- To: gtk-perl-list gnome org
- Subject: Struggling with TreeModelFilter
- Date: Mon, 22 May 2017 12:16:10 +0100
Hi
I have a small (3 columns including filter column) treeview with a treemodel filter.
Editing works fine if no filter is applied, but if a filter is applied I cant get the edit to apply to the correct row in the underlying model.
I assume its something to do with setting an iter_to_child_iter mapping , but where?
Code
###setup model###
my $tag_model=Gtk3::ListStore->new('Glib::String','Glib::String','Glib::Boolean')
my $filter=Gtk3::TreeModelFilter->new($widget_table{tag_model});
$filter->set_visible_column(2);
my $tag_view=Gtk3::TreeView->new();
$tag_view->set_model($filter);
the editing setup code is
my @tvctrl=(
[0,'text','tag',0],
[1,'text','value',1],
[2,'bool','vis',1]
);
&tv_cols(\@tvctrl,$tag_view,$tag_model);
sub tv_cols {
my ($cols,$list,$liststore)=@_;
foreach my $col (@{$cols}){
my $column;
my $r;
my $id=$col->[0];
if ($col->[1] eq 'text'){
$r=Gtk3::CellRendererText->new;
$r->set( editable => $col->[3] );
$column = Gtk3::TreeViewColumn->new_with_attributes(
$col->[2],
$r,
'text' => $col->[0]
);
my $model1=[$liststore,$id];
$r->signal_connect (edited => \&cell_edited, $model1);
}
$list->append_column($column);
}
sub cell_edited {
my ($cell, $path_string, $new_text, $model1) = @_;
my ($model,$column)=@{$model1};
my $path = Gtk3::TreePath->new_from_string ($path_string);
my $iter = $model->get_iter ($path);
my $gvalue = Glib::Object::Introspection::GValueWrapper->new (
'Glib::String', $new_text);
#$self->{stack}->child_set_property ($child, 'needs-attention', $gvalue);
$model->set_value ($iter, $column, $gvalue);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]