// 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/gdk/v4"
	"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 gboolean _gotk4_adw1_TabOverview_ConnectExtraDragDrop(gpointer, AdwTabPage*, GValue*, guintptr);
// extern GdkDragAction _gotk4_adw1_TabOverview_ConnectExtraDragValue(gpointer, AdwTabPage*, GValue*, guintptr);
// extern AdwTabPage* _gotk4_adw1_TabOverview_ConnectCreateTab(gpointer, guintptr);
import "C"

// GType values.
var (
	GTypeTabOverview = coreglib.Type(C.adw_tab_overview_get_type())
)

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

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

func defaultTabOverviewOverrides(v *TabOverview) TabOverviewOverrides {
	return TabOverviewOverrides{}
}

// TabOverview: tab overview for tabview.
//
// <picture> <source srcset="tab-overview-dark.png"
// media="(prefers-color-scheme: dark)"> <img src="tab-overview.png"
// alt="tab-overview"> </picture>
//
// AdwTabOverview is a widget that can display tabs from an AdwTabView in a
// grid.
//
// AdwTabOverview shows a thumbnail for each tab. By default thumbnails
// are static for all pages except the selected one. They can be made
// always live by setting tabpage:live-thumbnail to TRUE, or refreshed with
// tabpage.InvalidateThumbnail or tabview.InvalidateThumbnails otherwise.
//
// If the pages are too tall or too wide, the thumbnails will be cropped;
// use tabpage:thumbnail-xalign and tabpage:thumbnail-yalign to control which
// part of the page should be visible in this case.
//
// Pinned tabs are shown as smaller cards without thumbnails above the other
// tabs. Unlike in tabbar, they still have titles, as well as an unpin button.
//
// AdwTabOverview provides search in open tabs. It searches in tab titles and
// tooltips, as well as tabpage:keyword.
//
// If taboverview:enable-new-tab is set to TRUE, a new tab button will be shown.
// Connect to the taboverview::create-tab signal to use it.
//
// taboverview:secondary-menu can be used to provide a secondary menu for the
// overview. Use it to add extra actions, e.g. to open a new window or undo
// closed tab.
//
// AdwTabOverview is intended to be used as the direct child of the window,
// with the rest of the window contents set as the taboverview:child. The child
// is expected to contain an tabview.
//
// AdwTabOverview shows window buttons by default. They can be
// disabled by setting taboverview:show-start-title-buttons
// and/or taboverview:show-start-title-buttons and/or
// taboverview:show-end-title-buttons to FALSE.
//
// If search and window buttons are disabled, and secondary menu is not set,
// the header bar will be hidden.
//
// # Actions
//
// AdwTabOverview defines the overview.open and overview.close actions for
// opening and closing itself. They can be convenient when used together with
// tabbutton.
//
// # CSS nodes
//
// AdwTabOverview has a single CSS node with name taboverview.
type TabOverview struct {
	_ [0]func() // equal guard
	gtk.Widget
}

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

func init() {
	coreglib.RegisterClassInfo[*TabOverview, *TabOverviewClass, TabOverviewOverrides](
		GTypeTabOverview,
		initTabOverviewClass,
		wrapTabOverview,
		defaultTabOverviewOverrides,
	)
}

func initTabOverviewClass(gclass unsafe.Pointer, overrides TabOverviewOverrides, classInitFunc func(*TabOverviewClass)) {
	if classInitFunc != nil {
		class := (*TabOverviewClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

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

// ConnectCreateTab is emitted when a tab needs to be created;
//
// This can happen after the new tab button has been pressed, see
// taboverview:enable-new-tab.
//
// The signal handler is expected to create a new page in the corresponding
// tabview and return it.
func (self *TabOverview) ConnectCreateTab(f func() (tabPage *TabPage)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "create-tab", false, unsafe.Pointer(C._gotk4_adw1_TabOverview_ConnectCreateTab), f)
}

// ConnectExtraDragDrop: this signal is emitted when content is dropped onto a
// tab.
//
// The content must be of one of the types set up via
// taboverview.SetupExtraDropTarget.
//
// See gtk.DropTarget::drop.
func (self *TabOverview) ConnectExtraDragDrop(f func(page *TabPage, value *coreglib.Value) (ok bool)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "extra-drag-drop", false, unsafe.Pointer(C._gotk4_adw1_TabOverview_ConnectExtraDragDrop), f)
}

// ConnectExtraDragValue: this signal is emitted when the dropped content is
// preloaded.
//
// In order for data to be preloaded, taboverview:extra-drag-preload must be set
// to TRUE.
//
// The content must be of one of the types set up via
// taboverview.SetupExtraDropTarget.
//
// See gtk.DropTarget:value.
func (self *TabOverview) ConnectExtraDragValue(f func(page *TabPage, value *coreglib.Value) (dragAction gdk.DragAction)) coreglib.SignalHandle {
	return coreglib.ConnectGeneratedClosure(self, "extra-drag-value", false, unsafe.Pointer(C._gotk4_adw1_TabOverview_ConnectExtraDragValue), f)
}

// NewTabOverview creates a new AdwTabOverview.
//
// The function returns the following values:
//
//   - tabOverview: newly created AdwTabOverview.
func NewTabOverview() *TabOverview {
	var _cret *C.GtkWidget // in

	_cret = C.adw_tab_overview_new()

	var _tabOverview *TabOverview // out

	_tabOverview = wrapTabOverview(coreglib.Take(unsafe.Pointer(_cret)))

	return _tabOverview
}

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

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

	_cret = C.adw_tab_overview_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
}

// EnableNewTab gets whether to new tab button is enabled for self.
//
// The function returns the following values:
//
//   - ok: whether new tab button is enabled.
func (self *TabOverview) EnableNewTab() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// EnableSearch gets whether search in tabs is enabled for self.
//
// The function returns the following values:
//
//   - ok: whether search is enabled.
func (self *TabOverview) EnableSearch() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// ExtraDragPreferredAction gets the current action during a drop on the
// extra_drop_target.
//
// The function returns the following values:
//
//   - dragAction: drag action of the current drop.
func (self *TabOverview) ExtraDragPreferredAction() gdk.DragAction {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.GdkDragAction   // in

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

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

	var _dragAction gdk.DragAction // out

	_dragAction = gdk.DragAction(_cret)

	return _dragAction
}

// ExtraDragPreload gets whether drop data should be preloaded on hover.
//
// The function returns the following values:
//
//   - ok: whether drop data should be preloaded on hover.
func (self *TabOverview) ExtraDragPreload() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Inverted gets whether thumbnails use inverted layout.
//
// The function returns the following values:
//
//   - ok: whether thumbnails use inverted layout.
func (self *TabOverview) Inverted() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// Open gets whether self is open.
//
// The function returns the following values:
//
//   - ok: whether the overview is open.
func (self *TabOverview) Open() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SearchActive gets whether search is currently active for self.
//
// See taboverview:enable-search.
//
// The function returns the following values:
//
//   - ok: whether search is active.
func (self *TabOverview) SearchActive() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// SecondaryMenu gets the secondary menu model for self.
//
// The function returns the following values:
//
//   - menuModel (optional): secondary menu model.
func (self *TabOverview) SecondaryMenu() gio.MenuModeller {
	var _arg0 *C.AdwTabOverview // out
	var _cret *C.GMenuModel     // in

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

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

	var _menuModel gio.MenuModeller // out

	if _cret != nil {
		{
			objptr := unsafe.Pointer(_cret)

			object := coreglib.Take(objptr)
			casted := object.WalkCast(func(obj coreglib.Objector) bool {
				_, ok := obj.(gio.MenuModeller)
				return ok
			})
			rv, ok := casted.(gio.MenuModeller)
			if !ok {
				panic("no marshaler for " + object.TypeFromInstance().String() + " matching gio.MenuModeller")
			}
			_menuModel = rv
		}
	}

	return _menuModel
}

// ShowEndTitleButtons gets whether end title buttons are shown in self's header
// bar.
//
// The function returns the following values:
//
//   - ok: whether end title buttons are shown.
func (self *TabOverview) ShowEndTitleButtons() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// ShowStartTitleButtons gets whether start title buttons are shown in self's
// header bar.
//
// The function returns the following values:
//
//   - ok: whether start title buttons are shown.
func (self *TabOverview) ShowStartTitleButtons() bool {
	var _arg0 *C.AdwTabOverview // out
	var _cret C.gboolean        // in

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

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

	var _ok bool // out

	if _cret != 0 {
		_ok = true
	}

	return _ok
}

// View gets the tab view self controls.
//
// The function returns the following values:
//
//   - tabView (optional): tab view.
func (self *TabOverview) View() *TabView {
	var _arg0 *C.AdwTabOverview // out
	var _cret *C.AdwTabView     // in

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

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

	var _tabView *TabView // out

	if _cret != nil {
		_tabView = wrapTabView(coreglib.Take(unsafe.Pointer(_cret)))
	}

	return _tabView
}

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

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

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

// SetEnableNewTab sets whether to enable new tab button for self.
//
// Connect to the taboverview::create-tab signal to use it.
//
// The function takes the following parameters:
//
//   - enableNewTab: whether to enable new tab button.
func (self *TabOverview) SetEnableNewTab(enableNewTab bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_enable_new_tab(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(enableNewTab)
}

// SetEnableSearch sets whether to enable search in tabs for self.
//
// Search matches tab titles and tooltips, as well as keywords, set via
// tabpage:keyword. Use keywords to search in e.g. page URLs in a web browser.
//
// During search, tab reordering and drag-n-drop are disabled.
//
// Use taboverview:search-active to check out if search is currently active.
//
// The function takes the following parameters:
//
//   - enableSearch: whether to enable search.
func (self *TabOverview) SetEnableSearch(enableSearch bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_enable_search(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(enableSearch)
}

// SetExtraDragPreload sets whether drop data should be preloaded on hover.
//
// See gtk.DropTarget:preload.
//
// The function takes the following parameters:
//
//   - preload: whether to preload drop data.
func (self *TabOverview) SetExtraDragPreload(preload bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_extra_drag_preload(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(preload)
}

// SetInverted sets whether thumbnails use inverted layout.
//
// If set to TRUE, thumbnails will have the close or unpin button at the
// beginning and the indicator at the end rather than the other way around.
//
// The function takes the following parameters:
//
//   - inverted: whether thumbnails use inverted layout.
func (self *TabOverview) SetInverted(inverted bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_inverted(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(inverted)
}

// SetOpen sets whether the to open self.
//
// The function takes the following parameters:
//
//   - open: whether the overview is open.
func (self *TabOverview) SetOpen(open bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_open(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(open)
}

// SetSecondaryMenu sets the secondary menu model for self.
//
// Use it to add extra actions, e.g. to open a new window or undo closed tab.
//
// The function takes the following parameters:
//
//   - secondaryMenu (optional): menu model.
func (self *TabOverview) SetSecondaryMenu(secondaryMenu gio.MenuModeller) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 *C.GMenuModel     // out

	_arg0 = (*C.AdwTabOverview)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if secondaryMenu != nil {
		_arg1 = (*C.GMenuModel)(unsafe.Pointer(coreglib.InternObject(secondaryMenu).Native()))
	}

	C.adw_tab_overview_set_secondary_menu(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(secondaryMenu)
}

// SetShowEndTitleButtons sets whether to show end title buttons in self's
// header bar.
//
// See headerbar:show-start-title-buttons for the other side.
//
// The function takes the following parameters:
//
//   - showEndTitleButtons: whether to show end title buttons.
func (self *TabOverview) SetShowEndTitleButtons(showEndTitleButtons bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_show_end_title_buttons(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(showEndTitleButtons)
}

// SetShowStartTitleButtons sets whether to show start title buttons in self's
// header bar.
//
// See headerbar:show-end-title-buttons for the other side.
//
// The function takes the following parameters:
//
//   - showStartTitleButtons: whether to show start title buttons.
func (self *TabOverview) SetShowStartTitleButtons(showStartTitleButtons bool) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.gboolean        // out

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

	C.adw_tab_overview_set_show_start_title_buttons(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(showStartTitleButtons)
}

// SetView sets the tab view to control.
//
// The view must be inside self, see taboverview:child.
//
// The function takes the following parameters:
//
//   - view (optional): tab view.
func (self *TabOverview) SetView(view *TabView) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 *C.AdwTabView     // out

	_arg0 = (*C.AdwTabOverview)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	if view != nil {
		_arg1 = (*C.AdwTabView)(unsafe.Pointer(coreglib.InternObject(view).Native()))
	}

	C.adw_tab_overview_set_view(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(view)
}

// SetupExtraDropTarget sets the supported types for this drop target.
//
// Sets up an extra drop target on tabs.
//
// This allows to drag arbitrary content onto tabs, for example URLs in a web
// browser.
//
// If a tab is hovered for a certain period of time while dragging the content,
// it will be automatically selected.
//
// The taboverview::extra-drag-drop signal can be used to handle the drop.
//
// The function takes the following parameters:
//
//   - actions: supported actions.
//   - types (optional): all supported GTypes that can be dropped.
func (self *TabOverview) SetupExtraDropTarget(actions gdk.DragAction, types []coreglib.Type) {
	var _arg0 *C.AdwTabOverview // out
	var _arg1 C.GdkDragAction   // out
	var _arg2 *C.GType          // out
	var _arg3 C.gsize

	_arg0 = (*C.AdwTabOverview)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.GdkDragAction(actions)
	_arg3 = (C.gsize)(len(types))
	_arg2 = (*C.GType)(C.calloc(C.size_t(len(types)), C.size_t(C.sizeof_GType)))
	defer C.free(unsafe.Pointer(_arg2))
	{
		out := unsafe.Slice((*C.GType)(_arg2), len(types))
		for i := range types {
			out[i] = C.GType(types[i])
		}
	}

	C.adw_tab_overview_setup_extra_drop_target(_arg0, _arg1, _arg2, _arg3)
	runtime.KeepAlive(self)
	runtime.KeepAlive(actions)
	runtime.KeepAlive(types)
}
