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

use glib::{prelude::*, translate::*};
use std::fmt;

glib::wrapper! {
    #[doc(alias = "AtkAction")]
    pub struct Action(Interface<ffi::AtkAction, ffi::AtkActionIface>);

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

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

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Action>> Sealed for T {}
}

pub trait AtkActionExt: IsA<Action> + sealed::Sealed + 'static {
    #[doc(alias = "atk_action_do_action")]
    fn do_action(&self, i: i32) -> bool {
        unsafe { from_glib(ffi::atk_action_do_action(self.as_ref().to_glib_none().0, i)) }
    }

    #[doc(alias = "atk_action_get_description")]
    #[doc(alias = "get_description")]
    fn description(&self, i: i32) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::atk_action_get_description(
                self.as_ref().to_glib_none().0,
                i,
            ))
        }
    }

    #[doc(alias = "atk_action_get_keybinding")]
    #[doc(alias = "get_keybinding")]
    fn keybinding(&self, i: i32) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::atk_action_get_keybinding(
                self.as_ref().to_glib_none().0,
                i,
            ))
        }
    }

    #[doc(alias = "atk_action_get_localized_name")]
    #[doc(alias = "get_localized_name")]
    fn localized_name(&self, i: i32) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::atk_action_get_localized_name(
                self.as_ref().to_glib_none().0,
                i,
            ))
        }
    }

    #[doc(alias = "atk_action_get_n_actions")]
    #[doc(alias = "get_n_actions")]
    fn n_actions(&self) -> i32 {
        unsafe { ffi::atk_action_get_n_actions(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "atk_action_get_name")]
    #[doc(alias = "get_name")]
    fn name(&self, i: i32) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::atk_action_get_name(self.as_ref().to_glib_none().0, i)) }
    }

    #[doc(alias = "atk_action_set_description")]
    fn set_description(&self, i: i32, desc: &str) -> bool {
        unsafe {
            from_glib(ffi::atk_action_set_description(
                self.as_ref().to_glib_none().0,
                i,
                desc.to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<Action>> AtkActionExt for O {}

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