On 16/04/07, muppet <[EMAIL PROTECTED]> wrote: > Everything's good right up until the end. ;-)
I've added a couple of callbacks to get new entries into the ListModel to which the EntryCompletion is bound. Selecting entries several times from the EntryCompletion is giving me: Gtk-CRITICAL **: gtk_list_store_get_value: assertion `VALID_ITER (iter, list_store)' failed at ./EntryCompletion3.pl line 105. GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed at ./EntryCompletion3.pl line 105. I've attached the code. What am I doing wrong? #!/usr/bin/perl -w package Mup::CellRendererCompletion; use strict; use Gtk2; use Glib ':constants'; use Glib::Object::Subclass "Gtk2::CellRendererText", properties => [ Glib::ParamSpec->object ('completion', 'Completion', 'The entry completion object for this cell', 'Gtk2::EntryCompletion', G_PARAM_READWRITE), ], ; sub START_EDITING { my ($cell, $event, $view, $path, $background_area, $cell_area, $flags) = @_; my $editable = $cell->SUPER::START_EDITING ( $event, $view, $path, $background_area, $cell_area, $flags ); $editable->set_completion ($cell->{completion}) if ($editable && $editable->isa ('Gtk2::Entry') && $cell-> {completion}); return $editable; } ######################################################################## ####### package main; use strict; use Gtk2 -init; use Glib qw(TRUE FALSE); use Gtk2::Ex::Simple::List; my $cmp_model = Gtk2::ListStore->new ('Glib::String'); $cmp_model->set ($cmp_model->append, 0, $_) foreach qw(one two three four five six seven eight nine ten eleven twelve); $cmp_model -> signal_connect('row-inserted' => sub { my ($model, $path, $iter) = @_; my ($val) = $cmp_model->get($iter, 0); warn "inserted $val\n"; # Weed out duplicates my $iter2 = $cmp_model->iter_next($iter); while ($iter2) { my ($val2) = $cmp_model->get($iter2, 0); warn "list $val2\n"; if ($val eq $val2) { warn "removing $val2\n"; $cmp_model->remove ($iter2); warn "removed $val2\n"; } else { $iter = $iter2; } $iter2 = $cmp_model->iter_next($iter); } }); my $completion = Gtk2::EntryCompletion->new; $completion->set_model ($cmp_model); $completion->set_text_column (0); Gtk2::Ex::Simple::List->add_column_type( 'entrycompletion', type => 'Glib::Scalar', renderer => 'Mup::CellRendererCompletion', attr => sub { my ($treecol, $cell, $model, $iter, $col_num) = @_; my $info = $model->get ($iter, $col_num); $cell->set (text => $info); } ); my $slist = Gtk2::Ex::Simple::List->new( text => 'entrycompletion' ); $slist -> set_column_editable (0, TRUE); push @{$slist->{data}}, [$_] foreach ('one', 'one and a half', 'one and two thirds', 'one and three quarters', 'two'); $slist -> get_model -> signal_connect('row-changed' => sub { my ($model, $path, $iter) = @_; my $text = $slist->get_model->get($iter, 0); $cmp_model->insert_with_values(0, 0, $text); }); my $window = Gtk2::Window->new; $window->signal_connect (destroy => sub { Gtk2->main_quit }); # Get the already-existing renderer for column 0, so we can modify it. my $renderer = ($slist->get_column(0)->get_cell_renderers)[0]; $renderer->set (mode => "editable", editable => TRUE, completion => $completion); $renderer->signal_connect (edited => sub { my ($cell, $path, $new_value) = @_; $slist->{data}[$path][0] = $new_value; }); $window->add ($slist); $window->show_all; Gtk2->main; _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list