gtk_cell_layout_set_cell_data_func()



Hi.

Can anyone clarify how to use this function?  I have a GtkComboBox
which displays strings + icons to show whether particular item
satisfies certain condition.  I don't want to store icons in tree
model, because there is more than one condition (3 at present).

So I created a GtkCellRendererPixbuf and attached a function which
determines whether the icon should be shown.  The function looks
like this:


static void
set_pixbuf_cell_image(GtkCellLayout *cell_layout, GtkCellRenderer *cell,
                      GtkTreeModel *tree_model, GtkTreeIter *iterator,
                      gpointer data)
{
  MyDataType *row_data;

  gtk_tree_model_get(tree_model, iterator, DATA_COLUMN, &row_data, -1);

  /* `data' keeps the condition number. */
  if (row_satisfies_condition(row_data, GPOINTER_TO_INT(data)))
    g_object_set(cell, "stock-id", GTK_STOCK_YES, NULL);
  else
    g_object_set(cell, "stock-id", NULL, NULL);
}


I'm not sure whether g_object_set() is the right thing to use.  The
above function basically works, but when I switch condition, problems
begin.  Icons can disappear alltogether or can be shown when the
combo box'es menu is shown, but not in the combo box itself.

Can anyone help?

Thanks in advance.
  Paul



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