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)?
Note that this is not part of the window manager theme but actually drawn by GTK+.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With