// 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! {
    /// Requests for the session to be started using the provided command line, adding the supplied environment to that created by PAM. The session
    /// will start after the greeter process terminates
    ///
    /// ## Properties
    ///
    ///
    /// #### `cmd`
    ///  Readable | Writeable
    ///
    ///
    /// #### `env`
    ///  Readable | Writeable
    /// <details><summary><h4>Request</h4></summary>
    ///
    ///
    /// #### `type-name`
    ///  Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`StartSessionExt`][trait@crate::prelude::StartSessionExt], [`RequestExt`][trait@crate::prelude::RequestExt]
    #[doc(alias = "AstalGreetStartSession")]
    pub struct StartSession(Object<ffi::AstalGreetStartSession, ffi::AstalGreetStartSessionClass>) @extends Request;

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

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

    #[doc(alias = "astal_greet_start_session_new")]
    pub fn new(cmd: &[&str], env: &[&str]) -> StartSession {
        assert_initialized_main_thread!();
        let cmd_length1 = cmd.len() as _;
        let env_length1 = env.len() as _;
        unsafe {
            from_glib_full(ffi::astal_greet_start_session_new(cmd.to_glib_none().0, cmd_length1, env.to_glib_none().0, env_length1))
        }
    }

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

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

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

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

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

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

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

/// Trait containing all [`struct@StartSession`] methods.
///
/// # Implementors
///
/// [`StartSession`][struct@crate::StartSession]
pub trait StartSessionExt: IsA<StartSession> + 'static {
    #[doc(alias = "astal_greet_start_session_get_cmd")]
    #[doc(alias = "get_cmd")]
    fn cmd(&self) -> Vec<glib::GString> {
        unsafe {
            let mut result_length1 = std::mem::MaybeUninit::uninit();
            let ret = FromGlibContainer::from_glib_none_num(ffi::astal_greet_start_session_get_cmd(self.as_ref().to_glib_none().0, result_length1.as_mut_ptr()), result_length1.assume_init() as _);
            ret
        }
    }

    #[doc(alias = "astal_greet_start_session_set_cmd")]
    fn set_cmd(&self, value: &[&str]) {
        let value_length1 = value.len() as _;
        unsafe {
            ffi::astal_greet_start_session_set_cmd(self.as_ref().to_glib_none().0, value.to_glib_none().0, value_length1);
        }
    }

    #[doc(alias = "astal_greet_start_session_get_env")]
    #[doc(alias = "get_env")]
    fn env(&self) -> Vec<glib::GString> {
        unsafe {
            let mut result_length1 = std::mem::MaybeUninit::uninit();
            let ret = FromGlibContainer::from_glib_none_num(ffi::astal_greet_start_session_get_env(self.as_ref().to_glib_none().0, result_length1.as_mut_ptr()), result_length1.assume_init() as _);
            ret
        }
    }

    #[doc(alias = "astal_greet_start_session_set_env")]
    fn set_env(&self, value: &[&str]) {
        let value_length1 = value.len() as _;
        unsafe {
            ffi::astal_greet_start_session_set_env(self.as_ref().to_glib_none().0, value.to_glib_none().0, value_length1);
        }
    }

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

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

impl<O: IsA<StartSession>> StartSessionExt for O {}
