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

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

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

func defaultMultiLayoutViewOverrides(v *MultiLayoutView) MultiLayoutViewOverrides {
	return MultiLayoutViewOverrides{}
}

// MultiLayoutView: widget for switching between different layouts.
//
// AdwMultiLayoutView contains layouts and children. Each child has an ID, each
// layout has slots inside it, each slot also has an ID. When switching layouts,
// children are inserted into slots with matching IDs. The gtk.Widget:visible
// property of each slot is updated to match that of the inserted child.
//
// This can be useful for rearranging children when it's difficult to do so
// otherwise, for example to move a child from a sidebar to a bottom bar.
//
// The currently used layout can be switched using the multilayoutview:layout
// or multilayoutview:layout-name properties. For example, it can be done via a
// adw.Breakpoint setter to change layouts depending on the window size.
//
// # AdwMultiLayoutView as GtkBuildable
//
// The AdwMultiLayoutView implementation of the gtk.Buildable interface supports
// adding layouts via <child> element with the type attribute omitted.
//
// It also supports setting children via <child type="ID">.
//
// Example of an AdwMultiLayoutView UI definition that can display a secondary
// child as either a sidebar or a bottom sheet.
//
//	<object class="AdwMultiLayoutView">
//	  <child>
//	    <object class="AdwLayout">
//	      <property name="name">sidebar</property>
//	      <property name="content">
//	        <object class="AdwOverlaySplitView">
//	          <property name="sidebar">
//	            <object class="AdwLayoutSlot">
//	              <property name="id">secondary</property>
//	            </object>
//	          </property>
//	          <property name="content">
//	            <object class="AdwLayoutSlot">
//	              <property name="id">primary</property>
//	            </object>
//	          </property>
//	        </object>
//	      </property>
//	    </object>
//	  </child>
//	  <child>
//	    <object class="AdwLayout">
//	      <property name="name">bottom-sheet</property>
//	      <property name="content">
//	        <object class="AdwBottomSheet">
//	          <property name="open">True</property>
//	          <property name="content">
//	            <object class="AdwLayoutSlot">
//	              <property name="id">primary</property>
//	            </object>
//	          </property>
//	          <property name="sheet">
//	            <object class="AdwLayoutSlot">
//	              <property name="id">secondary</property>
//	            </object>
//	          </property>
//	        </object>
//	      </property>
//	    </object>
//	  </child>
//	  <child type="primary">
//	    <!-- ... -->
//	  </child>
//	  <child type="secondary">
//	    <!-- ... -->
//	  </child>
//	</object>
//
// # CSS nodes
//
// AdwMultiLayoutView has a single CSS node with name multi-layout-view.
type MultiLayoutView struct {
	_ [0]func() // equal guard
	gtk.Widget
}

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

func init() {
	coreglib.RegisterClassInfo[*MultiLayoutView, *MultiLayoutViewClass, MultiLayoutViewOverrides](
		GTypeMultiLayoutView,
		initMultiLayoutViewClass,
		wrapMultiLayoutView,
		defaultMultiLayoutViewOverrides,
	)
}

func initMultiLayoutViewClass(gclass unsafe.Pointer, overrides MultiLayoutViewOverrides, classInitFunc func(*MultiLayoutViewClass)) {
	if classInitFunc != nil {
		class := (*MultiLayoutViewClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

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

// NewMultiLayoutView creates a new AdwMultiLayoutView.
//
// The function returns the following values:
//
//   - multiLayoutView: newly created AdwMultiLayoutView.
func NewMultiLayoutView() *MultiLayoutView {
	var _cret *C.GtkWidget // in

	_cret = C.adw_multi_layout_view_new()

	var _multiLayoutView *MultiLayoutView // out

	_multiLayoutView = wrapMultiLayoutView(coreglib.Take(unsafe.Pointer(_cret)))

	return _multiLayoutView
}

// AddLayout adds layout to self.
//
// The function takes the following parameters:
//
//   - layout to add.
func (self *MultiLayoutView) AddLayout(layout *Layout) {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.AdwLayout          // out

	_arg0 = (*C.AdwMultiLayoutView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwLayout)(unsafe.Pointer(coreglib.InternObject(layout).Native()))
	C.g_object_ref(C.gpointer(coreglib.InternObject(layout).Native()))

	C.adw_multi_layout_view_add_layout(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(layout)
}

// Child gets the child for id to self.
//
// The function takes the following parameters:
//
//   - id of the child.
//
// The function returns the following values:
//
//   - widget (optional): child for id.
func (self *MultiLayoutView) Child(id string) gtk.Widgetter {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.char               // out
	var _cret *C.GtkWidget          // in

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

	_cret = C.adw_multi_layout_view_get_child(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(id)

	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
}

// Layout gets the currently used layout of self.
//
// The function returns the following values:
//
//   - layout (optional): current layout.
func (self *MultiLayoutView) Layout() *Layout {
	var _arg0 *C.AdwMultiLayoutView // out
	var _cret *C.AdwLayout          // in

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

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

	var _layout *Layout // out

	if _cret != nil {
		_layout = wrapLayout(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _layout
}

// LayoutByName gets layout with the name name from self, or NULL if it doesn't
// exist.
//
// See layout:name.
//
// The function takes the following parameters:
//
//   - name of the layout.
//
// The function returns the following values:
//
//   - layout (optional) with name.
func (self *MultiLayoutView) LayoutByName(name string) *Layout {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.char               // out
	var _cret *C.AdwLayout          // in

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

	_cret = C.adw_multi_layout_view_get_layout_by_name(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(name)

	var _layout *Layout // out

	if _cret != nil {
		_layout = wrapLayout(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _layout
}

// LayoutName returns the name of the currently used layout of self.
//
// The function returns the following values:
//
//   - utf8 (optional): name of the current layout.
func (self *MultiLayoutView) LayoutName() string {
	var _arg0 *C.AdwMultiLayoutView // out
	var _cret *C.char               // in

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

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

	var _utf8 string // out

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

	return _utf8
}

// RemoveLayout removes layout from self.
//
// The function takes the following parameters:
//
//   - layout to add.
func (self *MultiLayoutView) RemoveLayout(layout *Layout) {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.AdwLayout          // out

	_arg0 = (*C.AdwMultiLayoutView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwLayout)(unsafe.Pointer(coreglib.InternObject(layout).Native()))

	C.adw_multi_layout_view_remove_layout(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(layout)
}

// SetChild sets child as the child for id in self.
//
// When changing layouts, it will be inserted into the slot with id.
//
// The function takes the following parameters:
//
//   - id of the child.
//   - child to set.
func (self *MultiLayoutView) SetChild(id string, child gtk.Widgetter) {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.char               // out
	var _arg2 *C.GtkWidget          // out

	_arg0 = (*C.AdwMultiLayoutView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.char)(unsafe.Pointer(C.CString(id)))
	defer C.free(unsafe.Pointer(_arg1))
	_arg2 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))

	C.adw_multi_layout_view_set_child(_arg0, _arg1, _arg2)
	runtime.KeepAlive(self)
	runtime.KeepAlive(id)
	runtime.KeepAlive(child)
}

// SetLayout makes layout the current layout of self.
//
// The function takes the following parameters:
//
//   - layout in self.
func (self *MultiLayoutView) SetLayout(layout *Layout) {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.AdwLayout          // out

	_arg0 = (*C.AdwMultiLayoutView)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = (*C.AdwLayout)(unsafe.Pointer(coreglib.InternObject(layout).Native()))

	C.adw_multi_layout_view_set_layout(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(layout)
}

// SetLayoutName makes the layout with name the current layout of self.
//
// See layout:name.
//
// The function takes the following parameters:
//
//   - name of the layout.
func (self *MultiLayoutView) SetLayoutName(name string) {
	var _arg0 *C.AdwMultiLayoutView // out
	var _arg1 *C.char               // out

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

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