Gtk2::TreePath(3)
π Gtk2::TreePath π
okay bestie, sit down, hydrate, and let me tell you about Gtk2::TreePath β the wrapper for GtkTreePath from the gtk2-perl crew. this is your little β¨address bookβ¨ for nodes in a tree, and once it clicks you're gonna be obsessed. no cap.
π¦ HIERARCHY π¦
look at this lineage, it's giving noble bloodline:
Glib::Boxed
+----Gtk2::TreePath
β¨ METHODS β¨
πΈ treepath or undef = Gtk2::TreePath->new ($path=undef)
$path(string) β a string, bestie
makes a brand new path for you. and here's the cute lil shortcut: if you actually pass a $path, this is literally just an alias for new_from_string. same energy, less typing. π
π treepath = Gtk2::TreePath->new_first
gives you the path to the very first node. main character of the tree, first in line, periodt. π
π§ treepath or undef = Gtk2::TreePath->new_from_indices ($first_index, ...)
$first_index(integer) β a non-negative index value, gotta be β₯ 0...(list) β zero or more more index values, go off
builds a path out of a list of indices, one per level. now, the C API reference docs for this function say you should mark the end of the list with a -1 β but Perl doesn't need list terminators, so don't do that. we're not doing that here. skip it. π
and the tea: this one is specially implemented so it's available for all gtk+ versions. iconic behaviour honestly.
π treepath or undef = Gtk2::TreePath->new_from_string ($path=undef)
$path(string) β a string, again
makes a path out of a string. the classic.
π $path->append_index ($index_)
$index_(integer)
tacks an index onto the end of the path. append = end, bestie, remember it. π
π integer = $a->compare ($b)
$b(Gtk2::TreePath)
compares two paths, head to head. if $a appears before $b in the tree, you get -1. if $b appears before $a, you get 1. if the nodes are equal, you get 0. that's it, that's the whole vibe check. βοΈ
π integer = $path->get_depth
hands you the depth as an integer. how deep is this path? now you know. π³οΈ
π¦ $path->down
moves $path to point to the first child of the current path. going down a level, like descending into a group chat. π
β list = $path->get_indices
returns a list of integers describing the current indices of $path. it's giving receipts. π§Ύ
π
boolean = $path->is_ancestor ($descendant)
$descendant(Gtk2::TreePath)
is $path an ancestor of $descendant? yes or no, boo. π
πΈ boolean = $path->is_descendant ($ancestor)
$ancestor(Gtk2::TreePath)
the flip side β is $path a descendant of $ancestor? π«Ά
β¨ $path->next
moves $path to point to the next node at the current depth. no going up, no going down, just sideways. slay. πΆβοΈ
π $path->prepend_index ($index_)
$index_(integer)
slaps an index onto the front of the path. prepend = front. opposite of append. you got this. π
π₯ boolean = $path->prev
moves $path to point to the previous node at the current depth, if it exists. returns true if there actually is a previous node and $path got modified. if there's nothing before you, it's a no from the universe. π
π string = $path->to_string
turns the path into a string. for when you need it in text form, iykyk. π«
π§ boolean = $path->up
moves $path to point to its parent node. returns false if there's no parent β you can't go up from the top, bestie, that's just physics. π«
π SEE ALSO π
Gtk2Glib::Boxed
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
and that's the whole page, bestie! π this was Gtk2::TreePath(3) from the User Contributed Perl Documentation, brought to you by perl v5.42.0, dated 2025-07-25. mwah, go build something gorgeous with it. π
β¨π«Ά
π¦ where this page comes from
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms