Re: reordering GtkListStore items
- From: "David M. Cook" <dave davidcook org>
- To: gtk-app-devel-list gnome org
- Subject: Re: reordering GtkListStore items
- Date: Fri, 19 Mar 2004 18:29:59 -0800
On Sat, Mar 20, 2004 at 01:03:08AM +0200, Paul Pogonyshev wrote:
Is there an easy way to swap a given list store item with
next/previous item? I'm facing two problems: there appear
to be no reordering functions in GTK+ 2.0 (all marked as
"since 2.2") and there is gtk_tree_model_iter_next(), but
no gtk_tree_mode_iter_previous().
In Python:
path = store.get_path(iter)
i = path[-1] # last index of path
parent = store.iter_parent(iter)
if i > 0:
previous = store.iter_nth_child(parent, i-1)
else:
previous = None
Or even simpler (though I don't know how to do the path aritmetic in C)
path = store.get_path(iter)
if path[-1] > 0:
previous = store.get_iter(path[:-1] + (path[-1]+1,))
else:
previous = None
Dave Cook
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]