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::Converter;
6 use crate::FileInfo;
7 use crate::ZlibCompressorFormat;
8 use glib::object::ObjectType as ObjectType_;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::StaticType;
13 use std::boxed::Box as Box_;
14 use std::fmt;
15 use std::mem::transmute;
16 
17 glib::wrapper! {
18     #[doc(alias = "GZlibCompressor")]
19     pub struct ZlibCompressor(Object<ffi::GZlibCompressor, ffi::GZlibCompressorClass>) @implements Converter;
20 
21     match fn {
22         type_ => || ffi::g_zlib_compressor_get_type(),
23     }
24 }
25 
26 impl ZlibCompressor {
27     #[doc(alias = "g_zlib_compressor_new")]
new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor28     pub fn new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor {
29         unsafe { from_glib_full(ffi::g_zlib_compressor_new(format.into_glib(), level)) }
30     }
31 
32     #[doc(alias = "g_zlib_compressor_get_file_info")]
33     #[doc(alias = "get_file_info")]
file_info(&self) -> Option<FileInfo>34     pub fn file_info(&self) -> Option<FileInfo> {
35         unsafe { from_glib_none(ffi::g_zlib_compressor_get_file_info(self.to_glib_none().0)) }
36     }
37 
38     #[doc(alias = "g_zlib_compressor_set_file_info")]
set_file_info(&self, file_info: Option<&FileInfo>)39     pub fn set_file_info(&self, file_info: Option<&FileInfo>) {
40         unsafe {
41             ffi::g_zlib_compressor_set_file_info(self.to_glib_none().0, file_info.to_glib_none().0);
42         }
43     }
44 
format(&self) -> ZlibCompressorFormat45     pub fn format(&self) -> ZlibCompressorFormat {
46         unsafe {
47             let mut value =
48                 glib::Value::from_type(<ZlibCompressorFormat as StaticType>::static_type());
49             glib::gobject_ffi::g_object_get_property(
50                 self.as_ptr() as *mut glib::gobject_ffi::GObject,
51                 b"format\0".as_ptr() as *const _,
52                 value.to_glib_none_mut().0,
53             );
54             value
55                 .get()
56                 .expect("Return Value for property `format` getter")
57         }
58     }
59 
level(&self) -> i3260     pub fn level(&self) -> i32 {
61         unsafe {
62             let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
63             glib::gobject_ffi::g_object_get_property(
64                 self.as_ptr() as *mut glib::gobject_ffi::GObject,
65                 b"level\0".as_ptr() as *const _,
66                 value.to_glib_none_mut().0,
67             );
68             value
69                 .get()
70                 .expect("Return Value for property `level` getter")
71         }
72     }
73 
74     #[doc(alias = "file-info")]
connect_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId75     pub fn connect_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
76         unsafe extern "C" fn notify_file_info_trampoline<F: Fn(&ZlibCompressor) + 'static>(
77             this: *mut ffi::GZlibCompressor,
78             _param_spec: glib::ffi::gpointer,
79             f: glib::ffi::gpointer,
80         ) {
81             let f: &F = &*(f as *const F);
82             f(&from_glib_borrow(this))
83         }
84         unsafe {
85             let f: Box_<F> = Box_::new(f);
86             connect_raw(
87                 self.as_ptr() as *mut _,
88                 b"notify::file-info\0".as_ptr() as *const _,
89                 Some(transmute::<_, unsafe extern "C" fn()>(
90                     notify_file_info_trampoline::<F> as *const (),
91                 )),
92                 Box_::into_raw(f),
93             )
94         }
95     }
96 }
97 
98 impl fmt::Display for ZlibCompressor {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result99     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100         f.write_str("ZlibCompressor")
101     }
102 }
103