Re: gtk_list_store_set issues.



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, &current, 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 );
    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, &current );
    gtk_list_store_set ( list, &current, 0, "test00", -1 );
    gtk_list_store_set ( list, &current, 1, "test01", -1 );
    gtk_list_store_append ( list, &current );
    gtk_list_store_set ( list, &current, 0, "test10", -1 );
    gtk_list_store_set ( list, &current, 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, &current, 0, "test00", -1 ); was previously gtk_list_store_set ( list, &current, 0, "test00", 1, "test01", -1 ); and gtk_list_store_set ( list, &current, 1, "test01", -1 ); didn't exist.

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