NAME

Gtk2::Ex::TreeViewBits - various helpers for Gtk2::TreeView

SYNOPSIS

use Gtk2::Ex::TreeViewBits;

FUNCTIONS

Gtk2::Ex::TreeViewBits::toggle_expand_row ($treeview, $path)

Toggle the row at $path between expanded or collapsed. $path is a Gtk2::TreePath.

This is a simple combination of row_expanded then 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 and not necessarily the cursor row. See examples/treeview-toggle-expand.pl for doing it under row-activate.

Gtk2::Ex::TreeViewBits::remove_selected_rows ($treeview)

Remove the currently selected rows in $treeview from the underlying TreeModel. If nothing is selected then do nothing.

Rows are removed using $model->remove in the style of Gtk2::ListStore or Gtk2::TreeStore. The model doesn't have to be a ListStore or TreeStore, only something with a compatible remove method.

Currently this is implemented by tracking rows to be removed using a Gtk2::TreeRowReference each, and removing them one by one. This isn't fast, but is safe against additional changes to the model or selection during the removes.

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 basically 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 stops the contents jumping around when merely moving to different nearby rows.

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.

BUGS

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.

SEE ALSO

Gtk2::TreeView, Gtk2::Ex::WidgetBits

HOME PAGE

http://user42.tuxfamily.org/gtk2-ex-widgetbits/index.html

LICENSE

Copyright 2007, 2008, 2009, 2010, 2011 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/.