moving rows in a TreeStore



Hi,

I have a simple a TreeStore that is setup to allow selections only at
the root level (i.e: some rows have children, but the children aren't
selectable). I am trying to implement a couple of buttons that will move
a selected row up or down one row in the TreeStore. Looking at the api I
have found the functions gtk_tree_store_move_after(),
gtk_tree_store_move_before(), and gtk_tree_store_swap(), but I can't get
them to work.

I have tried...

GtkTreeIter iter;
GtkTreeStore *store;

iter = <loop to retrieve row corresponding to current selection>
gtk_tree_store_move_after(store, &iter, &iter);

...and...

GtkTreeIter iter, next_iter;
GtkTreeStore *store;

iter = <loop to retrieve row corresponding to current selection>
next_iter = iter;
gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next_iter);
gtk_tree_store_move_after(store, &iter, &next_iter);

...and...

GtkTreeIter iter, next_iter;
GtkTreeStore *store;

iter = <loop to retrieve row corresponding to current selection>
next_iter = iter;
gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next_iter);
gtk_tree_store_swap(store, &iter, &next_iter);

In the first two cases, nothing happens. In the last case I get a little
error that says the two rows are not at the same level, but I don't know
how that can be the case.

Any suggestions?

-Chris




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