// 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/gio/v2"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
)

// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
import "C"

// GType values.
var (
	GTypeViewStackPages = coreglib.Type(C.adw_view_stack_pages_get_type())
)

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

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

func defaultViewStackPagesOverrides(v *ViewStackPages) ViewStackPagesOverrides {
	return ViewStackPagesOverrides{}
}

// ViewStackPages: auxiliary class used by viewstack.
//
// See viewstack:pages.
type ViewStackPages struct {
	_ [0]func() // equal guard
	*coreglib.Object

	gtk.SelectionModel
}

var (
	_ coreglib.Objector = (*ViewStackPages)(nil)
)

func init() {
	coreglib.RegisterClassInfo[*ViewStackPages, *ViewStackPagesClass, ViewStackPagesOverrides](
		GTypeViewStackPages,
		initViewStackPagesClass,
		wrapViewStackPages,
		defaultViewStackPagesOverrides,
	)
}

func initViewStackPagesClass(gclass unsafe.Pointer, overrides ViewStackPagesOverrides, classInitFunc func(*ViewStackPagesClass)) {
	if classInitFunc != nil {
		class := (*ViewStackPagesClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapViewStackPages(obj *coreglib.Object) *ViewStackPages {
	return &ViewStackPages{
		Object: obj,
		SelectionModel: gtk.SelectionModel{
			ListModel: gio.ListModel{
				Object: obj,
			},
		},
	}
}

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

// SelectedPage gets the viewstackpage for the visible child of a view stack
//
// Gets the viewstackpage for the visible child of the associated stack.
//
// Returns NULL if there's no selected page.
//
// The function returns the following values:
//
//   - viewStackPage (optional): stack page.
func (self *ViewStackPages) SelectedPage() *ViewStackPage {
	var _arg0 *C.AdwViewStackPages // out
	var _cret *C.AdwViewStackPage  // in

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

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

	var _viewStackPage *ViewStackPage // out

	if _cret != nil {
		_viewStackPage = wrapViewStackPage(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _viewStackPage
}

// SetSelectedPage sets the visible child in the associated viewstack.
//
// See viewstack:visible-child.
//
// The function takes the following parameters:
//
//   - page: stack page within the associated stack.
func (self *ViewStackPages) SetSelectedPage(page *ViewStackPage) {
	var _arg0 *C.AdwViewStackPages // out
	var _arg1 *C.AdwViewStackPage  // out

	_arg0 = (*C.AdwViewStackPages)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwViewStackPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

	C.adw_view_stack_pages_set_selected_page(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(page)
}
