use crate::ffi;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "BisEnumListItem")]
pub struct EnumListItem(Object<ffi::BisEnumListItem, ffi::BisEnumListItemClass>);
match fn {
type_ => || ffi::bis_enum_list_item_get_type(),
}
}
impl EnumListItem {
#[doc(alias = "bis_enum_list_item_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::bis_enum_list_item_get_name(self.to_glib_none().0)) }
}
#[doc(alias = "bis_enum_list_item_get_nick")]
#[doc(alias = "get_nick")]
pub fn nick(&self) -> glib::GString {
unsafe { from_glib_none(ffi::bis_enum_list_item_get_nick(self.to_glib_none().0)) }
}
#[doc(alias = "bis_enum_list_item_get_value")]
#[doc(alias = "get_value")]
pub fn value(&self) -> i32 {
unsafe { ffi::bis_enum_list_item_get_value(self.to_glib_none().0) }
}
#[doc(alias = "name")]
pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_name_trampoline<F: Fn(&EnumListItem) + 'static>(
this: *mut ffi::BisEnumListItem,
_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::name\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_name_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "nick")]
pub fn connect_nick_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_nick_trampoline<F: Fn(&EnumListItem) + 'static>(
this: *mut ffi::BisEnumListItem,
_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::nick\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_nick_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "value")]
pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_value_trampoline<F: Fn(&EnumListItem) + 'static>(
this: *mut ffi::BisEnumListItem,
_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::value\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_value_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl std::fmt::Display for EnumListItem {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.name())
}
}