Re: How to set the GtkTreeViewColumn title font



Will Heyman wrote:

I'm trying to set up a table widget using a GtkTreeView and a GtkListStore.
I'd like to reset the font of the whole table.
I've been able to set the cell fonts by using g_object_set () on the cell renderers but how do I set the font of the column titles? Also is there a more gracefull way to set the font of the entire GtkTreeView without setting it for each cell and title?

Use gtk_widget_modify_font() function on GtkTreeView. This will set the default font for all cells. The font for the titles is tricky. The most *correct* way I see is to set your own title widget to GtkTreeViewColumn. Sample code (must be called after all column are set up and appended to tree view):

static void set_3_font(GtkTreeView *tv, PangoFontDescription *pfd)
{
 gint i;
 GtkWidget *title;
 GtkTreeViewColumn *column;
 gtk_widget_modify_font(GTK_WIDGET(tv), pfd);
 for (i=0; (column=gtk_tree_view_get_column(tv, i)) != NULL; i++) {
   title = gtk_label_new(gtk_tree_view_column_get_title(column));
   gtk_widget_show(title);
   gtk_widget_modify_font(title, pfd);
   gtk_tree_view_column_set_widget(column, title);
 }
}

   Olexiy





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