|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Get all rows in Gtk2::ListStoreHi All,
I have defined the following ListStore: my $list_store = Gtk2::ListStore->new('Glib::Int', 'Glib::String', 'Glib::String'); What is the best way to get all of the rows in the store? At the moment I am trying something like below to try to get all of the second column's values: while ( $list_store->iter_next($iter) ) { push( @existing_classfns, $list_store->get($iter, 1) ); $iter = $list_store->iter_next($iter); } But @existing_classfns is always empty. Many thanks, Peter. _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Get all rows in Gtk2::ListStorePeter E Dennis <peter.edwin.dennis@...> writes:
> > get all of the second column's values: I made a column_contents() in my Gtk2::Ex::TreeModelBits based on $model->foreach per below. A loop with your own iters ought to work equally well. > while ( $list_store->iter_next($iter) ) Is that the right loop condition? It doesn't miss the last row does it? sub column_contents { my ($model, $column) = @_; my @ret; # pre-extend, helpful for a list model style, likely to do little for an # actual tree $#ret = $model->iter_n_children(undef) - 1; my $pos = 0; $model->foreach (sub { my ($model, $path, $iter) = @_; $ret[$pos++] = $model->get_value ($iter, $column); return 0; # keep walking }); $#ret = $pos-1; return @ret; } _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Get all rows in Gtk2::ListStore2009/8/18 Kevin Ryde <user42@...>:
> Peter E Dennis <peter.edwin.dennis@...> writes: >> >> get all of the second column's values: > > I made a column_contents() in my Gtk2::Ex::TreeModelBits based on > $model->foreach per below. A loop with your own iters ought to work > equally well. > >> while ( $list_store->iter_next($iter) ) > > Is that the right loop condition? It doesn't miss the last row does it? Probably not. I really had no idea what I was doing. > sub column_contents { > my ($model, $column) = @_; > my @ret; > > # pre-extend, helpful for a list model style, likely to do little for an > # actual tree > $#ret = $model->iter_n_children(undef) - 1; > > my $pos = 0; > $model->foreach (sub { > my ($model, $path, $iter) = @_; > $ret[$pos++] = $model->get_value ($iter, $column); > return 0; # keep walking > }); > $#ret = $pos-1; > return @ret; > } > Thank you very much for providing an example. I will give it a go at applying it my own program. _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
| Free embeddable forum powered by Nabble | Forum Help |