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