Changing foreground and background color in GtkListView rows
- From: marcodev comcast net
- To: gtk-app-devel-list gnome org
- Subject: Changing foreground and background color in GtkListView rows
- Date: Wed, 19 Jan 2005 15:23:34 +0000
I have the following code creating the column and its renderer in the list:
{
......
vars_list = gtk_tree_view_new ();
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(var_list_col_title,
renderer,
"text", 0,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(vars_list), column);
......
}
The list displays the values of variables in memory and is updated by a timout that runs periodically. When a
variable is added (appended) to the list I use the following:
void
APPEND_TO_CLIST(GtkListStore *LIST, int ROW, char *STRING)
{
.....
GtkTreeIter iter;
gtk_list_store_append(LIST, &iter);
gtk_list_store_set(LIST, &iter,
0, STRING,
-1);
if(ROW % 2 == 0)
{
g_object_set(renderer, "background-gdk",
MM_GLBL->COLORS.CLIST_BG_A, NULL);
}
else
{
g_object_set(renderer, "background-gdk",
MM_GLBL->COLORS.CLIST_BG_B, NULL);
}
....
}
The above however is not changing the color on the background as I expected it. Am I even doing this right?
The following issue might be related to the same problem I have with the code above, when the value of a
variable in the list is updated the value should be displayed in one color (black) and when the value has
remained unchanged for a period of time then it should switch to another color (red). This is the code I use
for this:
void
UPDATE_CLIST_VALUE(GtkListStore *LIST, GtkTreeIter *ITER, char *STRING,
BOOLEAN NEWLY_CHANGED)
{
......
if (NEWLY_CHANGED)
{
g_object_set(renderer, "foreground", "Black", NULL);
}
else
{
g_object_set(renderer, "foreground", "Red", NULL);
}
gtk_list_store_set(list_store, ITER,
0, STRING,
-1);
// g_object_set(renderer, "text", STRING, NULL);
.......
}
The problem I have here is that when the color is chaned in the renderer and I set the value in the store to
a specific ITER then the entire column changes color, I need to have only ONE iter (row) to change color as
requested.
Any suggestions?
Thanks!!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]