gtk/color_button.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ColorButton;
4use crate::Widget;
5use glib::object::Cast;
6use glib::object::IsA;
7use glib::translate::*;
8use std::mem;
9
10mod sealed {
11 pub trait Sealed {}
12 impl<T: glib::IsA<crate::ColorButton>> Sealed for T {}
13}
14
15pub trait ColorButtonExtManual: IsA<ColorButton> + sealed::Sealed + 'static {
16 #[doc(alias = "gtk_color_button_new_with_color")]
17 fn with_color(color: &gdk::Color) -> ColorButton {
18 assert_initialized_main_thread!();
19 unsafe { Widget::from_glib_none(ffi::gtk_color_button_new_with_color(color)).unsafe_cast() }
20 }
21
22 #[doc(alias = "gtk_color_button_get_color")]
23 #[doc(alias = "get_color")]
24 fn color(&self) -> gdk::Color {
25 unsafe {
26 let mut color = mem::MaybeUninit::uninit();
27 ffi::gtk_color_button_get_color(self.as_ref().to_glib_none().0, color.as_mut_ptr());
28 color.assume_init()
29 }
30 }
31
32 #[doc(alias = "gtk_color_button_set_color")]
33 fn set_color(&self, color: &gdk::Color) {
34 unsafe { ffi::gtk_color_button_set_color(self.as_ref().to_glib_none().0, color) }
35 }
36}
37
38impl<O: IsA<ColorButton>> ColorButtonExtManual for O {}