Gtk2::T...election(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– 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 as iter_is_selected but 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 to undef.
  • $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 $func on 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_selected returns 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 the Gtk2::TreePath of 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 of select_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:

  • Gtk2
  • Glib::Object

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