polkit 0.19.0

High-level bindings for libpolkit-gobject-1
// Generated by gir (https://github.com/gtk-rs/gir @ 0e476ab5c1de)
// from /usr/share/gir-1.0 (@ ???)
// DO NOT EDIT

use crate::ImplicitAuthorization;
use glib::translate::*;

glib::wrapper! {
    /// Object used to encapsulate a registered action.
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "PolkitActionDescription")]
    pub struct ActionDescription(Object<ffi::PolkitActionDescription, ffi::PolkitActionDescriptionClass>);

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

impl ActionDescription {
    /// Gets the action id for `self`.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_action_id")]
    #[doc(alias = "get_action_id")]
    pub fn action_id(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_action_id(
                self.to_glib_none().0,
            ))
        }
    }

    /// Get the value of the annotation with `key`.
    /// ## `key`
    /// An annotation key.
    ///
    /// # Returns
    ///
    /// [`None`] if there is no annoation with `key`,
    /// otherwise the annotation value owned by `self`. Do not
    /// free.
    #[doc(alias = "polkit_action_description_get_annotation")]
    #[doc(alias = "get_annotation")]
    pub fn annotation(&self, key: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_annotation(
                self.to_glib_none().0,
                key.to_glib_none().0,
            ))
        }
    }

    /// Gets the keys of annotations defined in `self`.
    ///
    /// # Returns
    ///
    /// The annotation keys owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_annotation_keys")]
    #[doc(alias = "get_annotation_keys")]
    pub fn annotation_keys(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                ffi::polkit_action_description_get_annotation_keys(self.to_glib_none().0),
            )
        }
    }

    /// Gets the description used for `self`.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_description")]
    #[doc(alias = "get_description")]
    pub fn description(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_description(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the icon name for `self`, if any.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_icon_name")]
    #[doc(alias = "get_icon_name")]
    pub fn icon_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_icon_name(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the implicit authorization for `self` used for
    /// subjects in active sessions on a local console.
    ///
    /// # Returns
    ///
    /// A value from the [`ImplicitAuthorization`][crate::ImplicitAuthorization] enumeration.
    #[doc(alias = "polkit_action_description_get_implicit_active")]
    #[doc(alias = "get_implicit_active")]
    pub fn implicit_active(&self) -> ImplicitAuthorization {
        unsafe {
            from_glib(ffi::polkit_action_description_get_implicit_active(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the implicit authorization for `self` used for
    /// any subject.
    ///
    /// # Returns
    ///
    /// A value from the [`ImplicitAuthorization`][crate::ImplicitAuthorization] enumeration.
    #[doc(alias = "polkit_action_description_get_implicit_any")]
    #[doc(alias = "get_implicit_any")]
    pub fn implicit_any(&self) -> ImplicitAuthorization {
        unsafe {
            from_glib(ffi::polkit_action_description_get_implicit_any(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the implicit authorization for `self` used for
    /// subjects in inactive sessions on a local console.
    ///
    /// # Returns
    ///
    /// A value from the [`ImplicitAuthorization`][crate::ImplicitAuthorization] enumeration.
    #[doc(alias = "polkit_action_description_get_implicit_inactive")]
    #[doc(alias = "get_implicit_inactive")]
    pub fn implicit_inactive(&self) -> ImplicitAuthorization {
        unsafe {
            from_glib(ffi::polkit_action_description_get_implicit_inactive(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the message used for `self`.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_message")]
    #[doc(alias = "get_message")]
    pub fn message(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_message(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the vendor name for `self`, if any.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_vendor_name")]
    #[doc(alias = "get_vendor_name")]
    pub fn vendor_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_vendor_name(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the vendor URL for `self`, if any.
    ///
    /// # Returns
    ///
    /// A string owned by `self`. Do not free.
    #[doc(alias = "polkit_action_description_get_vendor_url")]
    #[doc(alias = "get_vendor_url")]
    pub fn vendor_url(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::polkit_action_description_get_vendor_url(
                self.to_glib_none().0,
            ))
        }
    }
}