libflatpak 0.2.0

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

use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    #[doc(alias = "FlatpakTransactionProgress")]
    pub struct TransactionProgress(Object<ffi::FlatpakTransactionProgress, ffi::FlatpakTransactionProgressClass>);

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

impl TransactionProgress {
    #[cfg(any(feature = "v1_1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1_2")))]
    #[doc(alias = "flatpak_transaction_progress_get_bytes_transferred")]
    #[doc(alias = "get_bytes_transferred")]
    pub fn bytes_transferred(&self) -> u64 {
        unsafe { ffi::flatpak_transaction_progress_get_bytes_transferred(self.to_glib_none().0) }
    }

    #[doc(alias = "flatpak_transaction_progress_get_is_estimating")]
    #[doc(alias = "get_is_estimating")]
    pub fn is_estimating(&self) -> bool {
        unsafe {
            from_glib(ffi::flatpak_transaction_progress_get_is_estimating(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "flatpak_transaction_progress_get_progress")]
    #[doc(alias = "get_progress")]
    pub fn progress(&self) -> i32 {
        unsafe { ffi::flatpak_transaction_progress_get_progress(self.to_glib_none().0) }
    }

    #[cfg(any(feature = "v1_1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_1_2")))]
    #[doc(alias = "flatpak_transaction_progress_get_start_time")]
    #[doc(alias = "get_start_time")]
    pub fn start_time(&self) -> u64 {
        unsafe { ffi::flatpak_transaction_progress_get_start_time(self.to_glib_none().0) }
    }

    #[doc(alias = "flatpak_transaction_progress_get_status")]
    #[doc(alias = "get_status")]
    pub fn status(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::flatpak_transaction_progress_get_status(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "flatpak_transaction_progress_set_update_frequency")]
    pub fn set_update_frequency(&self, update_interval: u32) {
        unsafe {
            ffi::flatpak_transaction_progress_set_update_frequency(
                self.to_glib_none().0,
                update_interval,
            );
        }
    }

    #[doc(alias = "changed")]
    pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<F: Fn(&TransactionProgress) + 'static>(
            this: *mut ffi::FlatpakTransactionProgress,
            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"changed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    changed_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for TransactionProgress {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("TransactionProgress")
    }
}