// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IMenuModel {
  fn as_menu_model(Self) -> MenuModel
  fn get_item_link(Self, Int, String) -> MenuModel? = _
  fn get_n_items(Self) -> Int = _
  fn is_mutable(Self) -> Bool = _
  fn items_changed(Self, Int, Int, Int) -> Unit = _
  fn iterate_item_attributes(Self, Int) -> MenuAttributeIter = _
  fn iterate_item_links(Self, Int) -> MenuLinkIter = _
  fn connect_items_changed(Self, (MenuModel, Int, Int, Int) -> Unit) -> UInt64 = _
}

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

///|
#borrow(self_, link)
extern "c" fn moonbit_g_menu_model_get_item_link(
  self_ : MenuModel,
  item_index : Int,
  link : Bytes,
) -> @glib.Nullable[MenuModel] = "moonbit_g_menu_model_get_item_link"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.get_item_link.html).
pub fn MenuModel::get_item_link(
  self : MenuModel,
  item_index : Int,
  link : String,
) -> MenuModel? {
  let raw_result = moonbit_g_menu_model_get_item_link(
    self,
    item_index,
    @encoding/utf8.encode(link),
  )
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.get_n_items.html).
#borrow(self)
pub extern "c" fn MenuModel::get_n_items(self : MenuModel) -> Int = "moonbit_g_menu_model_get_n_items"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.is_mutable.html).
#borrow(self)
pub extern "c" fn MenuModel::is_mutable(self : MenuModel) -> Bool = "moonbit_g_menu_model_is_mutable"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.items_changed.html).
#borrow(self)
pub extern "c" fn MenuModel::items_changed(
  self : MenuModel,
  position : Int,
  removed : Int,
  added : Int,
) = "moonbit_g_menu_model_items_changed"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.iterate_item_attributes.html).
#borrow(self)
pub extern "c" fn MenuModel::iterate_item_attributes(
  self : MenuModel,
  item_index : Int,
) -> MenuAttributeIter = "moonbit_g_menu_model_iterate_item_attributes"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.MenuModel.iterate_item_links.html).
#borrow(self)
pub extern "c" fn MenuModel::iterate_item_links(
  self : MenuModel,
  item_index : Int,
) -> MenuLinkIter = "moonbit_g_menu_model_iterate_item_links"

///|
#borrow(instance)
extern "c" fn g_menu_model_connect_items_changed(
  instance : MenuModel,
  function : FuncRef[
    (MenuModel, Int, Int, Int, (MenuModel, Int, Int, Int) -> Unit) -> Unit,
  ],
  closure : (MenuModel, Int, Int, Int) -> Unit,
) -> UInt64 = "moonbit_g_menu_model_connect_items_changed"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.MenuModel.items-changed.html).
pub fn MenuModel::connect_items_changed(
  self : MenuModel,
  f : (MenuModel, Int, Int, Int) -> Unit,
) -> UInt64 {
  g_menu_model_connect_items_changed(
    self,
    fn(instance_, position, removed, added, f) {
      f(instance_, position, removed, added)
    },
    f,
  )
}

///|
impl IMenuModel with fn get_item_link(self, item_index, link) -> MenuModel? {
  self.as_menu_model().get_item_link(item_index, link)
}

///|
impl IMenuModel with fn get_n_items(self) -> Int {
  self.as_menu_model().get_n_items()
}

///|
impl IMenuModel with fn is_mutable(self) -> Bool {
  self.as_menu_model().is_mutable()
}

///|
impl IMenuModel with fn items_changed(self, position, removed, added) -> Unit {
  self.as_menu_model().items_changed(position, removed, added)
}

///|
impl IMenuModel with fn iterate_item_attributes(self, item_index) -> MenuAttributeIter {
  self.as_menu_model().iterate_item_attributes(item_index)
}

///|
impl IMenuModel with fn iterate_item_links(self, item_index) -> MenuLinkIter {
  self.as_menu_model().iterate_item_links(item_index)
}

///|
impl IMenuModel with fn connect_items_changed(self, f) -> UInt64 {
  self.as_menu_model().connect_items_changed(f)
}

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

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