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
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
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for PropertyAction
impl !Send for PropertyAction
impl !Sync for PropertyAction
impl Unpin for PropertyAction
impl UnwindSafe for PropertyAction
Blanket Implementations
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
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
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.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,