RE: Gtk2::TreeModel - foreach
- From: Jeff Hallock <Jhallock WBandA com>
- To: Zettai Muri <zettaimuri ymail com>, Martin Schlemmer <Martin Schlemmer nwu ac za>, "gtk-perl-list gnome org" <gtk-perl-list gnome org>
- Subject: RE: Gtk2::TreeModel - foreach
- Date: Thu, 19 Nov 2009 16:15:24 -0500
-----Original Message-----
From: gtk-perl-list-bounces gnome org [mailto:gtk-perl-list-bounces gnome org] On Behalf Of Zettai Muri
Sent: Thursday, November 19, 2009 3:56 PM
To: Martin Schlemmer; gtk-perl-list gnome org
Subject: Re: Gtk2::TreeModel - foreach
Not exactly sure what you want, but attached is an example for a
Gtk2::ListStore's foreach.
Where does the $user_data (scalar) part of the method come into play?
Is it possible to get an extended example that shows how this is used?
$model->foreach(
sub {
my($model,$path,$iter) = @_;
my($item) = $model->get($iter, 0);
print "$item\n";
# return TRUE to end
return FALSE;
}, $user_data <----------------------- ???
);
Is this data within the ListStore or some other data passed to the method? How does the method act on this
data?
Again thanks for the help.
If you supply $user_data - then you it will be passed in as the last argument to the ForEach function.
$model->foreach(
sub {
my($model,$path,$iter,$user_data <-------------) = @_;
my($item) = $model->get($iter, 0);
print "$item\n";
# return TRUE to end
return FALSE;
}, $user_data <----------------------- ???
);
Here is an example that searches for a name in model:
sub search {
my($model,$path,$iter,$search_string) = @_;
my($item) = $model->get($iter, 0);
if ($item =~ /$search_string/) {
print "FOUND\n";
return TRUE;
}
else {
return FALSE;
}
}
$model->foreach(\&search, 'Bob');
$model->foreach(\&search, 'Billy');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]