Adw.CssClassBinding¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.CssClassBinding(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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
propertyis a boolean property,css-classwill be set every time the value ofpropertyis changed toTRUE, 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
propertyto 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.
Added in version 1.10.
- get_flags()¶
- Returns:
the binding flags
- Return type:
Gets the flags passed when constructing the binding.
Added in version 1.10.
- get_source()¶
- Returns:
the source, or
NULLif it doesn’t exist anymore- Return type:
Gets the object instance passed as the source of the binding.
While a binding can outlive the source as the binding doesn’t hold a strong reference to the source, the binding will try to finalize itself when it does not have a valid source. If the source, however, is destroyed before the binding is fully finalized then this function will return
NULL.Added in version 1.10.
- get_source_property()¶
- Returns:
the name of the source property
- Return type:
Gets the name of the property bound from [property`CssClassBinding`:py:data::source<Adw.CssClassBinding.props.source>].
Added in version 1.10.
- get_target()¶
- Returns:
the target, or
NULLif it doesn’t exist anymore- Return type:
Gtk.WidgetorNone
Gets the widget instance passed as the target of the binding.
While a binding can outlive the target as the binding doesn’t hold a strong reference to the target, the binding will try to finalize itself when it does not have a valid target. If the target, however, is destroyed before the binding is fully finalized then this function will return
NULL.Added in version 1.10.
- get_target_css_class()¶
- Returns:
the name of the target CSS class
- Return type:
Gets the CSS class to toggle on [property`CssClassBinding`:py:data::target<Adw.CssClassBinding.props.target>].
Added in version 1.10.
- unbind()¶
Explicitly releases the binding between the source and the target.
This function will release the reference that is being held on self if the binding is still bound; if you want to hold on to the binding instance after calling this method, you will need to manually hold a reference to it.
Note that this function does not take ownership of self, it only unrefs the instance that was initially created by [func`Adw`.bind_property_to_css_class] and is owned by the binding.
Added in version 1.10.
Property Details¶
- Adw.CssClassBinding.props.flags¶
- Name:
flags- Type:
- Default Value:
- Flags:
Flags to be used to control the binding.
Added in version 1.10.
- Adw.CssClassBinding.props.source¶
- Name:
source- Type:
- Default Value:
- Flags:
The object to use as the source of the CSS class binding.
Added in version 1.10.
- Adw.CssClassBinding.props.source_property¶
- Name:
source-property- Type:
- Default Value:
- Flags:
The name of the property that shoudl be used as the source of the binding.
Added in version 1.10.
- Adw.CssClassBinding.props.target¶
- Name:
target- Type:
- Default Value:
- Flags:
The widget to use as the target of the CSS class binding.
Added in version 1.10.