[gtkmm] TreeView/TreeModel navigation
- From: 3rdShift <vladg erols com>
- To: Gtkmm List <gtkmm-list gnome org>
- Subject: [gtkmm] TreeView/TreeModel navigation
- Date: 28 Nov 2002 23:17:35 -0500
Hi,
I am re-reading TreeView/TreeModel reference, docmentation and demo
examples again and again and can't seem to find a way to navigate
through ListStore. With CList I used to get a row number when user
selects the row.
1) How do I get the selected row number?
In the selection callback I can get to the row, but how far is
that row from the begin()?
Glib::RefPtr<Gtk::TreeSelection> m_tree_sel_ref;
Glib::RefPtr<Gtk::ListStore> m_list_store_ref;
Gtk::TreeModel::iterator iter = m_tree_sel_ref->get_selected ();
Gtk::TreeModel::Row row = *iter;
I tried to subtract iterators just like you can do in STL, but
all I get is 0!
int row_num = iter - m_list_store_ref->children ().begin ()
2) How can I select the previous row?
Gtk::TreeIter is a one-directional forward iterator.
Any hints?
3) How can I know if the TreeIter points to the last row
in ListStore?
I have an iterator to the currently selected row. I cannot say
if (iter + 1 != m_list_store_ref->children ().begin ()) {
m_tree_sel_ref->select (++iter);
}
because TreeIter does not support operator+(int).
However, if I increment the iterator and hit the end of the list,
I get gtk-CRITICAL assertion:
TreeView-Test:27034): Gtk-CRITICAL **: file gtkliststore.c: line 518
(gtk_list_store_get_path): assertion `iter->stamp == GTK_LIST_STORE
(tree_model)->stamp' failed
CList has this functionality right out of the box.
The examples I have looked into so far are: crossovertreeview (by Daniel
Sundberg), example_treeview_liststore, and example_stockbrowser from the
demo directory.
My application <http://gwavmerger.sourceforge.net/> has a navigation bar
with four buttons: up, down, left, right (see Main Window snapshot).
A user can select any row in the CList and then move up and down
by simply clicking on appropriate buttons (or using arrow keys) which
makes it very convenient.
Any hints are greatly appreciated.
-Vlad
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]