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

use crate::{ffi,Request};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// Answers an authentication message. If the message was informative (info, error), then a response does not need to be set in this
    /// message. The session is ready to be started if a success is returned.
    ///
    /// ## Properties
    ///
    ///
    /// #### `response`
    ///  Readable | Writeable
    /// <details><summary><h4>Request</h4></summary>
    ///
    ///
    /// #### `type-name`
    ///  Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`PostAuthMesssageExt`][trait@crate::prelude::PostAuthMesssageExt], [`RequestExt`][trait@crate::prelude::RequestExt]
    #[doc(alias = "AstalGreetPostAuthMesssage")]
    pub struct PostAuthMesssage(Object<ffi::AstalGreetPostAuthMesssage, ffi::AstalGreetPostAuthMesssageClass>) @extends Request;

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

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

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

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

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

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`PostAuthMesssage`] 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 PostAuthMesssageBuilder {
            builder: glib::object::ObjectBuilder<'static, PostAuthMesssage>,
        }

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

                            pub fn response(self, response: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("response", response.into()), }
                        }

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

/// Trait containing all [`struct@PostAuthMesssage`] methods.
///
/// # Implementors
///
/// [`PostAuthMesssage`][struct@crate::PostAuthMesssage]
pub trait PostAuthMesssageExt: IsA<PostAuthMesssage> + 'static {
    #[doc(alias = "astal_greet_post_auth_messsage_get_response")]
    #[doc(alias = "get_response")]
    fn response(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::astal_greet_post_auth_messsage_get_response(self.as_ref().to_glib_none().0))
        }
    }

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

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

impl<O: IsA<PostAuthMesssage>> PostAuthMesssageExt for O {}
