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

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

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

enum  {
	GRANITE_BOX_0_PROPERTY,
	GRANITE_BOX_CHILD_SPACING_PROPERTY,
	GRANITE_BOX_NUM_PROPERTIES
};
static GParamSpec* granite_box_properties[GRANITE_BOX_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GraniteBoxPrivate {
	GraniteBoxSpacing _child_spacing;
};

static gint GraniteBox_private_offset;
static gpointer granite_box_parent_class = NULL;

static void granite_box_update_child_spacing (GraniteBox* self);
static GObject * granite_box_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
static void _granite_box_update_child_spacing_g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self);
static void granite_box_finalize (GObject * obj);
static GType granite_box_get_type_once (void);
static void _vala_granite_box_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_granite_box_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);

static inline gpointer
granite_box_get_instance_private (GraniteBox* self)
{
	return G_STRUCT_MEMBER_P (self, GraniteBox_private_offset);
}

gchar*
granite_box_spacing_to_string (GraniteBoxSpacing self)
{
	gchar* result;
	switch (self) {
		case GRANITE_BOX_SPACING_HALF:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("border-spacing-half");
			result = _tmp0_;
			return result;
		}
		case GRANITE_BOX_SPACING_SINGLE:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("border-spacing-single");
			result = _tmp1_;
			return result;
		}
		case GRANITE_BOX_SPACING_DOUBLE:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("border-spacing-double");
			result = _tmp2_;
			return result;
		}
		case GRANITE_BOX_SPACING_LINKED:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("linked");
			result = _tmp3_;
			return result;
		}
		default:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("");
			result = _tmp4_;
			return result;
		}
	}
}

static GType
granite_box_spacing_get_type_once (void)
{
	static const GEnumValue values[] = {{GRANITE_BOX_SPACING_NONE, "GRANITE_BOX_SPACING_NONE", "none"}, {GRANITE_BOX_SPACING_HALF, "GRANITE_BOX_SPACING_HALF", "half"}, {GRANITE_BOX_SPACING_SINGLE, "GRANITE_BOX_SPACING_SINGLE", "single"}, {GRANITE_BOX_SPACING_DOUBLE, "GRANITE_BOX_SPACING_DOUBLE", "double"}, {GRANITE_BOX_SPACING_LINKED, "GRANITE_BOX_SPACING_LINKED", "linked"}, {0, NULL, NULL}};
	GType granite_box_spacing_type_id;
	granite_box_spacing_type_id = g_enum_register_static ("GraniteBoxSpacing", values);
	return granite_box_spacing_type_id;
}

GType
granite_box_spacing_get_type (void)
{
	static volatile gsize granite_box_spacing_type_id__once = 0;
	if (g_once_init_enter (&granite_box_spacing_type_id__once)) {
		GType granite_box_spacing_type_id;
		granite_box_spacing_type_id = granite_box_spacing_get_type_once ();
		g_once_init_leave (&granite_box_spacing_type_id__once, granite_box_spacing_type_id);
	}
	return granite_box_spacing_type_id__once;
}

GraniteBoxSpacing
granite_box_get_child_spacing (GraniteBox* self)
{
	GraniteBoxSpacing result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_child_spacing;
	return result;
}

void
granite_box_set_child_spacing (GraniteBox* self,
                               GraniteBoxSpacing value)
{
	GraniteBoxSpacing old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_box_get_child_spacing (self);
	if (old_value != value) {
		self->priv->_child_spacing = value;
		g_object_notify_by_pspec ((GObject *) self, granite_box_properties[GRANITE_BOX_CHILD_SPACING_PROPERTY]);
	}
}

/**
     * Constructs a new {@link Granite.Box}
     */
GraniteBox*
granite_box_construct (GType object_type,
                       GtkOrientation orientation,
                       GraniteBoxSpacing child_spacing)
{
	GraniteBox * self = NULL;
	self = (GraniteBox*) g_object_new (object_type, "orientation", orientation, "child-spacing", child_spacing, NULL);
	return self;
}

GraniteBox*
granite_box_new (GtkOrientation orientation,
                 GraniteBoxSpacing child_spacing)
{
	return granite_box_construct (GRANITE_TYPE_BOX, orientation, child_spacing);
}

static void
granite_box_update_child_spacing (GraniteBox* self)
{
	GEnumClass* enum_class = NULL;
	GTypeClass* _tmp0_;
	GEnumClass* _tmp1_;
	GEnumValue* _tmp2_;
	gint _tmp2__length1;
	GraniteBoxSpacing _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	GraniteBoxSpacing _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_type_class_peek (GRANITE_BOX_TYPE_SPACING);
	enum_class = (GEnumClass*) _tmp0_;
	_tmp1_ = enum_class;
	_tmp2_ = _tmp1_->values;
	_tmp2__length1 = _tmp1_->n_values;
	{
		GEnumValue* val_collection = NULL;
		gint val_collection_length1 = 0;
		gint _val_collection_size_ = 0;
		gint val_it = 0;
		val_collection = _tmp2_;
		val_collection_length1 = _tmp2__length1;
		for (val_it = 0; val_it < val_collection_length1; val_it = val_it + 1) {
			GEnumValue val = {0};
			val = val_collection[val_it];
			{
				gchar* css_class = NULL;
				GEnumValue _tmp3_;
				gchar* _tmp4_;
				gboolean _tmp5_ = FALSE;
				const gchar* _tmp6_;
				_tmp3_ = val;
				_tmp4_ = granite_box_spacing_to_string ((GraniteBoxSpacing) _tmp3_.value);
				css_class = _tmp4_;
				_tmp6_ = css_class;
				if (g_strcmp0 (_tmp6_, "") != 0) {
					const gchar* _tmp7_;
					_tmp7_ = css_class;
					_tmp5_ = gtk_widget_has_css_class ((GtkWidget*) self, _tmp7_);
				} else {
					_tmp5_ = FALSE;
				}
				if (_tmp5_) {
					const gchar* _tmp8_;
					_tmp8_ = css_class;
					gtk_widget_remove_css_class ((GtkWidget*) self, _tmp8_);
				}
				_g_free0 (css_class);
			}
		}
	}
	_tmp9_ = self->priv->_child_spacing;
	_tmp10_ = granite_box_spacing_to_string (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strcmp0 (_tmp11_, "") == 0;
	_g_free0 (_tmp11_);
	if (_tmp12_) {
		return;
	}
	_tmp13_ = self->priv->_child_spacing;
	_tmp14_ = granite_box_spacing_to_string (_tmp13_);
	_tmp15_ = _tmp14_;
	gtk_widget_add_css_class ((GtkWidget*) self, _tmp15_);
	_g_free0 (_tmp15_);
}

static void
_granite_box_update_child_spacing_g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self)
{
	granite_box_update_child_spacing ((GraniteBox*) self);
}

static GObject *
granite_box_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraniteBox * self;
	parent_class = G_OBJECT_CLASS (granite_box_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_BOX, GraniteBox);
	granite_box_update_child_spacing (self);
	g_signal_connect_object ((GObject*) self, "notify::child-spacing", (GCallback) _granite_box_update_child_spacing_g_object_notify, self, 0);
	return obj;
}

static void
granite_box_class_init (GraniteBoxClass * klass,
                        gpointer klass_data)
{
	granite_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraniteBox_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_granite_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_granite_box_set_property;
	G_OBJECT_CLASS (klass)->constructor = granite_box_constructor;
	G_OBJECT_CLASS (klass)->finalize = granite_box_finalize;
	/**
	     * How far apart to space children of #this
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_BOX_CHILD_SPACING_PROPERTY, granite_box_properties[GRANITE_BOX_CHILD_SPACING_PROPERTY] = g_param_spec_enum ("child-spacing", "child-spacing", "child-spacing", GRANITE_BOX_TYPE_SPACING, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
granite_box_instance_init (GraniteBox * self,
                           gpointer klass)
{
	self->priv = granite_box_get_instance_private (self);
}

static void
granite_box_finalize (GObject * obj)
{
	GraniteBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_BOX, GraniteBox);
	G_OBJECT_CLASS (granite_box_parent_class)->finalize (obj);
}

/**
 * A {@link Gtk.Box} subclass that has built-in properties for child spacing
 *
 * @since 7.7.0
 */
static GType
granite_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteBox), 0, (GInstanceInitFunc) granite_box_instance_init, NULL };
	GType granite_box_type_id;
	granite_box_type_id = g_type_register_static (gtk_box_get_type (), "GraniteBox", &g_define_type_info, 0);
	GraniteBox_private_offset = g_type_add_instance_private (granite_box_type_id, sizeof (GraniteBoxPrivate));
	return granite_box_type_id;
}

GType
granite_box_get_type (void)
{
	static volatile gsize granite_box_type_id__once = 0;
	if (g_once_init_enter (&granite_box_type_id__once)) {
		GType granite_box_type_id;
		granite_box_type_id = granite_box_get_type_once ();
		g_once_init_leave (&granite_box_type_id__once, granite_box_type_id);
	}
	return granite_box_type_id__once;
}

static void
_vala_granite_box_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	GraniteBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_BOX, GraniteBox);
	switch (property_id) {
		case GRANITE_BOX_CHILD_SPACING_PROPERTY:
		g_value_set_enum (value, granite_box_get_child_spacing (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_granite_box_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	GraniteBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_BOX, GraniteBox);
	switch (property_id) {
		case GRANITE_BOX_CHILD_SPACING_PROPERTY:
		granite_box_set_child_spacing (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

