Should cell renderer properties be cleared
- From: Federico Mena Quintero <federico ximian com>
- To: gtk-devel-list gnome org
- Subject: Should cell renderer properties be cleared
- Date: Tue, 09 Sep 2003 12:03:20 -0500
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>",
NULL);
else
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,
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?
Federico
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]