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; 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::GString; 12 use glib::StaticType; 13 use glib::ToValue; 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 ApplicationInhibitFlags; 22 use Window; 23 24 glib_wrapper! { 25 pub struct Application(Object<gtk_sys::GtkApplication, gtk_sys::GtkApplicationClass, ApplicationClass>) @extends gio::Application, @implements gio::ActionGroup, gio::ActionMap; 26 27 match fn { 28 get_type => || gtk_sys::gtk_application_get_type(), 29 } 30 } 31 32 #[derive(Clone, Default)] 33 pub struct ApplicationBuilder { 34 app_menu: Option<gio::MenuModel>, 35 menubar: Option<gio::MenuModel>, 36 register_session: Option<bool>, 37 action_group: Option<gio::ActionGroup>, 38 application_id: Option<String>, 39 flags: Option<gio::ApplicationFlags>, 40 inactivity_timeout: Option<u32>, 41 resource_base_path: Option<String>, 42 } 43 44 impl ApplicationBuilder { new() -> Self45 pub fn new() -> Self { 46 Self::default() 47 } 48 build(self) -> Application49 pub fn build(self) -> Application { 50 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 51 if let Some(ref app_menu) = self.app_menu { 52 properties.push(("app-menu", app_menu)); 53 } 54 if let Some(ref menubar) = self.menubar { 55 properties.push(("menubar", menubar)); 56 } 57 if let Some(ref register_session) = self.register_session { 58 properties.push(("register-session", register_session)); 59 } 60 if let Some(ref action_group) = self.action_group { 61 properties.push(("action-group", action_group)); 62 } 63 if let Some(ref application_id) = self.application_id { 64 properties.push(("application-id", application_id)); 65 } 66 if let Some(ref flags) = self.flags { 67 properties.push(("flags", flags)); 68 } 69 if let Some(ref inactivity_timeout) = self.inactivity_timeout { 70 properties.push(("inactivity-timeout", inactivity_timeout)); 71 } 72 if let Some(ref resource_base_path) = self.resource_base_path { 73 properties.push(("resource-base-path", resource_base_path)); 74 } 75 glib::Object::new(Application::static_type(), &properties) 76 .expect("object new") 77 .downcast() 78 .expect("downcast") 79 } 80 app_menu<P: IsA<gio::MenuModel>>(mut self, app_menu: &P) -> Self81 pub fn app_menu<P: IsA<gio::MenuModel>>(mut self, app_menu: &P) -> Self { 82 self.app_menu = Some(app_menu.clone().upcast()); 83 self 84 } 85 menubar<P: IsA<gio::MenuModel>>(mut self, menubar: &P) -> Self86 pub fn menubar<P: IsA<gio::MenuModel>>(mut self, menubar: &P) -> Self { 87 self.menubar = Some(menubar.clone().upcast()); 88 self 89 } 90 register_session(mut self, register_session: bool) -> Self91 pub fn register_session(mut self, register_session: bool) -> Self { 92 self.register_session = Some(register_session); 93 self 94 } 95 action_group<P: IsA<gio::ActionGroup>>(mut self, action_group: &P) -> Self96 pub fn action_group<P: IsA<gio::ActionGroup>>(mut self, action_group: &P) -> Self { 97 self.action_group = Some(action_group.clone().upcast()); 98 self 99 } 100 application_id(mut self, application_id: &str) -> Self101 pub fn application_id(mut self, application_id: &str) -> Self { 102 self.application_id = Some(application_id.to_string()); 103 self 104 } 105 flags(mut self, flags: gio::ApplicationFlags) -> Self106 pub fn flags(mut self, flags: gio::ApplicationFlags) -> Self { 107 self.flags = Some(flags); 108 self 109 } 110 inactivity_timeout(mut self, inactivity_timeout: u32) -> Self111 pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self { 112 self.inactivity_timeout = Some(inactivity_timeout); 113 self 114 } 115 resource_base_path(mut self, resource_base_path: &str) -> Self116 pub fn resource_base_path(mut self, resource_base_path: &str) -> Self { 117 self.resource_base_path = Some(resource_base_path.to_string()); 118 self 119 } 120 } 121 122 pub const NONE_APPLICATION: Option<&Application> = None; 123 124 pub trait GtkApplicationExt: 'static { add_window<P: IsA<Window>>(&self, window: &P)125 fn add_window<P: IsA<Window>>(&self, window: &P); 126 get_accels_for_action(&self, detailed_action_name: &str) -> Vec<GString>127 fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec<GString>; 128 get_actions_for_accel(&self, accel: &str) -> Vec<GString>129 fn get_actions_for_accel(&self, accel: &str) -> Vec<GString>; 130 get_active_window(&self) -> Option<Window>131 fn get_active_window(&self) -> Option<Window>; 132 get_app_menu(&self) -> Option<gio::MenuModel>133 fn get_app_menu(&self) -> Option<gio::MenuModel>; 134 get_menu_by_id(&self, id: &str) -> Option<gio::Menu>135 fn get_menu_by_id(&self, id: &str) -> Option<gio::Menu>; 136 get_menubar(&self) -> Option<gio::MenuModel>137 fn get_menubar(&self) -> Option<gio::MenuModel>; 138 get_window_by_id(&self, id: u32) -> Option<Window>139 fn get_window_by_id(&self, id: u32) -> Option<Window>; 140 get_windows(&self) -> Vec<Window>141 fn get_windows(&self) -> Vec<Window>; 142 inhibit<P: IsA<Window>>( &self, window: Option<&P>, flags: ApplicationInhibitFlags, reason: Option<&str>, ) -> u32143 fn inhibit<P: IsA<Window>>( 144 &self, 145 window: Option<&P>, 146 flags: ApplicationInhibitFlags, 147 reason: Option<&str>, 148 ) -> u32; 149 is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool150 fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool; 151 list_action_descriptions(&self) -> Vec<GString>152 fn list_action_descriptions(&self) -> Vec<GString>; 153 prefers_app_menu(&self) -> bool154 fn prefers_app_menu(&self) -> bool; 155 remove_window<P: IsA<Window>>(&self, window: &P)156 fn remove_window<P: IsA<Window>>(&self, window: &P); 157 set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str])158 fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]); 159 set_app_menu<P: IsA<gio::MenuModel>>(&self, app_menu: Option<&P>)160 fn set_app_menu<P: IsA<gio::MenuModel>>(&self, app_menu: Option<&P>); 161 set_menubar<P: IsA<gio::MenuModel>>(&self, menubar: Option<&P>)162 fn set_menubar<P: IsA<gio::MenuModel>>(&self, menubar: Option<&P>); 163 uninhibit(&self, cookie: u32)164 fn uninhibit(&self, cookie: u32); 165 get_property_register_session(&self) -> bool166 fn get_property_register_session(&self) -> bool; 167 set_property_register_session(&self, register_session: bool)168 fn set_property_register_session(&self, register_session: bool); 169 170 #[cfg(any(feature = "v3_24", feature = "dox"))] get_property_screensaver_active(&self) -> bool171 fn get_property_screensaver_active(&self) -> bool; 172 173 #[cfg(any(feature = "v3_24_8", feature = "dox"))] connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId174 fn connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 175 connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId176 fn connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId; 177 connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId178 fn connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId; 179 connect_property_active_window_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId180 fn connect_property_active_window_notify<F: Fn(&Self) + 'static>( 181 &self, 182 f: F, 183 ) -> SignalHandlerId; 184 connect_property_app_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId185 fn connect_property_app_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 186 connect_property_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId187 fn connect_property_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 188 connect_property_register_session_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId189 fn connect_property_register_session_notify<F: Fn(&Self) + 'static>( 190 &self, 191 f: F, 192 ) -> SignalHandlerId; 193 194 #[cfg(any(feature = "v3_24", feature = "dox"))] connect_property_screensaver_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId195 fn connect_property_screensaver_active_notify<F: Fn(&Self) + 'static>( 196 &self, 197 f: F, 198 ) -> SignalHandlerId; 199 } 200 201 impl<O: IsA<Application>> GtkApplicationExt for O { add_window<P: IsA<Window>>(&self, window: &P)202 fn add_window<P: IsA<Window>>(&self, window: &P) { 203 unsafe { 204 gtk_sys::gtk_application_add_window( 205 self.as_ref().to_glib_none().0, 206 window.as_ref().to_glib_none().0, 207 ); 208 } 209 } 210 get_accels_for_action(&self, detailed_action_name: &str) -> Vec<GString>211 fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec<GString> { 212 unsafe { 213 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_get_accels_for_action( 214 self.as_ref().to_glib_none().0, 215 detailed_action_name.to_glib_none().0, 216 )) 217 } 218 } 219 get_actions_for_accel(&self, accel: &str) -> Vec<GString>220 fn get_actions_for_accel(&self, accel: &str) -> Vec<GString> { 221 unsafe { 222 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_get_actions_for_accel( 223 self.as_ref().to_glib_none().0, 224 accel.to_glib_none().0, 225 )) 226 } 227 } 228 get_active_window(&self) -> Option<Window>229 fn get_active_window(&self) -> Option<Window> { 230 unsafe { 231 from_glib_none(gtk_sys::gtk_application_get_active_window( 232 self.as_ref().to_glib_none().0, 233 )) 234 } 235 } 236 get_app_menu(&self) -> Option<gio::MenuModel>237 fn get_app_menu(&self) -> Option<gio::MenuModel> { 238 unsafe { 239 from_glib_none(gtk_sys::gtk_application_get_app_menu( 240 self.as_ref().to_glib_none().0, 241 )) 242 } 243 } 244 get_menu_by_id(&self, id: &str) -> Option<gio::Menu>245 fn get_menu_by_id(&self, id: &str) -> Option<gio::Menu> { 246 unsafe { 247 from_glib_none(gtk_sys::gtk_application_get_menu_by_id( 248 self.as_ref().to_glib_none().0, 249 id.to_glib_none().0, 250 )) 251 } 252 } 253 get_menubar(&self) -> Option<gio::MenuModel>254 fn get_menubar(&self) -> Option<gio::MenuModel> { 255 unsafe { 256 from_glib_none(gtk_sys::gtk_application_get_menubar( 257 self.as_ref().to_glib_none().0, 258 )) 259 } 260 } 261 get_window_by_id(&self, id: u32) -> Option<Window>262 fn get_window_by_id(&self, id: u32) -> Option<Window> { 263 unsafe { 264 from_glib_none(gtk_sys::gtk_application_get_window_by_id( 265 self.as_ref().to_glib_none().0, 266 id, 267 )) 268 } 269 } 270 get_windows(&self) -> Vec<Window>271 fn get_windows(&self) -> Vec<Window> { 272 unsafe { 273 FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_application_get_windows( 274 self.as_ref().to_glib_none().0, 275 )) 276 } 277 } 278 inhibit<P: IsA<Window>>( &self, window: Option<&P>, flags: ApplicationInhibitFlags, reason: Option<&str>, ) -> u32279 fn inhibit<P: IsA<Window>>( 280 &self, 281 window: Option<&P>, 282 flags: ApplicationInhibitFlags, 283 reason: Option<&str>, 284 ) -> u32 { 285 unsafe { 286 gtk_sys::gtk_application_inhibit( 287 self.as_ref().to_glib_none().0, 288 window.map(|p| p.as_ref()).to_glib_none().0, 289 flags.to_glib(), 290 reason.to_glib_none().0, 291 ) 292 } 293 } 294 is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool295 fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool { 296 unsafe { 297 from_glib(gtk_sys::gtk_application_is_inhibited( 298 self.as_ref().to_glib_none().0, 299 flags.to_glib(), 300 )) 301 } 302 } 303 list_action_descriptions(&self) -> Vec<GString>304 fn list_action_descriptions(&self) -> Vec<GString> { 305 unsafe { 306 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_application_list_action_descriptions( 307 self.as_ref().to_glib_none().0, 308 )) 309 } 310 } 311 prefers_app_menu(&self) -> bool312 fn prefers_app_menu(&self) -> bool { 313 unsafe { 314 from_glib(gtk_sys::gtk_application_prefers_app_menu( 315 self.as_ref().to_glib_none().0, 316 )) 317 } 318 } 319 remove_window<P: IsA<Window>>(&self, window: &P)320 fn remove_window<P: IsA<Window>>(&self, window: &P) { 321 unsafe { 322 gtk_sys::gtk_application_remove_window( 323 self.as_ref().to_glib_none().0, 324 window.as_ref().to_glib_none().0, 325 ); 326 } 327 } 328 set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str])329 fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]) { 330 unsafe { 331 gtk_sys::gtk_application_set_accels_for_action( 332 self.as_ref().to_glib_none().0, 333 detailed_action_name.to_glib_none().0, 334 accels.to_glib_none().0, 335 ); 336 } 337 } 338 set_app_menu<P: IsA<gio::MenuModel>>(&self, app_menu: Option<&P>)339 fn set_app_menu<P: IsA<gio::MenuModel>>(&self, app_menu: Option<&P>) { 340 unsafe { 341 gtk_sys::gtk_application_set_app_menu( 342 self.as_ref().to_glib_none().0, 343 app_menu.map(|p| p.as_ref()).to_glib_none().0, 344 ); 345 } 346 } 347 set_menubar<P: IsA<gio::MenuModel>>(&self, menubar: Option<&P>)348 fn set_menubar<P: IsA<gio::MenuModel>>(&self, menubar: Option<&P>) { 349 unsafe { 350 gtk_sys::gtk_application_set_menubar( 351 self.as_ref().to_glib_none().0, 352 menubar.map(|p| p.as_ref()).to_glib_none().0, 353 ); 354 } 355 } 356 uninhibit(&self, cookie: u32)357 fn uninhibit(&self, cookie: u32) { 358 unsafe { 359 gtk_sys::gtk_application_uninhibit(self.as_ref().to_glib_none().0, cookie); 360 } 361 } 362 get_property_register_session(&self) -> bool363 fn get_property_register_session(&self) -> bool { 364 unsafe { 365 let mut value = Value::from_type(<bool as StaticType>::static_type()); 366 gobject_sys::g_object_get_property( 367 self.to_glib_none().0 as *mut gobject_sys::GObject, 368 b"register-session\0".as_ptr() as *const _, 369 value.to_glib_none_mut().0, 370 ); 371 value 372 .get() 373 .expect("Return Value for property `register-session` getter") 374 .unwrap() 375 } 376 } 377 set_property_register_session(&self, register_session: bool)378 fn set_property_register_session(&self, register_session: bool) { 379 unsafe { 380 gobject_sys::g_object_set_property( 381 self.to_glib_none().0 as *mut gobject_sys::GObject, 382 b"register-session\0".as_ptr() as *const _, 383 Value::from(®ister_session).to_glib_none().0, 384 ); 385 } 386 } 387 388 #[cfg(any(feature = "v3_24", feature = "dox"))] get_property_screensaver_active(&self) -> bool389 fn get_property_screensaver_active(&self) -> bool { 390 unsafe { 391 let mut value = Value::from_type(<bool as StaticType>::static_type()); 392 gobject_sys::g_object_get_property( 393 self.to_glib_none().0 as *mut gobject_sys::GObject, 394 b"screensaver-active\0".as_ptr() as *const _, 395 value.to_glib_none_mut().0, 396 ); 397 value 398 .get() 399 .expect("Return Value for property `screensaver-active` getter") 400 .unwrap() 401 } 402 } 403 404 #[cfg(any(feature = "v3_24_8", feature = "dox"))] connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId405 fn connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 406 unsafe extern "C" fn query_end_trampoline<P, F: Fn(&P) + 'static>( 407 this: *mut gtk_sys::GtkApplication, 408 f: glib_sys::gpointer, 409 ) where 410 P: IsA<Application>, 411 { 412 let f: &F = &*(f as *const F); 413 f(&Application::from_glib_borrow(this).unsafe_cast()) 414 } 415 unsafe { 416 let f: Box_<F> = Box_::new(f); 417 connect_raw( 418 self.as_ptr() as *mut _, 419 b"query-end\0".as_ptr() as *const _, 420 Some(transmute(query_end_trampoline::<Self, F> as usize)), 421 Box_::into_raw(f), 422 ) 423 } 424 } 425 connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId426 fn connect_window_added<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId { 427 unsafe extern "C" fn window_added_trampoline<P, F: Fn(&P, &Window) + 'static>( 428 this: *mut gtk_sys::GtkApplication, 429 window: *mut gtk_sys::GtkWindow, 430 f: glib_sys::gpointer, 431 ) where 432 P: IsA<Application>, 433 { 434 let f: &F = &*(f as *const F); 435 f( 436 &Application::from_glib_borrow(this).unsafe_cast(), 437 &from_glib_borrow(window), 438 ) 439 } 440 unsafe { 441 let f: Box_<F> = Box_::new(f); 442 connect_raw( 443 self.as_ptr() as *mut _, 444 b"window-added\0".as_ptr() as *const _, 445 Some(transmute(window_added_trampoline::<Self, F> as usize)), 446 Box_::into_raw(f), 447 ) 448 } 449 } 450 connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId451 fn connect_window_removed<F: Fn(&Self, &Window) + 'static>(&self, f: F) -> SignalHandlerId { 452 unsafe extern "C" fn window_removed_trampoline<P, F: Fn(&P, &Window) + 'static>( 453 this: *mut gtk_sys::GtkApplication, 454 window: *mut gtk_sys::GtkWindow, 455 f: glib_sys::gpointer, 456 ) where 457 P: IsA<Application>, 458 { 459 let f: &F = &*(f as *const F); 460 f( 461 &Application::from_glib_borrow(this).unsafe_cast(), 462 &from_glib_borrow(window), 463 ) 464 } 465 unsafe { 466 let f: Box_<F> = Box_::new(f); 467 connect_raw( 468 self.as_ptr() as *mut _, 469 b"window-removed\0".as_ptr() as *const _, 470 Some(transmute(window_removed_trampoline::<Self, F> as usize)), 471 Box_::into_raw(f), 472 ) 473 } 474 } 475 connect_property_active_window_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId476 fn connect_property_active_window_notify<F: Fn(&Self) + 'static>( 477 &self, 478 f: F, 479 ) -> SignalHandlerId { 480 unsafe extern "C" fn notify_active_window_trampoline<P, F: Fn(&P) + 'static>( 481 this: *mut gtk_sys::GtkApplication, 482 _param_spec: glib_sys::gpointer, 483 f: glib_sys::gpointer, 484 ) where 485 P: IsA<Application>, 486 { 487 let f: &F = &*(f as *const F); 488 f(&Application::from_glib_borrow(this).unsafe_cast()) 489 } 490 unsafe { 491 let f: Box_<F> = Box_::new(f); 492 connect_raw( 493 self.as_ptr() as *mut _, 494 b"notify::active-window\0".as_ptr() as *const _, 495 Some(transmute( 496 notify_active_window_trampoline::<Self, F> as usize, 497 )), 498 Box_::into_raw(f), 499 ) 500 } 501 } 502 connect_property_app_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId503 fn connect_property_app_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 504 unsafe extern "C" fn notify_app_menu_trampoline<P, F: Fn(&P) + 'static>( 505 this: *mut gtk_sys::GtkApplication, 506 _param_spec: glib_sys::gpointer, 507 f: glib_sys::gpointer, 508 ) where 509 P: IsA<Application>, 510 { 511 let f: &F = &*(f as *const F); 512 f(&Application::from_glib_borrow(this).unsafe_cast()) 513 } 514 unsafe { 515 let f: Box_<F> = Box_::new(f); 516 connect_raw( 517 self.as_ptr() as *mut _, 518 b"notify::app-menu\0".as_ptr() as *const _, 519 Some(transmute(notify_app_menu_trampoline::<Self, F> as usize)), 520 Box_::into_raw(f), 521 ) 522 } 523 } 524 connect_property_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId525 fn connect_property_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 526 unsafe extern "C" fn notify_menubar_trampoline<P, F: Fn(&P) + 'static>( 527 this: *mut gtk_sys::GtkApplication, 528 _param_spec: glib_sys::gpointer, 529 f: glib_sys::gpointer, 530 ) where 531 P: IsA<Application>, 532 { 533 let f: &F = &*(f as *const F); 534 f(&Application::from_glib_borrow(this).unsafe_cast()) 535 } 536 unsafe { 537 let f: Box_<F> = Box_::new(f); 538 connect_raw( 539 self.as_ptr() as *mut _, 540 b"notify::menubar\0".as_ptr() as *const _, 541 Some(transmute(notify_menubar_trampoline::<Self, F> as usize)), 542 Box_::into_raw(f), 543 ) 544 } 545 } 546 connect_property_register_session_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId547 fn connect_property_register_session_notify<F: Fn(&Self) + 'static>( 548 &self, 549 f: F, 550 ) -> SignalHandlerId { 551 unsafe extern "C" fn notify_register_session_trampoline<P, F: Fn(&P) + 'static>( 552 this: *mut gtk_sys::GtkApplication, 553 _param_spec: glib_sys::gpointer, 554 f: glib_sys::gpointer, 555 ) where 556 P: IsA<Application>, 557 { 558 let f: &F = &*(f as *const F); 559 f(&Application::from_glib_borrow(this).unsafe_cast()) 560 } 561 unsafe { 562 let f: Box_<F> = Box_::new(f); 563 connect_raw( 564 self.as_ptr() as *mut _, 565 b"notify::register-session\0".as_ptr() as *const _, 566 Some(transmute( 567 notify_register_session_trampoline::<Self, F> as usize, 568 )), 569 Box_::into_raw(f), 570 ) 571 } 572 } 573 574 #[cfg(any(feature = "v3_24", feature = "dox"))] connect_property_screensaver_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId575 fn connect_property_screensaver_active_notify<F: Fn(&Self) + 'static>( 576 &self, 577 f: F, 578 ) -> SignalHandlerId { 579 unsafe extern "C" fn notify_screensaver_active_trampoline<P, F: Fn(&P) + 'static>( 580 this: *mut gtk_sys::GtkApplication, 581 _param_spec: glib_sys::gpointer, 582 f: glib_sys::gpointer, 583 ) where 584 P: IsA<Application>, 585 { 586 let f: &F = &*(f as *const F); 587 f(&Application::from_glib_borrow(this).unsafe_cast()) 588 } 589 unsafe { 590 let f: Box_<F> = Box_::new(f); 591 connect_raw( 592 self.as_ptr() as *mut _, 593 b"notify::screensaver-active\0".as_ptr() as *const _, 594 Some(transmute( 595 notify_screensaver_active_trampoline::<Self, F> as usize, 596 )), 597 Box_::into_raw(f), 598 ) 599 } 600 } 601 } 602 603 impl fmt::Display for Application { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result604 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 605 write!(f, "Application") 606 } 607 } 608