// Code generated by girgen. DO NOT EDIT.

package adw

import (
	"runtime"
	"unsafe"

	"github.com/diamondburned/gotk4/pkg/core/gextras"
	coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
)

// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
// extern void _gotk4_adw1_Banner_ConnectButtonClicked(gpointer, guintptr);
import "C"

// GType values.
var (
	GTypeBanner = coreglib.Type(C.adw_banner_get_type())
)

func init() {
	coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
		coreglib.TypeMarshaler{T: GTypeBanner, F: marshalBanner},
	})
}

// BannerOverrides contains methods that are overridable.
type BannerOverrides struct {
}

func defaultBannerOverrides(v *Banner) BannerOverrides {
	return BannerOverrides{}
}

// Banner: bar with contextual information.
//
// <picture> <source srcset="banner-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="banner.png" alt="banner"> </picture>
//
// Banners are hidden by default, use banner:revealed to show them.
//
// Banners have a title, set with banner:title. Titles can be marked up with
// Pango markup, use banner:use-markup to enable it.
//
// The title will be shown centered or left-aligned depending on available
// space.
//
// Banners can optionally have a button with text on it, set through
// banner:button-label. The button can be used with a GAction, or with the
// banner::button-clicked signal. The button can have different styles, a gray
// style and a suggested style.
//
// <picture> <source srcset="banner-suggested-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="banner-suggested.png"
// alt="banner with suggested button style"> </picture>
//
// # CSS nodes
//
// AdwBanner has a main CSS node with the name banner.
type Banner struct {
	_ [0]func() // equal guard
	gtk.Widget

	*coreglib.Object
	gtk.Actionable
}

var (
	_ gtk.Widgetter     = (*Banner)(nil)
	_ coreglib.Objector = (*Banner)(nil)
)

func init() {
	coreglib.RegisterClassInfo[*Banner, *BannerClass, BannerOverrides](
		GTypeBanner,
		initBannerClass,
		wrapBanner,
		defaultBannerOverrides,
	)
}

func initBannerClass(gclass unsafe.Pointer, overrides BannerOverrides, classInitFunc func(*BannerClass)) {
	if classInitFunc != nil {
		class := (*BannerClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapBanner(obj *coreglib.Object) *Banner {
	return &Banner{
		Widget: gtk.Widget{
			InitiallyUnowned: coreglib.InitiallyUnowned{
				Object: obj,
			},
			Object: obj,
			Accessible: gtk.Accessible{
				Object: obj,
			},
			Buildable: gtk.Buildable{
				Object: obj,
			},
			ConstraintTarget: gtk.ConstraintTarget{
				Object: obj,
			},
		},
		Object: obj,
		Actionable: gtk.Actionable{
			Widget: gtk.Widget{
				InitiallyUnowned: coreglib.InitiallyUnowned{
					Object: obj,
				},
				Object: obj,
				Accessible: gtk.Accessible{
					Object: obj,
				},
				Buildable: gtk.Buildable{
					Object: obj,
				},
				ConstraintTarget: gtk.ConstraintTarget{
					Object: obj,
				},
			},
		},
	}
}

func marshalBanner(p uintptr) (interface{}, error) {
	return wrapBanner(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}

// ConnectButtonClicked: this signal is emitted after the action button has been
// clicked.
//
// It can be used as an alternative to setting an action.
func (self *Banner) ConnectButtonClicked(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "button-clicked", false, unsafe.Pointer(C._gotk4_adw1_Banner_ConnectButtonClicked), f)
}

// NewBanner creates a new AdwBanner.
//
// The function takes the following parameters:
//
//   - title: banner title.
//
// The function returns the following values:
//
//   - banner: newly created AdwBanner.
func NewBanner(title string) *Banner {
	var _arg1 *C.char      // out
	var _cret *C.GtkWidget // in

	_arg1 = (*C.char)(unsafe.Pointer(C.CString(title)))
	defer C.free(unsafe.Pointer(_arg1))

	_cret = C.adw_banner_new(_arg1)
	runtime.KeepAlive(title)

	var _banner *Banner // out

	_banner = wrapBanner(coreglib.Take(unsafe.Pointer(_cret)))

	return _banner
}

// ButtonLabel gets the button label for self.
//
// The function returns the following values:
//
//   - utf8 (optional): button label for self.
func (self *Banner) ButtonLabel() string {
	var _arg0 *C.AdwBanner // out
	var _cret *C.char      // in

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_banner_get_button_label(_arg0)
	runtime.KeepAlive(self)

	var _utf8 string // out

	if _cret != nil {
		_utf8 = C.GoString((*C.gchar)(unsafe.Pointer(_cret)))
	}

	return _utf8
}

// ButtonStyle gets the style class in use for the banner button.
//
// The function returns the following values:
//
//   - bannerButtonStyle: current button style.
func (self *Banner) ButtonStyle() BannerButtonStyle {
	var _arg0 *C.AdwBanner           // out
	var _cret C.AdwBannerButtonStyle // in

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_banner_get_button_style(_arg0)
	runtime.KeepAlive(self)

	var _bannerButtonStyle BannerButtonStyle // out

	_bannerButtonStyle = BannerButtonStyle(_cret)

	return _bannerButtonStyle
}

// Revealed gets if a banner is revealed.
//
// The function returns the following values:
//
//   - ok: whether a banner is revealed.
func (self *Banner) Revealed() bool {
	var _arg0 *C.AdwBanner // out
	var _cret C.gboolean   // in

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_banner_get_revealed(_arg0)
	runtime.KeepAlive(self)

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Title gets the title for self.
//
// The function returns the following values:
//
//   - utf8: title for self.
func (self *Banner) Title() string {
	var _arg0 *C.AdwBanner // out
	var _cret *C.char      // in

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_banner_get_title(_arg0)
	runtime.KeepAlive(self)

	var _utf8 string // out

	_utf8 = C.GoString((*C.gchar)(unsafe.Pointer(_cret)))

	return _utf8
}

// UseMarkup gets whether to use Pango markup for the banner title.
//
// The function returns the following values:
//
//   - ok: whether to use markup.
func (self *Banner) UseMarkup() bool {
	var _arg0 *C.AdwBanner // out
	var _cret C.gboolean   // in

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_banner_get_use_markup(_arg0)
	runtime.KeepAlive(self)

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SetButtonLabel sets the button label for self.
//
// If set to "" or NULL, the button won't be shown.
//
// The button can be used with a GAction, or with the banner::button-clicked
// signal.
//
// The function takes the following parameters:
//
//   - label (optional): label.
func (self *Banner) SetButtonLabel(label string) {
	var _arg0 *C.AdwBanner // out
	var _arg1 *C.char      // out

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if label != "" {
		_arg1 = (*C.char)(unsafe.Pointer(C.CString(label)))
		defer C.free(unsafe.Pointer(_arg1))
	}

	C.adw_banner_set_button_label(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(label)
}

// SetButtonStyle sets the style class to use for the banner button.
//
// When set to ADW_BANNER_BUTTON_DEFAULT, the button stays grey. When set
// to ADW_BANNER_BUTTON_SUGGESTED, the button follows the .suggested-action
// (style-classes.html#suggested-action) style
//
// <picture> <source srcset="banner-suggested-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="banner-suggested.png"
// alt="banner with suggested button style"> </picture>.
//
// The function takes the following parameters:
//
//   - style: button style.
func (self *Banner) SetButtonStyle(style BannerButtonStyle) {
	var _arg0 *C.AdwBanner           // out
	var _arg1 C.AdwBannerButtonStyle // out

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.AdwBannerButtonStyle(style)

	C.adw_banner_set_button_style(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(style)
}

// SetRevealed sets whether a banner should be revealed.
//
// The function takes the following parameters:
//
//   - revealed: whether a banner should be revealed.
func (self *Banner) SetRevealed(revealed bool) {
	var _arg0 *C.AdwBanner // out
	var _arg1 C.gboolean   // out

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if revealed {
		_arg1 = C.TRUE
	}

	C.adw_banner_set_revealed(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(revealed)
}

// SetTitle sets the title for this banner.
//
// See also: banner:use-markup.
//
// The function takes the following parameters:
//
//   - title: title.
func (self *Banner) SetTitle(title string) {
	var _arg0 *C.AdwBanner // out
	var _arg1 *C.char      // out

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.char)(unsafe.Pointer(C.CString(title)))
	defer C.free(unsafe.Pointer(_arg1))

	C.adw_banner_set_title(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(title)
}

// SetUseMarkup sets whether to use Pango markup for the banner title.
//
// See also pango.ParseMarkup().
//
// The function takes the following parameters:
//
//   - useMarkup: whether to use markup.
func (self *Banner) SetUseMarkup(useMarkup bool) {
	var _arg0 *C.AdwBanner // out
	var _arg1 C.gboolean   // out

	_arg0 = (*C.AdwBanner)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if useMarkup {
		_arg1 = C.TRUE
	}

	C.adw_banner_set_use_markup(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(useMarkup)
}
