3

Short version: What CSS selector can be used to style the background of a GTK TreeView header?

Long version: I've tried treeview header, treeview header .button, .button, button, label, GtkTreeView header, header and * as selectors for the header of a Gtk.TreeView. Of these, button works to change the colour of the text in the header (the color attribute) but not the background (background-color). label changes the colour of the background behind the header text, but leaves a big area around the text at the default. * works, but of course changes everything else, too.

1 Answer 1

6

I've tried to use Gtk Inspector on a simple python example and it reported the treeview class as .view and the button on the header as .button. Setting a custom css provider to the application with:

cssProvider = Gtk.CssProvider()
cssProvider.load_from_path("custom.css")
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)

and the custom.css file with the following content:

.view .button { color: Red; background: Cyan; font-weight: bold; text-shadow: none; box-shadow: none; }

The result was:

result ui

Here you can see the treeview header with font color as Red and backgroung as Cyan.

Tested on Fedora 23.

EDIT

On Fedora 26, it's as documented. you should use:

treeview.view header button { color: Red; background: Cyan; font-weight: bold; text-shadow: none; box-shadow: none; }

and the result is similar.

Sign up to request clarification or add additional context in comments.

2 Comments

Updated URL for the GtkTreeView CSS nodes documentation: docs.gtk.org/gtk3/class.TreeView.html#css-nodes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.