libfeedback 0.0.1

Rust bindings for libfeedback
Documentation
// 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::translate::*;

/// Get the application id set via [`Event::set_app_id()`][crate::Event::set_app_id()].
///
/// # Returns
///
/// the application id.
#[doc(alias = "lfb_get_app_id")]
#[doc(alias = "get_app_id")]
pub fn app_id() -> glib::GString {
    assert_initialized_main_thread!();
    unsafe { from_glib_none(ffi::lfb_get_app_id()) }
}

/// Gets the currently set feedback profile.
///
/// # Returns
///
/// The current profile or [`None`] on error.
#[doc(alias = "lfb_get_feedback_profile")]
#[doc(alias = "get_feedback_profile")]
pub fn feedback_profile() -> glib::GString {
    assert_initialized_main_thread!();
    unsafe { from_glib_none(ffi::lfb_get_feedback_profile()) }
}

//#[doc(alias = "lfb_get_proxy")]
//#[doc(alias = "get_proxy")]
//pub fn proxy() -> /*Ignored*/GdbusFeedback {
//    unsafe { TODO: call ffi:lfb_get_proxy() }
//}

/// Initialize libfeedback. This must be called before any other of libfeedback's functions.
/// ## `app_id`
/// The application id
///
/// # Returns
///
/// [`true`] if successful, or [`false`] on error.
#[doc(alias = "lfb_init")]
pub fn init(app_id: &str) -> Result<(), glib::Error> {
    assert_initialized_main_thread!();
    unsafe {
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::lfb_init(app_id.to_glib_none().0, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Gets whether or not libfeedback is initialized.
///
/// # Returns
///
/// [`true`] if libfeedback is initialized, or [`false`] otherwise.
#[doc(alias = "lfb_is_initted")]
pub fn is_initted() -> bool {
    assert_initialized_main_thread!();
    unsafe { from_glib(ffi::lfb_is_initted()) }
}

/// Sets the application id.
/// ## `app_id`
/// The application id
#[doc(alias = "lfb_set_app_id")]
pub fn set_app_id(app_id: &str) {
    assert_initialized_main_thread!();
    unsafe {
        ffi::lfb_set_app_id(app_id.to_glib_none().0);
    }
}

/// Sets the active feedback profile to #profile. It is up to the feedback
/// daemon to ignore this request. The new profile might not become active
/// immediately. You can listen to changes #LfbGdbusFeedback's ::profile
/// property to get notified when it takes effect.
/// ## `profile`
/// The profile to set
#[doc(alias = "lfb_set_feedback_profile")]
pub fn set_feedback_profile(profile: &str) {
    assert_initialized_main_thread!();
    unsafe {
        ffi::lfb_set_feedback_profile(profile.to_glib_none().0);
    }
}

/// Uninitialize the library when no longer used. Usually called
/// on program shutdown.
#[doc(alias = "lfb_uninit")]
pub fn uninit() {
    assert_initialized_main_thread!();
    unsafe {
        ffi::lfb_uninit();
    }
}