On 14/04/07, muppet <scott asofyet.org> wrote:
> To modify the behavior of SimpleList's editing
controls, you'll
> basically have to create a custom column type, and
handle the editing
> behavior all for yourself.
> There are other discussions on this list about how to
make all that
> work, and several cell editing examples available.
I've realised that I want EntryCompletion working in a
SimpleList. (I
hadn't realised that the EntryCompletion widget existed
before) You
provided an example with a TreeView in:
http://mail.gnome.org/archives/gtk-perl-list
/2006-June/msg00021.html
But I am having trouble converting it to a SimpleList.
Below is my (non-completing) version of your example. Where
am I going
wrong? Or is this not possible with a SimpleList?
Thanks for any help
Jeff
#!/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->)
if ($editable && $editable->isa ('Gtk2::Entry')
&& $cell-> );
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);
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->}, [$_]
foreach ('one', 'one and a half', 'one and two thirds',
'one and
three quarters', 'two');
my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub {
Gtk2->main_quit });
my $renderer = Mup::CellRendererCompletion->new;
$renderer->set (mode => "editable",
editable => TRUE,
completion => $completion);
$renderer->signal_connect (edited => sub {
my ($cell, $path, $new_value) = _;
$slist->[$path->get_indices][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
|