Skip to main content

gtk4/auto/
svg.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_24")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
7use crate::{Overflow, Settings};
8use crate::{SvgFeatures, SymbolicPaintable, ffi};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// A paintable implementation that renders SVG, with animations.
19    ///
20    /// [`Svg`][crate::Svg] objects are created by parsing a subset of SVG,
21    /// including SVG animations.
22    ///
23    /// [`Svg`][crate::Svg] fills or strokes paths with symbolic or fixed colors.
24    /// It can have multiple states, and paths can be included in a subset
25    /// of the states. States can have animations, and the transition
26    /// between different states can also be animated.
27    ///
28    /// To show a static SVG image, it is enough to load the
29    /// the SVG and use it like any other paintable.
30    ///
31    /// To play an SVG animation, use [`set_frame_clock()`][Self::set_frame_clock()]
32    /// to connect the paintable to a frame clock, and call
33    /// [`play()`][Self::play()] after loading the SVG. The animation can
34    /// be paused using [`pause()`][Self::pause()].
35    ///
36    /// To set the current state, use [`set_state()`][Self::set_state()].
37    ///
38    ///
39    /// ## Error handling
40    ///
41    /// Loading an SVG into [`Svg`][crate::Svg] will always produce a (possibly empty)
42    /// paintable. GTK will drop things that it can't handle and try to make
43    /// sense of the rest.
44    ///
45    /// To track errors during parsing or rendering, connect to the
46    /// [`error`][struct@crate::Svg#error] signal.
47    ///
48    /// For parsing errors in the `GTK_SVG_ERROR` domain, the functions
49    /// `Gtk::SvgError::get_start()`, `Gtk::SvgError::get_end()`,
50    /// [`SvgError::element()`][crate::SvgError::element()] and [`SvgError::attribute()`][crate::SvgError::attribute()]
51    /// can be used to obtain information about where the error occurred.
52    ///
53    ///
54    /// ## The supported subset of SVG
55    ///
56    /// The paintable supports much of [SVG 2](https://svgwg.org/svg2-draft/),
57    /// including [animations](https://svgwg.org/specs/animations/), with some
58    /// exceptions.
59    ///
60    /// Among the graphical elements, `<textPath>` and `<foreignObject>` are
61    /// not supported.
62    ///
63    /// In the `<filter>` element, the following primitives are not supported:
64    /// feConvolveMatrix, feDiffuseLighting, feMorphology, feSpecularLighting.
65    ///
66    /// Support for the `mask` attribute is limited to just a url referring to
67    /// the `<mask>` element by ID.
68    ///
69    /// In animation elements, the parsing of `begin` and `end` attributes is
70    /// limited, and the `min` and `max` attributes are not supported.
71    ///
72    /// The interactive aspects of SVG are supported by `Gtk::SvgWidget`.
73    ///
74    ///
75    /// ## SVG Extensions
76    ///
77    /// The paintable supports a number of [custom attributes](icon-format.html)
78    /// that offer a convenient way to define states, transitions and animations.
79    /// For example,
80    ///
81    ///     <circle cx='5' cy='5' r='5'
82    ///             gpa:states='0 1'
83    ///             gpa:animation-type='automatic'
84    ///             gpa:animation-direction='segment'
85    ///             gpa:animation-duration='600ms'/>
86    ///
87    /// defines the circle to be shown in states 0 and 1, and animates a segment
88    /// of the circle.
89    ///
90    ///
91    /// <image src="svg-renderer1.svg">
92    ///
93    /// Note that the generated animations are implemented using standard
94    /// SVG attributes (`visibility`, `stroke-dasharray, `stroke-dashoffset`,
95    /// `pathLength` and `filter`). Setting these attributes in your SVG
96    /// is therefore going to interfere with generated animations.
97    ///
98    /// To connect general SVG animations to the states of the paintable,
99    /// use the custom `StateChange(...)` condition in the `begin` and `end`
100    /// attributes of SVG animation elements. For example,
101    ///
102    ///     <animate href='path1'
103    ///              attributeName='fill'
104    ///              begin='StateChange(1 2 3, 0)'
105    ///              dur='300ms'
106    ///              fill='freeze'
107    ///              from='black'
108    ///              to='magenta'/>
109    ///
110    /// will make the fill color of path1 transition from black to
111    /// magenta when the renderer enters state 0 from states 1, 2, or 3.
112    ///
113    /// <image src="svg-renderer2.svg">
114    ///
115    /// The `StateChange(...)` condition triggers for upcoming state changes
116    /// as well, to support fade-out transitions. For example,
117    ///
118    ///     <animate href='path1'
119    ///              attributeName='opacity'
120    ///              begin='StateChange(0, 1 2 3) -300ms'
121    ///              dur='300ms'
122    ///              fill='freeze'
123    ///              from='1'
124    ///              to='0'/>
125    ///
126    /// will start a fade-out of path1 300ms before a transition from state
127    /// 0 to 1, 2 or 3.
128    ///
129    /// States can be specified numerically, or by name. It is also possible
130    /// to say `not STATE` instead of explictly listing all states that are
131    /// different from `STATE`.
132    ///
133    /// In addition to the `gpa:fill` and `gpa:stroke` attributes, symbolic
134    /// colors can also be specified as a custom paint server reference,
135    /// like this: `url(#gpa:warning)`. This works in `fill` and `stroke`
136    /// attributes, but also when specifying colors in SVG animation
137    /// attributes like `to` or `values`.
138    ///
139    /// Note that the SVG syntax allows for a fallback RGB color to be
140    /// specified after the url, for compatibility with other SVG consumers:
141    ///
142    ///     fill='url(#gpa:warning) orange'
143    ///
144    /// GtkSvg also allows to refer to symbolic colors like system colors
145    /// in CSS, with names like SymbolicForeground, SymbolicSuccess, etc.
146    /// These can be used whenever a color is required.
147    ///
148    /// In contrast to SVG 1.1 and 2.0, we allow the `transform` attribute
149    /// to be animated with `<animate>`.
150    ///
151    /// ## Properties
152    ///
153    ///
154    /// #### `features`
155    ///  Enabled features for this paintable.
156    ///
157    /// Note that features have to be set before
158    /// loading SVG data to take effect.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `overflow`
164    ///  Whether the rendering will be clipped to the bounds.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `playing`
170    ///  Whether the paintable is currently animating its content.
171    ///
172    /// To set this property, use the [`Svg::play()`][crate::Svg::play()] and
173    /// [`Svg::pause()`][crate::Svg::pause()] functions.
174    ///
175    /// Readable | Writable
176    ///
177    ///
178    /// #### `resource`
179    ///  Resource to load SVG data from.
180    ///
181    /// This property is meant to create a paintable
182    /// from a resource in ui files.
183    ///
184    /// Readable | Writable
185    ///
186    ///
187    /// #### `state`
188    ///  The current state of the renderer.
189    ///
190    /// This can be a number between 0 and 63.
191    ///
192    /// Readable | Writable
193    ///
194    ///
195    /// #### `stylesheet`
196    ///  A CSS stylesheet to apply to the SVG.
197    ///
198    /// Readable | Writable
199    ///
200    ///
201    /// #### `weight`
202    ///  If not set to -1, this value overrides the weight used
203    /// when rendering the paintable.
204    ///
205    /// Readable | Writable
206    ///
207    /// ## Signals
208    ///
209    ///
210    /// #### `error`
211    ///  Signals that an error occurred.
212    ///
213    /// Errors can occur both during parsing and during rendering.
214    ///
215    /// The expected error values are in the [`SvgError`][crate::SvgError] enumeration,
216    /// context information about the location of parsing errors can
217    /// be obtained with the various `gtk_svg_error` functions.
218    ///
219    /// Parsing errors are never fatal, so the parsing will resume after
220    /// the error. Errors may however cause parts of the given data or
221    /// even all of it to not be parsed at all. So it is a useful idea
222    /// to check that the parsing succeeds by connecting to this signal.
223    ///
224    /// ::: note
225    ///     This signal is emitted in the middle of parsing or rendering,
226    ///     and if you handle it, you must be careful. Logging the errors
227    ///     you receive is fine, but modifying the widget hierarchy or
228    ///     changing the paintable state definitively isn't.
229    ///
230    ///     If in doubt, defer to an idle.
231    ///
232    ///
233    /// <details><summary><h4>Paintable</h4></summary>
234    ///
235    ///
236    /// #### `invalidate-contents`
237    ///  Emitted when the contents of the @paintable change.
238    ///
239    /// Examples for such an event would be videos changing to the next frame or
240    /// the icon theme for an icon changing.
241    ///
242    ///
243    ///
244    ///
245    /// #### `invalidate-size`
246    ///  Emitted when the intrinsic size of the @paintable changes.
247    ///
248    /// This means the values reported by at least one of
249    /// [`PaintableExtManual::intrinsic_width()`][crate::gdk::prelude::PaintableExtManual::intrinsic_width()],
250    /// [`PaintableExtManual::intrinsic_height()`][crate::gdk::prelude::PaintableExtManual::intrinsic_height()] or
251    /// [`PaintableExtManual::intrinsic_aspect_ratio()`][crate::gdk::prelude::PaintableExtManual::intrinsic_aspect_ratio()]
252    /// has changed.
253    ///
254    /// Examples for such an event would be a paintable displaying
255    /// the contents of a toplevel surface being resized.
256    ///
257    ///
258    /// </details>
259    ///
260    /// # Implements
261    ///
262    /// [`trait@glib::ObjectExt`], [`trait@gdk::prelude::PaintableExt`], [`SymbolicPaintableExt`][trait@crate::prelude::SymbolicPaintableExt]
263    #[doc(alias = "GtkSvg")]
264    pub struct Svg(Object<ffi::GtkSvg, ffi::GtkSvgClass>) @implements gdk::Paintable, SymbolicPaintable;
265
266    match fn {
267        type_ => || ffi::gtk_svg_get_type(),
268    }
269}
270
271impl Svg {
272    /// Creates a new, empty SVG paintable.
273    ///
274    /// # Returns
275    ///
276    /// the paintable
277    #[doc(alias = "gtk_svg_new")]
278    pub fn new() -> Svg {
279        assert_initialized_main_thread!();
280        unsafe { from_glib_full(ffi::gtk_svg_new()) }
281    }
282
283    /// Parses the SVG data in @bytes and creates a paintable.
284    /// ## `bytes`
285    /// the data
286    ///
287    /// # Returns
288    ///
289    /// the paintable
290    #[doc(alias = "gtk_svg_new_from_bytes")]
291    #[doc(alias = "new_from_bytes")]
292    pub fn from_bytes(bytes: &glib::Bytes) -> Svg {
293        assert_initialized_main_thread!();
294        unsafe { from_glib_full(ffi::gtk_svg_new_from_bytes(bytes.to_glib_none().0)) }
295    }
296
297    /// Parses the SVG data in the resource and creates a paintable.
298    /// ## `path`
299    /// the resource path
300    ///
301    /// # Returns
302    ///
303    /// the paintable
304    #[doc(alias = "gtk_svg_new_from_resource")]
305    #[doc(alias = "new_from_resource")]
306    pub fn from_resource(path: &str) -> Svg {
307        assert_initialized_main_thread!();
308        unsafe { from_glib_full(ffi::gtk_svg_new_from_resource(path.to_glib_none().0)) }
309    }
310
311    /// Returns the currently enabled features.
312    ///
313    /// # Returns
314    ///
315    /// the enabled features
316    #[doc(alias = "gtk_svg_get_features")]
317    #[doc(alias = "get_features")]
318    pub fn features(&self) -> SvgFeatures {
319        unsafe { from_glib(ffi::gtk_svg_get_features(self.to_glib_none().0)) }
320    }
321
322    /// Gets the current overflow value.
323    ///
324    /// # Returns
325    ///
326    /// the current overflow value
327    #[cfg(feature = "v4_24")]
328    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
329    #[doc(alias = "gtk_svg_get_overflow")]
330    #[doc(alias = "get_overflow")]
331    pub fn overflow(&self) -> Overflow {
332        unsafe { from_glib(ffi::gtk_svg_get_overflow(self.to_glib_none().0)) }
333    }
334
335    /// Gets the current state of the paintable.
336    ///
337    /// # Returns
338    ///
339    /// the state
340    #[doc(alias = "gtk_svg_get_state")]
341    #[doc(alias = "get_state")]
342    pub fn state(&self) -> u32 {
343        unsafe { ffi::gtk_svg_get_state(self.to_glib_none().0) }
344    }
345
346    /// Returns a `NULL`-terminated array of
347    /// state names, if available.
348    ///
349    /// Note that the returned array and the strings
350    /// contained in it will only be valid until the
351    /// [`Svg`][crate::Svg] is cleared or reloaded, so if you
352    /// want to keep it around, you should make a copy.
353    ///
354    /// # Returns
355    ///
356    /// the state names
357    ///
358    /// ## `length`
359    /// return location for the number
360    ///   of strings that are returned
361    #[doc(alias = "gtk_svg_get_state_names")]
362    #[doc(alias = "get_state_names")]
363    pub fn state_names(&self) -> (Vec<glib::GString>, u32) {
364        unsafe {
365            let mut length = std::mem::MaybeUninit::uninit();
366            let ret = FromGlibPtrContainer::from_glib_none(ffi::gtk_svg_get_state_names(
367                self.to_glib_none().0,
368                length.as_mut_ptr(),
369            ));
370            (ret, length.assume_init())
371        }
372    }
373
374    /// Gets the CSS user stylesheet.
375    ///
376    /// # Returns
377    ///
378    /// a `GBytes` with the CSS data
379    #[cfg(feature = "v4_24")]
380    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
381    #[doc(alias = "gtk_svg_get_stylesheet")]
382    #[doc(alias = "get_stylesheet")]
383    pub fn stylesheet(&self) -> Option<glib::Bytes> {
384        unsafe { from_glib_full(ffi::gtk_svg_get_stylesheet(self.to_glib_none().0)) }
385    }
386
387    /// Gets the value of the weight property.
388    ///
389    /// # Returns
390    ///
391    /// the weight
392    #[doc(alias = "gtk_svg_get_weight")]
393    #[doc(alias = "get_weight")]
394    pub fn weight(&self) -> f64 {
395        unsafe { ffi::gtk_svg_get_weight(self.to_glib_none().0) }
396    }
397
398    /// Loads SVG content into an existing SVG paintable.
399    ///
400    /// To track errors while loading SVG content,
401    /// connect to the [`error`][struct@crate::Svg#error] signal.
402    ///
403    /// This clears any previously loaded content.
404    /// ## `bytes`
405    /// the data to load
406    #[doc(alias = "gtk_svg_load_from_bytes")]
407    pub fn load_from_bytes(&self, bytes: &glib::Bytes) {
408        unsafe {
409            ffi::gtk_svg_load_from_bytes(self.to_glib_none().0, bytes.to_glib_none().0);
410        }
411    }
412
413    /// Loads SVG content into an existing SVG paintable.
414    ///
415    /// To track errors while loading SVG content,
416    /// connect to the [`error`][struct@crate::Svg#error] signal.
417    ///
418    /// This clears any previously loaded content.
419    /// ## `path`
420    /// the resource path
421    #[doc(alias = "gtk_svg_load_from_resource")]
422    pub fn load_from_resource(&self, path: &str) {
423        unsafe {
424            ffi::gtk_svg_load_from_resource(self.to_glib_none().0, path.to_glib_none().0);
425        }
426    }
427
428    /// Stop any playing animations and state transitions.
429    ///
430    /// SvgAnimations can be paused and started repeatedly.
431    #[doc(alias = "gtk_svg_pause")]
432    pub fn pause(&self) {
433        unsafe {
434            ffi::gtk_svg_pause(self.to_glib_none().0);
435        }
436    }
437
438    /// Start playing animations and state transitions.
439    ///
440    /// SvgAnimations can be paused and started repeatedly.
441    #[doc(alias = "gtk_svg_play")]
442    pub fn play(&self) {
443        unsafe {
444            ffi::gtk_svg_play(self.to_glib_none().0);
445        }
446    }
447
448    /// Serializes the content of the renderer as SVG.
449    ///
450    /// The SVG will be similar to the orignally loaded one,
451    /// but is not guaranteed to be 100% identical.
452    ///
453    /// This function serializes the DOM, i.e. the results
454    /// of parsing the SVG. It does not reflect the effect
455    /// of applying animations.
456    ///
457    /// # Returns
458    ///
459    /// the serialized contents
460    #[doc(alias = "gtk_svg_serialize")]
461    pub fn serialize(&self) -> glib::Bytes {
462        unsafe { from_glib_full(ffi::gtk_svg_serialize(self.to_glib_none().0)) }
463    }
464
465    /// Enables or disables features of the SVG paintable.
466    ///
467    /// By default, all features are enabled.
468    ///
469    /// Note that this call only has an effect before the
470    /// SVG is loaded.
471    /// ## `features`
472    /// features to enable
473    #[doc(alias = "gtk_svg_set_features")]
474    #[doc(alias = "features")]
475    pub fn set_features(&self, features: SvgFeatures) {
476        unsafe {
477            ffi::gtk_svg_set_features(self.to_glib_none().0, features.into_glib());
478        }
479    }
480
481    /// Sets a frame clock.
482    ///
483    /// Without a frame clock, GtkSvg will not advance animations.
484    /// ## `clock`
485    /// the frame clock
486    #[doc(alias = "gtk_svg_set_frame_clock")]
487    pub fn set_frame_clock(&self, clock: &gdk::FrameClock) {
488        unsafe {
489            ffi::gtk_svg_set_frame_clock(self.to_glib_none().0, clock.to_glib_none().0);
490        }
491    }
492
493    /// Sets whether the rendering will be clipped
494    /// to the bounds.
495    ///
496    /// Clipping is expected for [`gdk::Paintable`][crate::gdk::Paintable]
497    /// semantics, so this property should not be
498    /// changed when using a [`Svg`][crate::Svg] as a paintable.
499    /// ## `overflow`
500    /// the new overflow value
501    #[cfg(feature = "v4_24")]
502    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
503    #[doc(alias = "gtk_svg_set_overflow")]
504    #[doc(alias = "overflow")]
505    pub fn set_overflow(&self, overflow: Overflow) {
506        unsafe {
507            ffi::gtk_svg_set_overflow(self.to_glib_none().0, overflow.into_glib());
508        }
509    }
510
511    /// Sets a settings object holding settinsg used when
512    /// rendering the SVG.
513    /// ## `settings`
514    /// the settings object
515    #[cfg(feature = "v4_24")]
516    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
517    #[doc(alias = "gtk_svg_set_settings")]
518    pub fn set_settings(&self, settings: Option<&Settings>) {
519        unsafe {
520            ffi::gtk_svg_set_settings(self.to_glib_none().0, settings.to_glib_none().0);
521        }
522    }
523
524    /// Sets the state of the paintable.
525    ///
526    /// If the paintable is currently playing, the state change
527    /// will apply transitions that are defined in the SVG. If
528    /// the paintable is not playing, the state change will take
529    /// effect instantaneously.
530    /// ## `state`
531    /// the state to set, as a value between 0 and 63
532    #[doc(alias = "gtk_svg_set_state")]
533    #[doc(alias = "state")]
534    pub fn set_state(&self, state: u32) {
535        unsafe {
536            ffi::gtk_svg_set_state(self.to_glib_none().0, state);
537        }
538    }
539
540    /// Sets a CSS user stylesheet to use.
541    ///
542    /// Note that styles are applied at load time,
543    /// so this function must be called before
544    /// loading SVG.
545    /// ## `bytes`
546    /// CSS data
547    #[cfg(feature = "v4_24")]
548    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
549    #[doc(alias = "gtk_svg_set_stylesheet")]
550    #[doc(alias = "stylesheet")]
551    pub fn set_stylesheet(&self, bytes: Option<&glib::Bytes>) {
552        unsafe {
553            ffi::gtk_svg_set_stylesheet(self.to_glib_none().0, bytes.to_glib_none().0);
554        }
555    }
556
557    /// Sets the weight that is used when rendering.
558    ///
559    /// The weight affects the effective linewidth when stroking
560    /// paths.
561    ///
562    /// The default value of -1 means to use the font weight
563    /// from CSS.
564    /// ## `weight`
565    /// the font weight, as a value between -1 and 1000
566    #[doc(alias = "gtk_svg_set_weight")]
567    #[doc(alias = "weight")]
568    pub fn set_weight(&self, weight: f64) {
569        unsafe {
570            ffi::gtk_svg_set_weight(self.to_glib_none().0, weight);
571        }
572    }
573
574    /// Serializes the paintable, and saves the result to a file.
575    /// ## `filename`
576    /// the file to save to
577    ///
578    /// # Returns
579    ///
580    /// true, unless an error occurred
581    #[doc(alias = "gtk_svg_write_to_file")]
582    pub fn write_to_file(&self, filename: &str) -> Result<(), glib::Error> {
583        unsafe {
584            let mut error = std::ptr::null_mut();
585            let is_ok = ffi::gtk_svg_write_to_file(
586                self.to_glib_none().0,
587                filename.to_glib_none().0,
588                &mut error,
589            );
590            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
591            if error.is_null() {
592                Ok(())
593            } else {
594                Err(from_glib_full(error))
595            }
596        }
597    }
598
599    /// Whether the paintable is currently animating its content.
600    ///
601    /// To set this property, use the [`play()`][Self::play()] and
602    /// [`pause()`][Self::pause()] functions.
603    #[cfg(feature = "v4_22")]
604    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
605    pub fn is_playing(&self) -> bool {
606        ObjectExt::property(self, "playing")
607    }
608
609    /// Whether the paintable is currently animating its content.
610    ///
611    /// To set this property, use the [`play()`][Self::play()] and
612    /// [`pause()`][Self::pause()] functions.
613    #[cfg(feature = "v4_22")]
614    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
615    pub fn set_playing(&self, playing: bool) {
616        ObjectExt::set_property(self, "playing", playing)
617    }
618
619    /// Resource to load SVG data from.
620    ///
621    /// This property is meant to create a paintable
622    /// from a resource in ui files.
623    #[cfg(feature = "v4_22")]
624    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
625    pub fn resource(&self) -> Option<glib::GString> {
626        ObjectExt::property(self, "resource")
627    }
628
629    /// Resource to load SVG data from.
630    ///
631    /// This property is meant to create a paintable
632    /// from a resource in ui files.
633    #[cfg(feature = "v4_22")]
634    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
635    pub fn set_resource(&self, resource: Option<&str>) {
636        ObjectExt::set_property(self, "resource", resource)
637    }
638
639    /// Signals that an error occurred.
640    ///
641    /// Errors can occur both during parsing and during rendering.
642    ///
643    /// The expected error values are in the [`SvgError`][crate::SvgError] enumeration,
644    /// context information about the location of parsing errors can
645    /// be obtained with the various `gtk_svg_error` functions.
646    ///
647    /// Parsing errors are never fatal, so the parsing will resume after
648    /// the error. Errors may however cause parts of the given data or
649    /// even all of it to not be parsed at all. So it is a useful idea
650    /// to check that the parsing succeeds by connecting to this signal.
651    ///
652    /// ::: note
653    ///     This signal is emitted in the middle of parsing or rendering,
654    ///     and if you handle it, you must be careful. Logging the errors
655    ///     you receive is fine, but modifying the widget hierarchy or
656    ///     changing the paintable state definitively isn't.
657    ///
658    ///     If in doubt, defer to an idle.
659    /// ## `error`
660    /// the error
661    #[cfg(feature = "v4_22")]
662    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
663    #[doc(alias = "error")]
664    pub fn connect_error<F: Fn(&Self, &glib::Error) + 'static>(&self, f: F) -> SignalHandlerId {
665        unsafe extern "C" fn error_trampoline<F: Fn(&Svg, &glib::Error) + 'static>(
666            this: *mut ffi::GtkSvg,
667            error: *mut glib::ffi::GError,
668            f: glib::ffi::gpointer,
669        ) {
670            unsafe {
671                let f: &F = &*(f as *const F);
672                f(&from_glib_borrow(this), &from_glib_borrow(error))
673            }
674        }
675        unsafe {
676            let f: Box_<F> = Box_::new(f);
677            connect_raw(
678                self.as_ptr() as *mut _,
679                c"error".as_ptr(),
680                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
681                    error_trampoline::<F> as *const (),
682                )),
683                Box_::into_raw(f),
684            )
685        }
686    }
687
688    #[cfg(feature = "v4_22")]
689    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
690    #[doc(alias = "features")]
691    pub fn connect_features_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
692        unsafe extern "C" fn notify_features_trampoline<F: Fn(&Svg) + 'static>(
693            this: *mut ffi::GtkSvg,
694            _param_spec: glib::ffi::gpointer,
695            f: glib::ffi::gpointer,
696        ) {
697            unsafe {
698                let f: &F = &*(f as *const F);
699                f(&from_glib_borrow(this))
700            }
701        }
702        unsafe {
703            let f: Box_<F> = Box_::new(f);
704            connect_raw(
705                self.as_ptr() as *mut _,
706                c"notify::features".as_ptr(),
707                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
708                    notify_features_trampoline::<F> as *const (),
709                )),
710                Box_::into_raw(f),
711            )
712        }
713    }
714
715    #[cfg(feature = "v4_24")]
716    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
717    #[doc(alias = "overflow")]
718    pub fn connect_overflow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
719        unsafe extern "C" fn notify_overflow_trampoline<F: Fn(&Svg) + 'static>(
720            this: *mut ffi::GtkSvg,
721            _param_spec: glib::ffi::gpointer,
722            f: glib::ffi::gpointer,
723        ) {
724            unsafe {
725                let f: &F = &*(f as *const F);
726                f(&from_glib_borrow(this))
727            }
728        }
729        unsafe {
730            let f: Box_<F> = Box_::new(f);
731            connect_raw(
732                self.as_ptr() as *mut _,
733                c"notify::overflow".as_ptr(),
734                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
735                    notify_overflow_trampoline::<F> as *const (),
736                )),
737                Box_::into_raw(f),
738            )
739        }
740    }
741
742    #[cfg(feature = "v4_22")]
743    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
744    #[doc(alias = "playing")]
745    pub fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
746        unsafe extern "C" fn notify_playing_trampoline<F: Fn(&Svg) + 'static>(
747            this: *mut ffi::GtkSvg,
748            _param_spec: glib::ffi::gpointer,
749            f: glib::ffi::gpointer,
750        ) {
751            unsafe {
752                let f: &F = &*(f as *const F);
753                f(&from_glib_borrow(this))
754            }
755        }
756        unsafe {
757            let f: Box_<F> = Box_::new(f);
758            connect_raw(
759                self.as_ptr() as *mut _,
760                c"notify::playing".as_ptr(),
761                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
762                    notify_playing_trampoline::<F> as *const (),
763                )),
764                Box_::into_raw(f),
765            )
766        }
767    }
768
769    #[cfg(feature = "v4_22")]
770    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
771    #[doc(alias = "resource")]
772    pub fn connect_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
773        unsafe extern "C" fn notify_resource_trampoline<F: Fn(&Svg) + 'static>(
774            this: *mut ffi::GtkSvg,
775            _param_spec: glib::ffi::gpointer,
776            f: glib::ffi::gpointer,
777        ) {
778            unsafe {
779                let f: &F = &*(f as *const F);
780                f(&from_glib_borrow(this))
781            }
782        }
783        unsafe {
784            let f: Box_<F> = Box_::new(f);
785            connect_raw(
786                self.as_ptr() as *mut _,
787                c"notify::resource".as_ptr(),
788                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
789                    notify_resource_trampoline::<F> as *const (),
790                )),
791                Box_::into_raw(f),
792            )
793        }
794    }
795
796    #[cfg(feature = "v4_22")]
797    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
798    #[doc(alias = "state")]
799    pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
800        unsafe extern "C" fn notify_state_trampoline<F: Fn(&Svg) + 'static>(
801            this: *mut ffi::GtkSvg,
802            _param_spec: glib::ffi::gpointer,
803            f: glib::ffi::gpointer,
804        ) {
805            unsafe {
806                let f: &F = &*(f as *const F);
807                f(&from_glib_borrow(this))
808            }
809        }
810        unsafe {
811            let f: Box_<F> = Box_::new(f);
812            connect_raw(
813                self.as_ptr() as *mut _,
814                c"notify::state".as_ptr(),
815                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
816                    notify_state_trampoline::<F> as *const (),
817                )),
818                Box_::into_raw(f),
819            )
820        }
821    }
822
823    #[cfg(feature = "v4_24")]
824    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
825    #[doc(alias = "stylesheet")]
826    pub fn connect_stylesheet_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
827        unsafe extern "C" fn notify_stylesheet_trampoline<F: Fn(&Svg) + 'static>(
828            this: *mut ffi::GtkSvg,
829            _param_spec: glib::ffi::gpointer,
830            f: glib::ffi::gpointer,
831        ) {
832            unsafe {
833                let f: &F = &*(f as *const F);
834                f(&from_glib_borrow(this))
835            }
836        }
837        unsafe {
838            let f: Box_<F> = Box_::new(f);
839            connect_raw(
840                self.as_ptr() as *mut _,
841                c"notify::stylesheet".as_ptr(),
842                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
843                    notify_stylesheet_trampoline::<F> as *const (),
844                )),
845                Box_::into_raw(f),
846            )
847        }
848    }
849
850    #[cfg(feature = "v4_22")]
851    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
852    #[doc(alias = "weight")]
853    pub fn connect_weight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
854        unsafe extern "C" fn notify_weight_trampoline<F: Fn(&Svg) + 'static>(
855            this: *mut ffi::GtkSvg,
856            _param_spec: glib::ffi::gpointer,
857            f: glib::ffi::gpointer,
858        ) {
859            unsafe {
860                let f: &F = &*(f as *const F);
861                f(&from_glib_borrow(this))
862            }
863        }
864        unsafe {
865            let f: Box_<F> = Box_::new(f);
866            connect_raw(
867                self.as_ptr() as *mut _,
868                c"notify::weight".as_ptr(),
869                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
870                    notify_weight_trampoline::<F> as *const (),
871                )),
872                Box_::into_raw(f),
873            )
874        }
875    }
876}
877
878#[cfg(feature = "v4_22")]
879#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
880impl Default for Svg {
881    fn default() -> Self {
882        Self::new()
883    }
884}