// GENERATED — DO NOT EDIT

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

///|
pub(open) trait ITextTagTable {
  fn as_text_tag_table(Self) -> TextTagTable
  fn add(Self, &ITextTag) -> Bool = _
  fn get_size(Self) -> Int = _
  fn lookup(Self, String) -> TextTag? = _
  fn remove(Self, &ITextTag) -> Unit = _
  fn connect_tag_added(Self, (TextTagTable, TextTag) -> Unit) -> UInt64 = _
  fn connect_tag_changed(Self, (TextTagTable, TextTag, Bool) -> Unit) -> UInt64 = _
  fn connect_tag_removed(Self, (TextTagTable, TextTag) -> Unit) -> UInt64 = _
}

///|
pub impl ITextTagTable for TextTagTable with fn as_text_tag_table(self) {
  self
}

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

///|
#borrow(self_, tag)
extern "c" fn moonbit_gtk_text_tag_table_add(
  self_ : TextTagTable,
  tag : TextTag,
) -> Bool = "moonbit_gtk_text_tag_table_add"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.TextTagTable.add.html).
pub fn TextTagTable::add(self : TextTagTable, tag : &ITextTag) -> Bool {
  moonbit_gtk_text_tag_table_add(self, tag.as_text_tag())
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.TextTagTable.get_size.html).
#borrow(self)
pub extern "c" fn TextTagTable::get_size(self : TextTagTable) -> Int = "moonbit_gtk_text_tag_table_get_size"

///|
#borrow(self_, name)
extern "c" fn moonbit_gtk_text_tag_table_lookup(
  self_ : TextTagTable,
  name : Bytes,
) -> @glib.Nullable[TextTag] = "moonbit_gtk_text_tag_table_lookup"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.TextTagTable.lookup.html).
pub fn TextTagTable::lookup(self : TextTagTable, name : String) -> TextTag? {
  let raw_result = moonbit_gtk_text_tag_table_lookup(
    self,
    @encoding/utf8.encode(name),
  )
  raw_result.to_option()
}

///|
#borrow(self_, tag)
extern "c" fn moonbit_gtk_text_tag_table_remove(
  self_ : TextTagTable,
  tag : TextTag,
) = "moonbit_gtk_text_tag_table_remove"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.TextTagTable.remove.html).
pub fn TextTagTable::remove(self : TextTagTable, tag : &ITextTag) -> Unit {
  moonbit_gtk_text_tag_table_remove(self, tag.as_text_tag())
}

///|
#borrow(instance)
extern "c" fn gtk_text_tag_table_connect_tag_added(
  instance : TextTagTable,
  function : FuncRef[
    (TextTagTable, TextTag, (TextTagTable, TextTag) -> Unit) -> Unit,
  ],
  closure : (TextTagTable, TextTag) -> Unit,
) -> UInt64 = "moonbit_gtk_text_tag_table_connect_tag_added"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/signal.TextTagTable.tag-added.html).
pub fn TextTagTable::connect_tag_added(
  self : TextTagTable,
  f : (TextTagTable, TextTag) -> Unit,
) -> UInt64 {
  gtk_text_tag_table_connect_tag_added(
    self,
    fn(instance_, tag, f) { f(instance_, tag) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn gtk_text_tag_table_connect_tag_changed(
  instance : TextTagTable,
  function : FuncRef[
    (TextTagTable, TextTag, Bool, (TextTagTable, TextTag, Bool) -> Unit) -> Unit,
  ],
  closure : (TextTagTable, TextTag, Bool) -> Unit,
) -> UInt64 = "moonbit_gtk_text_tag_table_connect_tag_changed"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/signal.TextTagTable.tag-changed.html).
pub fn TextTagTable::connect_tag_changed(
  self : TextTagTable,
  f : (TextTagTable, TextTag, Bool) -> Unit,
) -> UInt64 {
  gtk_text_tag_table_connect_tag_changed(
    self,
    fn(instance_, tag, size_changed, f) { f(instance_, tag, size_changed) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn gtk_text_tag_table_connect_tag_removed(
  instance : TextTagTable,
  function : FuncRef[
    (TextTagTable, TextTag, (TextTagTable, TextTag) -> Unit) -> Unit,
  ],
  closure : (TextTagTable, TextTag) -> Unit,
) -> UInt64 = "moonbit_gtk_text_tag_table_connect_tag_removed"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/signal.TextTagTable.tag-removed.html).
pub fn TextTagTable::connect_tag_removed(
  self : TextTagTable,
  f : (TextTagTable, TextTag) -> Unit,
) -> UInt64 {
  gtk_text_tag_table_connect_tag_removed(
    self,
    fn(instance_, tag, f) { f(instance_, tag) },
    f,
  )
}

///|
impl ITextTagTable with fn add(self, tag) -> Bool {
  self.as_text_tag_table().add(tag)
}

///|
impl ITextTagTable with fn get_size(self) -> Int {
  self.as_text_tag_table().get_size()
}

///|
impl ITextTagTable with fn lookup(self, name) -> TextTag? {
  self.as_text_tag_table().lookup(name)
}

///|
impl ITextTagTable with fn remove(self, tag) -> Unit {
  self.as_text_tag_table().remove(tag)
}

///|
impl ITextTagTable with fn connect_tag_added(self, f) -> UInt64 {
  self.as_text_tag_table().connect_tag_added(f)
}

///|
impl ITextTagTable with fn connect_tag_changed(self, f) -> UInt64 {
  self.as_text_tag_table().connect_tag_changed(f)
}

///|
impl ITextTagTable with fn connect_tag_removed(self, f) -> UInt64 {
  self.as_text_tag_table().connect_tag_removed(f)
}

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

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