Gtk List Store Problem



Hi List

I'm trying to use the gtk_list_store_set() function, but get a strange
result. A little code:

void imaginary_func(){
  GtkWidget *tree_view;
  GtkListStore *model;
  GtkCellRenderer *cell;
  GtkTreeViewColumn *mid_column;
  GtkTreeViewColumn *title_column;
  GtkTreeViewColumn *mediasource_column;
  GtkTreeViewColumn *mediaformat_column;

  model = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING);
  tree_view = gtk_tree_view_new();
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
(scrolled_window), tree_view);
  gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view),
GTK_TREE_MODEL(model));

  cell = gtk_cell_renderer_text_new();
  mid_column = gtk_tree_view_column_new_with_attributes("Movie ID",
cell, "text", 0, NULL);
  title_column = gtk_tree_view_column_new_with_attributes("Title", cell,
"text", 0, NULL);
  mediasource_column = gtk_tree_view_column_new_with_attributes("Media
Source", cell, "text", 0, NULL);
  mediaformat_column = gtk_tree_view_column_new_with_attributes("Media
Format", cell, "text", 0, NULL);
                                                                              
 
gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(mid_column),20);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
GTK_TREE_VIEW_COLUMN(mid_column));
 
gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(title_column),450);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
GTK_TREE_VIEW_COLUMN(title_column));
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
GTK_TREE_VIEW_COLUMN(mediasource_column));
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view),
GTK_TREE_VIEW_COLUMN(mediaformat_column));

  /* Append to list */
  gtk_list_store_append(GTK_LIST_STORE (model), &iter);
  gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, "test1", 1,
"test2", 2, "test3", 3, "test4", -1);
}

When I run my app, the columns is filled with the test1 string in all
the columns. Can't really figure out why? Any ideas?

greetings
Jesper




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