// 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 crate::ShortcutAction;
use glib::object::Cast;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;

glib::glib_wrapper! {
    pub struct NamedAction(Object<ffi::GtkNamedAction, ffi::GtkNamedActionClass>) @extends ShortcutAction;

    match fn {
        get_type => || ffi::gtk_named_action_get_type(),
    }
}

impl NamedAction {
    #[doc(alias = "gtk_named_action_new")]
    pub fn new(name: &str) -> NamedAction {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_named_action_new(name.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_named_action_get_action_name")]
    pub fn get_action_name(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::gtk_named_action_get_action_name(self.to_glib_none().0)) }
    }
}

#[derive(Clone, Default)]
pub struct NamedActionBuilder {
    action_name: Option<String>,
}

impl NamedActionBuilder {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn build(self) -> NamedAction {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        if let Some(ref action_name) = self.action_name {
            properties.push(("action-name", action_name));
        }
        let ret = glib::Object::new(NamedAction::static_type(), &properties)
            .expect("object new")
            .downcast::<NamedAction>()
            .expect("downcast");
        ret
    }

    pub fn action_name(mut self, action_name: &str) -> Self {
        self.action_name = Some(action_name.to_string());
        self
    }
}

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