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 glib; 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::object::ObjectExt; 9 use glib::signal::connect_raw; 10 use glib::signal::SignalHandlerId; 11 use glib::translate::*; 12 use glib::GString; 13 use glib::StaticType; 14 use glib::Value; 15 use glib_sys; 16 use gobject_sys; 17 use gtk_sys; 18 use std::boxed::Box as Box_; 19 use std::fmt; 20 use std::mem::transmute; 21 use Bin; 22 use Buildable; 23 use Container; 24 use Widget; 25 use Window; 26 27 glib_wrapper! { 28 pub struct ShortcutsWindow(Object<gtk_sys::GtkShortcutsWindow, gtk_sys::GtkShortcutsWindowClass, ShortcutsWindowClass>) @extends Window, Bin, Container, Widget, @implements Buildable; 29 30 match fn { 31 get_type => || gtk_sys::gtk_shortcuts_window_get_type(), 32 } 33 } 34 35 pub const NONE_SHORTCUTS_WINDOW: Option<&ShortcutsWindow> = None; 36 37 pub trait ShortcutsWindowExt: 'static { get_property_section_name(&self) -> Option<GString>38 fn get_property_section_name(&self) -> Option<GString>; 39 set_property_section_name(&self, section_name: Option<&str>)40 fn set_property_section_name(&self, section_name: Option<&str>); 41 get_property_view_name(&self) -> Option<GString>42 fn get_property_view_name(&self) -> Option<GString>; 43 set_property_view_name(&self, view_name: Option<&str>)44 fn set_property_view_name(&self, view_name: Option<&str>); 45 connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId46 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 47 emit_close(&self)48 fn emit_close(&self); 49 connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId50 fn connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 51 emit_search(&self)52 fn emit_search(&self); 53 connect_property_section_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId54 fn connect_property_section_name_notify<F: Fn(&Self) + 'static>(&self, f: F) 55 -> SignalHandlerId; 56 connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId57 fn connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 58 } 59 60 impl<O: IsA<ShortcutsWindow>> ShortcutsWindowExt for O { get_property_section_name(&self) -> Option<GString>61 fn get_property_section_name(&self) -> Option<GString> { 62 unsafe { 63 let mut value = Value::from_type(<GString as StaticType>::static_type()); 64 gobject_sys::g_object_get_property( 65 self.to_glib_none().0 as *mut gobject_sys::GObject, 66 b"section-name\0".as_ptr() as *const _, 67 value.to_glib_none_mut().0, 68 ); 69 value 70 .get() 71 .expect("Return Value for property `section-name` getter") 72 } 73 } 74 set_property_section_name(&self, section_name: Option<&str>)75 fn set_property_section_name(&self, section_name: Option<&str>) { 76 unsafe { 77 gobject_sys::g_object_set_property( 78 self.to_glib_none().0 as *mut gobject_sys::GObject, 79 b"section-name\0".as_ptr() as *const _, 80 Value::from(section_name).to_glib_none().0, 81 ); 82 } 83 } 84 get_property_view_name(&self) -> Option<GString>85 fn get_property_view_name(&self) -> Option<GString> { 86 unsafe { 87 let mut value = Value::from_type(<GString as StaticType>::static_type()); 88 gobject_sys::g_object_get_property( 89 self.to_glib_none().0 as *mut gobject_sys::GObject, 90 b"view-name\0".as_ptr() as *const _, 91 value.to_glib_none_mut().0, 92 ); 93 value 94 .get() 95 .expect("Return Value for property `view-name` getter") 96 } 97 } 98 set_property_view_name(&self, view_name: Option<&str>)99 fn set_property_view_name(&self, view_name: Option<&str>) { 100 unsafe { 101 gobject_sys::g_object_set_property( 102 self.to_glib_none().0 as *mut gobject_sys::GObject, 103 b"view-name\0".as_ptr() as *const _, 104 Value::from(view_name).to_glib_none().0, 105 ); 106 } 107 } 108 connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId109 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 110 unsafe extern "C" fn close_trampoline<P, F: Fn(&P) + 'static>( 111 this: *mut gtk_sys::GtkShortcutsWindow, 112 f: glib_sys::gpointer, 113 ) where 114 P: IsA<ShortcutsWindow>, 115 { 116 let f: &F = &*(f as *const F); 117 f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast()) 118 } 119 unsafe { 120 let f: Box_<F> = Box_::new(f); 121 connect_raw( 122 self.as_ptr() as *mut _, 123 b"close\0".as_ptr() as *const _, 124 Some(transmute(close_trampoline::<Self, F> as usize)), 125 Box_::into_raw(f), 126 ) 127 } 128 } 129 emit_close(&self)130 fn emit_close(&self) { 131 let _ = unsafe { 132 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) 133 .emit("close", &[]) 134 .unwrap() 135 }; 136 } 137 connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId138 fn connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 139 unsafe extern "C" fn search_trampoline<P, F: Fn(&P) + 'static>( 140 this: *mut gtk_sys::GtkShortcutsWindow, 141 f: glib_sys::gpointer, 142 ) where 143 P: IsA<ShortcutsWindow>, 144 { 145 let f: &F = &*(f as *const F); 146 f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast()) 147 } 148 unsafe { 149 let f: Box_<F> = Box_::new(f); 150 connect_raw( 151 self.as_ptr() as *mut _, 152 b"search\0".as_ptr() as *const _, 153 Some(transmute(search_trampoline::<Self, F> as usize)), 154 Box_::into_raw(f), 155 ) 156 } 157 } 158 emit_search(&self)159 fn emit_search(&self) { 160 let _ = unsafe { 161 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) 162 .emit("search", &[]) 163 .unwrap() 164 }; 165 } 166 connect_property_section_name_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId167 fn connect_property_section_name_notify<F: Fn(&Self) + 'static>( 168 &self, 169 f: F, 170 ) -> SignalHandlerId { 171 unsafe extern "C" fn notify_section_name_trampoline<P, F: Fn(&P) + 'static>( 172 this: *mut gtk_sys::GtkShortcutsWindow, 173 _param_spec: glib_sys::gpointer, 174 f: glib_sys::gpointer, 175 ) where 176 P: IsA<ShortcutsWindow>, 177 { 178 let f: &F = &*(f as *const F); 179 f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast()) 180 } 181 unsafe { 182 let f: Box_<F> = Box_::new(f); 183 connect_raw( 184 self.as_ptr() as *mut _, 185 b"notify::section-name\0".as_ptr() as *const _, 186 Some(transmute( 187 notify_section_name_trampoline::<Self, F> as usize, 188 )), 189 Box_::into_raw(f), 190 ) 191 } 192 } 193 connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId194 fn connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 195 unsafe extern "C" fn notify_view_name_trampoline<P, F: Fn(&P) + 'static>( 196 this: *mut gtk_sys::GtkShortcutsWindow, 197 _param_spec: glib_sys::gpointer, 198 f: glib_sys::gpointer, 199 ) where 200 P: IsA<ShortcutsWindow>, 201 { 202 let f: &F = &*(f as *const F); 203 f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast()) 204 } 205 unsafe { 206 let f: Box_<F> = Box_::new(f); 207 connect_raw( 208 self.as_ptr() as *mut _, 209 b"notify::view-name\0".as_ptr() as *const _, 210 Some(transmute(notify_view_name_trampoline::<Self, F> as usize)), 211 Box_::into_raw(f), 212 ) 213 } 214 } 215 } 216 217 impl fmt::Display for ShortcutsWindow { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result218 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 219 write!(f, "ShortcutsWindow") 220 } 221 } 222