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

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

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

func defaultViewSwitcherBarOverrides(v *ViewSwitcherBar) ViewSwitcherBarOverrides {
	return ViewSwitcherBarOverrides{}
}

// ViewSwitcherBar: view switcher action bar.
//
// <picture> <source srcset="view-switcher-bar-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="view-switcher-bar.png"
// alt="view-switcher-bar"> </picture>
//
// An action bar letting you switch between multiple views contained in a
// viewstack, via an viewswitcher. It is designed to be put at the bottom of
// a window and to be revealed only on really narrow windows, e.g. on mobile
// phones. It can't be revealed if there are less than two pages.
//
// AdwViewSwitcherBar is intended to be used together with AdwViewSwitcher in a
// header bar, and a breakpoint showing the view switcher bar on narrow sizes,
// while removing the view switcher from the header bar, as follows:
//
//	<object class="AdwWindow">
//	  <property name="width-request">360</property>
//	  <property name="height-request">200</property>
//	  <child>
//	    <object class="AdwBreakpoint">
//	      <condition>max-width: 550sp</condition>
//	      <setter object="switcher_bar" property="reveal">True</setter>
//	      <setter object="header_bar" property="title-widget"/>
//	    </object>
//	  </child>
//	  <property name="content">
//	    <object class="AdwToolbarView">
//	      <child type="top">
//	        <object class="AdwHeaderBar" id="header_bar">
//	          <property name="title-widget">
//	            <object class="AdwViewSwitcher">
//	              <property name="stack">stack</property>
//	              <property name="policy">wide</property>
//	            </object>
//	          </property>
//	        </object>
//	      </child>
//	      <property name="content">
//	        <object class="AdwViewStack" id="stack"/>
//	      </property>
//	      <child type="bottom">
//	        <object class="AdwViewSwitcherBar" id="switcher_bar">
//	          <property name="stack">stack</property>
//	        </object>
//	      </child>
//	    </object>
//	  </property>
//	</object>
//
// It's recommended to set viewswitcher:policy to ADW_VIEW_SWITCHER_POLICY_WIDE
// in this case.
//
// You may have to adjust the breakpoint condition for your specific pages.
//
// # CSS nodes
//
// AdwViewSwitcherBar has a single CSS node with name viewswitcherbar.
type ViewSwitcherBar struct {
	_ [0]func() // equal guard
	gtk.Widget
}

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

func init() {
	coreglib.RegisterClassInfo[*ViewSwitcherBar, *ViewSwitcherBarClass, ViewSwitcherBarOverrides](
		GTypeViewSwitcherBar,
		initViewSwitcherBarClass,
		wrapViewSwitcherBar,
		defaultViewSwitcherBarOverrides,
	)
}

func initViewSwitcherBarClass(gclass unsafe.Pointer, overrides ViewSwitcherBarOverrides, classInitFunc func(*ViewSwitcherBarClass)) {
	if classInitFunc != nil {
		class := (*ViewSwitcherBarClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

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

// NewViewSwitcherBar creates a new AdwViewSwitcherBar.
//
// The function returns the following values:
//
//   - viewSwitcherBar: newly created AdwViewSwitcherBar.
func NewViewSwitcherBar() *ViewSwitcherBar {
	var _cret *C.GtkWidget // in

	_cret = C.adw_view_switcher_bar_new()

	var _viewSwitcherBar *ViewSwitcherBar // out

	_viewSwitcherBar = wrapViewSwitcherBar(coreglib.Take(unsafe.Pointer(_cret)))

	return _viewSwitcherBar
}

// Reveal gets whether self should be revealed or hidden.
//
// The function returns the following values:
//
//   - ok: whether self is revealed.
func (self *ViewSwitcherBar) Reveal() bool {
	var _arg0 *C.AdwViewSwitcherBar // out
	var _cret C.gboolean            // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Stack gets the stack controlled by self.
//
// The function returns the following values:
//
//   - viewStack (optional): stack.
func (self *ViewSwitcherBar) Stack() *ViewStack {
	var _arg0 *C.AdwViewSwitcherBar // out
	var _cret *C.AdwViewStack       // in

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

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

	var _viewStack *ViewStack // out

	if _cret != nil {
		_viewStack = wrapViewStack(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _viewStack
}

// SetReveal sets whether self should be revealed or hidden.
//
// The function takes the following parameters:
//
//   - reveal: whether to reveal self.
func (self *ViewSwitcherBar) SetReveal(reveal bool) {
	var _arg0 *C.AdwViewSwitcherBar // out
	var _arg1 C.gboolean            // out

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

	C.adw_view_switcher_bar_set_reveal(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(reveal)
}

// SetStack sets the stack controlled by self.
//
// The function takes the following parameters:
//
//   - stack (optional): stack.
func (self *ViewSwitcherBar) SetStack(stack *ViewStack) {
	var _arg0 *C.AdwViewSwitcherBar // out
	var _arg1 *C.AdwViewStack       // out

	_arg0 = (*C.AdwViewSwitcherBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if stack != nil {
		_arg1 = (*C.AdwViewStack)(unsafe.Pointer(coreglib.InternObject(stack).Native()))
	}

	C.adw_view_switcher_bar_set_stack(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(stack)
}

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

// viewSwitcherBarClass is the struct that's finalized.
type viewSwitcherBarClass struct {
	native *C.AdwViewSwitcherBarClass
}

func (v *ViewSwitcherBarClass) ParentClass() *gtk.WidgetClass {
	valptr := &v.native.parent_class
	var _v *gtk.WidgetClass // out
	_v = (*gtk.WidgetClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
	return _v
}
