Gtk2::Ex::TiedTreePath - tie an array to a Gtk2::TreePath
use Gtk2::Ex::TiedTreePath; my $path = Gtk2::Path->new; my @array; tie @array, 'Gtk2::Ex::TiedTreePath', $path; my $aref = Gtk2::Ex::TiedTreePath->new ($path);
TiedTreePath ties a Perl array to a
Gtk2::TreePath object so that reading and writing the array acts on the indices making up the path.
tie things, TiedTreePath is probably better in concept than actuality. Being able to store to individual elements is handy, as are Perl operations like push and pop, but a native
Gtk2::TreePath will suffice for most uses.
A TreePath has no notion of "exists" on an array element. If you
delete an element in the middle of the array then it's cleared to 0, but
exists is still true, unlike an ordinary perl array where
exists is false in that case. The tied
exists method simply checks whether the given index is within the number of indices in the path.
Deleting the endmost element of a TiedTreePath works the same as an ordinary array though. In this case the TreePath is shortened with
exists on that element is then false, being beyond the available indices.
tie @var, 'Gtk2::Ex::TiedTreePath', $path
Tie array variable
@varto the given
@varit accesses the path indices.
$arrayref = Gtk2::Ex::TiedTreePath->new ($path)
Return an arrayref which is tied to
$path. For example
my $aref = Gtk2::Ex::TiedTreePath->new ($path);
is the same as
tie (my @array, 'Gtk2::Ex::TiedTreePath', $path); my $aref = \@array;
If you want your own
@arrayas such then the plain
tieis easier. If you want an arrayref to pass around to other funcs then
newsaves a line of code.
The tie object associated with the array (as returned by the
tie or obtained later with
tied) has the following methods.
$path = $tobj->path
Return the underlying
my @array; tie @array, 'Gtk2::Ex::TiedTreePath', $path; ... my $tobj = tied(@array); print $tobj->path->to_string;
Or likewise through an arrayref
my $aref = Gtk2::Ex::TiedTreePath->new($path); ... my $path = tied(@$aref)->path;
Copyright 2010 Kevin Ryde
Gtk2-Ex-TiedListColumn is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Gtk2-Ex-TiedListColumn is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Gtk2-Ex-TiedListColumn. If not, see http://www.gnu.org/licenses/.