// Code generated by girgen. DO NOT EDIT.

package adw

import (
	"fmt"
	"runtime"
	"unsafe"

	"github.com/diamondburned/gotk4/pkg/core/gextras"
	coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
	"github.com/diamondburned/gotk4/pkg/gdk/v4"
)

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

// GType values.
var (
	GTypeColorScheme  = coreglib.Type(C.adw_color_scheme_get_type())
	GTypeStyleManager = coreglib.Type(C.adw_style_manager_get_type())
)

func init() {
	coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
		coreglib.TypeMarshaler{T: GTypeColorScheme, F: marshalColorScheme},
		coreglib.TypeMarshaler{T: GTypeStyleManager, F: marshalStyleManager},
	})
}

// ColorScheme: application color schemes for stylemanager:color-scheme.
type ColorScheme C.gint

const (
	// ColorSchemeDefault: inherit the parent color-scheme. When set on the
	// AdwStyleManager returned by stylemanager.GetDefault(), it's equivalent to
	// ADW_COLOR_SCHEME_PREFER_LIGHT.
	ColorSchemeDefault ColorScheme = iota
	// ColorSchemeForceLight always use light appearance.
	ColorSchemeForceLight
	// ColorSchemePreferLight: use light appearance unless the system prefers
	// dark colors.
	ColorSchemePreferLight
	// ColorSchemePreferDark: use dark appearance unless the system prefers
	// prefers light colors.
	ColorSchemePreferDark
	// ColorSchemeForceDark always use dark appearance.
	ColorSchemeForceDark
)

func marshalColorScheme(p uintptr) (interface{}, error) {
	return ColorScheme(coreglib.ValueFromNative(unsafe.Pointer(p)).Enum()), nil
}

// String returns the name in string for ColorScheme.
func (c ColorScheme) String() string {
	switch c {
	case ColorSchemeDefault:
		return "Default"
	case ColorSchemeForceLight:
		return "ForceLight"
	case ColorSchemePreferLight:
		return "PreferLight"
	case ColorSchemePreferDark:
		return "PreferDark"
	case ColorSchemeForceDark:
		return "ForceDark"
	default:
		return fmt.Sprintf("ColorScheme(%d)", c)
	}
}

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

func defaultStyleManagerOverrides(v *StyleManager) StyleManagerOverrides {
	return StyleManagerOverrides{}
}

// StyleManager class for managing application-wide styling.
//
// AdwStyleManager provides a way to query and influence the application styles,
// such as whether to use dark style, the system accent color or high contrast
// appearance.
//
// It allows to set the color scheme via the stylemanager:color-scheme property,
// and to query the current appearance, as well as whether a system-wide color
// scheme and accent color preferences exists.
type StyleManager struct {
	_ [0]func() // equal guard
	*coreglib.Object
}

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

func init() {
	coreglib.RegisterClassInfo[*StyleManager, *StyleManagerClass, StyleManagerOverrides](
		GTypeStyleManager,
		initStyleManagerClass,
		wrapStyleManager,
		defaultStyleManagerOverrides,
	)
}

func initStyleManagerClass(gclass unsafe.Pointer, overrides StyleManagerOverrides, classInitFunc func(*StyleManagerClass)) {
	if classInitFunc != nil {
		class := (*StyleManagerClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapStyleManager(obj *coreglib.Object) *StyleManager {
	return &StyleManager{
		Object: obj,
	}
}

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

// AccentColor gets the current system accent color.
//
// See also stylemanager:accent-color-rgba.
//
// The function returns the following values:
//
//   - accentColor: current system accent color.
func (self *StyleManager) AccentColor() AccentColor {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.AdwAccentColor   // in

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

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

	var _accentColor AccentColor // out

	_accentColor = AccentColor(_cret)

	return _accentColor
}

// AccentColorRGBA gets the current system accent color as a GdkRGBA.
//
// Equivalent to calling accentcolor.ToRGBA() on the value of
// stylemanager:accent-color.
//
// This is a background color. The matching foreground color is white.
//
// The function returns the following values:
//
//   - rgbA: current system accent color.
func (self *StyleManager) AccentColorRGBA() *gdk.RGBA {
	var _arg0 *C.AdwStyleManager // out
	var _cret *C.GdkRGBA         // in

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

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

	var _rgbA *gdk.RGBA // out

	_rgbA = (*gdk.RGBA)(gextras.NewStructNative(unsafe.Pointer(_cret)))
	runtime.SetFinalizer(
		gextras.StructIntern(unsafe.Pointer(_rgbA)),
		func(intern *struct{ C unsafe.Pointer }) {
			C.gdk_rgba_free((*C.GdkRGBA)(intern.C))
		},
	)

	return _rgbA
}

// ColorScheme gets the requested application color scheme.
//
// The function returns the following values:
//
//   - colorScheme: color scheme.
func (self *StyleManager) ColorScheme() ColorScheme {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.AdwColorScheme   // in

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

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

	var _colorScheme ColorScheme // out

	_colorScheme = ColorScheme(_cret)

	return _colorScheme
}

// Dark gets whether the application is using dark appearance.
//
// This can be used to query the current appearance, as requested via
// stylemanager:color-scheme.
//
// The function returns the following values:
//
//   - ok: whether the application is using dark appearance.
func (self *StyleManager) Dark() bool {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.gboolean         // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Display gets the display the style manager is associated with.
//
// The display will be NULL for the style manager returned by
// stylemanager.GetDefault().
//
// The function returns the following values:
//
//   - display (optional): display.
func (self *StyleManager) Display() *gdk.Display {
	var _arg0 *C.AdwStyleManager // out
	var _cret *C.GdkDisplay      // in

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

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

	var _display *gdk.Display // out

	if _cret != nil {
		{
			obj := coreglib.Take(unsafe.Pointer(_cret))
			_display = &gdk.Display{
				Object: obj,
			}
		}
	}

	return _display
}

// DocumentFontName gets the system document font.
//
// The font is in the same format as gtk.Settings:gtk-font-name, e.g. "Adwaita
// Sans 11".
//
// Use pango.FontDescription().FromString to parse it.
//
// The function returns the following values:
//
//   - utf8: system document font.
func (self *StyleManager) DocumentFontName() string {
	var _arg0 *C.AdwStyleManager // out
	var _cret *C.char            // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// HighContrast gets whether the application is using high contrast appearance.
//
// This cannot be overridden by applications.
//
// The function returns the following values:
//
//   - ok: whether the application is using high contrast appearance.
func (self *StyleManager) HighContrast() bool {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.gboolean         // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// MonospaceFontName gets the system monospace font.
//
// The font is in the same format as gtk.Settings:gtk-font-name, e.g. "Adwaita
// Mono 11".
//
// Use pango.FontDescription().FromString to parse it.
//
// The function returns the following values:
//
//   - utf8: system monospace font.
func (self *StyleManager) MonospaceFontName() string {
	var _arg0 *C.AdwStyleManager // out
	var _cret *C.char            // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// SystemSupportsAccentColors gets whether the system supports accent colors.
//
// This can be used to check if the current environment provides an accent color
// preference. For example, applications might want to show a preference for
// choosing accent color if it's set to FALSE.
//
// See stylemanager:accent-color.
//
// The function returns the following values:
//
//   - ok: whether the system supports accent colors.
func (self *StyleManager) SystemSupportsAccentColors() bool {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.gboolean         // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SystemSupportsColorSchemes gets whether the system supports color schemes.
//
// This can be used to check if the current environment provides a color
// scheme preference. For example, applications might want to show a separate
// appearance switcher if it's set to FALSE.
//
// The function returns the following values:
//
//   - ok: whether the system supports color schemes.
func (self *StyleManager) SystemSupportsColorSchemes() bool {
	var _arg0 *C.AdwStyleManager // out
	var _cret C.gboolean         // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SetColorScheme sets the requested application color scheme.
//
// The effective appearance will be decided based on the application color
// scheme and the system preferred color scheme. The stylemanager:dark property
// can be used to query the current effective appearance.
//
// The ADW_COLOR_SCHEME_PREFER_LIGHT color scheme results in the application
// using light appearance unless the system prefers dark colors. This is the
// default value.
//
// The ADW_COLOR_SCHEME_PREFER_DARK color scheme results in the application
// using dark appearance, but can still switch to the light appearance if the
// system can prefers it, for example, when the high contrast preference is
// enabled.
//
// The ADW_COLOR_SCHEME_FORCE_LIGHT and ADW_COLOR_SCHEME_FORCE_DARK values
// ignore the system preference entirely. They are useful if the application
// wants to match its UI to its content or to provide a separate color scheme
// switcher.
//
// If a per-gdk.Display style manager has its color scheme set to
// ADW_COLOR_SCHEME_DEFAULT, it will inherit the color scheme from the default
// style manager.
//
// For the default style manager, ADW_COLOR_SCHEME_DEFAULT is equivalent to
// ADW_COLOR_SCHEME_PREFER_LIGHT.
//
// The stylemanager:system-supports-color-schemes property can be used to check
// if the current environment provides a color scheme preference.
//
// The function takes the following parameters:
//
//   - colorScheme: color scheme.
func (self *StyleManager) SetColorScheme(colorScheme ColorScheme) {
	var _arg0 *C.AdwStyleManager // out
	var _arg1 C.AdwColorScheme   // out

	_arg0 = (*C.AdwStyleManager)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.AdwColorScheme(colorScheme)

	C.adw_style_manager_set_color_scheme(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(colorScheme)
}

// StyleManagerGetDefault gets the default AdwStyleManager instance.
//
// It manages all gdk.Display instances unless the style manager for that
// display has an override.
//
// See stylemanager.GetForDisplay().
//
// The function returns the following values:
//
//   - styleManager: default style manager.
func StyleManagerGetDefault() *StyleManager {
	var _cret *C.AdwStyleManager // in

	_cret = C.adw_style_manager_get_default()

	var _styleManager *StyleManager // out

	_styleManager = wrapStyleManager(coreglib.Take(unsafe.Pointer(_cret)))

	return _styleManager
}

// StyleManagerGetForDisplay gets the AdwStyleManager instance managing display.
//
// It can be used to override styles for that specific display instead of the
// whole application.
//
// Most applications should use stylemanager.GetDefault() instead.
//
// The function takes the following parameters:
//
//   - display: GdkDisplay.
//
// The function returns the following values:
//
//   - styleManager: style manager for display.
func StyleManagerGetForDisplay(display *gdk.Display) *StyleManager {
	var _arg1 *C.GdkDisplay      // out
	var _cret *C.AdwStyleManager // in

	_arg1 = (*C.GdkDisplay)(unsafe.Pointer(coreglib.InternObject(display).Native()))

	_cret = C.adw_style_manager_get_for_display(_arg1)
	runtime.KeepAlive(display)

	var _styleManager *StyleManager // out

	_styleManager = wrapStyleManager(coreglib.Take(unsafe.Pointer(_cret)))

	return _styleManager
}

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

// styleManagerClass is the struct that's finalized.
type styleManagerClass struct {
	native *C.AdwStyleManagerClass
}
