webkit6 0.6.1

Rust bindings for WebKit 6.0
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::ffi;
use glib::{
    object::ObjectType as _,
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
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 {
    #[doc(alias = "webkit_color_chooser_request_cancel")]
    pub fn cancel(&self) {
        unsafe {
            ffi::webkit_color_chooser_request_cancel(self.to_glib_none().0);
        }
    }

    #[doc(alias = "webkit_color_chooser_request_finish")]
    pub fn finish(&self) {
        unsafe {
            ffi::webkit_color_chooser_request_finish(self.to_glib_none().0);
        }
    }

    #[doc(alias = "webkit_color_chooser_request_get_element_rectangle")]
    #[doc(alias = "get_element_rectangle")]
    pub fn element_rectangle(&self) -> gdk::Rectangle {
        unsafe {
            let mut rect = gdk::Rectangle::uninitialized();
            ffi::webkit_color_chooser_request_get_element_rectangle(
                self.to_glib_none().0,
                rect.to_glib_none_mut().0,
            );
            rect
        }
    }

    #[doc(alias = "webkit_color_chooser_request_get_rgba")]
    #[doc(alias = "get_rgba")]
    pub fn rgba(&self) -> gdk::RGBA {
        unsafe {
            let mut rgba = gdk::RGBA::uninitialized();
            ffi::webkit_color_chooser_request_get_rgba(
                self.to_glib_none().0,
                rgba.to_glib_none_mut().0,
            );
            rgba
        }
    }

    #[doc(alias = "webkit_color_chooser_request_set_rgba")]
    #[doc(alias = "rgba")]
    pub fn set_rgba(&self, rgba: &gdk::RGBA) {
        unsafe {
            ffi::webkit_color_chooser_request_set_rgba(
                self.to_glib_none().0,
                rgba.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "finished")]
    pub fn connect_finished<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn finished_trampoline<F: Fn(&ColorChooserRequest) + 'static>(
            this: *mut ffi::WebKitColorChooserRequest,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"finished".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    finished_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "rgba")]
    pub fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rgba_trampoline<F: Fn(&ColorChooserRequest) + 'static>(
            this: *mut ffi::WebKitColorChooserRequest,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::rgba".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_rgba_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}