1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use gdk;
6 use gdk_sys;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib_sys;
13 use gtk_sys;
14 use std::boxed::Box as Box_;
15 use std::fmt;
16 use std::mem::transmute;
17 
18 glib_wrapper! {
19     pub struct ColorChooser(Interface<gtk_sys::GtkColorChooser>);
20 
21     match fn {
22         get_type => || gtk_sys::gtk_color_chooser_get_type(),
23     }
24 }
25 
26 pub const NONE_COLOR_CHOOSER: Option<&ColorChooser> = None;
27 
28 pub trait ColorChooserExt: 'static {
get_rgba(&self) -> gdk::RGBA29     fn get_rgba(&self) -> gdk::RGBA;
30 
get_use_alpha(&self) -> bool31     fn get_use_alpha(&self) -> bool;
32 
set_rgba(&self, color: &gdk::RGBA)33     fn set_rgba(&self, color: &gdk::RGBA);
34 
set_use_alpha(&self, use_alpha: bool)35     fn set_use_alpha(&self, use_alpha: bool);
36 
connect_color_activated<F: Fn(&Self, &gdk::RGBA) + 'static>(&self, f: F) -> SignalHandlerId37     fn connect_color_activated<F: Fn(&Self, &gdk::RGBA) + 'static>(&self, f: F) -> SignalHandlerId;
38 
connect_property_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId39     fn connect_property_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
40 
connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId41     fn connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
42 }
43 
44 impl<O: IsA<ColorChooser>> ColorChooserExt for O {
get_rgba(&self) -> gdk::RGBA45     fn get_rgba(&self) -> gdk::RGBA {
46         unsafe {
47             let mut color = gdk::RGBA::uninitialized();
48             gtk_sys::gtk_color_chooser_get_rgba(
49                 self.as_ref().to_glib_none().0,
50                 color.to_glib_none_mut().0,
51             );
52             color
53         }
54     }
55 
get_use_alpha(&self) -> bool56     fn get_use_alpha(&self) -> bool {
57         unsafe {
58             from_glib(gtk_sys::gtk_color_chooser_get_use_alpha(
59                 self.as_ref().to_glib_none().0,
60             ))
61         }
62     }
63 
set_rgba(&self, color: &gdk::RGBA)64     fn set_rgba(&self, color: &gdk::RGBA) {
65         unsafe {
66             gtk_sys::gtk_color_chooser_set_rgba(
67                 self.as_ref().to_glib_none().0,
68                 color.to_glib_none().0,
69             );
70         }
71     }
72 
set_use_alpha(&self, use_alpha: bool)73     fn set_use_alpha(&self, use_alpha: bool) {
74         unsafe {
75             gtk_sys::gtk_color_chooser_set_use_alpha(
76                 self.as_ref().to_glib_none().0,
77                 use_alpha.to_glib(),
78             );
79         }
80     }
81 
connect_color_activated<F: Fn(&Self, &gdk::RGBA) + 'static>(&self, f: F) -> SignalHandlerId82     fn connect_color_activated<F: Fn(&Self, &gdk::RGBA) + 'static>(&self, f: F) -> SignalHandlerId {
83         unsafe extern "C" fn color_activated_trampoline<P, F: Fn(&P, &gdk::RGBA) + 'static>(
84             this: *mut gtk_sys::GtkColorChooser,
85             color: *mut gdk_sys::GdkRGBA,
86             f: glib_sys::gpointer,
87         ) where
88             P: IsA<ColorChooser>,
89         {
90             let f: &F = &*(f as *const F);
91             f(
92                 &ColorChooser::from_glib_borrow(this).unsafe_cast(),
93                 &from_glib_borrow(color),
94             )
95         }
96         unsafe {
97             let f: Box_<F> = Box_::new(f);
98             connect_raw(
99                 self.as_ptr() as *mut _,
100                 b"color-activated\0".as_ptr() as *const _,
101                 Some(transmute(color_activated_trampoline::<Self, F> as usize)),
102                 Box_::into_raw(f),
103             )
104         }
105     }
106 
connect_property_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId107     fn connect_property_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
108         unsafe extern "C" fn notify_rgba_trampoline<P, F: Fn(&P) + 'static>(
109             this: *mut gtk_sys::GtkColorChooser,
110             _param_spec: glib_sys::gpointer,
111             f: glib_sys::gpointer,
112         ) where
113             P: IsA<ColorChooser>,
114         {
115             let f: &F = &*(f as *const F);
116             f(&ColorChooser::from_glib_borrow(this).unsafe_cast())
117         }
118         unsafe {
119             let f: Box_<F> = Box_::new(f);
120             connect_raw(
121                 self.as_ptr() as *mut _,
122                 b"notify::rgba\0".as_ptr() as *const _,
123                 Some(transmute(notify_rgba_trampoline::<Self, F> as usize)),
124                 Box_::into_raw(f),
125             )
126         }
127     }
128 
connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId129     fn connect_property_use_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
130         unsafe extern "C" fn notify_use_alpha_trampoline<P, F: Fn(&P) + 'static>(
131             this: *mut gtk_sys::GtkColorChooser,
132             _param_spec: glib_sys::gpointer,
133             f: glib_sys::gpointer,
134         ) where
135             P: IsA<ColorChooser>,
136         {
137             let f: &F = &*(f as *const F);
138             f(&ColorChooser::from_glib_borrow(this).unsafe_cast())
139         }
140         unsafe {
141             let f: Box_<F> = Box_::new(f);
142             connect_raw(
143                 self.as_ptr() as *mut _,
144                 b"notify::use-alpha\0".as_ptr() as *const _,
145                 Some(transmute(notify_use_alpha_trampoline::<Self, F> as usize)),
146                 Box_::into_raw(f),
147             )
148         }
149     }
150 }
151 
152 impl fmt::Display for ColorChooser {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result153     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
154         write!(f, "ColorChooser")
155     }
156 }
157