use crate::ffi;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "HeView")]
pub struct View(Object<ffi::HeView, ffi::HeViewClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
match fn {
type_ => || ffi::he_view_get_type(),
}
}
impl View {
pub const NONE: Option<&'static View> = None;
}
pub trait ViewExt: IsA<View> + 'static {
#[doc(alias = "he_view_add_child")]
fn add_child(
&self,
builder: >k::Builder,
child: &impl IsA<glib::Object>,
type_: Option<&str>,
) {
unsafe {
ffi::he_view_add_child(
self.as_ref().to_glib_none().0,
builder.to_glib_none().0,
child.as_ref().to_glib_none().0,
type_.to_glib_none().0,
);
}
}
#[doc(alias = "he_view_add")]
fn add(&self, widget: &impl IsA<gtk::Widget>) {
unsafe {
ffi::he_view_add(
self.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
);
}
}
#[doc(alias = "he_view_get_title")]
#[doc(alias = "get_title")]
fn title(&self) -> glib::GString {
unsafe { from_glib_none(ffi::he_view_get_title(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "he_view_set_title")]
fn set_title(&self, value: &str) {
unsafe {
ffi::he_view_set_title(self.as_ref().to_glib_none().0, value.to_glib_none().0);
}
}
#[doc(alias = "he_view_get_stack")]
#[doc(alias = "get_stack")]
fn stack(&self) -> gtk::Stack {
unsafe { from_glib_none(ffi::he_view_get_stack(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "he_view_set_stack")]
fn set_stack(&self, value: >k::Stack) {
unsafe {
ffi::he_view_set_stack(self.as_ref().to_glib_none().0, value.to_glib_none().0);
}
}
#[doc(alias = "he_view_get_subtitle")]
#[doc(alias = "get_subtitle")]
fn subtitle(&self) -> glib::GString {
unsafe { from_glib_none(ffi::he_view_get_subtitle(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "he_view_set_subtitle")]
fn set_subtitle(&self, value: &str) {
unsafe {
ffi::he_view_set_subtitle(self.as_ref().to_glib_none().0, value.to_glib_none().0);
}
}
#[doc(alias = "he_view_get_has_margins")]
#[doc(alias = "get_has_margins")]
fn has_margins(&self) -> bool {
unsafe { from_glib(ffi::he_view_get_has_margins(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "he_view_set_has_margins")]
fn set_has_margins(&self, value: bool) {
unsafe {
ffi::he_view_set_has_margins(self.as_ref().to_glib_none().0, value.into_glib());
}
}
#[doc(alias = "title")]
fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_title_trampoline<P: IsA<View>, F: Fn(&P) + 'static>(
this: *mut ffi::HeView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(View::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::title".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_title_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "stack")]
fn connect_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_stack_trampoline<P: IsA<View>, F: Fn(&P) + 'static>(
this: *mut ffi::HeView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(View::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::stack".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_stack_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "subtitle")]
fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_subtitle_trampoline<P: IsA<View>, F: Fn(&P) + 'static>(
this: *mut ffi::HeView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(View::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::subtitle".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_subtitle_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "has-margins")]
fn connect_has_margins_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_margins_trampoline<P: IsA<View>, F: Fn(&P) + 'static>(
this: *mut ffi::HeView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(View::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::has-margins".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_has_margins_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<View>> ViewExt for O {}