Should cell renderer properties be cleared

I have a text cell renderer and its data func looks like this:

static void
data_func (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
	if (some_condition ())
		g_object_set (cell, "markup", 
			      "<span weight=\"bold\">I'M BOLD</span>",
		g_object_set (cell, "text", "I'm not bold", NULL);

However, this makes the tree display mess up badly.  Say the data_func
gets called for a bold item, so it sets the "markup" property.  However,
if the next invocation of data_func is for a non-bold item, the cell
renderer will keep its extra_attrs set and the "I'm not bold" text will
have a chunk of bold text and a non-bold section as well --- this
changes in random ways when you scroll the tree.

To fix this, in my "else" clause I have to do

	g_object_set (cell, 
		      "text", "I'm not bold", 
		      "attributes", NULL,

Or escape the text into markup without tags and set the "markup"
property, but this is ugly.

This is cumbersome.  Should the treeview reset a cell renderer's
parameters to the defaults between invocations of the data_funcs?


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