// 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_ActionRow_ConnectActivated(gpointer, guintptr);
// extern void _gotk4_adw1_ActionRowClass_activate(AdwActionRow*);
// void _gotk4_adw1_ActionRow_virtual_activate(void* fnptr, AdwActionRow* arg0) {
//   ((void (*)(AdwActionRow*))(fnptr))(arg0);
// };
import "C"

// GType values.
var (
	GTypeActionRow = coreglib.Type(C.adw_action_row_get_type())
)

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

// ActionRowOverrides contains methods that are overridable.
type ActionRowOverrides struct {
	// Activate activates self.
	Activate func()
}

func defaultActionRowOverrides(v *ActionRow) ActionRowOverrides {
	return ActionRowOverrides{
		Activate: v.activate,
	}
}

// ActionRow: gtk.ListBoxRow used to present actions.
//
// <picture> <source srcset="action-row-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="action-row.png" alt="action-row"> </picture>
//
// The AdwActionRow widget can have a title, a subtitle and an icon. The row can
// receive additional widgets at its end, or prefix widgets at its start.
//
// It is convenient to present a preference and its related actions.
//
// AdwActionRow is unactivatable by default, giving it an activatable widget
// will automatically make it activatable, but unsetting it won't change the
// row's activatability.
//
// # AdwActionRow as GtkBuildable
//
// The AdwActionRow implementation of the gtk.Buildable interface supports
// adding a child at its end by specifying “suffix” or omitting the “type”
// attribute of a <child> element.
//
// It also supports adding a child as a prefix widget by specifying “prefix” as
// the “type” attribute of a <child> element.
//
// # CSS nodes
//
// AdwActionRow has a main CSS node with name row.
//
// It contains the subnode box.header for its main horizontal box, and box.title
// for the vertical box containing the title and subtitle labels.
//
// It contains subnodes label.title and label.subtitle representing respectively
// the title label and subtitle label.
//
// # Style classes
//
// AdwActionRow can use the .property (style-classes.html#property-rows) style
// class to emphasize the row subtitle instead of the row title, which is useful
// for displaying read-only properties.
//
// <picture> <source srcset="property-row-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="property-row.png"
// alt="property-row"> </picture>
//
// When used together with the .monospace style class, only the subtitle becomes
// monospace, not the title or any extra widgets.
type ActionRow struct {
	_ [0]func() // equal guard
	PreferencesRow
}

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

func init() {
	coreglib.RegisterClassInfo[*ActionRow, *ActionRowClass, ActionRowOverrides](
		GTypeActionRow,
		initActionRowClass,
		wrapActionRow,
		defaultActionRowOverrides,
	)
}

func initActionRowClass(gclass unsafe.Pointer, overrides ActionRowOverrides, classInitFunc func(*ActionRowClass)) {
	pclass := (*C.AdwActionRowClass)(unsafe.Pointer(C.g_type_check_class_cast((*C.GTypeClass)(gclass), C.GType(GTypeActionRow))))

	if overrides.Activate != nil {
		pclass.activate = (*[0]byte)(C._gotk4_adw1_ActionRowClass_activate)
	}

	if classInitFunc != nil {
		class := (*ActionRowClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapActionRow(obj *coreglib.Object) *ActionRow {
	return &ActionRow{
		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 marshalActionRow(p uintptr) (interface{}, error) {
	return wrapActionRow(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}

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

// NewActionRow creates a new AdwActionRow.
//
// The function returns the following values:
//
//   - actionRow: newly created AdwActionRow.
func NewActionRow() *ActionRow {
	var _cret *C.GtkWidget // in

	_cret = C.adw_action_row_new()

	var _actionRow *ActionRow // out

	_actionRow = wrapActionRow(coreglib.Take(unsafe.Pointer(_cret)))

	return _actionRow
}

// Activate activates self.
func (self *ActionRow) Activate() {
	var _arg0 *C.AdwActionRow // out

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

	C.adw_action_row_activate(_arg0)
	runtime.KeepAlive(self)
}

// AddPrefix adds a prefix widget to self.
//
// The function takes the following parameters:
//
//   - widget: widget.
func (self *ActionRow) AddPrefix(widget gtk.Widgetter) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.GtkWidget    // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))

	C.adw_action_row_add_prefix(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(widget)
}

// AddSuffix adds a suffix widget to self.
//
// The function takes the following parameters:
//
//   - widget: widget.
func (self *ActionRow) AddSuffix(widget gtk.Widgetter) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.GtkWidget    // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))

	C.adw_action_row_add_suffix(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(widget)
}

// ActivatableWidget gets the widget activated when self is activated.
//
// The function returns the following values:
//
//   - widget (optional): activatable widget for self.
func (self *ActionRow) ActivatableWidget() gtk.Widgetter {
	var _arg0 *C.AdwActionRow // out
	var _cret *C.GtkWidget    // in

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

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

	var _widget gtk.Widgetter // out

	if _cret != nil {
		{
			objptr := unsafe.Pointer(_cret)

			object := coreglib.Take(objptr)
			casted := object.WalkCast(func(obj coreglib.Objector) bool {
				_, ok := obj.(gtk.Widgetter)
				return ok
			})
			rv, ok := casted.(gtk.Widgetter)
			if !ok {
				panic("no marshaler for " + object.TypeFromInstance().String() + " matching gtk.Widgetter")
			}
			_widget = rv
		}
	}

	return _widget
}

// IconName gets the icon name for self.
//
// Deprecated: Use actionrow.AddPrefix to add an icon.
//
// The function returns the following values:
//
//   - utf8 (optional): icon name for self.
func (self *ActionRow) IconName() string {
	var _arg0 *C.AdwActionRow // out
	var _cret *C.char         // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// Subtitle gets the subtitle for self.
//
// The function returns the following values:
//
//   - utf8 (optional): subtitle for self.
func (self *ActionRow) Subtitle() string {
	var _arg0 *C.AdwActionRow // out
	var _cret *C.char         // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// SubtitleLines gets the number of lines at the end of which the subtitle label
// will be ellipsized.
//
// The function returns the following values:
//
//   - gint: number of lines at the end of which the subtitle label will be
//     ellipsized.
func (self *ActionRow) SubtitleLines() int {
	var _arg0 *C.AdwActionRow // out
	var _cret C.int           // in

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

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

	var _gint int // out

	_gint = int(_cret)

	return _gint
}

// SubtitleSelectable gets whether the user can copy the subtitle from the
// label.
//
// The function returns the following values:
//
//   - ok: whether the user can copy the subtitle from the label.
func (self *ActionRow) SubtitleSelectable() bool {
	var _arg0 *C.AdwActionRow // out
	var _cret C.gboolean      // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// TitleLines gets the number of lines at the end of which the title label will
// be ellipsized.
//
// The function returns the following values:
//
//   - gint: number of lines at the end of which the title label will be
//     ellipsized.
func (self *ActionRow) TitleLines() int {
	var _arg0 *C.AdwActionRow // out
	var _cret C.int           // in

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

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

	var _gint int // out

	_gint = int(_cret)

	return _gint
}

// Remove removes a child from self.
//
// The function takes the following parameters:
//
//   - widget: child to be removed.
func (self *ActionRow) Remove(widget gtk.Widgetter) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.GtkWidget    // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))

	C.adw_action_row_remove(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(widget)
}

// SetActivatableWidget sets the widget to activate when self is activated.
//
// The row can be activated either by clicking on it, calling
// actionrow.Activate, or via mnemonics in the title. See the
// preferencesrow:use-underline property to enable mnemonics.
//
// The target widget will be activated by emitting the
// gtk.Widget::mnemonic-activate signal on it.
//
// The function takes the following parameters:
//
//   - widget (optional): target widget.
func (self *ActionRow) SetActivatableWidget(widget gtk.Widgetter) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.GtkWidget    // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if widget != nil {
		_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))
	}

	C.adw_action_row_set_activatable_widget(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(widget)
}

// SetIconName sets the icon name for self.
//
// Deprecated: Use actionrow.AddPrefix to add an icon.
//
// The function takes the following parameters:
//
//   - iconName (optional): icon name.
func (self *ActionRow) SetIconName(iconName string) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.char         // out

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

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

// SetSubtitle sets the subtitle for self.
//
// The subtitle is interpreted as Pango markup unless preferencesrow:use-markup
// is set to FALSE.
//
// The function takes the following parameters:
//
//   - subtitle: subtitle.
func (self *ActionRow) SetSubtitle(subtitle string) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 *C.char         // out

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

	C.adw_action_row_set_subtitle(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(subtitle)
}

// SetSubtitleLines sets the number of lines at the end of which the subtitle
// label will be ellipsized.
//
// If the value is 0, the number of lines won't be limited.
//
// The function takes the following parameters:
//
//   - subtitleLines: number of lines at the end of which the subtitle label
//     will be ellipsized.
func (self *ActionRow) SetSubtitleLines(subtitleLines int) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 C.int           // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.int(subtitleLines)

	C.adw_action_row_set_subtitle_lines(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(subtitleLines)
}

// SetSubtitleSelectable sets whether the user can copy the subtitle from the
// label
//
// See also gtk.Label:selectable.
//
// The function takes the following parameters:
//
//   - subtitleSelectable: TRUE if the user can copy the subtitle from the
//     label.
func (self *ActionRow) SetSubtitleSelectable(subtitleSelectable bool) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 C.gboolean      // out

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

	C.adw_action_row_set_subtitle_selectable(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(subtitleSelectable)
}

// SetTitleLines sets the number of lines at the end of which the title label
// will be ellipsized.
//
// If the value is 0, the number of lines won't be limited.
//
// The function takes the following parameters:
//
//   - titleLines: number of lines at the end of which the title label will be
//     ellipsized.
func (self *ActionRow) SetTitleLines(titleLines int) {
	var _arg0 *C.AdwActionRow // out
	var _arg1 C.int           // out

	_arg0 = (*C.AdwActionRow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.int(titleLines)

	C.adw_action_row_set_title_lines(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(titleLines)
}

// Activate activates self.
func (self *ActionRow) activate() {
	gclass := (*C.AdwActionRowClass)(coreglib.PeekParentClass(self))
	fnarg := gclass.activate

	var _arg0 *C.AdwActionRow // out

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

	C._gotk4_adw1_ActionRow_virtual_activate(unsafe.Pointer(fnarg), _arg0)
	runtime.KeepAlive(self)
}

// ActionRowClass: instance of this type is always passed by reference.
type ActionRowClass struct {
	*actionRowClass
}

// actionRowClass is the struct that's finalized.
type actionRowClass struct {
	native *C.AdwActionRowClass
}

// ParentClass: parent class.
func (a *ActionRowClass) ParentClass() *PreferencesRowClass {
	valptr := &a.native.parent_class
	var _v *PreferencesRowClass // out
	_v = (*PreferencesRowClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
	return _v
}
