Using the CSS file format

The syntax of RC and CSS files formats is obviously different. The CSS-like syntax will hopefully be much more familiar to many people, lowering the barrier for custom theming.

Instead of going through the syntax differences one-by-one, we will present a more or less comprehensive example and discuss how it can be translated into CSS:

Example 44. Sample RC code

1

would roughly translate to this CSS:

Example 45. CSS translation

1

One notable difference is the reduction from fg/bg/text/base colors to only foreground/background, in exchange the widget is able to render its various elements with different CSS classes, which can be themed independently.

In the same vein, the light, dark and mid color variants that were available in GtkStyle should be replaced by a combination of symbolic colors and custom CSS, where necessary. text_aa should really not be used anywhere, anyway, and the white and black colors that were available in GtkStyle can just be replaced by literal GdkRGBA structs.

Access to colors has also changed a bit. With GtkStyle, the common way to access colors is:

1

With GtkStyleContext, you generally use GdkRGBA instead of GdkColor and the code looks like this:

1

Note that the memory handling here is different: gtk_style_context_get() expects the address of a GdkRGBA* and returns a newly allocated struct, gtk_style_context_lookup_color() expects the address of an existing struct, and fills it.

It is worth mentioning that the new file format does not support stock icon mappings as the RC format did.