// Code generated by girgen. DO NOT EDIT.

package adw

import (
	"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>
import "C"

// GType values.
var (
	GTypeSpinner = coreglib.Type(C.adw_spinner_get_type())
)

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

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

func defaultSpinnerOverrides(v *Spinner) SpinnerOverrides {
	return SpinnerOverrides{}
}

// Spinner: widget showing a loading spinner.
//
// <picture> <source srcset="spinner-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="spinner.png" alt="spinner"> </picture>
//
// The size of the spinner depends on the available size, never smaller than
// 16×16 pixels and never larger than 64×64 pixels.
//
// Use the gtk.Widget:halign and gtk.Widget:valign properties in combination
// with gtk.Widget:width-request and gtk.Widget:height-request for fine sizing
// control.
//
// For example, the following snippet shows the spinner at 48×48 pixels:
//
//	<object class="AdwSpinner">
//	  <property name="halign">center</property>
//	  <property name="valign">center</property>
//	  <property name="width-request">48</property>
//	  <property name="height-request">48</property>
//	</object>
//
// See spinnerpaintable for cases where using a widget is impractical or
// impossible, such as statuspage:paintable.
//
// # CSS nodes
//
// AdwSpinner has a single node with the name image and the style class
// .spinner.
type Spinner struct {
	_ [0]func() // equal guard
	gtk.Widget
}

var (
	_ gtk.Widgetter = (*Spinner)(nil)
)

func init() {
	coreglib.RegisterClassInfo[*Spinner, *SpinnerClass, SpinnerOverrides](
		GTypeSpinner,
		initSpinnerClass,
		wrapSpinner,
		defaultSpinnerOverrides,
	)
}

func initSpinnerClass(gclass unsafe.Pointer, overrides SpinnerOverrides, classInitFunc func(*SpinnerClass)) {
	if classInitFunc != nil {
		class := (*SpinnerClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

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

// NewSpinner creates a new AdwSpinner.
//
// The function returns the following values:
//
//   - spinner: newly created AdwSpinner.
func NewSpinner() *Spinner {
	var _cret *C.GtkWidget // in

	_cret = C.adw_spinner_new()

	var _spinner *Spinner // out

	_spinner = wrapSpinner(coreglib.Take(unsafe.Pointer(_cret)))

	return _spinner
}
