Gtk2::T...election(3)
π Gtk2::TreeSelection β the manual, but make it make sense π
okay bestie, so this is the Gtk2::TreeSelection page from the User Contributed Perl Documentation β it's the wrapper for GtkTreeSelection, aka the thing that keeps track of which rows in your tree are the chosen ones. π Basically every "ooh this row is highlighted" moment in a Gtk2::TreeView goes through here. It's giving backstage pass energy. π
β¨ NAME β¨
Gtk2::TreeSelection β wrapper for GtkTreeSelection, no cap. That's it, that's the name. π
πΈ HIERARCHY πΈ
the family tree (ironic, we love it) goes like this:
Glib::Object
+----Gtk2::TreeSelection
so yeah, it's a Glib::Object at heart, with all the object-y powers that implies. π¦
π METHODS π
okay here's the whole toolbox, one by one, no skipping, i promised. π«Ά
integer = $selection->count_selected_rowsβ literally counts how many rows are currently selected. a number. that's the vibe. π’boolean = $selection->iter_is_selected ($iter)β asks "is this specific iter selected or not?" and gives you a true/false back.$iter(Gtk2::TreeIter) β the iter you're interrogating, bestie. π΅οΈ
selectionmode = $selection->get_modeβ hands you back the current selection mode, so you know what kind of chaos you're allowed to cause. ποΈ$selection->set_mode ($type)β sets the selection mode. change the rules, change the game.$type(Gtk2::SelectionMode) β the mode you want, from the enum down below. β¬οΈ
boolean = $selection->path_is_selected ($path)β same energy asiter_is_selectedbut you're asking about a path instead.$path(Gtk2::TreePath) β the path in question. π€οΈ
$selection->select_allβ selects EVERYTHING. all of it. no survivors. main character move, honestly. π₯$selection->set_select_function ($func, $data=undef)β gives you a say in what's allowed to get selected, via a callback. (lowkey powerful)$func(scalar) β your callback.$data(scalar) β whatever data you wanna hand it. defaults toundef.
$selection->select_iter ($iter)β select that one iter, specifically. π―$iter(Gtk2::TreeIter)
$selection->select_path ($path)β select that one path, specifically. π€οΈ$path(Gtk2::TreePath)
$selection->select_range ($start_path, $end_path)β selects a whole range, from start to end. the "select a chunk" move.$start_path(Gtk2::TreePath)$end_path(Gtk2::TreePath)
$selection->selected_foreach ($func, $data=undef)β calls$funcon every selected row in$selection's view. every. single. one. π$func(subroutine)$data(scalar)
iter = $tree_selection->get_selected/(model, iter) = $tree_selection->get_selectedβ gets you the selected thing. here's the tea though: since most of the time you are only interested in the iter,get_selectedreturns only the iter in scalar context. π«‘ so if you want the model too, call it in list context. iykyk.@paths = $selection->get_selected_rowsβ returns theGtk2::TreePathof each selected row, or an empty list if no rows are selected. ngl the model is not returned, as documented in the C API reference. so if you want the model, try$selection->get_tree_view->get_model. πtreeview = $selection->get_tree_viewβ gives you back the tree view this selection belongs to. found the parent, bestie. π³$selection->unselect_allβ the opposite ofselect_all. clears the whole selection. release everyone. ποΈ$selection->unselect_iter ($iter)β deselects that one iter.$iter(Gtk2::TreeIter)
$selection->unselect_path ($path)β deselects that one path.$path(Gtk2::TreePath)
$selection->unselect_range ($start_path, $end_path)β deselects a whole range, start to end.$start_path(Gtk2::TreePath)$end_path(Gtk2::TreePath)- Since: gtk+ 2.2 β so this one's been around a minute. π°οΈ
scalar = $selection->get_user_dataβ hands you back your user data. yours, back in your hands. π«΄
π SIGNALS π
changed(Gtk2::TreeSelection) β fires when the selection changes. it's giving "notify the group chat" energy. π£
π ENUMS AND FLAGS π
enum Gtk2::SelectionMode
the menu of selection vibes, pick your fighter:
'none'/GTK_SELECTION_NONE'single'/GTK_SELECTION_SINGLE'browse'/GTK_SELECTION_BROWSE'multiple'/GTK_SELECTION_MULTIPLE'extended'/GTK_SELECTION_EXTENDED
π SEE ALSO π
go read these too, bestie:
Gtk2Glib::Object
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team. π«Ά
This software is licensed under the LGPL. See Gtk2 for a full notice. (yes, fr, go read the full notice, i'm not paraphrasing legal text π)
and that's the whole page, periodt. π β¨
cute little sign-off before you go: this gem of a page came from perl v5.42.0, dated 2025-07-25, and it lives in the manual as Gtk2::T...election(3). ππ¦π slay, go select some rows.
π¦ 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