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

// GType values.
var (
	GTypeCarousel = coreglib.Type(C.adw_carousel_get_type())
)

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

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

func defaultCarouselOverrides(v *Carousel) CarouselOverrides {
	return CarouselOverrides{}
}

// Carousel: paginated scrolling widget.
//
// <picture> <source srcset="carousel-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="carousel.png" alt="carousel"> </picture>
//
// The AdwCarousel widget can be used to display a set of pages with swipe-based
// navigation between them.
//
// carouselindicatordots and carouselindicatorlines can be used to provide page
// indicators for AdwCarousel.
//
// # CSS nodes
//
// AdwCarousel has a single CSS node with name carousel.
type Carousel struct {
	_ [0]func() // equal guard
	gtk.Widget

	*coreglib.Object
	Swipeable
	gtk.Orientable
}

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

func init() {
	coreglib.RegisterClassInfo[*Carousel, *CarouselClass, CarouselOverrides](
		GTypeCarousel,
		initCarouselClass,
		wrapCarousel,
		defaultCarouselOverrides,
	)
}

func initCarouselClass(gclass unsafe.Pointer, overrides CarouselOverrides, classInitFunc func(*CarouselClass)) {
	if classInitFunc != nil {
		class := (*CarouselClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapCarousel(obj *coreglib.Object) *Carousel {
	return &Carousel{
		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,
		Swipeable: Swipeable{
			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,
				},
			},
		},
		Orientable: gtk.Orientable{
			Object: obj,
		},
	}
}

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

// ConnectPageChanged: this signal is emitted after a page has been changed.
//
// It can be used to implement "infinite scrolling" by amending the pages after
// every scroll.
//
// ::: note An empty carousel is indicated by (int)index == -1.
func (self *Carousel) ConnectPageChanged(f func(index uint)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "page-changed", false, unsafe.Pointer(C._gotk4_adw1_Carousel_ConnectPageChanged), f)
}

// NewCarousel creates a new AdwCarousel.
//
// The function returns the following values:
//
//   - carousel: newly created AdwCarousel.
func NewCarousel() *Carousel {
	var _cret *C.GtkWidget // in

	_cret = C.adw_carousel_new()

	var _carousel *Carousel // out

	_carousel = wrapCarousel(coreglib.Take(unsafe.Pointer(_cret)))

	return _carousel
}

// Append appends child to self.
//
// The function takes the following parameters:
//
//   - child: widget to add.
func (self *Carousel) Append(child gtk.Widgetter) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))

	C.adw_carousel_append(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(child)
}

// AllowLongSwipes gets whether to allow swiping for more than one page at a
// time.
//
// The function returns the following values:
//
//   - ok: TRUE if long swipes are allowed.
func (self *Carousel) AllowLongSwipes() bool {
	var _arg0 *C.AdwCarousel // out
	var _cret C.gboolean     // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// AllowMouseDrag sets whether self can be dragged with mouse pointer.
//
// The function returns the following values:
//
//   - ok: whether self can be dragged with mouse pointer.
func (self *Carousel) AllowMouseDrag() bool {
	var _arg0 *C.AdwCarousel // out
	var _cret C.gboolean     // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// AllowScrollWheel gets whether self will respond to scroll wheel events.
//
// The function returns the following values:
//
//   - ok: TRUE if self will respond to scroll wheel events.
func (self *Carousel) AllowScrollWheel() bool {
	var _arg0 *C.AdwCarousel // out
	var _cret C.gboolean     // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Interactive gets whether self can be navigated.
//
// The function returns the following values:
//
//   - ok: whether self can be navigated.
func (self *Carousel) Interactive() bool {
	var _arg0 *C.AdwCarousel // out
	var _cret C.gboolean     // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// NPages gets the number of pages in self.
//
// The function returns the following values:
//
//   - guint: number of pages in self.
func (self *Carousel) NPages() uint {
	var _arg0 *C.AdwCarousel // out
	var _cret C.guint        // in

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

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

	var _guint uint // out

	_guint = uint(_cret)

	return _guint
}

// NthPage gets the page at position n.
//
// The function takes the following parameters:
//
//   - n: index of the page.
//
// The function returns the following values:
//
//   - widget: page.
func (self *Carousel) NthPage(n uint) gtk.Widgetter {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.guint        // out
	var _cret *C.GtkWidget   // in

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.guint(n)

	_cret = C.adw_carousel_get_nth_page(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(n)

	var _widget gtk.Widgetter // out

	{
		objptr := unsafe.Pointer(_cret)
		if objptr == nil {
			panic("object of type gtk.Widgetter is nil")
		}

		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
}

// Position gets current scroll position in self, unitless.
//
// 1 matches 1 page. Use carousel.ScrollTo for changing it.
//
// The function returns the following values:
//
//   - gdouble: scroll position.
func (self *Carousel) Position() float64 {
	var _arg0 *C.AdwCarousel // out
	var _cret C.double       // in

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

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

	var _gdouble float64 // out

	_gdouble = float64(_cret)

	return _gdouble
}

// RevealDuration gets the page reveal duration, in milliseconds.
//
// The function returns the following values:
//
//   - guint: duration.
func (self *Carousel) RevealDuration() uint {
	var _arg0 *C.AdwCarousel // out
	var _cret C.guint        // in

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

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

	var _guint uint // out

	_guint = uint(_cret)

	return _guint
}

// ScrollParams gets the scroll animation spring parameters for self.
//
// The function returns the following values:
//
//   - springParams: animation parameters.
func (self *Carousel) ScrollParams() *SpringParams {
	var _arg0 *C.AdwCarousel     // out
	var _cret *C.AdwSpringParams // in

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

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

	var _springParams *SpringParams // out

	_springParams = (*SpringParams)(gextras.NewStructNative(unsafe.Pointer(_cret)))
	runtime.SetFinalizer(
		gextras.StructIntern(unsafe.Pointer(_springParams)),
		func(intern *struct{ C unsafe.Pointer }) {
			C.adw_spring_params_unref((*C.AdwSpringParams)(intern.C))
		},
	)

	return _springParams
}

// Spacing gets spacing between pages in pixels.
//
// The function returns the following values:
//
//   - guint: spacing between pages.
func (self *Carousel) Spacing() uint {
	var _arg0 *C.AdwCarousel // out
	var _cret C.guint        // in

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

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

	var _guint uint // out

	_guint = uint(_cret)

	return _guint
}

// Insert inserts child into self at position position.
//
// If position is -1, or larger than the number of pages, child will be appended
// to the end.
//
// The function takes the following parameters:
//
//   - child: widget to add.
//   - position to insert child at.
func (self *Carousel) Insert(child gtk.Widgetter, position int) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out
	var _arg2 C.int          // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
	_arg2 = C.int(position)

	C.adw_carousel_insert(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(child)
	runtime.KeepAlive(position)
}

// Prepend prepends child to self.
//
// The function takes the following parameters:
//
//   - child: widget to add.
func (self *Carousel) Prepend(child gtk.Widgetter) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))

	C.adw_carousel_prepend(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(child)
}

// Remove removes child from self.
//
// The function takes the following parameters:
//
//   - child: widget to remove.
func (self *Carousel) Remove(child gtk.Widgetter) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))

	C.adw_carousel_remove(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(child)
}

// Reorder moves child into position position.
//
// If position is -1, or larger than the number of pages, child will be moved at
// the end.
//
// The function takes the following parameters:
//
//   - child: widget to add.
//   - position to move child to.
func (self *Carousel) Reorder(child gtk.Widgetter, position int) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out
	var _arg2 C.int          // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
	_arg2 = C.int(position)

	C.adw_carousel_reorder(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(child)
	runtime.KeepAlive(position)
}

// ScrollTo scrolls to widget.
//
// If animate is TRUE, the transition will be animated.
//
// The function takes the following parameters:
//
//   - widget: child of self.
//   - animate: whether to animate the transition.
func (self *Carousel) ScrollTo(widget gtk.Widgetter, animate bool) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 *C.GtkWidget   // out
	var _arg2 C.gboolean     // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))
	if animate {
		_arg2 = C.TRUE
	}

	C.adw_carousel_scroll_to(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(widget)
	runtime.KeepAlive(animate)
}

// SetAllowLongSwipes sets whether to allow swiping for more than one page at a
// time.
//
// If allow_long_swipes is FALSE, each swipe can only move to the adjacent
// pages.
//
// The function takes the following parameters:
//
//   - allowLongSwipes: whether to allow long swipes.
func (self *Carousel) SetAllowLongSwipes(allowLongSwipes bool) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.gboolean     // out

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

	C.adw_carousel_set_allow_long_swipes(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(allowLongSwipes)
}

// SetAllowMouseDrag sets whether self can be dragged with mouse pointer.
//
// If allow_mouse_drag is FALSE, dragging is only available on touch.
//
// The function takes the following parameters:
//
//   - allowMouseDrag: whether self can be dragged with mouse pointer.
func (self *Carousel) SetAllowMouseDrag(allowMouseDrag bool) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.gboolean     // out

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

	C.adw_carousel_set_allow_mouse_drag(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(allowMouseDrag)
}

// SetAllowScrollWheel sets whether self will respond to scroll wheel events.
//
// If allow_scroll_wheel is FALSE, wheel events will be ignored.
//
// The function takes the following parameters:
//
//   - allowScrollWheel: whether self will respond to scroll wheel events.
func (self *Carousel) SetAllowScrollWheel(allowScrollWheel bool) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.gboolean     // out

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

	C.adw_carousel_set_allow_scroll_wheel(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(allowScrollWheel)
}

// SetInteractive sets whether self can be navigated.
//
// This can be used to temporarily disable the carousel to only allow navigating
// it in a certain state.
//
// The function takes the following parameters:
//
//   - interactive: whether self can be navigated.
func (self *Carousel) SetInteractive(interactive bool) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.gboolean     // out

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

	C.adw_carousel_set_interactive(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(interactive)
}

// SetRevealDuration sets the page reveal duration, in milliseconds.
//
// Reveal duration is used when animating adding or removing pages.
//
// The function takes the following parameters:
//
//   - revealDuration: new reveal duration value.
func (self *Carousel) SetRevealDuration(revealDuration uint) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.guint        // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.guint(revealDuration)

	C.adw_carousel_set_reveal_duration(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(revealDuration)
}

// SetScrollParams sets the scroll animation spring parameters for self.
//
// The default value is equivalent to:
//
//	adw_spring_params_new (1, 0.5, 500).
//
// The function takes the following parameters:
//
//   - params: new parameters.
func (self *Carousel) SetScrollParams(params *SpringParams) {
	var _arg0 *C.AdwCarousel     // out
	var _arg1 *C.AdwSpringParams // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwSpringParams)(gextras.StructNative(unsafe.Pointer(params)))

	C.adw_carousel_set_scroll_params(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(params)
}

// SetSpacing sets spacing between pages in pixels.
//
// The function takes the following parameters:
//
//   - spacing: new spacing value.
func (self *Carousel) SetSpacing(spacing uint) {
	var _arg0 *C.AdwCarousel // out
	var _arg1 C.guint        // out

	_arg0 = (*C.AdwCarousel)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.guint(spacing)

	C.adw_carousel_set_spacing(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(spacing)
}

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

// carouselClass is the struct that's finalized.
type carouselClass struct {
	native *C.AdwCarouselClass
}

func (c *CarouselClass) ParentClass() *gtk.WidgetClass {
	valptr := &c.native.parent_class
	var _v *gtk.WidgetClass // out
	_v = (*gtk.WidgetClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
	return _v
}
