[ CCode ( type_id = "adw_css_class_binding_get_type ()" ) ]
[ Version ( since = "1.10" ) ]
public sealed class CssClassBinding : Object
A binding between a [class@GObject.
Object] property and a CSS class on a [class@Gtk.Widget].
To create a binding, use [func@Adw.bind_property_to_css_class].
Whenever the source property changes, a CSS class is toggled on the target object; for instance, given the following binding:
```c adw_bind_property_to_css_class (source, "property", target, "css-class", G_BINDING_DEFAULT); ```
when `property` is a boolean property, `css-class` will be set every time the value of `property` is changed to `TRUE`, and vice versa.
Using [func@Adw.bind_property_to_css_class_full], it's possible to define a custom mapping between a property and the boolean enable state, that is, defining a mapping between any arbitrary property type and a boolean type. This allows for any property, not just boolean properties, to be bound to a CSS class; for instance, the following binding
```c adw_bind_property_to_css_class_full (source, "property", target, "css-class", G_BINDING_DEFAULT, int_to_bool, bool_to_int, NULL, NULL); ```
will map an integer-typed `property` to a boolean value, and use the value of that boolean to toggle the CSS class.
It is possible to invert the type of a boolean without using a custom map function by using the [ flags@GObject.BindingFlags.INVERT_BOOLEAN] flag.
A binding will be removed, and any allocated resources freed, whenever either one of the source or target instances are finalized, or when the binding instances loses its last reference.
Languages with garbage collection, or developers wanting to fully control the lifecycle of a binding may use [ method@CssClassBinding.unbind] to expliticly release a binding, instead of relying on the last reference on the binding, source, and target instances to drop.