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

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include "gnome-games.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <cairo-gobject.h>
#include <glib-object.h>
#include <string.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  {
	GAMES_DISPLAY_BIN_0_PROPERTY,
	GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY,
	GAMES_DISPLAY_BIN_NUM_PROPERTIES
};
static GParamSpec* games_display_bin_properties[GAMES_DISPLAY_BIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesDisplayBinPrivate {
	gint _child_width;
};

static gint GamesDisplayBin_private_offset;
static gpointer games_display_bin_parent_class = NULL;

static void games_display_bin_real_get_preferred_width (GtkWidget* base,
                                                 gint* minimum,
                                                 gint* natural);
static void games_display_bin_real_size_allocate (GtkWidget* base,
                                           GtkAllocation* alloc);
static void games_display_bin_finalize (GObject * obj);
static GType games_display_bin_get_type_once (void);
static void _vala_games_display_bin_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_games_display_bin_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_display_bin_get_instance_private (GamesDisplayBin* self)
{
	return G_STRUCT_MEMBER_P (self, GamesDisplayBin_private_offset);
}

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

static void
games_display_bin_real_get_preferred_width (GtkWidget* base,
                                            gint* minimum,
                                            gint* natural)
{
	GamesDisplayBin * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	GtkWidget* child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	self = (GamesDisplayBin*) base;
	_tmp0_ = gtk_bin_get_child ((GtkBin*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	child = _tmp1_;
	_vala_minimum = 0;
	_tmp2_ = child;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp3_;
		gint _tmp4_ = 0;
		_tmp3_ = child;
		gtk_widget_get_preferred_width (_tmp3_, NULL, &_tmp4_);
		_vala_natural = _tmp4_;
	} else {
		_vala_natural = 0;
	}
	_g_object_unref0 (child);
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
}

static void
games_display_bin_real_size_allocate (GtkWidget* base,
                                      GtkAllocation* alloc)
{
	GamesDisplayBin * self;
	GtkAllocation _tmp0_;
	gint delta = 0;
	GtkAllocation _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GtkWidget* child = NULL;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	self = (GamesDisplayBin*) base;
	g_return_if_fail (alloc != NULL);
	_tmp0_ = *alloc;
	GTK_WIDGET_CLASS (games_display_bin_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_event_box_get_type (), GtkEventBox), &_tmp0_);
	_tmp1_ = *alloc;
	_tmp2_ = games_display_bin_get_child_width (self);
	_tmp3_ = _tmp2_;
	delta = _tmp1_.width - _tmp3_;
	_tmp4_ = gtk_bin_get_child ((GtkBin*) self);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	child = _tmp5_;
	_tmp6_ = child;
	if (_tmp6_ != NULL) {
		GtkWidget* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		GtkAllocation _tmp10_;
		GtkAllocation _tmp11_ = {0};
		_tmp7_ = child;
		_tmp8_ = games_display_bin_get_child_width (self);
		_tmp9_ = _tmp8_;
		_tmp10_ = *alloc;
		_tmp11_.x = delta / 2;
		_tmp11_.y = 0;
		_tmp11_.width = _tmp9_;
		_tmp11_.height = _tmp10_.height;
		gtk_widget_size_allocate (_tmp7_, &_tmp11_);
	}
	_g_object_unref0 (child);
}

GamesDisplayBin*
games_display_bin_construct (GType object_type)
{
	GamesDisplayBin * self = NULL;
	self = (GamesDisplayBin*) g_object_new (object_type, NULL);
	return self;
}

GamesDisplayBin*
games_display_bin_new (void)
{
	return games_display_bin_construct (GAMES_TYPE_DISPLAY_BIN);
}

gint
games_display_bin_get_child_width (GamesDisplayBin* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_child_width;
	return result;
}

void
games_display_bin_set_child_width (GamesDisplayBin* self,
                                   gint value)
{
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = games_display_bin_get_child_width (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == value) {
		return;
	}
	self->priv->_child_width = value;
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, games_display_bin_properties[GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY]);
}

static void
games_display_bin_class_init (GamesDisplayBinClass * klass,
                              gpointer klass_data)
{
	games_display_bin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesDisplayBin_private_offset);
	((GtkWidgetClass *) klass)->get_preferred_width = (void (*) (GtkWidget*, gint*, gint*)) games_display_bin_real_get_preferred_width;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, GtkAllocation*)) games_display_bin_real_size_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_games_display_bin_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_display_bin_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_display_bin_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY, games_display_bin_properties[GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY] = g_param_spec_int ("child-width", "child-width", "child-width", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
games_display_bin_instance_init (GamesDisplayBin * self,
                                 gpointer klass)
{
	self->priv = games_display_bin_get_instance_private (self);
}

static void
games_display_bin_finalize (GObject * obj)
{
	GamesDisplayBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_DISPLAY_BIN, GamesDisplayBin);
	G_OBJECT_CLASS (games_display_bin_parent_class)->finalize (obj);
}

static GType
games_display_bin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesDisplayBinClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_display_bin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesDisplayBin), 0, (GInstanceInitFunc) games_display_bin_instance_init, NULL };
	GType games_display_bin_type_id;
	games_display_bin_type_id = g_type_register_static (gtk_event_box_get_type (), "GamesDisplayBin", &g_define_type_info, 0);
	GamesDisplayBin_private_offset = g_type_add_instance_private (games_display_bin_type_id, sizeof (GamesDisplayBinPrivate));
	return games_display_bin_type_id;
}

GType
games_display_bin_get_type (void)
{
	static volatile gsize games_display_bin_type_id__once = 0;
	if (g_once_init_enter (&games_display_bin_type_id__once)) {
		GType games_display_bin_type_id;
		games_display_bin_type_id = games_display_bin_get_type_once ();
		g_once_init_leave (&games_display_bin_type_id__once, games_display_bin_type_id);
	}
	return games_display_bin_type_id__once;
}

static void
_vala_games_display_bin_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	GamesDisplayBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_DISPLAY_BIN, GamesDisplayBin);
	switch (property_id) {
		case GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY:
		g_value_set_int (value, games_display_bin_get_child_width (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_display_bin_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	GamesDisplayBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_DISPLAY_BIN, GamesDisplayBin);
	switch (property_id) {
		case GAMES_DISPLAY_BIN_CHILD_WIDTH_PROPERTY:
		games_display_bin_set_child_width (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

