1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::{PageRange, PrintJob};
use glib::translate::*;
use std::boxed::Box as Box_;
impl PrintJob {
#[doc(alias = "gtk_print_job_send")]
pub fn send<P: Fn(&PrintJob, &glib::Error) + 'static>(&self, callback: P) {
let callback_data: Box_<P> = Box_::new(callback);
unsafe extern "C" fn callback_func<P: Fn(&PrintJob, &glib::Error) + 'static>(
print_job: *mut ffi::GtkPrintJob,
user_data: glib::ffi::gpointer,
error: *const glib::ffi::GError,
) {
let print_job = from_glib_borrow(print_job);
let error = from_glib_borrow(error);
let callback: &P = &*(user_data as *mut _);
(*callback)(&print_job, &error);
}
let callback = Some(callback_func::<P> as _);
unsafe extern "C" fn dnotify_func<P: Fn(&PrintJob, &glib::Error) + 'static>(
data: glib::ffi::gpointer,
) {
let _callback: Box_<P> = Box_::from_raw(data as *mut _);
}
let destroy_call3 = Some(dnotify_func::<P> as _);
let super_callback0: Box_<P> = callback_data;
unsafe {
ffi::gtk_print_job_send(
self.to_glib_none().0,
callback,
Box_::into_raw(super_callback0) as *mut _,
destroy_call3,
);
}
}
#[doc(alias = "gtk_print_job_set_page_ranges")]
pub fn set_page_ranges(&self, ranges: &[PageRange]) {
let n_ranges = ranges.len() as i32;
unsafe {
ffi::gtk_print_job_set_page_ranges(
self.to_glib_none().0,
mut_override(ranges.to_glib_full()),
n_ranges,
);
}
}
}