// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IAppLaunchContext {
  fn as_app_launch_context(Self) -> AppLaunchContext
  fn get_display(Self, &IAppInfo, Array[File]) -> String? = _
  fn launch_failed(Self, String) -> Unit = _
  fn setenv(Self, String, String) -> Unit = _
  fn unsetenv(Self, String) -> Unit = _
  fn connect_launch_failed(Self, (AppLaunchContext, String) -> Unit) -> UInt64 = _
  fn connect_launch_started(
    Self,
    (AppLaunchContext, AppInfo, @glib.Variant?) -> Unit,
  ) -> UInt64 = _
  fn connect_launched(Self, (AppLaunchContext, AppInfo, @glib.Variant) -> Unit) -> UInt64 = _
}

///|
pub impl IAppLaunchContext for AppLaunchContext with fn as_app_launch_context(
  self,
) {
  self
}

///|
/// Implementation contract for AppLaunchContext.launch_failed. Self is the retained MoonBit state; the second parameter is the invoked AppLaunchContext object.
pub(open) trait VAppLaunchContextLaunchFailed {
  fn launch_failed(Self, AppLaunchContext, String) -> Unit
}

///|
/// Implementation contract for AppLaunchContext.launch_started. Self is the retained MoonBit state; the second parameter is the invoked AppLaunchContext object.
pub(open) trait VAppLaunchContextLaunchStarted {
  fn launch_started(Self, AppLaunchContext, &IAppInfo, &@glib.IVariant) -> Unit
}

///|
/// Implementation contract for AppLaunchContext.launched. Self is the retained MoonBit state; the second parameter is the invoked AppLaunchContext object.
pub(open) trait VAppLaunchContextLaunched {
  fn launched(Self, AppLaunchContext, &IAppInfo, &@glib.IVariant) -> Unit
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/ctor.AppLaunchContext.new.html).
pub extern "c" fn AppLaunchContext::new() -> AppLaunchContext = "moonbit_g_app_launch_context_new"

///|
#borrow(self_, info, files)
extern "c" fn moonbit_g_app_launch_context_get_display(
  self_ : AppLaunchContext,
  info : AppInfo,
  files : FixedArray[File],
) -> @glib.Nullable[Bytes] = "moonbit_g_app_launch_context_get_display"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.AppLaunchContext.get_display.html).
pub fn AppLaunchContext::get_display(
  self : AppLaunchContext,
  info : &IAppInfo,
  files : Array[File],
) -> String? {
  let result = moonbit_g_app_launch_context_get_display(
    self,
    info.as_app_info(),
    FixedArray::from_array(files),
  )
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(self_, startup_notify_id)
extern "c" fn moonbit_g_app_launch_context_launch_failed(
  self_ : AppLaunchContext,
  startup_notify_id : Bytes,
) = "moonbit_g_app_launch_context_launch_failed"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.AppLaunchContext.launch_failed.html).
pub fn AppLaunchContext::launch_failed(
  self : AppLaunchContext,
  startup_notify_id : String,
) -> Unit {
  moonbit_g_app_launch_context_launch_failed(
    self,
    @encoding/utf8.encode(startup_notify_id),
  )
}

///|
#borrow(self_, variable, value)
extern "c" fn moonbit_g_app_launch_context_setenv(
  self_ : AppLaunchContext,
  variable : Bytes,
  value : Bytes,
) = "moonbit_g_app_launch_context_setenv"

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

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

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

///|
#borrow(instance)
extern "c" fn g_app_launch_context_connect_launch_failed(
  instance : AppLaunchContext,
  function : FuncRef[
    (AppLaunchContext, Bytes, (AppLaunchContext, String) -> Unit) -> Unit,
  ],
  closure : (AppLaunchContext, String) -> Unit,
) -> UInt64 = "moonbit_g_app_launch_context_connect_launch_failed"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.AppLaunchContext.launch-failed.html).
pub fn AppLaunchContext::connect_launch_failed(
  self : AppLaunchContext,
  f : (AppLaunchContext, String) -> Unit,
) -> UInt64 {
  g_app_launch_context_connect_launch_failed(
    self,
    fn(instance_, startup_notify_id, f) {
      f(instance_, @encoding/utf8.decode_lossy(startup_notify_id))
    },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn g_app_launch_context_connect_launch_started(
  instance : AppLaunchContext,
  function : FuncRef[
    (
      AppLaunchContext,
      AppInfo,
      @glib.Variant?,
      (AppLaunchContext, AppInfo, @glib.Variant?) -> Unit,
    ) -> Unit,
  ],
  closure : (AppLaunchContext, AppInfo, @glib.Variant?) -> Unit,
) -> UInt64 = "moonbit_g_app_launch_context_connect_launch_started"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.AppLaunchContext.launch-started.html).
pub fn AppLaunchContext::connect_launch_started(
  self : AppLaunchContext,
  f : (AppLaunchContext, AppInfo, @glib.Variant?) -> Unit,
) -> UInt64 {
  g_app_launch_context_connect_launch_started(
    self,
    fn(instance_, info, platform_data, f) { f(instance_, info, platform_data) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn g_app_launch_context_connect_launched(
  instance : AppLaunchContext,
  function : FuncRef[
    (
      AppLaunchContext,
      AppInfo,
      @glib.Variant,
      (AppLaunchContext, AppInfo, @glib.Variant) -> Unit,
    ) -> Unit,
  ],
  closure : (AppLaunchContext, AppInfo, @glib.Variant) -> Unit,
) -> UInt64 = "moonbit_g_app_launch_context_connect_launched"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.AppLaunchContext.launched.html).
pub fn AppLaunchContext::connect_launched(
  self : AppLaunchContext,
  f : (AppLaunchContext, AppInfo, @glib.Variant) -> Unit,
) -> UInt64 {
  g_app_launch_context_connect_launched(
    self,
    fn(instance_, info, platform_data, f) { f(instance_, info, platform_data) },
    f,
  )
}

///|
impl IAppLaunchContext with fn get_display(self, info, files) -> String? {
  self.as_app_launch_context().get_display(info, files)
}

///|
impl IAppLaunchContext with fn launch_failed(self, startup_notify_id) -> Unit {
  self.as_app_launch_context().launch_failed(startup_notify_id)
}

///|
impl IAppLaunchContext with fn setenv(self, variable, value) -> Unit {
  self.as_app_launch_context().setenv(variable, value)
}

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

///|
impl IAppLaunchContext with fn connect_launch_failed(self, f) -> UInt64 {
  self.as_app_launch_context().connect_launch_failed(f)
}

///|
impl IAppLaunchContext with fn connect_launch_started(self, f) -> UInt64 {
  self.as_app_launch_context().connect_launch_started(f)
}

///|
impl IAppLaunchContext with fn connect_launched(self, f) -> UInt64 {
  self.as_app_launch_context().connect_launched(f)
}

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

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