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