Gtk2::Ex::TreeViewBits - various helpers for Gtk2::TreeView
use Gtk2::Ex::TreeViewBits;
Gtk2::Ex::TreeViewBits::toggle_expand_row ($treeview, $path)
Toggle the row at $path between expanded or collapsed. $path is a Gtk2::TreePath.
$path
Gtk2::TreePath
This is a simple combination of check row_expanded then either expand_row or collapse_row. It's handy for making a toggle in the style of the Space key (toggle-cursor-row), but say on a button press rather than the cursor row.
row_expanded
expand_row
collapse_row
toggle-cursor-row
See examples/treeview-toggle-expand.pl in the Gtk2-Ex-WidgetBits sources for a complete program using this under a row-activate signal.
row-activate
Gtk2::Ex::TreeViewBits::remove_selected_rows ($treeview)
Remove the currently selected rows of $treeview from the underlying TreeModel. If nothing is selected then do nothing.
$treeview
Rows are removed using $model->remove() as per Gtk2::ListStore or Gtk2::TreeStore. The model doesn't have to be a ListStore or TreeStore, only something with a compatible remove() method.
$model->remove()
Gtk2::ListStore
Gtk2::TreeStore
remove()
Currently this is implemented by tracking rows to be removed using a Gtk2::TreeRowReference on each and removing them one by one. This isn't fast, but is safe against additional changes to the model or the selection during the removals.
Gtk2::TreeRowReference
Gtk2::Ex::TreeViewBits::scroll_cursor_to_path ($treeview, $path)
Move the TreeView cursor to $path, expanding and scrolling if necessary to ensure the row is then visible.
This function is a combination of expand_row(), set_cursor() and scroll_to_cell(), except the scroll is skipped if $path is already fully visible. Avoiding a scroll is good because it avoids content jumping around when merely moving to different nearby rows.
expand_row()
set_cursor()
scroll_to_cell()
When a scroll is done the row is centred in the $treeview window. If the row is bigger than the window then it's positioned at the start of the window.
As of Gtk 2.12.12, if a TreeView is in fixed-height-mode and the last row is unexpanded then a scroll_cursor_to_path() to a sub-row of it doesn't scroll correctly. It expands, moves the cursor, but the scroll goes only to that last parent row, not the intended sub-row. Believe this is a bug in Gtk.
fixed-height-mode
scroll_cursor_to_path()
Gtk2::TreeView, Gtk2::Ex::WidgetBits
Gtk2::TreeView
Gtk2::Ex::WidgetBits
http://user42.tuxfamily.org/gtk2-ex-widgetbits/index.html
Copyright 2007, 2008, 2009, 2010, 2011, 2012 Kevin Ryde
Gtk2-Ex-WidgetBits 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-WidgetBits 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-WidgetBits. If not, see http://www.gnu.org/licenses/.
To install Gtk2::Ex::WidgetBits, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Ex::WidgetBits
CPAN shell
perl -MCPAN -e shell install Gtk2::Ex::WidgetBits
For more information on module installation, please visit the detailed CPAN module installation guide.