Re: Change the treeview's color

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

 



Tetim wrote (@ Segunda, 27 de Novembro de 2006 20:29):
> How I can change line's color of the a treeview, but only one line...

 Ok. Your current GtkTreeView must be something like this:

GtkTreeStore *store = gtk_tree_store_new (1, G_TYPE_STRING);
GtkTreeView *view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
    0, "header", gtk_cell_renderer_text_new(), "text", 0, NULL);

 Now, modify that into this:

GtkTreeStore *store = gtk_tree_store_new (2, G_TYPE_STRING, GDK_TYPE_COLOR);
GtkTreeView *view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
    0, "header", gtk_cell_renderer_text_new(), "text", 0,
                                         "foreground-gdk", 1, NULL);

 Check the changes... I bet you'll understand... Anyway, a GtkTreeView is made 
of several components... What displays the several items text is not it, but 
a GtkCellRendererText. And what tells a CellRenderer about the values it 
should use is the GtkTreeViewColumn. Check the code again...

 A bit complex, but you can do complex things in return. ;)
 This GtkTreeView tutoral seems very good. Check it: 
http://scentric.net/tutorial/

 Btw, instead of the "foreground-gdk", you may want to use the "foreground" 
attribute where a string is asked (like "brown"). These attributes are the 
ones from GtkCellRendererText. Check them.

 And you may set the color value to NULL if you want to use the default. As an 
example:
GdkColor red = { 0, 255, 0, 0, 0 };
gtk_tree_store_append (getStore(), &iter, parent);
gtk_tree_store_set (getStore(), &iter, 0, "red", 1, &color, -1);
gtk_tree_store_append (getStore(), &iter, parent);
gtk_tree_store_set (getStore(), &iter, 0, "default color", -1);

Cheers,
 Ricardo

> Because, with:
>
> gdk_color_parse( "blue", &color);
> gtk_widget_modify_base( entry, GTK_STATE_NORMAL, &color );
>
> change all your color.
>
> Thanks
>
>
-- 
H. L. Mencken suffers from the hallucination that he is H. L.
Mencken -- there is no cure for a disease of that magnitude.
		-- Maxwell Bodenheim
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux