// Code generated by girgen. DO NOT EDIT.

package adw

import (
	"runtime"
	"unsafe"

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

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

// GType values.
var (
	GTypePropertyAnimationTarget = coreglib.Type(C.adw_property_animation_target_get_type())
)

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

// PropertyAnimationTarget: animationtarget changing the value of a property of
// a gobject.Object instance.
type PropertyAnimationTarget struct {
	_ [0]func() // equal guard
	AnimationTarget
}

var (
	_ AnimationTargetter = (*PropertyAnimationTarget)(nil)
)

func wrapPropertyAnimationTarget(obj *coreglib.Object) *PropertyAnimationTarget {
	return &PropertyAnimationTarget{
		AnimationTarget: AnimationTarget{
			Object: obj,
		},
	}
}

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

// NewPropertyAnimationTarget creates a new AdwPropertyAnimationTarget for the
// property_name property on object.
//
// The function takes the following parameters:
//
//   - object to be animated.
//   - propertyName: name of the property on object to animate.
//
// The function returns the following values:
//
//   - propertyAnimationTarget: newly created AdwPropertyAnimationTarget.
func NewPropertyAnimationTarget(object *coreglib.Object, propertyName string) *PropertyAnimationTarget {
	var _arg1 *C.GObject            // out
	var _arg2 *C.char               // out
	var _cret *C.AdwAnimationTarget // in

	_arg1 = (*C.GObject)(unsafe.Pointer(object.Native()))
	_arg2 = (*C.char)(unsafe.Pointer(C.CString(propertyName)))
	defer C.free(unsafe.Pointer(_arg2))

	_cret = C.adw_property_animation_target_new(_arg1, _arg2)
	runtime.KeepAlive(object)
	runtime.KeepAlive(propertyName)

	var _propertyAnimationTarget *PropertyAnimationTarget // out

	_propertyAnimationTarget = wrapPropertyAnimationTarget(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))

	return _propertyAnimationTarget
}

// Object gets the object animated by self.
//
// The AdwPropertyAnimationTarget instance does not hold a strong reference
// on the object; make sure the object is kept alive throughout the target's
// lifetime.
//
// The function returns the following values:
//
//   - object: animated object.
func (self *PropertyAnimationTarget) Object() *coreglib.Object {
	var _arg0 *C.AdwPropertyAnimationTarget // out
	var _cret *C.GObject                    // in

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

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

	var _object *coreglib.Object // out

	_object = coreglib.Take(unsafe.Pointer(_cret))

	return _object
}
