// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IMenu {
  fn as_menu(Self) -> Menu
  fn append(Self, String?, String?) -> Unit = _
  fn append_item(Self, &IMenuItem) -> Unit = _
  fn append_section(Self, String?, &IMenuModel) -> Unit = _
  fn append_submenu(Self, String?, &IMenuModel) -> Unit = _
  fn freeze(Self) -> Unit = _
  fn insert(Self, Int, String?, String?) -> Unit = _
  fn insert_item(Self, Int, &IMenuItem) -> Unit = _
  fn insert_section(Self, Int, String?, &IMenuModel) -> Unit = _
  fn insert_submenu(Self, Int, String?, &IMenuModel) -> Unit = _
  fn prepend(Self, String?, String?) -> Unit = _
  fn prepend_item(Self, &IMenuItem) -> Unit = _
  fn prepend_section(Self, String?, &IMenuModel) -> Unit = _
  fn prepend_submenu(Self, String?, &IMenuModel) -> Unit = _
  fn remove(Self, Int) -> Unit = _
  fn remove_all(Self) -> Unit = _
}

///|
pub impl IMenu for Menu with fn as_menu(self) {
  self
}

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

///|
#borrow(self_, label, detailed_action)
extern "c" fn moonbit_g_menu_append(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  detailed_action : @glib.Nullable[Bytes],
) = "moonbit_g_menu_append"

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

///|
#borrow(self_, item)
extern "c" fn moonbit_g_menu_append_item(self_ : Menu, item : MenuItem) = "moonbit_g_menu_append_item"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.append_item.html).
pub fn Menu::append_item(self : Menu, item : &IMenuItem) -> Unit {
  moonbit_g_menu_append_item(self, item.as_menu_item())
}

///|
#borrow(self_, label, section)
extern "c" fn moonbit_g_menu_append_section(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  section : MenuModel,
) = "moonbit_g_menu_append_section"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.append_section.html).
pub fn Menu::append_section(
  self : Menu,
  label : String?,
  section : &IMenuModel,
) -> Unit {
  moonbit_g_menu_append_section(
    self,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    section.as_menu_model(),
  )
}

///|
#borrow(self_, label, submenu)
extern "c" fn moonbit_g_menu_append_submenu(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  submenu : MenuModel,
) = "moonbit_g_menu_append_submenu"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.append_submenu.html).
pub fn Menu::append_submenu(
  self : Menu,
  label : String?,
  submenu : &IMenuModel,
) -> Unit {
  moonbit_g_menu_append_submenu(
    self,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    submenu.as_menu_model(),
  )
}

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

///|
#borrow(self_, label, detailed_action)
extern "c" fn moonbit_g_menu_insert(
  self_ : Menu,
  position : Int,
  label : @glib.Nullable[Bytes],
  detailed_action : @glib.Nullable[Bytes],
) = "moonbit_g_menu_insert"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.insert.html).
pub fn Menu::insert(
  self : Menu,
  position : Int,
  label : String?,
  detailed_action : String?,
) -> Unit {
  moonbit_g_menu_insert(
    self,
    position,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    match detailed_action {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(self_, item)
extern "c" fn moonbit_g_menu_insert_item(
  self_ : Menu,
  position : Int,
  item : MenuItem,
) = "moonbit_g_menu_insert_item"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.insert_item.html).
pub fn Menu::insert_item(
  self : Menu,
  position : Int,
  item : &IMenuItem,
) -> Unit {
  moonbit_g_menu_insert_item(self, position, item.as_menu_item())
}

///|
#borrow(self_, label, section)
extern "c" fn moonbit_g_menu_insert_section(
  self_ : Menu,
  position : Int,
  label : @glib.Nullable[Bytes],
  section : MenuModel,
) = "moonbit_g_menu_insert_section"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.insert_section.html).
pub fn Menu::insert_section(
  self : Menu,
  position : Int,
  label : String?,
  section : &IMenuModel,
) -> Unit {
  moonbit_g_menu_insert_section(
    self,
    position,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    section.as_menu_model(),
  )
}

///|
#borrow(self_, label, submenu)
extern "c" fn moonbit_g_menu_insert_submenu(
  self_ : Menu,
  position : Int,
  label : @glib.Nullable[Bytes],
  submenu : MenuModel,
) = "moonbit_g_menu_insert_submenu"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.insert_submenu.html).
pub fn Menu::insert_submenu(
  self : Menu,
  position : Int,
  label : String?,
  submenu : &IMenuModel,
) -> Unit {
  moonbit_g_menu_insert_submenu(
    self,
    position,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    submenu.as_menu_model(),
  )
}

///|
#borrow(self_, label, detailed_action)
extern "c" fn moonbit_g_menu_prepend(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  detailed_action : @glib.Nullable[Bytes],
) = "moonbit_g_menu_prepend"

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

///|
#borrow(self_, item)
extern "c" fn moonbit_g_menu_prepend_item(self_ : Menu, item : MenuItem) = "moonbit_g_menu_prepend_item"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.prepend_item.html).
pub fn Menu::prepend_item(self : Menu, item : &IMenuItem) -> Unit {
  moonbit_g_menu_prepend_item(self, item.as_menu_item())
}

///|
#borrow(self_, label, section)
extern "c" fn moonbit_g_menu_prepend_section(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  section : MenuModel,
) = "moonbit_g_menu_prepend_section"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.prepend_section.html).
pub fn Menu::prepend_section(
  self : Menu,
  label : String?,
  section : &IMenuModel,
) -> Unit {
  moonbit_g_menu_prepend_section(
    self,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    section.as_menu_model(),
  )
}

///|
#borrow(self_, label, submenu)
extern "c" fn moonbit_g_menu_prepend_submenu(
  self_ : Menu,
  label : @glib.Nullable[Bytes],
  submenu : MenuModel,
) = "moonbit_g_menu_prepend_submenu"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.prepend_submenu.html).
pub fn Menu::prepend_submenu(
  self : Menu,
  label : String?,
  submenu : &IMenuModel,
) -> Unit {
  moonbit_g_menu_prepend_submenu(
    self,
    match label {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    submenu.as_menu_model(),
  )
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Menu.remove.html).
#borrow(self)
pub extern "c" fn Menu::remove(self : Menu, position : Int) = "moonbit_g_menu_remove"

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

///|
impl IMenu with fn append(self, label, detailed_action) -> Unit {
  self.as_menu().append(label, detailed_action)
}

///|
impl IMenu with fn append_item(self, item) -> Unit {
  self.as_menu().append_item(item)
}

///|
impl IMenu with fn append_section(self, label, section) -> Unit {
  self.as_menu().append_section(label, section)
}

///|
impl IMenu with fn append_submenu(self, label, submenu) -> Unit {
  self.as_menu().append_submenu(label, submenu)
}

///|
impl IMenu with fn freeze(self) -> Unit {
  self.as_menu().freeze()
}

///|
impl IMenu with fn insert(self, position, label, detailed_action) -> Unit {
  self.as_menu().insert(position, label, detailed_action)
}

///|
impl IMenu with fn insert_item(self, position, item) -> Unit {
  self.as_menu().insert_item(position, item)
}

///|
impl IMenu with fn insert_section(self, position, label, section) -> Unit {
  self.as_menu().insert_section(position, label, section)
}

///|
impl IMenu with fn insert_submenu(self, position, label, submenu) -> Unit {
  self.as_menu().insert_submenu(position, label, submenu)
}

///|
impl IMenu with fn prepend(self, label, detailed_action) -> Unit {
  self.as_menu().prepend(label, detailed_action)
}

///|
impl IMenu with fn prepend_item(self, item) -> Unit {
  self.as_menu().prepend_item(item)
}

///|
impl IMenu with fn prepend_section(self, label, section) -> Unit {
  self.as_menu().prepend_section(label, section)
}

///|
impl IMenu with fn prepend_submenu(self, label, submenu) -> Unit {
  self.as_menu().prepend_submenu(label, submenu)
}

///|
impl IMenu with fn remove(self, position) -> Unit {
  self.as_menu().remove(position)
}

///|
impl IMenu with fn remove_all(self) -> Unit {
  self.as_menu().remove_all()
}

///|
pub fn Menu::as_menu_model(self : Menu) -> MenuModel = "%identity"

///|
pub impl IMenuModel for Menu with fn as_menu_model(self) {
  self.as_menu_model()
}

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

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