Re: making GtkTreeView look like GtkTree? and Setting colums diff. colors based on level?
- From: John Ellis <johne bellatlantic net>
- To: shark centibyte org
- Cc: gtk-app-devel-list gnome org
- Subject: Re: making GtkTreeView look like GtkTree? and Setting colums diff. colors based on level?
- Date: Wed, 24 Dec 2003 01:48:15 -0500
shark centibyte org wrote:
I like how GtkTree looks, with the lines connecting parent nodes/rows to
child nodes/rows, and the slight indentation. GtkTreeView has the
indendation but not the lines. Does anyone know how to make GtkTreeView
look like GtkTree in that respect?
For GTK 2, aesthetic things like the lines in a tree view can no longer be set
by the application, it is up to the theme to draw such lines.
Also, is it possible to make all the first columns be red text, but only
if they are root-level rows? As I understand it, GtkTreeView has you set
the CellRenderer by column only, with no regard to what level is being
rendered.
For all text cells that you want to have red text set for root nodes, use:
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
gtk_tree_view_column_set_cell_data_func(column, cell, set_cell_color_cb, NULL,
NULL);
...
void set_cell_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer
data)
{
GtkTreeIter parent;
if (!GTK_IS_CELL_RENDERER_TEXT(cell)) return;
if (gtk_tree_model_iter_parent(tree_model, &parent, iter) == FALSE)
g_object_set(G_OBJECT(cell), "foreground", "red", "foreground-set", TRUE,
NULL);
else
g_object_set(G_OBJECT(cell), "foreground-set", FALSE, NULL);
}
set_cell_color_cb is called before each cell is rendered.
Another way to check for a root node above would be to create a GtkTreePath from
iter and test if (gtk_tree_path_get_depth(tree_path) == 0).
For setting the color by RGB value, the "foreground-gdk" property could be used
in place of "foreground" and takes a GdkColor as the value.
Greetings,
John
--
John Ellis <johne bellatlantic net>
http://gqview.sourceforge.net <GQview> | http://gqapplets.sourceforge.net
http://gqmpeg.sourceforge.net <GQmpeg> | <panel applets>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]