Class

AdwCssClassBinding

unstable since: 1.10

Description [src]

final class Adw.CssClassBinding : GObject.Object
{
  /* No available fields */
}

A binding between a GObject property and a CSS class on a GtkWidget.

To create a binding, use 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:

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 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

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 G_BINDING_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 adw_css_class_binding_unbind() to expliticly release a binding, instead of relying on the last reference on the binding, source, and target instances to drop.

Available since: 1.10

Hierarchy

hierarchy this AdwCssClassBinding ancestor_0 GObject ancestor_0--this

Ancestors

Instance methods

adw_css_class_binding_get_flags

Gets the flags passed when constructing the binding.

unstable since: 1.10

adw_css_class_binding_get_source

Gets the object instance passed as the source of the binding.

unstable since: 1.10

adw_css_class_binding_get_source_property

Gets the name of the property bound from AdwCssClassBinding:source.

unstable since: 1.10

adw_css_class_binding_get_target

Gets the widget instance passed as the target of the binding.

unstable since: 1.10

adw_css_class_binding_get_target_css_class

Gets the CSS class to toggle on AdwCssClassBinding:target.

unstable since: 1.10

adw_css_class_binding_unbind

Explicitly releases the binding between the source and the target.

unstable since: 1.10

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Adw.CssClassBinding:flags

Flags to be used to control the binding.

unstable since: 1.10

Adw.CssClassBinding:source

The object to use as the source of the CSS class binding.

unstable since: 1.10

Adw.CssClassBinding:source-property

The name of the property that shoudl be used as the source of the binding.

unstable since: 1.10

Adw.CssClassBinding:target

The widget to use as the target of the CSS class binding.

unstable since: 1.10

Adw.CssClassBinding:target-css-class

The name of the CSS class that should be toggled on the target object.

unstable since: 1.10

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct AdwCssClassBindingClass {
  GObjectClass parent_class;
  
}

No description available.

Class members
parent_class: GObjectClass

No description available.