Kevin Ryde > Gtk2-Ex-WidgetBits-48 > Gtk2::Ex::TreeViewBits

Download:
Gtk2-Ex-WidgetBits-48.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 48   Source  

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 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.

See examples/treeview-toggle-expand.pl in the Gtk2-Ex-WidgetBits sources for a complete program using this under a row-activate signal.

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.

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.

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::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.

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, 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/.

syntax highlighting: