gtk 0.16.2

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

use crate::Box;
use crate::Buildable;
use crate::Container;
use crate::Orientable;
use crate::Widget;
use glib::object::Cast;
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    #[doc(alias = "GtkShortcutLabel")]
    pub struct ShortcutLabel(Object<ffi::GtkShortcutLabel, ffi::GtkShortcutLabelClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;

    match fn {
        type_ => || ffi::gtk_shortcut_label_get_type(),
    }
}

impl ShortcutLabel {
    #[doc(alias = "gtk_shortcut_label_new")]
    pub fn new(accelerator: &str) -> ShortcutLabel {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_shortcut_label_new(accelerator.to_glib_none().0))
                .unsafe_cast()
        }
    }

    #[doc(alias = "gtk_shortcut_label_get_accelerator")]
    #[doc(alias = "get_accelerator")]
    pub fn accelerator(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_shortcut_label_get_accelerator(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_shortcut_label_get_disabled_text")]
    #[doc(alias = "get_disabled_text")]
    pub fn disabled_text(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_shortcut_label_get_disabled_text(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_shortcut_label_set_accelerator")]
    pub fn set_accelerator(&self, accelerator: &str) {
        unsafe {
            ffi::gtk_shortcut_label_set_accelerator(
                self.to_glib_none().0,
                accelerator.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "gtk_shortcut_label_set_disabled_text")]
    pub fn set_disabled_text(&self, disabled_text: &str) {
        unsafe {
            ffi::gtk_shortcut_label_set_disabled_text(
                self.to_glib_none().0,
                disabled_text.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "accelerator")]
    pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutLabel) + 'static>(
            this: *mut ffi::GtkShortcutLabel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::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::<_, unsafe extern "C" fn()>(
                    notify_accelerator_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "disabled-text")]
    pub fn connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
            this: *mut ffi::GtkShortcutLabel,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::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::<_, unsafe extern "C" fn()>(
                    notify_disabled_text_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

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