// 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_ButtonRow_ConnectActivated(gpointer, guintptr);
import "C"

// GType values.
var (
	GTypeButtonRow = coreglib.Type(C.adw_button_row_get_type())
)

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

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

func defaultButtonRowOverrides(v *ButtonRow) ButtonRowOverrides {
	return ButtonRowOverrides{}
}

// ButtonRow: gtk.ListBoxRow that looks like a button.
//
// <picture> <source srcset="button-rows-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="button-rows.png" alt="button-rows"> </picture>
//
// The AdwButtonRow widget has a title and two icons: before and after the
// title.
//
// It is convenient for presenting actions like "Delete" at the end of a boxed
// list.
//
// AdwButtonRow is always activatable.
//
// # CSS nodes
//
// AdwButtonRow has a main CSS node with name row and the style class .button.
//
// It contains the subnode box for its main horizontal box, which contains
// the nodes: image.icon.start for the start icon, label.title for the title,
// and image.icon.end for the end icon.
//
// # Style classes
//
// The .suggested-action (style-classes.html#suggested-action) style class makes
// AdwButtonRow use accent color for its background. It should be used very
// sparingly to denote important buttons.
//
// <picture> <source srcset="button-row-suggested-action-dark.png"
// media="(prefers-color-scheme: dark)"> <img
// src="button-row-suggested-action.png" alt="button-row-suggested-action">
// </picture>
//
// The .destructive-action (style-classes.html#destructive-action) style makes
// the row use destructive colors. It can be used to draw attention to the
// potentially damaging consequences of using it. This style acts as a warning
// to the user.
//
// <picture> <source srcset="button-row-destructive-action-dark.png"
// media="(prefers-color-scheme: dark)"> <img
// src="button-row-destructive-action.png" alt="button-row-destructive-action">
// </picture>.
type ButtonRow struct {
	_ [0]func() // equal guard
	PreferencesRow
}

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

func init() {
	coreglib.RegisterClassInfo[*ButtonRow, *ButtonRowClass, ButtonRowOverrides](
		GTypeButtonRow,
		initButtonRowClass,
		wrapButtonRow,
		defaultButtonRowOverrides,
	)
}

func initButtonRowClass(gclass unsafe.Pointer, overrides ButtonRowOverrides, classInitFunc func(*ButtonRowClass)) {
	if classInitFunc != nil {
		class := (*ButtonRowClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapButtonRow(obj *coreglib.Object) *ButtonRow {
	return &ButtonRow{
		PreferencesRow: PreferencesRow{
			ListBoxRow: gtk.ListBoxRow{
				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 marshalButtonRow(p uintptr) (interface{}, error) {
	return wrapButtonRow(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}

// ConnectActivated: this signal is emitted after the row has been activated.
func (self *ButtonRow) ConnectActivated(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "activated", false, unsafe.Pointer(C._gotk4_adw1_ButtonRow_ConnectActivated), f)
}

// NewButtonRow creates a new AdwButtonRow.
//
// The function returns the following values:
//
//   - buttonRow: newly created AdwButtonRow.
func NewButtonRow() *ButtonRow {
	var _cret *C.GtkWidget // in

	_cret = C.adw_button_row_new()

	var _buttonRow *ButtonRow // out

	_buttonRow = wrapButtonRow(coreglib.Take(unsafe.Pointer(_cret)))

	return _buttonRow
}

// EndIconName gets the end icon name for self.
//
// The function returns the following values:
//
//   - utf8 (optional): end icon name for self.
func (self *ButtonRow) EndIconName() string {
	var _arg0 *C.AdwButtonRow // out
	var _cret *C.char         // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// StartIconName gets the start icon name for self.
//
// The function returns the following values:
//
//   - utf8 (optional): start icon name for self.
func (self *ButtonRow) StartIconName() string {
	var _arg0 *C.AdwButtonRow // out
	var _cret *C.char         // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// SetEndIconName sets the end icon name for self.
//
// The function takes the following parameters:
//
//   - iconName (optional): end icon name.
func (self *ButtonRow) SetEndIconName(iconName string) {
	var _arg0 *C.AdwButtonRow // out
	var _arg1 *C.char         // out

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

	C.adw_button_row_set_end_icon_name(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(iconName)
}

// SetStartIconName sets the start icon name for self.
//
// The function takes the following parameters:
//
//   - iconName (optional): start icon name.
func (self *ButtonRow) SetStartIconName(iconName string) {
	var _arg0 *C.AdwButtonRow // out
	var _arg1 *C.char         // out

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

	C.adw_button_row_set_start_icon_name(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(iconName)
}
