[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

tree scroll



I am trying to force a scroll to a row in a tree. I have a tree with about 20 items in of which only about 10 are visible. Scrolling with the mouse on the tree works fine. After a user presses a button, I am trying to scroll to the newest row added to the tree(which is not usually the last row). I would like to select the row and then scroll to it so that it is visble. I am trying to use the gtk_tree_view_scroll_to_cell function but nothing happens when I use it. Here is a code snippet of what I am doing. Is there something you need to call after you call the scroll_to_cell to repaint or revalidate the tree?

Note: iter was set to the newly added row. Selecting the row works fine here. It's just not viewable without scrolling.


			GtkTreePath* iterPath =
				gtk_tree_model_get_path(treeModel, &iter);
			gtk_tree_view_expand_to_path(treeView, iterPath);

			GtkTreeSelection* select = gtk_tree_view_get_selection (treeView);
			gtk_tree_selection_select_path(select, iterPath);

			GtkTreeViewColumn* column = gtk_tree_view_get_column(treeView, 0);
			gtk_tree_view_set_cursor(treeView, iterPath, column, 0);

			gtk_tree_view_scroll_to_cell(treeView,
						     iterPath,
						     NULL,
						     false, // do not use align
						     0, // row align is ignored
						     0); // col align is ignored
			gtk_tree_path_free(iterPath);


If anyone has any suggestions or sees something I am doing wrong, I'd greatly appreciate it.

Thanks!
Eric




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]