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_sys; 13 use gtk_sys; 14 use std; 15 use std::boxed::Box as Box_; 16 use std::fmt; 17 use std::mem::transmute; 18 use std::ptr; 19 use Error; 20 use FileChooserAction; 21 use FileChooserConfirmation; 22 use FileFilter; 23 use Widget; 24 25 glib_wrapper! { 26 pub struct FileChooser(Interface<gtk_sys::GtkFileChooser>); 27 28 match fn { 29 get_type => || gtk_sys::gtk_file_chooser_get_type(), 30 } 31 } 32 33 pub const NONE_FILE_CHOOSER: Option<&FileChooser> = None; 34 35 pub trait FileChooserExt: 'static { add_filter(&self, filter: &FileFilter)36 fn add_filter(&self, filter: &FileFilter); 37 add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>38 fn add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>; 39 add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>40 fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>; 41 get_action(&self) -> FileChooserAction42 fn get_action(&self) -> FileChooserAction; 43 44 #[cfg(any(feature = "v3_22", feature = "dox"))] get_choice(&self, id: &str) -> Option<GString>45 fn get_choice(&self, id: &str) -> Option<GString>; 46 get_create_folders(&self) -> bool47 fn get_create_folders(&self) -> bool; 48 get_current_folder(&self) -> Option<std::path::PathBuf>49 fn get_current_folder(&self) -> Option<std::path::PathBuf>; 50 get_current_folder_file(&self) -> Option<gio::File>51 fn get_current_folder_file(&self) -> Option<gio::File>; 52 get_current_folder_uri(&self) -> Option<GString>53 fn get_current_folder_uri(&self) -> Option<GString>; 54 get_current_name(&self) -> Option<GString>55 fn get_current_name(&self) -> Option<GString>; 56 get_do_overwrite_confirmation(&self) -> bool57 fn get_do_overwrite_confirmation(&self) -> bool; 58 get_extra_widget(&self) -> Option<Widget>59 fn get_extra_widget(&self) -> Option<Widget>; 60 get_file(&self) -> Option<gio::File>61 fn get_file(&self) -> Option<gio::File>; 62 get_filename(&self) -> Option<std::path::PathBuf>63 fn get_filename(&self) -> Option<std::path::PathBuf>; 64 get_filenames(&self) -> Vec<std::path::PathBuf>65 fn get_filenames(&self) -> Vec<std::path::PathBuf>; 66 get_files(&self) -> Vec<gio::File>67 fn get_files(&self) -> Vec<gio::File>; 68 get_filter(&self) -> Option<FileFilter>69 fn get_filter(&self) -> Option<FileFilter>; 70 get_local_only(&self) -> bool71 fn get_local_only(&self) -> bool; 72 get_preview_file(&self) -> Option<gio::File>73 fn get_preview_file(&self) -> Option<gio::File>; 74 get_preview_filename(&self) -> Option<std::path::PathBuf>75 fn get_preview_filename(&self) -> Option<std::path::PathBuf>; 76 get_preview_uri(&self) -> Option<GString>77 fn get_preview_uri(&self) -> Option<GString>; 78 get_preview_widget(&self) -> Option<Widget>79 fn get_preview_widget(&self) -> Option<Widget>; 80 get_preview_widget_active(&self) -> bool81 fn get_preview_widget_active(&self) -> bool; 82 get_select_multiple(&self) -> bool83 fn get_select_multiple(&self) -> bool; 84 get_show_hidden(&self) -> bool85 fn get_show_hidden(&self) -> bool; 86 get_uri(&self) -> Option<GString>87 fn get_uri(&self) -> Option<GString>; 88 get_uris(&self) -> Vec<GString>89 fn get_uris(&self) -> Vec<GString>; 90 get_use_preview_label(&self) -> bool91 fn get_use_preview_label(&self) -> bool; 92 list_filters(&self) -> Vec<FileFilter>93 fn list_filters(&self) -> Vec<FileFilter>; 94 list_shortcut_folder_uris(&self) -> Vec<GString>95 fn list_shortcut_folder_uris(&self) -> Vec<GString>; 96 list_shortcut_folders(&self) -> Vec<std::path::PathBuf>97 fn list_shortcut_folders(&self) -> Vec<std::path::PathBuf>; 98 99 #[cfg(any(feature = "v3_22", feature = "dox"))] remove_choice(&self, id: &str)100 fn remove_choice(&self, id: &str); 101 remove_filter(&self, filter: &FileFilter)102 fn remove_filter(&self, filter: &FileFilter); 103 remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>104 fn remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>; 105 remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>106 fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>; 107 select_all(&self)108 fn select_all(&self); 109 select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>110 fn select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>; 111 select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool112 fn select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool; 113 select_uri(&self, uri: &str) -> bool114 fn select_uri(&self, uri: &str) -> bool; 115 set_action(&self, action: FileChooserAction)116 fn set_action(&self, action: FileChooserAction); 117 118 #[cfg(any(feature = "v3_22", feature = "dox"))] set_choice(&self, id: &str, option: &str)119 fn set_choice(&self, id: &str, option: &str); 120 set_create_folders(&self, create_folders: bool)121 fn set_create_folders(&self, create_folders: bool); 122 set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool123 fn set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool; 124 set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>125 fn set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>; 126 set_current_folder_uri(&self, uri: &str) -> bool127 fn set_current_folder_uri(&self, uri: &str) -> bool; 128 set_current_name<P: AsRef<std::path::Path>>(&self, name: P)129 fn set_current_name<P: AsRef<std::path::Path>>(&self, name: P); 130 set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool)131 fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool); 132 set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P)133 fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P); 134 set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>135 fn set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>; 136 set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool137 fn set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool; 138 set_filter(&self, filter: &FileFilter)139 fn set_filter(&self, filter: &FileFilter); 140 set_local_only(&self, local_only: bool)141 fn set_local_only(&self, local_only: bool); 142 set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P)143 fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P); 144 set_preview_widget_active(&self, active: bool)145 fn set_preview_widget_active(&self, active: bool); 146 set_select_multiple(&self, select_multiple: bool)147 fn set_select_multiple(&self, select_multiple: bool); 148 set_show_hidden(&self, show_hidden: bool)149 fn set_show_hidden(&self, show_hidden: bool); 150 set_uri(&self, uri: &str) -> bool151 fn set_uri(&self, uri: &str) -> bool; 152 set_use_preview_label(&self, use_label: bool)153 fn set_use_preview_label(&self, use_label: bool); 154 unselect_all(&self)155 fn unselect_all(&self); 156 unselect_file<P: IsA<gio::File>>(&self, file: &P)157 fn unselect_file<P: IsA<gio::File>>(&self, file: &P); 158 unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P)159 fn unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P); 160 unselect_uri(&self, uri: &str)161 fn unselect_uri(&self, uri: &str); 162 connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>( &self, f: F, ) -> SignalHandlerId163 fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>( 164 &self, 165 f: F, 166 ) -> SignalHandlerId; 167 connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId168 fn connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 169 connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId170 fn connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 171 connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId172 fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 173 connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId174 fn connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 175 connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId176 fn connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 177 connect_property_create_folders_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId178 fn connect_property_create_folders_notify<F: Fn(&Self) + 'static>( 179 &self, 180 f: F, 181 ) -> SignalHandlerId; 182 connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId183 fn connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>( 184 &self, 185 f: F, 186 ) -> SignalHandlerId; 187 connect_property_extra_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId188 fn connect_property_extra_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) 189 -> SignalHandlerId; 190 connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId191 fn connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 192 connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId193 fn connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 194 connect_property_preview_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId195 fn connect_property_preview_widget_notify<F: Fn(&Self) + 'static>( 196 &self, 197 f: F, 198 ) -> SignalHandlerId; 199 connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId200 fn connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>( 201 &self, 202 f: F, 203 ) -> SignalHandlerId; 204 connect_property_select_multiple_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId205 fn connect_property_select_multiple_notify<F: Fn(&Self) + 'static>( 206 &self, 207 f: F, 208 ) -> SignalHandlerId; 209 connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId210 fn connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 211 connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId212 fn connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>( 213 &self, 214 f: F, 215 ) -> SignalHandlerId; 216 } 217 218 impl<O: IsA<FileChooser>> FileChooserExt for O { add_filter(&self, filter: &FileFilter)219 fn add_filter(&self, filter: &FileFilter) { 220 unsafe { 221 gtk_sys::gtk_file_chooser_add_filter( 222 self.as_ref().to_glib_none().0, 223 filter.to_glib_full(), 224 ); 225 } 226 } 227 add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>228 fn add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error> { 229 unsafe { 230 let mut error = ptr::null_mut(); 231 let _ = gtk_sys::gtk_file_chooser_add_shortcut_folder( 232 self.as_ref().to_glib_none().0, 233 folder.as_ref().to_glib_none().0, 234 &mut error, 235 ); 236 if error.is_null() { 237 Ok(()) 238 } else { 239 Err(from_glib_full(error)) 240 } 241 } 242 } 243 add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>244 fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error> { 245 unsafe { 246 let mut error = ptr::null_mut(); 247 let _ = gtk_sys::gtk_file_chooser_add_shortcut_folder_uri( 248 self.as_ref().to_glib_none().0, 249 uri.to_glib_none().0, 250 &mut error, 251 ); 252 if error.is_null() { 253 Ok(()) 254 } else { 255 Err(from_glib_full(error)) 256 } 257 } 258 } 259 get_action(&self) -> FileChooserAction260 fn get_action(&self) -> FileChooserAction { 261 unsafe { 262 from_glib(gtk_sys::gtk_file_chooser_get_action( 263 self.as_ref().to_glib_none().0, 264 )) 265 } 266 } 267 268 #[cfg(any(feature = "v3_22", feature = "dox"))] get_choice(&self, id: &str) -> Option<GString>269 fn get_choice(&self, id: &str) -> Option<GString> { 270 unsafe { 271 from_glib_none(gtk_sys::gtk_file_chooser_get_choice( 272 self.as_ref().to_glib_none().0, 273 id.to_glib_none().0, 274 )) 275 } 276 } 277 get_create_folders(&self) -> bool278 fn get_create_folders(&self) -> bool { 279 unsafe { 280 from_glib(gtk_sys::gtk_file_chooser_get_create_folders( 281 self.as_ref().to_glib_none().0, 282 )) 283 } 284 } 285 get_current_folder(&self) -> Option<std::path::PathBuf>286 fn get_current_folder(&self) -> Option<std::path::PathBuf> { 287 unsafe { 288 from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder( 289 self.as_ref().to_glib_none().0, 290 )) 291 } 292 } 293 get_current_folder_file(&self) -> Option<gio::File>294 fn get_current_folder_file(&self) -> Option<gio::File> { 295 unsafe { 296 from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder_file( 297 self.as_ref().to_glib_none().0, 298 )) 299 } 300 } 301 get_current_folder_uri(&self) -> Option<GString>302 fn get_current_folder_uri(&self) -> Option<GString> { 303 unsafe { 304 from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder_uri( 305 self.as_ref().to_glib_none().0, 306 )) 307 } 308 } 309 get_current_name(&self) -> Option<GString>310 fn get_current_name(&self) -> Option<GString> { 311 unsafe { 312 from_glib_full(gtk_sys::gtk_file_chooser_get_current_name( 313 self.as_ref().to_glib_none().0, 314 )) 315 } 316 } 317 get_do_overwrite_confirmation(&self) -> bool318 fn get_do_overwrite_confirmation(&self) -> bool { 319 unsafe { 320 from_glib(gtk_sys::gtk_file_chooser_get_do_overwrite_confirmation( 321 self.as_ref().to_glib_none().0, 322 )) 323 } 324 } 325 get_extra_widget(&self) -> Option<Widget>326 fn get_extra_widget(&self) -> Option<Widget> { 327 unsafe { 328 from_glib_none(gtk_sys::gtk_file_chooser_get_extra_widget( 329 self.as_ref().to_glib_none().0, 330 )) 331 } 332 } 333 get_file(&self) -> Option<gio::File>334 fn get_file(&self) -> Option<gio::File> { 335 unsafe { 336 from_glib_full(gtk_sys::gtk_file_chooser_get_file( 337 self.as_ref().to_glib_none().0, 338 )) 339 } 340 } 341 get_filename(&self) -> Option<std::path::PathBuf>342 fn get_filename(&self) -> Option<std::path::PathBuf> { 343 unsafe { 344 from_glib_full(gtk_sys::gtk_file_chooser_get_filename( 345 self.as_ref().to_glib_none().0, 346 )) 347 } 348 } 349 get_filenames(&self) -> Vec<std::path::PathBuf>350 fn get_filenames(&self) -> Vec<std::path::PathBuf> { 351 unsafe { 352 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_filenames( 353 self.as_ref().to_glib_none().0, 354 )) 355 } 356 } 357 get_files(&self) -> Vec<gio::File>358 fn get_files(&self) -> Vec<gio::File> { 359 unsafe { 360 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_files( 361 self.as_ref().to_glib_none().0, 362 )) 363 } 364 } 365 get_filter(&self) -> Option<FileFilter>366 fn get_filter(&self) -> Option<FileFilter> { 367 unsafe { 368 from_glib_none(gtk_sys::gtk_file_chooser_get_filter( 369 self.as_ref().to_glib_none().0, 370 )) 371 } 372 } 373 get_local_only(&self) -> bool374 fn get_local_only(&self) -> bool { 375 unsafe { 376 from_glib(gtk_sys::gtk_file_chooser_get_local_only( 377 self.as_ref().to_glib_none().0, 378 )) 379 } 380 } 381 get_preview_file(&self) -> Option<gio::File>382 fn get_preview_file(&self) -> Option<gio::File> { 383 unsafe { 384 from_glib_full(gtk_sys::gtk_file_chooser_get_preview_file( 385 self.as_ref().to_glib_none().0, 386 )) 387 } 388 } 389 get_preview_filename(&self) -> Option<std::path::PathBuf>390 fn get_preview_filename(&self) -> Option<std::path::PathBuf> { 391 unsafe { 392 from_glib_full(gtk_sys::gtk_file_chooser_get_preview_filename( 393 self.as_ref().to_glib_none().0, 394 )) 395 } 396 } 397 get_preview_uri(&self) -> Option<GString>398 fn get_preview_uri(&self) -> Option<GString> { 399 unsafe { 400 from_glib_full(gtk_sys::gtk_file_chooser_get_preview_uri( 401 self.as_ref().to_glib_none().0, 402 )) 403 } 404 } 405 get_preview_widget(&self) -> Option<Widget>406 fn get_preview_widget(&self) -> Option<Widget> { 407 unsafe { 408 from_glib_none(gtk_sys::gtk_file_chooser_get_preview_widget( 409 self.as_ref().to_glib_none().0, 410 )) 411 } 412 } 413 get_preview_widget_active(&self) -> bool414 fn get_preview_widget_active(&self) -> bool { 415 unsafe { 416 from_glib(gtk_sys::gtk_file_chooser_get_preview_widget_active( 417 self.as_ref().to_glib_none().0, 418 )) 419 } 420 } 421 get_select_multiple(&self) -> bool422 fn get_select_multiple(&self) -> bool { 423 unsafe { 424 from_glib(gtk_sys::gtk_file_chooser_get_select_multiple( 425 self.as_ref().to_glib_none().0, 426 )) 427 } 428 } 429 get_show_hidden(&self) -> bool430 fn get_show_hidden(&self) -> bool { 431 unsafe { 432 from_glib(gtk_sys::gtk_file_chooser_get_show_hidden( 433 self.as_ref().to_glib_none().0, 434 )) 435 } 436 } 437 get_uri(&self) -> Option<GString>438 fn get_uri(&self) -> Option<GString> { 439 unsafe { 440 from_glib_full(gtk_sys::gtk_file_chooser_get_uri( 441 self.as_ref().to_glib_none().0, 442 )) 443 } 444 } 445 get_uris(&self) -> Vec<GString>446 fn get_uris(&self) -> Vec<GString> { 447 unsafe { 448 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_uris( 449 self.as_ref().to_glib_none().0, 450 )) 451 } 452 } 453 get_use_preview_label(&self) -> bool454 fn get_use_preview_label(&self) -> bool { 455 unsafe { 456 from_glib(gtk_sys::gtk_file_chooser_get_use_preview_label( 457 self.as_ref().to_glib_none().0, 458 )) 459 } 460 } 461 list_filters(&self) -> Vec<FileFilter>462 fn list_filters(&self) -> Vec<FileFilter> { 463 unsafe { 464 FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_file_chooser_list_filters( 465 self.as_ref().to_glib_none().0, 466 )) 467 } 468 } 469 list_shortcut_folder_uris(&self) -> Vec<GString>470 fn list_shortcut_folder_uris(&self) -> Vec<GString> { 471 unsafe { 472 FromGlibPtrContainer::from_glib_full( 473 gtk_sys::gtk_file_chooser_list_shortcut_folder_uris(self.as_ref().to_glib_none().0), 474 ) 475 } 476 } 477 list_shortcut_folders(&self) -> Vec<std::path::PathBuf>478 fn list_shortcut_folders(&self) -> Vec<std::path::PathBuf> { 479 unsafe { 480 FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_list_shortcut_folders( 481 self.as_ref().to_glib_none().0, 482 )) 483 } 484 } 485 486 #[cfg(any(feature = "v3_22", feature = "dox"))] remove_choice(&self, id: &str)487 fn remove_choice(&self, id: &str) { 488 unsafe { 489 gtk_sys::gtk_file_chooser_remove_choice( 490 self.as_ref().to_glib_none().0, 491 id.to_glib_none().0, 492 ); 493 } 494 } 495 remove_filter(&self, filter: &FileFilter)496 fn remove_filter(&self, filter: &FileFilter) { 497 unsafe { 498 gtk_sys::gtk_file_chooser_remove_filter( 499 self.as_ref().to_glib_none().0, 500 filter.to_glib_none().0, 501 ); 502 } 503 } 504 remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>505 fn remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error> { 506 unsafe { 507 let mut error = ptr::null_mut(); 508 let _ = gtk_sys::gtk_file_chooser_remove_shortcut_folder( 509 self.as_ref().to_glib_none().0, 510 folder.as_ref().to_glib_none().0, 511 &mut error, 512 ); 513 if error.is_null() { 514 Ok(()) 515 } else { 516 Err(from_glib_full(error)) 517 } 518 } 519 } 520 remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>521 fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error> { 522 unsafe { 523 let mut error = ptr::null_mut(); 524 let _ = gtk_sys::gtk_file_chooser_remove_shortcut_folder_uri( 525 self.as_ref().to_glib_none().0, 526 uri.to_glib_none().0, 527 &mut error, 528 ); 529 if error.is_null() { 530 Ok(()) 531 } else { 532 Err(from_glib_full(error)) 533 } 534 } 535 } 536 select_all(&self)537 fn select_all(&self) { 538 unsafe { 539 gtk_sys::gtk_file_chooser_select_all(self.as_ref().to_glib_none().0); 540 } 541 } 542 select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>543 fn select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> { 544 unsafe { 545 let mut error = ptr::null_mut(); 546 let _ = gtk_sys::gtk_file_chooser_select_file( 547 self.as_ref().to_glib_none().0, 548 file.as_ref().to_glib_none().0, 549 &mut error, 550 ); 551 if error.is_null() { 552 Ok(()) 553 } else { 554 Err(from_glib_full(error)) 555 } 556 } 557 } 558 select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool559 fn select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool { 560 unsafe { 561 from_glib(gtk_sys::gtk_file_chooser_select_filename( 562 self.as_ref().to_glib_none().0, 563 filename.as_ref().to_glib_none().0, 564 )) 565 } 566 } 567 select_uri(&self, uri: &str) -> bool568 fn select_uri(&self, uri: &str) -> bool { 569 unsafe { 570 from_glib(gtk_sys::gtk_file_chooser_select_uri( 571 self.as_ref().to_glib_none().0, 572 uri.to_glib_none().0, 573 )) 574 } 575 } 576 set_action(&self, action: FileChooserAction)577 fn set_action(&self, action: FileChooserAction) { 578 unsafe { 579 gtk_sys::gtk_file_chooser_set_action(self.as_ref().to_glib_none().0, action.to_glib()); 580 } 581 } 582 583 #[cfg(any(feature = "v3_22", feature = "dox"))] set_choice(&self, id: &str, option: &str)584 fn set_choice(&self, id: &str, option: &str) { 585 unsafe { 586 gtk_sys::gtk_file_chooser_set_choice( 587 self.as_ref().to_glib_none().0, 588 id.to_glib_none().0, 589 option.to_glib_none().0, 590 ); 591 } 592 } 593 set_create_folders(&self, create_folders: bool)594 fn set_create_folders(&self, create_folders: bool) { 595 unsafe { 596 gtk_sys::gtk_file_chooser_set_create_folders( 597 self.as_ref().to_glib_none().0, 598 create_folders.to_glib(), 599 ); 600 } 601 } 602 set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool603 fn set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool { 604 unsafe { 605 from_glib(gtk_sys::gtk_file_chooser_set_current_folder( 606 self.as_ref().to_glib_none().0, 607 filename.as_ref().to_glib_none().0, 608 )) 609 } 610 } 611 set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>612 fn set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> { 613 unsafe { 614 let mut error = ptr::null_mut(); 615 let _ = gtk_sys::gtk_file_chooser_set_current_folder_file( 616 self.as_ref().to_glib_none().0, 617 file.as_ref().to_glib_none().0, 618 &mut error, 619 ); 620 if error.is_null() { 621 Ok(()) 622 } else { 623 Err(from_glib_full(error)) 624 } 625 } 626 } 627 set_current_folder_uri(&self, uri: &str) -> bool628 fn set_current_folder_uri(&self, uri: &str) -> bool { 629 unsafe { 630 from_glib(gtk_sys::gtk_file_chooser_set_current_folder_uri( 631 self.as_ref().to_glib_none().0, 632 uri.to_glib_none().0, 633 )) 634 } 635 } 636 set_current_name<P: AsRef<std::path::Path>>(&self, name: P)637 fn set_current_name<P: AsRef<std::path::Path>>(&self, name: P) { 638 unsafe { 639 gtk_sys::gtk_file_chooser_set_current_name( 640 self.as_ref().to_glib_none().0, 641 name.as_ref().to_glib_none().0, 642 ); 643 } 644 } 645 set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool)646 fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool) { 647 unsafe { 648 gtk_sys::gtk_file_chooser_set_do_overwrite_confirmation( 649 self.as_ref().to_glib_none().0, 650 do_overwrite_confirmation.to_glib(), 651 ); 652 } 653 } 654 set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P)655 fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P) { 656 unsafe { 657 gtk_sys::gtk_file_chooser_set_extra_widget( 658 self.as_ref().to_glib_none().0, 659 extra_widget.as_ref().to_glib_none().0, 660 ); 661 } 662 } 663 set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>664 fn set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> { 665 unsafe { 666 let mut error = ptr::null_mut(); 667 let _ = gtk_sys::gtk_file_chooser_set_file( 668 self.as_ref().to_glib_none().0, 669 file.as_ref().to_glib_none().0, 670 &mut error, 671 ); 672 if error.is_null() { 673 Ok(()) 674 } else { 675 Err(from_glib_full(error)) 676 } 677 } 678 } 679 set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool680 fn set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool { 681 unsafe { 682 from_glib(gtk_sys::gtk_file_chooser_set_filename( 683 self.as_ref().to_glib_none().0, 684 filename.as_ref().to_glib_none().0, 685 )) 686 } 687 } 688 set_filter(&self, filter: &FileFilter)689 fn set_filter(&self, filter: &FileFilter) { 690 unsafe { 691 gtk_sys::gtk_file_chooser_set_filter( 692 self.as_ref().to_glib_none().0, 693 filter.to_glib_none().0, 694 ); 695 } 696 } 697 set_local_only(&self, local_only: bool)698 fn set_local_only(&self, local_only: bool) { 699 unsafe { 700 gtk_sys::gtk_file_chooser_set_local_only( 701 self.as_ref().to_glib_none().0, 702 local_only.to_glib(), 703 ); 704 } 705 } 706 set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P)707 fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P) { 708 unsafe { 709 gtk_sys::gtk_file_chooser_set_preview_widget( 710 self.as_ref().to_glib_none().0, 711 preview_widget.as_ref().to_glib_none().0, 712 ); 713 } 714 } 715 set_preview_widget_active(&self, active: bool)716 fn set_preview_widget_active(&self, active: bool) { 717 unsafe { 718 gtk_sys::gtk_file_chooser_set_preview_widget_active( 719 self.as_ref().to_glib_none().0, 720 active.to_glib(), 721 ); 722 } 723 } 724 set_select_multiple(&self, select_multiple: bool)725 fn set_select_multiple(&self, select_multiple: bool) { 726 unsafe { 727 gtk_sys::gtk_file_chooser_set_select_multiple( 728 self.as_ref().to_glib_none().0, 729 select_multiple.to_glib(), 730 ); 731 } 732 } 733 set_show_hidden(&self, show_hidden: bool)734 fn set_show_hidden(&self, show_hidden: bool) { 735 unsafe { 736 gtk_sys::gtk_file_chooser_set_show_hidden( 737 self.as_ref().to_glib_none().0, 738 show_hidden.to_glib(), 739 ); 740 } 741 } 742 set_uri(&self, uri: &str) -> bool743 fn set_uri(&self, uri: &str) -> bool { 744 unsafe { 745 from_glib(gtk_sys::gtk_file_chooser_set_uri( 746 self.as_ref().to_glib_none().0, 747 uri.to_glib_none().0, 748 )) 749 } 750 } 751 set_use_preview_label(&self, use_label: bool)752 fn set_use_preview_label(&self, use_label: bool) { 753 unsafe { 754 gtk_sys::gtk_file_chooser_set_use_preview_label( 755 self.as_ref().to_glib_none().0, 756 use_label.to_glib(), 757 ); 758 } 759 } 760 unselect_all(&self)761 fn unselect_all(&self) { 762 unsafe { 763 gtk_sys::gtk_file_chooser_unselect_all(self.as_ref().to_glib_none().0); 764 } 765 } 766 unselect_file<P: IsA<gio::File>>(&self, file: &P)767 fn unselect_file<P: IsA<gio::File>>(&self, file: &P) { 768 unsafe { 769 gtk_sys::gtk_file_chooser_unselect_file( 770 self.as_ref().to_glib_none().0, 771 file.as_ref().to_glib_none().0, 772 ); 773 } 774 } 775 unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P)776 fn unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P) { 777 unsafe { 778 gtk_sys::gtk_file_chooser_unselect_filename( 779 self.as_ref().to_glib_none().0, 780 filename.as_ref().to_glib_none().0, 781 ); 782 } 783 } 784 unselect_uri(&self, uri: &str)785 fn unselect_uri(&self, uri: &str) { 786 unsafe { 787 gtk_sys::gtk_file_chooser_unselect_uri( 788 self.as_ref().to_glib_none().0, 789 uri.to_glib_none().0, 790 ); 791 } 792 } 793 connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>( &self, f: F, ) -> SignalHandlerId794 fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>( 795 &self, 796 f: F, 797 ) -> SignalHandlerId { 798 unsafe extern "C" fn confirm_overwrite_trampoline< 799 P, 800 F: Fn(&P) -> FileChooserConfirmation + 'static, 801 >( 802 this: *mut gtk_sys::GtkFileChooser, 803 f: glib_sys::gpointer, 804 ) -> gtk_sys::GtkFileChooserConfirmation 805 where 806 P: IsA<FileChooser>, 807 { 808 let f: &F = &*(f as *const F); 809 f(&FileChooser::from_glib_borrow(this).unsafe_cast()).to_glib() 810 } 811 unsafe { 812 let f: Box_<F> = Box_::new(f); 813 connect_raw( 814 self.as_ptr() as *mut _, 815 b"confirm-overwrite\0".as_ptr() as *const _, 816 Some(transmute(confirm_overwrite_trampoline::<Self, F> as usize)), 817 Box_::into_raw(f), 818 ) 819 } 820 } 821 connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId822 fn connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 823 unsafe extern "C" fn current_folder_changed_trampoline<P, F: Fn(&P) + 'static>( 824 this: *mut gtk_sys::GtkFileChooser, 825 f: glib_sys::gpointer, 826 ) where 827 P: IsA<FileChooser>, 828 { 829 let f: &F = &*(f as *const F); 830 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 831 } 832 unsafe { 833 let f: Box_<F> = Box_::new(f); 834 connect_raw( 835 self.as_ptr() as *mut _, 836 b"current-folder-changed\0".as_ptr() as *const _, 837 Some(transmute( 838 current_folder_changed_trampoline::<Self, F> as usize, 839 )), 840 Box_::into_raw(f), 841 ) 842 } 843 } 844 connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId845 fn connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 846 unsafe extern "C" fn file_activated_trampoline<P, F: Fn(&P) + 'static>( 847 this: *mut gtk_sys::GtkFileChooser, 848 f: glib_sys::gpointer, 849 ) where 850 P: IsA<FileChooser>, 851 { 852 let f: &F = &*(f as *const F); 853 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 854 } 855 unsafe { 856 let f: Box_<F> = Box_::new(f); 857 connect_raw( 858 self.as_ptr() as *mut _, 859 b"file-activated\0".as_ptr() as *const _, 860 Some(transmute(file_activated_trampoline::<Self, F> as usize)), 861 Box_::into_raw(f), 862 ) 863 } 864 } 865 connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId866 fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 867 unsafe extern "C" fn selection_changed_trampoline<P, F: Fn(&P) + 'static>( 868 this: *mut gtk_sys::GtkFileChooser, 869 f: glib_sys::gpointer, 870 ) where 871 P: IsA<FileChooser>, 872 { 873 let f: &F = &*(f as *const F); 874 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 875 } 876 unsafe { 877 let f: Box_<F> = Box_::new(f); 878 connect_raw( 879 self.as_ptr() as *mut _, 880 b"selection-changed\0".as_ptr() as *const _, 881 Some(transmute(selection_changed_trampoline::<Self, F> as usize)), 882 Box_::into_raw(f), 883 ) 884 } 885 } 886 connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId887 fn connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 888 unsafe extern "C" fn update_preview_trampoline<P, F: Fn(&P) + 'static>( 889 this: *mut gtk_sys::GtkFileChooser, 890 f: glib_sys::gpointer, 891 ) where 892 P: IsA<FileChooser>, 893 { 894 let f: &F = &*(f as *const F); 895 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 896 } 897 unsafe { 898 let f: Box_<F> = Box_::new(f); 899 connect_raw( 900 self.as_ptr() as *mut _, 901 b"update-preview\0".as_ptr() as *const _, 902 Some(transmute(update_preview_trampoline::<Self, F> as usize)), 903 Box_::into_raw(f), 904 ) 905 } 906 } 907 connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId908 fn connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 909 unsafe extern "C" fn notify_action_trampoline<P, F: Fn(&P) + 'static>( 910 this: *mut gtk_sys::GtkFileChooser, 911 _param_spec: glib_sys::gpointer, 912 f: glib_sys::gpointer, 913 ) where 914 P: IsA<FileChooser>, 915 { 916 let f: &F = &*(f as *const F); 917 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 918 } 919 unsafe { 920 let f: Box_<F> = Box_::new(f); 921 connect_raw( 922 self.as_ptr() as *mut _, 923 b"notify::action\0".as_ptr() as *const _, 924 Some(transmute(notify_action_trampoline::<Self, F> as usize)), 925 Box_::into_raw(f), 926 ) 927 } 928 } 929 connect_property_create_folders_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId930 fn connect_property_create_folders_notify<F: Fn(&Self) + 'static>( 931 &self, 932 f: F, 933 ) -> SignalHandlerId { 934 unsafe extern "C" fn notify_create_folders_trampoline<P, F: Fn(&P) + 'static>( 935 this: *mut gtk_sys::GtkFileChooser, 936 _param_spec: glib_sys::gpointer, 937 f: glib_sys::gpointer, 938 ) where 939 P: IsA<FileChooser>, 940 { 941 let f: &F = &*(f as *const F); 942 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 943 } 944 unsafe { 945 let f: Box_<F> = Box_::new(f); 946 connect_raw( 947 self.as_ptr() as *mut _, 948 b"notify::create-folders\0".as_ptr() as *const _, 949 Some(transmute( 950 notify_create_folders_trampoline::<Self, F> as usize, 951 )), 952 Box_::into_raw(f), 953 ) 954 } 955 } 956 connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId957 fn connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>( 958 &self, 959 f: F, 960 ) -> SignalHandlerId { 961 unsafe extern "C" fn notify_do_overwrite_confirmation_trampoline<P, F: Fn(&P) + 'static>( 962 this: *mut gtk_sys::GtkFileChooser, 963 _param_spec: glib_sys::gpointer, 964 f: glib_sys::gpointer, 965 ) where 966 P: IsA<FileChooser>, 967 { 968 let f: &F = &*(f as *const F); 969 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 970 } 971 unsafe { 972 let f: Box_<F> = Box_::new(f); 973 connect_raw( 974 self.as_ptr() as *mut _, 975 b"notify::do-overwrite-confirmation\0".as_ptr() as *const _, 976 Some(transmute( 977 notify_do_overwrite_confirmation_trampoline::<Self, F> as usize, 978 )), 979 Box_::into_raw(f), 980 ) 981 } 982 } 983 connect_property_extra_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId984 fn connect_property_extra_widget_notify<F: Fn(&Self) + 'static>( 985 &self, 986 f: F, 987 ) -> SignalHandlerId { 988 unsafe extern "C" fn notify_extra_widget_trampoline<P, F: Fn(&P) + 'static>( 989 this: *mut gtk_sys::GtkFileChooser, 990 _param_spec: glib_sys::gpointer, 991 f: glib_sys::gpointer, 992 ) where 993 P: IsA<FileChooser>, 994 { 995 let f: &F = &*(f as *const F); 996 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 997 } 998 unsafe { 999 let f: Box_<F> = Box_::new(f); 1000 connect_raw( 1001 self.as_ptr() as *mut _, 1002 b"notify::extra-widget\0".as_ptr() as *const _, 1003 Some(transmute( 1004 notify_extra_widget_trampoline::<Self, F> as usize, 1005 )), 1006 Box_::into_raw(f), 1007 ) 1008 } 1009 } 1010 connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1011 fn connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1012 unsafe extern "C" fn notify_filter_trampoline<P, F: Fn(&P) + 'static>( 1013 this: *mut gtk_sys::GtkFileChooser, 1014 _param_spec: glib_sys::gpointer, 1015 f: glib_sys::gpointer, 1016 ) where 1017 P: IsA<FileChooser>, 1018 { 1019 let f: &F = &*(f as *const F); 1020 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1021 } 1022 unsafe { 1023 let f: Box_<F> = Box_::new(f); 1024 connect_raw( 1025 self.as_ptr() as *mut _, 1026 b"notify::filter\0".as_ptr() as *const _, 1027 Some(transmute(notify_filter_trampoline::<Self, F> as usize)), 1028 Box_::into_raw(f), 1029 ) 1030 } 1031 } 1032 connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1033 fn connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1034 unsafe extern "C" fn notify_local_only_trampoline<P, F: Fn(&P) + 'static>( 1035 this: *mut gtk_sys::GtkFileChooser, 1036 _param_spec: glib_sys::gpointer, 1037 f: glib_sys::gpointer, 1038 ) where 1039 P: IsA<FileChooser>, 1040 { 1041 let f: &F = &*(f as *const F); 1042 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1043 } 1044 unsafe { 1045 let f: Box_<F> = Box_::new(f); 1046 connect_raw( 1047 self.as_ptr() as *mut _, 1048 b"notify::local-only\0".as_ptr() as *const _, 1049 Some(transmute(notify_local_only_trampoline::<Self, F> as usize)), 1050 Box_::into_raw(f), 1051 ) 1052 } 1053 } 1054 connect_property_preview_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1055 fn connect_property_preview_widget_notify<F: Fn(&Self) + 'static>( 1056 &self, 1057 f: F, 1058 ) -> SignalHandlerId { 1059 unsafe extern "C" fn notify_preview_widget_trampoline<P, F: Fn(&P) + 'static>( 1060 this: *mut gtk_sys::GtkFileChooser, 1061 _param_spec: glib_sys::gpointer, 1062 f: glib_sys::gpointer, 1063 ) where 1064 P: IsA<FileChooser>, 1065 { 1066 let f: &F = &*(f as *const F); 1067 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1068 } 1069 unsafe { 1070 let f: Box_<F> = Box_::new(f); 1071 connect_raw( 1072 self.as_ptr() as *mut _, 1073 b"notify::preview-widget\0".as_ptr() as *const _, 1074 Some(transmute( 1075 notify_preview_widget_trampoline::<Self, F> as usize, 1076 )), 1077 Box_::into_raw(f), 1078 ) 1079 } 1080 } 1081 connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1082 fn connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>( 1083 &self, 1084 f: F, 1085 ) -> SignalHandlerId { 1086 unsafe extern "C" fn notify_preview_widget_active_trampoline<P, F: Fn(&P) + 'static>( 1087 this: *mut gtk_sys::GtkFileChooser, 1088 _param_spec: glib_sys::gpointer, 1089 f: glib_sys::gpointer, 1090 ) where 1091 P: IsA<FileChooser>, 1092 { 1093 let f: &F = &*(f as *const F); 1094 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1095 } 1096 unsafe { 1097 let f: Box_<F> = Box_::new(f); 1098 connect_raw( 1099 self.as_ptr() as *mut _, 1100 b"notify::preview-widget-active\0".as_ptr() as *const _, 1101 Some(transmute( 1102 notify_preview_widget_active_trampoline::<Self, F> as usize, 1103 )), 1104 Box_::into_raw(f), 1105 ) 1106 } 1107 } 1108 connect_property_select_multiple_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1109 fn connect_property_select_multiple_notify<F: Fn(&Self) + 'static>( 1110 &self, 1111 f: F, 1112 ) -> SignalHandlerId { 1113 unsafe extern "C" fn notify_select_multiple_trampoline<P, F: Fn(&P) + 'static>( 1114 this: *mut gtk_sys::GtkFileChooser, 1115 _param_spec: glib_sys::gpointer, 1116 f: glib_sys::gpointer, 1117 ) where 1118 P: IsA<FileChooser>, 1119 { 1120 let f: &F = &*(f as *const F); 1121 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1122 } 1123 unsafe { 1124 let f: Box_<F> = Box_::new(f); 1125 connect_raw( 1126 self.as_ptr() as *mut _, 1127 b"notify::select-multiple\0".as_ptr() as *const _, 1128 Some(transmute( 1129 notify_select_multiple_trampoline::<Self, F> as usize, 1130 )), 1131 Box_::into_raw(f), 1132 ) 1133 } 1134 } 1135 connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId1136 fn connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 1137 unsafe extern "C" fn notify_show_hidden_trampoline<P, F: Fn(&P) + 'static>( 1138 this: *mut gtk_sys::GtkFileChooser, 1139 _param_spec: glib_sys::gpointer, 1140 f: glib_sys::gpointer, 1141 ) where 1142 P: IsA<FileChooser>, 1143 { 1144 let f: &F = &*(f as *const F); 1145 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1146 } 1147 unsafe { 1148 let f: Box_<F> = Box_::new(f); 1149 connect_raw( 1150 self.as_ptr() as *mut _, 1151 b"notify::show-hidden\0".as_ptr() as *const _, 1152 Some(transmute(notify_show_hidden_trampoline::<Self, F> as usize)), 1153 Box_::into_raw(f), 1154 ) 1155 } 1156 } 1157 connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId1158 fn connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>( 1159 &self, 1160 f: F, 1161 ) -> SignalHandlerId { 1162 unsafe extern "C" fn notify_use_preview_label_trampoline<P, F: Fn(&P) + 'static>( 1163 this: *mut gtk_sys::GtkFileChooser, 1164 _param_spec: glib_sys::gpointer, 1165 f: glib_sys::gpointer, 1166 ) where 1167 P: IsA<FileChooser>, 1168 { 1169 let f: &F = &*(f as *const F); 1170 f(&FileChooser::from_glib_borrow(this).unsafe_cast()) 1171 } 1172 unsafe { 1173 let f: Box_<F> = Box_::new(f); 1174 connect_raw( 1175 self.as_ptr() as *mut _, 1176 b"notify::use-preview-label\0".as_ptr() as *const _, 1177 Some(transmute( 1178 notify_use_preview_label_trampoline::<Self, F> as usize, 1179 )), 1180 Box_::into_raw(f), 1181 ) 1182 } 1183 } 1184 } 1185 1186 impl fmt::Display for FileChooser { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result1187 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 1188 write!(f, "FileChooser") 1189 } 1190 } 1191