Skip to main content

webkit6/auto/
user_media_permission_request.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// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{PermissionRequest, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A permission request for accessing user's audio/video devices.
16    ///
17    /// WebKitUserMediaPermissionRequest represents a request for
18    /// permission to decide whether WebKit should be allowed to access the user's
19    /// audio and video source devices when requested through the getUserMedia API.
20    ///
21    /// When a WebKitUserMediaPermissionRequest is not handled by the user,
22    /// it is denied by default.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `is-for-audio-device`
28    ///  Whether the media device to which the permission was requested has a microphone or not.
29    ///
30    /// Readable
31    ///
32    ///
33    /// #### `is-for-video-device`
34    ///  Whether the media device to which the permission was requested has a video capture capability or not.
35    ///
36    /// Readable
37    ///
38    /// # Implements
39    ///
40    /// [`PermissionRequestExt`][trait@crate::prelude::PermissionRequestExt]
41    #[doc(alias = "WebKitUserMediaPermissionRequest")]
42    pub struct UserMediaPermissionRequest(Object<ffi::WebKitUserMediaPermissionRequest, ffi::WebKitUserMediaPermissionRequestClass>) @implements PermissionRequest;
43
44    match fn {
45        type_ => || ffi::webkit_user_media_permission_request_get_type(),
46    }
47}
48
49impl UserMediaPermissionRequest {
50    /// Whether the media device to which the permission was requested has a microphone or not.
51    #[doc(alias = "is-for-audio-device")]
52    pub fn is_for_audio_device(&self) -> bool {
53        ObjectExt::property(self, "is-for-audio-device")
54    }
55
56    /// Whether the media device to which the permission was requested has a video capture capability or not.
57    #[doc(alias = "is-for-video-device")]
58    pub fn is_for_video_device(&self) -> bool {
59        ObjectExt::property(self, "is-for-video-device")
60    }
61
62    #[doc(alias = "is-for-audio-device")]
63    pub fn connect_is_for_audio_device_notify<F: Fn(&Self) + 'static>(
64        &self,
65        f: F,
66    ) -> SignalHandlerId {
67        unsafe extern "C" fn notify_is_for_audio_device_trampoline<
68            F: Fn(&UserMediaPermissionRequest) + 'static,
69        >(
70            this: *mut ffi::WebKitUserMediaPermissionRequest,
71            _param_spec: glib::ffi::gpointer,
72            f: glib::ffi::gpointer,
73        ) {
74            unsafe {
75                let f: &F = &*(f as *const F);
76                f(&from_glib_borrow(this))
77            }
78        }
79        unsafe {
80            let f: Box_<F> = Box_::new(f);
81            connect_raw(
82                self.as_ptr() as *mut _,
83                c"notify::is-for-audio-device".as_ptr(),
84                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
85                    notify_is_for_audio_device_trampoline::<F> as *const (),
86                )),
87                Box_::into_raw(f),
88            )
89        }
90    }
91
92    #[doc(alias = "is-for-video-device")]
93    pub fn connect_is_for_video_device_notify<F: Fn(&Self) + 'static>(
94        &self,
95        f: F,
96    ) -> SignalHandlerId {
97        unsafe extern "C" fn notify_is_for_video_device_trampoline<
98            F: Fn(&UserMediaPermissionRequest) + 'static,
99        >(
100            this: *mut ffi::WebKitUserMediaPermissionRequest,
101            _param_spec: glib::ffi::gpointer,
102            f: glib::ffi::gpointer,
103        ) {
104            unsafe {
105                let f: &F = &*(f as *const F);
106                f(&from_glib_borrow(this))
107            }
108        }
109        unsafe {
110            let f: Box_<F> = Box_::new(f);
111            connect_raw(
112                self.as_ptr() as *mut _,
113                c"notify::is-for-video-device".as_ptr(),
114                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
115                    notify_is_for_video_device_trampoline::<F> as *const (),
116                )),
117                Box_::into_raw(f),
118            )
119        }
120    }
121}