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    /// `.
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `features`
24    ///  Enabled features for this paintable.
25    ///
26    /// Note that features have to be set before
27    /// loading SVG data to take effect.
28    ///
29    /// Readable | Writable
30    ///
31    ///
32    /// #### `overflow`
33    ///  Whether the rendering will be clipped to the bounds.
34    ///
35    /// Readable | Writable
36    ///
37    ///
38    /// #### `playing`
39    ///  Whether the paintable is currently animating its content.
40    ///
41    /// To set this property, use the [`Svg::play()`][crate::Svg::play()] and
42    /// [`Svg::pause()`][crate::Svg::pause()] functions.
43    ///
44    /// Readable | Writable
45    ///
46    ///
47    /// #### `resource`
48    ///  Resource to load SVG data from.
49    ///
50    /// This property is meant to create a paintable
51    /// from a resource in ui files.
52    ///
53    /// Readable | Writable
54    ///
55    ///
56    /// #### `state`
57    ///  The current state of the renderer.
58    ///
59    /// This can be a number between 0 and 63.
60    ///
61    /// Readable | Writable
62    ///
63    ///
64    /// #### `stylesheet`
65    ///  A CSS stylesheet to apply to the SVG.
66    ///
67    /// Readable | Writable
68    ///
69    ///
70    /// #### `weight`
71    ///  If not set to -1, this value overrides the weight used
72    /// when rendering the paintable.
73    ///
74    /// Readable | Writable
75    ///
76    /// ## Signals
77    ///
78    ///
79    /// #### `error`
80    ///  Signals that an error occurred.
81    ///
82    /// Errors can occur both during parsing and during rendering.
83    ///
84    /// The expected error values are in the [`SvgError`][crate::SvgError] enumeration,
85    /// context information about the location of parsing errors can
86    /// be obtained with the various `gtk_svg_error` functions.
87    ///
88    /// Parsing errors are never fatal, so the parsing will resume after
89    /// the error. Errors may however cause parts of the given data or
90    /// even all of it to not be parsed at all. So it is a useful idea
91    /// to check that the parsing succeeds by connecting to this signal.
92    ///
93    /// ::: note
94    ///     This signal is emitted in the middle of parsing or rendering,
95    ///     and if you handle it, you must be careful. Logging the errors
96    ///     you receive is fine, but modifying the widget hierarchy or
97    ///     changing the paintable state definitively isn't.
98    ///
99    ///     If in doubt, defer to an idle.
100    ///
101    ///
102    /// <details><summary><h4>Paintable</h4></summary>
103    ///
104    ///
105    /// #### `invalidate-contents`
106    ///  Emitted when the contents of the @paintable change.
107    ///
108    /// Examples for such an event would be videos changing to the next frame or
109    /// the icon theme for an icon changing.
110    ///
111    ///
112    ///
113    ///
114    /// #### `invalidate-size`
115    ///  Emitted when the intrinsic size of the @paintable changes.
116    ///
117    /// This means the values reported by at least one of
118    /// [`PaintableExtManual::intrinsic_width()`][crate::gdk::prelude::PaintableExtManual::intrinsic_width()],
119    /// [`PaintableExtManual::intrinsic_height()`][crate::gdk::prelude::PaintableExtManual::intrinsic_height()] or
120    /// [`PaintableExtManual::intrinsic_aspect_ratio()`][crate::gdk::prelude::PaintableExtManual::intrinsic_aspect_ratio()]
121    /// has changed.
122    ///
123    /// Examples for such an event would be a paintable displaying
124    /// the contents of a toplevel surface being resized.
125    ///
126    ///
127    /// </details>
128    ///
129    /// # Implements
130    ///
131    /// [`trait@glib::ObjectExt`], [`trait@gdk::prelude::PaintableExt`], [`SymbolicPaintableExt`][trait@crate::prelude::SymbolicPaintableExt]
132    #[doc(alias = "GtkSvg")]
133    pub struct Svg(Object<ffi::GtkSvg, ffi::GtkSvgClass>) @implements gdk::Paintable, SymbolicPaintable;
134
135    match fn {
136        type_ => || ffi::gtk_svg_get_type(),
137    }
138}
139
140impl Svg {
141    /// Creates a new, empty SVG paintable.
142    ///
143    /// # Returns
144    ///
145    /// the paintable
146    #[doc(alias = "gtk_svg_new")]
147    pub fn new() -> Svg {
148        assert_initialized_main_thread!();
149        unsafe { from_glib_full(ffi::gtk_svg_new()) }
150    }
151
152    /// Parses the SVG data in @bytes and creates a paintable.
153    /// ## `bytes`
154    /// the data
155    ///
156    /// # Returns
157    ///
158    /// the paintable
159    #[doc(alias = "gtk_svg_new_from_bytes")]
160    #[doc(alias = "new_from_bytes")]
161    pub fn from_bytes(bytes: &glib::Bytes) -> Svg {
162        assert_initialized_main_thread!();
163        unsafe { from_glib_full(ffi::gtk_svg_new_from_bytes(bytes.to_glib_none().0)) }
164    }
165
166    /// Parses the SVG data in the resource and creates a paintable.
167    /// ## `path`
168    /// the resource path
169    ///
170    /// # Returns
171    ///
172    /// the paintable
173    #[doc(alias = "gtk_svg_new_from_resource")]
174    #[doc(alias = "new_from_resource")]
175    pub fn from_resource(path: &str) -> Svg {
176        assert_initialized_main_thread!();
177        unsafe { from_glib_full(ffi::gtk_svg_new_from_resource(path.to_glib_none().0)) }
178    }
179
180    /// Returns the currently enabled features.
181    ///
182    /// # Returns
183    ///
184    /// the enabled features
185    #[doc(alias = "gtk_svg_get_features")]
186    #[doc(alias = "get_features")]
187    pub fn features(&self) -> SvgFeatures {
188        unsafe { from_glib(ffi::gtk_svg_get_features(self.to_glib_none().0)) }
189    }
190
191    /// Gets the current overflow value.
192    ///
193    /// # Returns
194    ///
195    /// the current overflow value
196    #[cfg(feature = "v4_24")]
197    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
198    #[doc(alias = "gtk_svg_get_overflow")]
199    #[doc(alias = "get_overflow")]
200    pub fn overflow(&self) -> Overflow {
201        unsafe { from_glib(ffi::gtk_svg_get_overflow(self.to_glib_none().0)) }
202    }
203
204    /// Gets the current state of the paintable.
205    ///
206    /// # Returns
207    ///
208    /// the state
209    #[doc(alias = "gtk_svg_get_state")]
210    #[doc(alias = "get_state")]
211    pub fn state(&self) -> u32 {
212        unsafe { ffi::gtk_svg_get_state(self.to_glib_none().0) }
213    }
214
215    /// Returns a `NULL`-terminated array of
216    /// state names, if available.
217    ///
218    /// Note that the returned array and the strings
219    /// contained in it will only be valid until the
220    /// [`Svg`][crate::Svg] is cleared or reloaded, so if you
221    /// want to keep it around, you should make a copy.
222    ///
223    /// # Returns
224    ///
225    /// the state names
226    ///
227    /// ## `length`
228    /// return location for the number
229    ///   of strings that are returned
230    #[doc(alias = "gtk_svg_get_state_names")]
231    #[doc(alias = "get_state_names")]
232    pub fn state_names(&self) -> (Vec<glib::GString>, u32) {
233        unsafe {
234            let mut length = std::mem::MaybeUninit::uninit();
235            let ret = FromGlibPtrContainer::from_glib_none(ffi::gtk_svg_get_state_names(
236                self.to_glib_none().0,
237                length.as_mut_ptr(),
238            ));
239            (ret, length.assume_init())
240        }
241    }
242
243    /// Gets the CSS user stylesheet.
244    ///
245    /// # Returns
246    ///
247    /// a `GBytes` with the CSS data
248    #[cfg(feature = "v4_24")]
249    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
250    #[doc(alias = "gtk_svg_get_stylesheet")]
251    #[doc(alias = "get_stylesheet")]
252    pub fn stylesheet(&self) -> Option<glib::Bytes> {
253        unsafe { from_glib_full(ffi::gtk_svg_get_stylesheet(self.to_glib_none().0)) }
254    }
255
256    /// Gets the value of the weight property.
257    ///
258    /// # Returns
259    ///
260    /// the weight
261    #[doc(alias = "gtk_svg_get_weight")]
262    #[doc(alias = "get_weight")]
263    pub fn weight(&self) -> f64 {
264        unsafe { ffi::gtk_svg_get_weight(self.to_glib_none().0) }
265    }
266
267    /// Loads SVG content into an existing SVG paintable.
268    ///
269    /// To track errors while loading SVG content,
270    /// connect to the [`error`][struct@crate::Svg#error] signal.
271    ///
272    /// This clears any previously loaded content.
273    /// ## `bytes`
274    /// the data to load
275    #[doc(alias = "gtk_svg_load_from_bytes")]
276    pub fn load_from_bytes(&self, bytes: &glib::Bytes) {
277        unsafe {
278            ffi::gtk_svg_load_from_bytes(self.to_glib_none().0, bytes.to_glib_none().0);
279        }
280    }
281
282    /// Loads SVG content into an existing SVG paintable.
283    ///
284    /// To track errors while loading SVG content,
285    /// connect to the [`error`][struct@crate::Svg#error] signal.
286    ///
287    /// This clears any previously loaded content.
288    /// ## `path`
289    /// the resource path
290    #[doc(alias = "gtk_svg_load_from_resource")]
291    pub fn load_from_resource(&self, path: &str) {
292        unsafe {
293            ffi::gtk_svg_load_from_resource(self.to_glib_none().0, path.to_glib_none().0);
294        }
295    }
296
297    /// Stop any playing animations and state transitions.
298    ///
299    /// SvgAnimations can be paused and started repeatedly.
300    #[doc(alias = "gtk_svg_pause")]
301    pub fn pause(&self) {
302        unsafe {
303            ffi::gtk_svg_pause(self.to_glib_none().0);
304        }
305    }
306
307    /// Start playing animations and state transitions.
308    ///
309    /// SvgAnimations can be paused and started repeatedly.
310    #[doc(alias = "gtk_svg_play")]
311    pub fn play(&self) {
312        unsafe {
313            ffi::gtk_svg_play(self.to_glib_none().0);
314        }
315    }
316
317    /// Serializes the content of the renderer as SVG.
318    ///
319    /// The SVG will be similar to the orignally loaded one,
320    /// but is not guaranteed to be 100% identical.
321    ///
322    /// This function serializes the DOM, i.e. the results
323    /// of parsing the SVG. It does not reflect the effect
324    /// of applying animations.
325    ///
326    /// # Returns
327    ///
328    /// the serialized contents
329    #[doc(alias = "gtk_svg_serialize")]
330    pub fn serialize(&self) -> glib::Bytes {
331        unsafe { from_glib_full(ffi::gtk_svg_serialize(self.to_glib_none().0)) }
332    }
333
334    /// Enables or disables features of the SVG paintable.
335    ///
336    /// By default, all features are enabled.
337    ///
338    /// Note that this call only has an effect before the
339    /// SVG is loaded.
340    /// ## `features`
341    /// features to enable
342    #[doc(alias = "gtk_svg_set_features")]
343    #[doc(alias = "features")]
344    pub fn set_features(&self, features: SvgFeatures) {
345        unsafe {
346            ffi::gtk_svg_set_features(self.to_glib_none().0, features.into_glib());
347        }
348    }
349
350    /// Sets a frame clock.
351    ///
352    /// Without a frame clock, GtkSvg will not advance animations.
353    /// ## `clock`
354    /// the frame clock
355    #[doc(alias = "gtk_svg_set_frame_clock")]
356    pub fn set_frame_clock(&self, clock: &gdk::FrameClock) {
357        unsafe {
358            ffi::gtk_svg_set_frame_clock(self.to_glib_none().0, clock.to_glib_none().0);
359        }
360    }
361
362    /// Sets whether the rendering will be clipped
363    /// to the bounds.
364    ///
365    /// Clipping is expected for [`gdk::Paintable`][crate::gdk::Paintable]
366    /// semantics, so this property should not be
367    /// changed when using a [`Svg`][crate::Svg] as a paintable.
368    /// ## `overflow`
369    /// the new overflow value
370    #[cfg(feature = "v4_24")]
371    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
372    #[doc(alias = "gtk_svg_set_overflow")]
373    #[doc(alias = "overflow")]
374    pub fn set_overflow(&self, overflow: Overflow) {
375        unsafe {
376            ffi::gtk_svg_set_overflow(self.to_glib_none().0, overflow.into_glib());
377        }
378    }
379
380    /// Sets a settings object holding settinsg used when
381    /// rendering the SVG.
382    /// ## `settings`
383    /// the settings object
384    #[cfg(feature = "v4_24")]
385    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
386    #[doc(alias = "gtk_svg_set_settings")]
387    pub fn set_settings(&self, settings: Option<&Settings>) {
388        unsafe {
389            ffi::gtk_svg_set_settings(self.to_glib_none().0, settings.to_glib_none().0);
390        }
391    }
392
393    /// Sets the state of the paintable.
394    ///
395    /// If the paintable is currently playing, the state change
396    /// will apply transitions that are defined in the SVG. If
397    /// the paintable is not playing, the state change will take
398    /// effect instantaneously.
399    /// ## `state`
400    /// the state to set, as a value between 0 and 63
401    #[doc(alias = "gtk_svg_set_state")]
402    #[doc(alias = "state")]
403    pub fn set_state(&self, state: u32) {
404        unsafe {
405            ffi::gtk_svg_set_state(self.to_glib_none().0, state);
406        }
407    }
408
409    /// Sets a CSS user stylesheet to use.
410    ///
411    /// Note that styles are applied at load time,
412    /// so this function must be called before
413    /// loading SVG.
414    /// ## `bytes`
415    /// CSS data
416    #[cfg(feature = "v4_24")]
417    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
418    #[doc(alias = "gtk_svg_set_stylesheet")]
419    #[doc(alias = "stylesheet")]
420    pub fn set_stylesheet(&self, bytes: Option<&glib::Bytes>) {
421        unsafe {
422            ffi::gtk_svg_set_stylesheet(self.to_glib_none().0, bytes.to_glib_none().0);
423        }
424    }
425
426    /// Sets the weight that is used when rendering.
427    ///
428    /// The weight affects the effective linewidth when stroking
429    /// paths.
430    ///
431    /// The default value of -1 means to use the font weight
432    /// from CSS.
433    /// ## `weight`
434    /// the font weight, as a value between -1 and 1000
435    #[doc(alias = "gtk_svg_set_weight")]
436    #[doc(alias = "weight")]
437    pub fn set_weight(&self, weight: f64) {
438        unsafe {
439            ffi::gtk_svg_set_weight(self.to_glib_none().0, weight);
440        }
441    }
442
443    /// Serializes the paintable, and saves the result to a file.
444    /// ## `filename`
445    /// the file to save to
446    ///
447    /// # Returns
448    ///
449    /// true, unless an error occurred
450    #[doc(alias = "gtk_svg_write_to_file")]
451    pub fn write_to_file(&self, filename: &str) -> Result<(), glib::Error> {
452        unsafe {
453            let mut error = std::ptr::null_mut();
454            let is_ok = ffi::gtk_svg_write_to_file(
455                self.to_glib_none().0,
456                filename.to_glib_none().0,
457                &mut error,
458            );
459            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
460            if error.is_null() {
461                Ok(())
462            } else {
463                Err(from_glib_full(error))
464            }
465        }
466    }
467
468    /// Whether the paintable is currently animating its content.
469    ///
470    /// To set this property, use the [`play()`][Self::play()] and
471    /// [`pause()`][Self::pause()] functions.
472    #[cfg(feature = "v4_22")]
473    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
474    pub fn is_playing(&self) -> bool {
475        ObjectExt::property(self, "playing")
476    }
477
478    /// Whether the paintable is currently animating its content.
479    ///
480    /// To set this property, use the [`play()`][Self::play()] and
481    /// [`pause()`][Self::pause()] functions.
482    #[cfg(feature = "v4_22")]
483    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
484    pub fn set_playing(&self, playing: bool) {
485        ObjectExt::set_property(self, "playing", playing)
486    }
487
488    /// Resource to load SVG data from.
489    ///
490    /// This property is meant to create a paintable
491    /// from a resource in ui files.
492    #[cfg(feature = "v4_22")]
493    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
494    pub fn resource(&self) -> Option<glib::GString> {
495        ObjectExt::property(self, "resource")
496    }
497
498    /// Resource to load SVG data from.
499    ///
500    /// This property is meant to create a paintable
501    /// from a resource in ui files.
502    #[cfg(feature = "v4_22")]
503    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
504    pub fn set_resource(&self, resource: Option<&str>) {
505        ObjectExt::set_property(self, "resource", resource)
506    }
507
508    /// Signals that an error occurred.
509    ///
510    /// Errors can occur both during parsing and during rendering.
511    ///
512    /// The expected error values are in the [`SvgError`][crate::SvgError] enumeration,
513    /// context information about the location of parsing errors can
514    /// be obtained with the various `gtk_svg_error` functions.
515    ///
516    /// Parsing errors are never fatal, so the parsing will resume after
517    /// the error. Errors may however cause parts of the given data or
518    /// even all of it to not be parsed at all. So it is a useful idea
519    /// to check that the parsing succeeds by connecting to this signal.
520    ///
521    /// ::: note
522    ///     This signal is emitted in the middle of parsing or rendering,
523    ///     and if you handle it, you must be careful. Logging the errors
524    ///     you receive is fine, but modifying the widget hierarchy or
525    ///     changing the paintable state definitively isn't.
526    ///
527    ///     If in doubt, defer to an idle.
528    /// ## `error`
529    /// the error
530    #[cfg(feature = "v4_22")]
531    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
532    #[doc(alias = "error")]
533    pub fn connect_error<F: Fn(&Self, &glib::Error) + 'static>(&self, f: F) -> SignalHandlerId {
534        unsafe extern "C" fn error_trampoline<F: Fn(&Svg, &glib::Error) + 'static>(
535            this: *mut ffi::GtkSvg,
536            error: *mut glib::ffi::GError,
537            f: glib::ffi::gpointer,
538        ) {
539            unsafe {
540                let f: &F = &*(f as *const F);
541                f(&from_glib_borrow(this), &from_glib_borrow(error))
542            }
543        }
544        unsafe {
545            let f: Box_<F> = Box_::new(f);
546            connect_raw(
547                self.as_ptr() as *mut _,
548                c"error".as_ptr(),
549                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
550                    error_trampoline::<F> as *const (),
551                )),
552                Box_::into_raw(f),
553            )
554        }
555    }
556
557    #[cfg(feature = "v4_22")]
558    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
559    #[doc(alias = "features")]
560    pub fn connect_features_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
561        unsafe extern "C" fn notify_features_trampoline<F: Fn(&Svg) + 'static>(
562            this: *mut ffi::GtkSvg,
563            _param_spec: glib::ffi::gpointer,
564            f: glib::ffi::gpointer,
565        ) {
566            unsafe {
567                let f: &F = &*(f as *const F);
568                f(&from_glib_borrow(this))
569            }
570        }
571        unsafe {
572            let f: Box_<F> = Box_::new(f);
573            connect_raw(
574                self.as_ptr() as *mut _,
575                c"notify::features".as_ptr(),
576                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577                    notify_features_trampoline::<F> as *const (),
578                )),
579                Box_::into_raw(f),
580            )
581        }
582    }
583
584    #[cfg(feature = "v4_24")]
585    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
586    #[doc(alias = "overflow")]
587    pub fn connect_overflow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
588        unsafe extern "C" fn notify_overflow_trampoline<F: Fn(&Svg) + 'static>(
589            this: *mut ffi::GtkSvg,
590            _param_spec: glib::ffi::gpointer,
591            f: glib::ffi::gpointer,
592        ) {
593            unsafe {
594                let f: &F = &*(f as *const F);
595                f(&from_glib_borrow(this))
596            }
597        }
598        unsafe {
599            let f: Box_<F> = Box_::new(f);
600            connect_raw(
601                self.as_ptr() as *mut _,
602                c"notify::overflow".as_ptr(),
603                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
604                    notify_overflow_trampoline::<F> as *const (),
605                )),
606                Box_::into_raw(f),
607            )
608        }
609    }
610
611    #[cfg(feature = "v4_22")]
612    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
613    #[doc(alias = "playing")]
614    pub fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
615        unsafe extern "C" fn notify_playing_trampoline<F: Fn(&Svg) + 'static>(
616            this: *mut ffi::GtkSvg,
617            _param_spec: glib::ffi::gpointer,
618            f: glib::ffi::gpointer,
619        ) {
620            unsafe {
621                let f: &F = &*(f as *const F);
622                f(&from_glib_borrow(this))
623            }
624        }
625        unsafe {
626            let f: Box_<F> = Box_::new(f);
627            connect_raw(
628                self.as_ptr() as *mut _,
629                c"notify::playing".as_ptr(),
630                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
631                    notify_playing_trampoline::<F> as *const (),
632                )),
633                Box_::into_raw(f),
634            )
635        }
636    }
637
638    #[cfg(feature = "v4_22")]
639    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
640    #[doc(alias = "resource")]
641    pub fn connect_resource_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
642        unsafe extern "C" fn notify_resource_trampoline<F: Fn(&Svg) + 'static>(
643            this: *mut ffi::GtkSvg,
644            _param_spec: glib::ffi::gpointer,
645            f: glib::ffi::gpointer,
646        ) {
647            unsafe {
648                let f: &F = &*(f as *const F);
649                f(&from_glib_borrow(this))
650            }
651        }
652        unsafe {
653            let f: Box_<F> = Box_::new(f);
654            connect_raw(
655                self.as_ptr() as *mut _,
656                c"notify::resource".as_ptr(),
657                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
658                    notify_resource_trampoline::<F> as *const (),
659                )),
660                Box_::into_raw(f),
661            )
662        }
663    }
664
665    #[cfg(feature = "v4_22")]
666    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
667    #[doc(alias = "state")]
668    pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
669        unsafe extern "C" fn notify_state_trampoline<F: Fn(&Svg) + 'static>(
670            this: *mut ffi::GtkSvg,
671            _param_spec: glib::ffi::gpointer,
672            f: glib::ffi::gpointer,
673        ) {
674            unsafe {
675                let f: &F = &*(f as *const F);
676                f(&from_glib_borrow(this))
677            }
678        }
679        unsafe {
680            let f: Box_<F> = Box_::new(f);
681            connect_raw(
682                self.as_ptr() as *mut _,
683                c"notify::state".as_ptr(),
684                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
685                    notify_state_trampoline::<F> as *const (),
686                )),
687                Box_::into_raw(f),
688            )
689        }
690    }
691
692    #[cfg(feature = "v4_24")]
693    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
694    #[doc(alias = "stylesheet")]
695    pub fn connect_stylesheet_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
696        unsafe extern "C" fn notify_stylesheet_trampoline<F: Fn(&Svg) + 'static>(
697            this: *mut ffi::GtkSvg,
698            _param_spec: glib::ffi::gpointer,
699            f: glib::ffi::gpointer,
700        ) {
701            unsafe {
702                let f: &F = &*(f as *const F);
703                f(&from_glib_borrow(this))
704            }
705        }
706        unsafe {
707            let f: Box_<F> = Box_::new(f);
708            connect_raw(
709                self.as_ptr() as *mut _,
710                c"notify::stylesheet".as_ptr(),
711                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
712                    notify_stylesheet_trampoline::<F> as *const (),
713                )),
714                Box_::into_raw(f),
715            )
716        }
717    }
718
719    #[cfg(feature = "v4_22")]
720    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
721    #[doc(alias = "weight")]
722    pub fn connect_weight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
723        unsafe extern "C" fn notify_weight_trampoline<F: Fn(&Svg) + 'static>(
724            this: *mut ffi::GtkSvg,
725            _param_spec: glib::ffi::gpointer,
726            f: glib::ffi::gpointer,
727        ) {
728            unsafe {
729                let f: &F = &*(f as *const F);
730                f(&from_glib_borrow(this))
731            }
732        }
733        unsafe {
734            let f: Box_<F> = Box_::new(f);
735            connect_raw(
736                self.as_ptr() as *mut _,
737                c"notify::weight".as_ptr(),
738                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
739                    notify_weight_trampoline::<F> as *const (),
740                )),
741                Box_::into_raw(f),
742            )
743        }
744    }
745}
746
747#[cfg(feature = "v4_22")]
748#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
749impl Default for Svg {
750    fn default() -> Self {
751        Self::new()
752    }
753}