Kevin Ryde > Gtk2-Ex-TiedListColumn-5 > Gtk2::Ex::TiedTreePath

Download:
Gtk2-Ex-TiedListColumn-5.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 5   Source  

NAME ^

Gtk2::Ex::TiedTreePath - tie an array to a Gtk2::TreePath

SYNOPSIS ^

 use Gtk2::Ex::TiedTreePath;
 my $path = Gtk2::Path->new;

 my @array;
 tie @array, 'Gtk2::Ex::TiedTreePath', $path;

 my $aref = Gtk2::Ex::TiedTreePath->new ($path);

DESCRIPTION ^

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.

Like most 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.

delete and exists

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 $path->up and exists on that element is then false, being beyond the available indices.

FUNCTIONS ^

tie @var, 'Gtk2::Ex::TiedTreePath', $path

Tie array variable @var to the given $path (a Gtk2::TreePath) so @var it 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 @array as such then the plain tie is easier. If you want an arrayref to pass around to other funcs then new saves a line of code.

Object Methods

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 Gtk2::TreePath object. Eg.

    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;

SEE ALSO ^

Gtk2::TreePath, Gtk2::Ex::TiedListColumn

HOME PAGE ^

http://user42.tuxfamily.org/gtk2-ex-tiedlistcolumn/

COPYRIGHT ^

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/.

syntax highlighting: