gtk 0.6.0

Rust bindings for the GTK+ 3 library
Documentation
// 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

#[cfg(any(feature = "v3_20", feature = "dox"))]
use ResponseType;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use Window;
use ffi;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::GString;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::Value;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::object::Cast;
use glib::object::IsA;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::signal::SignalHandlerId;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::signal::connect_raw;
use glib::translate::*;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib_ffi;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use gobject_ffi;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use std::boxed::Box as Box_;
use std::fmt;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use std::mem::transmute;

glib_wrapper! {
    pub struct NativeDialog(Object<ffi::GtkNativeDialog, ffi::GtkNativeDialogClass, NativeDialogClass>);

    match fn {
        get_type => || ffi::gtk_native_dialog_get_type(),
    }
}

pub const NONE_NATIVE_DIALOG: Option<&NativeDialog> = None;

pub trait NativeDialogExt: 'static {
    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn destroy(&self);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_modal(&self) -> bool;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_title(&self) -> Option<GString>;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_transient_for(&self) -> Option<Window>;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_visible(&self) -> bool;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn hide(&self);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn run(&self) -> i32;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_modal(&self, modal: bool);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_title(&self, title: &str);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_transient_for<'a, P: IsA<Window> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn show(&self);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_property_visible(&self, visible: bool);

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<NativeDialog>> NativeDialogExt for O {
    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn destroy(&self) {
        unsafe {
            ffi::gtk_native_dialog_destroy(self.as_ref().to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_modal(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_native_dialog_get_modal(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_title(&self) -> Option<GString> {
        unsafe {
            from_glib_none(ffi::gtk_native_dialog_get_title(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_transient_for(&self) -> Option<Window> {
        unsafe {
            from_glib_none(ffi::gtk_native_dialog_get_transient_for(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn get_visible(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_native_dialog_get_visible(self.as_ref().to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn hide(&self) {
        unsafe {
            ffi::gtk_native_dialog_hide(self.as_ref().to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn run(&self) -> i32 {
        unsafe {
            ffi::gtk_native_dialog_run(self.as_ref().to_glib_none().0)
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_modal(&self, modal: bool) {
        unsafe {
            ffi::gtk_native_dialog_set_modal(self.as_ref().to_glib_none().0, modal.to_glib());
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_title(&self, title: &str) {
        unsafe {
            ffi::gtk_native_dialog_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_transient_for<'a, P: IsA<Window> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q) {
        let parent = parent.into();
        unsafe {
            ffi::gtk_native_dialog_set_transient_for(self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn show(&self) {
        unsafe {
            ffi::gtk_native_dialog_show(self.as_ref().to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn set_property_visible(&self, visible: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"visible\0".as_ptr() as *const _, Value::from(&visible).to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"response\0".as_ptr() as *const _,
                Some(transmute(response_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::modal\0".as_ptr() as *const _,
                Some(transmute(notify_modal_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::title\0".as_ptr() as *const _,
                Some(transmute(notify_title_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::transient-for\0".as_ptr() as *const _,
                Some(transmute(notify_transient_for_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn connect_property_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::visible\0".as_ptr() as *const _,
                Some(transmute(notify_visible_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn response_trampoline<P, F: Fn(&P, ResponseType) + 'static>(this: *mut ffi::GtkNativeDialog, response_id: ffi::GtkResponseType, f: glib_ffi::gpointer)
where P: IsA<NativeDialog> {
    let f: &F = transmute(f);
    f(&NativeDialog::from_glib_borrow(this).unsafe_cast(), from_glib(response_id))
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn notify_modal_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkNativeDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<NativeDialog> {
    let f: &F = transmute(f);
    f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn notify_title_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkNativeDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<NativeDialog> {
    let f: &F = transmute(f);
    f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn notify_transient_for_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkNativeDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<NativeDialog> {
    let f: &F = transmute(f);
    f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn notify_visible_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkNativeDialog, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<NativeDialog> {
    let f: &F = transmute(f);
    f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
}

impl fmt::Display for NativeDialog {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "NativeDialog")
    }
}