Re: Working With Trees
- From: Owen Taylor <otaylor redhat com>
- To: Charles Tassell <ctassell isn net>
- Cc: gtk-list gnome org
- Subject: Re: Working With Trees
- Date: 23 May 2003 11:26:15 -0400
On Mon, 2003-05-19 at 04:27, Charles Tassell wrote:
> I'm using Glade 2.0 and GTK 2.something to try and write a very simple
> file manager, and I can't get the GtkTreeView object to work at all.
> I've looked around, and there doesn't seem to be any docs in regards to
> this widget, other than the API, and the examples in the API are garbage
> (my apologies to their authors): most of them are referencing variables
> that they don't even define.
>
> What I am trying to do at the moment is add an item to the GtkTreeStore,
> but it doesn't seem to want to go. I'm not getting any warnings on the
> console about bad types or non-existant objects, or anything else for
> that matter, but gtk_tree_model_get just returns garbage. The code is
> below.
For gtk_tree_model_get() returning garbage-you need to use it
as shown in the example in:
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html
gchar *str_data;
gint int_data;
/* Make sure you terminate calls to gtk_tree_model_get()
* with a '-1' value
*/
gtk_tree_model_get (list_store, &iter,
STRING_COLUMN, &str_data,
INT_COLUMN, &int_data,
-1);
/* Do something with the data */
g_print ("Row %d: (%s,%d)\n", row_count, str_data, int_data);
g_free (str_data);
What you have with char Test[100] just isn't the same thing at
all; its the difference between a malloc()'ed string and an array.
Why your GtkTreeView isn't working ... hard to say. It's often useful
to make examples posted here complete and standalone (sort of like
what you were complaining about in the API docs :-) ... from
gtk_init() on. Often the problem can be something that you aren't
thinking about and didn't quote.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]