// 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>
// extern void _gotk4_adw1_NavigationView_ConnectReplaced(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationView_ConnectPushed(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationView_ConnectPopped(gpointer, AdwNavigationPage*, guintptr);
// extern void _gotk4_adw1_NavigationPage_ConnectShown(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationPage_ConnectShowing(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationPage_ConnectHiding(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationPage_ConnectHidden(gpointer, guintptr);
// extern void _gotk4_adw1_NavigationPageClass_shown(AdwNavigationPage*);
// extern void _gotk4_adw1_NavigationPageClass_showing(AdwNavigationPage*);
// extern void _gotk4_adw1_NavigationPageClass_hiding(AdwNavigationPage*);
// extern void _gotk4_adw1_NavigationPageClass_hidden(AdwNavigationPage*);
// extern AdwNavigationPage* _gotk4_adw1_NavigationView_ConnectGetNextPage(gpointer, guintptr);
// void _gotk4_adw1_NavigationPage_virtual_hidden(void* fnptr, AdwNavigationPage* arg0) {
//   ((void (*)(AdwNavigationPage*))(fnptr))(arg0);
// };
// void _gotk4_adw1_NavigationPage_virtual_hiding(void* fnptr, AdwNavigationPage* arg0) {
//   ((void (*)(AdwNavigationPage*))(fnptr))(arg0);
// };
// void _gotk4_adw1_NavigationPage_virtual_showing(void* fnptr, AdwNavigationPage* arg0) {
//   ((void (*)(AdwNavigationPage*))(fnptr))(arg0);
// };
// void _gotk4_adw1_NavigationPage_virtual_shown(void* fnptr, AdwNavigationPage* arg0) {
//   ((void (*)(AdwNavigationPage*))(fnptr))(arg0);
// };
import "C"

// GType values.
var (
	GTypeNavigationPage = coreglib.Type(C.adw_navigation_page_get_type())
	GTypeNavigationView = coreglib.Type(C.adw_navigation_view_get_type())
)

func init() {
	coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
		coreglib.TypeMarshaler{T: GTypeNavigationPage, F: marshalNavigationPage},
		coreglib.TypeMarshaler{T: GTypeNavigationView, F: marshalNavigationView},
	})
}

// NavigationPageOverrides contains methods that are overridable.
type NavigationPageOverrides struct {
	// Hidden: called when the navigation view transition has been completed and
	// the page is fully hidden.
	Hidden func()
	// Hiding: called when the page starts hiding at the beginning of the
	// navigation view transition.
	Hiding func()
	// Showing: called when the page shows at the beginning of the navigation
	// view transition.
	Showing func()
	// Shown: called when the navigation view transition has been completed and
	// the page is fully shown.
	Shown func()
}

func defaultNavigationPageOverrides(v *NavigationPage) NavigationPageOverrides {
	return NavigationPageOverrides{
		Hidden:  v.hidden,
		Hiding:  v.hiding,
		Showing: v.showing,
		Shown:   v.shown,
	}
}

// NavigationPage: page within navigationview or navigationsplitview.
//
// Each page has a child widget, a title and optionally a tag.
//
// The navigationpage::showing, navigationpage::shown, navigationpage::hiding
// and navigationpage::hidden signals can be used to track the page's visibility
// within its AdwNavigationView.
//
// # Header Bar Integration
//
// When placed inside AdwNavigationPage, headerbar will display the page title
// instead of window title.
//
// When used together with navigationview, it will also display a
// back button that can be used to go back to the previous page.
// Set headerbar:show-back-button to FALSE to disable that behavior if it's
// unwanted.
//
// # CSS Nodes
//
// AdwNavigationPage has a single CSS node with name navigation-view-page.
//
// # Accessibility
//
// AdwNavigationPage uses the GTK_ACCESSIBLE_ROLE_GROUP role.
type NavigationPage struct {
	_ [0]func() // equal guard
	gtk.Widget
}

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

func init() {
	coreglib.RegisterClassInfo[*NavigationPage, *NavigationPageClass, NavigationPageOverrides](
		GTypeNavigationPage,
		initNavigationPageClass,
		wrapNavigationPage,
		defaultNavigationPageOverrides,
	)
}

func initNavigationPageClass(gclass unsafe.Pointer, overrides NavigationPageOverrides, classInitFunc func(*NavigationPageClass)) {
	pclass := (*C.AdwNavigationPageClass)(unsafe.Pointer(C.g_type_check_class_cast((*C.GTypeClass)(gclass), C.GType(GTypeNavigationPage))))

	if overrides.Hidden != nil {
		pclass.hidden = (*[0]byte)(C._gotk4_adw1_NavigationPageClass_hidden)
	}

	if overrides.Hiding != nil {
		pclass.hiding = (*[0]byte)(C._gotk4_adw1_NavigationPageClass_hiding)
	}

	if overrides.Showing != nil {
		pclass.showing = (*[0]byte)(C._gotk4_adw1_NavigationPageClass_showing)
	}

	if overrides.Shown != nil {
		pclass.shown = (*[0]byte)(C._gotk4_adw1_NavigationPageClass_shown)
	}

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

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

// ConnectHidden is emitted when the navigation view transition has been
// completed and the page is fully hidden.
//
// It will always be preceded by navigationpage::hiding or
// navigationpage::showing.
func (self *NavigationPage) ConnectHidden(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "hidden", false, unsafe.Pointer(C._gotk4_adw1_NavigationPage_ConnectHidden), f)
}

// ConnectHiding is emitted when the page starts hiding at the beginning of the
// navigation view transition.
//
// It will always be followed by navigationpage::hidden or
// navigationpage::shown.
func (self *NavigationPage) ConnectHiding(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "hiding", false, unsafe.Pointer(C._gotk4_adw1_NavigationPage_ConnectHiding), f)
}

// ConnectShowing is emitted when the page shows at the beginning of the
// navigation view transition.
//
// It will always be followed by navigationpage::shown or
// navigationpage::hidden.
func (self *NavigationPage) ConnectShowing(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "showing", false, unsafe.Pointer(C._gotk4_adw1_NavigationPage_ConnectShowing), f)
}

// ConnectShown is emitted when the navigation view transition has been
// completed and the page is fully shown.
//
// It will always be preceded by navigationpage::showing or
// navigationpage::hiding.
func (self *NavigationPage) ConnectShown(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "shown", false, unsafe.Pointer(C._gotk4_adw1_NavigationPage_ConnectShown), f)
}

// NewNavigationPage creates a new AdwNavigationPage.
//
// The function takes the following parameters:
//
//   - child widget.
//   - title: page title.
//
// The function returns the following values:
//
//   - navigationPage: new created AdwNavigationPage.
func NewNavigationPage(child gtk.Widgetter, title string) *NavigationPage {
	var _arg1 *C.GtkWidget         // out
	var _arg2 *C.char              // out
	var _cret *C.AdwNavigationPage // in

	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
	_arg2 = (*C.char)(unsafe.Pointer(C.CString(title)))
	defer C.free(unsafe.Pointer(_arg2))

	_cret = C.adw_navigation_page_new(_arg1, _arg2)
	runtime.KeepAlive(child)
	runtime.KeepAlive(title)

	var _navigationPage *NavigationPage // out

	_navigationPage = wrapNavigationPage(coreglib.Take(unsafe.Pointer(_cret)))

	return _navigationPage
}

// NewNavigationPageWithTag creates a new AdwNavigationPage with provided tag.
//
// The function takes the following parameters:
//
//   - child widget.
//   - title: page title.
//   - tag: page tag.
//
// The function returns the following values:
//
//   - navigationPage: new created AdwNavigationPage.
func NewNavigationPageWithTag(child gtk.Widgetter, title, tag string) *NavigationPage {
	var _arg1 *C.GtkWidget         // out
	var _arg2 *C.char              // out
	var _arg3 *C.char              // out
	var _cret *C.AdwNavigationPage // in

	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
	_arg2 = (*C.char)(unsafe.Pointer(C.CString(title)))
	defer C.free(unsafe.Pointer(_arg2))
	_arg3 = (*C.char)(unsafe.Pointer(C.CString(tag)))
	defer C.free(unsafe.Pointer(_arg3))

	_cret = C.adw_navigation_page_new_with_tag(_arg1, _arg2, _arg3)
	runtime.KeepAlive(child)
	runtime.KeepAlive(title)
	runtime.KeepAlive(tag)

	var _navigationPage *NavigationPage // out

	_navigationPage = wrapNavigationPage(coreglib.Take(unsafe.Pointer(_cret)))

	return _navigationPage
}

// CanPop gets whether self can be popped from navigation stack.
//
// The function returns the following values:
//
//   - ok: whether the page can be popped from navigation stack.
func (self *NavigationPage) CanPop() bool {
	var _arg0 *C.AdwNavigationPage // out
	var _cret C.gboolean           // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Child gets the child widget of self.
//
// The function returns the following values:
//
//   - widget (optional): child widget of self.
func (self *NavigationPage) Child() gtk.Widgetter {
	var _arg0 *C.AdwNavigationPage // out
	var _cret *C.GtkWidget         // in

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

	_cret = C.adw_navigation_page_get_child(_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
}

// Tag gets the tag of self.
//
// The function returns the following values:
//
//   - utf8 (optional): page tag.
func (self *NavigationPage) Tag() string {
	var _arg0 *C.AdwNavigationPage // out
	var _cret *C.char              // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// Title gets the title of self.
//
// The function returns the following values:
//
//   - utf8: title of self.
func (self *NavigationPage) Title() string {
	var _arg0 *C.AdwNavigationPage // out
	var _cret *C.char              // in

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

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

	var _utf8 string // out

	_utf8 = C.GoString((*C.gchar)(unsafe.Pointer(_cret)))

	return _utf8
}

// SetCanPop sets whether self can be popped from navigation stack.
//
// Set it to FALSE to disable shortcuts and gestures, as well as remove the back
// button from headerbar.
//
// Manually calling navigationview.Pop or using the navigation.pop action will
// still work.
//
// See headerbar:show-back-button for removing only the back button, but not
// shortcuts.
//
// The function takes the following parameters:
//
//   - canPop: whether the page can be popped from navigation stack.
func (self *NavigationPage) SetCanPop(canPop bool) {
	var _arg0 *C.AdwNavigationPage // out
	var _arg1 C.gboolean           // out

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

	C.adw_navigation_page_set_can_pop(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(canPop)
}

// SetChild sets the child widget of self.
//
// The function takes the following parameters:
//
//   - child (optional) widget.
func (self *NavigationPage) SetChild(child gtk.Widgetter) {
	var _arg0 *C.AdwNavigationPage // out
	var _arg1 *C.GtkWidget         // out

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

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

// SetTag sets the tag for self.
//
// The tag can be used to retrieve the page with navigationview.FindPage,
// as well as with navigationview.PushByTag, navigationview.PopToTag or
// navigationview.ReplaceWithTags.
//
// Tags must be unique within each navigationview.
//
// The tag also must be set to use the navigation.push action.
//
// The function takes the following parameters:
//
//   - tag (optional): page tag.
func (self *NavigationPage) SetTag(tag string) {
	var _arg0 *C.AdwNavigationPage // out
	var _arg1 *C.char              // out

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

	C.adw_navigation_page_set_tag(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tag)
}

// SetTitle sets the title of self.
//
// It's displayed in headerbar instead of the window title, and used as the
// tooltip on the next page's back button, as well as by screen reader.
//
// The function takes the following parameters:
//
//   - title: title.
func (self *NavigationPage) SetTitle(title string) {
	var _arg0 *C.AdwNavigationPage // out
	var _arg1 *C.char              // out

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

	C.adw_navigation_page_set_title(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(title)
}

// Hidden: called when the navigation view transition has been completed and the
// page is fully hidden.
func (self *NavigationPage) hidden() {
	gclass := (*C.AdwNavigationPageClass)(coreglib.PeekParentClass(self))
	fnarg := gclass.hidden

	var _arg0 *C.AdwNavigationPage // out

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

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

// Hiding: called when the page starts hiding at the beginning of the navigation
// view transition.
func (self *NavigationPage) hiding() {
	gclass := (*C.AdwNavigationPageClass)(coreglib.PeekParentClass(self))
	fnarg := gclass.hiding

	var _arg0 *C.AdwNavigationPage // out

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

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

// Showing: called when the page shows at the beginning of the navigation view
// transition.
func (self *NavigationPage) showing() {
	gclass := (*C.AdwNavigationPageClass)(coreglib.PeekParentClass(self))
	fnarg := gclass.showing

	var _arg0 *C.AdwNavigationPage // out

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

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

// Shown: called when the navigation view transition has been completed and the
// page is fully shown.
func (self *NavigationPage) shown() {
	gclass := (*C.AdwNavigationPageClass)(coreglib.PeekParentClass(self))
	fnarg := gclass.shown

	var _arg0 *C.AdwNavigationPage // out

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

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

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

func defaultNavigationViewOverrides(v *NavigationView) NavigationViewOverrides {
	return NavigationViewOverrides{}
}

// NavigationView: page-based navigation container.
//
// <picture> <source srcset="navigation-view-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="navigation-view.png"
// alt="navigation-view"> </picture>
//
// AdwNavigationView presents one child at a time, similar to gtk.Stack.
//
// AdwNavigationView can only contain navigationpage children.
//
// It maintains a navigation stack that can be controlled with
// navigationview.Push and navigationview.Pop. The whole navigation stack can
// also be replaced using navigationview.Replace.
//
// AdwNavigationView allows to manage pages statically or dynamically.
//
// Static pages can be added using the navigationview.Add method. The
// AdwNavigationView will keep a reference to these pages, but they aren't
// accessible to the user until navigationview.Push is called (except for the
// first page, which is pushed automatically). Use the navigationview.Remove
// method to remove them. This is useful for applications that have a small
// number of unique pages and just need navigation between them.
//
// Dynamic pages are automatically destroyed once they are popped off
// the navigation stack. To add a page like this, push it using the
// navigationview.Push method without calling navigationview.Add first.
//
// # Tags
//
// Static pages, as well as any pages in the navigation stack, can be accessed
// by their navigationpage:tag. For example, navigationview.PushByTag can be
// used to push a static page that's not in the navigation stack without having
// to keep a reference to it manually.
//
// # Header Bar Integration
//
// When used inside AdwNavigationView, headerbar will automatically display a
// back button that can be used to go back to the previous page when possible.
// The button also has a context menu, allowing to pop multiple pages at once,
// potentially across multiple navigation views.
//
// Set headerbar:show-back-button to FALSE to disable this behavior in rare
// scenarios where it's unwanted.
//
// AdwHeaderBar will also display the title of the AdwNavigationPage it's placed
// into, so most applications shouldn't need to customize it at all.
//
// # Shortcuts and Gestures
//
// AdwNavigationView supports the following shortcuts for going to the previous
// page:
//
// - <kbd>Escape</kbd> (unless navigationview:pop-on-escape is set to FALSE)
//
// - <kbd>Alt</kbd>+<kbd>←</kbd>
//
// - Back mouse button
//
// Additionally, it supports interactive gestures:
//
// - One-finger swipe towards the right on touchscreens
//
// - Scrolling towards the right on touchpads (usually two-finger swipe)
//
// These gestures have transitions enabled regardless of the
// navigationview:animate-transitions value.
//
// Applications can also enable shortcuts for pushing another page onto the
// navigation stack via connecting to the navigationview::get-next-page signal,
// in that case the following shortcuts are supported:
//
// - <kbd>Alt</kbd>+<kbd>→</kbd>
//
// - Forward mouse button
//
// - Swipe/scrolling towards the left
//
// For right-to-left locales, the gestures and shortcuts are reversed.
//
// navigationpage:can-pop can be used to disable them, along with the header bar
// back buttons.
//
// # Actions
//
// AdwNavigationView defines actions for controlling the navigation stack.
// actions for controlling the navigation stack:
//
// - navigation.push takes a string parameter specifying the tag of the page to
// push, and is equivalent to calling navigationview.PushByTag.
//
// - navigation.pop doesn't take any parameters and pops the current page from
// the navigation stack, equivalent to calling navigationview.Pop.
//
// # AdwNavigationView as GtkBuildable
//
// AdwNavigationView allows to add pages as children, equivalent to using the
// navigationview.Add method.
//
// Example of an AdwNavigationView UI definition:
//
//	<object class="AdwNavigationView">
//	  <child>
//	    <object class="AdwNavigationPage">
//	      <property name="title" translatable="yes">Page 1</property>
//	      <property name="child">
//	        <object class="AdwToolbarView">
//	          <child type="top">
//	            <object class="AdwHeaderBar"/>
//	          </child>
//	          <property name="content">
//	            <object class="GtkButton">
//	              <property name="label" translatable="yes">Open Page 2</property>
//	              <property name="halign">center</property>
//	              <property name="valign">center</property>
//	              <property name="action-name">navigation.push</property>
//	              <property name="action-target">'page-2'</property>
//	              <style>
//	                <class name="pill"/>
//	               </style>
//	            </object>
//	          </property>
//	        </object>
//	      </property>
//	    </object>
//	  </child>
//	  <child>
//	    <object class="AdwNavigationPage">
//	      <property name="title" translatable="yes">Page 2</property>
//	      <property name="tag">page-2</property>
//	      <property name="child">
//	        <object class="AdwToolbarView">
//	          <child type="top">
//	            <object class="AdwHeaderBar"/>
//	          </child>
//	          <property name="content">
//	            <!-- ... -->
//	          </property>
//	        </object>
//	      </property>
//	    </object>
//	  </child>
//	</object>
//
// <picture> <source srcset="navigation-view-example-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="navigation-view-example.png"
// alt="navigation-view-example"> </picture>
//
// # CSS nodes
//
// AdwNavigationView has a single CSS node with the name navigation-view.
//
// # Accessibility
//
// AdwNavigationView uses the GTK_ACCESSIBLE_ROLE_GROUP role.
type NavigationView struct {
	_ [0]func() // equal guard
	gtk.Widget

	*coreglib.Object
	Swipeable
}

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

func init() {
	coreglib.RegisterClassInfo[*NavigationView, *NavigationViewClass, NavigationViewOverrides](
		GTypeNavigationView,
		initNavigationViewClass,
		wrapNavigationView,
		defaultNavigationViewOverrides,
	)
}

func initNavigationViewClass(gclass unsafe.Pointer, overrides NavigationViewOverrides, classInitFunc func(*NavigationViewClass)) {
	if classInitFunc != nil {
		class := (*NavigationViewClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapNavigationView(obj *coreglib.Object) *NavigationView {
	return &NavigationView{
		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,
				},
			},
		},
	}
}

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

// ConnectGetNextPage is emitted when a push shortcut or a gesture is triggered.
//
// To support the push shortcuts and gestures, the application is expected to
// return the page to push in the handler.
//
// This signal can be emitted multiple times for the gestures, for example when
// the gesture is cancelled by the user. As such, the application must not make
// any irreversible changes in the handler, such as removing the page from a
// forward stack.
//
// Instead, it should be done in the navigationview::pushed handler.
func (self *NavigationView) ConnectGetNextPage(f func() (navigationPage *NavigationPage)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "get-next-page", false, unsafe.Pointer(C._gotk4_adw1_NavigationView_ConnectGetNextPage), f)
}

// ConnectPopped is emitted after page has been popped from the navigation
// stack.
//
// See navigationview.Pop.
//
// When using navigationview.PopToPage or navigationview.PopToTag, this signal
// is emitted for each of the popped pages.
func (self *NavigationView) ConnectPopped(f func(page *NavigationPage)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "popped", false, unsafe.Pointer(C._gotk4_adw1_NavigationView_ConnectPopped), f)
}

// ConnectPushed is emitted after a page has been pushed to the navigation
// stack.
//
// See navigationview.Push.
func (self *NavigationView) ConnectPushed(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "pushed", false, unsafe.Pointer(C._gotk4_adw1_NavigationView_ConnectPushed), f)
}

// ConnectReplaced is emitted after the navigation stack has been replaced.
//
// See navigationview.Replace.
func (self *NavigationView) ConnectReplaced(f func()) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "replaced", false, unsafe.Pointer(C._gotk4_adw1_NavigationView_ConnectReplaced), f)
}

// NewNavigationView creates a new AdwNavigationView.
//
// The function returns the following values:
//
//   - navigationView: new created AdwNavigationView.
func NewNavigationView() *NavigationView {
	var _cret *C.GtkWidget // in

	_cret = C.adw_navigation_view_new()

	var _navigationView *NavigationView // out

	_navigationView = wrapNavigationView(coreglib.Take(unsafe.Pointer(_cret)))

	return _navigationView
}

// Add: permanently adds page to self.
//
// Any page that has been added will stay in self even after being popped from
// the navigation stack.
//
// Adding a page while no page is visible will automatically push it to the
// navigation stack.
//
// See navigationview.Remove.
//
// The function takes the following parameters:
//
//   - page to add.
func (self *NavigationView) Add(page *NavigationPage) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.AdwNavigationPage // out

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// FindPage finds a page in self by its tag.
//
// See navigationpage:tag.
//
// The function takes the following parameters:
//
//   - tag: page tag.
//
// The function returns the following values:
//
//   - navigationPage (optional): page with the given tag.
func (self *NavigationView) FindPage(tag string) *NavigationPage {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.char              // out
	var _cret *C.AdwNavigationPage // in

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

	_cret = C.adw_navigation_view_find_page(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tag)

	var _navigationPage *NavigationPage // out

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

	return _navigationPage
}

// AnimateTransitions gets whether self animates page transitions.
//
// The function returns the following values:
//
//   - ok: whether to animate page transitions.
func (self *NavigationView) AnimateTransitions() bool {
	var _arg0 *C.AdwNavigationView // out
	var _cret C.gboolean           // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// NavigationStack returns a gio.ListModel that contains the pages in navigation
// stack.
//
// The pages are sorted from root page to visible page.
//
// This can be used to keep an up-to-date view.
//
// The function returns the following values:
//
//   - listModel: list model for the navigation stack.
func (self *NavigationView) NavigationStack() *gio.ListModel {
	var _arg0 *C.AdwNavigationView // out
	var _cret *C.GListModel        // in

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

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

	var _listModel *gio.ListModel // out

	{
		obj := coreglib.AssumeOwnership(unsafe.Pointer(_cret))
		_listModel = &gio.ListModel{
			Object: obj,
		}
	}

	return _listModel
}

// PopOnEscape gets whether pressing Escape pops the current page on self.
//
// The function returns the following values:
//
//   - ok: whether to pop the current page.
func (self *NavigationView) PopOnEscape() bool {
	var _arg0 *C.AdwNavigationView // out
	var _cret C.gboolean           // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// PreviousPage gets the previous page for page.
//
// If page is in the navigation stack, returns the page popping page will
// reveal.
//
// If page is the root page or is not in the navigation stack, returns NULL.
//
// The function takes the following parameters:
//
//   - page in self.
//
// The function returns the following values:
//
//   - navigationPage (optional) previous page.
func (self *NavigationView) PreviousPage(page *NavigationPage) *NavigationPage {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.AdwNavigationPage // out
	var _cret *C.AdwNavigationPage // in

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

	_cret = C.adw_navigation_view_get_previous_page(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(page)

	var _navigationPage *NavigationPage // out

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

	return _navigationPage
}

// VisiblePage gets the currently visible page in self.
//
// The function returns the following values:
//
//   - navigationPage (optional): currently visible page.
func (self *NavigationView) VisiblePage() *NavigationPage {
	var _arg0 *C.AdwNavigationView // out
	var _cret *C.AdwNavigationPage // in

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

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

	var _navigationPage *NavigationPage // out

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

	return _navigationPage
}

// Pop pops the visible page from the navigation stack.
//
// Does nothing if the navigation stack contains less than two pages.
//
// If navigationview.Add hasn't been called, the page is automatically removed.
//
// navigationview::popped will be emitted for the current visible page.
//
// See navigationview.PopToPage and navigationview.PopToTag.
//
// The function returns the following values:
//
//   - ok: TRUE if a page has been popped.
func (self *NavigationView) Pop() bool {
	var _arg0 *C.AdwNavigationView // out
	var _cret C.gboolean           // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// PopToPage pops pages from the navigation stack until page is visible.
//
// page must be in the navigation stack.
//
// If navigationview.Add hasn't been called for any of the popped pages,
// they are automatically removed.
//
// navigationview::popped will be be emitted for each of the popped pages.
//
// See navigationview.Pop and navigationview.PopToTag.
//
// The function takes the following parameters:
//
//   - page to pop to.
//
// The function returns the following values:
//
//   - ok: TRUE if any pages have been popped.
func (self *NavigationView) PopToPage(page *NavigationPage) bool {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.AdwNavigationPage // out
	var _cret C.gboolean           // in

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

	_cret = C.adw_navigation_view_pop_to_page(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(page)

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// PopToTag pops pages from the navigation stack until page with the tag tag is
// visible.
//
// The page must be in the navigation stack.
//
// If navigationview.Add hasn't been called for any of the popped pages,
// they are automatically removed.
//
// navigationview::popped will be emitted for each of the popped pages.
//
// See navigationview.PopToPage and navigationpage:tag.
//
// The function takes the following parameters:
//
//   - tag: page tag.
//
// The function returns the following values:
//
//   - ok: TRUE if any pages have been popped.
func (self *NavigationView) PopToTag(tag string) bool {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.char              // out
	var _cret C.gboolean           // in

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

	_cret = C.adw_navigation_view_pop_to_tag(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tag)

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Push pushes page onto the navigation stack.
//
// If navigationview.Add hasn't been called, the page is automatically removed
// once it's popped.
//
// navigationview::pushed will be emitted for page.
//
// See navigationview.PushByTag.
//
// The function takes the following parameters:
//
//   - page to push.
func (self *NavigationView) Push(page *NavigationPage) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.AdwNavigationPage // out

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// PushByTag pushes the page with the tag tag onto the navigation stack.
//
// If navigationview.Add hasn't been called, the page is automatically removed
// once it's popped.
//
// navigationview::pushed will be emitted for the page.
//
// See navigationview.Push and navigationpage:tag.
//
// The function takes the following parameters:
//
//   - tag: page tag.
func (self *NavigationView) PushByTag(tag string) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.char              // out

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

	C.adw_navigation_view_push_by_tag(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tag)
}

// Remove removes page from self.
//
// If page is currently in the navigation stack, it will be removed once it's
// popped. Otherwise, it's removed immediately.
//
// See navigationview.Add.
//
// The function takes the following parameters:
//
//   - page to remove.
func (self *NavigationView) Remove(page *NavigationPage) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 *C.AdwNavigationPage // out

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// Replace replaces the current navigation stack with pages.
//
// The last page becomes the visible page.
//
// Replacing the navigation stack has no animation.
//
// If navigationview.Add hasn't been called for any pages that are no longer in
// the navigation stack, they are automatically removed.
//
// n_pages can be 0, in that case no page will be visible after calling this
// method. This can be useful for removing all pages from self.
//
// The navigationview::replaced signal will be emitted.
//
// See navigationview.ReplaceWithTags.
//
// The function takes the following parameters:
//
//   - pages: new navigation stack.
func (self *NavigationView) Replace(pages []*NavigationPage) {
	var _arg0 *C.AdwNavigationView  // out
	var _arg1 **C.AdwNavigationPage // out
	var _arg2 C.int

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg2 = (C.int)(len(pages))
	_arg1 = (**C.AdwNavigationPage)(C.calloc(C.size_t(len(pages)), C.size_t(unsafe.Sizeof(uint(0)))))
	defer C.free(unsafe.Pointer(_arg1))
	{
		out := unsafe.Slice((**C.AdwNavigationPage)(_arg1), len(pages))
		for i := range pages {
			out[i] = (*C.AdwNavigationPage)(unsafe.Pointer(coreglib.InternObject(pages[i]).Native()))
		}
	}

	C.adw_navigation_view_replace(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(pages)
}

// ReplaceWithTags replaces the current navigation stack with pages with the
// tags tags.
//
// The last page becomes the visible page.
//
// Replacing the navigation stack has no animation.
//
// If navigationview.Add hasn't been called for any pages that are no longer in
// the navigation stack, they are automatically removed.
//
// n_tags can be 0, in that case no page will be visible after calling this
// method. This can be useful for removing all pages from self.
//
// The navigationview::replaced signal will be emitted.
//
// See navigationview.Replace and navigationpage:tag.
//
// The function takes the following parameters:
//
//   - tags of the pages in the navigation stack.
func (self *NavigationView) ReplaceWithTags(tags []string) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 **C.char             // out
	var _arg2 C.int

	_arg0 = (*C.AdwNavigationView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg2 = (C.int)(len(tags))
	_arg1 = (**C.char)(C.calloc(C.size_t(len(tags)), C.size_t(unsafe.Sizeof(uint(0)))))
	defer C.free(unsafe.Pointer(_arg1))
	{
		out := unsafe.Slice((**C.char)(_arg1), len(tags))
		for i := range tags {
			out[i] = (*C.char)(unsafe.Pointer(C.CString(tags[i])))
			defer C.free(unsafe.Pointer(out[i]))
		}
	}

	C.adw_navigation_view_replace_with_tags(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tags)
}

// SetAnimateTransitions sets whether self should animate page transitions.
//
// Gesture-based transitions are always animated.
//
// The function takes the following parameters:
//
//   - animateTransitions: whether to animate page transitions.
func (self *NavigationView) SetAnimateTransitions(animateTransitions bool) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 C.gboolean           // out

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

	C.adw_navigation_view_set_animate_transitions(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(animateTransitions)
}

// SetPopOnEscape sets whether pressing Escape pops the current page on self.
//
// Applications using AdwNavigationView to implement a browser may want to
// disable it.
//
// The function takes the following parameters:
//
//   - popOnEscape: whether to pop the current page when pressing Escape.
func (self *NavigationView) SetPopOnEscape(popOnEscape bool) {
	var _arg0 *C.AdwNavigationView // out
	var _arg1 C.gboolean           // out

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

	C.adw_navigation_view_set_pop_on_escape(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(popOnEscape)
}
