Re: gtk_list_store_set issues.
- From: dE <de techno gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: gtk_list_store_set issues.
- Date: Sat, 01 Jun 2013 21:28:44 +0530
On 06/01/13 21:17, Arnel A. Borja wrote:
On Saturday, 01 June, 2013 11:33 PM, dE wrote:
On 06/01/13 20:38, Arnel A. Borja wrote:
On Saturday, 01 June, 2013 10:49 PM, dE wrote:
Hi,
Hello everyone!
This is my first time serious programming in C, and I'm using GTK
for this.
In a ListStore, I'm trying to add data to it via --
gtk_list_store_set ( list, ¤t, 0, "test00", 1, "test01", -1 );
However, in both the columns I get test00 instead.
Do you mean GtkTreeViewColumn when you said "columns"? Make sure
that you set attributes properly (one way of doing that is using
gtk_tree_view_insert_column_with_attributes). Maybe you could post
your code here (especially the part where the tree view is created).
Yes, I meant GtkTreeViewColumn.
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GtkTreeViewColumn **test_col = g_malloc (sizeof
(GtkTreeViewColumn *) * 2);
test_col [0] = gtk_tree_view_column_new_with_attributes (
"test0", renderer, "text", 0, NULL );
test_col [1] = gtk_tree_view_column_new_with_attributes (
"test1", renderer, "text", 0, NULL );
Here, you're setting the text attributes to the same column of the
list store. It should be:
test_col [0] = gtk_tree_view_column_new_with_attributes ( "test0",
renderer, "text", 0, NULL );
test_col [1] = gtk_tree_view_column_new_with_attributes ( "test1",
renderer, "text", 1, NULL );
so that the first column of the GtkTreeView will show the text from
the first column of the GtkListStore, and the second column of the
GtkTreeView will show the text from the second column of the
GtkListStore.
gtk_tree_view_append_column ( target, test_col[0] );
gtk_tree_view_append_column ( target, test_col[1] );
GType string_type = G_TYPE_STRING;
GtkTreeIter current;
GType *types = g_malloc (sizeof (GType) * 2);
types [0] = G_TYPE_STRING;
types [1] = G_TYPE_STRING;
GtkListStore *list = gtk_list_store_newv (2, types);
gtk_list_store_append ( list, ¤t );
gtk_list_store_set ( list, ¤t, 0, "test00", -1 );
gtk_list_store_set ( list, ¤t, 1, "test01", -1 );
gtk_list_store_append ( list, ¤t );
gtk_list_store_set ( list, ¤t, 0, "test10", -1 );
gtk_list_store_set ( list, ¤t, 1, "test11", -1 );
gtk_tree_view_set_model ( GTK_TREE_VIEW ( target ) ,
GTK_TREE_MODEL ( list )) ;
I made the GUI in Glade.
gtk_list_store_set ( list, ¤t, 0, "test00", -1 ); was
previously gtk_list_store_set ( list, ¤t, 0, "test00", 1,
"test01", -1 ); and gtk_list_store_set ( list, ¤t, 1, "test01",
-1 ); didn't exist.
Thank you! I didn't understand what that argument did.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]