Skip to main content

gtk4/auto/
video.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_14")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
7use crate::GraphicsOffloadEnabled;
8use crate::{
9    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, MediaStream,
10    Overflow, Widget, ffi,
11};
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    /// Shows a [`MediaStream`][crate::MediaStream] with media controls.
21    ///
22    /// <picture>
23    ///   <source srcset="video-dark.png" media="(prefers-color-scheme: dark)">
24    ///   <img alt="An example GtkVideo" src="video.png">
25    /// </picture>
26    ///
27    /// The controls are available separately as [`MediaControls`][crate::MediaControls].
28    /// If you just want to display a video without controls, you can treat it
29    /// like any other paintable and for example put it into a [`Picture`][crate::Picture].
30    ///
31    /// [`Video`][crate::Video] aims to cover use cases such as previews, embedded animations,
32    /// etc. It supports autoplay, looping, and simple media controls. It does
33    /// not have support for video overlays, multichannel audio, device
34    /// selection, or input. If you are writing a full-fledged video player,
35    /// you may want to use the [`gdk::Paintable`][crate::gdk::Paintable] API and a media framework
36    /// such as Gstreamer directly.
37    ///
38    /// ## Properties
39    ///
40    ///
41    /// #### `autoplay`
42    ///  If the video should automatically begin playing.
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `file`
48    ///  The file played by this video if the video is playing a file.
49    ///
50    /// Readable | Writeable
51    ///
52    ///
53    /// #### `graphics-offload`
54    ///  Whether to enable graphics offload.
55    ///
56    /// Readable | Writeable
57    ///
58    ///
59    /// #### `loop`
60    ///  If new media files should be set to loop.
61    ///
62    /// Readable | Writeable
63    ///
64    ///
65    /// #### `media-stream`
66    ///  The media-stream played
67    ///
68    /// Readable | Writeable
69    /// <details><summary><h4>Widget</h4></summary>
70    ///
71    ///
72    /// #### `can-focus`
73    ///  Whether the widget or any of its descendents can accept
74    /// the input focus.
75    ///
76    /// This property is meant to be set by widget implementations,
77    /// typically in their instance init function.
78    ///
79    /// Readable | Writeable
80    ///
81    ///
82    /// #### `can-target`
83    ///  Whether the widget can receive pointer events.
84    ///
85    /// Readable | Writeable
86    ///
87    ///
88    /// #### `css-classes`
89    ///  A list of css classes applied to this widget.
90    ///
91    /// Readable | Writeable
92    ///
93    ///
94    /// #### `css-name`
95    ///  The name of this widget in the CSS tree.
96    ///
97    /// This property is meant to be set by widget implementations,
98    /// typically in their instance init function.
99    ///
100    /// Readable | Writeable | Construct Only
101    ///
102    ///
103    /// #### `cursor`
104    ///  The cursor used by @widget.
105    ///
106    /// Readable | Writeable
107    ///
108    ///
109    /// #### `focus-on-click`
110    ///  Whether the widget should grab focus when it is clicked with the mouse.
111    ///
112    /// This property is only relevant for widgets that can take focus.
113    ///
114    /// Readable | Writeable
115    ///
116    ///
117    /// #### `focusable`
118    ///  Whether this widget itself will accept the input focus.
119    ///
120    /// Readable | Writeable
121    ///
122    ///
123    /// #### `halign`
124    ///  How to distribute horizontal space if widget gets extra space.
125    ///
126    /// Readable | Writeable
127    ///
128    ///
129    /// #### `has-default`
130    ///  Whether the widget is the default widget.
131    ///
132    /// Readable
133    ///
134    ///
135    /// #### `has-focus`
136    ///  Whether the widget has the input focus.
137    ///
138    /// Readable
139    ///
140    ///
141    /// #### `has-tooltip`
142    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
143    /// signal on @widget.
144    ///
145    /// A true value indicates that @widget can have a tooltip, in this case
146    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
147    /// determine whether it will provide a tooltip or not.
148    ///
149    /// Readable | Writeable
150    ///
151    ///
152    /// #### `height-request`
153    ///  Overrides for height request of the widget.
154    ///
155    /// If this is -1, the natural request will be used.
156    ///
157    /// Readable | Writeable
158    ///
159    ///
160    /// #### `hexpand`
161    ///  Whether to expand horizontally.
162    ///
163    /// Readable | Writeable
164    ///
165    ///
166    /// #### `hexpand-set`
167    ///  Whether to use the `hexpand` property.
168    ///
169    /// Readable | Writeable
170    ///
171    ///
172    /// #### `layout-manager`
173    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
174    /// the preferred size of the widget, and allocate its children.
175    ///
176    /// This property is meant to be set by widget implementations,
177    /// typically in their instance init function.
178    ///
179    /// Readable | Writeable
180    ///
181    ///
182    /// #### `limit-events`
183    ///  Makes this widget act like a modal dialog, with respect to
184    /// event delivery.
185    ///
186    /// Global event controllers will not handle events with targets
187    /// inside the widget, unless they are set up to ignore propagation
188    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
189    ///
190    /// Readable | Writeable
191    ///
192    ///
193    /// #### `margin-bottom`
194    ///  Margin on bottom side of widget.
195    ///
196    /// This property adds margin outside of the widget's normal size
197    /// request, the margin will be added in addition to the size from
198    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
199    ///
200    /// Readable | Writeable
201    ///
202    ///
203    /// #### `margin-end`
204    ///  Margin on end of widget, horizontally.
205    ///
206    /// This property supports left-to-right and right-to-left text
207    /// directions.
208    ///
209    /// This property adds margin outside of the widget's normal size
210    /// request, the margin will be added in addition to the size from
211    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
212    ///
213    /// Readable | Writeable
214    ///
215    ///
216    /// #### `margin-start`
217    ///  Margin on start of widget, horizontally.
218    ///
219    /// This property supports left-to-right and right-to-left text
220    /// directions.
221    ///
222    /// This property adds margin outside of the widget's normal size
223    /// request, the margin will be added in addition to the size from
224    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
225    ///
226    /// Readable | Writeable
227    ///
228    ///
229    /// #### `margin-top`
230    ///  Margin on top side of widget.
231    ///
232    /// This property adds margin outside of the widget's normal size
233    /// request, the margin will be added in addition to the size from
234    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
235    ///
236    /// Readable | Writeable
237    ///
238    ///
239    /// #### `name`
240    ///  The name of the widget.
241    ///
242    /// Readable | Writeable
243    ///
244    ///
245    /// #### `opacity`
246    ///  The requested opacity of the widget.
247    ///
248    /// Readable | Writeable
249    ///
250    ///
251    /// #### `overflow`
252    ///  How content outside the widget's content area is treated.
253    ///
254    /// This property is meant to be set by widget implementations,
255    /// typically in their instance init function.
256    ///
257    /// Readable | Writeable
258    ///
259    ///
260    /// #### `parent`
261    ///  The parent widget of this widget.
262    ///
263    /// Readable
264    ///
265    ///
266    /// #### `receives-default`
267    ///  Whether the widget will receive the default action when it is focused.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `root`
273    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
274    ///
275    /// This will be `NULL` if the widget is not contained in a root widget.
276    ///
277    /// Readable
278    ///
279    ///
280    /// #### `scale-factor`
281    ///  The scale factor of the widget.
282    ///
283    /// Readable
284    ///
285    ///
286    /// #### `sensitive`
287    ///  Whether the widget responds to input.
288    ///
289    /// Readable | Writeable
290    ///
291    ///
292    /// #### `tooltip-markup`
293    ///  Sets the text of tooltip to be the given string, which is marked up
294    /// with Pango markup.
295    ///
296    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
297    ///
298    /// This is a convenience property which will take care of getting the
299    /// tooltip shown if the given string is not `NULL`:
300    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
301    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
302    /// the default signal handler.
303    ///
304    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
305    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
306    ///
307    /// Readable | Writeable
308    ///
309    ///
310    /// #### `tooltip-text`
311    ///  Sets the text of tooltip to be the given string.
312    ///
313    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
314    ///
315    /// This is a convenience property which will take care of getting the
316    /// tooltip shown if the given string is not `NULL`:
317    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
318    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
319    /// the default signal handler.
320    ///
321    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
322    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
323    ///
324    /// Readable | Writeable
325    ///
326    ///
327    /// #### `valign`
328    ///  How to distribute vertical space if widget gets extra space.
329    ///
330    /// Readable | Writeable
331    ///
332    ///
333    /// #### `vexpand`
334    ///  Whether to expand vertically.
335    ///
336    /// Readable | Writeable
337    ///
338    ///
339    /// #### `vexpand-set`
340    ///  Whether to use the `vexpand` property.
341    ///
342    /// Readable | Writeable
343    ///
344    ///
345    /// #### `visible`
346    ///  Whether the widget is visible.
347    ///
348    /// Readable | Writeable
349    ///
350    ///
351    /// #### `width-request`
352    ///  Overrides for width request of the widget.
353    ///
354    /// If this is -1, the natural request will be used.
355    ///
356    /// Readable | Writeable
357    /// </details>
358    /// <details><summary><h4>Accessible</h4></summary>
359    ///
360    ///
361    /// #### `accessible-role`
362    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
363    ///
364    /// The accessible role cannot be changed once set.
365    ///
366    /// Readable | Writeable
367    /// </details>
368    ///
369    /// # Implements
370    ///
371    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
372    #[doc(alias = "GtkVideo")]
373    pub struct Video(Object<ffi::GtkVideo, ffi::GtkVideoClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
374
375    match fn {
376        type_ => || ffi::gtk_video_get_type(),
377    }
378}
379
380impl Video {
381    /// Creates a new empty [`Video`][crate::Video].
382    ///
383    /// # Returns
384    ///
385    /// a new [`Video`][crate::Video]
386    #[doc(alias = "gtk_video_new")]
387    pub fn new() -> Video {
388        assert_initialized_main_thread!();
389        unsafe { Widget::from_glib_none(ffi::gtk_video_new()).unsafe_cast() }
390    }
391
392    /// Creates a [`Video`][crate::Video] to play back the given @file.
393    /// ## `file`
394    /// a `GFile`
395    ///
396    /// # Returns
397    ///
398    /// a new [`Video`][crate::Video]
399    #[doc(alias = "gtk_video_new_for_file")]
400    #[doc(alias = "new_for_file")]
401    pub fn for_file(file: Option<&impl IsA<gio::File>>) -> Video {
402        assert_initialized_main_thread!();
403        unsafe {
404            Widget::from_glib_none(ffi::gtk_video_new_for_file(
405                file.map(|p| p.as_ref()).to_glib_none().0,
406            ))
407            .unsafe_cast()
408        }
409    }
410
411    /// Creates a [`Video`][crate::Video] to play back the given @filename.
412    ///
413    /// This is a utility function that calls [`for_file()`][Self::for_file()],
414    /// See that function for details.
415    /// ## `filename`
416    /// filename to play back
417    ///
418    /// # Returns
419    ///
420    /// a new [`Video`][crate::Video]
421    #[doc(alias = "gtk_video_new_for_filename")]
422    #[doc(alias = "new_for_filename")]
423    pub fn for_filename(filename: Option<impl AsRef<std::path::Path>>) -> Video {
424        assert_initialized_main_thread!();
425        unsafe {
426            Widget::from_glib_none(ffi::gtk_video_new_for_filename(
427                filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
428            ))
429            .unsafe_cast()
430        }
431    }
432
433    /// Creates a [`Video`][crate::Video] to play back the given @stream.
434    /// ## `stream`
435    /// a [`MediaStream`][crate::MediaStream]
436    ///
437    /// # Returns
438    ///
439    /// a new [`Video`][crate::Video]
440    #[doc(alias = "gtk_video_new_for_media_stream")]
441    #[doc(alias = "new_for_media_stream")]
442    pub fn for_media_stream(stream: Option<&impl IsA<MediaStream>>) -> Video {
443        assert_initialized_main_thread!();
444        unsafe {
445            Widget::from_glib_none(ffi::gtk_video_new_for_media_stream(
446                stream.map(|p| p.as_ref()).to_glib_none().0,
447            ))
448            .unsafe_cast()
449        }
450    }
451
452    /// Creates a [`Video`][crate::Video] to play back the resource at the
453    /// given @resource_path.
454    ///
455    /// This is a utility function that calls [`for_file()`][Self::for_file()].
456    /// ## `resource_path`
457    /// resource path to play back
458    ///
459    /// # Returns
460    ///
461    /// a new [`Video`][crate::Video]
462    #[doc(alias = "gtk_video_new_for_resource")]
463    #[doc(alias = "new_for_resource")]
464    pub fn for_resource(resource_path: Option<&str>) -> Video {
465        assert_initialized_main_thread!();
466        unsafe {
467            Widget::from_glib_none(ffi::gtk_video_new_for_resource(
468                resource_path.to_glib_none().0,
469            ))
470            .unsafe_cast()
471        }
472    }
473
474    // rustdoc-stripper-ignore-next
475    /// Creates a new builder-pattern struct instance to construct [`Video`] objects.
476    ///
477    /// This method returns an instance of [`VideoBuilder`](crate::builders::VideoBuilder) which can be used to create [`Video`] objects.
478    pub fn builder() -> VideoBuilder {
479        VideoBuilder::new()
480    }
481
482    /// Returns [`true`] if videos have been set to loop.
483    ///
484    /// # Returns
485    ///
486    /// [`true`] if streams should autoplay
487    #[doc(alias = "gtk_video_get_autoplay")]
488    #[doc(alias = "get_autoplay")]
489    #[doc(alias = "autoplay")]
490    pub fn is_autoplay(&self) -> bool {
491        unsafe { from_glib(ffi::gtk_video_get_autoplay(self.to_glib_none().0)) }
492    }
493
494    /// Gets the file played by @self or [`None`] if not playing back
495    /// a file.
496    ///
497    /// # Returns
498    ///
499    /// The file played by @self
500    #[doc(alias = "gtk_video_get_file")]
501    #[doc(alias = "get_file")]
502    pub fn file(&self) -> Option<gio::File> {
503        unsafe { from_glib_none(ffi::gtk_video_get_file(self.to_glib_none().0)) }
504    }
505
506    /// Returns whether graphics offload is enabled.
507    ///
508    /// See [`GraphicsOffload`][crate::GraphicsOffload] for more information on graphics offload.
509    ///
510    /// # Returns
511    ///
512    /// the graphics offload status
513    #[cfg(feature = "v4_14")]
514    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
515    #[doc(alias = "gtk_video_get_graphics_offload")]
516    #[doc(alias = "get_graphics_offload")]
517    #[doc(alias = "graphics-offload")]
518    pub fn graphics_offload(&self) -> GraphicsOffloadEnabled {
519        unsafe { from_glib(ffi::gtk_video_get_graphics_offload(self.to_glib_none().0)) }
520    }
521
522    /// Returns [`true`] if videos have been set to loop.
523    ///
524    /// # Returns
525    ///
526    /// [`true`] if streams should loop
527    #[doc(alias = "gtk_video_get_loop")]
528    #[doc(alias = "get_loop")]
529    #[doc(alias = "loop")]
530    pub fn is_loop(&self) -> bool {
531        unsafe { from_glib(ffi::gtk_video_get_loop(self.to_glib_none().0)) }
532    }
533
534    /// Gets the media stream managed by @self or [`None`] if none.
535    ///
536    /// # Returns
537    ///
538    /// The media stream managed by @self
539    #[doc(alias = "gtk_video_get_media_stream")]
540    #[doc(alias = "get_media_stream")]
541    #[doc(alias = "media-stream")]
542    pub fn media_stream(&self) -> Option<MediaStream> {
543        unsafe { from_glib_none(ffi::gtk_video_get_media_stream(self.to_glib_none().0)) }
544    }
545
546    /// Sets whether @self automatically starts playback when it
547    /// becomes visible or when a new file gets loaded.
548    /// ## `autoplay`
549    /// whether media streams should autoplay
550    #[doc(alias = "gtk_video_set_autoplay")]
551    #[doc(alias = "autoplay")]
552    pub fn set_autoplay(&self, autoplay: bool) {
553        unsafe {
554            ffi::gtk_video_set_autoplay(self.to_glib_none().0, autoplay.into_glib());
555        }
556    }
557
558    /// Makes @self play the given @file.
559    /// ## `file`
560    /// the file to play
561    #[doc(alias = "gtk_video_set_file")]
562    #[doc(alias = "file")]
563    pub fn set_file(&self, file: Option<&impl IsA<gio::File>>) {
564        unsafe {
565            ffi::gtk_video_set_file(
566                self.to_glib_none().0,
567                file.map(|p| p.as_ref()).to_glib_none().0,
568            );
569        }
570    }
571
572    /// Makes @self play the given @filename.
573    ///
574    /// This is a utility function that calls gtk_video_set_file(),
575    /// ## `filename`
576    /// the filename to play
577    #[doc(alias = "gtk_video_set_filename")]
578    pub fn set_filename(&self, filename: Option<impl AsRef<std::path::Path>>) {
579        unsafe {
580            ffi::gtk_video_set_filename(
581                self.to_glib_none().0,
582                filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
583            );
584        }
585    }
586
587    /// Sets whether to enable graphics offload.
588    ///
589    /// See [`GraphicsOffload`][crate::GraphicsOffload] for more information on graphics offload.
590    /// ## `enabled`
591    /// the new graphics offload status
592    #[cfg(feature = "v4_14")]
593    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
594    #[doc(alias = "gtk_video_set_graphics_offload")]
595    #[doc(alias = "graphics-offload")]
596    pub fn set_graphics_offload(&self, enabled: GraphicsOffloadEnabled) {
597        unsafe {
598            ffi::gtk_video_set_graphics_offload(self.to_glib_none().0, enabled.into_glib());
599        }
600    }
601
602    /// Sets whether new files loaded by @self should be set to loop.
603    /// ## `loop_`
604    /// whether media streams should loop
605    #[doc(alias = "gtk_video_set_loop")]
606    #[doc(alias = "loop")]
607    pub fn set_loop(&self, loop_: bool) {
608        unsafe {
609            ffi::gtk_video_set_loop(self.to_glib_none().0, loop_.into_glib());
610        }
611    }
612
613    /// Sets the media stream to be played back.
614    ///
615    /// @self will take full control of managing the media stream. If you
616    /// want to manage a media stream yourself, consider using a
617    /// [`Picture`][crate::Picture] for display.
618    ///
619    /// If you want to display a file, consider using [`set_file()`][Self::set_file()]
620    /// instead.
621    /// ## `stream`
622    /// The media stream to play or [`None`] to unset
623    #[doc(alias = "gtk_video_set_media_stream")]
624    #[doc(alias = "media-stream")]
625    pub fn set_media_stream(&self, stream: Option<&impl IsA<MediaStream>>) {
626        unsafe {
627            ffi::gtk_video_set_media_stream(
628                self.to_glib_none().0,
629                stream.map(|p| p.as_ref()).to_glib_none().0,
630            );
631        }
632    }
633
634    /// Makes @self play the resource at the given @resource_path.
635    ///
636    /// This is a utility function that calls [`set_file()`][Self::set_file()].
637    /// ## `resource_path`
638    /// the resource to set
639    #[doc(alias = "gtk_video_set_resource")]
640    pub fn set_resource(&self, resource_path: Option<&str>) {
641        unsafe {
642            ffi::gtk_video_set_resource(self.to_glib_none().0, resource_path.to_glib_none().0);
643        }
644    }
645
646    #[doc(alias = "autoplay")]
647    pub fn connect_autoplay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
648        unsafe extern "C" fn notify_autoplay_trampoline<F: Fn(&Video) + 'static>(
649            this: *mut ffi::GtkVideo,
650            _param_spec: glib::ffi::gpointer,
651            f: glib::ffi::gpointer,
652        ) {
653            unsafe {
654                let f: &F = &*(f as *const F);
655                f(&from_glib_borrow(this))
656            }
657        }
658        unsafe {
659            let f: Box_<F> = Box_::new(f);
660            connect_raw(
661                self.as_ptr() as *mut _,
662                c"notify::autoplay".as_ptr(),
663                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
664                    notify_autoplay_trampoline::<F> as *const (),
665                )),
666                Box_::into_raw(f),
667            )
668        }
669    }
670
671    #[doc(alias = "file")]
672    pub fn connect_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
673        unsafe extern "C" fn notify_file_trampoline<F: Fn(&Video) + 'static>(
674            this: *mut ffi::GtkVideo,
675            _param_spec: glib::ffi::gpointer,
676            f: glib::ffi::gpointer,
677        ) {
678            unsafe {
679                let f: &F = &*(f as *const F);
680                f(&from_glib_borrow(this))
681            }
682        }
683        unsafe {
684            let f: Box_<F> = Box_::new(f);
685            connect_raw(
686                self.as_ptr() as *mut _,
687                c"notify::file".as_ptr(),
688                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
689                    notify_file_trampoline::<F> as *const (),
690                )),
691                Box_::into_raw(f),
692            )
693        }
694    }
695
696    #[cfg(feature = "v4_14")]
697    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
698    #[doc(alias = "graphics-offload")]
699    pub fn connect_graphics_offload_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
700        unsafe extern "C" fn notify_graphics_offload_trampoline<F: Fn(&Video) + 'static>(
701            this: *mut ffi::GtkVideo,
702            _param_spec: glib::ffi::gpointer,
703            f: glib::ffi::gpointer,
704        ) {
705            unsafe {
706                let f: &F = &*(f as *const F);
707                f(&from_glib_borrow(this))
708            }
709        }
710        unsafe {
711            let f: Box_<F> = Box_::new(f);
712            connect_raw(
713                self.as_ptr() as *mut _,
714                c"notify::graphics-offload".as_ptr(),
715                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
716                    notify_graphics_offload_trampoline::<F> as *const (),
717                )),
718                Box_::into_raw(f),
719            )
720        }
721    }
722
723    #[doc(alias = "loop")]
724    pub fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
725        unsafe extern "C" fn notify_loop_trampoline<F: Fn(&Video) + 'static>(
726            this: *mut ffi::GtkVideo,
727            _param_spec: glib::ffi::gpointer,
728            f: glib::ffi::gpointer,
729        ) {
730            unsafe {
731                let f: &F = &*(f as *const F);
732                f(&from_glib_borrow(this))
733            }
734        }
735        unsafe {
736            let f: Box_<F> = Box_::new(f);
737            connect_raw(
738                self.as_ptr() as *mut _,
739                c"notify::loop".as_ptr(),
740                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
741                    notify_loop_trampoline::<F> as *const (),
742                )),
743                Box_::into_raw(f),
744            )
745        }
746    }
747
748    #[doc(alias = "media-stream")]
749    pub fn connect_media_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
750        unsafe extern "C" fn notify_media_stream_trampoline<F: Fn(&Video) + 'static>(
751            this: *mut ffi::GtkVideo,
752            _param_spec: glib::ffi::gpointer,
753            f: glib::ffi::gpointer,
754        ) {
755            unsafe {
756                let f: &F = &*(f as *const F);
757                f(&from_glib_borrow(this))
758            }
759        }
760        unsafe {
761            let f: Box_<F> = Box_::new(f);
762            connect_raw(
763                self.as_ptr() as *mut _,
764                c"notify::media-stream".as_ptr(),
765                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
766                    notify_media_stream_trampoline::<F> as *const (),
767                )),
768                Box_::into_raw(f),
769            )
770        }
771    }
772}
773
774impl Default for Video {
775    fn default() -> Self {
776        Self::new()
777    }
778}
779
780// rustdoc-stripper-ignore-next
781/// A [builder-pattern] type to construct [`Video`] objects.
782///
783/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
784#[must_use = "The builder must be built to be used"]
785pub struct VideoBuilder {
786    builder: glib::object::ObjectBuilder<'static, Video>,
787}
788
789impl VideoBuilder {
790    fn new() -> Self {
791        Self {
792            builder: glib::object::Object::builder(),
793        }
794    }
795
796    /// If the video should automatically begin playing.
797    pub fn autoplay(self, autoplay: bool) -> Self {
798        Self {
799            builder: self.builder.property("autoplay", autoplay),
800        }
801    }
802
803    /// The file played by this video if the video is playing a file.
804    pub fn file(self, file: &impl IsA<gio::File>) -> Self {
805        Self {
806            builder: self.builder.property("file", file.clone().upcast()),
807        }
808    }
809
810    /// Whether to enable graphics offload.
811    #[cfg(feature = "v4_14")]
812    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
813    pub fn graphics_offload(self, graphics_offload: GraphicsOffloadEnabled) -> Self {
814        Self {
815            builder: self.builder.property("graphics-offload", graphics_offload),
816        }
817    }
818
819    pub fn loop_(self, loop_: bool) -> Self {
820        Self {
821            builder: self.builder.property("loop", loop_),
822        }
823    }
824
825    /// The media-stream played
826    pub fn media_stream(self, media_stream: &impl IsA<MediaStream>) -> Self {
827        Self {
828            builder: self
829                .builder
830                .property("media-stream", media_stream.clone().upcast()),
831        }
832    }
833
834    /// Whether the widget or any of its descendents can accept
835    /// the input focus.
836    ///
837    /// This property is meant to be set by widget implementations,
838    /// typically in their instance init function.
839    pub fn can_focus(self, can_focus: bool) -> Self {
840        Self {
841            builder: self.builder.property("can-focus", can_focus),
842        }
843    }
844
845    /// Whether the widget can receive pointer events.
846    pub fn can_target(self, can_target: bool) -> Self {
847        Self {
848            builder: self.builder.property("can-target", can_target),
849        }
850    }
851
852    /// A list of css classes applied to this widget.
853    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
854        Self {
855            builder: self.builder.property("css-classes", css_classes.into()),
856        }
857    }
858
859    /// The name of this widget in the CSS tree.
860    ///
861    /// This property is meant to be set by widget implementations,
862    /// typically in their instance init function.
863    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
864        Self {
865            builder: self.builder.property("css-name", css_name.into()),
866        }
867    }
868
869    /// The cursor used by @widget.
870    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
871        Self {
872            builder: self.builder.property("cursor", cursor.clone()),
873        }
874    }
875
876    /// Whether the widget should grab focus when it is clicked with the mouse.
877    ///
878    /// This property is only relevant for widgets that can take focus.
879    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
880        Self {
881            builder: self.builder.property("focus-on-click", focus_on_click),
882        }
883    }
884
885    /// Whether this widget itself will accept the input focus.
886    pub fn focusable(self, focusable: bool) -> Self {
887        Self {
888            builder: self.builder.property("focusable", focusable),
889        }
890    }
891
892    /// How to distribute horizontal space if widget gets extra space.
893    pub fn halign(self, halign: Align) -> Self {
894        Self {
895            builder: self.builder.property("halign", halign),
896        }
897    }
898
899    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
900    /// signal on @widget.
901    ///
902    /// A true value indicates that @widget can have a tooltip, in this case
903    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
904    /// determine whether it will provide a tooltip or not.
905    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
906        Self {
907            builder: self.builder.property("has-tooltip", has_tooltip),
908        }
909    }
910
911    /// Overrides for height request of the widget.
912    ///
913    /// If this is -1, the natural request will be used.
914    pub fn height_request(self, height_request: i32) -> Self {
915        Self {
916            builder: self.builder.property("height-request", height_request),
917        }
918    }
919
920    /// Whether to expand horizontally.
921    pub fn hexpand(self, hexpand: bool) -> Self {
922        Self {
923            builder: self.builder.property("hexpand", hexpand),
924        }
925    }
926
927    /// Whether to use the `hexpand` property.
928    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
929        Self {
930            builder: self.builder.property("hexpand-set", hexpand_set),
931        }
932    }
933
934    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
935    /// the preferred size of the widget, and allocate its children.
936    ///
937    /// This property is meant to be set by widget implementations,
938    /// typically in their instance init function.
939    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
940        Self {
941            builder: self
942                .builder
943                .property("layout-manager", layout_manager.clone().upcast()),
944        }
945    }
946
947    /// Makes this widget act like a modal dialog, with respect to
948    /// event delivery.
949    ///
950    /// Global event controllers will not handle events with targets
951    /// inside the widget, unless they are set up to ignore propagation
952    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
953    #[cfg(feature = "v4_18")]
954    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
955    pub fn limit_events(self, limit_events: bool) -> Self {
956        Self {
957            builder: self.builder.property("limit-events", limit_events),
958        }
959    }
960
961    /// Margin on bottom side of widget.
962    ///
963    /// This property adds margin outside of the widget's normal size
964    /// request, the margin will be added in addition to the size from
965    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
966    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
967        Self {
968            builder: self.builder.property("margin-bottom", margin_bottom),
969        }
970    }
971
972    /// Margin on end of widget, horizontally.
973    ///
974    /// This property supports left-to-right and right-to-left text
975    /// directions.
976    ///
977    /// This property adds margin outside of the widget's normal size
978    /// request, the margin will be added in addition to the size from
979    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
980    pub fn margin_end(self, margin_end: i32) -> Self {
981        Self {
982            builder: self.builder.property("margin-end", margin_end),
983        }
984    }
985
986    /// Margin on start of widget, horizontally.
987    ///
988    /// This property supports left-to-right and right-to-left text
989    /// directions.
990    ///
991    /// This property adds margin outside of the widget's normal size
992    /// request, the margin will be added in addition to the size from
993    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
994    pub fn margin_start(self, margin_start: i32) -> Self {
995        Self {
996            builder: self.builder.property("margin-start", margin_start),
997        }
998    }
999
1000    /// Margin on top side of widget.
1001    ///
1002    /// This property adds margin outside of the widget's normal size
1003    /// request, the margin will be added in addition to the size from
1004    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1005    pub fn margin_top(self, margin_top: i32) -> Self {
1006        Self {
1007            builder: self.builder.property("margin-top", margin_top),
1008        }
1009    }
1010
1011    /// The name of the widget.
1012    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1013        Self {
1014            builder: self.builder.property("name", name.into()),
1015        }
1016    }
1017
1018    /// The requested opacity of the widget.
1019    pub fn opacity(self, opacity: f64) -> Self {
1020        Self {
1021            builder: self.builder.property("opacity", opacity),
1022        }
1023    }
1024
1025    /// How content outside the widget's content area is treated.
1026    ///
1027    /// This property is meant to be set by widget implementations,
1028    /// typically in their instance init function.
1029    pub fn overflow(self, overflow: Overflow) -> Self {
1030        Self {
1031            builder: self.builder.property("overflow", overflow),
1032        }
1033    }
1034
1035    /// Whether the widget will receive the default action when it is focused.
1036    pub fn receives_default(self, receives_default: bool) -> Self {
1037        Self {
1038            builder: self.builder.property("receives-default", receives_default),
1039        }
1040    }
1041
1042    /// Whether the widget responds to input.
1043    pub fn sensitive(self, sensitive: bool) -> Self {
1044        Self {
1045            builder: self.builder.property("sensitive", sensitive),
1046        }
1047    }
1048
1049    /// Sets the text of tooltip to be the given string, which is marked up
1050    /// with Pango markup.
1051    ///
1052    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1053    ///
1054    /// This is a convenience property which will take care of getting the
1055    /// tooltip shown if the given string is not `NULL`:
1056    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1057    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1058    /// the default signal handler.
1059    ///
1060    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1061    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1062    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1063        Self {
1064            builder: self
1065                .builder
1066                .property("tooltip-markup", tooltip_markup.into()),
1067        }
1068    }
1069
1070    /// Sets the text of tooltip to be the given string.
1071    ///
1072    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1073    ///
1074    /// This is a convenience property which will take care of getting the
1075    /// tooltip shown if the given string is not `NULL`:
1076    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1077    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1078    /// the default signal handler.
1079    ///
1080    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1081    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1082    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1083        Self {
1084            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1085        }
1086    }
1087
1088    /// How to distribute vertical space if widget gets extra space.
1089    pub fn valign(self, valign: Align) -> Self {
1090        Self {
1091            builder: self.builder.property("valign", valign),
1092        }
1093    }
1094
1095    /// Whether to expand vertically.
1096    pub fn vexpand(self, vexpand: bool) -> Self {
1097        Self {
1098            builder: self.builder.property("vexpand", vexpand),
1099        }
1100    }
1101
1102    /// Whether to use the `vexpand` property.
1103    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1104        Self {
1105            builder: self.builder.property("vexpand-set", vexpand_set),
1106        }
1107    }
1108
1109    /// Whether the widget is visible.
1110    pub fn visible(self, visible: bool) -> Self {
1111        Self {
1112            builder: self.builder.property("visible", visible),
1113        }
1114    }
1115
1116    /// Overrides for width request of the widget.
1117    ///
1118    /// If this is -1, the natural request will be used.
1119    pub fn width_request(self, width_request: i32) -> Self {
1120        Self {
1121            builder: self.builder.property("width-request", width_request),
1122        }
1123    }
1124
1125    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1126    ///
1127    /// The accessible role cannot be changed once set.
1128    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1129        Self {
1130            builder: self.builder.property("accessible-role", accessible_role),
1131        }
1132    }
1133
1134    // rustdoc-stripper-ignore-next
1135    /// Build the [`Video`].
1136    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1137    pub fn build(self) -> Video {
1138        assert_initialized_main_thread!();
1139        self.builder.build()
1140    }
1141}