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

// GType values.
var (
	GTypeNavigationSplitView = coreglib.Type(C.adw_navigation_split_view_get_type())
)

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

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

func defaultNavigationSplitViewOverrides(v *NavigationSplitView) NavigationSplitViewOverrides {
	return NavigationSplitViewOverrides{}
}

// NavigationSplitView: widget presenting sidebar and content side by side or as
// a navigation view.
//
// <picture> <source srcset="navigation-split-view-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="navigation-split-view.png"
// alt="navigation-split-view"> </picture> <picture> <source
// srcset="navigation-split-view-collapsed-dark.png"
// media="(prefers-color-scheme: dark)"> <img
// src="navigation-split-view-collapsed.png"
// alt="navigation-split-view-collapsed"> </picture>
//
// AdwNavigationSplitView has two navigationpage children: sidebar and content,
// and displays them side by side.
//
// When navigationsplitview:collapsed is set to TRUE, it instead puts both
// children inside an navigationview. The navigationsplitview:show-content
// controls which child is visible while collapsed.
//
// See also overlaysplitview.
//
// AdwNavigationSplitView is typically used together with an breakpoint setting
// the collapsed property to TRUE on small widths, as follows:
//
//	<object class="AdwWindow">
//	  <property name="width-request">280</property>
//	  <property name="height-request">200</property>
//	  <property name="default-width">800</property>
//	  <property name="default-height">800</property>
//	  <child>
//	    <object class="AdwBreakpoint">
//	      <condition>max-width: 400sp</condition>
//	      <setter object="split_view" property="collapsed">True</setter>
//	    </object>
//	  </child>
//	  <property name="content">
//	    <object class="AdwNavigationSplitView" id="split_view">
//	      <property name="sidebar">
//	        <object class="AdwNavigationPage">
//	          <property name="title" translatable="yes">Sidebar</property>
//	          <property name="child">
//	            <!-- ... -->
//	          </property>
//	        </object>
//	      </property>
//	      <property name="content">
//	        <object class="AdwNavigationPage">
//	          <property name="title" translatable="yes">Content</property>
//	          <property name="child">
//	            <!-- ... -->
//	          </property>
//	        </object>
//	      </property>
//	    </object>
//	  </property>
//	</object>
//
// # Sizing
//
// When not collapsed, AdwNavigationSplitView changes the sidebar width
// depending on its own width.
//
// If possible, it tries to allocate a fraction of the total width, controlled
// with the navigationsplitview:sidebar-width-fraction property.
//
// The sidebar also has minimum and maximum sizes, controlled
// with the navigationsplitview:min-sidebar-width and
// navigationsplitview:max-sidebar-width properties.
//
// The minimum and maximum sizes are using the length unit specified with the
// navigationsplitview:sidebar-width-unit.
//
// By default, sidebar is using 25% of the total width, with 180sp as the
// minimum size and 280sp as the maximum size.
//
// # Header Bar Integration
//
// When used inside AdwNavigationSplitView, headerbar will automatically hide
// the window buttons in the middle.
//
// When collapsed, it also displays a back button for the content widget,
// as well as the page titles. See navigationview documentation for details.
//
// # Actions
//
// AdwNavigationSplitView defines the same actions as AdwNavigationView,
// but they can be used even when the split view is not collapsed:
//
// - navigation.push takes a string parameter specifying the tag of the
// page to push. If it matches the tag of the content widget, it sets
// navigationsplitview:show-content to TRUE.
//
// - navigation.pop doesn't take any parameters and sets
// navigationsplitview:show-content to FALSE.
//
// # AdwNavigationSplitView as GtkBuildable
//
// The AdwNavigationSplitView implementation of the gtk.Buildable interface
// supports setting the sidebar widget by specifying “sidebar” as the “type”
// attribute of a <child> element, Specifying “content” child type or omitting
// it results in setting the content widget.
//
// # CSS nodes
//
// AdwNavigationSplitView has a single CSS node with the name
// navigation-split-view.
//
// When collapsed, it contains a child node with the name navigation-view
// containing both children.
//
//	navigation-split-view
//	╰── navigation-view
//	    ├── [sidebar child]
//	    ╰── [content child]
//
// When not collapsed, it contains two nodes with the name widget, one with
// the .sidebar-pane style class, the other one with .content-view style class,
// containing the sidebar and content children respectively.
//
//	navigation-split-view
//	├── widget.sidebar-pane
//	│   ╰── [sidebar child]
//	╰── widget.content-pane
//	    ╰── [content child]
//
// # Accessibility
//
// AdwNavigationSplitView uses the GTK_ACCESSIBLE_ROLE_GROUP role.
type NavigationSplitView struct {
	_ [0]func() // equal guard
	gtk.Widget
}

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

func init() {
	coreglib.RegisterClassInfo[*NavigationSplitView, *NavigationSplitViewClass, NavigationSplitViewOverrides](
		GTypeNavigationSplitView,
		initNavigationSplitViewClass,
		wrapNavigationSplitView,
		defaultNavigationSplitViewOverrides,
	)
}

func initNavigationSplitViewClass(gclass unsafe.Pointer, overrides NavigationSplitViewOverrides, classInitFunc func(*NavigationSplitViewClass)) {
	if classInitFunc != nil {
		class := (*NavigationSplitViewClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

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

// NewNavigationSplitView creates a new AdwNavigationSplitView.
//
// The function returns the following values:
//
//   - navigationSplitView: newly created AdwNavigationSplitView.
func NewNavigationSplitView() *NavigationSplitView {
	var _cret *C.GtkWidget // in

	_cret = C.adw_navigation_split_view_new()

	var _navigationSplitView *NavigationSplitView // out

	_navigationSplitView = wrapNavigationSplitView(coreglib.Take(unsafe.Pointer(_cret)))

	return _navigationSplitView
}

// Collapsed gets whether self is collapsed.
//
// The function returns the following values:
//
//   - ok: whether self is collapsed.
func (self *NavigationSplitView) Collapsed() bool {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.gboolean                // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Content sets the content widget for self.
//
// The function returns the following values:
//
//   - navigationPage (optional): content widget.
func (self *NavigationSplitView) Content() *NavigationPage {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret *C.AdwNavigationPage      // in

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

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

	var _navigationPage *NavigationPage // out

	if _cret != nil {
		_navigationPage = wrapNavigationPage(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _navigationPage
}

// MaxSidebarWidth gets the maximum sidebar width for self.
//
// The function returns the following values:
//
//   - gdouble: maximum width.
func (self *NavigationSplitView) MaxSidebarWidth() float64 {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.double                  // in

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

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

	var _gdouble float64 // out

	_gdouble = float64(_cret)

	return _gdouble
}

// MinSidebarWidth gets the minimum sidebar width for self.
//
// The function returns the following values:
//
//   - gdouble: minimum width.
func (self *NavigationSplitView) MinSidebarWidth() float64 {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.double                  // in

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

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

	var _gdouble float64 // out

	_gdouble = float64(_cret)

	return _gdouble
}

// ShowContent gets which page is visible when self is collapsed.
//
// The function returns the following values:
//
//   - ok: whether to show content when collapsed.
func (self *NavigationSplitView) ShowContent() bool {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.gboolean                // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Sidebar gets the sidebar widget for self.
//
// The function returns the following values:
//
//   - navigationPage (optional): sidebar widget.
func (self *NavigationSplitView) Sidebar() *NavigationPage {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret *C.AdwNavigationPage      // in

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

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

	var _navigationPage *NavigationPage // out

	if _cret != nil {
		_navigationPage = wrapNavigationPage(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _navigationPage
}

// SidebarPosition gets the sidebar position for self.
//
// The function returns the following values:
//
//   - packType: sidebar position for self.
func (self *NavigationSplitView) SidebarPosition() gtk.PackType {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.GtkPackType             // in

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

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

	var _packType gtk.PackType // out

	_packType = gtk.PackType(_cret)

	return _packType
}

// SidebarWidthFraction gets the preferred sidebar width fraction for self.
//
// The function returns the following values:
//
//   - gdouble: preferred width fraction.
func (self *NavigationSplitView) SidebarWidthFraction() float64 {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.double                  // in

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

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

	var _gdouble float64 // out

	_gdouble = float64(_cret)

	return _gdouble
}

// SidebarWidthUnit gets the length unit for minimum and maximum sidebar widths.
//
// The function returns the following values:
//
//   - lengthUnit: length unit.
func (self *NavigationSplitView) SidebarWidthUnit() LengthUnit {
	var _arg0 *C.AdwNavigationSplitView // out
	var _cret C.AdwLengthUnit           // in

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

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

	var _lengthUnit LengthUnit // out

	_lengthUnit = LengthUnit(_cret)

	return _lengthUnit
}

// SetCollapsed sets whether self is collapsed.
//
// When collapsed, the children are put inside an navigationview, otherwise they
// are displayed side by side.
//
// The navigationsplitview:show-content controls which child is visible while
// collapsed.
//
// The function takes the following parameters:
//
//   - collapsed: whether self is collapsed.
func (self *NavigationSplitView) SetCollapsed(collapsed bool) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.gboolean                // out

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

	C.adw_navigation_split_view_set_collapsed(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(collapsed)
}

// SetContent sets the content widget for self.
//
// The function takes the following parameters:
//
//   - content (optional) widget.
func (self *NavigationSplitView) SetContent(content *NavigationPage) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 *C.AdwNavigationPage      // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if content != nil {
		_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(content).Native()))
	}

	C.adw_navigation_split_view_set_content(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(content)
}

// SetMaxSidebarWidth sets the maximum sidebar width for self.
//
// Maximum width is affected by navigationsplitview:sidebar-width-unit.
//
// The sidebar widget can still be allocated with larger width if its own
// minimum width exceeds it.
//
// The function takes the following parameters:
//
//   - width: maximum width.
func (self *NavigationSplitView) SetMaxSidebarWidth(width float64) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.double                  // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.double(width)

	C.adw_navigation_split_view_set_max_sidebar_width(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(width)
}

// SetMinSidebarWidth sets the minimum sidebar width for self.
//
// Minimum width is affected by navigationsplitview:sidebar-width-unit.
//
// The sidebar widget can still be allocated with larger width if its own
// minimum width exceeds it.
//
// The function takes the following parameters:
//
//   - width: minimum width.
func (self *NavigationSplitView) SetMinSidebarWidth(width float64) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.double                  // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.double(width)

	C.adw_navigation_split_view_set_min_sidebar_width(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(width)
}

// SetShowContent sets which page is visible when self is collapsed.
//
// If set to TRUE, the content widget will be the visible page when
// navigationsplitview:collapsed is TRUE; otherwise the sidebar widget will be
// visible.
//
// If the split view is already collapsed, the visible page changes immediately.
//
// The function takes the following parameters:
//
//   - showContent: whether to show content when collapsed.
func (self *NavigationSplitView) SetShowContent(showContent bool) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.gboolean                // out

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

	C.adw_navigation_split_view_set_show_content(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(showContent)
}

// SetSidebar sets the sidebar widget for self.
//
// The function takes the following parameters:
//
//   - sidebar (optional) widget.
func (self *NavigationSplitView) SetSidebar(sidebar *NavigationPage) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 *C.AdwNavigationPage      // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if sidebar != nil {
		_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(sidebar).Native()))
	}

	C.adw_navigation_split_view_set_sidebar(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(sidebar)
}

// SetSidebarPosition sets the sidebar position for self.
//
// If set to GTK_PACK_START, the sidebar is displayed before the content,
// and the sidebar will be the root page when collapsed.
//
// If set to GTK_PACK_END, the sidebar is displayed after the content, and the
// content will be the root page.
//
// The function takes the following parameters:
//
//   - position: new position.
func (self *NavigationSplitView) SetSidebarPosition(position gtk.PackType) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.GtkPackType             // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.GtkPackType(position)

	C.adw_navigation_split_view_set_sidebar_position(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(position)
}

// SetSidebarWidthFraction sets the preferred sidebar width as a fraction of the
// total width of self.
//
// The preferred width is additionally limited
// by navigationsplitview:min-sidebar-width and
// navigationsplitview:max-sidebar-width.
//
// The sidebar widget can be allocated with larger width if its own minimum
// width exceeds the preferred width.
//
// The function takes the following parameters:
//
//   - fraction: preferred width fraction.
func (self *NavigationSplitView) SetSidebarWidthFraction(fraction float64) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.double                  // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.double(fraction)

	C.adw_navigation_split_view_set_sidebar_width_fraction(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(fraction)
}

// SetSidebarWidthUnit sets the length unit for minimum and maximum sidebar
// widths.
//
// See navigationsplitview:min-sidebar-width and
// navigationsplitview:max-sidebar-width.
//
// The function takes the following parameters:
//
//   - unit: length unit.
func (self *NavigationSplitView) SetSidebarWidthUnit(unit LengthUnit) {
	var _arg0 *C.AdwNavigationSplitView // out
	var _arg1 C.AdwLengthUnit           // out

	_arg0 = (*C.AdwNavigationSplitView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.AdwLengthUnit(unit)

	C.adw_navigation_split_view_set_sidebar_width_unit(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(unit)
}
