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

/*
* Copyright (c) 2017 Robert San <robertsanseries@gmail.com>
*
* 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 2 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
*/

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define CIANO_OBJECTS_TYPE_ITEM_CONVERSION (ciano_objects_item_conversion_get_type ())
#define CIANO_OBJECTS_ITEM_CONVERSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CIANO_OBJECTS_TYPE_ITEM_CONVERSION, CianoObjectsItemConversion))
#define CIANO_OBJECTS_ITEM_CONVERSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CIANO_OBJECTS_TYPE_ITEM_CONVERSION, CianoObjectsItemConversionClass))
#define CIANO_OBJECTS_IS_ITEM_CONVERSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CIANO_OBJECTS_TYPE_ITEM_CONVERSION))
#define CIANO_OBJECTS_IS_ITEM_CONVERSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CIANO_OBJECTS_TYPE_ITEM_CONVERSION))
#define CIANO_OBJECTS_ITEM_CONVERSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CIANO_OBJECTS_TYPE_ITEM_CONVERSION, CianoObjectsItemConversionClass))

typedef struct _CianoObjectsItemConversion CianoObjectsItemConversion;
typedef struct _CianoObjectsItemConversionClass CianoObjectsItemConversionClass;
typedef struct _CianoObjectsItemConversionPrivate CianoObjectsItemConversionPrivate;
typedef enum  {
	CIANO_ENUMS_TYPE_ITEM_ENUM_VIDEO,
	CIANO_ENUMS_TYPE_ITEM_ENUM_MUSIC,
	CIANO_ENUMS_TYPE_ITEM_ENUM_IMAGE
} CianoEnumsTypeItemEnum;

#define CIANO_ENUMS_TYPE_TYPE_ITEM_ENUM (ciano_enums_type_item_enum_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _CianoObjectsParamSpecItemConversion CianoObjectsParamSpecItemConversion;

struct _CianoObjectsItemConversion {
	GTypeInstance parent_instance;
	volatile int ref_count;
	CianoObjectsItemConversionPrivate * priv;
};

struct _CianoObjectsItemConversionClass {
	GTypeClass parent_class;
	void (*finalize) (CianoObjectsItemConversion *self);
};

struct _CianoObjectsItemConversionPrivate {
	gint _id;
	gchar* _name;
	gchar* _directory;
	gchar* _convert_to;
	gdouble _progress;
	CianoEnumsTypeItemEnum _type_item;
};

struct _CianoObjectsParamSpecItemConversion {
	GParamSpec parent_instance;
};

static gint CianoObjectsItemConversion_private_offset;
static gpointer ciano_objects_item_conversion_parent_class = NULL;

VALA_EXTERN gpointer ciano_objects_item_conversion_ref (gpointer instance);
VALA_EXTERN void ciano_objects_item_conversion_unref (gpointer instance);
VALA_EXTERN GParamSpec* ciano_objects_param_spec_item_conversion (const gchar* name,
                                                      const gchar* nick,
                                                      const gchar* blurb,
                                                      GType object_type,
                                                      GParamFlags flags);
VALA_EXTERN void ciano_objects_value_set_item_conversion (GValue* value,
                                              gpointer v_object);
VALA_EXTERN void ciano_objects_value_take_item_conversion (GValue* value,
                                               gpointer v_object);
VALA_EXTERN gpointer ciano_objects_value_get_item_conversion (const GValue* value);
VALA_EXTERN GType ciano_objects_item_conversion_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CianoObjectsItemConversion, ciano_objects_item_conversion_unref)
VALA_EXTERN GType ciano_enums_type_item_enum_get_type (void) G_GNUC_CONST ;
VALA_EXTERN CianoObjectsItemConversion* ciano_objects_item_conversion_new (gint id,
                                                               const gchar* name,
                                                               const gchar* directory,
                                                               const gchar* convert_to,
                                                               gdouble* progress,
                                                               CianoEnumsTypeItemEnum type_item);
VALA_EXTERN CianoObjectsItemConversion* ciano_objects_item_conversion_construct (GType object_type,
                                                                     gint id,
                                                                     const gchar* name,
                                                                     const gchar* directory,
                                                                     const gchar* convert_to,
                                                                     gdouble* progress,
                                                                     CianoEnumsTypeItemEnum type_item);
VALA_EXTERN void ciano_objects_item_conversion_set_id (CianoObjectsItemConversion* self,
                                           gint value);
VALA_EXTERN void ciano_objects_item_conversion_set_name (CianoObjectsItemConversion* self,
                                             const gchar* value);
VALA_EXTERN void ciano_objects_item_conversion_set_directory (CianoObjectsItemConversion* self,
                                                  const gchar* value);
VALA_EXTERN void ciano_objects_item_conversion_set_type_item (CianoObjectsItemConversion* self,
                                                  CianoEnumsTypeItemEnum value);
VALA_EXTERN void ciano_objects_item_conversion_set_convert_to (CianoObjectsItemConversion* self,
                                                   const gchar* value);
VALA_EXTERN void ciano_objects_item_conversion_set_progress (CianoObjectsItemConversion* self,
                                                 gdouble value);
VALA_EXTERN gint ciano_objects_item_conversion_get_id (CianoObjectsItemConversion* self);
VALA_EXTERN const gchar* ciano_objects_item_conversion_get_name (CianoObjectsItemConversion* self);
VALA_EXTERN const gchar* ciano_objects_item_conversion_get_directory (CianoObjectsItemConversion* self);
VALA_EXTERN const gchar* ciano_objects_item_conversion_get_convert_to (CianoObjectsItemConversion* self);
VALA_EXTERN gdouble ciano_objects_item_conversion_get_progress (CianoObjectsItemConversion* self);
VALA_EXTERN CianoEnumsTypeItemEnum ciano_objects_item_conversion_get_type_item (CianoObjectsItemConversion* self);
static void ciano_objects_item_conversion_finalize (CianoObjectsItemConversion * obj);
static GType ciano_objects_item_conversion_get_type_once (void);

static inline gpointer
ciano_objects_item_conversion_get_instance_private (CianoObjectsItemConversion* self)
{
	return G_STRUCT_MEMBER_P (self, CianoObjectsItemConversion_private_offset);
}

/**
         * Constructs a new {@code ItemConversion} object.
         *
         * @see Ciano.Enums.TypeItemEnum
         */
CianoObjectsItemConversion*
ciano_objects_item_conversion_construct (GType object_type,
                                         gint id,
                                         const gchar* name,
                                         const gchar* directory,
                                         const gchar* convert_to,
                                         gdouble* progress,
                                         CianoEnumsTypeItemEnum type_item)
{
	CianoObjectsItemConversion* self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (directory != NULL, NULL);
	self = (CianoObjectsItemConversion*) g_type_create_instance (object_type);
	ciano_objects_item_conversion_set_id (self, id);
	ciano_objects_item_conversion_set_name (self, name);
	ciano_objects_item_conversion_set_directory (self, directory);
	ciano_objects_item_conversion_set_type_item (self, type_item);
	if (convert_to != NULL) {
		ciano_objects_item_conversion_set_convert_to (self, convert_to);
	}
	if (progress != NULL) {
		ciano_objects_item_conversion_set_progress (self, *progress);
	}
	return self;
}

CianoObjectsItemConversion*
ciano_objects_item_conversion_new (gint id,
                                   const gchar* name,
                                   const gchar* directory,
                                   const gchar* convert_to,
                                   gdouble* progress,
                                   CianoEnumsTypeItemEnum type_item)
{
	return ciano_objects_item_conversion_construct (CIANO_OBJECTS_TYPE_ITEM_CONVERSION, id, name, directory, convert_to, progress, type_item);
}

gint
ciano_objects_item_conversion_get_id (CianoObjectsItemConversion* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_id;
	return result;
}

void
ciano_objects_item_conversion_set_id (CianoObjectsItemConversion* self,
                                      gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_id = value;
}

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

void
ciano_objects_item_conversion_set_name (CianoObjectsItemConversion* self,
                                        const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp0_;
}

const gchar*
ciano_objects_item_conversion_get_directory (CianoObjectsItemConversion* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_directory;
	result = _tmp0_;
	return result;
}

void
ciano_objects_item_conversion_set_directory (CianoObjectsItemConversion* self,
                                             const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_directory);
	self->priv->_directory = _tmp0_;
}

const gchar*
ciano_objects_item_conversion_get_convert_to (CianoObjectsItemConversion* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_convert_to;
	result = _tmp0_;
	return result;
}

void
ciano_objects_item_conversion_set_convert_to (CianoObjectsItemConversion* self,
                                              const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_convert_to);
	self->priv->_convert_to = _tmp0_;
}

gdouble
ciano_objects_item_conversion_get_progress (CianoObjectsItemConversion* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_progress;
	return result;
}

void
ciano_objects_item_conversion_set_progress (CianoObjectsItemConversion* self,
                                            gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_progress = value;
}

CianoEnumsTypeItemEnum
ciano_objects_item_conversion_get_type_item (CianoObjectsItemConversion* self)
{
	CianoEnumsTypeItemEnum result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_type_item;
	return result;
}

void
ciano_objects_item_conversion_set_type_item (CianoObjectsItemConversion* self,
                                             CianoEnumsTypeItemEnum value)
{
	g_return_if_fail (self != NULL);
	self->priv->_type_item = value;
}

static void
ciano_objects_value_item_conversion_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
ciano_objects_value_item_conversion_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		ciano_objects_item_conversion_unref (value->data[0].v_pointer);
	}
}

static void
ciano_objects_value_item_conversion_copy_value (const GValue* src_value,
                                                GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = ciano_objects_item_conversion_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
ciano_objects_value_item_conversion_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
ciano_objects_value_item_conversion_collect_value (GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		CianoObjectsItemConversion * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = ciano_objects_item_conversion_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
ciano_objects_value_item_conversion_lcopy_value (const GValue* value,
                                                 guint n_collect_values,
                                                 GTypeCValue* collect_values,
                                                 guint collect_flags)
{
	CianoObjectsItemConversion ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = ciano_objects_item_conversion_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
ciano_objects_param_spec_item_conversion (const gchar* name,
                                          const gchar* nick,
                                          const gchar* blurb,
                                          GType object_type,
                                          GParamFlags flags)
{
	CianoObjectsParamSpecItemConversion* spec;
	g_return_val_if_fail (g_type_is_a (object_type, CIANO_OBJECTS_TYPE_ITEM_CONVERSION), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
ciano_objects_value_get_item_conversion (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CIANO_OBJECTS_TYPE_ITEM_CONVERSION), NULL);
	return value->data[0].v_pointer;
}

void
ciano_objects_value_set_item_conversion (GValue* value,
                                         gpointer v_object)
{
	CianoObjectsItemConversion * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CIANO_OBJECTS_TYPE_ITEM_CONVERSION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CIANO_OBJECTS_TYPE_ITEM_CONVERSION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		ciano_objects_item_conversion_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ciano_objects_item_conversion_unref (old);
	}
}

void
ciano_objects_value_take_item_conversion (GValue* value,
                                          gpointer v_object)
{
	CianoObjectsItemConversion * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CIANO_OBJECTS_TYPE_ITEM_CONVERSION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CIANO_OBJECTS_TYPE_ITEM_CONVERSION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ciano_objects_item_conversion_unref (old);
	}
}

static void
ciano_objects_item_conversion_class_init (CianoObjectsItemConversionClass * klass,
                                          gpointer klass_data)
{
	ciano_objects_item_conversion_parent_class = g_type_class_peek_parent (klass);
	((CianoObjectsItemConversionClass *) klass)->finalize = ciano_objects_item_conversion_finalize;
	g_type_class_adjust_private_offset (klass, &CianoObjectsItemConversion_private_offset);
}

static void
ciano_objects_item_conversion_instance_init (CianoObjectsItemConversion * self,
                                             gpointer klass)
{
	self->priv = ciano_objects_item_conversion_get_instance_private (self);
	self->ref_count = 1;
}

static void
ciano_objects_item_conversion_finalize (CianoObjectsItemConversion * obj)
{
	CianoObjectsItemConversion * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CIANO_OBJECTS_TYPE_ITEM_CONVERSION, CianoObjectsItemConversion);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_directory);
	_g_free0 (self->priv->_convert_to);
}

/**
     * The {@code Conversion} class is responsible for representing 
     * each item selected for conversion.
     *
     * @see Ciano.Enums.TypeItemEnum
     * @since 0.1.0
     */
static GType
ciano_objects_item_conversion_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { ciano_objects_value_item_conversion_init, ciano_objects_value_item_conversion_free_value, ciano_objects_value_item_conversion_copy_value, ciano_objects_value_item_conversion_peek_pointer, "p", ciano_objects_value_item_conversion_collect_value, "p", ciano_objects_value_item_conversion_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (CianoObjectsItemConversionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ciano_objects_item_conversion_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CianoObjectsItemConversion), 0, (GInstanceInitFunc) ciano_objects_item_conversion_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType ciano_objects_item_conversion_type_id;
	ciano_objects_item_conversion_type_id = g_type_register_fundamental (g_type_fundamental_next (), "CianoObjectsItemConversion", &g_define_type_info, &g_define_type_fundamental_info, 0);
	CianoObjectsItemConversion_private_offset = g_type_add_instance_private (ciano_objects_item_conversion_type_id, sizeof (CianoObjectsItemConversionPrivate));
	return ciano_objects_item_conversion_type_id;
}

GType
ciano_objects_item_conversion_get_type (void)
{
	static volatile gsize ciano_objects_item_conversion_type_id__once = 0;
	if (g_once_init_enter (&ciano_objects_item_conversion_type_id__once)) {
		GType ciano_objects_item_conversion_type_id;
		ciano_objects_item_conversion_type_id = ciano_objects_item_conversion_get_type_once ();
		g_once_init_leave (&ciano_objects_item_conversion_type_id__once, ciano_objects_item_conversion_type_id);
	}
	return ciano_objects_item_conversion_type_id__once;
}

gpointer
ciano_objects_item_conversion_ref (gpointer instance)
{
	CianoObjectsItemConversion * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
ciano_objects_item_conversion_unref (gpointer instance)
{
	CianoObjectsItemConversion * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		CIANO_OBJECTS_ITEM_CONVERSION_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

