/* transparentcontainer.c generated by valac 0.56.19, the Vala compiler
 * generated from transparentcontainer.vala, do not modify */

/*
 * Gnome Nibbles: Gnome Worm Game
 * Copyright (C) 2025 Ben Corby <bcorby@new-ms.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * Coding style.
 *
 * To help you comply with the coding style in this project use the
 * following greps. Any lines returned should be adjusted so they
 * don't match. The convoluted regular expressions are so they don't
 * match them self.
 *
 * grep -ne '[^][)(_!$ "](' *.vala
 * grep -ne '[(] ' *.vala
 * grep -ne '[ ])' *.vala
 * grep -ne ' $' *.vala
 *
 */
/*
 * A simple transparent widget that can contain a single child widget.
 */

#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_TRANSPARENT_CONTAINER (transparent_container_get_type ())
#define TRANSPARENT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPARENT_CONTAINER, TransparentContainer))
#define TRANSPARENT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPARENT_CONTAINER, TransparentContainerClass))
#define IS_TRANSPARENT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPARENT_CONTAINER))
#define IS_TRANSPARENT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPARENT_CONTAINER))
#define TRANSPARENT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPARENT_CONTAINER, TransparentContainerClass))

typedef struct _TransparentContainer TransparentContainer;
typedef struct _TransparentContainerClass TransparentContainerClass;
typedef struct _TransparentContainerPrivate TransparentContainerPrivate;
enum  {
	TRANSPARENT_CONTAINER_0_PROPERTY,
	TRANSPARENT_CONTAINER_CHILD_PROPERTY,
	TRANSPARENT_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* transparent_container_properties[TRANSPARENT_CONTAINER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TransparentContainer {
	GtkWidget parent_instance;
	TransparentContainerPrivate * priv;
};

struct _TransparentContainerClass {
	GtkWidgetClass parent_class;
};

struct _TransparentContainerPrivate {
	GtkWidget* _child;
};

static gint TransparentContainer_private_offset;
static gpointer transparent_container_parent_class = NULL;

VALA_EXTERN GType transparent_container_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TransparentContainer, g_object_unref)
static void transparent_container_real_dispose (GObject* base);
VALA_EXTERN GtkWidget* transparent_container_get_child (TransparentContainer* self);
VALA_EXTERN void transparent_container_set_child (TransparentContainer* self,
                                      GtkWidget* value);
static void transparent_container_real_size_allocate (GtkWidget* base,
                                               gint width,
                                               gint height,
                                               gint baseline);
VALA_EXTERN TransparentContainer* transparent_container_new (void);
VALA_EXTERN TransparentContainer* transparent_container_construct (GType object_type);
static void transparent_container_finalize (GObject * obj);
static GType transparent_container_get_type_once (void);
static void _vala_transparent_container_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_transparent_container_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);

static inline gpointer
transparent_container_get_instance_private (TransparentContainer* self)
{
	return G_STRUCT_MEMBER_P (self, TransparentContainer_private_offset);
}

static void
transparent_container_real_dispose (GObject* base)
{
	TransparentContainer * self;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	self = (TransparentContainer*) base;
	_tmp0_ = transparent_container_get_child (self);
	_tmp1_ = _tmp0_;
	if (NULL != _tmp1_) {
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		_tmp2_ = transparent_container_get_child (self);
		_tmp3_ = _tmp2_;
		gtk_widget_unparent (_tmp3_);
		transparent_container_set_child (self, NULL);
	}
	G_OBJECT_CLASS (transparent_container_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

static void
transparent_container_real_size_allocate (GtkWidget* base,
                                          gint width,
                                          gint height,
                                          gint baseline)
{
	TransparentContainer * self;
	gboolean _tmp0_ = FALSE;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	self = (TransparentContainer*) base;
	_tmp1_ = transparent_container_get_child (self);
	_tmp2_ = _tmp1_;
	if (NULL != _tmp2_) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = transparent_container_get_child (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = gtk_widget_get_visible (_tmp4_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkAllocation _tmp7_ = {0};
		_tmp5_ = transparent_container_get_child (self);
		_tmp6_ = _tmp5_;
		_tmp7_.x = 0;
		_tmp7_.y = 0;
		_tmp7_.width = width;
		_tmp7_.height = height;
		gtk_widget_size_allocate (_tmp6_, &_tmp7_, baseline);
	}
	GTK_WIDGET_CLASS (transparent_container_parent_class)->size_allocate (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), width, height, baseline);
}

TransparentContainer*
transparent_container_construct (GType object_type)
{
	TransparentContainer * self = NULL;
	self = (TransparentContainer*) g_object_new (object_type, NULL);
	return self;
}

TransparentContainer*
transparent_container_new (void)
{
	return transparent_container_construct (TYPE_TRANSPARENT_CONTAINER);
}

GtkWidget*
transparent_container_get_child (TransparentContainer* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_child;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
transparent_container_set_child (TransparentContainer* self,
                                 GtkWidget* value)
{
	GtkWidget* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != value) {
		GtkWidget* _tmp1_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp1_ = self->priv->_child;
		if (NULL != _tmp1_) {
			GtkWidget* _tmp2_;
			_tmp2_ = self->priv->_child;
			gtk_widget_unparent (_tmp2_);
		}
		_tmp3_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_child);
		self->priv->_child = _tmp3_;
		_tmp4_ = self->priv->_child;
		if (NULL != _tmp4_) {
			GtkWidget* _tmp5_;
			_tmp5_ = self->priv->_child;
			gtk_widget_set_parent (_tmp5_, (GtkWidget*) self);
		}
		gtk_widget_queue_resize ((GtkWidget*) self);
	}
	g_object_notify_by_pspec ((GObject *) self, transparent_container_properties[TRANSPARENT_CONTAINER_CHILD_PROPERTY]);
}

static void
transparent_container_class_init (TransparentContainerClass * klass,
                                  gpointer klass_data)
{
	transparent_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TransparentContainer_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) transparent_container_real_dispose;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) transparent_container_real_size_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_transparent_container_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_transparent_container_set_property;
	G_OBJECT_CLASS (klass)->finalize = transparent_container_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TRANSPARENT_CONTAINER_CHILD_PROPERTY, transparent_container_properties[TRANSPARENT_CONTAINER_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
transparent_container_instance_init (TransparentContainer * self,
                                     gpointer klass)
{
	self->priv = transparent_container_get_instance_private (self);
	self->priv->_child = NULL;
}

static void
transparent_container_finalize (GObject * obj)
{
	TransparentContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TRANSPARENT_CONTAINER, TransparentContainer);
	_g_object_unref0 (self->priv->_child);
	G_OBJECT_CLASS (transparent_container_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
transparent_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TransparentContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) transparent_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TransparentContainer), 0, (GInstanceInitFunc) transparent_container_instance_init, NULL };
	GType transparent_container_type_id;
	transparent_container_type_id = g_type_register_static (gtk_widget_get_type (), "TransparentContainer", &g_define_type_info, G_TYPE_FLAG_NONE);
	TransparentContainer_private_offset = g_type_add_instance_private (transparent_container_type_id, sizeof (TransparentContainerPrivate));
	return transparent_container_type_id;
}

GType
transparent_container_get_type (void)
{
	static GType transparent_container_type_id__once = 0;
	if (g_once_init_enter_pointer (&transparent_container_type_id__once)) {
		GType transparent_container_type_id;
		transparent_container_type_id = transparent_container_get_type_once ();
		g_once_init_leave_pointer (&transparent_container_type_id__once, transparent_container_type_id);
	}
	return transparent_container_type_id__once;
}

static void
_vala_transparent_container_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	TransparentContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TRANSPARENT_CONTAINER, TransparentContainer);
	switch (property_id) {
		case TRANSPARENT_CONTAINER_CHILD_PROPERTY:
		g_value_set_object (value, transparent_container_get_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_transparent_container_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	TransparentContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TRANSPARENT_CONTAINER, TransparentContainer);
	switch (property_id) {
		case TRANSPARENT_CONTAINER_CHILD_PROPERTY:
		transparent_container_set_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

