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