Re: Background color of Treeviews with just few rows



It is solved now!

Your code works perfectly but it changes the color of ALL ROWS and the part below the last row also.

I already had in the application rc file the following:
style "TreeStyle"
{
 GtkTreeView::allow-rules          = 1          # draw alternating color rows
 GtkTreeView::odd-row-color        = "#EDE7D3"  # light grey
 GtkTreeView::even-row-color       = "#FFFFFF"  # white
}
class "GtkTreeView" style "TreeStyle"
and in the code there was the set_rules_hint (true), so odd rows are colored as light grey and even rows are colored white.

It seems that the treeview uses the even-row-color for the part below the last row, so I changed the rc file to
style "TreeStyle"
{
 GtkTreeView::allow-rules          = 1          # draw alternating color rows
 GtkTreeView::odd-row-color        = "#FFFFFF"  # white
 
GtkTreeView::even-row-color       = "#EDE7D3"  # light grey
}
class "GtkTreeView" style "TreeStyle"
and then this part (below the last row in a treeview with just a few rows) is colored now as light grey, which is more or less what I wanted.

Thanks a lot!!!
Best Regards
JLF



El 01/10/2015 a las 6:07, Miroslav Rajcic escribió:
Hi Juan,

have you tried the proposed code to verify that if works or not, or just guessing?

I use that code (plus your code, but it doesn't work on its own) in my own program, and it works fine.
Note that the same color is set for odd and even color.

You can download my program NoteCase Pro (www.notecasepro.com) and use "General Settings" window (page "03 Display", select color for "Color" -> "Background" entry) to change the color of the tree view found on the left of the main window.

Regards,
  Miroslav

On 30.9.2015. 20:54, Juan L. Freniche wrote:
Thanks. However I think your recommendation will draw odd and even row with the selected color but this is not what I am looking for.

I would like to give some color to the area below last row, in a treeview with a small number of rows. This area is by default white.

El 30/09/2015 a las 12:45, Miroslav Rajcic escribió:
This code works for me for GTK 2.x:

static const char color_rc[] =
                "style \"aaa\"\n"
                "{\n"
                "GtkTreeView::odd-row-color=\"#%04x%04x%04x\"\n"
                "GtkTreeView::even-row-color =\"#%04x%04x%04x\"\n"
                "}\n"
                "widget \"*.aaa\" style \"aaa\"";  // removed "class \"GtkTreeView\"" because it would change all trees

            gchar *rc_temp = g_strdup_printf(color_rc,
                color.red,
                color.green,
                color.blue,
                color.red,
                color.green,
                color.blue);
            gtk_rc_parse_string(rc_temp);
            gtk_widget_set_name(widget, "aaa");
            gtk_widget_reset_rc_styles(widget);
            g_free(rc_temp);

I hope it helps.

Regards,
  Miroslav
On 30.9.2015. 8:51, Juan L. Freniche wrote:
Hello, I would appreciate help in this topic:

I have a notebook with several pages. Every page has a scrolledwindow and then a treeview.

For treeviews with sufficient rows, no problema but if the treeview has a small number of rows, the remaining area below the last row is in white color.

I would like to change the color of this area. I tried

style =get_style (widget)
set_background (style, state_normal, other color)
set_style (widget, style)


where widget was sucessively the notebook, the scrolled window and the treeview. No success.

I am using Gtk 2.24 and in the process of moving to Gtk3.

Thanks in advance.

_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



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