clepsydre-rebind 0.1.0

Safe bindings for libclepsydre
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from ../gir-files
// DO NOT EDIT

use crate::{Manager, Timeframe, ffi};
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "ClepsydreSubscription")]
    pub struct Subscription(Object<ffi::ClepsydreSubscription, ffi::ClepsydreSubscriptionClass>) @implements gio::ListModel;

    match fn {
        type_ => || ffi::clepsydre_subscription_get_type(),
    }
}

impl Subscription {
    pub const NONE: Option<&'static Subscription> = None;
}

pub trait SubscriptionExt: IsA<Subscription> + 'static {
    #[doc(alias = "clepsydre_subscription_get_manager")]
    #[doc(alias = "get_manager")]
    fn manager(&self) -> Option<Manager> {
        unsafe {
            from_glib_full(ffi::clepsydre_subscription_get_manager(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "clepsydre_subscription_get_timeframe")]
    #[doc(alias = "get_timeframe")]
    fn timeframe(&self) -> Option<Timeframe> {
        unsafe {
            from_glib_full(ffi::clepsydre_subscription_get_timeframe(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "clepsydre_subscription_set_timeframe")]
    #[doc(alias = "timeframe")]
    fn set_timeframe(&self, timeframe: Option<&Timeframe>) {
        unsafe {
            ffi::clepsydre_subscription_set_timeframe(
                self.as_ref().to_glib_none().0,
                timeframe.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "timeframe")]
    fn connect_timeframe_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_timeframe_trampoline<
            P: IsA<Subscription>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ClepsydreSubscription,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(Subscription::from_glib_borrow(this).unsafe_cast_ref())
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::timeframe".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_timeframe_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Subscription>> SubscriptionExt for O {}