Cell Renderer Combo Callback

I have a combo render in a treeview and I can't get the callback to set
the value once it's selected.  I want the combo to default to "Stock"
but be able to be changed to any of the other values in the itemtype
array.  Below is the way the item type combo is being created and added
to the tree view followed by the callback.  Does any one see the error?


  /* --- ItemType Treeview Column --- */
  renderer = gtk_cell_renderer_combo_new();

  /* Create the combo box */
  ls_combo=gtk_list_store_new(1, G_TYPE_STRING);
  for(ii=0; ii<9; ii++) {
    gtk_list_store_append (ls_combo, &iter);
    gtk_list_store_set (ls_combo, &iter, 0, itemtype[ii], -1);

  g_object_set(G_OBJECT(renderer), "model", ls_combo,
                                   "text-column", 0,
                                   "text", "Stock",
                                   "has-entry", FALSE,
                                   "editable", TRUE,
  g_signal_connect(renderer, "edited",
G_CALLBACK(itemTypeComboEditedCb), ls_combo);
  /* Create a Column */
  gtk_tree_view_column_set_title(column, "ItemType");
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  // gtk_tree_view_column_set_attributes(column, renderer, "text", ips,
  col_num=gtk_tree_view_insert_column(GTK_TREE_VIEW(tv), column, -1);
  /* FIELD is the column number not the index:  always one more than
index. */
  g_object_set_data(G_OBJECT(renderer), "FIELD",
  /* -------------- */

/* The callback */
void itemTypeComboEditedCb(GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list) {
  gboolean rc=FALSE;
  GtkTreeIter iter;
  GtkTreePath *tp=NULL;
  GtkTreeModel *tm=NULL; /* a tree model */
  gint col_num=0;
  col_num=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "FIELD"));

  gtk_tree_model_get_iter (GTK_TREE_MODEL(list), &iter, tp);
  gtk_list_store_set(list, &iter, 0, value, -1);  
  /* The following sets the whole column to the same value, not just the
row it was select in. */
  //g_object_set(G_OBJECT(cell), "text", value, NULL);

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