Re: [Gtk-Perl] Gtk2::SimpleList
- From: muppet <scott asofyet org>
- To: Gtk-Perl-List <gtk-perl-list gnome org>
- Subject: Re: [Gtk-Perl] Gtk2::SimpleList
- Date: Sat, 26 Jul 2003 14:51:36 -0400
On Saturday, July 26, 2003, at 01:20 PM, Ross McFarland wrote:
$list = Gtk2::SimpleList->new(
'Column One' => 'text',
'Column Two' => 'int',
'Column Three' => 'bool',
);
that's column title => datatype nickname... you can turn off display
of the titles or otherwise manipulate the headings through the normal
treeview methods.
# in general you can use @$ldata or what i pointed it to,
@{$list->{data}}, as an array.
incidentally, when you set all the data in one go, you have to use it
as a real array, not an array reference --- otherwise, you overwrite
the tied object. (i haven't messed ties enough to know standard
practice, could anyone illuminate me?)
$ldata->[0][1] would return 'one'
i think that should be [0][0]...
you can also do
@$ldata = qw/foo bar baz/;
to set just the zeroth columns of the rows --- allowing you do to fun
things like add single-column listboxes to dialogs with very little
code:
$dlg = Gtk2::Dialog->new (...);
$dlg->vbox->pack_start (Gtk2::Label->new ('pick a fish...', 0,0,0);
$list = Gtk2::SimpleList->new ('' => 'string');
$list->set_columns_visible (0);
$dlg->vbox->pack_start ($list, 0, 0, 0);
@{ $list->{data} } = qw/one two red blue/;
$dlg->show_all;
$dlg->run;
what it doesn't yet have is a way to tell what was selected --- but the
SimpleList inherits the TreeView, so you could conceivably do
my ($model,$iter) = $list->get_selection->get_selected;
$selected = $model->get ($iter, 0);
but i'd really prefer something like
$selindex = $list->get_selected_index;
$selected = $list->{data}[$selindex][0];
but i think we need to put more thought into than that.
it also will keep up with updates, i.e. when the bool's change.
actually, i think it only keeps up with changing of bools. you'll have
to use normal treeview tricks to get editable cells.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]