// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IButton {
  fn as_button(Self) -> Button
  fn get_can_shrink(Self) -> Bool = _
  fn get_child(Self) -> Widget? = _
  fn get_has_frame(Self) -> Bool = _
  fn get_icon_name(Self) -> String? = _
  fn get_label(Self) -> String? = _
  fn get_use_underline(Self) -> Bool = _
  fn set_can_shrink(Self, Bool) -> Unit = _
  fn set_child(Self, &IWidget?) -> Unit = _
  fn set_has_frame(Self, Bool) -> Unit = _
  fn set_icon_name(Self, String) -> Unit = _
  fn set_label(Self, String) -> Unit = _
  fn set_use_underline(Self, Bool) -> Unit = _
  fn connect_activate(Self, (Button) -> Unit) -> UInt64 = _
  fn connect_clicked(Self, (Button) -> Unit) -> UInt64 = _
}

///|
pub impl IButton for Button with fn as_button(self) {
  self
}

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

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

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

///|
#borrow(icon_name)
extern "c" fn moonbit_gtk_button_new_from_icon_name(
  icon_name : Bytes,
) -> Button = "moonbit_gtk_button_new_from_icon_name"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/ctor.Button.new_from_icon_name.html).
pub fn Button::new_from_icon_name(icon_name : String) -> Button {
  moonbit_gtk_button_new_from_icon_name(@encoding/utf8.encode(icon_name))
}

///|
#borrow(label)
extern "c" fn moonbit_gtk_button_new_with_label(label : Bytes) -> Button = "moonbit_gtk_button_new_with_label"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/ctor.Button.new_with_label.html).
pub fn Button::new_with_label(label : String) -> Button {
  moonbit_gtk_button_new_with_label(@encoding/utf8.encode(label))
}

///|
#borrow(label)
extern "c" fn moonbit_gtk_button_new_with_mnemonic(label : Bytes) -> Button = "moonbit_gtk_button_new_with_mnemonic"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/ctor.Button.new_with_mnemonic.html).
pub fn Button::new_with_mnemonic(label : String) -> Button {
  moonbit_gtk_button_new_with_mnemonic(@encoding/utf8.encode(label))
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_can_shrink.html).
#borrow(self)
pub extern "c" fn Button::get_can_shrink(self : Button) -> Bool = "moonbit_gtk_button_get_can_shrink"

///|
#borrow(self_)
extern "c" fn moonbit_gtk_button_get_child(
  self_ : Button,
) -> @glib.Nullable[Widget] = "moonbit_gtk_button_get_child"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_child.html).
pub fn Button::get_child(self : Button) -> Widget? {
  let raw_result = moonbit_gtk_button_get_child(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_has_frame.html).
#borrow(self)
pub extern "c" fn Button::get_has_frame(self : Button) -> Bool = "moonbit_gtk_button_get_has_frame"

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

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_icon_name.html).
pub fn Button::get_icon_name(self : Button) -> String? {
  let result = moonbit_gtk_button_get_icon_name(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

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

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_label.html).
pub fn Button::get_label(self : Button) -> String? {
  let result = moonbit_gtk_button_get_label(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.get_use_underline.html).
#borrow(self)
pub extern "c" fn Button::get_use_underline(self : Button) -> Bool = "moonbit_gtk_button_get_use_underline"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_can_shrink.html).
#borrow(self)
pub extern "c" fn Button::set_can_shrink(self : Button, can_shrink : Bool) = "moonbit_gtk_button_set_can_shrink"

///|
#borrow(self_, child)
extern "c" fn moonbit_gtk_button_set_child(
  self_ : Button,
  child : @glib.Nullable[Widget],
) = "moonbit_gtk_button_set_child"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_child.html).
pub fn Button::set_child(self : Button, child : &IWidget?) -> Unit {
  moonbit_gtk_button_set_child(
    self,
    match child {
      Some(v) => @glib.Nullable::some(v.as_widget())
      None => @glib.Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_has_frame.html).
#borrow(self)
pub extern "c" fn Button::set_has_frame(self : Button, has_frame : Bool) = "moonbit_gtk_button_set_has_frame"

///|
#borrow(self_, icon_name)
extern "c" fn moonbit_gtk_button_set_icon_name(
  self_ : Button,
  icon_name : Bytes,
) = "moonbit_gtk_button_set_icon_name"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_icon_name.html).
pub fn Button::set_icon_name(self : Button, icon_name : String) -> Unit {
  moonbit_gtk_button_set_icon_name(self, @encoding/utf8.encode(icon_name))
}

///|
#borrow(self_, label)
extern "c" fn moonbit_gtk_button_set_label(self_ : Button, label : Bytes) = "moonbit_gtk_button_set_label"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_label.html).
pub fn Button::set_label(self : Button, label : String) -> Unit {
  moonbit_gtk_button_set_label(self, @encoding/utf8.encode(label))
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Button.set_use_underline.html).
#borrow(self)
pub extern "c" fn Button::set_use_underline(
  self : Button,
  use_underline : Bool,
) = "moonbit_gtk_button_set_use_underline"

///|
#borrow(instance)
extern "c" fn gtk_button_connect_activate(
  instance : Button,
  function : FuncRef[(Button, (Button) -> Unit) -> Unit],
  closure : (Button) -> Unit,
) -> UInt64 = "moonbit_gtk_button_connect_activate"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/signal.Button.activate.html).
pub fn Button::connect_activate(self : Button, f : (Button) -> Unit) -> UInt64 {
  gtk_button_connect_activate(self, fn(instance_, f) { f(instance_) }, f)
}

///|
#borrow(instance)
extern "c" fn gtk_button_connect_clicked(
  instance : Button,
  function : FuncRef[(Button, (Button) -> Unit) -> Unit],
  closure : (Button) -> Unit,
) -> UInt64 = "moonbit_gtk_button_connect_clicked"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/signal.Button.clicked.html).
pub fn Button::connect_clicked(self : Button, f : (Button) -> Unit) -> UInt64 {
  gtk_button_connect_clicked(self, fn(instance_, f) { f(instance_) }, f)
}

///|
impl IButton with fn get_can_shrink(self) -> Bool {
  self.as_button().get_can_shrink()
}

///|
impl IButton with fn get_child(self) -> Widget? {
  self.as_button().get_child()
}

///|
impl IButton with fn get_has_frame(self) -> Bool {
  self.as_button().get_has_frame()
}

///|
impl IButton with fn get_icon_name(self) -> String? {
  self.as_button().get_icon_name()
}

///|
impl IButton with fn get_label(self) -> String? {
  self.as_button().get_label()
}

///|
impl IButton with fn get_use_underline(self) -> Bool {
  self.as_button().get_use_underline()
}

///|
impl IButton with fn set_can_shrink(self, can_shrink) -> Unit {
  self.as_button().set_can_shrink(can_shrink)
}

///|
impl IButton with fn set_child(self, child) -> Unit {
  self.as_button().set_child(child)
}

///|
impl IButton with fn set_has_frame(self, has_frame) -> Unit {
  self.as_button().set_has_frame(has_frame)
}

///|
impl IButton with fn set_icon_name(self, icon_name) -> Unit {
  self.as_button().set_icon_name(icon_name)
}

///|
impl IButton with fn set_label(self, label) -> Unit {
  self.as_button().set_label(label)
}

///|
impl IButton with fn set_use_underline(self, use_underline) -> Unit {
  self.as_button().set_use_underline(use_underline)
}

///|
impl IButton with fn connect_activate(self, f) -> UInt64 {
  self.as_button().connect_activate(f)
}

///|
impl IButton with fn connect_clicked(self, f) -> UInt64 {
  self.as_button().connect_clicked(f)
}

///|
pub fn Button::as_widget(self : Button) -> Widget = "%identity"

///|
pub impl IWidget for Button with fn as_widget(self) {
  self.as_widget()
}

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

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