Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to theme the header bar close button in GTK+3?

Tags:

themes

gtk

gtk3

I'd like to change the style of the close button on GTK+3 windows with so called "header bars", where the window is rendered without decoration and GTK composes title bar and widgets.

What kind of element is the "X" close button, and what CSS classes does it belong to (if any)?

Screenshot

Note that this is not part of the window manager theme but actually drawn by GTK+.

like image 354
Fabian Knorr Avatar asked Feb 27 '14 13:02

Fabian Knorr


People also ask

How do you make a GTK 3 theme?

To create a GTK3 theme, developers can start with an empty file or they can use a pre-existing theme as a template. It may help beginners to start with a pre-existing theme. For instance, a theme can be copied to the user's home folder and then the developer can start editing the files.

Where are GTK themes?

System themes are stored in /usr/share/themes/ . This is the system-wide equivalent of your ~/. themes/ directory. The directory matching the name of the value of your dconf setting is your current gtk theme.


3 Answers

It's a GtkButton with icon window-close-symbolic with style class titlebutton (the same class as the other buttons on the header), assuming the app is using the built-in close button.

like image 158
Jussi Kukkonen Avatar answered Oct 18 '22 05:10

Jussi Kukkonen


2020-10-14 EDIT:

gtkparasite has been integrated into GTK under the name GtkInspector since GTK 3.14.

Original answer:

You may use gtkparasite to find the type and name of the element and how it's nested.

like image 32
liberforce Avatar answered Oct 18 '22 05:10

liberforce


the min/max/close button selectors:

headerbar.titlebar button.titlebutton.close
headerbar.titlebar button.titlebutton.maximize
headerbar.titlebar button.titlebutton.minimize

the selector for any/each of the individual min/max/close buttons:

headerbar.titlebar > :last-child button.titlebutton

the selector for the container of the entire group of min/max/close buttons:

headerbar.titlebar > :last-child

the selector for the left-most button (usually, but not always, the application button):

headerbar.titlebar > :first-child > button.titlebutton

the selector for the left-most button's container:

headerbar.titlebar > :first-child

i used these selectors in a theme of my own, you can inspect the relevant piece(s) of code here: http://xfce-evolution.sourceforge.net

like image 21
Gyll Avatar answered Oct 18 '22 07:10

Gyll