While applying my own CSS to my GTK+ application, I noticed, that some elements ignore some CSS properties and others ignore others or don't ignore them, which leads me to search for an overview of which elements support which CSS properties.
So far I couldn't find any such overview.
For example Gtk.Label
doesn't support border
at all, I had to put a Gtk.Frame
around it and style that in the CSS file. Another issue is, that even a Gtk.Frame
doesn't support margin
, which I want to use.
Can anyone give me some direction on where to find that?
(Or if I am mistaken with all of this, how do I make the elements support CSS properties?)
Here is an overview of which CSS properties are supported as of GTK 3.8. The same information is mostly contained in the documentation for GtkCssProvider
, albeit not in table form.
Which widgets support which properties is a bit harder. It boils down to two kinds of widgets: those that are simple and only support basic styling (no borders or backgrounds), such as GtkLabel
; and those that support all properties, such as GtkFrame
. Wrapping a simple widget inside a GtkFrame
or GtkEventBox
, as you have discovered, is the usual way to turn one into the other.
The margin
property is not supported at all, and I'm told that this is a choice by the GTK developers. The thinking goes, as I understand it, that GTK is not HTML, and the layout of your widgets on screen should be governed by your code and not by CSS.
Update in GTK 3.20: The margin
CSS property is now supported across most or all widgets.