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

/*
 * Copyright 2021 elementary, Inc. (https://elementary.io)
 *
 * 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: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
 */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "gala.h"

#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 GALA_TYPE_NAMED_COLOR (gala_named_color_get_type ())
#define GALA_NAMED_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_NAMED_COLOR, GalaNamedColor))
#define GALA_NAMED_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_NAMED_COLOR, GalaNamedColorClass))
#define GALA_IS_NAMED_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_NAMED_COLOR))
#define GALA_IS_NAMED_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_NAMED_COLOR))
#define GALA_NAMED_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_NAMED_COLOR, GalaNamedColorClass))

typedef struct _GalaNamedColor GalaNamedColor;
typedef struct _GalaNamedColorClass GalaNamedColorClass;
typedef struct _GalaNamedColorPrivate GalaNamedColorPrivate;
enum  {
	GALA_NAMED_COLOR_0_PROPERTY,
	GALA_NAMED_COLOR_NAME_PROPERTY,
	GALA_NAMED_COLOR_THEME_PROPERTY,
	GALA_NAMED_COLOR_COLOR_PROPERTY,
	GALA_NAMED_COLOR_NUM_PROPERTIES
};
static GParamSpec* gala_named_color_properties[GALA_NAMED_COLOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaNamedColor {
	GObject parent_instance;
	GalaNamedColorPrivate * priv;
};

struct _GalaNamedColorClass {
	GObjectClass parent_class;
};

struct _GalaNamedColorPrivate {
	gchar* _name;
	gchar* _theme;
	GalaDrawingColor* _color;
};

static gint GalaNamedColor_private_offset;
static gpointer gala_named_color_parent_class = NULL;

VALA_EXTERN GType gala_named_color_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaNamedColor, g_object_unref)
VALA_EXTERN GalaNamedColor* gala_named_color_new (const gchar* name,
                                      const gchar* theme);
VALA_EXTERN GalaNamedColor* gala_named_color_construct (GType object_type,
                                            const gchar* name,
                                            const gchar* theme);
VALA_EXTERN GalaDrawingColor* gala_internal_utils_get_accent_color_by_theme_name (const gchar* theme_name);
VALA_EXTERN const gchar* gala_named_color_get_name (GalaNamedColor* self);
VALA_EXTERN void gala_named_color_set_name (GalaNamedColor* self,
                                const gchar* value);
VALA_EXTERN const gchar* gala_named_color_get_theme (GalaNamedColor* self);
VALA_EXTERN void gala_named_color_set_theme (GalaNamedColor* self,
                                 const gchar* value);
VALA_EXTERN GalaDrawingColor* gala_named_color_get_color (GalaNamedColor* self);
VALA_EXTERN void gala_named_color_set_color (GalaNamedColor* self,
                                 GalaDrawingColor* value);
static void gala_named_color_finalize (GObject * obj);
static GType gala_named_color_get_type_once (void);
static void _vala_gala_named_color_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_gala_named_color_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
gala_named_color_get_instance_private (GalaNamedColor* self)
{
	return G_STRUCT_MEMBER_P (self, GalaNamedColor_private_offset);
}

GalaNamedColor*
gala_named_color_construct (GType object_type,
                            const gchar* name,
                            const gchar* theme)
{
	GalaNamedColor * self = NULL;
	GalaDrawingColor* _tmp0_;
	GalaDrawingColor* _tmp1_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (theme != NULL, NULL);
	_tmp0_ = gala_internal_utils_get_accent_color_by_theme_name (theme);
	_tmp1_ = _tmp0_;
	self = (GalaNamedColor*) g_object_new (object_type, "name", name, "theme", theme, "color", _tmp1_, NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

GalaNamedColor*
gala_named_color_new (const gchar* name,
                      const gchar* theme)
{
	return gala_named_color_construct (GALA_TYPE_NAMED_COLOR, name, theme);
}

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

void
gala_named_color_set_name (GalaNamedColor* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_named_color_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, gala_named_color_properties[GALA_NAMED_COLOR_NAME_PROPERTY]);
	}
}

const gchar*
gala_named_color_get_theme (GalaNamedColor* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_theme;
	result = _tmp0_;
	return result;
}

void
gala_named_color_set_theme (GalaNamedColor* self,
                            const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_named_color_get_theme (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_theme);
		self->priv->_theme = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_named_color_properties[GALA_NAMED_COLOR_THEME_PROPERTY]);
	}
}

GalaDrawingColor*
gala_named_color_get_color (GalaNamedColor* self)
{
	GalaDrawingColor* result;
	GalaDrawingColor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_color;
	result = _tmp0_;
	return result;
}

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

void
gala_named_color_set_color (GalaNamedColor* self,
                            GalaDrawingColor* value)
{
	GalaDrawingColor* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_named_color_get_color (self);
	if (old_value != value) {
		GalaDrawingColor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_color);
		self->priv->_color = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_named_color_properties[GALA_NAMED_COLOR_COLOR_PROPERTY]);
	}
}

static void
gala_named_color_class_init (GalaNamedColorClass * klass,
                             gpointer klass_data)
{
	gala_named_color_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaNamedColor_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_named_color_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_named_color_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_named_color_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_NAMED_COLOR_NAME_PROPERTY, gala_named_color_properties[GALA_NAMED_COLOR_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_NAMED_COLOR_THEME_PROPERTY, gala_named_color_properties[GALA_NAMED_COLOR_THEME_PROPERTY] = g_param_spec_string ("theme", "theme", "theme", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_NAMED_COLOR_COLOR_PROPERTY, gala_named_color_properties[GALA_NAMED_COLOR_COLOR_PROPERTY] = g_param_spec_object ("color", "color", "color", GALA_DRAWING_TYPE_COLOR, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
gala_named_color_instance_init (GalaNamedColor * self,
                                gpointer klass)
{
	self->priv = gala_named_color_get_instance_private (self);
}

static void
gala_named_color_finalize (GObject * obj)
{
	GalaNamedColor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_NAMED_COLOR, GalaNamedColor);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_theme);
	_g_object_unref0 (self->priv->_color);
	G_OBJECT_CLASS (gala_named_color_parent_class)->finalize (obj);
}

static GType
gala_named_color_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaNamedColorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_named_color_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaNamedColor), 0, (GInstanceInitFunc) gala_named_color_instance_init, NULL };
	GType gala_named_color_type_id;
	gala_named_color_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaNamedColor", &g_define_type_info, 0);
	GalaNamedColor_private_offset = g_type_add_instance_private (gala_named_color_type_id, sizeof (GalaNamedColorPrivate));
	return gala_named_color_type_id;
}

GType
gala_named_color_get_type (void)
{
	static volatile gsize gala_named_color_type_id__once = 0;
	if (g_once_init_enter (&gala_named_color_type_id__once)) {
		GType gala_named_color_type_id;
		gala_named_color_type_id = gala_named_color_get_type_once ();
		g_once_init_leave (&gala_named_color_type_id__once, gala_named_color_type_id);
	}
	return gala_named_color_type_id__once;
}

static void
_vala_gala_named_color_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GalaNamedColor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_NAMED_COLOR, GalaNamedColor);
	switch (property_id) {
		case GALA_NAMED_COLOR_NAME_PROPERTY:
		g_value_set_string (value, gala_named_color_get_name (self));
		break;
		case GALA_NAMED_COLOR_THEME_PROPERTY:
		g_value_set_string (value, gala_named_color_get_theme (self));
		break;
		case GALA_NAMED_COLOR_COLOR_PROPERTY:
		g_value_set_object (value, gala_named_color_get_color (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_named_color_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	GalaNamedColor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_NAMED_COLOR, GalaNamedColor);
	switch (property_id) {
		case GALA_NAMED_COLOR_NAME_PROPERTY:
		gala_named_color_set_name (self, g_value_get_string (value));
		break;
		case GALA_NAMED_COLOR_THEME_PROPERTY:
		gala_named_color_set_theme (self, g_value_get_string (value));
		break;
		case GALA_NAMED_COLOR_COLOR_PROPERTY:
		gala_named_color_set_color (self, g_value_get_object (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;
}

