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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use gdk; use gdk_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use gobject_sys; use gtk_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib_wrapper! { /// A `AccelGroup` represents a group of keyboard accelerators, /// typically attached to a toplevel `Window` (with /// `GtkWindowExt::add_accel_group`). Usually you won’t need to create a /// `AccelGroup` directly; instead, when using `UIManager`, GTK+ /// automatically sets up the accelerators for your menus in the ui /// manager’s `AccelGroup`. /// /// Note that “accelerators” are different from /// “mnemonics”. Accelerators are shortcuts for /// activating a menu item; they appear alongside the menu item they’re a /// shortcut for. For example “Ctrl+Q” might appear alongside the “Quit” /// menu item. Mnemonics are shortcuts for GUI elements such as text /// entries or buttons; they appear as underlined characters. See /// `Label::new_with_mnemonic`. Menu items can have both accelerators /// and mnemonics, of course. /// /// # Implements /// /// [`AccelGroupExt`](trait.AccelGroupExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html), [`AccelGroupExtManual`](prelude/trait.AccelGroupExtManual.html) pub struct AccelGroup(Object<gtk_sys::GtkAccelGroup, gtk_sys::GtkAccelGroupClass, AccelGroupClass>); match fn { get_type => || gtk_sys::gtk_accel_group_get_type(), } } impl AccelGroup { /// Creates a new `AccelGroup`. /// /// # Returns /// /// a new `AccelGroup` object pub fn new() -> AccelGroup { assert_initialized_main_thread!(); unsafe { from_glib_full(gtk_sys::gtk_accel_group_new()) } } /// Finds the `AccelGroup` to which `closure` is connected; /// see `AccelGroup::connect`. /// ## `closure` /// a `gobject::Closure` /// /// # Returns /// /// the `AccelGroup` to which `closure` /// is connected, or `None` pub fn from_accel_closure(closure: &glib::Closure) -> Option<AccelGroup> { assert_initialized_main_thread!(); unsafe { from_glib_none(gtk_sys::gtk_accel_group_from_accel_closure( closure.to_glib_none().0, )) } } } impl Default for AccelGroup { fn default() -> Self { Self::new() } } pub const NONE_ACCEL_GROUP: Option<&AccelGroup> = None; /// Trait containing all `AccelGroup` methods. /// /// # Implementors /// /// [`AccelGroup`](struct.AccelGroup.html) pub trait AccelGroupExt: 'static { /// Finds the first accelerator in `self` that matches /// `accel_key` and `accel_mods`, and activates it. /// ## `accel_quark` /// the quark for the accelerator name /// ## `acceleratable` /// the `gobject::Object`, usually a `Window`, on which /// to activate the accelerator /// ## `accel_key` /// accelerator keyval from a key event /// ## `accel_mods` /// keyboard state mask from a key event /// /// # Returns /// /// `true` if an accelerator was activated and handled /// this keypress fn activate<P: IsA<glib::Object>>( &self, accel_quark: glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType, ) -> bool; /// Removes an accelerator previously installed through /// `AccelGroup::connect`. /// /// Since 2.20 `closure` can be `None`. /// ## `closure` /// the closure to remove from this accelerator /// group, or `None` to remove all closures /// /// # Returns /// /// `true` if the closure was found and got disconnected fn disconnect(&self, closure: Option<&glib::Closure>) -> bool; /// Removes an accelerator previously installed through /// `AccelGroup::connect`. /// ## `accel_key` /// key value of the accelerator /// ## `accel_mods` /// modifier combination of the accelerator /// /// # Returns /// /// `true` if there was an accelerator which could be /// removed, `false` otherwise fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool; //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option<Fundamental: Pointer>) -> /*Ignored*/Option<AccelKey>; /// Locks are added and removed using `AccelGroupExt::lock` and /// `AccelGroupExt::unlock`. /// /// # Returns /// /// `true` if there are 1 or more locks on the `self`, /// `false` otherwise. fn get_is_locked(&self) -> bool; /// Gets a `gdk::ModifierType` representing the mask for this /// `self`. For example, `gdk::ModifierType::ControlMask`, `gdk::ModifierType::ShiftMask`, etc. /// /// # Returns /// /// the modifier mask for this accel group. fn get_modifier_mask(&self) -> gdk::ModifierType; /// Locks the given accelerator group. /// /// Locking an acelerator group prevents the accelerators contained /// within it to be changed during runtime. Refer to /// `AccelMap::change_entry` about runtime accelerator changes. /// /// If called more than once, `self` remains locked until /// `AccelGroupExt::unlock` has been called an equivalent number /// of times. fn lock(&self); /// Undoes the last call to `AccelGroupExt::lock` on this `self`. fn unlock(&self); /// The accel-activate signal is an implementation detail of /// `AccelGroup` and not meant to be used by applications. /// ## `acceleratable` /// the object on which the accelerator was activated /// ## `keyval` /// the accelerator keyval /// ## `modifier` /// the modifier combination of the accelerator /// /// # Returns /// /// `true` if the accelerator was activated fn connect_accel_activate< F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId; /// The accel-changed signal is emitted when an entry /// is added to or removed from the accel group. /// /// Widgets like `AccelLabel` which display an associated /// accelerator should connect to this signal, and rebuild /// their visual representation if the `accel_closure` is theirs. /// ## `keyval` /// the accelerator keyval /// ## `modifier` /// the modifier combination of the accelerator /// ## `accel_closure` /// the `gobject::Closure` of the accelerator fn connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_property_modifier_mask_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId; } impl<O: IsA<AccelGroup>> AccelGroupExt for O { fn activate<P: IsA<glib::Object>>( &self, accel_quark: glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType, ) -> bool { unsafe { from_glib(gtk_sys::gtk_accel_group_activate( self.as_ref().to_glib_none().0, accel_quark.to_glib(), acceleratable.as_ref().to_glib_none().0, accel_key, accel_mods.to_glib(), )) } } fn disconnect(&self, closure: Option<&glib::Closure>) -> bool { unsafe { from_glib(gtk_sys::gtk_accel_group_disconnect( self.as_ref().to_glib_none().0, closure.to_glib_none().0, )) } } fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool { unsafe { from_glib(gtk_sys::gtk_accel_group_disconnect_key( self.as_ref().to_glib_none().0, accel_key, accel_mods.to_glib(), )) } } //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option<Fundamental: Pointer>) -> /*Ignored*/Option<AccelKey> { // unsafe { TODO: call gtk_sys:gtk_accel_group_find() } //} fn get_is_locked(&self) -> bool { unsafe { from_glib(gtk_sys::gtk_accel_group_get_is_locked( self.as_ref().to_glib_none().0, )) } } fn get_modifier_mask(&self) -> gdk::ModifierType { unsafe { from_glib(gtk_sys::gtk_accel_group_get_modifier_mask( self.as_ref().to_glib_none().0, )) } } fn lock(&self) { unsafe { gtk_sys::gtk_accel_group_lock(self.as_ref().to_glib_none().0); } } fn unlock(&self) { unsafe { gtk_sys::gtk_accel_group_unlock(self.as_ref().to_glib_none().0); } } fn connect_accel_activate< F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn accel_activate_trampoline< P, F: Fn(&P, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, >( this: *mut gtk_sys::GtkAccelGroup, acceleratable: *mut gobject_sys::GObject, keyval: libc::c_uint, modifier: gdk_sys::GdkModifierType, f: glib_sys::gpointer, ) -> glib_sys::gboolean where P: IsA<AccelGroup>, { let f: &F = &*(f as *const F); f( &AccelGroup::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(acceleratable), keyval, from_glib(modifier), ) .to_glib() } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"accel-activate\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( accel_activate_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn accel_changed_trampoline< P, F: Fn(&P, u32, gdk::ModifierType, &glib::Closure) + 'static, >( this: *mut gtk_sys::GtkAccelGroup, keyval: libc::c_uint, modifier: gdk_sys::GdkModifierType, accel_closure: *mut gobject_sys::GClosure, f: glib_sys::gpointer, ) where P: IsA<AccelGroup>, { let f: &F = &*(f as *const F); f( &AccelGroup::from_glib_borrow(this).unsafe_cast_ref(), keyval, from_glib(modifier), &from_glib_borrow(accel_closure), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"accel-changed\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( accel_changed_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_property_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_locked_trampoline<P, F: Fn(&P) + 'static>( this: *mut gtk_sys::GtkAccelGroup, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<AccelGroup>, { let f: &F = &*(f as *const F); f(&AccelGroup::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-locked\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_is_locked_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_property_modifier_mask_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_modifier_mask_trampoline<P, F: Fn(&P) + 'static>( this: *mut gtk_sys::GtkAccelGroup, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<AccelGroup>, { let f: &F = &*(f as *const F); f(&AccelGroup::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::modifier-mask\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_modifier_mask_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for AccelGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AccelGroup") } }