Re: TreeView and Colors?



hi!

you need this code, I think

 renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start(column, renderer, FALSE);
  gtk_tree_view_column_set_cell_data_func (column, renderer,
                                           func_text, NULL, NULL);

where func_text can look like this one

static
void
func_text (GtkTreeViewColumn *tree_column,
             GtkCellRenderer   *cell,
             GtkTreeModel      *model,
             GtkTreeIter       *iter,
             gpointer           data)
{
  guint status;
  gchar *s;

  gtk_tree_model_get (model, iter,
                      0, &status,
                      -1);
  gtk_tree_model_get (model, iter,
                      1, &s,
                      -1);
  switch(status)
  {
    case 0://brak autoryzacji
      g_object_set (GTK_CELL_RENDERER (cell),
                  "font", "bold",
                  NULL);
      g_object_set (GTK_CELL_RENDERER (cell),
                  "text", s,
                  NULL);
      break;
    case 1://grupa
      g_object_set (GTK_CELL_RENDERER (cell),
                  "font", "bold",
                  NULL);
      g_object_set (GTK_CELL_RENDERER (cell),
                  "text", s,
                  NULL);
      break;
    default://osoby
      g_object_set (GTK_CELL_RENDERER (cell),
                    "font", "normal",
                    NULL);
      g_object_set (GTK_CELL_RENDERER (cell),
                  "text", s,
                  NULL);
  }
}

for other properties such as forground color look in gtk+ reference manual
for gtkCellRenderer

bye
hs

On Sat, 30 Nov 2002, Martin Klaffenboeck wrote:

Hello,

I want to add the entries in my GtkTreeView in different colors.  Such
as red for not installed, blue for installed, and green for installing
now.  How can I set up different colors in the GtkTreeView?  (pygtk2 -
but I hope I can also find it out if you send me a c example - or any
other hints)

Thanks,
Martin
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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