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