Re: where's GtkTreeM/V/C tutorial? (how create GtkTreeIter?)

On Sun, Mar 03, 2002 at 01:52:44AM +0900, Kang Jeong-Hee wrote:
> I missed a word to describe my say explicitly: "returns primarily"
> on greping on /usr/include/gtk-2.0/gtk/* with "^GtkTreeIter",
> there's only two functions copy and free. where's new?
> or other way to new?

(My experience is limited to the text widget and may not apply here,
but it looks like it does.)

Iterators are simple structure, so they can be copied manually:

	GtkTreeIter i1, i2;
	/* initialize i1 somehow */
	i2 = i2;

The docs for the gtk_tree_iter_copy() function note that it isn't very

	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 (GtkTreeIter new_iter =
	iter;). You must free this iter with gtk_tree_iter_free().

To actually *get* an iterator, you provide your own to one of the tree
functions.  Here I "allocate" one on the stack:

	GtkTreeIter iter;
	gtk_tree_mode_get_iter(model, &iter, path);

This will fill out iter with the given path.

So you don't need a _new() function.  It confused me for a bit, too--
they don't behave like other GTK objects.

      Evan Martin
martine cs washington edu

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