// 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 (
	GTypePreferencesWindow = coreglib.Type(C.adw_preferences_window_get_type())
)

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

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

func defaultPreferencesWindowOverrides(v *PreferencesWindow) PreferencesWindowOverrides {
	return PreferencesWindowOverrides{}
}

// PreferencesWindow: window to present an application's preferences.
//
// <picture> <source srcset="preferences-window-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="preferences-window.png"
// alt="preferences-window"> </picture>
//
// The AdwPreferencesWindow widget presents an application's preferences
// gathered into pages and groups. The preferences are searchable by the user.
//
// # CSS nodes
//
// AdwPreferencesWindow has a main CSS node with the name window and the style
// class .preferences.
//
// Deprecated: Use preferencesdialog.
type PreferencesWindow struct {
	_ [0]func() // equal guard
	Window
}

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

func init() {
	coreglib.RegisterClassInfo[*PreferencesWindow, *PreferencesWindowClass, PreferencesWindowOverrides](
		GTypePreferencesWindow,
		initPreferencesWindowClass,
		wrapPreferencesWindow,
		defaultPreferencesWindowOverrides,
	)
}

func initPreferencesWindowClass(gclass unsafe.Pointer, overrides PreferencesWindowOverrides, classInitFunc func(*PreferencesWindowClass)) {
	if classInitFunc != nil {
		class := (*PreferencesWindowClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapPreferencesWindow(obj *coreglib.Object) *PreferencesWindow {
	return &PreferencesWindow{
		Window: Window{
			Window: gtk.Window{
				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,
				Root: gtk.Root{
					NativeSurface: gtk.NativeSurface{
						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,
							},
						},
					},
				},
				ShortcutManager: gtk.ShortcutManager{
					Object: obj,
				},
			},
		},
	}
}

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

// NewPreferencesWindow creates a new AdwPreferencesWindow.
//
// Deprecated: Use preferencesdialog.
//
// The function returns the following values:
//
//   - preferencesWindow: newly created AdwPreferencesWindow.
func NewPreferencesWindow() *PreferencesWindow {
	var _cret *C.GtkWidget // in

	_cret = C.adw_preferences_window_new()

	var _preferencesWindow *PreferencesWindow // out

	_preferencesWindow = wrapPreferencesWindow(coreglib.Take(unsafe.Pointer(_cret)))

	return _preferencesWindow
}

// Add adds a preferences page to self.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - page to add.
func (self *PreferencesWindow) Add(page *PreferencesPage) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.AdwPreferencesPage   // out

	_arg0 = (*C.AdwPreferencesWindow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwPreferencesPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// AddToast displays toast.
//
// See toastoverlay.AddToast.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - toast: toast.
func (self *PreferencesWindow) AddToast(toast *Toast) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.AdwToast             // out

	_arg0 = (*C.AdwPreferencesWindow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwToast)(unsafe.Pointer(coreglib.InternObject(toast).Native()))
	C.g_object_ref(C.gpointer(coreglib.InternObject(toast).Native()))

	C.adw_preferences_window_add_toast(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(toast)
}

// CloseSubpage closes the current subpage.
//
// If there is no presented subpage, this does nothing.
//
// Deprecated: Use preferenceswindow.PopSubpage instead.
func (self *PreferencesWindow) CloseSubpage() {
	var _arg0 *C.AdwPreferencesWindow // out

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

	C.adw_preferences_window_close_subpage(_arg0)
	runtime.KeepAlive(self)
}

// CanNavigateBack gets whether gestures and shortcuts for closing subpages are
// enabled.
//
// Deprecated: Use navigationpage.GetCanPop instead.
//
// The function returns the following values:
//
//   - ok: whether gestures and shortcuts are enabled.
func (self *PreferencesWindow) CanNavigateBack() bool {
	var _arg0 *C.AdwPreferencesWindow // out
	var _cret C.gboolean              // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SearchEnabled gets whether search is enabled for self.
//
// Deprecated: Use preferencesdialog.
//
// The function returns the following values:
//
//   - ok: whether search is enabled for self.
func (self *PreferencesWindow) SearchEnabled() bool {
	var _arg0 *C.AdwPreferencesWindow // out
	var _cret C.gboolean              // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// VisiblePage gets the currently visible page of self.
//
// Deprecated: Use preferencesdialog.
//
// The function returns the following values:
//
//   - preferencesPage (optional): visible page.
func (self *PreferencesWindow) VisiblePage() *PreferencesPage {
	var _arg0 *C.AdwPreferencesWindow // out
	var _cret *C.AdwPreferencesPage   // in

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

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

	var _preferencesPage *PreferencesPage // out

	if _cret != nil {
		_preferencesPage = wrapPreferencesPage(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _preferencesPage
}

// VisiblePageName gets the name of currently visible page of self.
//
// Deprecated: Use preferencesdialog.
//
// The function returns the following values:
//
//   - utf8 (optional): name of the visible page.
func (self *PreferencesWindow) VisiblePageName() string {
	var _arg0 *C.AdwPreferencesWindow // out
	var _cret *C.char                 // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// PopSubpage: pop the visible page from the subpage stack of self.
//
// Deprecated: Use preferencesdialog.
//
// The function returns the following values:
//
//   - ok: TRUE if a page has been popped.
func (self *PreferencesWindow) PopSubpage() bool {
	var _arg0 *C.AdwPreferencesWindow // out
	var _cret C.gboolean              // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// PresentSubpage sets subpage as the window's subpage and opens it.
//
// The transition can be cancelled by the user, in which case visible child will
// change back to the previously visible child.
//
// Deprecated: Use preferenceswindow.PushSubpage instead.
//
// The function takes the following parameters:
//
//   - subpage: subpage.
func (self *PreferencesWindow) PresentSubpage(subpage gtk.Widgetter) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.GtkWidget            // out

	_arg0 = (*C.AdwPreferencesWindow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(subpage).Native()))

	C.adw_preferences_window_present_subpage(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(subpage)
}

// PushSubpage pushes page onto the subpage stack of self.
//
// The page will be automatically removed when popped.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - page: subpage.
func (self *PreferencesWindow) PushSubpage(page *NavigationPage) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.AdwNavigationPage    // out

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

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

// Remove removes a page from self.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - page to remove.
func (self *PreferencesWindow) Remove(page *PreferencesPage) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.AdwPreferencesPage   // out

	_arg0 = (*C.AdwPreferencesWindow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwPreferencesPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// SetCanNavigateBack sets whether gestures and shortcuts for closing subpages
// are enabled.
//
// The supported gestures are:
//
// - One-finger swipe on touchscreens
//
// - Horizontal scrolling on touchpads (usually two-finger swipe)
//
// - Back mouse button
//
// The keyboard back key is also supported, as well as the
// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
//
// For right-to-left locales, gestures and shortcuts are reversed.
//
// Has no effect for subpages added with preferenceswindow.PushSubpage.
//
// Deprecated: Use navigationpage.SetCanPop instead.
//
// The function takes the following parameters:
//
//   - canNavigateBack: new value.
func (self *PreferencesWindow) SetCanNavigateBack(canNavigateBack bool) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 C.gboolean              // out

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

	C.adw_preferences_window_set_can_navigate_back(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(canNavigateBack)
}

// SetSearchEnabled sets whether search is enabled for self.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - searchEnabled: whether search is enabled.
func (self *PreferencesWindow) SetSearchEnabled(searchEnabled bool) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 C.gboolean              // out

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

	C.adw_preferences_window_set_search_enabled(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(searchEnabled)
}

// SetVisiblePage makes page the visible page of self.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - page of self.
func (self *PreferencesWindow) SetVisiblePage(page *PreferencesPage) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.AdwPreferencesPage   // out

	_arg0 = (*C.AdwPreferencesWindow)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwPreferencesPage)(unsafe.Pointer(coreglib.InternObject(page).Native()))

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

// SetVisiblePageName makes the page with the given name visible.
//
// See preferenceswindow:visible-page.
//
// Deprecated: Use preferencesdialog.
//
// The function takes the following parameters:
//
//   - name of the page to make visible.
func (self *PreferencesWindow) SetVisiblePageName(name string) {
	var _arg0 *C.AdwPreferencesWindow // out
	var _arg1 *C.char                 // out

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

	C.adw_preferences_window_set_visible_page_name(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(name)
}

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

// preferencesWindowClass is the struct that's finalized.
type preferencesWindowClass struct {
	native *C.AdwPreferencesWindowClass
}

// ParentClass: parent class.
func (p *PreferencesWindowClass) ParentClass() *WindowClass {
	valptr := &p.native.parent_class
	var _v *WindowClass // out
	_v = (*WindowClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
	return _v
}
