Trait glib::object::ObjectExt[][src]

pub trait ObjectExt: ObjectType {
Show 71 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_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

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

Returns the type of the object.

Returns the ObjectClass of the object.

This is equivalent to calling obj.class().upcast_ref::<ObjectClass>().

Returns the class of the object.

Returns the class of the object in the given type T.

None is returned if the object is not a subclass of T.

Returns the interface T of the object.

None is returned if the object does not implement the interface T.

Similar to Self::set_property but fails instead of panicking.

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.

Similar to Self::set_property but fails instead of panicking.

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.

Similar to Self::set_properties but fails instead of panicking.

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.

Similar to Self::set_properties_from_value but fails instead of panicking.

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.

Similar to Self::property but fails instead of panicking.

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.

Similar to Self::property_value but fails instead of panicking.

Gets the property property_name of the object.

Panics

If the property does not exist or is not writable.

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.

Get the type of the property property_name of this object.

This returns None if the property does not exist.

Get the ParamSpec of the property property_name of this object.

Return all ParamSpec of the properties of this object.

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.

Set arbitrary data on this object with the given key.

Safety

This function doesn’t store type information

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

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

Set arbitrary data on this object with the given key.

Safety

This function doesn’t store type information

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

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

Block a given signal handler.

It will not be called again during signal emissions until it is unblocked.

Unblock a given signal handler.

Stop emission of the currently emitted signal.

Stop emission of the currently emitted signal by the (possibly detailed) signal name.

Similar to Self::connect but fails instead of panicking.

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.

Similar to Self::connect_id but fails instead of panicking.

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.

Similar to Self::connect_local but fails instead of panicking.

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.

Similar to Self::connect_local_id but fails instead of panicking.

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.

Similar to Self::connect_unsafe but fails instead of panicking.

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.

Similar to Self::connect_unsafe_id but fails instead of panicking.

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.

Similar to Self::connect_closure but fails instead of panicking.

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.

Same as Self::connect but takes a Closure instead of a Fn.

Similar to Self::connect_closure_id but fails instead of panicking.

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.

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.

Similar to Self::emit but fails instead of panicking.

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.

Similar to Self::emit_with_values but fails instead of panicking.

Same as Self::emit but takes Value for the arguments.

Similar to Self::emit_by_name but fails instead of panicking.

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.

Similar to Self::emit_by_name_with_values but fails instead of panicking.

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.

Similar to Self::emit_with_details but fails instead of panicking.

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.

Similar to Self::emit_with_details_and_values but fails instead of panicking.

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.

Disconnect a previously connected signal handler.

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.

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.

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.

Notify that the given property has changed its value.

This emits the notify signal.

Notify that the given property has changed its value.

This emits the notify signal.

Downgrade this object to a weak reference.

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.

Returns the strong reference count of this object.

Implementors