Commit c97d57eb authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

added more fields to allow more interesting iterators. Also, made the

Thu Nov  9 11:23:22 2000  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
	allow more interesting iterators.  Also, made the lifecycle of
	iterators more explicit.

	* gtk/gtktreemodelsort.[ch]: New model for sorting.

	* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
	types.
parent 8898529c
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
Thu Nov 9 11:23:22 2000 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodel.h (struct _GtkTreeIter): added more fields to
allow more interesting iterators. Also, made the lifecycle of
iterators more explicit.
* gtk/gtktreemodelsort.[ch]: New model for sorting.
* gtk/gtk-boxed.defs (GtkTreeIter, GtkTreePath): Added two boxed
types.
2000-11-09 Alexander Larsson <alexl@redhat.com>
* demos/testgtk/menus.c:
......
......@@ -242,7 +242,7 @@ selection_cb (GtkTreeSelection *selection,
GtkTreeIter iter;
GValue value = {0, };
if (! gtk_tree_selection_get_selected (selection, &iter))
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
return;
gtk_tree_model_get_value (model, &iter,
......
......@@ -242,7 +242,7 @@ selection_cb (GtkTreeSelection *selection,
GtkTreeIter iter;
GValue value = {0, };
if (! gtk_tree_selection_get_selected (selection, &iter))
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
return;
gtk_tree_model_get_value (model, &iter,
......
......@@ -171,6 +171,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtktree.h \
gtktreeitem.h \
gtktreemodel.h \
gtktreemodelsort.h \
gtktreeselection.h \
gtktreestore.h \
gtktreeview.h \
......@@ -329,6 +330,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtktreeitem.c \
gtktreedatalist.c \
gtktreemodel.c \
gtktreemodelsort.c \
gtktreeselection.c \
gtktreestore.c \
gtktreeview.c \
......
......@@ -1286,6 +1286,15 @@
gtk_text_iter_copy
gtk_text_iter_free)
;; TreeView
(define-boxed GtkTreeIter
gtk_tree_iter_copy
gtk_tree_iter_free)
(define-boxed GtkTreePath
gtk_tree_path_copy
gtk_tree_path_free)
;; Alignment
(define-object GtkAlignment (GtkBin))
......
......@@ -141,6 +141,7 @@
#include <gtk/gtktree.h>
#include <gtk/gtktreeitem.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreemodelsort.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtktreestore.h>
#include <gtk/gtktreeview.h>
......
......@@ -38,6 +38,7 @@ static guint list_store_signals[LAST_SIGNAL] = { 0 };
static void gtk_list_store_init (GtkListStore *list_store);
static void gtk_list_store_class_init (GtkListStoreClass *class);
static void gtk_list_store_tree_model_init (GtkTreeModelIface *iface);
static guint gtk_list_store_get_flags (GtkTreeModel *tree_model);
static gint gtk_list_store_get_n_columns (GtkTreeModel *tree_model);
static gboolean gtk_list_store_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
......@@ -152,6 +153,7 @@ gtk_list_store_class_init (GtkListStoreClass *class)
static void
gtk_list_store_tree_model_init (GtkTreeModelIface *iface)
{
iface->get_flags = gtk_list_store_get_flags;
iface->get_n_columns = gtk_list_store_get_n_columns;
iface->get_iter = gtk_list_store_get_iter;
iface->get_path = gtk_list_store_get_path;
......@@ -168,7 +170,7 @@ static void
gtk_list_store_init (GtkListStore *list_store)
{
list_store->root = NULL;
list_store->stamp = 1;
list_store->stamp = g_random_int ();
}
GtkListStore *
......@@ -242,6 +244,14 @@ gtk_list_store_set_column_type (GtkListStore *list_store,
}
/* Fulfill the GtkTreeModel requirements */
static guint
gtk_list_store_get_flags (GtkTreeModel *tree_model)
{
g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), 0);
return GTK_TREE_MODEL_ITERS_PERSIST;
}
static gint
gtk_list_store_get_n_columns (GtkTreeModel *tree_model)
{
......@@ -350,6 +360,9 @@ static gint
gtk_list_store_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
if (iter == NULL)
return g_slist_length (G_SLIST (GTK_LIST_STORE (tree_model)->root));
return 0;
}
......
......@@ -260,7 +260,7 @@ gtk_tree_path_free (GtkTreePath *path)
* gtk_tree_path_copy:
* @path: A #GtkTreePath.
*
* Creates a new #GtkTreePath based upon @path.
* Creates a new #GtkTreePath as a copy of @path.
*
* Return value: A new #GtkTreePath.
**/
......@@ -381,6 +381,69 @@ gtk_tree_path_down (GtkTreePath *path)
gtk_tree_path_append_index (path, 0);
}
/**
* gtk_tree_iter_copy:
* @iter: A #GtkTreeIter.
*
* Creates a dynamically allocated tree iterator as a copy of @iter. This
* function is not intended for use in applications, because you can just copy
* the structs by value (<literal>GtkTreeIter new_iter = iter;</literal>). You
* must free this iter with gtk_tree_iter_free ().
*
* Return value: a newly allocated copy of @iter.
**/
GtkTreeIter *
gtk_tree_iter_copy (GtkTreeIter *iter)
{
GtkTreeIter *retval;
g_return_val_if_fail (iter != NULL, NULL);
retval = g_new (GtkTreeIter, 1);
*retval = *iter;
return retval;
}
/**
* gtk_tree_iter_free:
* @iter: A dynamically allocated tree iterator.
*
* Free an iterator that has been allocated on the heap. This function is
* mainly used for language bindings.
**/
void
gtk_tree_iter_free (GtkTreeIter *iter)
{
g_return_if_fail (iter != NULL);
g_free (iter);
}
/**
* gtk_tree_model_get_flags:
* @tree_model: A #GtkTreeModel.
*
* Returns a list of flags supported by this interface. The flags are a bitwise
* combination of #GtkTreeModelFlags. It is expected that the flags supported
* do not change for an interface.
*
* Return value: The flags supported by this interface.
**/
guint
gtk_tree_model_get_flags (GtkTreeModel *tree_model)
{
g_return_val_if_fail (tree_model != NULL, 0);
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), 0);
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_flags)
return (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_flags) (tree_model);
return 0;
}
/**
* gtk_tree_model_get_n_columns:
* @tree_model: A #GtkTreeModel.
......@@ -399,6 +462,27 @@ gtk_tree_model_get_n_columns (GtkTreeModel *tree_model)
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_n_columns) (tree_model);
}
/**
* gtk_tree_model_get_column_type:
* @tree_model: A #GtkTreeModel.
* @index: The column index.
*
* Returns the type of the column.
*
* Return value: The type of the column.
**/
GType
gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
gint index)
{
g_return_val_if_fail (tree_model != NULL, G_TYPE_INVALID);
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), G_TYPE_INVALID);
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_column_type != NULL, G_TYPE_INVALID);
g_return_val_if_fail (index >= 0, G_TYPE_INVALID);
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_column_type) (tree_model, index);
}
/**
* gtk_tree_model_get_iter:
* @tree_model: A #GtkTreeModel.
......@@ -564,9 +648,10 @@ gtk_tree_model_iter_has_child (GtkTreeModel *tree_model,
/**
* gtk_tree_model_iter_n_children:
* @tree_model: A #GtkTreeModel.
* @iter: The #GtkTreeIter.
* @iter: The #GtkTreeIter, or NULL.
*
* Returns the number of children that @iter has.
* Returns the number of children that @iter has. If @iter is NULL, then the
* number of toplevel nodes is returned.
*
* Return value: The number of children of @iter.
**/
......@@ -576,7 +661,6 @@ gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
{
g_return_val_if_fail (tree_model != NULL, 0);
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), 0);
g_return_val_if_fail (iter != NULL, 0);
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_n_children != NULL, 0);
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_n_children) (tree_model, iter);
......@@ -589,10 +673,11 @@ gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
* @parent: The #GtkTreeIter to get the child from, or NULL.
* @n: Then index of the desired child.
*
* Sets @iter to be the child of @parent, using the given index. The first index
* is 0. If the index is too big, or @parent has no children, @iter is set to an
* invalid iterator and FALSE is returned. @parent will remain a valid node after
* this function has been called. If @parent is NULL, then the root node is assumed.
* Sets @iter to be the child of @parent, using the given index. The first
* index is 0. If the index is too big, or @parent has no children, @iter is
* set to an invalid iterator and FALSE is returned. @parent will remain a
* valid node after this function has been called. If @parent is NULL, then the
* root node is assumed.
*
* Return value: TRUE, if @parent has an nth child.
**/
......@@ -629,8 +714,51 @@ gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child)
{
g_return_val_if_fail (tree_model != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (child != NULL, FALSE);
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_parent != NULL, FALSE);
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_parent) (tree_model, iter, child);
}
/**
* gtk_tree_model_ref_iter:
* @tree_model: A #GtkTreeModel.
* @iter: The #GtkTreeIter.
*
* Ref's the iter. This is an optional method for models to implement. To be
* more specific, models may ignore this call as it exists primarily for
* performance reasons.
**/
void
gtk_tree_model_ref_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
g_return_if_fail (tree_model != NULL);
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->ref_iter)
(* GTK_TREE_MODEL_GET_IFACE (tree_model)->ref_iter) (tree_model, iter);
}
/**
* gtk_tree_model_unref_iter:
* @tree_model: A #GtkTreeModel.
* @iter: The #GtkTreeIter.
*
* Unref's the iter. This is an optional method for models to implement. To be
* more specific, models may ignore this call as it exists primarily for
* performance reasons.
**/
void
gtk_tree_model_unref_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
g_return_if_fail (tree_model != NULL);
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->unref_iter)
(* GTK_TREE_MODEL_GET_IFACE (tree_model)->unref_iter) (tree_model, iter);
}
......@@ -37,10 +37,18 @@ typedef struct _GtkTreePath GtkTreePath;
typedef struct _GtkTreeModel GtkTreeModel; /* Dummy typedef */
typedef struct _GtkTreeModelIface GtkTreeModelIface;
typedef enum
{
GTK_TREE_MODEL_ITERS_PERSIST = 1 << 0
} GtkTreeModelFlags;
struct _GtkTreeIter
{
gint stamp;
gpointer tree_node;
gpointer tree_node2;
gpointer tree_node3;
};
struct _GtkTreeModelIface
......@@ -65,6 +73,7 @@ struct _GtkTreeModelIface
GtkTreePath *path);
/* VTable - not signals */
guint (* get_flags) (GtkTreeModel *tree_model);
gint (* get_n_columns) (GtkTreeModel *tree_model);
GType (* get_column_type) (GtkTreeModel *tree_model,
gint index);
......@@ -93,10 +102,14 @@ struct _GtkTreeModelIface
gboolean (* iter_parent) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
void (* ref_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void (* unref_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
};
/* Path operations */
/* GtkTreePath operations */
GtkTreePath *gtk_tree_path_new (void);
GtkTreePath *gtk_tree_path_new_from_string (gchar *path);
gchar *gtk_tree_path_to_string (GtkTreePath *path);
......@@ -117,9 +130,13 @@ gint gtk_tree_path_up (GtkTreePath *path);
void gtk_tree_path_down (GtkTreePath *path);
/* GtkTreeIter operations */
GtkTreeIter *gtk_tree_iter_copy (GtkTreeIter *iter);
void gtk_tree_iter_free (GtkTreeIter *iter);
/* GtkTreeModel stuff */
GtkType gtk_tree_model_get_type (void) G_GNUC_CONST;
guint gtk_tree_model_get_flags (GtkTreeModel *tree_model);
/* Column information */
gint gtk_tree_model_get_n_columns (GtkTreeModel *tree_model);
......@@ -153,7 +170,10 @@ gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
void gtk_tree_model_ref_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void gtk_tree_model_unref_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter);
#ifdef __cplusplus
}
......
This diff is collapsed.
/* gtktreemodelsort.h
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_TREE_MODEL_SORT_H__
#define __GTK_TREE_MODEL_SORT_H__
#include <gtk/gtktreemodel.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GTK_TYPE_TREE_MODEL_SORT (gtk_tree_model_sort_get_type ())
#define GTK_TREE_MODEL_SORT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_MODEL_SORT, GtkTreeModelSort))
#define GTK_TREE_MODEL_SORT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_MODEL_SORT, GtkTreeModelSortClass))
#define GTK_IS_TREE_MODEL_SORT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TREE_MODEL_SORT))
#define GTK_IS_TREE_MODEL_SORT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_MODEL_SORT))
typedef struct _GtkTreeModelSort GtkTreeModelSort;
typedef struct _GtkTreeModelSortClass GtkTreeModelSortClass;
typedef gint (* GValueCompareFunc) (const GValue *a,
const GValue *b);
struct _GtkTreeModelSort
{
GtkObject parent;
/* < private > */
gpointer root;
gint stamp;
guint flags;
GtkTreeModel *model;
gint sort_col;
GValueCompareFunc *func;
};
struct _GtkTreeModelSortClass
{
GtkObjectClass parent_class;
/* signals */
/* Will be moved into the GtkTreeModelIface eventually */
void (* changed) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* inserted) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* child_toggled) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* deleted) (GtkTreeModel *tree_model,
GtkTreePath *path);
};
GtkType gtk_tree_model_sort_get_type (void);
GtkTreeModel *gtk_tree_model_sort_new (void);
GtkTreeModel *gtk_tree_model_sort_new_with_model (GtkTreeModel *model,
GValueCompareFunc *func,
gint sort_col);
void gtk_tree_model_sort_set_model (GtkTreeModelSort *tree_model_sort,
GtkTreeModel *model);
void gtk_tree_model_sort_set_sort_col (GtkTreeModelSort *tree_model_sort,
gint sort_col);
void gtk_tree_model_sort_set_compare (GtkTreeModelSort *tree_model_sort,
GValueCompareFunc *func);
void gtk_tree_model_sort_resort (GtkTreeModelSort *tree_model_sort);
GtkTreePath *gtk_tree_model_sort_convert_path (GtkTreeModelSort *tree_model_sort,
GtkTreePath *path);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_TREE_MODEL_SORT_H__ */
......@@ -241,17 +241,20 @@ gtk_tree_selection_get_user_data (GtkTreeSelection *selection)
/**
* gtk_tree_selection_get_selected:
* @selection: A #GtkTreeSelection.
* @model: A pointer set to the #GtkTreeModel, or NULL.
* @iter: The #GtkTreeIter, or NULL.
*
* Sets @iter to the currently selected node if @selection is set to
* #GTK_TREE_SELECTION_SINGLE. Otherwise, it uses the anchor. @iter may be
* NULL if you just want to test if @selection has any selected nodes.
* NULL if you just want to test if @selection has any selected nodes. @model
* is filled with the current model as a convenience.
*
* Return value: TRUE, if there is a selected node.
**/
gboolean
gtk_tree_selection_get_selected (GtkTreeSelection *selection,
GtkTreeIter *iter)
gtk_tree_selection_get_selected (GtkTreeSelection *selection,
GtkTreeModel **model,
GtkTreeIter *iter)
{
GtkRBTree *tree;
GtkRBNode *node;
......@@ -274,9 +277,11 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection,
! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
/* We don't want to return the anchor if it isn't actually selected.
*/
return FALSE;
if (model)
*model = selection->tree_view->priv->model;
return gtk_tree_model_get_iter (selection->tree_view->priv->model,
iter,
selection->tree_view->priv->anchor);
......
......@@ -79,6 +79,7 @@ gpointer gtk_tree_selection_get_user_data (GtkTreeSelection
/* Only meaningful if GTK_TREE_SELECTION_SINGLE is set */
/* Use selected_foreach for GTK_TREE_SELECTION_MULTI */
gboolean gtk_tree_selection_get_selected (GtkTreeSelection *selection,
GtkTreeModel **model,
GtkTreeIter *iter);
/* FIXME: Get a more convenient get_selection function???? one returning GSList?? */
......
......@@ -40,6 +40,7 @@ static guint tree_store_signals[LAST_SIGNAL] = { 0 };
static void gtk_tree_store_init (GtkTreeStore *tree_store);
static void gtk_tree_store_class_init (GtkTreeStoreClass *tree_store_class);
static void gtk_tree_store_tree_model_init (GtkTreeModelIface *iface);
static guint gtk_tree_store_get_flags (GtkTreeModel *tree_model);
static gint gtk_tree_store_get_n_columns (GtkTreeModel *tree_model);
static GtkTreePath *gtk_tree_store_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter);
......@@ -58,11 +59,11 @@ static gint gtk_tree_store_iter_n_children (GtkTreeModel *tree_mode
GtkTreeIter *iter);
static gboolean gtk_tree_store_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child,
GtkTreeIter *parent,
gint n);
static gboolean gtk_tree_store_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
GtkTreeIter *child);
GtkType
......@@ -150,6 +151,7 @@ gtk_tree_store_class_init (GtkTreeStoreClass *tree_store_class)
static void
gtk_tree_store_tree_model_init (GtkTreeModelIface *iface)
{
iface->get_flags = gtk_tree_store_get_flags;
iface->get_n_columns = gtk_tree_store_get_n_columns;
iface->get_path = gtk_tree_store_get_path;
iface->get_value = gtk_tree_store_get_value;
......@@ -165,7 +167,7 @@ static void
gtk_tree_store_init (GtkTreeStore *tree_store)
{
tree_store->root = g_node_new (NULL);
tree_store->stamp = 1;
tree_store->stamp = g_random_int ();
}
GtkTreeStore *
......@@ -242,10 +244,19 @@ gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
* it is not visible to the tree or to the user., and the path "1" refers to the
* first child of GtkTreeStore::root.
*/
static guint
gtk_tree_store_get_flags (GtkTreeModel *tree_model)
{
g_return_val_if_fail (GTK_IS_TREE_STORE (tree_model), 0);
return GTK_TREE_MODEL_ITERS_PERSIST;
}
static gint
gtk_tree_store_get_n_columns (GtkTreeModel *tree_model)
{
g_return_val_if_fail (tree_model != NULL, 0);
g_return_val_if_fail (GTK_IS_TREE_STORE (tree_model), 0);
return GTK_TREE_STORE (tree_model)->n_columns;
......@@ -362,7 +373,10 @@ gtk_tree_store_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *parent)
{
iter->stamp = GTK_TREE_STORE (tree_model)->stamp;
iter->tree_node = G_NODE (parent->tree_node)->children;
if (parent)
iter->tree_node = G_NODE (parent->tree_node)->children;
else
iter->tree_node = G_NODE (GTK_TREE_STORE (tree_model)->root)->children;
return iter->tree_node != NULL;
}
......@@ -388,10 +402,13 @@ gtk_tree_store_iter_n_children (GtkTreeModel *tree_model,
g_return_val_if_fail (tree_model != NULL, 0);
g_return_val_if_fail (GTK_IS_TREE_STORE (tree_model), 0);
g_return_val_if_fail (iter != NULL, 0);
g_return_val_if_fail (iter->stamp == GTK_TREE_STORE (tree_model)->stamp, 0);
if (iter)
g_return_val_if_fail (iter->stamp == GTK_TREE_STORE (tree_model)->stamp, 0);
node = G_NODE (iter->tree_node)->children;
if (iter == NULL)
node = G_NODE (GTK_TREE_STORE (tree_model)->root)->children;
else
node = G_NODE (iter->tree_node)->children;
while (node)
{
i++;
......
......@@ -2037,6 +2037,8 @@ gtk_tree_view_inserted (GtkTreeModel *model,
}
}
/* ref the node */
gtk_tree_model_ref_iter (tree_view->priv->model, iter);
max_height = gtk_tree_view_insert_iter_height (tree_view,
tree,
iter,
......@@ -2245,6 +2247,8 @@ gtk_tree_view_build_tree (GtkTreeView *tree_view,
tree,
iter,
depth);
gtk_tree_model_ref_iter (tree_view->priv->model, iter);
temp = _gtk_rbtree_insert_after (tree, temp, max_height);
if (recurse)
{
......
......@@ -145,12 +145,12 @@ gtk_real_tree_column_clicked (GtkTreeViewColumn *tree_column)
*
* Return value: A newly created #GtkTreeViewColumn.
**/
GtkObject *
GtkTreeViewColumn *
gtk_tree_view_column_new (void)
{
GtkObject *retval;
GtkTreeViewColumn *retval;
retval = GTK_OBJECT (gtk_type_new (GTK_TYPE_TREE_COLUMN));
retval = GTK_TREE_VIEW_COLUMN (gtk_type_new (GTK_TYPE_TREE_COLUMN));
return retval;
}
......@@ -168,22 +168,21 @@ gtk_tree_view_column_new (void)
*
* Return value: A newly created #GtkTreeViewColumn.
**/
GtkObject *
GtkTreeViewColumn *
gtk_tree_view_column_new_with_attributes (gchar *title,
GtkCellRenderer *cell,
...)
{
GtkObject *retval;
GtkTreeViewColumn *retval;
va_list args;
retval = gtk_tree_view_column_new ();