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 gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{Bus, Object}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem::transmute}; |
13 | |
14 | glib::wrapper! { |
15 | #[doc (alias = "GstDeviceMonitor" )] |
16 | pub struct DeviceMonitor(Object<ffi::GstDeviceMonitor, ffi::GstDeviceMonitorClass>) @extends Object; |
17 | |
18 | match fn { |
19 | type_ => || ffi::gst_device_monitor_get_type(), |
20 | } |
21 | } |
22 | |
23 | impl DeviceMonitor { |
24 | pub const NONE: Option<&'static DeviceMonitor> = None; |
25 | |
26 | #[doc (alias = "gst_device_monitor_new" )] |
27 | pub fn new() -> DeviceMonitor { |
28 | assert_initialized_main_thread!(); |
29 | unsafe { from_glib_full(ptr:ffi::gst_device_monitor_new()) } |
30 | } |
31 | } |
32 | |
33 | impl Default for DeviceMonitor { |
34 | fn default() -> Self { |
35 | Self::new() |
36 | } |
37 | } |
38 | |
39 | unsafe impl Send for DeviceMonitor {} |
40 | unsafe impl Sync for DeviceMonitor {} |
41 | |
42 | mod sealed { |
43 | pub trait Sealed {} |
44 | impl<T: super::IsA<super::DeviceMonitor>> Sealed for T {} |
45 | } |
46 | |
47 | pub trait DeviceMonitorExt: IsA<DeviceMonitor> + sealed::Sealed + 'static { |
48 | #[doc (alias = "gst_device_monitor_get_bus" )] |
49 | #[doc (alias = "get_bus" )] |
50 | fn bus(&self) -> Bus { |
51 | unsafe { |
52 | from_glib_full(ffi::gst_device_monitor_get_bus( |
53 | self.as_ref().to_glib_none().0, |
54 | )) |
55 | } |
56 | } |
57 | |
58 | #[doc (alias = "gst_device_monitor_get_providers" )] |
59 | #[doc (alias = "get_providers" )] |
60 | fn providers(&self) -> Vec<glib::GString> { |
61 | unsafe { |
62 | FromGlibPtrContainer::from_glib_full(ffi::gst_device_monitor_get_providers( |
63 | self.as_ref().to_glib_none().0, |
64 | )) |
65 | } |
66 | } |
67 | |
68 | #[doc (alias = "gst_device_monitor_get_show_all_devices" )] |
69 | #[doc (alias = "get_show_all_devices" )] |
70 | fn shows_all_devices(&self) -> bool { |
71 | unsafe { |
72 | from_glib(ffi::gst_device_monitor_get_show_all_devices( |
73 | self.as_ref().to_glib_none().0, |
74 | )) |
75 | } |
76 | } |
77 | |
78 | #[doc (alias = "gst_device_monitor_set_show_all_devices" )] |
79 | fn set_show_all_devices(&self, show_all: bool) { |
80 | unsafe { |
81 | ffi::gst_device_monitor_set_show_all_devices( |
82 | self.as_ref().to_glib_none().0, |
83 | show_all.into_glib(), |
84 | ); |
85 | } |
86 | } |
87 | |
88 | #[doc (alias = "gst_device_monitor_start" )] |
89 | fn start(&self) -> Result<(), glib::error::BoolError> { |
90 | unsafe { |
91 | glib::result_from_gboolean!( |
92 | ffi::gst_device_monitor_start(self.as_ref().to_glib_none().0), |
93 | "Failed to start" |
94 | ) |
95 | } |
96 | } |
97 | |
98 | #[doc (alias = "gst_device_monitor_stop" )] |
99 | fn stop(&self) { |
100 | unsafe { |
101 | ffi::gst_device_monitor_stop(self.as_ref().to_glib_none().0); |
102 | } |
103 | } |
104 | |
105 | #[doc (alias = "show-all" )] |
106 | fn shows_all(&self) -> bool { |
107 | ObjectExt::property(self.as_ref(), "show-all" ) |
108 | } |
109 | |
110 | #[doc (alias = "show-all" )] |
111 | fn set_show_all(&self, show_all: bool) { |
112 | ObjectExt::set_property(self.as_ref(), "show-all" , show_all) |
113 | } |
114 | |
115 | #[doc (alias = "show-all" )] |
116 | fn connect_show_all_notify<F: Fn(&Self) + Send + Sync + 'static>( |
117 | &self, |
118 | f: F, |
119 | ) -> SignalHandlerId { |
120 | unsafe extern "C" fn notify_show_all_trampoline< |
121 | P: IsA<DeviceMonitor>, |
122 | F: Fn(&P) + Send + Sync + 'static, |
123 | >( |
124 | this: *mut ffi::GstDeviceMonitor, |
125 | _param_spec: glib::ffi::gpointer, |
126 | f: glib::ffi::gpointer, |
127 | ) { |
128 | let f: &F = &*(f as *const F); |
129 | f(DeviceMonitor::from_glib_borrow(this).unsafe_cast_ref()) |
130 | } |
131 | unsafe { |
132 | let f: Box_<F> = Box_::new(f); |
133 | connect_raw( |
134 | self.as_ptr() as *mut _, |
135 | b"notify::show-all \0" .as_ptr() as *const _, |
136 | Some(transmute::<_, unsafe extern "C" fn()>( |
137 | notify_show_all_trampoline::<Self, F> as *const (), |
138 | )), |
139 | Box_::into_raw(f), |
140 | ) |
141 | } |
142 | } |
143 | } |
144 | |
145 | impl<O: IsA<DeviceMonitor>> DeviceMonitorExt for O {} |
146 | |