gio 0.5.1

Rust bindings for the Gio 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 Icon;
use LoadableIcon;
use ffi;
use glib;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use glib::object::Downcast;
use glib::object::IsA;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use glib::signal::SignalHandlerId;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use std::boxed::Box as Box_;
use std::mem;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
    pub struct BytesIcon(Object<ffi::GBytesIcon>): Icon, LoadableIcon;

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

impl BytesIcon {
    #[cfg(any(feature = "v2_38", feature = "dox"))]
    pub fn new(bytes: &glib::Bytes) -> BytesIcon {
        unsafe {
            from_glib_full(ffi::g_bytes_icon_new(bytes.to_glib_none().0))
        }
    }
}

pub trait BytesIconExt {
    #[cfg(any(feature = "v2_38", feature = "dox"))]
    fn get_bytes(&self) -> Option<glib::Bytes>;

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

impl<O: IsA<BytesIcon> + IsA<glib::object::Object>> BytesIconExt for O {
    #[cfg(any(feature = "v2_38", feature = "dox"))]
    fn get_bytes(&self) -> Option<glib::Bytes> {
        unsafe {
            from_glib_none(ffi::g_bytes_icon_get_bytes(self.to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v2_38", feature = "dox"))]
    fn connect_property_bytes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::bytes",
                transmute(notify_bytes_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

#[cfg(any(feature = "v2_38", feature = "dox"))]
unsafe extern "C" fn notify_bytes_trampoline<P>(this: *mut ffi::GBytesIcon, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BytesIcon> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&BytesIcon::from_glib_borrow(this).downcast_unchecked())
}