pub trait ObjectExt: ObjectType {
Show 75 methods
// Required methods
fn is<T: StaticType>(&self) -> bool;
fn type_(&self) -> Type;
fn object_class(&self) -> &ObjectClass;
fn class(&self) -> &Class<Self>
where Self: IsClass;
fn class_of<T: IsClass>(&self) -> Option<&Class<T>>;
fn interface<T: IsInterface>(&self) -> Option<InterfaceRef<'_, T>>;
fn try_set_property<V: ToValue>(
&self,
property_name: &str,
value: V
) -> Result<(), BoolError>;
fn set_property<V: ToValue>(&self, property_name: &str, value: V);
fn try_set_property_from_value(
&self,
property_name: &str,
value: &Value
) -> Result<(), BoolError>;
fn set_property_from_value(&self, property_name: &str, value: &Value);
fn try_set_properties(
&self,
property_values: &[(&str, &dyn ToValue)]
) -> Result<(), BoolError>;
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)]);
fn try_set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>;
fn set_properties_from_value(&self, property_values: &[(&str, Value)]);
fn try_property<V: for<'b> FromValue<'b> + 'static>(
&self,
property_name: &str
) -> Result<V, BoolError>;
fn property<V: for<'b> FromValue<'b> + 'static>(
&self,
property_name: &str
) -> V;
fn try_property_value(
&self,
property_name: &str
) -> Result<Value, BoolError>;
fn property_value(&self, property_name: &str) -> Value;
fn has_property(&self, property_name: &str, type_: Option<Type>) -> bool;
fn property_type(&self, property_name: &str) -> Option<Type>;
fn find_property(&self, property_name: &str) -> Option<ParamSpec>;
fn list_properties(&self) -> PtrSlice<ParamSpec>;
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard;
unsafe fn set_qdata<QD: 'static>(&self, key: Quark, value: QD);
unsafe fn qdata<QD: 'static>(&self, key: Quark) -> Option<NonNull<QD>>;
unsafe fn steal_qdata<QD: 'static>(&self, key: Quark) -> Option<QD>;
unsafe fn set_data<QD: 'static>(&self, key: &str, value: QD);
unsafe fn data<QD: 'static>(&self, key: &str) -> Option<NonNull<QD>>;
unsafe fn steal_data<QD: 'static>(&self, key: &str) -> Option<QD>;
fn block_signal(&self, handler_id: &SignalHandlerId);
fn unblock_signal(&self, handler_id: &SignalHandlerId);
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>);
fn stop_signal_emission_by_name(&self, signal_name: &str);
fn try_connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static;
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static;
fn try_connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static;
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static;
fn try_connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value> + 'static;
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static;
fn try_connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value> + 'static;
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static;
unsafe fn try_connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value>;
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>;
unsafe fn try_connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>
where F: Fn(&[Value]) -> Option<Value>;
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>;
fn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>;
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId;
fn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>;
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId;
fn watch_closure(&self, closure: &impl AsRef<Closure>);
fn try_emit<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> Result<R, BoolError>;
fn emit<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> R;
fn try_emit_with_values(
&self,
signal_id: SignalId,
args: &[Value]
) -> Result<Option<Value>, BoolError>;
fn emit_with_values(
&self,
signal_id: SignalId,
args: &[Value]
) -> Option<Value>;
fn try_emit_by_name<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError>;
fn emit_by_name<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> R;
fn try_emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Result<Option<Value>, BoolError>;
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>;
fn try_emit_by_name_with_details<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError>;
fn emit_by_name_with_details<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> R;
fn try_emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>;
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>;
fn try_emit_with_details<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError>;
fn emit_with_details<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R;
fn try_emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>;
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>;
fn disconnect(&self, handler_id: SignalHandlerId);
fn connect_notify<F: Fn(&Self, &ParamSpec) + Send + Sync + 'static>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId;
fn connect_notify_local<F: Fn(&Self, &ParamSpec) + 'static>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId;
unsafe fn connect_notify_unsafe<F: Fn(&Self, &ParamSpec)>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId;
fn notify(&self, property_name: &str);
fn notify_by_pspec(&self, pspec: &ParamSpec);
fn downgrade(&self) -> WeakRef<Self>;
fn bind_property<'a, O: ObjectType>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a>;
fn ref_count(&self) -> u32;
}
Required Methods§
sourcefn is<T: StaticType>(&self) -> bool
fn is<T: StaticType>(&self) -> bool
Returns true
if the object is an instance of (can be cast to) T
.
sourcefn object_class(&self) -> &ObjectClass
fn object_class(&self) -> &ObjectClass
Returns the ObjectClass
of the object.
This is equivalent to calling obj.class().upcast_ref::<ObjectClass>()
.
sourcefn class_of<T: IsClass>(&self) -> Option<&Class<T>>
fn class_of<T: IsClass>(&self) -> Option<&Class<T>>
Returns the class of the object in the given type T
.
None
is returned if the object is not a subclass of T
.
sourcefn interface<T: IsInterface>(&self) -> Option<InterfaceRef<'_, T>>
fn interface<T: IsInterface>(&self) -> Option<InterfaceRef<'_, T>>
Returns the interface T
of the object.
None
is returned if the object does not implement the interface T
.
sourcefn try_set_property<V: ToValue>(
&self,
property_name: &str,
value: V
) -> Result<(), BoolError>
fn try_set_property<V: ToValue>( &self, property_name: &str, value: V ) -> Result<(), BoolError>
Similar to Self::set_property
but fails instead of panicking.
sourcefn set_property<V: ToValue>(&self, property_name: &str, value: V)
fn set_property<V: ToValue>(&self, property_name: &str, value: V)
Sets the property property_name
of the object to value value
.
Panics
If the property does not exist, if the type of the property is different than the provided value, or if the property is not writable.
sourcefn try_set_property_from_value(
&self,
property_name: &str,
value: &Value
) -> Result<(), BoolError>
fn try_set_property_from_value( &self, property_name: &str, value: &Value ) -> Result<(), BoolError>
Similar to Self::set_property
but fails instead of panicking.
sourcefn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
Sets the property property_name
of the object to value value
.
Panics
If the property does not exist, the type of the property is different than the provided value, or if the property is not writable.
sourcefn try_set_properties(
&self,
property_values: &[(&str, &dyn ToValue)]
) -> Result<(), BoolError>
fn try_set_properties( &self, property_values: &[(&str, &dyn ToValue)] ) -> Result<(), BoolError>
Similar to Self::set_properties
but fails instead of panicking.
sourcefn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
Sets multiple properties of the object at once.
Panics
This does not set any properties if one or more properties don’t exist, values of the wrong type are provided, or if any of the properties is not writable.
sourcefn try_set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
fn try_set_properties_from_value( &self, property_values: &[(&str, Value)] ) -> Result<(), BoolError>
Similar to Self::set_properties_from_value
but fails instead of panicking.
sourcefn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
Sets multiple properties of the object at once.
Panics
This does not set any properties if one or more properties don’t exist, values of the wrong type are provided, or if any of the properties is not writable.
sourcefn try_property<V: for<'b> FromValue<'b> + 'static>(
&self,
property_name: &str
) -> Result<V, BoolError>
fn try_property<V: for<'b> FromValue<'b> + 'static>( &self, property_name: &str ) -> Result<V, BoolError>
Similar to Self::property
but fails instead of panicking.
sourcefn property<V: for<'b> FromValue<'b> + 'static>(&self, property_name: &str) -> V
fn property<V: for<'b> FromValue<'b> + 'static>(&self, property_name: &str) -> V
Gets the property property_name
of the object and cast it to the type V.
Panics
If the property doesn’t exist or is not readable or of a different type than V.
sourcefn try_property_value(&self, property_name: &str) -> Result<Value, BoolError>
fn try_property_value(&self, property_name: &str) -> Result<Value, BoolError>
Similar to Self::property_value
but fails instead of panicking.
sourcefn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
Gets the property property_name
of the object.
Panics
If the property does not exist or is not writable.
sourcefn has_property(&self, property_name: &str, type_: Option<Type>) -> bool
fn has_property(&self, property_name: &str, type_: Option<Type>) -> bool
Check if the object has a property property_name
of the given type_
.
If no type is provided then only the existence of the property is checked.
sourcefn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
Get the type of the property property_name
of this object.
This returns None
if the property does not exist.
sourcefn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
Get the ParamSpec
of the property property_name
of this object.
sourcefn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
Return all ParamSpec
of the properties of this object.
sourcefn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
Freeze all property notifications until the return guard object is dropped.
This prevents the notify
signal for all properties of this object to be emitted.
sourceunsafe fn set_qdata<QD: 'static>(&self, key: Quark, value: QD)
unsafe fn set_qdata<QD: 'static>(&self, key: Quark, value: QD)
Set arbitrary data on this object with the given key
.
Safety
This function doesn’t store type information
sourceunsafe fn qdata<QD: 'static>(&self, key: Quark) -> Option<NonNull<QD>>
unsafe fn qdata<QD: 'static>(&self, key: Quark) -> Option<NonNull<QD>>
Return previously set arbitrary data of this object with the given key
.
Safety
The returned pointer can become invalid by a call to
set_qdata
, steal_qdata
, set_data
or steal_data
.
The caller is responsible for ensuring the returned value is of a suitable type
sourceunsafe fn steal_qdata<QD: 'static>(&self, key: Quark) -> Option<QD>
unsafe fn steal_qdata<QD: 'static>(&self, key: Quark) -> Option<QD>
Retrieve previously set arbitrary data of this object with the given key
.
The data is not set on the object anymore afterwards.
Safety
The caller is responsible for ensuring the returned value is of a suitable type
sourceunsafe fn set_data<QD: 'static>(&self, key: &str, value: QD)
unsafe fn set_data<QD: 'static>(&self, key: &str, value: QD)
Set arbitrary data on this object with the given key
.
Safety
This function doesn’t store type information
sourceunsafe fn data<QD: 'static>(&self, key: &str) -> Option<NonNull<QD>>
unsafe fn data<QD: 'static>(&self, key: &str) -> Option<NonNull<QD>>
Return previously set arbitrary data of this object with the given key
.
Safety
The returned pointer can become invalid by a call to
set_qdata
, steal_qdata
, set_data
or steal_data
.
The caller is responsible for ensuring the returned value is of a suitable type
sourceunsafe fn steal_data<QD: 'static>(&self, key: &str) -> Option<QD>
unsafe fn steal_data<QD: 'static>(&self, key: &str) -> Option<QD>
Retrieve previously set arbitrary data of this object with the given key
.
The data is not set on the object anymore afterwards.
Safety
The caller is responsible for ensuring the returned value is of a suitable type
sourcefn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
Block a given signal handler.
It will not be called again during signal emissions until it is unblocked.
sourcefn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
Unblock a given signal handler.
sourcefn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
Stop emission of the currently emitted signal.
sourcefn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
sourcefn try_connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn try_connect<F>( &self, signal_name: &str, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
Similar to Self::connect
but fails instead of panicking.
sourcefn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn connect<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
Connect to the signal signal_name
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Panics
If the signal does not exist.
sourcefn try_connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn try_connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
Similar to Self::connect_id
but fails instead of panicking.
sourcefn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
Connect to the signal signal_id
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Same as Self::connect
but takes a SignalId
instead of a signal name.
Panics
If the signal does not exist.
sourcefn try_connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value> + 'static,
fn try_connect_local<F>( &self, signal_name: &str, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value> + 'static,
Similar to Self::connect_local
but fails instead of panicking.
sourcefn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + 'static,
fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,
Connect to the signal signal_name
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Same as Self::connect
but takes a non-Send+Sync
closure. If the signal is emitted from a
different thread than it was connected to then the signal emission will panic.
Panics
If the signal does not exist.
sourcefn try_connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value> + 'static,
fn try_connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value> + 'static,
Similar to Self::connect_local_id
but fails instead of panicking.
sourcefn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + 'static,
fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,
Connect to the signal signal_id
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Same as Self::connect_id
but takes a non-Send+Sync
closure. If the signal is emitted from a
different thread than it was connected to then the signal emission will panic.
Panics
This panics if the signal does not exist.
sourceunsafe fn try_connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value>,
unsafe fn try_connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_unsafe
but fails instead of panicking.
sourceunsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_name
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Same as Self::connect
but takes a non-Send+Sync
and non-'static'
closure. No runtime checks
are performed for ensuring that the closure is called correctly.
Safety
The provided closure must be valid until the signal handler is disconnected, and it must be allowed to call the closure from the threads the signal is emitted from.
Panics
If the signal does not exist.
sourceunsafe fn try_connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError>where
F: Fn(&[Value]) -> Option<Value>,
unsafe fn try_connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> Result<SignalHandlerId, BoolError>where F: Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_unsafe_id
but fails instead of panicking.
sourceunsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_id
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
Same as Self::connect_id
but takes a non-Send+Sync
and non-'static'
closure. No runtime checks
are performed for ensuring that the closure is called correctly.
Safety
The provided closure must be valid until the signal handler is disconnected, and it must be allowed to call the closure from the threads the signal is emitted from.
Panics
If the signal does not exist.
sourcefn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
fn try_connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure ) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure
but fails instead of panicking.
sourcefn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure ) -> SignalHandlerId
Connect a closure to the signal signal_name
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
This panics if the signal does not exist.
A recurring case is connecting a handler which will be automatically disconnected
when an object it refers to is destroyed, as it happens with g_signal_connect_object
in C. This can be achieved with a closure that watches an object: see the documentation
of the closure!
macro for more details.
Same as Self::connect
but takes a Closure
instead of a Fn
.
sourcefn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
fn try_connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure ) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure_id
but fails instead of panicking.
sourcefn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure ) -> SignalHandlerId
Connect a closure to the signal signal_id
on this object.
If after
is set to true
then the callback will be called after the default class
handler of the signal is emitted, otherwise before.
This panics if the signal does not exist.
Same as Self::connect_closure
but takes a
SignalId
instead of a signal name.
sourcefn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
Limits the lifetime of closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
Closure::invoke
.
sourcefn try_emit<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> Result<R, BoolError>
fn try_emit<R: TryFromClosureReturnValue>( &self, signal_id: SignalId, args: &[&dyn ToValue] ) -> Result<R, BoolError>
Similar to Self::emit
but fails instead of panicking.
sourcefn emit<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> R
fn emit<R: TryFromClosureReturnValue>( &self, signal_id: SignalId, args: &[&dyn ToValue] ) -> R
Emit signal by signal id.
If the signal has a return value then this is returned here.
Panics
If the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_with_values(
&self,
signal_id: SignalId,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_with_values( &self, signal_id: SignalId, args: &[Value] ) -> Result<Option<Value>, BoolError>
Similar to Self::emit_with_values
but fails instead of panicking.
sourcefn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Same as Self::emit
but takes Value
for the arguments.
sourcefn try_emit_by_name<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError>
fn try_emit_by_name<R: TryFromClosureReturnValue>( &self, signal_name: &str, args: &[&dyn ToValue] ) -> Result<R, BoolError>
Similar to Self::emit_by_name
but fails instead of panicking.
sourcefn emit_by_name<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> R
fn emit_by_name<R: TryFromClosureReturnValue>( &self, signal_name: &str, args: &[&dyn ToValue] ) -> R
Emit signal by its name.
If the signal has a return value then this is returned here.
Panics
If the signal does not exist, the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_by_name_with_values( &self, signal_name: &str, args: &[Value] ) -> Result<Option<Value>, BoolError>
Similar to Self::emit_by_name_with_values
but fails instead of panicking.
sourcefn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value] ) -> Option<Value>
Emit signal by its name.
If the signal has a return value then this is returned here.
Panics
If the signal does not exist, the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_by_name_with_details<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError>
fn try_emit_by_name_with_details<R: TryFromClosureReturnValue>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue] ) -> Result<R, BoolError>
Similar to Self::emit_by_name_with_details
but fails instead of panicking.
sourcefn emit_by_name_with_details<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> R
fn emit_by_name_with_details<R: TryFromClosureReturnValue>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue] ) -> R
Emit signal by its name with details.
If the signal has a return value then this is returned here.
Panics
If the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value] ) -> Result<Option<Value>, BoolError>
Similar to Self::emit_by_name_with_details_and_values
but fails instead of panicking.
sourcefn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value] ) -> Option<Value>
Emit signal by its name with details.
If the signal has a return value then this is returned here.
Panics
If the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_with_details<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError>
fn try_emit_with_details<R: TryFromClosureReturnValue>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue] ) -> Result<R, BoolError>
Similar to Self::emit_with_details
but fails instead of panicking.
sourcefn emit_with_details<R: TryFromClosureReturnValue>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R
fn emit_with_details<R: TryFromClosureReturnValue>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue] ) -> R
Emit signal by signal id with details.
If the signal has a return value then this is returned here.
Panics
If the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn try_emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value] ) -> Result<Option<Value>, BoolError>
Similar to Self::emit_with_details_and_values
but fails instead of panicking.
sourcefn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value] ) -> Option<Value>
Emit signal by signal id with details.
If the signal has a return value then this is returned here.
Panics
If the wrong number of arguments is provided, or arguments of the wrong types were provided.
sourcefn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
Disconnect a previously connected signal handler.
sourcefn connect_notify<F: Fn(&Self, &ParamSpec) + Send + Sync + 'static>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId
fn connect_notify<F: Fn(&Self, &ParamSpec) + Send + Sync + 'static>( &self, name: Option<&str>, f: F ) -> SignalHandlerId
Connect to the notify
signal of the object.
This is emitted whenever a property is changed. If name
is provided then the signal
handler is only called for this specific property.
sourcefn connect_notify_local<F: Fn(&Self, &ParamSpec) + 'static>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId
fn connect_notify_local<F: Fn(&Self, &ParamSpec) + 'static>( &self, name: Option<&str>, f: F ) -> SignalHandlerId
Connect to the notify
signal of the object.
This is emitted whenever a property is changed. If name
is provided then the signal
handler is only called for this specific property.
This is like connect_notify
but doesn’t require a Send+Sync
closure. Signal emission
will panic if the signal is emitted from the wrong thread.
sourceunsafe fn connect_notify_unsafe<F: Fn(&Self, &ParamSpec)>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId
unsafe fn connect_notify_unsafe<F: Fn(&Self, &ParamSpec)>( &self, name: Option<&str>, f: F ) -> SignalHandlerId
Connect to the notify
signal of the object.
This is emitted whenever a property is changed. If name
is provided then the signal
handler is only called for this specific property.
This is like connect_notify
but doesn’t require a Send+Sync
or 'static
closure. No
runtime checks for wrongly calling the closure are performed.
Safety
The provided closure must be valid until the signal handler is disconnected, and it must be allowed to call the closure from the threads the signal is emitted from.
sourcefn notify(&self, property_name: &str)
fn notify(&self, property_name: &str)
Notify that the given property has changed its value.
This emits the notify
signal.
sourcefn notify_by_pspec(&self, pspec: &ParamSpec)
fn notify_by_pspec(&self, pspec: &ParamSpec)
Notify that the given property has changed its value.
This emits the notify
signal.
sourcefn bind_property<'a, O: ObjectType>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a>
fn bind_property<'a, O: ObjectType>( &'a self, source_property: &'a str, target: &'a O, target_property: &'a str ) -> BindingBuilder<'a>
Bind property source_property
on this object to the target_property
on the target
object.
This allows keeping the properties of both objects in sync.
The binding can be unidirectional or bidirectional and optionally it is possible to transform the property values before they’re passed to the other object.