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 use crate::AsyncResult;
6 use crate::Cancellable;
7 use crate::DriveStartFlags;
8 use crate::DriveStartStopType;
9 use crate::Icon;
10 use crate::MountOperation;
11 use crate::MountUnmountFlags;
12 use crate::Volume;
13 use glib::object::Cast;
14 use glib::object::IsA;
15 use glib::signal::connect_raw;
16 use glib::signal::SignalHandlerId;
17 use glib::translate::*;
18 use std::boxed::Box as Box_;
19 use std::fmt;
20 use std::mem::transmute;
21 use std::pin::Pin;
22 use std::ptr;
23 
24 glib::wrapper! {
25     #[doc(alias = "GDrive")]
26     pub struct Drive(Interface<ffi::GDrive, ffi::GDriveIface>);
27 
28     match fn {
29         type_ => || ffi::g_drive_get_type(),
30     }
31 }
32 
33 pub const NONE_DRIVE: Option<&Drive> = None;
34 
35 pub trait DriveExt: 'static {
36     #[doc(alias = "g_drive_can_eject")]
can_eject(&self) -> bool37     fn can_eject(&self) -> bool;
38 
39     #[doc(alias = "g_drive_can_poll_for_media")]
can_poll_for_media(&self) -> bool40     fn can_poll_for_media(&self) -> bool;
41 
42     #[doc(alias = "g_drive_can_start")]
can_start(&self) -> bool43     fn can_start(&self) -> bool;
44 
45     #[doc(alias = "g_drive_can_start_degraded")]
can_start_degraded(&self) -> bool46     fn can_start_degraded(&self) -> bool;
47 
48     #[doc(alias = "g_drive_can_stop")]
can_stop(&self) -> bool49     fn can_stop(&self) -> bool;
50 
51     #[doc(alias = "g_drive_eject_with_operation")]
eject_with_operation< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )52     fn eject_with_operation<
53         P: IsA<MountOperation>,
54         Q: IsA<Cancellable>,
55         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
56     >(
57         &self,
58         flags: MountUnmountFlags,
59         mount_operation: Option<&P>,
60         cancellable: Option<&Q>,
61         callback: R,
62     );
63 
eject_with_operation_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>64     fn eject_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
65         &self,
66         flags: MountUnmountFlags,
67         mount_operation: Option<&P>,
68     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
69 
70     #[doc(alias = "g_drive_enumerate_identifiers")]
enumerate_identifiers(&self) -> Vec<glib::GString>71     fn enumerate_identifiers(&self) -> Vec<glib::GString>;
72 
73     #[doc(alias = "g_drive_get_icon")]
74     #[doc(alias = "get_icon")]
icon(&self) -> Icon75     fn icon(&self) -> Icon;
76 
77     #[doc(alias = "g_drive_get_identifier")]
78     #[doc(alias = "get_identifier")]
identifier(&self, kind: &str) -> Option<glib::GString>79     fn identifier(&self, kind: &str) -> Option<glib::GString>;
80 
81     #[doc(alias = "g_drive_get_name")]
82     #[doc(alias = "get_name")]
name(&self) -> glib::GString83     fn name(&self) -> glib::GString;
84 
85     #[doc(alias = "g_drive_get_sort_key")]
86     #[doc(alias = "get_sort_key")]
sort_key(&self) -> Option<glib::GString>87     fn sort_key(&self) -> Option<glib::GString>;
88 
89     #[doc(alias = "g_drive_get_start_stop_type")]
90     #[doc(alias = "get_start_stop_type")]
start_stop_type(&self) -> DriveStartStopType91     fn start_stop_type(&self) -> DriveStartStopType;
92 
93     #[doc(alias = "g_drive_get_symbolic_icon")]
94     #[doc(alias = "get_symbolic_icon")]
symbolic_icon(&self) -> Icon95     fn symbolic_icon(&self) -> Icon;
96 
97     #[doc(alias = "g_drive_get_volumes")]
98     #[doc(alias = "get_volumes")]
volumes(&self) -> Vec<Volume>99     fn volumes(&self) -> Vec<Volume>;
100 
101     #[doc(alias = "g_drive_has_media")]
has_media(&self) -> bool102     fn has_media(&self) -> bool;
103 
104     #[doc(alias = "g_drive_has_volumes")]
has_volumes(&self) -> bool105     fn has_volumes(&self) -> bool;
106 
107     #[doc(alias = "g_drive_is_media_check_automatic")]
is_media_check_automatic(&self) -> bool108     fn is_media_check_automatic(&self) -> bool;
109 
110     #[doc(alias = "g_drive_is_media_removable")]
is_media_removable(&self) -> bool111     fn is_media_removable(&self) -> bool;
112 
113     #[cfg(any(feature = "v2_50", feature = "dox"))]
114     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))]
115     #[doc(alias = "g_drive_is_removable")]
is_removable(&self) -> bool116     fn is_removable(&self) -> bool;
117 
118     #[doc(alias = "g_drive_poll_for_media")]
poll_for_media<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, )119     fn poll_for_media<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(
120         &self,
121         cancellable: Option<&P>,
122         callback: Q,
123     );
124 
poll_for_media_future( &self, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>125     fn poll_for_media_future(
126         &self,
127     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
128 
129     #[doc(alias = "g_drive_start")]
start< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )130     fn start<
131         P: IsA<MountOperation>,
132         Q: IsA<Cancellable>,
133         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
134     >(
135         &self,
136         flags: DriveStartFlags,
137         mount_operation: Option<&P>,
138         cancellable: Option<&Q>,
139         callback: R,
140     );
141 
start_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>142     fn start_future<P: IsA<MountOperation> + Clone + 'static>(
143         &self,
144         flags: DriveStartFlags,
145         mount_operation: Option<&P>,
146     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
147 
148     #[doc(alias = "g_drive_stop")]
stop< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )149     fn stop<
150         P: IsA<MountOperation>,
151         Q: IsA<Cancellable>,
152         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
153     >(
154         &self,
155         flags: MountUnmountFlags,
156         mount_operation: Option<&P>,
157         cancellable: Option<&Q>,
158         callback: R,
159     );
160 
stop_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>161     fn stop_future<P: IsA<MountOperation> + Clone + 'static>(
162         &self,
163         flags: MountUnmountFlags,
164         mount_operation: Option<&P>,
165     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
166 
167     #[doc(alias = "changed")]
connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId168     fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
169 
170     #[doc(alias = "disconnected")]
connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId171     fn connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
172 
173     #[doc(alias = "eject-button")]
connect_eject_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId174     fn connect_eject_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
175 
176     #[doc(alias = "stop-button")]
connect_stop_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId177     fn connect_stop_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
178 }
179 
180 impl<O: IsA<Drive>> DriveExt for O {
can_eject(&self) -> bool181     fn can_eject(&self) -> bool {
182         unsafe { from_glib(ffi::g_drive_can_eject(self.as_ref().to_glib_none().0)) }
183     }
184 
can_poll_for_media(&self) -> bool185     fn can_poll_for_media(&self) -> bool {
186         unsafe {
187             from_glib(ffi::g_drive_can_poll_for_media(
188                 self.as_ref().to_glib_none().0,
189             ))
190         }
191     }
192 
can_start(&self) -> bool193     fn can_start(&self) -> bool {
194         unsafe { from_glib(ffi::g_drive_can_start(self.as_ref().to_glib_none().0)) }
195     }
196 
can_start_degraded(&self) -> bool197     fn can_start_degraded(&self) -> bool {
198         unsafe {
199             from_glib(ffi::g_drive_can_start_degraded(
200                 self.as_ref().to_glib_none().0,
201             ))
202         }
203     }
204 
can_stop(&self) -> bool205     fn can_stop(&self) -> bool {
206         unsafe { from_glib(ffi::g_drive_can_stop(self.as_ref().to_glib_none().0)) }
207     }
208 
eject_with_operation< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )209     fn eject_with_operation<
210         P: IsA<MountOperation>,
211         Q: IsA<Cancellable>,
212         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
213     >(
214         &self,
215         flags: MountUnmountFlags,
216         mount_operation: Option<&P>,
217         cancellable: Option<&Q>,
218         callback: R,
219     ) {
220         let user_data: Box_<R> = Box_::new(callback);
221         unsafe extern "C" fn eject_with_operation_trampoline<
222             R: FnOnce(Result<(), glib::Error>) + Send + 'static,
223         >(
224             _source_object: *mut glib::gobject_ffi::GObject,
225             res: *mut crate::ffi::GAsyncResult,
226             user_data: glib::ffi::gpointer,
227         ) {
228             let mut error = ptr::null_mut();
229             let _ =
230                 ffi::g_drive_eject_with_operation_finish(_source_object as *mut _, res, &mut error);
231             let result = if error.is_null() {
232                 Ok(())
233             } else {
234                 Err(from_glib_full(error))
235             };
236             let callback: Box_<R> = Box_::from_raw(user_data as *mut _);
237             callback(result);
238         }
239         let callback = eject_with_operation_trampoline::<R>;
240         unsafe {
241             ffi::g_drive_eject_with_operation(
242                 self.as_ref().to_glib_none().0,
243                 flags.into_glib(),
244                 mount_operation.map(|p| p.as_ref()).to_glib_none().0,
245                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
246                 Some(callback),
247                 Box_::into_raw(user_data) as *mut _,
248             );
249         }
250     }
251 
eject_with_operation_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>252     fn eject_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
253         &self,
254         flags: MountUnmountFlags,
255         mount_operation: Option<&P>,
256     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
257         let mount_operation = mount_operation.map(ToOwned::to_owned);
258         Box_::pin(crate::GioFuture::new(
259             self,
260             move |obj, cancellable, send| {
261                 obj.eject_with_operation(
262                     flags,
263                     mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
264                     Some(cancellable),
265                     move |res| {
266                         send.resolve(res);
267                     },
268                 );
269             },
270         ))
271     }
272 
enumerate_identifiers(&self) -> Vec<glib::GString>273     fn enumerate_identifiers(&self) -> Vec<glib::GString> {
274         unsafe {
275             FromGlibPtrContainer::from_glib_full(ffi::g_drive_enumerate_identifiers(
276                 self.as_ref().to_glib_none().0,
277             ))
278         }
279     }
280 
icon(&self) -> Icon281     fn icon(&self) -> Icon {
282         unsafe { from_glib_full(ffi::g_drive_get_icon(self.as_ref().to_glib_none().0)) }
283     }
284 
identifier(&self, kind: &str) -> Option<glib::GString>285     fn identifier(&self, kind: &str) -> Option<glib::GString> {
286         unsafe {
287             from_glib_full(ffi::g_drive_get_identifier(
288                 self.as_ref().to_glib_none().0,
289                 kind.to_glib_none().0,
290             ))
291         }
292     }
293 
name(&self) -> glib::GString294     fn name(&self) -> glib::GString {
295         unsafe { from_glib_full(ffi::g_drive_get_name(self.as_ref().to_glib_none().0)) }
296     }
297 
sort_key(&self) -> Option<glib::GString>298     fn sort_key(&self) -> Option<glib::GString> {
299         unsafe { from_glib_none(ffi::g_drive_get_sort_key(self.as_ref().to_glib_none().0)) }
300     }
301 
start_stop_type(&self) -> DriveStartStopType302     fn start_stop_type(&self) -> DriveStartStopType {
303         unsafe {
304             from_glib(ffi::g_drive_get_start_stop_type(
305                 self.as_ref().to_glib_none().0,
306             ))
307         }
308     }
309 
symbolic_icon(&self) -> Icon310     fn symbolic_icon(&self) -> Icon {
311         unsafe {
312             from_glib_full(ffi::g_drive_get_symbolic_icon(
313                 self.as_ref().to_glib_none().0,
314             ))
315         }
316     }
317 
volumes(&self) -> Vec<Volume>318     fn volumes(&self) -> Vec<Volume> {
319         unsafe {
320             FromGlibPtrContainer::from_glib_full(ffi::g_drive_get_volumes(
321                 self.as_ref().to_glib_none().0,
322             ))
323         }
324     }
325 
has_media(&self) -> bool326     fn has_media(&self) -> bool {
327         unsafe { from_glib(ffi::g_drive_has_media(self.as_ref().to_glib_none().0)) }
328     }
329 
has_volumes(&self) -> bool330     fn has_volumes(&self) -> bool {
331         unsafe { from_glib(ffi::g_drive_has_volumes(self.as_ref().to_glib_none().0)) }
332     }
333 
is_media_check_automatic(&self) -> bool334     fn is_media_check_automatic(&self) -> bool {
335         unsafe {
336             from_glib(ffi::g_drive_is_media_check_automatic(
337                 self.as_ref().to_glib_none().0,
338             ))
339         }
340     }
341 
is_media_removable(&self) -> bool342     fn is_media_removable(&self) -> bool {
343         unsafe {
344             from_glib(ffi::g_drive_is_media_removable(
345                 self.as_ref().to_glib_none().0,
346             ))
347         }
348     }
349 
350     #[cfg(any(feature = "v2_50", feature = "dox"))]
351     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))]
is_removable(&self) -> bool352     fn is_removable(&self) -> bool {
353         unsafe { from_glib(ffi::g_drive_is_removable(self.as_ref().to_glib_none().0)) }
354     }
355 
poll_for_media<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, )356     fn poll_for_media<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(
357         &self,
358         cancellable: Option<&P>,
359         callback: Q,
360     ) {
361         let user_data: Box_<Q> = Box_::new(callback);
362         unsafe extern "C" fn poll_for_media_trampoline<
363             Q: FnOnce(Result<(), glib::Error>) + Send + 'static,
364         >(
365             _source_object: *mut glib::gobject_ffi::GObject,
366             res: *mut crate::ffi::GAsyncResult,
367             user_data: glib::ffi::gpointer,
368         ) {
369             let mut error = ptr::null_mut();
370             let _ = ffi::g_drive_poll_for_media_finish(_source_object as *mut _, res, &mut error);
371             let result = if error.is_null() {
372                 Ok(())
373             } else {
374                 Err(from_glib_full(error))
375             };
376             let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
377             callback(result);
378         }
379         let callback = poll_for_media_trampoline::<Q>;
380         unsafe {
381             ffi::g_drive_poll_for_media(
382                 self.as_ref().to_glib_none().0,
383                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
384                 Some(callback),
385                 Box_::into_raw(user_data) as *mut _,
386             );
387         }
388     }
389 
poll_for_media_future( &self, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>390     fn poll_for_media_future(
391         &self,
392     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
393         Box_::pin(crate::GioFuture::new(
394             self,
395             move |obj, cancellable, send| {
396                 obj.poll_for_media(Some(cancellable), move |res| {
397                     send.resolve(res);
398                 });
399             },
400         ))
401     }
402 
start< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )403     fn start<
404         P: IsA<MountOperation>,
405         Q: IsA<Cancellable>,
406         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
407     >(
408         &self,
409         flags: DriveStartFlags,
410         mount_operation: Option<&P>,
411         cancellable: Option<&Q>,
412         callback: R,
413     ) {
414         let user_data: Box_<R> = Box_::new(callback);
415         unsafe extern "C" fn start_trampoline<
416             R: FnOnce(Result<(), glib::Error>) + Send + 'static,
417         >(
418             _source_object: *mut glib::gobject_ffi::GObject,
419             res: *mut crate::ffi::GAsyncResult,
420             user_data: glib::ffi::gpointer,
421         ) {
422             let mut error = ptr::null_mut();
423             let _ = ffi::g_drive_start_finish(_source_object as *mut _, res, &mut error);
424             let result = if error.is_null() {
425                 Ok(())
426             } else {
427                 Err(from_glib_full(error))
428             };
429             let callback: Box_<R> = Box_::from_raw(user_data as *mut _);
430             callback(result);
431         }
432         let callback = start_trampoline::<R>;
433         unsafe {
434             ffi::g_drive_start(
435                 self.as_ref().to_glib_none().0,
436                 flags.into_glib(),
437                 mount_operation.map(|p| p.as_ref()).to_glib_none().0,
438                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
439                 Some(callback),
440                 Box_::into_raw(user_data) as *mut _,
441             );
442         }
443     }
444 
start_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>445     fn start_future<P: IsA<MountOperation> + Clone + 'static>(
446         &self,
447         flags: DriveStartFlags,
448         mount_operation: Option<&P>,
449     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
450         let mount_operation = mount_operation.map(ToOwned::to_owned);
451         Box_::pin(crate::GioFuture::new(
452             self,
453             move |obj, cancellable, send| {
454                 obj.start(
455                     flags,
456                     mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
457                     Some(cancellable),
458                     move |res| {
459                         send.resolve(res);
460                     },
461                 );
462             },
463         ))
464     }
465 
stop< P: IsA<MountOperation>, Q: IsA<Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, )466     fn stop<
467         P: IsA<MountOperation>,
468         Q: IsA<Cancellable>,
469         R: FnOnce(Result<(), glib::Error>) + Send + 'static,
470     >(
471         &self,
472         flags: MountUnmountFlags,
473         mount_operation: Option<&P>,
474         cancellable: Option<&Q>,
475         callback: R,
476     ) {
477         let user_data: Box_<R> = Box_::new(callback);
478         unsafe extern "C" fn stop_trampoline<
479             R: FnOnce(Result<(), glib::Error>) + Send + 'static,
480         >(
481             _source_object: *mut glib::gobject_ffi::GObject,
482             res: *mut crate::ffi::GAsyncResult,
483             user_data: glib::ffi::gpointer,
484         ) {
485             let mut error = ptr::null_mut();
486             let _ = ffi::g_drive_stop_finish(_source_object as *mut _, res, &mut error);
487             let result = if error.is_null() {
488                 Ok(())
489             } else {
490                 Err(from_glib_full(error))
491             };
492             let callback: Box_<R> = Box_::from_raw(user_data as *mut _);
493             callback(result);
494         }
495         let callback = stop_trampoline::<R>;
496         unsafe {
497             ffi::g_drive_stop(
498                 self.as_ref().to_glib_none().0,
499                 flags.into_glib(),
500                 mount_operation.map(|p| p.as_ref()).to_glib_none().0,
501                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
502                 Some(callback),
503                 Box_::into_raw(user_data) as *mut _,
504             );
505         }
506     }
507 
stop_future<P: IsA<MountOperation> + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>508     fn stop_future<P: IsA<MountOperation> + Clone + 'static>(
509         &self,
510         flags: MountUnmountFlags,
511         mount_operation: Option<&P>,
512     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
513         let mount_operation = mount_operation.map(ToOwned::to_owned);
514         Box_::pin(crate::GioFuture::new(
515             self,
516             move |obj, cancellable, send| {
517                 obj.stop(
518                     flags,
519                     mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
520                     Some(cancellable),
521                     move |res| {
522                         send.resolve(res);
523                     },
524                 );
525             },
526         ))
527     }
528 
connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId529     fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
530         unsafe extern "C" fn changed_trampoline<P: IsA<Drive>, F: Fn(&P) + 'static>(
531             this: *mut ffi::GDrive,
532             f: glib::ffi::gpointer,
533         ) {
534             let f: &F = &*(f as *const F);
535             f(Drive::from_glib_borrow(this).unsafe_cast_ref())
536         }
537         unsafe {
538             let f: Box_<F> = Box_::new(f);
539             connect_raw(
540                 self.as_ptr() as *mut _,
541                 b"changed\0".as_ptr() as *const _,
542                 Some(transmute::<_, unsafe extern "C" fn()>(
543                     changed_trampoline::<Self, F> as *const (),
544                 )),
545                 Box_::into_raw(f),
546             )
547         }
548     }
549 
connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId550     fn connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
551         unsafe extern "C" fn disconnected_trampoline<P: IsA<Drive>, F: Fn(&P) + 'static>(
552             this: *mut ffi::GDrive,
553             f: glib::ffi::gpointer,
554         ) {
555             let f: &F = &*(f as *const F);
556             f(Drive::from_glib_borrow(this).unsafe_cast_ref())
557         }
558         unsafe {
559             let f: Box_<F> = Box_::new(f);
560             connect_raw(
561                 self.as_ptr() as *mut _,
562                 b"disconnected\0".as_ptr() as *const _,
563                 Some(transmute::<_, unsafe extern "C" fn()>(
564                     disconnected_trampoline::<Self, F> as *const (),
565                 )),
566                 Box_::into_raw(f),
567             )
568         }
569     }
570 
connect_eject_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId571     fn connect_eject_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
572         unsafe extern "C" fn eject_button_trampoline<P: IsA<Drive>, F: Fn(&P) + 'static>(
573             this: *mut ffi::GDrive,
574             f: glib::ffi::gpointer,
575         ) {
576             let f: &F = &*(f as *const F);
577             f(Drive::from_glib_borrow(this).unsafe_cast_ref())
578         }
579         unsafe {
580             let f: Box_<F> = Box_::new(f);
581             connect_raw(
582                 self.as_ptr() as *mut _,
583                 b"eject-button\0".as_ptr() as *const _,
584                 Some(transmute::<_, unsafe extern "C" fn()>(
585                     eject_button_trampoline::<Self, F> as *const (),
586                 )),
587                 Box_::into_raw(f),
588             )
589         }
590     }
591 
connect_stop_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId592     fn connect_stop_button<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
593         unsafe extern "C" fn stop_button_trampoline<P: IsA<Drive>, F: Fn(&P) + 'static>(
594             this: *mut ffi::GDrive,
595             f: glib::ffi::gpointer,
596         ) {
597             let f: &F = &*(f as *const F);
598             f(Drive::from_glib_borrow(this).unsafe_cast_ref())
599         }
600         unsafe {
601             let f: Box_<F> = Box_::new(f);
602             connect_raw(
603                 self.as_ptr() as *mut _,
604                 b"stop-button\0".as_ptr() as *const _,
605                 Some(transmute::<_, unsafe extern "C" fn()>(
606                     stop_button_trampoline::<Self, F> as *const (),
607                 )),
608                 Box_::into_raw(f),
609             )
610         }
611     }
612 }
613 
614 impl fmt::Display for Drive {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result615     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
616         f.write_str("Drive")
617     }
618 }
619