/* underlay.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from underlay.vala, do not modify */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_UNDERLAY (underlay_get_type ())
#define UNDERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDERLAY, Underlay))
#define UNDERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDERLAY, UnderlayClass))
#define IS_UNDERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDERLAY))
#define IS_UNDERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDERLAY))
#define UNDERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDERLAY, UnderlayClass))

typedef struct _Underlay Underlay;
typedef struct _UnderlayClass UnderlayClass;
typedef struct _UnderlayPrivate UnderlayPrivate;
enum  {
	UNDERLAY_0_PROPERTY,
	UNDERLAY_CHILD_PROPERTY,
	UNDERLAY_UNDERLAY_CHILD_PROPERTY,
	UNDERLAY_NUM_PROPERTIES
};
static GParamSpec* underlay_properties[UNDERLAY_NUM_PROPERTIES];

struct _Underlay {
	GtkWidget parent_instance;
	UnderlayPrivate * priv;
	GtkWidget* _child;
	GtkWidget* _underlay_child;
};

struct _UnderlayClass {
	GtkWidgetClass parent_class;
};

static gpointer underlay_parent_class = NULL;

VALA_EXTERN GType underlay_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Underlay, g_object_unref)
static void underlay_set_children (Underlay* self);
static GtkSizeRequestMode underlay_real_get_request_mode (GtkWidget* base);
static void underlay_real_measure (GtkWidget* base,
                            GtkOrientation orientation,
                            gint for_size,
                            gint* minimum,
                            gint* natural,
                            gint* minimum_baseline,
                            gint* natural_baseline);
VALA_EXTERN GtkWidget* underlay_get_child (Underlay* self);
static void underlay_real_size_allocate (GtkWidget* base,
                                  gint width,
                                  gint height,
                                  gint baseline);
VALA_EXTERN GtkWidget* underlay_get_underlay_child (Underlay* self);
VALA_EXTERN Underlay* underlay_new (void);
VALA_EXTERN Underlay* underlay_construct (GType object_type);
VALA_EXTERN void underlay_set_child (Underlay* self,
                         GtkWidget* value);
VALA_EXTERN void underlay_set_underlay_child (Underlay* self,
                                  GtkWidget* value);
static void underlay_finalize (GObject * obj);
static GType underlay_get_type_once (void);
static void _vala_underlay_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec);
static void _vala_underlay_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec);

static void
underlay_set_children (Underlay* self)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp3_;
	g_return_if_fail (IS_UNDERLAY (self));
	_tmp0_ = self->_underlay_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		GtkWidget* _tmp2_;
		_tmp1_ = self->_underlay_child;
		gtk_widget_unparent (_tmp1_);
		_tmp2_ = self->_underlay_child;
		gtk_widget_insert_after (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), NULL);
	}
	_tmp3_ = self->_child;
	if (_tmp3_ != NULL) {
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp4_ = self->_child;
		gtk_widget_unparent (_tmp4_);
		_tmp5_ = self->_child;
		_tmp6_ = self->_underlay_child;
		gtk_widget_insert_after (_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp6_);
	}
}

static GtkSizeRequestMode
underlay_real_get_request_mode (GtkWidget* base)
{
	Underlay * self;
	GtkSizeRequestMode result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_UNDERLAY, Underlay);
	result = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
	return result;
}

static void
underlay_real_measure (GtkWidget* base,
                       GtkOrientation orientation,
                       gint for_size,
                       gint* minimum,
                       gint* natural,
                       gint* minimum_baseline,
                       gint* natural_baseline)
{
	Underlay * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint child_min = 0;
	gint child_nat = 0;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_UNDERLAY, Underlay);
	_vala_minimum = 0;
	_vala_natural = 0;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	_tmp0_ = underlay_get_child (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_widget_get_visible (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		if (minimum) {
			*minimum = _vala_minimum;
		}
		if (natural) {
			*natural = _vala_natural;
		}
		if (minimum_baseline) {
			*minimum_baseline = _vala_minimum_baseline;
		}
		if (natural_baseline) {
			*natural_baseline = _vala_natural_baseline;
		}
		return;
	}
	_tmp4_ = underlay_get_child (self);
	_tmp5_ = _tmp4_;
	gtk_widget_measure (_tmp5_, orientation, for_size, &_tmp6_, &_tmp7_, NULL, NULL);
	child_min = _tmp6_;
	child_nat = _tmp7_;
	_vala_minimum = MAX (_vala_minimum, child_min);
	_vala_natural = MAX (_vala_natural, child_nat);
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static void
underlay_real_size_allocate (GtkWidget* base,
                             gint width,
                             gint height,
                             gint baseline)
{
	Underlay * self;
	gboolean _tmp0_ = FALSE;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean _tmp7_ = FALSE;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_UNDERLAY, Underlay);
	_tmp1_ = underlay_get_child (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = underlay_get_child (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = gtk_widget_should_layout (_tmp4_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp5_ = underlay_get_child (self);
		_tmp6_ = _tmp5_;
		gtk_widget_allocate (_tmp6_, width, height, baseline, NULL);
	}
	_tmp8_ = underlay_get_underlay_child (self);
	_tmp9_ = _tmp8_;
	if (_tmp9_ != NULL) {
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		_tmp10_ = underlay_get_underlay_child (self);
		_tmp11_ = _tmp10_;
		_tmp7_ = gtk_widget_should_layout (_tmp11_);
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		GtkWidget* _tmp12_;
		GtkWidget* _tmp13_;
		_tmp12_ = underlay_get_underlay_child (self);
		_tmp13_ = _tmp12_;
		gtk_widget_allocate (_tmp13_, width, height, baseline, NULL);
	}
}

Underlay*
underlay_construct (GType object_type)
{
	Underlay * self = NULL;
	self = (Underlay*) g_object_new (object_type, NULL);
	return self;
}

Underlay*
underlay_new (void)
{
	return underlay_construct (TYPE_UNDERLAY);
}

GtkWidget*
underlay_get_child (Underlay* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (IS_UNDERLAY (self), NULL);
	_tmp0_ = self->_child;
	result = _tmp0_;
	return result;
}

void
underlay_set_child (Underlay* self,
                    GtkWidget* value)
{
	g_return_if_fail (IS_UNDERLAY (self));
	self->_child = value;
	underlay_set_children (self);
	g_object_notify_by_pspec ((GObject *) self, underlay_properties[UNDERLAY_CHILD_PROPERTY]);
}

GtkWidget*
underlay_get_underlay_child (Underlay* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (IS_UNDERLAY (self), NULL);
	_tmp0_ = self->_underlay_child;
	result = _tmp0_;
	return result;
}

void
underlay_set_underlay_child (Underlay* self,
                             GtkWidget* value)
{
	g_return_if_fail (IS_UNDERLAY (self));
	self->_underlay_child = value;
	underlay_set_children (self);
	g_object_notify_by_pspec ((GObject *) self, underlay_properties[UNDERLAY_UNDERLAY_CHILD_PROPERTY]);
}

static void
underlay_class_init (UnderlayClass * klass,
                     gpointer klass_data)
{
	underlay_parent_class = g_type_class_peek_parent (klass);
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) underlay_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) underlay_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) underlay_real_size_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_underlay_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_underlay_set_property;
	G_OBJECT_CLASS (klass)->finalize = underlay_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), UNDERLAY_CHILD_PROPERTY, underlay_properties[UNDERLAY_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), UNDERLAY_UNDERLAY_CHILD_PROPERTY, underlay_properties[UNDERLAY_UNDERLAY_CHILD_PROPERTY] = g_param_spec_object ("underlay-child", "underlay-child", "underlay-child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
underlay_instance_init (Underlay * self,
                        gpointer klass)
{
	self->_child = NULL;
	self->_underlay_child = NULL;
}

static void
underlay_finalize (GObject * obj)
{
	Underlay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDERLAY, Underlay);
	G_OBJECT_CLASS (underlay_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
underlay_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UnderlayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) underlay_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Underlay), 0, (GInstanceInitFunc) underlay_instance_init, NULL };
	GType underlay_type_id;
	underlay_type_id = g_type_register_static (gtk_widget_get_type (), "Underlay", &g_define_type_info, 0);
	return underlay_type_id;
}

GType
underlay_get_type (void)
{
	static gsize underlay_type_id__once = 0;
	if (g_once_init_enter (&underlay_type_id__once)) {
		GType underlay_type_id;
		underlay_type_id = underlay_get_type_once ();
		g_once_init_leave (&underlay_type_id__once, underlay_type_id);
	}
	return underlay_type_id__once;
}

static void
_vala_underlay_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec)
{
	Underlay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_UNDERLAY, Underlay);
	switch (property_id) {
		case UNDERLAY_CHILD_PROPERTY:
		g_value_set_object (value, underlay_get_child (self));
		break;
		case UNDERLAY_UNDERLAY_CHILD_PROPERTY:
		g_value_set_object (value, underlay_get_underlay_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_underlay_set_property (GObject * object,
                             guint property_id,
                             const GValue * value,
                             GParamSpec * pspec)
{
	Underlay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_UNDERLAY, Underlay);
	switch (property_id) {
		case UNDERLAY_CHILD_PROPERTY:
		underlay_set_child (self, g_value_get_object (value));
		break;
		case UNDERLAY_UNDERLAY_CHILD_PROPERTY:
		underlay_set_underlay_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

