gtk_tree_store_set() repeats value



I'm getting my treeview objects out of a glade xml.  Everything works
fine until I call gtk_tree_store_set().  The application runs and there
arn't any errors.  However, the values don't get set, unless
gtk_tree_store_set() is called to set the second item in the treestore:
index 1.  Then all columns in the treeview get the same value and
although I'm only setting a single column the value is repeated accross
them all.  Any ideas what could be causing this?  The bulk of the code
is below.

As a side question, I'm a little confused about the "text" property in
gtk_tree_view_insert_column_with_attributes().  What is this the "text"
property to?  Neither a renderer or a column has a "text" property.  The
text renderer has the property but it should be a string not a boolean,
but a string doesn't work.

************** Message Break **************

Here's the code.


  /* This is from callback.c */
  void on_ipm1_activate(GtkMenuItem *menuitem, gpointer user_data) {
    GtkWidget *tv=NULL;  /* a tree view */
    GtkTreeIter iter;
    GtkTreeModel *tm=NULL; /* a tree model */

    xml=glade_xml_new(FILE_GLADE_XML0, "ipm1", NULL);
    glade_xml_signal_autoconnect(xml); // Connect the Signals

    tv=glade_xml_get_widget(xml, "ipms_tv");
    g_assert(tv);
    ipmsPriceStore0(tv);
    ipmsPriceView0(tv);
    tm=gtk_tree_view_get_model(tv));
    gtk_tree_store_prepend(GTK_TREE_STORE(tm), &iter, NULL);

    /* If using this All Columns will get AAA */
    gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, 1, "AAA", 2, "BBB",
-1);

    /* If using this All Columns will get AAA */
    gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, 1, "AAA", -1);

    /* If using this All Columns are empty */
    gtk_tree_store_set(GTK_TREE_STORE(tm), &iter, 2, "BBB", -1);
  }



  /* This is how ipmsPriceStore0() is defined */
  void ipmsItemStore0(GtkWidget *tv) {
    GtkTreeStore *ts=NULL;

    ts=gtk_tree_store_new(11,     /* Total number of columns */
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_STRING,
      G_TYPE_BOOLEAN
    );

    gtk_tree_view_set_model(GTK_TREE_VIEW(tv), GTK_TREE_MODEL(ts));
  }


  /* This is how ipmsPriceView0() is defined */
  void ipmsItemView0(GtkWidget *tv) {
    gint ii=0;
    GtkCellRenderer *renderer=NULL;
    GtkTreeViewColumn *column=NULL;
    gint col=0;  /* The column number */
    GtkTreeModel *tm=gtk_tree_view_get_model(GTK_TREE_VIEW(tv));

    /* First Column */
    col=gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tv),
    -1, "First Column",
    renderer,
    "text", TRUE,
    NULL);

    /* Second Column */
    col=gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tv),
    -1, "Second Column",
    renderer,
    "text", TRUE,
    NULL);

    /* Third Column */
    col=gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tv),
    -1, "Third Column",
    renderer,
    "text", TRUE,
    NULL);

    /* Forth Column */
    col=gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tv),
    -1, "Forth Column",
    renderer,
    "text", TRUE,
    NULL);

    /* Fifth column a Check box */
    renderer=gtk_cell_renderer_toggle_new();
    g_object_set(G_OBJECT(renderer), "activatable", TRUE, NULL);
    g_signal_connect(renderer, "toggled", G_CALLBACK(itemToggled), tv);

    /* Create a Column */
    column=gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column, "Disable");
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    col=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);

  }





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