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 gio_sys; 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use glib::StaticType; 12 use glib::Value; 13 use glib_sys; 14 use gobject_sys; 15 use std::boxed::Box as Box_; 16 use std::fmt; 17 use std::mem::transmute; 18 use Converter; 19 use FileInfo; 20 use ZlibCompressorFormat; 21 22 glib_wrapper! { 23 pub struct ZlibCompressor(Object<gio_sys::GZlibCompressor, gio_sys::GZlibCompressorClass, ZlibCompressorClass>) @implements Converter; 24 25 match fn { 26 get_type => || gio_sys::g_zlib_compressor_get_type(), 27 } 28 } 29 30 impl ZlibCompressor { new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor31 pub fn new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor { 32 unsafe { from_glib_full(gio_sys::g_zlib_compressor_new(format.to_glib(), level)) } 33 } 34 } 35 36 pub const NONE_ZLIB_COMPRESSOR: Option<&ZlibCompressor> = None; 37 38 pub trait ZlibCompressorExt: 'static { get_file_info(&self) -> Option<FileInfo>39 fn get_file_info(&self) -> Option<FileInfo>; 40 set_file_info(&self, file_info: Option<&FileInfo>)41 fn set_file_info(&self, file_info: Option<&FileInfo>); 42 get_property_format(&self) -> ZlibCompressorFormat43 fn get_property_format(&self) -> ZlibCompressorFormat; 44 get_property_level(&self) -> i3245 fn get_property_level(&self) -> i32; 46 connect_property_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId47 fn connect_property_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 48 } 49 50 impl<O: IsA<ZlibCompressor>> ZlibCompressorExt for O { get_file_info(&self) -> Option<FileInfo>51 fn get_file_info(&self) -> Option<FileInfo> { 52 unsafe { 53 from_glib_none(gio_sys::g_zlib_compressor_get_file_info( 54 self.as_ref().to_glib_none().0, 55 )) 56 } 57 } 58 set_file_info(&self, file_info: Option<&FileInfo>)59 fn set_file_info(&self, file_info: Option<&FileInfo>) { 60 unsafe { 61 gio_sys::g_zlib_compressor_set_file_info( 62 self.as_ref().to_glib_none().0, 63 file_info.to_glib_none().0, 64 ); 65 } 66 } 67 get_property_format(&self) -> ZlibCompressorFormat68 fn get_property_format(&self) -> ZlibCompressorFormat { 69 unsafe { 70 let mut value = Value::from_type(<ZlibCompressorFormat as StaticType>::static_type()); 71 gobject_sys::g_object_get_property( 72 self.to_glib_none().0 as *mut gobject_sys::GObject, 73 b"format\0".as_ptr() as *const _, 74 value.to_glib_none_mut().0, 75 ); 76 value 77 .get() 78 .expect("Return Value for property `format` getter") 79 .unwrap() 80 } 81 } 82 get_property_level(&self) -> i3283 fn get_property_level(&self) -> i32 { 84 unsafe { 85 let mut value = Value::from_type(<i32 as StaticType>::static_type()); 86 gobject_sys::g_object_get_property( 87 self.to_glib_none().0 as *mut gobject_sys::GObject, 88 b"level\0".as_ptr() as *const _, 89 value.to_glib_none_mut().0, 90 ); 91 value 92 .get() 93 .expect("Return Value for property `level` getter") 94 .unwrap() 95 } 96 } 97 connect_property_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId98 fn connect_property_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 99 unsafe extern "C" fn notify_file_info_trampoline<P, F: Fn(&P) + 'static>( 100 this: *mut gio_sys::GZlibCompressor, 101 _param_spec: glib_sys::gpointer, 102 f: glib_sys::gpointer, 103 ) where 104 P: IsA<ZlibCompressor>, 105 { 106 let f: &F = &*(f as *const F); 107 f(&ZlibCompressor::from_glib_borrow(this).unsafe_cast()) 108 } 109 unsafe { 110 let f: Box_<F> = Box_::new(f); 111 connect_raw( 112 self.as_ptr() as *mut _, 113 b"notify::file-info\0".as_ptr() as *const _, 114 Some(transmute(notify_file_info_trampoline::<Self, F> as usize)), 115 Box_::into_raw(f), 116 ) 117 } 118 } 119 } 120 121 impl fmt::Display for ZlibCompressor { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result122 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 123 write!(f, "ZlibCompressor") 124 } 125 } 126