use crate::ffi;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "WebKitNotification")]
pub struct Notification(Object<ffi::WebKitNotification, ffi::WebKitNotificationClass>);
match fn {
type_ => || ffi::webkit_notification_get_type(),
}
}
impl Notification {
#[doc(alias = "webkit_notification_clicked")]
pub fn clicked(&self) {
unsafe {
ffi::webkit_notification_clicked(self.to_glib_none().0);
}
}
#[doc(alias = "webkit_notification_close")]
pub fn close(&self) {
unsafe {
ffi::webkit_notification_close(self.to_glib_none().0);
}
}
#[doc(alias = "webkit_notification_get_body")]
#[doc(alias = "get_body")]
pub fn body(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_notification_get_body(self.to_glib_none().0)) }
}
#[doc(alias = "webkit_notification_get_id")]
#[doc(alias = "get_id")]
pub fn id(&self) -> u64 {
unsafe { ffi::webkit_notification_get_id(self.to_glib_none().0) }
}
#[doc(alias = "webkit_notification_get_tag")]
#[doc(alias = "get_tag")]
pub fn tag(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_notification_get_tag(self.to_glib_none().0)) }
}
#[doc(alias = "webkit_notification_get_title")]
#[doc(alias = "get_title")]
pub fn title(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_notification_get_title(self.to_glib_none().0)) }
}
#[doc(alias = "clicked")]
pub fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn clicked_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
f: glib::ffi::gpointer,
) {
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 _,
b"clicked\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
clicked_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "closed")]
pub fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn closed_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
f: glib::ffi::gpointer,
) {
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 _,
b"closed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
closed_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "body")]
pub fn connect_body_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_body_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
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 _,
b"notify::body\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_body_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "id")]
pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_id_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
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 _,
b"notify::id\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_id_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "tag")]
pub fn connect_tag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tag_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
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 _,
b"notify::tag\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_tag_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "title")]
pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_title_trampoline<F: Fn(&Notification) + 'static>(
this: *mut ffi::WebKitNotification,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
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 _,
b"notify::title\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_title_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}