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

#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.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_LIST_BOX_CONTROLLER (iter_list_box_controller_get_type ())
#define ITER_LIST_BOX_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxController))
#define ITER_LIST_BOX_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxControllerClass))
#define IS_ITER_LIST_BOX_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ITER_LIST_BOX_CONTROLLER))
#define IS_ITER_LIST_BOX_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ITER_LIST_BOX_CONTROLLER))
#define ITER_LIST_BOX_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxControllerClass))

typedef struct _IterListBoxController IterListBoxController;
typedef struct _IterListBoxControllerClass IterListBoxControllerClass;
typedef struct _IterListBoxControllerPrivate IterListBoxControllerPrivate;
enum  {
	ITER_LIST_BOX_CONTROLLER_0_PROPERTY,
	ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY,
	ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY,
	ITER_LIST_BOX_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* iter_list_box_controller_properties[ITER_LIST_BOX_CONTROLLER_NUM_PROPERTIES];

struct _IterListBoxController {
	GObject parent_instance;
	IterListBoxControllerPrivate * priv;
};

struct _IterListBoxControllerClass {
	GObjectClass parent_class;
};

struct _IterListBoxControllerPrivate {
	gint _length;
	GList* children;
	GtkListBox* _list_box;
};

static gint IterListBoxController_private_offset;
static gpointer iter_list_box_controller_parent_class = NULL;

VALA_EXTERN GType iter_list_box_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IterListBoxController, g_object_unref)
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN IterListBoxController* iter_list_box_controller_new (GtkListBox* list_box);
VALA_EXTERN IterListBoxController* iter_list_box_controller_construct (GType object_type,
                                                           GtkListBox* list_box);
static void iter_list_box_controller_set_list_box (IterListBoxController* self,
                                            GtkListBox* value);
static void iter_list_box_controller_on_add (IterListBoxController* self,
                                      GtkWidget* child);
VALA_EXTERN gint iter_list_box_controller_get_length (IterListBoxController* self);
static void iter_list_box_controller_set_length (IterListBoxController* self,
                                          gint value);
VALA_EXTERN void iter_list_box_controller_remove (IterListBoxController* self,
                                      GtkWidget* child);
static void _iter_list_box_controller_remove_gtk_widget_destroy (GtkWidget* _sender,
                                                          gpointer self);
VALA_EXTERN GList* iter_list_box_controller_get_children (IterListBoxController* self);
VALA_EXTERN void iter_list_box_controller_append (IterListBoxController* self,
                                      GtkWidget* child);
VALA_EXTERN GtkListBox* iter_list_box_controller_get_list_box (IterListBoxController* self);
VALA_EXTERN void iter_list_box_controller_prepend (IterListBoxController* self,
                                       GtkWidget* child);
VALA_EXTERN void iter_list_box_controller_insert (IterListBoxController* self,
                                      GtkWidget* child,
                                      gint position);
static void iter_list_box_controller_finalize (GObject * obj);
static GType iter_list_box_controller_get_type_once (void);
static void _vala_iter_list_box_controller_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_iter_list_box_controller_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
iter_list_box_controller_get_instance_private (IterListBoxController* self)
{
	return G_STRUCT_MEMBER_P (self, IterListBoxController_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_);
}

IterListBoxController*
iter_list_box_controller_construct (GType object_type,
                                    GtkListBox* list_box)
{
	IterListBoxController * self = NULL;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (list_box, gtk_list_box_get_type ()), NULL);
	self = (IterListBoxController*) g_object_new (object_type, NULL);
	iter_list_box_controller_set_list_box (self, list_box);
	return self;
}

IterListBoxController*
iter_list_box_controller_new (GtkListBox* list_box)
{
	return iter_list_box_controller_construct (TYPE_ITER_LIST_BOX_CONTROLLER, list_box);
}

static void
_iter_list_box_controller_remove_gtk_widget_destroy (GtkWidget* _sender,
                                                     gpointer self)
{
	iter_list_box_controller_remove ((IterListBoxController*) self, _sender);
}

static void
iter_list_box_controller_on_add (IterListBoxController* self,
                                 GtkWidget* child)
{
	gint _tmp0_;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()));
	_tmp0_ = self->priv->_length;
	iter_list_box_controller_set_length (self, _tmp0_ + 1);
	g_signal_connect_object (child, "destroy", (GCallback) _iter_list_box_controller_remove_gtk_widget_destroy, self, 0);
}

GList*
iter_list_box_controller_get_children (IterListBoxController* self)
{
	GList* _tmp0_;
	GList* _tmp1_;
	GList* result;
	g_return_val_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->children;
	_tmp1_ = g_list_copy (_tmp0_);
	result = _tmp1_;
	return result;
}

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

void
iter_list_box_controller_append (IterListBoxController* self,
                                 GtkWidget* child)
{
	GtkWidget* _tmp0_;
	GtkListBox* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	gconstpointer _tmp4_;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (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->_list_box;
	_tmp2_ = self->priv->children;
	_tmp3_ = g_list_last (_tmp2_);
	_tmp4_ = _tmp3_->data;
	gtk_list_box_append (_tmp1_, (GtkWidget*) _tmp4_);
	iter_list_box_controller_on_add (self, child);
}

void
iter_list_box_controller_prepend (IterListBoxController* self,
                                  GtkWidget* child)
{
	GtkWidget* _tmp0_;
	GtkListBox* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	gconstpointer _tmp4_;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (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->_list_box;
	_tmp2_ = self->priv->children;
	_tmp3_ = g_list_first (_tmp2_);
	_tmp4_ = _tmp3_->data;
	gtk_list_box_prepend (_tmp1_, (GtkWidget*) _tmp4_);
	iter_list_box_controller_on_add (self, child);
}

void
iter_list_box_controller_insert (IterListBoxController* self,
                                 GtkWidget* child,
                                 gint position)
{
	GtkWidget* _tmp0_;
	GtkListBox* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	gconstpointer _tmp4_;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (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_insert (self->priv->children, _tmp0_, position);
	_tmp1_ = self->priv->_list_box;
	_tmp2_ = self->priv->children;
	_tmp3_ = g_list_nth (_tmp2_, (guint) position);
	_tmp4_ = _tmp3_->data;
	gtk_list_box_insert (_tmp1_, (GtkWidget*) _tmp4_, position);
	iter_list_box_controller_on_add (self, child);
}

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;
}

void
iter_list_box_controller_remove (IterListBoxController* self,
                                 GtkWidget* child)
{
	GtkListBox* _tmp0_;
	gint _tmp1_;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (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_);
	_tmp0_ = self->priv->_list_box;
	gtk_list_box_remove (_tmp0_, child);
	_tmp1_ = self->priv->_length;
	iter_list_box_controller_set_length (self, _tmp1_ - 1);
}

gint
iter_list_box_controller_get_length (IterListBoxController* self)
{
	gint result;
	g_return_val_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self), 0);
	result = self->priv->_length;
	return result;
}

static void
iter_list_box_controller_set_length (IterListBoxController* self,
                                     gint value)
{
	gint old_value;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self));
	old_value = iter_list_box_controller_get_length (self);
	if (old_value != value) {
		self->priv->_length = value;
		g_object_notify_by_pspec ((GObject *) self, iter_list_box_controller_properties[ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY]);
	}
}

GtkListBox*
iter_list_box_controller_get_list_box (IterListBoxController* self)
{
	GtkListBox* result;
	GtkListBox* _tmp0_;
	g_return_val_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->_list_box;
	result = _tmp0_;
	return result;
}

static void
iter_list_box_controller_set_list_box (IterListBoxController* self,
                                       GtkListBox* value)
{
	GtkListBox* old_value;
	g_return_if_fail (IS_ITER_LIST_BOX_CONTROLLER (self));
	old_value = iter_list_box_controller_get_list_box (self);
	if (old_value != value) {
		self->priv->_list_box = value;
		g_object_notify_by_pspec ((GObject *) self, iter_list_box_controller_properties[ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY]);
	}
}

static void
iter_list_box_controller_class_init (IterListBoxControllerClass * klass,
                                     gpointer klass_data)
{
	iter_list_box_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &IterListBoxController_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_iter_list_box_controller_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_iter_list_box_controller_set_property;
	G_OBJECT_CLASS (klass)->finalize = iter_list_box_controller_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY, iter_list_box_controller_properties[ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY] = g_param_spec_int ("length", "length", "length", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY, iter_list_box_controller_properties[ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY] = g_param_spec_object ("list-box", "list-box", "list-box", gtk_list_box_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
iter_list_box_controller_instance_init (IterListBoxController * self,
                                        gpointer klass)
{
	self->priv = iter_list_box_controller_get_instance_private (self);
	self->priv->_length = 0;
	self->priv->children = NULL;
}

static void
iter_list_box_controller_finalize (GObject * obj)
{
	IterListBoxController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxController);
	(self->priv->children == NULL) ? NULL : (self->priv->children = (_g_list_free__g_object_unref0_ (self->priv->children), NULL));
	G_OBJECT_CLASS (iter_list_box_controller_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
iter_list_box_controller_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (IterListBoxControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iter_list_box_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IterListBoxController), 0, (GInstanceInitFunc) iter_list_box_controller_instance_init, NULL };
	GType iter_list_box_controller_type_id;
	iter_list_box_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "IterListBoxController", &g_define_type_info, 0);
	IterListBoxController_private_offset = g_type_add_instance_private (iter_list_box_controller_type_id, sizeof (IterListBoxControllerPrivate));
	return iter_list_box_controller_type_id;
}

GType
iter_list_box_controller_get_type (void)
{
	static gsize iter_list_box_controller_type_id__once = 0;
	if (g_once_init_enter (&iter_list_box_controller_type_id__once)) {
		GType iter_list_box_controller_type_id;
		iter_list_box_controller_type_id = iter_list_box_controller_get_type_once ();
		g_once_init_leave (&iter_list_box_controller_type_id__once, iter_list_box_controller_type_id);
	}
	return iter_list_box_controller_type_id__once;
}

static void
_vala_iter_list_box_controller_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	IterListBoxController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxController);
	switch (property_id) {
		case ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY:
		g_value_set_int (value, iter_list_box_controller_get_length (self));
		break;
		case ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY:
		g_value_set_object (value, iter_list_box_controller_get_list_box (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_iter_list_box_controller_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	IterListBoxController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ITER_LIST_BOX_CONTROLLER, IterListBoxController);
	switch (property_id) {
		case ITER_LIST_BOX_CONTROLLER_LENGTH_PROPERTY:
		iter_list_box_controller_set_length (self, g_value_get_int (value));
		break;
		case ITER_LIST_BOX_CONTROLLER_LIST_BOX_PROPERTY:
		iter_list_box_controller_set_list_box (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

