Svg

Struct Svg 

Source
pub struct Svg { /* private fields */ }
Available on crate feature v4_22 only.
Expand description

A paintable implementation that renders (a subset of) SVG, with animations.

Svg objects are created by parsing a subset of SVG, including SVG animations.

The Svg fills or strokes paths with symbolic or fixed colors. It can have multiple states, and paths can be included in a subset of the states. The special ‘empty’ state is always available. States can have animation, and the transition between different states can also be animated.

To find out what states a Svg has, use n_states(). To set the current state, use set_state().

To play the animations in an SVG file, use set_frame_clock() to connect the paintable to a frame clock, and then use play() to start the animation.

§Error handling

Loading an SVG into Svg will always produce a (possibly empty) paintable. GTK will drop things that it can’t handle and try to make sense of the rest.

To track errors during parsing or rednering, connect to the error signal.

For parsing errors in the GTK_SVG_ERROR domain, the functions Gtk::SvgError::get_start(), Gtk::SvgError::get_end(), Gtk::SvgError::get_element() and Gtk::SvgError::get_attribute() can be used to obtain information about where the error occurred.

§The supported subset of SVG

The paintable does not support text or images, only shapes and paths.

In <defs>, only <clipPath>, <mask>, gradients and shapes are supported, not <filter>, <pattern> or other things.

Gradient templating is not implemented.

The support for filters is limited to filter functions minus drop-shadow() plus a custom alpha-level() function, which implements one particular case of feComponentTransfer.

The transform-origin and transform-box attributes are not supported.

The support for the mask attribute is limited to just a url referring to the <mask> element by ID.

In animation elements, the parsing of begin and end attributes is limited, and the by, min and max attributes are not supported.

Lastly, there is no CSS support, and no interactivity.

§SVG Extensions

The paintable supports a number of custom attributes that offer a convenient way to define states, transitions and animations. For example,

 <circle cx='5' cy='5' r='5'
         gpa:states='0 1'
         gpa:animation-type='automatic'
         gpa:animation-direction='segment'
         gpa:animation-duration='600ms'/>

defines the circle to be shown in states 0 and 1, and animates a segment of the circle.

Note that the generated animations assume a pathLengh value of 1. Setting pathLength in your SVG is therefore going to interfere with generated animations.

To connect general SVG animations to the states of the paintable, use the custom gpa:states(...) condition in the begin and end attributes of SVG animation elements. For example,

 <animate href='path1'
          attributeName='fill'
          begin='gpa:states(0).begin'
          dur='300ms'
          fill='freeze'
          from='black'
          to='magenta'/>

will make the fill color of path1 transition from black to magenta when the renderer enters state 0.

The gpa:states(...) condition triggers for upcoming state changes as well, to support fade-out transitions. For example,

 <animate href='path1'
          attributeName='opacity'
          begin='gpa:states(0).end -300ms'
          dur='300ms'
          fill='freeze'
          from='1'
          to='0'/>

will start a fade-out of path1 300ms before state 0 ends.

In addition to gpa:fill and gpa:stroke, symbolic colors can also be specified as a custom paint server reference, like this: url(gpa:#warning). This works in fill and stroke attributes, but also when specifying colors in SVG animation attributes like to or values.

Note that the SVG syntax allows for a fallback RGB color to be specified after the url, for compatibility with other SVG consumers:

 fill='url(gpa:#warning) orange'

In contrast to SVG 1.1 and 2.0, we allow the transform attribute to be animated with <animate>.

§Properties

§playing

Whether the paintable is currently animating its content.

To set this property, use the Svg::play() and Svg::pause() functions.

Readable | Writeable

§resource

Construct-only property to create a paintable from a resource in ui files.

Writeable | Construct Only

§state

The current state of the renderer.

This can be a number between 0 and 63, or the special value (unsigned int) -1 to indicate the ‘empty’ state in which nothing is drawn.

Readable | Writeable

§weight

If not set to -1, this value overrides the weight used when rendering the paintable.

Readable | Writeable

§Signals

§error

Signals that an error occurred.

Errors can occur both during parsing and during rendering.

The expected error values are in the Gtk::SvgError enumeration, context information about the location of parsing errors can be obtained with the various gtk_svg_error functions.

Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal.

::: note This signal is emitted in the middle of parsing or rendering, and if you handle it, you must be careful. Logging the errors you receive is fine, but modifying the widget hierarchy or changing the paintable state definitively isn’t.

 If in doubt, defer to an idle.

Paintable

§invalidate-contents

Emitted when the contents of the @paintable change.

Examples for such an event would be videos changing to the next frame or the icon theme for an icon changing.

§invalidate-size

Emitted when the intrinsic size of the @paintable changes.

This means the values reported by at least one of [PaintableExtManual::intrinsic_width()][crate::gdk::prelude::PaintableExtManual::intrinsic_width()], [PaintableExtManual::intrinsic_height()][crate::gdk::prelude::PaintableExtManual::intrinsic_height()] or [PaintableExtManual::intrinsic_aspect_ratio()][crate::gdk::prelude::PaintableExtManual::intrinsic_aspect_ratio()] has changed.

Examples for such an event would be a paintable displaying the contents of a toplevel surface being resized.

§Implements

[trait@glib::ObjectExt], gdk::prelude::PaintableExt, SymbolicPaintableExt

GLib type: GObject with reference counted clone semantics.

Implementations§

Source§

impl Svg

Source

pub fn new() -> Svg

Creates a new, empty SVG paintable.

§Returns

the paintable

Source

pub fn from_bytes(bytes: &Bytes) -> Svg

Parses the SVG data in @bytes and creates a paintable.

§bytes

the data

§Returns

the paintable

Source

pub fn from_resource(path: &str) -> Svg

Parses the SVG data in the resource and creates a paintable.

§path

the resource path

§Returns

the paintable

Source

pub fn n_states(&self) -> u32

Gets the number of states defined in the SVG.

Note that there is always an empty state, which does not count towards this number. If this function returns the value N, the meaningful states of the SVG are 0, 1, …, N - 1 and GTK_SVG_STATE_EMPTY.

§Returns

the number of states

Source

pub fn state(&self) -> u32

Gets the current state of the paintable.

§Returns

the state

Source

pub fn weight(&self) -> f64

Gets the value of the weight property.

§Returns

the weight

Source

pub fn load_from_bytes(&self, bytes: &Bytes)

Loads SVG content into an existing SVG paintable.

To track errors while loading SVG content, connect to the error signal.

This clears any previously loaded content.

§bytes

the data to load

Source

pub fn pause(&self)

Stop any playing animations.

Animations can be paused and started repeatedly.

Source

pub fn play(&self)

Start playing animations.

Note that this is necessary for state changes as well.

Source

pub fn serialize(&self) -> Bytes

Serializes the content of the renderer as SVG.

The SVG will be similar to the orignally loaded one, but is not guaranteed to be 100% identical.

This function serializes the DOM, i.e. the results of parsing the SVG. It does not reflect the effect of applying animations.

§Returns

the serialized contents

Source

pub fn set_frame_clock(&self, clock: &FrameClock)

Sets a frame clock.

Without a frame clock, GTK has to rely on simple timeouts to run animations.

§clock

the frame clock

Source

pub fn set_state(&self, state: u32)

Sets the state of the paintable.

Use n_states() to find out what states @self has.

Note that play() must have been called for the SVG paintable to react to state changes.

§state

the state to set, as a value between 0 and 63, or (unsigned int) -1

Source

pub fn set_weight(&self, weight: f64)

Sets the weight that is used when rendering.

The default value of -1 means to use the font weight from CSS.

§weight

the font weight, as a value between -1 and 1000

Source

pub fn write_to_file(&self, filename: &str) -> Result<(), Error>

Serializes the paintable, and saves the result to a file.

§filename

the file to save to

§Returns

true, unless an error occurred

Source

pub fn is_playing(&self) -> bool

Whether the paintable is currently animating its content.

To set this property, use the play() and pause() functions.

Source

pub fn set_playing(&self, playing: bool)

Whether the paintable is currently animating its content.

To set this property, use the play() and pause() functions.

Source

pub fn connect_error<F: Fn(&Self, &Error) + 'static>( &self, f: F, ) -> SignalHandlerId

Signals that an error occurred.

Errors can occur both during parsing and during rendering.

The expected error values are in the Gtk::SvgError enumeration, context information about the location of parsing errors can be obtained with the various gtk_svg_error functions.

Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal.

::: note This signal is emitted in the middle of parsing or rendering, and if you handle it, you must be careful. Logging the errors you receive is fine, but modifying the widget hierarchy or changing the paintable state definitively isn’t.

If in doubt, defer to an idle.
§error

the error

Source

pub fn connect_playing_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

pub fn connect_state_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

pub fn connect_weight_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Trait Implementations§

Source§

impl Clone for Svg

Source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the object. Dropping the object will decrement it again.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Svg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Svg

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl HasParamSpec for Svg

Source§

type ParamSpec = ParamSpecObject

Source§

type SetValue = Svg

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(&str) -> ParamSpecObjectBuilder<'_, Svg>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl Hash for Svg

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Hashes the memory address of this object.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl Ord for Svg

Source§

fn cmp(&self, other: &Self) -> Ordering

Comparison for two GObjects.

Compares the memory addresses of the provided objects.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl ParentClassIs for Svg

Source§

impl<OT: ObjectType> PartialEq<OT> for Svg

Source§

fn eq(&self, other: &OT) -> bool

Equality for two GObjects.

Two GObjects are equal if their memory addresses are equal.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<OT: ObjectType> PartialOrd<OT> for Svg

Source§

fn partial_cmp(&self, other: &OT) -> Option<Ordering>

Partial comparison for two GObjects.

Compares the memory addresses of the provided objects.

1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for Svg

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq for Svg

Source§

impl IsA<Paintable> for Svg

Source§

impl IsA<SymbolicPaintable> for Svg

Auto Trait Implementations§

§

impl Freeze for Svg

§

impl RefUnwindSafe for Svg

§

impl !Send for Svg

§

impl !Sync for Svg

§

impl Unpin for Svg

§

impl UnwindSafe for Svg

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Cast for T
where T: ObjectType,

Source§

fn upcast<T>(self) -> T
where T: ObjectType, Self: IsA<T>,

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

fn upcast_ref<T>(&self) -> &T
where T: ObjectType, Self: IsA<T>,

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

fn downcast<T>(self) -> Result<T, Self>
where T: ObjectType, Self: MayDowncastTo<T>,

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

fn downcast_ref<T>(&self) -> Option<&T>
where T: ObjectType, Self: MayDowncastTo<T>,

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

fn dynamic_cast<T>(self) -> Result<T, Self>
where T: ObjectType,

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 upcast will do many checks at compile-time already. downcast will perform the same checks at runtime as dynamic_cast, but will also ensure some amount of compile-time safety. Read more
Source§

fn dynamic_cast_ref<T>(&self) -> Option<&T>
where T: ObjectType,

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
Source§

unsafe fn unsafe_cast<T>(self) -> T
where T: ObjectType,

Casts to T unconditionally. Read more
Source§

unsafe fn unsafe_cast_ref<T>(&self) -> &T
where T: ObjectType,

Casts to &T unconditionally. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

impl<O> GObjectPropertyExpressionExt for O
where O: IsA<Object>,

Source§

fn property_expression(&self, property_name: &str) -> PropertyExpression

Create an expression looking up an object’s property.
Source§

fn property_expression_weak(&self, property_name: &str) -> PropertyExpression

Create an expression looking up an object’s property with a weak reference.
Source§

fn this_expression(property_name: &str) -> PropertyExpression

Create an expression looking up a property in the bound this object.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<U> IsSubclassableExt for U

Source§

impl<T> ObjectExt for T
where T: ObjectType,

Source§

fn is<U>(&self) -> bool
where U: StaticType,

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

fn type_(&self) -> Type

Returns the type of the object.
Source§

fn object_class(&self) -> &Class<Object>

Returns the ObjectClass of the object. Read more
Source§

fn class(&self) -> &Class<T>
where T: IsClass,

Returns the class of the object.
Source§

fn class_of<U>(&self) -> Option<&Class<U>>
where U: IsClass,

Returns the class of the object in the given type T. Read more
Source§

fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>
where U: IsInterface,

Returns the interface T of the object. Read more
Source§

fn set_property(&self, property_name: &str, value: impl Into<Value>)

Sets the property property_name of the object to value value. Read more
Source§

fn set_property_from_value(&self, property_name: &str, value: &Value)

Sets the property property_name of the object to value value. Read more
Source§

fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])

Sets multiple properties of the object at once. Read more
Source§

fn set_properties_from_value(&self, property_values: &[(&str, Value)])

Sets multiple properties of the object at once. Read more
Source§

fn property<V>(&self, property_name: &str) -> V
where V: for<'b> FromValue<'b> + 'static,

Gets the property property_name of the object and cast it to the type V. Read more
Source§

fn property_value(&self, property_name: &str) -> Value

Gets the property property_name of the object. Read more
Source§

fn has_property(&self, property_name: &str) -> bool

Check if the object has a property property_name.
Source§

fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool

Check if the object has a property property_name of the given type_.
Source§

fn property_type(&self, property_name: &str) -> Option<Type>

Get the type of the property property_name of this object. Read more
Source§

fn find_property(&self, property_name: &str) -> Option<ParamSpec>

Get the ParamSpec of the property property_name of this object.
Source§

fn list_properties(&self) -> PtrSlice<ParamSpec>

Return all ParamSpec of the properties of this object.
Source§

fn freeze_notify(&self) -> PropertyNotificationFreezeGuard

Freeze all property notifications until the return guard object is dropped. Read more
Source§

unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)
where QD: 'static,

Set arbitrary data on this object with the given key. Read more
Source§

unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>
where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>
where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn set_data<QD>(&self, key: &str, value: QD)
where QD: 'static,

Set arbitrary data on this object with the given key. Read more
Source§

unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>
where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>
where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
Source§

fn block_signal(&self, handler_id: &SignalHandlerId)

Block a given signal handler. Read more
Source§

fn unblock_signal(&self, handler_id: &SignalHandlerId)

Unblock a given signal handler.
Source§

fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)

Stop emission of the currently emitted signal.
Source§

fn stop_signal_emission_by_name(&self, signal_name: &str)

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

fn connect<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,

Connect to the signal signal_name on this object. Read more
Source§

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,

Connect to the signal signal_id on this object. Read more
Source§

fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_name on this object. Read more
Source§

fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_id on this object. Read more
Source§

unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_name on this object. Read more
Source§

unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_id on this object. Read more
Source§

fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure, ) -> SignalHandlerId

Connect a closure to the signal signal_name on this object. Read more
Source§

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. Read more
Source§

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 invoke_with_values, or invoke when using Rust closures.
Source§

fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> R

Emit signal by signal id. Read more
Source§

fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>

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

fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R

Emit signal by its name. Read more
Source§

fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value], ) -> Option<Value>

Emit signal by its name. Read more
Source§

fn emit_by_name_with_details<R>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue], ) -> R

Emit signal by its name with details. Read more
Source§

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. Read more
Source§

fn emit_with_details<R>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue], ) -> R

Emit signal by signal id with details. Read more
Source§

fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value], ) -> Option<Value>

Emit signal by signal id with details. Read more
Source§

fn disconnect(&self, handler_id: SignalHandlerId)

Disconnect a previously connected signal handler.
Source§

fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
where F: Fn(&T, &ParamSpec) + Send + Sync + 'static,

Connect to the notify signal of the object. Read more
Source§

fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
where F: Fn(&T, &ParamSpec) + 'static,

Connect to the notify signal of the object. Read more
Source§

unsafe fn connect_notify_unsafe<F>( &self, name: Option<&str>, f: F, ) -> SignalHandlerId
where F: Fn(&T, &ParamSpec),

Connect to the notify signal of the object. Read more
Source§

fn notify(&self, property_name: &str)

Notify that the given property has changed its value. Read more
Source§

fn notify_by_pspec(&self, pspec: &ParamSpec)

Notify that the given property has changed its value. Read more
Source§

fn downgrade(&self) -> WeakRef<T>

Downgrade this object to a weak reference.
Source§

fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>
where F: FnOnce() + Send + 'static,

Add a callback to be notified when the Object is disposed.
Source§

fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>
where F: FnOnce() + 'static,

Add a callback to be notified when the Object is disposed. Read more
Source§

fn bind_property<'a, 'f, 't, O>( &'a self, source_property: &'a str, target: &'a O, target_property: &'a str, ) -> BindingBuilder<'a, 'f, 't>
where O: ObjectType,

Bind property source_property on this object to the target_property on the target object. Read more
Source§

fn ref_count(&self) -> u32

Returns the strong reference count of this object.
Source§

unsafe fn run_dispose(&self)

Runs the dispose mechanism of the object. Read more
Source§

impl<O> PaintableExt for O
where O: IsA<Paintable>,

Source§

fn compute_concrete_size( &self, specified_width: f64, specified_height: f64, default_width: f64, default_height: f64, ) -> (f64, f64)

Compute a concrete size for the Paintable. Read more
Source§

fn current_image(&self) -> Paintable

Gets an immutable paintable for the current contents displayed by @self. Read more
Source§

fn flags(&self) -> PaintableFlags

Get flags for the paintable. Read more
Source§

fn intrinsic_aspect_ratio(&self) -> f64

Gets the preferred aspect ratio the @self would like to be displayed at. Read more
Source§

fn intrinsic_height(&self) -> i32

Gets the preferred height the @self would like to be displayed at. Read more
Source§

fn intrinsic_width(&self) -> i32

Gets the preferred width the @self would like to be displayed at. Read more
Source§

fn invalidate_contents(&self)

Called by implementations of Paintable to invalidate their contents. Read more
Source§

fn invalidate_size(&self)

Called by implementations of Paintable to invalidate their size. Read more
Source§

fn snapshot(&self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64)

Snapshots the given paintable with the given @width and @height. Read more
Source§

fn connect_invalidate_contents<F>(&self, f: F) -> SignalHandlerId
where F: Fn(&Self) + 'static,

Emitted when the contents of the @paintable change. Read more
Source§

fn connect_invalidate_size<F>(&self, f: F) -> SignalHandlerId
where F: Fn(&Self) + 'static,

Emitted when the intrinsic size of the @paintable changes. Read more
Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

Ensures that the type has been registered with the type system.
Source§

impl<O> SymbolicPaintableExt for O

Source§

fn snapshot_symbolic( &self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64, colors: &[RGBA], )

Available on crate feature v4_6 only.
Snapshots the paintable with the given colors. Read more
Source§

fn snapshot_with_weight( &self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64, colors: &[RGBA], weight: f64, )

Available on crate feature v4_22 only.
Snapshots the paintable with the given colors and weight. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> TransparentType for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,

Source§

impl<Super, Sub> MayDowncastTo<Sub> for Super
where Super: IsA<Super>, Sub: IsA<Super>,