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

/*
 * Copyright 2024 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "granite-7.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.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

enum  {
	GRANITE_BIN_0_PROPERTY,
	GRANITE_BIN_CHILD_PROPERTY,
	GRANITE_BIN_NUM_PROPERTIES
};
static GParamSpec* granite_bin_properties[GRANITE_BIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GraniteBinPrivate {
	GtkWidget* _child;
};

static gint GraniteBin_private_offset;
static gpointer granite_bin_parent_class = NULL;

static void granite_bin_finalize (GObject * obj);
static GType granite_bin_get_type_once (void);
static void _vala_granite_bin_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_granite_bin_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);

static inline gpointer
granite_bin_get_instance_private (GraniteBin* self)
{
	return G_STRUCT_MEMBER_P (self, GraniteBin_private_offset);
}

GtkWidget*
granite_bin_get_child (GraniteBin* 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
granite_bin_set_child (GraniteBin* self,
                       GtkWidget* value)
{
	gboolean _tmp0_ = FALSE;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	g_return_if_fail (self != NULL);
	if (value != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = gtk_widget_get_parent (value);
		_tmp0_ = _tmp1_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		g_critical ("Bin.vala:29: Tried to set a widget as child that already has a parent.");
		return;
	}
	_tmp2_ = self->priv->_child;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp3_;
		_tmp3_ = self->priv->_child;
		gtk_widget_unparent (_tmp3_);
	}
	_tmp4_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_child);
	self->priv->_child = _tmp4_;
	_tmp5_ = self->priv->_child;
	if (_tmp5_ != NULL) {
		GtkWidget* _tmp6_;
		_tmp6_ = self->priv->_child;
		gtk_widget_set_parent (_tmp6_, (GtkWidget*) self);
	}
	g_object_notify_by_pspec ((GObject *) self, granite_bin_properties[GRANITE_BIN_CHILD_PROPERTY]);
}

GraniteBin*
granite_bin_construct (GType object_type)
{
	GraniteBin * self = NULL;
	self = (GraniteBin*) g_object_new (object_type, NULL);
	return self;
}

GraniteBin*
granite_bin_new (void)
{
	return granite_bin_construct (GRANITE_TYPE_BIN);
}

static void
granite_bin_base_init (GraniteBinClass * klass)
{
	gtk_widget_class_set_layout_manager_type (GTK_WIDGET_CLASS (klass), gtk_bin_layout_get_type ());
}

static void
granite_bin_class_init (GraniteBinClass * klass,
                        gpointer klass_data)
{
	granite_bin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraniteBin_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_granite_bin_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_granite_bin_set_property;
	G_OBJECT_CLASS (klass)->finalize = granite_bin_finalize;
	/**
	     * The child widget of the bin.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_BIN_CHILD_PROPERTY, granite_bin_properties[GRANITE_BIN_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
granite_bin_instance_init (GraniteBin * self,
                           gpointer klass)
{
	self->priv = granite_bin_get_instance_private (self);
}

static void
granite_bin_finalize (GObject * obj)
{
	GraniteBin * self;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_BIN, GraniteBin);
	_tmp0_ = granite_bin_get_child (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		_tmp2_ = granite_bin_get_child (self);
		_tmp3_ = _tmp2_;
		gtk_widget_unparent (_tmp3_);
	}
	_g_object_unref0 (self->priv->_child);
	G_OBJECT_CLASS (granite_bin_parent_class)->finalize (obj);
}

/**
 * This widget is a simple container that can hold a single child widget.
 * It is mostly useful for deriving subclasses.
 *
 * @since 7.6.0
 */
static GType
granite_bin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteBinClass), (GBaseInitFunc) granite_bin_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_bin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteBin), 0, (GInstanceInitFunc) granite_bin_instance_init, NULL };
	GType granite_bin_type_id;
	granite_bin_type_id = g_type_register_static (gtk_widget_get_type (), "GraniteBin", &g_define_type_info, 0);
	GraniteBin_private_offset = g_type_add_instance_private (granite_bin_type_id, sizeof (GraniteBinPrivate));
	return granite_bin_type_id;
}

GType
granite_bin_get_type (void)
{
	static volatile gsize granite_bin_type_id__once = 0;
	if (g_once_init_enter (&granite_bin_type_id__once)) {
		GType granite_bin_type_id;
		granite_bin_type_id = granite_bin_get_type_once ();
		g_once_init_leave (&granite_bin_type_id__once, granite_bin_type_id);
	}
	return granite_bin_type_id__once;
}

static void
_vala_granite_bin_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	GraniteBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_BIN, GraniteBin);
	switch (property_id) {
		case GRANITE_BIN_CHILD_PROPERTY:
		g_value_set_object (value, granite_bin_get_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_granite_bin_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	GraniteBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_BIN, GraniteBin);
	switch (property_id) {
		case GRANITE_BIN_CHILD_PROPERTY:
		granite_bin_set_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

