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

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

glib::wrapper! {
    #[doc(alias = "OstreeAsyncProgress")]
    pub struct AsyncProgress(Object<ffi::OstreeAsyncProgress, ffi::OstreeAsyncProgressClass>);

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

impl AsyncProgress {
    #[doc(alias = "ostree_async_progress_new")]
    pub fn new() -> AsyncProgress {
        unsafe {
            from_glib_full(ffi::ostree_async_progress_new())
        }
    }

    //#[doc(alias = "ostree_async_progress_new_and_connect")]
    //pub fn new_and_connect(changed: /*Unimplemented*/Option<Basic: Pointer>, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> AsyncProgress {
    //    unsafe { TODO: call ffi:ostree_async_progress_new_and_connect() }
    //}

    #[cfg(feature = "v2019_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2019_6")))]
    #[doc(alias = "ostree_async_progress_copy_state")]
    pub fn copy_state(&self, dest: &AsyncProgress) {
        unsafe {
            ffi::ostree_async_progress_copy_state(self.to_glib_none().0, dest.to_glib_none().0);
        }
    }

    #[doc(alias = "ostree_async_progress_finish")]
    pub fn finish(&self) {
        unsafe {
            ffi::ostree_async_progress_finish(self.to_glib_none().0);
        }
    }

    //#[cfg(feature = "v2017_6")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v2017_6")))]
    //#[doc(alias = "ostree_async_progress_get")]
    //pub fn get(&self, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
    //    unsafe { TODO: call ffi:ostree_async_progress_get() }
    //}

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

    #[doc(alias = "ostree_async_progress_get_uint")]
    #[doc(alias = "get_uint")]
    pub fn uint(&self, key: &str) -> u32 {
        unsafe {
            ffi::ostree_async_progress_get_uint(self.to_glib_none().0, key.to_glib_none().0)
        }
    }

    #[doc(alias = "ostree_async_progress_get_uint64")]
    #[doc(alias = "get_uint64")]
    pub fn uint64(&self, key: &str) -> u64 {
        unsafe {
            ffi::ostree_async_progress_get_uint64(self.to_glib_none().0, key.to_glib_none().0)
        }
    }

    #[cfg(feature = "v2017_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2017_6")))]
    #[doc(alias = "ostree_async_progress_get_variant")]
    #[doc(alias = "get_variant")]
    pub fn variant(&self, key: &str) -> Option<glib::Variant> {
        unsafe {
            from_glib_full(ffi::ostree_async_progress_get_variant(self.to_glib_none().0, key.to_glib_none().0))
        }
    }

    //#[cfg(feature = "v2017_6")]
    //#[cfg_attr(docsrs, doc(cfg(feature = "v2017_6")))]
    //#[doc(alias = "ostree_async_progress_set")]
    //pub fn set(&self, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
    //    unsafe { TODO: call ffi:ostree_async_progress_set() }
    //}

    #[cfg(feature = "v2017_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2017_6")))]
    #[doc(alias = "ostree_async_progress_set_status")]
    pub fn set_status(&self, status: Option<&str>) {
        unsafe {
            ffi::ostree_async_progress_set_status(self.to_glib_none().0, status.to_glib_none().0);
        }
    }

    #[doc(alias = "ostree_async_progress_set_uint")]
    pub fn set_uint(&self, key: &str, value: u32) {
        unsafe {
            ffi::ostree_async_progress_set_uint(self.to_glib_none().0, key.to_glib_none().0, value);
        }
    }

    #[doc(alias = "ostree_async_progress_set_uint64")]
    pub fn set_uint64(&self, key: &str, value: u64) {
        unsafe {
            ffi::ostree_async_progress_set_uint64(self.to_glib_none().0, key.to_glib_none().0, value);
        }
    }

    #[cfg(feature = "v2017_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2017_6")))]
    #[doc(alias = "ostree_async_progress_set_variant")]
    pub fn set_variant(&self, key: &str, value: &glib::Variant) {
        unsafe {
            ffi::ostree_async_progress_set_variant(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0);
        }
    }

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

impl Default for AsyncProgress {
                     fn default() -> Self {
                         Self::new()
                     }
                 }
