Struct gio::PropertyAction[][src]

pub struct PropertyAction(_);
Expand description

A PropertyAction is a way to get a Action with a state value reflecting and controlling the value of a glib::Object property.

The state of the action will correspond to the value of the property. Changing it will change the property (assuming the requested value matches the requirements as specified in the GParamSpec).

Only the most common types are presently supported. Booleans are mapped to booleans, strings to strings, signed/unsigned integers to int32/uint32 and floats and doubles to doubles.

If the property is an enum then the state will be string-typed and conversion will automatically be performed between the enum value and “nick” string as per the GEnumValue table.

Flags types are not currently supported.

Properties of object types, boxed types and pointer types are not supported and probably never will be.

Properties of glib::Variant types are not currently supported.

If the property is boolean-valued then the action will have a NULL parameter type, and activating the action (with no parameter) will toggle the value of the property.

In all other cases, the parameter type will correspond to the type of the property.

The general idea here is to reduce the number of locations where a particular piece of state is kept (and therefore has to be synchronised between). PropertyAction does not have a separate state that is kept in sync with the property value – its state is the property value.

For example, it might be useful to create a Action corresponding to the “visible-child-name” property of a GtkStack so that the current page can be switched from a menu. The active radio indication in the menu is then directly determined from the active page of the GtkStack.

An anti-example would be binding the “active-id” property on a GtkComboBox. This is because the state of the combobox itself is probably uninteresting and is actually being used to control something else.

Another anti-example would be to bind to the “visible-child-name” property of a GtkStack if this value is actually stored in Settings. In that case, the real source of the value is Settings. If you want a Action to control a setting stored in Settings, see SettingsExt::create_action() instead, and possibly combine its use with SettingsExtManual::bind().

Implements

glib::ObjectExt, ActionExt

Implementations

Creates a Action corresponding to the value of property property_name on object.

The property must be existent and readable and writable (and not construct-only).

This function takes a reference on object and doesn’t release it until the action is destroyed.

name

the name of the action to create

object

the object that has the property to wrap

property_name

the name of the property

Returns

a new PropertyAction

If true, the state of the action will be the negation of the property value, provided the property is boolean.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.