// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../../girs
// from ../../gtk-girs
// 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! {
    /// Notification action.
    ///
    /// ## Properties
    ///
    ///
    /// #### `id`
    ///  Id of this action.
    ///
    /// Readable | Writeable | Construct
    ///
    ///
    /// #### `label`
    ///  Label of this action that should be displayed to user.
    ///
    /// Readable | Writeable | Construct
    ///
    /// ## Signals
    ///
    ///
    /// #### `invoked`
    ///  Emitted when the notification this action was added to invoked this action.
    ///
    ///
    ///
    /// # Implements
    ///
    /// [`ActionExt`][trait@crate::prelude::ActionExt]
    #[doc(alias = "AstalNotifdAction")]
    pub struct Action(Object<ffi::AstalNotifdAction, ffi::AstalNotifdActionClass>);

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

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

    #[doc(alias = "astal_notifd_action_new")]
    pub fn new(id: &str, label: &str) -> Action {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::astal_notifd_action_new(id.to_glib_none().0, label.to_glib_none().0))
        }
    }

            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`Action`] objects.
            ///
            /// This method returns an instance of [`ActionBuilder`](crate::builders::ActionBuilder) which can be used to create [`Action`] objects.
            pub fn builder() -> ActionBuilder {
                ActionBuilder::new()
            }
        
}

impl Default for Action {
                     fn default() -> Self {
                         glib::object::Object::new::<Self>()
                     }
                 }

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`Action`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct ActionBuilder {
            builder: glib::object::ObjectBuilder<'static, Action>,
        }

        impl ActionBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            /// Id of this action.
                            pub fn id(self, id: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("id", id.into()), }
                        }

                            /// Label of this action that should be displayed to user.
                            pub fn label(self, label: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("label", label.into()), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`Action`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Action {
assert_initialized_main_thread!();
    self.builder.build() }
}

/// Trait containing all [`struct@Action`] methods.
///
/// # Implementors
///
/// [`Action`][struct@crate::Action]
pub trait ActionExt: IsA<Action> + 'static {
    /// Invoke this action. Note that this method just notifies the client that this action was invoked by the user. If for example this notification
    /// persists through the lifetime of the sending application this action will have no effect.
    #[doc(alias = "astal_notifd_action_invoke")]
    fn invoke(&self) {
        unsafe {
            ffi::astal_notifd_action_invoke(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "astal_notifd_action_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::astal_notifd_action_get_id(self.as_ref().to_glib_none().0))
        }
    }

    #[doc(alias = "astal_notifd_action_set_id")]
    fn set_id(&self, value: &str) {
        unsafe {
            ffi::astal_notifd_action_set_id(self.as_ref().to_glib_none().0, value.to_glib_none().0);
        }
    }

    #[doc(alias = "astal_notifd_action_get_label")]
    #[doc(alias = "get_label")]
    fn label(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::astal_notifd_action_get_label(self.as_ref().to_glib_none().0))
        }
    }

    #[doc(alias = "astal_notifd_action_set_label")]
    fn set_label(&self, value: &str) {
        unsafe {
            ffi::astal_notifd_action_set_label(self.as_ref().to_glib_none().0, value.to_glib_none().0);
        }
    }

    /// Emitted when the notification this action was added to invoked this action.
    #[doc(alias = "invoked")]
    fn connect_invoked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn invoked_trampoline<P: IsA<Action>, F: Fn(&P) + 'static>(this: *mut ffi::AstalNotifdAction, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(Action::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"invoked".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(invoked_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "id")]
    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_id_trampoline<P: IsA<Action>, F: Fn(&P) + 'static>(this: *mut ffi::AstalNotifdAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(Action::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::id".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_id_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "label")]
    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_label_trampoline<P: IsA<Action>, F: Fn(&P) + 'static>(this: *mut ffi::AstalNotifdAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(Action::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::label".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_label_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }
}

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