Skip to main content

spice_client_glib/auto/
file_transfer_task.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, MainChannel};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "SpiceFileTransferTask")]
17    pub struct FileTransferTask(Object<ffi::SpiceFileTransferTask, ffi::SpiceFileTransferTaskClass>);
18
19    match fn {
20        type_ => || ffi::spice_file_transfer_task_get_type(),
21    }
22}
23
24impl FileTransferTask {
25    #[doc(alias = "spice_file_transfer_task_cancel")]
26    pub fn cancel(&self) {
27        unsafe {
28            ffi::spice_file_transfer_task_cancel(self.to_glib_none().0);
29        }
30    }
31
32    #[doc(alias = "spice_file_transfer_task_get_filename")]
33    #[doc(alias = "get_filename")]
34    pub fn filename(&self) -> Option<glib::GString> {
35        unsafe {
36            from_glib_full(ffi::spice_file_transfer_task_get_filename(
37                self.to_glib_none().0,
38            ))
39        }
40    }
41
42    #[doc(alias = "spice_file_transfer_task_get_progress")]
43    #[doc(alias = "get_progress")]
44    pub fn progress(&self) -> f64 {
45        unsafe { ffi::spice_file_transfer_task_get_progress(self.to_glib_none().0) }
46    }
47
48    #[doc(alias = "spice_file_transfer_task_get_total_bytes")]
49    #[doc(alias = "get_total_bytes")]
50    #[doc(alias = "total-bytes")]
51    pub fn total_bytes(&self) -> u64 {
52        unsafe { ffi::spice_file_transfer_task_get_total_bytes(self.to_glib_none().0) }
53    }
54
55    #[doc(alias = "spice_file_transfer_task_get_transferred_bytes")]
56    #[doc(alias = "get_transferred_bytes")]
57    #[doc(alias = "transferred-bytes")]
58    pub fn transferred_bytes(&self) -> u64 {
59        unsafe { ffi::spice_file_transfer_task_get_transferred_bytes(self.to_glib_none().0) }
60    }
61
62    pub fn cancellable(&self) -> Option<gio::Cancellable> {
63        ObjectExt::property(self, "cancellable")
64    }
65
66    pub fn channel(&self) -> Option<MainChannel> {
67        ObjectExt::property(self, "channel")
68    }
69
70    pub fn file(&self) -> Option<gio::File> {
71        ObjectExt::property(self, "file")
72    }
73
74    pub fn id(&self) -> u32 {
75        ObjectExt::property(self, "id")
76    }
77
78    #[doc(alias = "finished")]
79    pub fn connect_finished<F: Fn(&Self, &glib::Error) + 'static>(&self, f: F) -> SignalHandlerId {
80        unsafe extern "C" fn finished_trampoline<
81            F: Fn(&FileTransferTask, &glib::Error) + 'static,
82        >(
83            this: *mut ffi::SpiceFileTransferTask,
84            object: *mut glib::ffi::GError,
85            f: glib::ffi::gpointer,
86        ) {
87            unsafe {
88                let f: &F = &*(f as *const F);
89                f(&from_glib_borrow(this), &from_glib_borrow(object))
90            }
91        }
92        unsafe {
93            let f: Box_<F> = Box_::new(f);
94            connect_raw(
95                self.as_ptr() as *mut _,
96                c"finished".as_ptr(),
97                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
98                    finished_trampoline::<F> as *const (),
99                )),
100                Box_::into_raw(f),
101            )
102        }
103    }
104
105    #[doc(alias = "progress")]
106    pub fn connect_progress_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
107        unsafe extern "C" fn notify_progress_trampoline<F: Fn(&FileTransferTask) + 'static>(
108            this: *mut ffi::SpiceFileTransferTask,
109            _param_spec: glib::ffi::gpointer,
110            f: glib::ffi::gpointer,
111        ) {
112            unsafe {
113                let f: &F = &*(f as *const F);
114                f(&from_glib_borrow(this))
115            }
116        }
117        unsafe {
118            let f: Box_<F> = Box_::new(f);
119            connect_raw(
120                self.as_ptr() as *mut _,
121                c"notify::progress".as_ptr(),
122                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
123                    notify_progress_trampoline::<F> as *const (),
124                )),
125                Box_::into_raw(f),
126            )
127        }
128    }
129
130    #[doc(alias = "total-bytes")]
131    pub fn connect_total_bytes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
132        unsafe extern "C" fn notify_total_bytes_trampoline<F: Fn(&FileTransferTask) + 'static>(
133            this: *mut ffi::SpiceFileTransferTask,
134            _param_spec: glib::ffi::gpointer,
135            f: glib::ffi::gpointer,
136        ) {
137            unsafe {
138                let f: &F = &*(f as *const F);
139                f(&from_glib_borrow(this))
140            }
141        }
142        unsafe {
143            let f: Box_<F> = Box_::new(f);
144            connect_raw(
145                self.as_ptr() as *mut _,
146                c"notify::total-bytes".as_ptr(),
147                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
148                    notify_total_bytes_trampoline::<F> as *const (),
149                )),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    #[doc(alias = "transferred-bytes")]
156    pub fn connect_transferred_bytes_notify<F: Fn(&Self) + 'static>(
157        &self,
158        f: F,
159    ) -> SignalHandlerId {
160        unsafe extern "C" fn notify_transferred_bytes_trampoline<
161            F: Fn(&FileTransferTask) + 'static,
162        >(
163            this: *mut ffi::SpiceFileTransferTask,
164            _param_spec: glib::ffi::gpointer,
165            f: glib::ffi::gpointer,
166        ) {
167            unsafe {
168                let f: &F = &*(f as *const F);
169                f(&from_glib_borrow(this))
170            }
171        }
172        unsafe {
173            let f: Box_<F> = Box_::new(f);
174            connect_raw(
175                self.as_ptr() as *mut _,
176                c"notify::transferred-bytes".as_ptr(),
177                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
178                    notify_transferred_bytes_trampoline::<F> as *const (),
179                )),
180                Box_::into_raw(f),
181            )
182        }
183    }
184}