// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://docs.gtk.org/gio/class.SubprocessLauncher.html).
pub type SubprocessLauncher

///|
pub(open) trait ISubprocessLauncher {
  fn as_subprocess_launcher(Self) -> SubprocessLauncher
  fn close(Self) -> Unit = _
  fn getenv(Self, String) -> String? = _
  fn set_cwd(Self, String) -> Unit = _
  fn set_environ(Self, Array[String]) -> Unit = _
  fn set_flags(Self, SubprocessFlags) -> Unit = _
  fn set_stderr_file_path(Self, String?) -> Unit = _
  fn set_stdin_file_path(Self, String?) -> Unit = _
  fn set_stdout_file_path(Self, String?) -> Unit = _
  fn setenv(Self, String, String, Bool) -> Unit = _
  fn spawnv(Self, Array[String]) -> Subprocess raise @glib.Error_ = _
  fn take_fd(Self, Int, Int) -> Unit = _
  fn take_stderr_fd(Self, Int) -> Unit = _
  fn take_stdin_fd(Self, Int) -> Unit = _
  fn take_stdout_fd(Self, Int) -> Unit = _
  fn unsetenv(Self, String) -> Unit = _
}

///|
pub impl ISubprocessLauncher for SubprocessLauncher with fn as_subprocess_launcher(
  self,
) {
  self
}

///|
extern "c" fn moonbit_g_subprocess_launcher_new(
  flags : Int,
) -> SubprocessLauncher = "moonbit_g_subprocess_launcher_new"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/ctor.SubprocessLauncher.new.html).
pub fn SubprocessLauncher::new(flags : SubprocessFlags) -> SubprocessLauncher {
  moonbit_g_subprocess_launcher_new(flags.to_int())
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.close.html).
#borrow(self)
pub extern "c" fn SubprocessLauncher::close(self : SubprocessLauncher) = "moonbit_g_subprocess_launcher_close"

///|
#borrow(self_, variable)
extern "c" fn moonbit_g_subprocess_launcher_getenv(
  self_ : SubprocessLauncher,
  variable : Bytes,
) -> @glib.Nullable[Bytes] = "moonbit_g_subprocess_launcher_getenv"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.getenv.html).
pub fn SubprocessLauncher::getenv(
  self : SubprocessLauncher,
  variable : String,
) -> String? {
  let result = moonbit_g_subprocess_launcher_getenv(
    self,
    @encoding/utf8.encode(variable),
  )
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(self_, cwd)
extern "c" fn moonbit_g_subprocess_launcher_set_cwd(
  self_ : SubprocessLauncher,
  cwd : Bytes,
) = "moonbit_g_subprocess_launcher_set_cwd"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_cwd.html).
pub fn SubprocessLauncher::set_cwd(
  self : SubprocessLauncher,
  cwd : String,
) -> Unit {
  moonbit_g_subprocess_launcher_set_cwd(self, @encoding/utf8.encode(cwd))
}

///|
#borrow(self_, __sa_env)
extern "c" fn moonbit_g_subprocess_launcher_set_environ(
  self_ : SubprocessLauncher,
  __sa_env : FixedArray[Bytes],
) = "moonbit_g_subprocess_launcher_set_environ"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_environ.html).
pub fn SubprocessLauncher::set_environ(
  self : SubprocessLauncher,
  env : Array[String],
) -> Unit {
  moonbit_g_subprocess_launcher_set_environ(
    self,
    FixedArray::from_array(env.map(fn(s) { @encoding/utf8.encode(s) })),
  )
}

///|
#borrow(self_)
extern "c" fn moonbit_g_subprocess_launcher_set_flags(
  self_ : SubprocessLauncher,
  flags : Int,
) = "moonbit_g_subprocess_launcher_set_flags"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_flags.html).
pub fn SubprocessLauncher::set_flags(
  self : SubprocessLauncher,
  flags : SubprocessFlags,
) -> Unit {
  moonbit_g_subprocess_launcher_set_flags(self, flags.to_int())
}

///|
#borrow(self_, path)
extern "c" fn moonbit_g_subprocess_launcher_set_stderr_file_path(
  self_ : SubprocessLauncher,
  path : @glib.Nullable[Bytes],
) = "moonbit_g_subprocess_launcher_set_stderr_file_path"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_stderr_file_path.html).
pub fn SubprocessLauncher::set_stderr_file_path(
  self : SubprocessLauncher,
  path : String?,
) -> Unit {
  moonbit_g_subprocess_launcher_set_stderr_file_path(
    self,
    match path {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(self_, path)
extern "c" fn moonbit_g_subprocess_launcher_set_stdin_file_path(
  self_ : SubprocessLauncher,
  path : @glib.Nullable[Bytes],
) = "moonbit_g_subprocess_launcher_set_stdin_file_path"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_stdin_file_path.html).
pub fn SubprocessLauncher::set_stdin_file_path(
  self : SubprocessLauncher,
  path : String?,
) -> Unit {
  moonbit_g_subprocess_launcher_set_stdin_file_path(
    self,
    match path {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(self_, path)
extern "c" fn moonbit_g_subprocess_launcher_set_stdout_file_path(
  self_ : SubprocessLauncher,
  path : @glib.Nullable[Bytes],
) = "moonbit_g_subprocess_launcher_set_stdout_file_path"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.set_stdout_file_path.html).
pub fn SubprocessLauncher::set_stdout_file_path(
  self : SubprocessLauncher,
  path : String?,
) -> Unit {
  moonbit_g_subprocess_launcher_set_stdout_file_path(
    self,
    match path {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(self_, variable, value)
extern "c" fn moonbit_g_subprocess_launcher_setenv(
  self_ : SubprocessLauncher,
  variable : Bytes,
  value : Bytes,
  overwrite : Bool,
) = "moonbit_g_subprocess_launcher_setenv"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.setenv.html).
pub fn SubprocessLauncher::setenv(
  self : SubprocessLauncher,
  variable : String,
  value : String,
  overwrite : Bool,
) -> Unit {
  moonbit_g_subprocess_launcher_setenv(
    self,
    @encoding/utf8.encode(variable),
    @encoding/utf8.encode(value),
    overwrite,
  )
}

///|
#borrow(self_, __sa_argv, error)
extern "c" fn moonbit_g_subprocess_launcher_spawnv(
  self_ : SubprocessLauncher,
  __sa_argv : FixedArray[Bytes],
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Subprocess = "moonbit_g_subprocess_launcher_spawnv"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.spawnv.html).
pub fn SubprocessLauncher::spawnv(
  self : SubprocessLauncher,
  argv : Array[String],
) -> Subprocess raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_g_subprocess_launcher_spawnv(
    self,
    FixedArray::from_array(argv.map(fn(s) { @encoding/utf8.encode(s) })),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.take_fd.html).
#borrow(self)
pub extern "c" fn SubprocessLauncher::take_fd(
  self : SubprocessLauncher,
  source_fd : Int,
  target_fd : Int,
) = "moonbit_g_subprocess_launcher_take_fd"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.take_stderr_fd.html).
#borrow(self)
pub extern "c" fn SubprocessLauncher::take_stderr_fd(
  self : SubprocessLauncher,
  fd : Int,
) = "moonbit_g_subprocess_launcher_take_stderr_fd"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.take_stdin_fd.html).
#borrow(self)
pub extern "c" fn SubprocessLauncher::take_stdin_fd(
  self : SubprocessLauncher,
  fd : Int,
) = "moonbit_g_subprocess_launcher_take_stdin_fd"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.take_stdout_fd.html).
#borrow(self)
pub extern "c" fn SubprocessLauncher::take_stdout_fd(
  self : SubprocessLauncher,
  fd : Int,
) = "moonbit_g_subprocess_launcher_take_stdout_fd"

///|
#borrow(self_, variable)
extern "c" fn moonbit_g_subprocess_launcher_unsetenv(
  self_ : SubprocessLauncher,
  variable : Bytes,
) = "moonbit_g_subprocess_launcher_unsetenv"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SubprocessLauncher.unsetenv.html).
pub fn SubprocessLauncher::unsetenv(
  self : SubprocessLauncher,
  variable : String,
) -> Unit {
  moonbit_g_subprocess_launcher_unsetenv(self, @encoding/utf8.encode(variable))
}

///|
impl ISubprocessLauncher with fn close(self) -> Unit {
  self.as_subprocess_launcher().close()
}

///|
impl ISubprocessLauncher with fn getenv(self, variable) -> String? {
  self.as_subprocess_launcher().getenv(variable)
}

///|
impl ISubprocessLauncher with fn set_cwd(self, cwd) -> Unit {
  self.as_subprocess_launcher().set_cwd(cwd)
}

///|
impl ISubprocessLauncher with fn set_environ(self, env) -> Unit {
  self.as_subprocess_launcher().set_environ(env)
}

///|
impl ISubprocessLauncher with fn set_flags(self, flags) -> Unit {
  self.as_subprocess_launcher().set_flags(flags)
}

///|
impl ISubprocessLauncher with fn set_stderr_file_path(self, path) -> Unit {
  self.as_subprocess_launcher().set_stderr_file_path(path)
}

///|
impl ISubprocessLauncher with fn set_stdin_file_path(self, path) -> Unit {
  self.as_subprocess_launcher().set_stdin_file_path(path)
}

///|
impl ISubprocessLauncher with fn set_stdout_file_path(self, path) -> Unit {
  self.as_subprocess_launcher().set_stdout_file_path(path)
}

///|
impl ISubprocessLauncher with fn setenv(self, variable, value, overwrite) -> Unit {
  self.as_subprocess_launcher().setenv(variable, value, overwrite)
}

///|
impl ISubprocessLauncher with fn spawnv(self, argv) -> Subprocess raise @glib.Error_ {
  self.as_subprocess_launcher().spawnv(argv)
}

///|
impl ISubprocessLauncher with fn take_fd(self, source_fd, target_fd) -> Unit {
  self.as_subprocess_launcher().take_fd(source_fd, target_fd)
}

///|
impl ISubprocessLauncher with fn take_stderr_fd(self, fd) -> Unit {
  self.as_subprocess_launcher().take_stderr_fd(fd)
}

///|
impl ISubprocessLauncher with fn take_stdin_fd(self, fd) -> Unit {
  self.as_subprocess_launcher().take_stdin_fd(fd)
}

///|
impl ISubprocessLauncher with fn take_stdout_fd(self, fd) -> Unit {
  self.as_subprocess_launcher().take_stdout_fd(fd)
}

///|
impl ISubprocessLauncher with fn unsetenv(self, variable) -> Unit {
  self.as_subprocess_launcher().unsetenv(variable)
}

///|
pub fn SubprocessLauncher::as_gobject_object(
  self : SubprocessLauncher,
) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for SubprocessLauncher with fn as_object(self) {
  self.as_gobject_object()
}