Setting tree view column attributes from its signal handler
- From: "Ian Puleston" <ian underpressuredivers com>
- To: <gtk-list gnome org>
- Subject: Setting tree view column attributes from its signal handler
- Date: Wed, 2 Apr 2008 20:15:25 -0700
Hi,
Any ideas on this? I have a tree view that pops-up a menu when the user
double-clicks in a cell. The menu has options both for the selected row and
the selected column, but on this event the tree view highlights the selected
row, so I wanted to try to highlight the selected column too. The following
is what I tried to do in the tree view's "row-activated" signal handler:
void treeViewClickHandler(GtkTreeView *treeView, GtkTreePath *rowPath,
GtkTreeViewColumn *column, gpointer data)
{
GtkWidget *colsMenu = data;
GtkCellRenderer *renderer;
GList *cellList;
int i;
g_assert(GTK_IS_MENU(colsMenu));
cellList = gtk_tree_view_column_get_cell_renderers(column);
for (i = 0; (renderer = g_list_nth_data(cellList, i)) != NULL; i++)
{
g_object_set(G_OBJECT(renderer), "background", "blue", NULL);
}
g_list_free(cellList);
gtk_menu_popup(GTK_MENU(colsMenu), NULL, NULL, NULL, NULL,
0, gtk_get_current_event_time());
}
This nearly worked, but the background color doesn't get rendered. It
actually appears in the cells of the column as I subsequently move the mouse
over them. So I tried adding this after the g_object_set to try to get the
column's cells to render:
gtk_cell_renderer_get_size(renderer, GTK_WIDGET(column), &cellArea,
&xOff, &yOff, &width, &height);
gtk_cell_renderer_render(renderer, GTK_WIDGET(column)->window,
GTK_WIDGET(column),
&cellArea, &cellArea, &cellArea,
GTK_CELL_RENDERER_SELECTED);
But that did nothing. I also tried removing the menu popup line and it still
behaves the same, so it's not caused by displaying the menu. But I call
similar code to change attributes of a column later in the signal handler
for the menu, and that works fine.
Can anyone see anything that I'm doing wrong here?
Ian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]