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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "planify.h"
#include <stdlib.h>
#include <string.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  {
	OBJECTS_FILTERS_FILTER_ITEM_0_PROPERTY,
	OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY,
	OBJECTS_FILTERS_FILTER_ITEM_NAME_PROPERTY,
	OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY,
	OBJECTS_FILTERS_FILTER_ITEM_ID_PROPERTY,
	OBJECTS_FILTERS_FILTER_ITEM_NUM_PROPERTIES
};
static GParamSpec* objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ObjectsFiltersFilterItemPrivate {
	FilterItemType _filter_type;
	gchar* _name;
	gchar* _value;
	gchar* _id;
};

static gint ObjectsFiltersFilterItem_private_offset;
static gpointer objects_filters_filter_item_parent_class = NULL;

static void objects_filters_filter_item_finalize (GObject * obj);
static GType objects_filters_filter_item_get_type_once (void);
static void _vala_objects_filters_filter_item_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_objects_filters_filter_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
objects_filters_filter_item_get_instance_private (ObjectsFiltersFilterItem* self)
{
	return G_STRUCT_MEMBER_P (self, ObjectsFiltersFilterItem_private_offset);
}

ObjectsFiltersFilterItem*
objects_filters_filter_item_construct (GType object_type)
{
	ObjectsFiltersFilterItem * self = NULL;
	self = (ObjectsFiltersFilterItem*) g_object_new (object_type, NULL);
	return self;
}

ObjectsFiltersFilterItem*
objects_filters_filter_item_new (void)
{
	return objects_filters_filter_item_construct (OBJECTS_FILTERS_TYPE_FILTER_ITEM);
}

FilterItemType
objects_filters_filter_item_get_filter_type (ObjectsFiltersFilterItem* self)
{
	FilterItemType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_filter_type;
	return result;
}

void
objects_filters_filter_item_set_filter_type (ObjectsFiltersFilterItem* self,
                                             FilterItemType value)
{
	FilterItemType old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_filters_filter_item_get_filter_type (self);
	if (old_value != value) {
		self->priv->_filter_type = value;
		g_object_notify_by_pspec ((GObject *) self, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY]);
	}
}

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

void
objects_filters_filter_item_set_name (ObjectsFiltersFilterItem* self,
                                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_filters_filter_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, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_NAME_PROPERTY]);
	}
}

const gchar*
objects_filters_filter_item_get_value (ObjectsFiltersFilterItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_value;
	result = _tmp0_;
	return result;
}

void
objects_filters_filter_item_set_value (ObjectsFiltersFilterItem* self,
                                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_filters_filter_item_get_value (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_value);
		self->priv->_value = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY]);
	}
}

const gchar*
objects_filters_filter_item_get_id (ObjectsFiltersFilterItem* self)
{
	const gchar* result;
	FilterItemType _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	FilterItemType _tmp8_;
	const gchar* _tmp12_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_filter_type;
	_tmp1_ = filter_item_type_to_string (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "-", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_value;
	_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
	_g_free0 (self->priv->_id);
	self->priv->_id = _tmp6_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp8_ = self->priv->_filter_type;
	if (_tmp8_ == FILTER_ITEM_TYPE_DUE_DATE) {
		_tmp7_ = TRUE;
	} else {
		FilterItemType _tmp9_;
		_tmp9_ = self->priv->_filter_type;
		_tmp7_ = _tmp9_ == FILTER_ITEM_TYPE_SECTION;
	}
	if (_tmp7_) {
		FilterItemType _tmp10_;
		gchar* _tmp11_;
		_tmp10_ = self->priv->_filter_type;
		_tmp11_ = filter_item_type_to_string (_tmp10_);
		_g_free0 (self->priv->_id);
		self->priv->_id = _tmp11_;
	}
	_tmp12_ = self->priv->_id;
	result = _tmp12_;
	return result;
}

static void
objects_filters_filter_item_class_init (ObjectsFiltersFilterItemClass * klass,
                                        gpointer klass_data)
{
	objects_filters_filter_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ObjectsFiltersFilterItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_objects_filters_filter_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_objects_filters_filter_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = objects_filters_filter_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY] = g_param_spec_enum ("filter-type", "filter-type", "filter-type", TYPE_FILTER_ITEM_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_FILTERS_FILTER_ITEM_NAME_PROPERTY, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_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), OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_FILTERS_FILTER_ITEM_ID_PROPERTY, objects_filters_filter_item_properties[OBJECTS_FILTERS_FILTER_ITEM_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
objects_filters_filter_item_instance_init (ObjectsFiltersFilterItem * self,
                                           gpointer klass)
{
	self->priv = objects_filters_filter_item_get_instance_private (self);
}

static void
objects_filters_filter_item_finalize (GObject * obj)
{
	ObjectsFiltersFilterItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_FILTERS_TYPE_FILTER_ITEM, ObjectsFiltersFilterItem);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_value);
	_g_free0 (self->priv->_id);
	G_OBJECT_CLASS (objects_filters_filter_item_parent_class)->finalize (obj);
}

static GType
objects_filters_filter_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ObjectsFiltersFilterItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) objects_filters_filter_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ObjectsFiltersFilterItem), 0, (GInstanceInitFunc) objects_filters_filter_item_instance_init, NULL };
	GType objects_filters_filter_item_type_id;
	objects_filters_filter_item_type_id = g_type_register_static (G_TYPE_OBJECT, "ObjectsFiltersFilterItem", &g_define_type_info, 0);
	ObjectsFiltersFilterItem_private_offset = g_type_add_instance_private (objects_filters_filter_item_type_id, sizeof (ObjectsFiltersFilterItemPrivate));
	return objects_filters_filter_item_type_id;
}

GType
objects_filters_filter_item_get_type (void)
{
	static volatile gsize objects_filters_filter_item_type_id__once = 0;
	if (g_once_init_enter (&objects_filters_filter_item_type_id__once)) {
		GType objects_filters_filter_item_type_id;
		objects_filters_filter_item_type_id = objects_filters_filter_item_get_type_once ();
		g_once_init_leave (&objects_filters_filter_item_type_id__once, objects_filters_filter_item_type_id);
	}
	return objects_filters_filter_item_type_id__once;
}

static void
_vala_objects_filters_filter_item_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	ObjectsFiltersFilterItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_FILTERS_TYPE_FILTER_ITEM, ObjectsFiltersFilterItem);
	switch (property_id) {
		case OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY:
		g_value_set_enum (value, objects_filters_filter_item_get_filter_type (self));
		break;
		case OBJECTS_FILTERS_FILTER_ITEM_NAME_PROPERTY:
		g_value_set_string (value, objects_filters_filter_item_get_name (self));
		break;
		case OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY:
		g_value_set_string (value, objects_filters_filter_item_get_value (self));
		break;
		case OBJECTS_FILTERS_FILTER_ITEM_ID_PROPERTY:
		g_value_set_string (value, objects_filters_filter_item_get_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_objects_filters_filter_item_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	ObjectsFiltersFilterItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_FILTERS_TYPE_FILTER_ITEM, ObjectsFiltersFilterItem);
	switch (property_id) {
		case OBJECTS_FILTERS_FILTER_ITEM_FILTER_TYPE_PROPERTY:
		objects_filters_filter_item_set_filter_type (self, g_value_get_enum (value));
		break;
		case OBJECTS_FILTERS_FILTER_ITEM_NAME_PROPERTY:
		objects_filters_filter_item_set_name (self, g_value_get_string (value));
		break;
		case OBJECTS_FILTERS_FILTER_ITEM_VALUE_PROPERTY:
		objects_filters_filter_item_set_value (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;
}

