/* item.c generated by valac 0.56.19, the Vala compiler
 * generated from item.vala, do not modify */

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include "graphs.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.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  {
	GRAPHS_ITEM_0_PROPERTY,
	GRAPHS_ITEM_NAME_PROPERTY,
	GRAPHS_ITEM_COLOR_PROPERTY,
	GRAPHS_ITEM_ALPHA_PROPERTY,
	GRAPHS_ITEM_SELECTED_PROPERTY,
	GRAPHS_ITEM_XLABEL_PROPERTY,
	GRAPHS_ITEM_YLABEL_PROPERTY,
	GRAPHS_ITEM_XPOSITION_PROPERTY,
	GRAPHS_ITEM_YPOSITION_PROPERTY,
	GRAPHS_ITEM_UUID_PROPERTY,
	GRAPHS_ITEM_NUM_PROPERTIES
};
static GParamSpec* graphs_item_properties[GRAPHS_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GraphsItemPrivate {
	gchar* _name;
	gchar* _color;
	gfloat _alpha;
	gboolean _selected;
	gchar* _xlabel;
	gchar* _ylabel;
	gint _xposition;
	gint _yposition;
	gchar* _uuid;
};

static gint GraphsItem_private_offset;
static gpointer graphs_item_parent_class = NULL;

static void graphs_item_finalize (GObject * obj);
static GType graphs_item_get_type_once (void);
static void _vala_graphs_item_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_graphs_item_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
graphs_item_get_instance_private (GraphsItem* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsItem_private_offset);
}

void
graphs_item_get_rgba (GraphsItem* self,
                      GdkRGBA* result)
{
	GdkRGBA rgba = {0};
	const gchar* _tmp0_;
	GdkRGBA _tmp1_ = {0};
	gfloat _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_color;
	graphs_tools_hex_to_rgba (_tmp0_, &_tmp1_);
	rgba = _tmp1_;
	_tmp2_ = self->priv->_alpha;
	rgba.alpha = _tmp2_;
	*result = rgba;
	return;
}

void
graphs_item_set_rgba (GraphsItem* self,
                      GdkRGBA* rgba)
{
	GdkRGBA _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GdkRGBA _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (rgba != NULL);
	_tmp0_ = *rgba;
	_tmp1_ = graphs_tools_rgba_to_hex (&_tmp0_);
	_tmp2_ = _tmp1_;
	graphs_item_set_color (self, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = *rgba;
	graphs_item_set_alpha (self, _tmp3_.alpha);
}

GraphsItem*
graphs_item_construct (GType object_type)
{
	GraphsItem * self = NULL;
	self = (GraphsItem*) g_object_new (object_type, NULL);
	return self;
}

GraphsItem*
graphs_item_new (void)
{
	return graphs_item_construct (GRAPHS_TYPE_ITEM);
}

const gchar*
graphs_item_get_name (GraphsItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
graphs_item_set_name (GraphsItem* self,
                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_NAME_PROPERTY]);
	}
}

const gchar*
graphs_item_get_color (GraphsItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_color;
	result = _tmp0_;
	return result;
}

void
graphs_item_set_color (GraphsItem* self,
                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_color (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_color);
		self->priv->_color = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_COLOR_PROPERTY]);
	}
}

gfloat
graphs_item_get_alpha (GraphsItem* self)
{
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	result = self->priv->_alpha;
	return result;
}

void
graphs_item_set_alpha (GraphsItem* self,
                       gfloat value)
{
	gfloat old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_alpha (self);
	if (old_value != value) {
		self->priv->_alpha = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_ALPHA_PROPERTY]);
	}
}

gboolean
graphs_item_get_selected (GraphsItem* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selected;
	return result;
}

void
graphs_item_set_selected (GraphsItem* self,
                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_selected (self);
	if (old_value != value) {
		self->priv->_selected = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_SELECTED_PROPERTY]);
	}
}

const gchar*
graphs_item_get_xlabel (GraphsItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_xlabel;
	result = _tmp0_;
	return result;
}

void
graphs_item_set_xlabel (GraphsItem* self,
                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_xlabel (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_xlabel);
		self->priv->_xlabel = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_XLABEL_PROPERTY]);
	}
}

const gchar*
graphs_item_get_ylabel (GraphsItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_ylabel;
	result = _tmp0_;
	return result;
}

void
graphs_item_set_ylabel (GraphsItem* self,
                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_ylabel (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_ylabel);
		self->priv->_ylabel = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_YLABEL_PROPERTY]);
	}
}

gint
graphs_item_get_xposition (GraphsItem* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_xposition;
	return result;
}

void
graphs_item_set_xposition (GraphsItem* self,
                           gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_xposition (self);
	if (old_value != value) {
		self->priv->_xposition = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_XPOSITION_PROPERTY]);
	}
}

gint
graphs_item_get_yposition (GraphsItem* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_yposition;
	return result;
}

void
graphs_item_set_yposition (GraphsItem* self,
                           gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_yposition (self);
	if (old_value != value) {
		self->priv->_yposition = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_YPOSITION_PROPERTY]);
	}
}

const gchar*
graphs_item_get_uuid (GraphsItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_uuid;
	result = _tmp0_;
	return result;
}

void
graphs_item_set_uuid (GraphsItem* self,
                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_get_uuid (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_uuid);
		self->priv->_uuid = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_properties[GRAPHS_ITEM_UUID_PROPERTY]);
	}
}

static void
graphs_item_class_init (GraphsItemClass * klass,
                        gpointer klass_data)
{
	graphs_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_NAME_PROPERTY, graphs_item_properties[GRAPHS_ITEM_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_COLOR_PROPERTY, graphs_item_properties[GRAPHS_ITEM_COLOR_PROPERTY] = g_param_spec_string ("color", "color", "color", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_ALPHA_PROPERTY, graphs_item_properties[GRAPHS_ITEM_ALPHA_PROPERTY] = g_param_spec_float ("alpha", "alpha", "alpha", -G_MAXFLOAT, G_MAXFLOAT, (gfloat) 1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_SELECTED_PROPERTY, graphs_item_properties[GRAPHS_ITEM_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_XLABEL_PROPERTY, graphs_item_properties[GRAPHS_ITEM_XLABEL_PROPERTY] = g_param_spec_string ("xlabel", "xlabel", "xlabel", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_YLABEL_PROPERTY, graphs_item_properties[GRAPHS_ITEM_YLABEL_PROPERTY] = g_param_spec_string ("ylabel", "ylabel", "ylabel", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_XPOSITION_PROPERTY, graphs_item_properties[GRAPHS_ITEM_XPOSITION_PROPERTY] = g_param_spec_int ("xposition", "xposition", "xposition", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_YPOSITION_PROPERTY, graphs_item_properties[GRAPHS_ITEM_YPOSITION_PROPERTY] = g_param_spec_int ("yposition", "yposition", "yposition", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_UUID_PROPERTY, graphs_item_properties[GRAPHS_ITEM_UUID_PROPERTY] = g_param_spec_string ("uuid", "uuid", "uuid", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
graphs_item_instance_init (GraphsItem * self,
                           gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	self->priv = graphs_item_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_name = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_color = _tmp1_;
	self->priv->_alpha = (gfloat) 1;
	self->priv->_selected = TRUE;
	_tmp2_ = g_strdup ("");
	self->priv->_xlabel = _tmp2_;
	_tmp3_ = g_strdup ("");
	self->priv->_ylabel = _tmp3_;
	self->priv->_xposition = 0;
	self->priv->_yposition = 0;
	_tmp4_ = g_uuid_string_random ();
	self->priv->_uuid = _tmp4_;
}

static void
graphs_item_finalize (GObject * obj)
{
	GraphsItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_ITEM, GraphsItem);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_color);
	_g_free0 (self->priv->_xlabel);
	_g_free0 (self->priv->_ylabel);
	_g_free0 (self->priv->_uuid);
	G_OBJECT_CLASS (graphs_item_parent_class)->finalize (obj);
}

/**
     * Base item class
     */
static GType
graphs_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsItem), 0, (GInstanceInitFunc) graphs_item_instance_init, NULL };
	GType graphs_item_type_id;
	graphs_item_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsItem", &g_define_type_info, 0);
	GraphsItem_private_offset = g_type_add_instance_private (graphs_item_type_id, sizeof (GraphsItemPrivate));
	return graphs_item_type_id;
}

GType
graphs_item_get_type (void)
{
	static volatile gsize graphs_item_type_id__once = 0;
	if (g_once_init_enter (&graphs_item_type_id__once)) {
		GType graphs_item_type_id;
		graphs_item_type_id = graphs_item_get_type_once ();
		g_once_init_leave (&graphs_item_type_id__once, graphs_item_type_id);
	}
	return graphs_item_type_id__once;
}

static void
_vala_graphs_item_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	GraphsItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_ITEM, GraphsItem);
	switch (property_id) {
		case GRAPHS_ITEM_NAME_PROPERTY:
		g_value_set_string (value, graphs_item_get_name (self));
		break;
		case GRAPHS_ITEM_COLOR_PROPERTY:
		g_value_set_string (value, graphs_item_get_color (self));
		break;
		case GRAPHS_ITEM_ALPHA_PROPERTY:
		g_value_set_float (value, graphs_item_get_alpha (self));
		break;
		case GRAPHS_ITEM_SELECTED_PROPERTY:
		g_value_set_boolean (value, graphs_item_get_selected (self));
		break;
		case GRAPHS_ITEM_XLABEL_PROPERTY:
		g_value_set_string (value, graphs_item_get_xlabel (self));
		break;
		case GRAPHS_ITEM_YLABEL_PROPERTY:
		g_value_set_string (value, graphs_item_get_ylabel (self));
		break;
		case GRAPHS_ITEM_XPOSITION_PROPERTY:
		g_value_set_int (value, graphs_item_get_xposition (self));
		break;
		case GRAPHS_ITEM_YPOSITION_PROPERTY:
		g_value_set_int (value, graphs_item_get_yposition (self));
		break;
		case GRAPHS_ITEM_UUID_PROPERTY:
		g_value_set_string (value, graphs_item_get_uuid (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_item_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	GraphsItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_ITEM, GraphsItem);
	switch (property_id) {
		case GRAPHS_ITEM_NAME_PROPERTY:
		graphs_item_set_name (self, g_value_get_string (value));
		break;
		case GRAPHS_ITEM_COLOR_PROPERTY:
		graphs_item_set_color (self, g_value_get_string (value));
		break;
		case GRAPHS_ITEM_ALPHA_PROPERTY:
		graphs_item_set_alpha (self, g_value_get_float (value));
		break;
		case GRAPHS_ITEM_SELECTED_PROPERTY:
		graphs_item_set_selected (self, g_value_get_boolean (value));
		break;
		case GRAPHS_ITEM_XLABEL_PROPERTY:
		graphs_item_set_xlabel (self, g_value_get_string (value));
		break;
		case GRAPHS_ITEM_YLABEL_PROPERTY:
		graphs_item_set_ylabel (self, g_value_get_string (value));
		break;
		case GRAPHS_ITEM_XPOSITION_PROPERTY:
		graphs_item_set_xposition (self, g_value_get_int (value));
		break;
		case GRAPHS_ITEM_YPOSITION_PROPERTY:
		graphs_item_set_yposition (self, g_value_get_int (value));
		break;
		case GRAPHS_ITEM_UUID_PROPERTY:
		graphs_item_set_uuid (self, g_value_get_string (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;
}

