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