// 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; use gtk_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use FileChooser; use FileChooserAction; use FileFilter; use NativeDialog; use Widget; #[cfg(any(feature = "v3_20", feature = "dox"))] use Window; glib_wrapper! { pub struct FileChooserNative(Object) @extends NativeDialog, @implements FileChooser; match fn { get_type => || gtk_sys::gtk_file_chooser_native_get_type(), } } impl FileChooserNative { #[cfg(any(feature = "v3_20", feature = "dox"))] pub fn new>( title: Option<&str>, parent: Option<&P>, action: FileChooserAction, accept_label: Option<&str>, cancel_label: Option<&str>, ) -> FileChooserNative { assert_initialized_main_thread!(); unsafe { from_glib_full(gtk_sys::gtk_file_chooser_native_new( title.to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, action.to_glib(), accept_label.to_glib_none().0, cancel_label.to_glib_none().0, )) } } } #[derive(Clone, Default)] pub struct FileChooserNativeBuilder { accept_label: Option, cancel_label: Option, #[cfg(any(feature = "v3_20", feature = "dox"))] modal: Option, #[cfg(any(feature = "v3_20", feature = "dox"))] title: Option, #[cfg(any(feature = "v3_20", feature = "dox"))] transient_for: Option, #[cfg(any(feature = "v3_20", feature = "dox"))] visible: Option, action: Option, create_folders: Option, do_overwrite_confirmation: Option, extra_widget: Option, filter: Option, local_only: Option, preview_widget: Option, preview_widget_active: Option, select_multiple: Option, show_hidden: Option, use_preview_label: Option, } impl FileChooserNativeBuilder { pub fn new() -> Self { Self::default() } pub fn build(self) -> FileChooserNative { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref accept_label) = self.accept_label { properties.push(("accept-label", accept_label)); } if let Some(ref cancel_label) = self.cancel_label { properties.push(("cancel-label", cancel_label)); } #[cfg(any(feature = "v3_20", feature = "dox"))] { if let Some(ref modal) = self.modal { properties.push(("modal", modal)); } } #[cfg(any(feature = "v3_20", feature = "dox"))] { if let Some(ref title) = self.title { properties.push(("title", title)); } } #[cfg(any(feature = "v3_20", feature = "dox"))] { if let Some(ref transient_for) = self.transient_for { properties.push(("transient-for", transient_for)); } } #[cfg(any(feature = "v3_20", feature = "dox"))] { if let Some(ref visible) = self.visible { properties.push(("visible", visible)); } } if let Some(ref action) = self.action { properties.push(("action", action)); } if let Some(ref create_folders) = self.create_folders { properties.push(("create-folders", create_folders)); } if let Some(ref do_overwrite_confirmation) = self.do_overwrite_confirmation { properties.push(("do-overwrite-confirmation", do_overwrite_confirmation)); } if let Some(ref extra_widget) = self.extra_widget { properties.push(("extra-widget", extra_widget)); } if let Some(ref filter) = self.filter { properties.push(("filter", filter)); } if let Some(ref local_only) = self.local_only { properties.push(("local-only", local_only)); } if let Some(ref preview_widget) = self.preview_widget { properties.push(("preview-widget", preview_widget)); } if let Some(ref preview_widget_active) = self.preview_widget_active { properties.push(("preview-widget-active", preview_widget_active)); } if let Some(ref select_multiple) = self.select_multiple { properties.push(("select-multiple", select_multiple)); } if let Some(ref show_hidden) = self.show_hidden { properties.push(("show-hidden", show_hidden)); } if let Some(ref use_preview_label) = self.use_preview_label { properties.push(("use-preview-label", use_preview_label)); } glib::Object::new(FileChooserNative::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn accept_label(mut self, accept_label: &str) -> Self { self.accept_label = Some(accept_label.to_string()); self } pub fn cancel_label(mut self, cancel_label: &str) -> Self { self.cancel_label = Some(cancel_label.to_string()); self } #[cfg(any(feature = "v3_20", feature = "dox"))] pub fn modal(mut self, modal: bool) -> Self { self.modal = Some(modal); self } #[cfg(any(feature = "v3_20", feature = "dox"))] pub fn title(mut self, title: &str) -> Self { self.title = Some(title.to_string()); self } #[cfg(any(feature = "v3_20", feature = "dox"))] pub fn transient_for>(mut self, transient_for: &P) -> Self { self.transient_for = Some(transient_for.clone().upcast()); self } #[cfg(any(feature = "v3_20", feature = "dox"))] pub fn visible(mut self, visible: bool) -> Self { self.visible = Some(visible); self } pub fn action(mut self, action: FileChooserAction) -> Self { self.action = Some(action); self } pub fn create_folders(mut self, create_folders: bool) -> Self { self.create_folders = Some(create_folders); self } pub fn do_overwrite_confirmation(mut self, do_overwrite_confirmation: bool) -> Self { self.do_overwrite_confirmation = Some(do_overwrite_confirmation); self } pub fn extra_widget>(mut self, extra_widget: &P) -> Self { self.extra_widget = Some(extra_widget.clone().upcast()); self } pub fn filter(mut self, filter: &FileFilter) -> Self { self.filter = Some(filter.clone()); self } pub fn local_only(mut self, local_only: bool) -> Self { self.local_only = Some(local_only); self } pub fn preview_widget>(mut self, preview_widget: &P) -> Self { self.preview_widget = Some(preview_widget.clone().upcast()); self } pub fn preview_widget_active(mut self, preview_widget_active: bool) -> Self { self.preview_widget_active = Some(preview_widget_active); self } pub fn select_multiple(mut self, select_multiple: bool) -> Self { self.select_multiple = Some(select_multiple); self } pub fn show_hidden(mut self, show_hidden: bool) -> Self { self.show_hidden = Some(show_hidden); self } pub fn use_preview_label(mut self, use_preview_label: bool) -> Self { self.use_preview_label = Some(use_preview_label); self } } pub const NONE_FILE_CHOOSER_NATIVE: Option<&FileChooserNative> = None; pub trait FileChooserNativeExt: 'static { #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_accept_label(&self) -> Option; #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_cancel_label(&self) -> Option; #[cfg(any(feature = "v3_20", feature = "dox"))] fn set_accept_label(&self, accept_label: Option<&str>); #[cfg(any(feature = "v3_20", feature = "dox"))] fn set_cancel_label(&self, cancel_label: Option<&str>); fn get_property_accept_label(&self) -> Option; fn set_property_accept_label(&self, accept_label: Option<&str>); fn get_property_cancel_label(&self) -> Option; fn set_property_cancel_label(&self, cancel_label: Option<&str>); fn connect_property_accept_label_notify(&self, f: F) -> SignalHandlerId; fn connect_property_cancel_label_notify(&self, f: F) -> SignalHandlerId; } impl> FileChooserNativeExt for O { #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_accept_label(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_file_chooser_native_get_accept_label( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v3_20", feature = "dox"))] fn get_cancel_label(&self) -> Option { unsafe { from_glib_none(gtk_sys::gtk_file_chooser_native_get_cancel_label( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v3_20", feature = "dox"))] fn set_accept_label(&self, accept_label: Option<&str>) { unsafe { gtk_sys::gtk_file_chooser_native_set_accept_label( self.as_ref().to_glib_none().0, accept_label.to_glib_none().0, ); } } #[cfg(any(feature = "v3_20", feature = "dox"))] fn set_cancel_label(&self, cancel_label: Option<&str>) { unsafe { gtk_sys::gtk_file_chooser_native_set_cancel_label( self.as_ref().to_glib_none().0, cancel_label.to_glib_none().0, ); } } fn get_property_accept_label(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"accept-label\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `accept-label` getter") } } fn set_property_accept_label(&self, accept_label: Option<&str>) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"accept-label\0".as_ptr() as *const _, Value::from(accept_label).to_glib_none().0, ); } } fn get_property_cancel_label(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"cancel-label\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `cancel-label` getter") } } fn set_property_cancel_label(&self, cancel_label: Option<&str>) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"cancel-label\0".as_ptr() as *const _, Value::from(cancel_label).to_glib_none().0, ); } } fn connect_property_accept_label_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_accept_label_trampoline( this: *mut gtk_sys::GtkFileChooserNative, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FileChooserNative::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::accept-label\0".as_ptr() as *const _, Some(transmute( notify_accept_label_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_cancel_label_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_cancel_label_trampoline( this: *mut gtk_sys::GtkFileChooserNative, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FileChooserNative::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::cancel-label\0".as_ptr() as *const _, Some(transmute( notify_cancel_label_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for FileChooserNative { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileChooserNative") } }