/* iterBox.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from iterBox.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_ITER_BOX (iter_box_get_type ())
#define ITER_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ITER_BOX, IterBox))
#define ITER_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ITER_BOX, IterBoxClass))
#define IS_ITER_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ITER_BOX))
#define IS_ITER_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ITER_BOX))
#define ITER_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ITER_BOX, IterBoxClass))

typedef struct _IterBox IterBox;
typedef struct _IterBoxClass IterBoxClass;
typedef struct _IterBoxPrivate IterBoxPrivate;
enum  {
	ITER_BOX_0_PROPERTY,
	ITER_BOX_LENGTH_PROPERTY,
	ITER_BOX_NUM_PROPERTIES
};
static GParamSpec* iter_box_properties[ITER_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block3Data Block3Data;

struct _IterBox {
	GtkBox parent_instance;
	IterBoxPrivate * priv;
};

struct _IterBoxClass {
	GtkBoxClass parent_class;
};

struct _IterBoxPrivate {
	guint _length;
	GList* children;
};

struct _Block3Data {
	int _ref_count_;
	IterBox* self;
	GtkWidget* child;
};

static gint IterBox_private_offset;
static gpointer iter_box_parent_class = NULL;

VALA_EXTERN GType iter_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IterBox, g_object_unref)
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN IterBox* iter_box_new (GtkOrientation orientation,
                       gint spacing);
VALA_EXTERN IterBox* iter_box_construct (GType object_type,
                             GtkOrientation orientation,
                             gint spacing);
static void iter_box_real_dispose (GObject* base);
VALA_EXTERN void iter_box_remove (IterBox* self,
                      GtkWidget* child);
static void iter_box_on_add (IterBox* self,
                      GtkWidget* child);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
VALA_EXTERN guint iter_box_get_length (IterBox* self);
static void iter_box_set_length (IterBox* self,
                          guint value);
static void __lambda11_ (Block3Data* _data3_);
static void ___lambda11__gtk_widget_destroy (GtkWidget* _sender,
                                      gpointer self);
VALA_EXTERN GList* iter_box_get_children (IterBox* self);
VALA_EXTERN void iter_box_append (IterBox* self,
                      GtkWidget* child);
VALA_EXTERN void iter_box_prepend (IterBox* self,
                       GtkWidget* child);
static void iter_box_finalize (GObject * obj);
static GType iter_box_get_type_once (void);
static void _vala_iter_box_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec);
static void _vala_iter_box_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec);

static inline gpointer
iter_box_get_instance_private (IterBox* self)
{
	return G_STRUCT_MEMBER_P (self, IterBox_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

IterBox*
iter_box_construct (GType object_type,
                    GtkOrientation orientation,
                    gint spacing)
{
	IterBox * self = NULL;
	self = (IterBox*) g_object_new (object_type, "orientation", orientation, "spacing", spacing, NULL);
	gtk_widget_set_name (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), "iterbox");
	return self;
}

IterBox*
iter_box_new (GtkOrientation orientation,
              gint spacing)
{
	return iter_box_construct (TYPE_ITER_BOX, orientation, spacing);
}

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

static void
iter_box_real_dispose (GObject* base)
{
	IterBox * self;
	GList* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_ITER_BOX, IterBox);
	_tmp0_ = self->priv->children;
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp0_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			GtkWidget* _tmp1_;
			GtkWidget* child = NULL;
			_tmp1_ = _g_object_ref0 ((GtkWidget*) child_it->data);
			child = _tmp1_;
			{
				GtkWidget* _tmp2_;
				_tmp2_ = child;
				iter_box_remove (self, _tmp2_);
				_g_object_unref0 (child);
			}
		}
	}
	G_OBJECT_CLASS (iter_box_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), G_TYPE_OBJECT, GObject));
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		IterBox* self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->child);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static GList*
vala_g_list_remove_full (GList* self,
                         gconstpointer data,
                         GFreeFunc func)
{
	GList* l = NULL;
	GList* result;
	l = self;
	while (TRUE) {
		GList* _tmp0_;
		GList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp0_ = l;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = l;
		_tmp2_ = ((GList*) _tmp1_)->data;
		if (_tmp2_ != data) {
			GList* _tmp3_;
			GList* _tmp4_;
			_tmp3_ = l;
			_tmp4_ = ((GList*) _tmp3_)->next;
			l = _tmp4_;
		} else {
			GList* _tmp5_;
			gconstpointer _tmp6_;
			GList* _tmp7_;
			_tmp5_ = l;
			_tmp6_ = ((GList*) _tmp5_)->data;
			func (_tmp6_);
			_tmp7_ = l;
			self = g_list_delete_link (self, (GList*) _tmp7_);
			break;
		}
	}
	result = self;
	return result;
}

static void
__lambda11_ (Block3Data* _data3_)
{
	IterBox* self;
	self = _data3_->self;
	self->priv->children = vala_g_list_remove_full (self->priv->children, _data3_->child, _g_object_unref0_);
}

static void
___lambda11__gtk_widget_destroy (GtkWidget* _sender,
                                 gpointer self)
{
	__lambda11_ (self);
}

static void
iter_box_on_add (IterBox* self,
                 GtkWidget* child)
{
	Block3Data* _data3_;
	GtkWidget* _tmp0_;
	guint _tmp1_;
	g_return_if_fail (IS_ITER_BOX (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()));
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (child);
	_g_object_unref0 (_data3_->child);
	_data3_->child = _tmp0_;
	_tmp1_ = self->priv->_length;
	iter_box_set_length (self, _tmp1_ + 1);
	g_signal_connect_data (_data3_->child, "destroy", (GCallback) ___lambda11__gtk_widget_destroy, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

GList*
iter_box_get_children (IterBox* self)
{
	GList* _tmp0_;
	GList* _tmp1_;
	GList* result;
	g_return_val_if_fail (IS_ITER_BOX (self), NULL);
	_tmp0_ = self->priv->children;
	_tmp1_ = g_list_copy (_tmp0_);
	result = _tmp1_;
	return result;
}

void
iter_box_append (IterBox* self,
                 GtkWidget* child)
{
	GtkWidget* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	gconstpointer _tmp3_;
	g_return_if_fail (IS_ITER_BOX (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()));
	_tmp0_ = _g_object_ref0 (child);
	self->priv->children = g_list_append (self->priv->children, _tmp0_);
	_tmp1_ = self->priv->children;
	_tmp2_ = g_list_last (_tmp1_);
	_tmp3_ = _tmp2_->data;
	gtk_box_append (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), (GtkWidget*) _tmp3_);
	iter_box_on_add (self, child);
}

void
iter_box_prepend (IterBox* self,
                  GtkWidget* child)
{
	GtkWidget* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	gconstpointer _tmp3_;
	g_return_if_fail (IS_ITER_BOX (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()));
	_tmp0_ = _g_object_ref0 (child);
	self->priv->children = g_list_prepend (self->priv->children, _tmp0_);
	_tmp1_ = self->priv->children;
	_tmp2_ = g_list_first (_tmp1_);
	_tmp3_ = _tmp2_->data;
	gtk_box_prepend (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), (GtkWidget*) _tmp3_);
	iter_box_on_add (self, child);
}

void
iter_box_remove (IterBox* self,
                 GtkWidget* child)
{
	guint _tmp0_;
	g_return_if_fail (IS_ITER_BOX (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()));
	self->priv->children = vala_g_list_remove_full (self->priv->children, child, _g_object_unref0_);
	gtk_box_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), child);
	_tmp0_ = self->priv->_length;
	iter_box_set_length (self, _tmp0_ - 1);
}

guint
iter_box_get_length (IterBox* self)
{
	guint result;
	g_return_val_if_fail (IS_ITER_BOX (self), 0U);
	result = self->priv->_length;
	return result;
}

static void
iter_box_set_length (IterBox* self,
                     guint value)
{
	guint old_value;
	g_return_if_fail (IS_ITER_BOX (self));
	old_value = iter_box_get_length (self);
	if (old_value != value) {
		self->priv->_length = value;
		g_object_notify_by_pspec ((GObject *) self, iter_box_properties[ITER_BOX_LENGTH_PROPERTY]);
	}
}

static void
iter_box_class_init (IterBoxClass * klass,
                     gpointer klass_data)
{
	iter_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &IterBox_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) iter_box_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_iter_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_iter_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = iter_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ITER_BOX_LENGTH_PROPERTY, iter_box_properties[ITER_BOX_LENGTH_PROPERTY] = g_param_spec_uint ("length", "length", "length", 0, G_MAXUINT, (guint) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
iter_box_instance_init (IterBox * self,
                        gpointer klass)
{
	self->priv = iter_box_get_instance_private (self);
	self->priv->_length = (guint) 0;
	self->priv->children = NULL;
}

static void
iter_box_finalize (GObject * obj)
{
	IterBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ITER_BOX, IterBox);
	(self->priv->children == NULL) ? NULL : (self->priv->children = (_g_list_free__g_object_unref0_ (self->priv->children), NULL));
	G_OBJECT_CLASS (iter_box_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
iter_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (IterBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iter_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IterBox), 0, (GInstanceInitFunc) iter_box_instance_init, NULL };
	GType iter_box_type_id;
	iter_box_type_id = g_type_register_static (gtk_box_get_type (), "IterBox", &g_define_type_info, 0);
	IterBox_private_offset = g_type_add_instance_private (iter_box_type_id, sizeof (IterBoxPrivate));
	return iter_box_type_id;
}

GType
iter_box_get_type (void)
{
	static gsize iter_box_type_id__once = 0;
	if (g_once_init_enter (&iter_box_type_id__once)) {
		GType iter_box_type_id;
		iter_box_type_id = iter_box_get_type_once ();
		g_once_init_leave (&iter_box_type_id__once, iter_box_type_id);
	}
	return iter_box_type_id__once;
}

static void
_vala_iter_box_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec)
{
	IterBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ITER_BOX, IterBox);
	switch (property_id) {
		case ITER_BOX_LENGTH_PROPERTY:
		g_value_set_uint (value, iter_box_get_length (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_iter_box_set_property (GObject * object,
                             guint property_id,
                             const GValue * value,
                             GParamSpec * pspec)
{
	IterBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ITER_BOX, IterBox);
	switch (property_id) {
		case ITER_BOX_LENGTH_PROPERTY:
		iter_box_set_length (self, g_value_get_uint (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

