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_22", feature = "dox"))]
use glib::object::Cast;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use glib::object::ObjectType as ObjectType_;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use glib::GString;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use glib_sys;
use gtk_sys;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use std::boxed::Box as Box_;
use std::fmt;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use std::mem::transmute;
use Box;
use Buildable;
use Container;
use Orientable;
use Widget;

glib_wrapper! {
    pub struct ShortcutLabel(Object<gtk_sys::GtkShortcutLabel, gtk_sys::GtkShortcutLabelClass, ShortcutLabelClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;

    match fn {
        get_type => || gtk_sys::gtk_shortcut_label_get_type(),
    }
}

impl ShortcutLabel {
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn new(accelerator: &str) -> ShortcutLabel {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(gtk_sys::gtk_shortcut_label_new(
                accelerator.to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn get_accelerator(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gtk_sys::gtk_shortcut_label_get_accelerator(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn get_disabled_text(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gtk_sys::gtk_shortcut_label_get_disabled_text(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn set_accelerator(&self, accelerator: &str) {
        unsafe {
            gtk_sys::gtk_shortcut_label_set_accelerator(
                self.to_glib_none().0,
                accelerator.to_glib_none().0,
            );
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn set_disabled_text(&self, disabled_text: &str) {
        unsafe {
            gtk_sys::gtk_shortcut_label_set_disabled_text(
                self.to_glib_none().0,
                disabled_text.to_glib_none().0,
            );
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn connect_property_accelerator_notify<F: Fn(&ShortcutLabel) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutLabel) + 'static>(
            this: *mut gtk_sys::GtkShortcutLabel,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::accelerator\0".as_ptr() as *const _,
                Some(transmute(notify_accelerator_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn connect_property_disabled_text_notify<F: Fn(&ShortcutLabel) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
            this: *mut gtk_sys::GtkShortcutLabel,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::disabled-text\0".as_ptr() as *const _,
                Some(transmute(notify_disabled_text_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }
}

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