use glib::prelude::*;
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
use glib::{
signal::{connect_raw, SignalHandlerId},
translate::*,
};
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "WebKitColorChooserRequest")]
pub struct ColorChooserRequest(Object<ffi::WebKitColorChooserRequest, ffi::WebKitColorChooserRequestClass>);
match fn {
type_ => || ffi::webkit_color_chooser_request_get_type(),
}
}
impl ColorChooserRequest {
pub const NONE: Option<&'static ColorChooserRequest> = None;
pub fn builder() -> ColorChooserRequestBuilder {
ColorChooserRequestBuilder::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct ColorChooserRequestBuilder {
builder: glib::object::ObjectBuilder<'static, ColorChooserRequest>,
}
impl ColorChooserRequestBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
pub fn rgba(self, rgba: &gdk::RGBA) -> Self {
Self {
builder: self.builder.property("rgba", rgba),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> ColorChooserRequest {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::ColorChooserRequest>> Sealed for T {}
}
pub trait ColorChooserRequestExt: IsA<ColorChooserRequest> + sealed::Sealed + 'static {
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "webkit_color_chooser_request_cancel")]
fn cancel(&self) {
unsafe {
ffi::webkit_color_chooser_request_cancel(self.as_ref().to_glib_none().0);
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "webkit_color_chooser_request_finish")]
fn finish(&self) {
unsafe {
ffi::webkit_color_chooser_request_finish(self.as_ref().to_glib_none().0);
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "webkit_color_chooser_request_get_element_rectangle")]
#[doc(alias = "get_element_rectangle")]
fn element_rectangle(&self) -> gdk::Rectangle {
unsafe {
let mut rect = gdk::Rectangle::uninitialized();
ffi::webkit_color_chooser_request_get_element_rectangle(
self.as_ref().to_glib_none().0,
rect.to_glib_none_mut().0,
);
rect
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "webkit_color_chooser_request_get_rgba")]
#[doc(alias = "get_rgba")]
fn rgba(&self) -> gdk::RGBA {
unsafe {
let mut rgba = gdk::RGBA::uninitialized();
ffi::webkit_color_chooser_request_get_rgba(
self.as_ref().to_glib_none().0,
rgba.to_glib_none_mut().0,
);
rgba
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "webkit_color_chooser_request_set_rgba")]
fn set_rgba(&self, rgba: &gdk::RGBA) {
unsafe {
ffi::webkit_color_chooser_request_set_rgba(
self.as_ref().to_glib_none().0,
rgba.to_glib_none().0,
);
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "finished")]
fn connect_finished<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn finished_trampoline<P: IsA<ColorChooserRequest>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitColorChooserRequest,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ColorChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"finished\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
finished_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v2_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
#[doc(alias = "rgba")]
fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_rgba_trampoline<
P: IsA<ColorChooserRequest>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitColorChooserRequest,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ColorChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::rgba\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_rgba_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<ColorChooserRequest>> ColorChooserRequestExt for O {}