Re: copying GtkTreeStore?

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)
        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:
    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]