Re: copying GtkTreeStore?
- From: "David M. Cook" <dave davidcook org>
- To: gtk-app-devel-list gnome org
- Subject: Re: copying GtkTreeStore?
- Date: Wed, 11 Feb 2004 15:57:09 -0800
On Wed, Feb 11, 2004 at 03:15:51PM -0800, Shark wrote:
Does anyone know if there is a function in the GTK+ API which will
create a copy of a GtkTreeStore (including its data, such as column
types and row data)?
Not that I'm aware of, but it shouldn't be hard to do. Thinking in Python
(untested code!):
def appendrow(model, path, iter, copy, column_numbers):
parent_path = path[:-1]
if parent_path:
parent_iter = copy.get_iter(parent_path)
else:
parent_iter = None
newiter = copy.append(parent_iter)
for i in column_numbers:
copy.set_value(newiter, i, model.get_value(iter, i))
def copymodel(model):
column_types = []
column_numbers = range(model.get_n_columns())
for i in column_numbers:
column_types.append(model.get_column_type(i))
copy = gtk.TreeStore(*column_types)
model.foreach(appendrow, copy, column_numbers)
return copy
Dave Cook
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]