[go: up one dir, main page]

gtk 0.8.1

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 glib::object::Cast;
use glib::object::IsA;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
#[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_sys;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use gobject_sys;
use gtk_sys;
#[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;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use ResponseType;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use Window;

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

    match fn {
        get_type => || gtk_sys::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) -> ResponseType;

    #[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<P: IsA<Window>>(&self, parent: Option<&P>);

    #[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 {
            gtk_sys::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(gtk_sys::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(gtk_sys::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(gtk_sys::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(gtk_sys::gtk_native_dialog_get_visible(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

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

    #[cfg(any(feature = "v3_20", feature = "dox"))]
    fn run(&self) -> ResponseType {
        unsafe {
            from_glib(gtk_sys::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 {
            gtk_sys::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 {
            gtk_sys::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<P: IsA<Window>>(&self, parent: Option<&P>) {
        unsafe {
            gtk_sys::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 {
            gtk_sys::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_sys::g_object_set_property(
                self.to_glib_none().0 as *mut gobject_sys::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 extern "C" fn response_trampoline<P, F: Fn(&P, ResponseType) + 'static>(
            this: *mut gtk_sys::GtkNativeDialog,
            response_id: gtk_sys::GtkResponseType,
            f: glib_sys::gpointer,
        ) where
            P: IsA<NativeDialog>,
        {
            let f: &F = &*(f as *const F);
            f(
                &NativeDialog::from_glib_borrow(this).unsafe_cast(),
                from_glib(response_id),
            )
        }
        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 extern "C" fn notify_modal_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut gtk_sys::GtkNativeDialog,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<NativeDialog>,
        {
            let f: &F = &*(f as *const F);
            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
        }
        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 extern "C" fn notify_title_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut gtk_sys::GtkNativeDialog,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<NativeDialog>,
        {
            let f: &F = &*(f as *const F);
            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
        }
        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 extern "C" fn notify_transient_for_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut gtk_sys::GtkNativeDialog,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<NativeDialog>,
        {
            let f: &F = &*(f as *const F);
            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
        }
        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 extern "C" fn notify_visible_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut gtk_sys::GtkNativeDialog,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<NativeDialog>,
        {
            let f: &F = &*(f as *const F);
            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
        }
        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),
            )
        }
    }
}

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