use Actionable;
use Bin;
use Button;
use ColorChooser;
use Container;
use Widget;
use ffi;
use glib::object::Downcast;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct ColorButton(Object<ffi::GtkColorButton>): Button, Bin, Container, Widget, Actionable, ColorChooser;
match fn {
get_type => || ffi::gtk_color_button_get_type(),
}
}
impl ColorButton {
pub fn new() -> ColorButton {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_color_button_new()).downcast_unchecked()
}
}
pub fn get_title(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gtk_color_button_get_title(self.to_glib_none().0))
}
}
pub fn set_title(&self, title: &str) {
unsafe {
ffi::gtk_color_button_set_title(self.to_glib_none().0, title.to_glib_none().0);
}
}
pub fn connect_color_set<F: Fn(&ColorButton) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&ColorButton) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "color-set",
transmute(color_set_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn color_set_trampoline(this: *mut ffi::GtkColorButton, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&ColorButton) + 'static> = transmute(f);
f(&from_glib_none(this))
}