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

/*
* Copyright (c) 2025-2026 (https://github.com/phase1geo/Minder)
*
* 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
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <libxml/tree.h>
#include <granite-7.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

typedef enum  {
	TAG_COMBO_TYPE_AND,
	TAG_COMBO_TYPE_OR,
	TAG_COMBO_TYPE_NONE,
	TAG_COMBO_TYPE_NUM
} TagComboType;

#define TYPE_TAG_COMBO_TYPE (tag_combo_type_get_type ())

#define TYPE_TAGS (tags_get_type ())
#define TAGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TAGS, Tags))
#define TAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TAGS, TagsClass))
#define IS_TAGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TAGS))
#define IS_TAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TAGS))
#define TAGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TAGS, TagsClass))

typedef struct _Tags Tags;
typedef struct _TagsClass TagsClass;
#define _tags_unref0(var) ((var == NULL) ? NULL : (var = (tags_unref (var), NULL)))

#define TYPE_TAG (tag_get_type ())
#define TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TAG, Tag))
#define TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TAG, TagClass))
#define IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TAG))
#define IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TAG))
#define TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TAG, TagClass))

typedef struct _Tag Tag;
typedef struct _TagClass TagClass;
typedef struct _TagPrivate TagPrivate;
enum  {
	TAG_0_PROPERTY,
	TAG_NAME_PROPERTY,
	TAG_COLOR_PROPERTY,
	TAG_NUM_PROPERTIES
};
static GParamSpec* tag_properties[TAG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _TagsPrivate TagsPrivate;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
#define _g_variant_builder_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_builder_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_variant_iter_free0(var) ((var == NULL) ? NULL : (var = (g_variant_iter_free (var), NULL)))
typedef struct _ParamSpecTags ParamSpecTags;
enum  {
	TAGS_CHANGED_SIGNAL,
	TAGS_NUM_SIGNALS
};
static guint tags_signals[TAGS_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Tag {
	GObject parent_instance;
	TagPrivate * priv;
};

struct _TagClass {
	GObjectClass parent_class;
};

struct _TagPrivate {
	gchar* _name;
	GdkRGBA _color;
};

struct _Tags {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TagsPrivate * priv;
};

struct _TagsClass {
	GTypeClass parent_class;
	void (*finalize) (Tags *self);
};

struct _TagsPrivate {
	GArray* _tags;
};

struct _ParamSpecTags {
	GParamSpec parent_instance;
};

static gint Tag_private_offset;
static gpointer tag_parent_class = NULL;
static gint Tags_private_offset;
static gpointer tags_parent_class = NULL;

VALA_EXTERN GType tag_combo_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* tag_combo_type_to_string (TagComboType self);
VALA_EXTERN gchar* tag_combo_type_label (TagComboType self);
VALA_EXTERN TagComboType tag_combo_type_parse (const gchar* val);
VALA_EXTERN gpointer tags_ref (gpointer instance);
VALA_EXTERN void tags_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_tags (const gchar* name,
                             const gchar* nick,
                             const gchar* blurb,
                             GType object_type,
                             GParamFlags flags);
VALA_EXTERN void value_set_tags (GValue* value,
                     gpointer v_object);
VALA_EXTERN void value_take_tags (GValue* value,
                      gpointer v_object);
VALA_EXTERN gpointer value_get_tags (const GValue* value);
VALA_EXTERN GType tags_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Tags, tags_unref)
VALA_EXTERN gboolean tag_combo_type_highlightable (TagComboType self,
                                       Tags* tags,
                                       Tags* highlight);
VALA_EXTERN Tags* tags_intersect (Tags* first,
                      Tags* second);
VALA_EXTERN gint tags_size (Tags* self);
VALA_EXTERN GType tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Tag, g_object_unref)
VALA_EXTERN void utils_color_from_string (const gchar* value,
                              GdkRGBA* result);
VALA_EXTERN Tag* tag_new (const gchar* name,
              GdkRGBA* color);
VALA_EXTERN Tag* tag_construct (GType object_type,
                    const gchar* name,
                    GdkRGBA* color);
VALA_EXTERN void tag_set_name (Tag* self,
                   const gchar* value);
VALA_EXTERN void tag_set_color (Tag* self,
                    GdkRGBA * value);
VALA_EXTERN Tag* tag_new_from_xml (xmlNode* node);
VALA_EXTERN Tag* tag_construct_from_xml (GType object_type,
                             xmlNode* node);
VALA_EXTERN void tag_load (Tag* self,
               xmlNode* node);
VALA_EXTERN Tag* tag_copy (Tag* self);
VALA_EXTERN const gchar* tag_get_name (Tag* self);
VALA_EXTERN void tag_get_color (Tag* self,
                    GdkRGBA * result);
VALA_EXTERN xmlNode* tag_save (Tag* self);
VALA_EXTERN gchar* utils_color_from_rgba (GdkRGBA* rgba);
VALA_EXTERN gchar* tag_to_tooltip (Tag* self);
static gboolean _gdk_rgba_equal (const GdkRGBA * s1,
                          const GdkRGBA * s2);
static void tag_finalize (GObject * obj);
static GType tag_get_type_once (void);
static void _vala_tag_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec);
static void _vala_tag_set_property (GObject * object,
                             guint property_id,
                             const GValue * value,
                             GParamSpec * pspec);
VALA_EXTERN Tags* tags_new (void);
VALA_EXTERN Tags* tags_construct (GType object_type);
static void _g_object_unref0_ (gpointer var);
static void _vala_Tag_free_function_content_of (gpointer data);
VALA_EXTERN Tag* tags_get_tag (Tags* self,
                   gint index);
VALA_EXTERN Tag* tags_get_tag_from_name (Tags* self,
                             const gchar* name);
VALA_EXTERN gint tags_get_tag_index (Tags* self,
                         Tag* tag);
VALA_EXTERN gboolean tags_contains_tag (Tags* self,
                            Tag* tag);
VALA_EXTERN gboolean tags_add_tag (Tags* self,
                       Tag* tag,
                       gint index);
VALA_EXTERN Tags* tags_copy (Tags* self);
VALA_EXTERN void tags_copy_tags (Tags* self,
                     Tags* other);
VALA_EXTERN gboolean tags_remove_tag (Tags* self,
                          gint index);
VALA_EXTERN void tags_clear_tags (Tags* self);
VALA_EXTERN xmlNode* tags_save (Tags* self);
VALA_EXTERN xmlNode* tags_save_indices (Tags* self,
                            Tags* all_tags);
static void _vala_array_add47 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN GVariant* tags_save_variant (Tags* self);
VALA_EXTERN void tags_load (Tags* self,
                xmlNode* node);
VALA_EXTERN void tags_load_indices (Tags* self,
                        xmlNode* node,
                        Tags* all_tags);
VALA_EXTERN void tags_load_variant (Tags* self,
                        GVariant* variant);
VALA_EXTERN gchar* tags_to_string (Tags* self);
static void _vala_array_add48 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN gchar* tags_to_tooltip (Tags* self);
static void tags_finalize (Tags * obj);
static GType tags_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gchar*
tag_combo_type_to_string (TagComboType self)
{
	gchar* result;
	switch (self) {
		case TAG_COMBO_TYPE_AND:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("and");
			result = _tmp0_;
			return result;
		}
		case TAG_COMBO_TYPE_OR:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("or");
			result = _tmp1_;
			return result;
		}
		case TAG_COMBO_TYPE_NONE:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("none");
			result = _tmp2_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

gchar*
tag_combo_type_label (TagComboType self)
{
	gchar* result;
	switch (self) {
		case TAG_COMBO_TYPE_AND:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup (_ ("All"));
			result = _tmp0_;
			return result;
		}
		case TAG_COMBO_TYPE_OR:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup (_ ("Any"));
			result = _tmp1_;
			return result;
		}
		case TAG_COMBO_TYPE_NONE:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup (_ ("None"));
			result = _tmp2_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

TagComboType
tag_combo_type_parse (const gchar* val)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	TagComboType result;
	g_return_val_if_fail (val != NULL, 0);
	_tmp0_ = val;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("and")))) {
		switch (0) {
			default:
			{
				result = TAG_COMBO_TYPE_AND;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("or")))) {
		switch (0) {
			default:
			{
				result = TAG_COMBO_TYPE_OR;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("none")))) {
		switch (0) {
			default:
			{
				result = TAG_COMBO_TYPE_NONE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = TAG_COMBO_TYPE_AND;
				return result;
			}
		}
	}
}

gboolean
tag_combo_type_highlightable (TagComboType self,
                              Tags* tags,
                              Tags* highlight)
{
	Tags* intersect = NULL;
	Tags* _tmp0_;
	gboolean result;
	g_return_val_if_fail (tags != NULL, FALSE);
	g_return_val_if_fail (highlight != NULL, FALSE);
	_tmp0_ = tags_intersect (tags, highlight);
	intersect = _tmp0_;
	switch (self) {
		case TAG_COMBO_TYPE_AND:
		{
			Tags* _tmp1_;
			_tmp1_ = intersect;
			result = tags_size (_tmp1_) == tags_size (highlight);
			_tags_unref0 (intersect);
			return result;
		}
		case TAG_COMBO_TYPE_OR:
		{
			Tags* _tmp2_;
			_tmp2_ = intersect;
			result = tags_size (_tmp2_) > 0;
			_tags_unref0 (intersect);
			return result;
		}
		case TAG_COMBO_TYPE_NONE:
		{
			Tags* _tmp3_;
			_tmp3_ = intersect;
			result = tags_size (_tmp3_) == 0;
			_tags_unref0 (intersect);
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static GType
tag_combo_type_get_type_once (void)
{
	static const GEnumValue values[] = {{TAG_COMBO_TYPE_AND, "TAG_COMBO_TYPE_AND", "and"}, {TAG_COMBO_TYPE_OR, "TAG_COMBO_TYPE_OR", "or"}, {TAG_COMBO_TYPE_NONE, "TAG_COMBO_TYPE_NONE", "none"}, {TAG_COMBO_TYPE_NUM, "TAG_COMBO_TYPE_NUM", "num"}, {0, NULL, NULL}};
	GType tag_combo_type_type_id;
	tag_combo_type_type_id = g_enum_register_static ("TagComboType", values);
	return tag_combo_type_type_id;
}

GType
tag_combo_type_get_type (void)
{
	static volatile gsize tag_combo_type_type_id__once = 0;
	if (g_once_init_enter (&tag_combo_type_type_id__once)) {
		GType tag_combo_type_type_id;
		tag_combo_type_type_id = tag_combo_type_get_type_once ();
		g_once_init_leave (&tag_combo_type_type_id__once, tag_combo_type_type_id);
	}
	return tag_combo_type_type_id__once;
}

static inline gpointer
tag_get_instance_private (Tag* self)
{
	return G_STRUCT_MEMBER_P (self, Tag_private_offset);
}

Tag*
tag_construct (GType object_type,
               const gchar* name,
               GdkRGBA* color)
{
	Tag * self = NULL;
	GdkRGBA _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (color != NULL, NULL);
	self = (Tag*) g_object_new (object_type, NULL);
	tag_set_name (self, name);
	_tmp0_ = *color;
	tag_set_color (self, &_tmp0_);
	return self;
}

Tag*
tag_new (const gchar* name,
         GdkRGBA* color)
{
	return tag_construct (TYPE_TAG, name, color);
}

Tag*
tag_construct_from_xml (GType object_type,
                        xmlNode* node)
{
	Tag * self = NULL;
	self = (Tag*) g_object_new (object_type, NULL);
	tag_load (self, node);
	return self;
}

Tag*
tag_new_from_xml (xmlNode* node)
{
	return tag_construct_from_xml (TYPE_TAG, node);
}

Tag*
tag_copy (Tag* self)
{
	Tag* tag = NULL;
	const gchar* _tmp0_;
	GdkRGBA _tmp1_;
	Tag* _tmp2_;
	Tag* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	_tmp1_ = self->priv->_color;
	_tmp2_ = tag_new (_tmp0_, &_tmp1_);
	tag = _tmp2_;
	result = tag;
	return result;
}

xmlNode*
tag_save (Tag* self)
{
	xmlNode* node = NULL;
	xmlNode* _tmp0_;
	const gchar* _tmp1_;
	GdkRGBA _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "tag");
	node = _tmp0_;
	_tmp1_ = self->priv->_name;
	xmlSetProp (node, (xmlChar*) "name", (xmlChar*) _tmp1_);
	_tmp2_ = self->priv->_color;
	_tmp3_ = utils_color_from_rgba (&_tmp2_);
	_tmp4_ = _tmp3_;
	xmlSetProp (node, (xmlChar*) "color", (xmlChar*) _tmp4_);
	_g_free0 (_tmp4_);
	result = node;
	return result;
}

void
tag_load (Tag* self,
          xmlNode* node)
{
	gchar* n = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* c = NULL;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (gchar*) xmlGetProp (node, (xmlChar*) "name");
	n = _tmp0_;
	_tmp1_ = n;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = n;
		tag_set_name (self, _tmp2_);
	}
	_tmp3_ = (gchar*) xmlGetProp (node, (xmlChar*) "color");
	c = _tmp3_;
	_tmp4_ = c;
	if (_tmp4_ != NULL) {
		const gchar* _tmp5_;
		GdkRGBA _tmp6_ = {0};
		_tmp5_ = c;
		utils_color_from_string (_tmp5_, &_tmp6_);
		tag_set_color (self, &_tmp6_);
	}
	_g_free0 (c);
	_g_free0 (n);
}

gchar*
tag_to_tooltip (Tag* self)
{
	gchar* bgcolor = NULL;
	GdkRGBA _tmp0_;
	gchar* _tmp1_;
	gchar* fgcolor = NULL;
	GdkRGBA _tmp2_;
	GdkRGBA _tmp3_ = {0};
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_color;
	_tmp1_ = utils_color_from_rgba (&_tmp0_);
	bgcolor = _tmp1_;
	_tmp2_ = self->priv->_color;
	granite_contrasting_foreground_color (&_tmp2_, &_tmp3_);
	_tmp4_ = utils_color_from_rgba (&_tmp3_);
	fgcolor = _tmp4_;
	_tmp5_ = self->priv->_name;
	_tmp6_ = g_markup_escape_text (_tmp5_, (gssize) -1);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strdup_printf ("<span background='%s' foreground='%s'> %s </span> ", bgcolor, fgcolor, _tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	result = _tmp9_;
	_g_free0 (fgcolor);
	_g_free0 (bgcolor);
	return result;
}

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

void
tag_set_name (Tag* self,
              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tag_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, tag_properties[TAG_NAME_PROPERTY]);
	}
}

void
tag_get_color (Tag* self,
               GdkRGBA * result)
{
	GdkRGBA _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_color;
	*result = _tmp0_;
	return;
}

static gboolean
_gdk_rgba_equal (const GdkRGBA * s1,
                 const GdkRGBA * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->red != s2->red) {
		return FALSE;
	}
	if (s1->green != s2->green) {
		return FALSE;
	}
	if (s1->blue != s2->blue) {
		return FALSE;
	}
	if (s1->alpha != s2->alpha) {
		return FALSE;
	}
	return TRUE;
}

void
tag_set_color (Tag* self,
               GdkRGBA * value)
{
	GdkRGBA old_value;
	g_return_if_fail (self != NULL);
	tag_get_color (self, &old_value);
	if (_gdk_rgba_equal (value, &old_value) != TRUE) {
		GdkRGBA _tmp0_;
		_tmp0_ = *value;
		self->priv->_color = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tag_properties[TAG_COLOR_PROPERTY]);
	}
}

static void
tag_class_init (TagClass * klass,
                gpointer klass_data)
{
	tag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Tag_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tag_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tag_set_property;
	G_OBJECT_CLASS (klass)->finalize = tag_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TAG_NAME_PROPERTY, tag_properties[TAG_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), TAG_COLOR_PROPERTY, tag_properties[TAG_COLOR_PROPERTY] = g_param_spec_boxed ("color", "color", "color", gdk_rgba_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tag_instance_init (Tag * self,
                   gpointer klass)
{
	gchar* _tmp0_;
	GdkRGBA _tmp1_ = {0};
	self->priv = tag_get_instance_private (self);
	_tmp0_ = g_strdup (_ ("Tag"));
	self->priv->_name = _tmp0_;
	utils_color_from_string ("#000000", &_tmp1_);
	self->priv->_color = _tmp1_;
}

static void
tag_finalize (GObject * obj)
{
	Tag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TAG, Tag);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (tag_parent_class)->finalize (obj);
}

static GType
tag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Tag), 0, (GInstanceInitFunc) tag_instance_init, NULL };
	GType tag_type_id;
	tag_type_id = g_type_register_static (G_TYPE_OBJECT, "Tag", &g_define_type_info, 0);
	Tag_private_offset = g_type_add_instance_private (tag_type_id, sizeof (TagPrivate));
	return tag_type_id;
}

GType
tag_get_type (void)
{
	static volatile gsize tag_type_id__once = 0;
	if (g_once_init_enter (&tag_type_id__once)) {
		GType tag_type_id;
		tag_type_id = tag_get_type_once ();
		g_once_init_leave (&tag_type_id__once, tag_type_id);
	}
	return tag_type_id__once;
}

static void
_vala_tag_get_property (GObject * object,
                        guint property_id,
                        GValue * value,
                        GParamSpec * pspec)
{
	Tag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TAG, Tag);
	switch (property_id) {
		case TAG_NAME_PROPERTY:
		g_value_set_string (value, tag_get_name (self));
		break;
		case TAG_COLOR_PROPERTY:
		{
			GdkRGBA boxed;
			tag_get_color (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tag_set_property (GObject * object,
                        guint property_id,
                        const GValue * value,
                        GParamSpec * pspec)
{
	Tag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TAG, Tag);
	switch (property_id) {
		case TAG_NAME_PROPERTY:
		tag_set_name (self, g_value_get_string (value));
		break;
		case TAG_COLOR_PROPERTY:
		tag_set_color (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
tags_get_instance_private (Tags* self)
{
	return G_STRUCT_MEMBER_P (self, Tags_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_vala_Tag_free_function_content_of (gpointer data)
{
	Tag* self;
	self = *((Tag**) data);
	_g_object_unref0_ (self);
}

Tags*
tags_construct (GType object_type)
{
	Tags* self = NULL;
	GArray* _tmp0_;
	self = (Tags*) g_type_create_instance (object_type);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (Tag*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_Tag_free_function_content_of);
	_g_array_unref0 (self->priv->_tags);
	self->priv->_tags = _tmp0_;
	return self;
}

Tags*
tags_new (void)
{
	return tags_construct (TYPE_TAGS);
}

gint
tags_size (Tags* self)
{
	GArray* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->_tags;
	result = (gint) _tmp0_->len;
	return result;
}

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

Tag*
tags_get_tag (Tags* self,
              gint index)
{
	GArray* _tmp0_;
	Tag* _tmp1_;
	Tag* _tmp2_;
	Tag* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_tags;
	_tmp1_ = g_array_index (_tmp0_, Tag*, (guint) index);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

Tag*
tags_get_tag_from_name (Tags* self,
                        const gchar* name)
{
	Tag* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				Tag* tag = NULL;
				GArray* _tmp3_;
				Tag* _tmp4_;
				Tag* _tmp5_;
				Tag* _tmp6_;
				const gchar* _tmp7_;
				const gchar* _tmp8_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_tags;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_tags;
				_tmp4_ = g_array_index (_tmp3_, Tag*, (guint) i);
				_tmp5_ = _g_object_ref0 (_tmp4_);
				tag = _tmp5_;
				_tmp6_ = tag;
				_tmp7_ = tag_get_name (_tmp6_);
				_tmp8_ = _tmp7_;
				if (g_strcmp0 (_tmp8_, name) == 0) {
					result = tag;
					return result;
				}
				_g_object_unref0 (tag);
			}
		}
	}
	result = NULL;
	return result;
}

gint
tags_get_tag_index (Tags* self,
                    Tag* tag)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (tag != NULL, -1);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				GArray* _tmp3_;
				Tag* _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_tags;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_tags;
				_tmp4_ = g_array_index (_tmp3_, Tag*, (guint) i);
				if (_tmp4_ == tag) {
					result = i;
					return result;
				}
			}
		}
	}
	result = -1;
	return result;
}

gboolean
tags_contains_tag (Tags* self,
                   Tag* tag)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tag != NULL, FALSE);
	result = tags_get_tag_index (self, tag) != -1;
	return result;
}

gboolean
tags_add_tag (Tags* self,
              Tag* tag,
              gint index)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tag != NULL, FALSE);
	if (tags_contains_tag (self, tag)) {
		result = FALSE;
		return result;
	}
	if (index == -1) {
		GArray* _tmp0_;
		Tag* _tmp1_;
		_tmp0_ = self->priv->_tags;
		_tmp1_ = _g_object_ref0 (tag);
		g_array_append_val (_tmp0_, _tmp1_);
	} else {
		GArray* _tmp2_;
		Tag* _tmp3_;
		_tmp2_ = self->priv->_tags;
		_tmp3_ = _g_object_ref0 (tag);
		g_array_insert_val (_tmp2_, (guint) index, _tmp3_);
	}
	g_signal_emit (self, tags_signals[TAGS_CHANGED_SIGNAL], 0);
	result = TRUE;
	return result;
}

Tags*
tags_copy (Tags* self)
{
	Tags* tags = NULL;
	Tags* _tmp0_;
	Tags* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = tags_new ();
	tags = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				Tags* _tmp4_;
				GArray* _tmp5_;
				Tag* _tmp6_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_tags;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = tags;
				_tmp5_ = self->priv->_tags;
				_tmp6_ = g_array_index (_tmp5_, Tag*, (guint) i);
				tags_add_tag (_tmp4_, _tmp6_, -1);
			}
		}
	}
	result = tags;
	return result;
}

void
tags_copy_tags (Tags* self,
                Tags* other)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (other != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				Tag* _tmp2_;
				Tag* _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < tags_size (other))) {
					break;
				}
				_tmp2_ = tags_get_tag (other, i);
				_tmp3_ = _tmp2_;
				tags_add_tag (self, _tmp3_, -1);
				_g_object_unref0 (_tmp3_);
			}
		}
	}
}

static gpointer
vala_g_array_remove_index (GArray* self,
                           guint index)
{
	gpointer g = NULL;
	gpointer* _tmp0_;
	gint _tmp0__length1;
	gpointer _tmp1_;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len > index, "length > index");
	_tmp0_ = self->data;
	_tmp0__length1 = self->len;
	_tmp1_ = _tmp0_[index];
	_tmp0_[index] = NULL;
	g = _tmp1_;
	g_array_remove_index (self, index);
	result = g;
	return result;
}

gboolean
tags_remove_tag (Tags* self,
                 gint index)
{
	gboolean _tmp0_ = FALSE;
	GArray* _tmp2_;
	Tag* _tmp3_;
	Tag* _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (index < 0) {
		_tmp0_ = TRUE;
	} else {
		GArray* _tmp1_;
		_tmp1_ = self->priv->_tags;
		_tmp0_ = ((guint) index) > _tmp1_->len;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp2_ = self->priv->_tags;
	_tmp3_ = vala_g_array_remove_index (_tmp2_, (guint) index);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp4_);
	g_signal_emit (self, tags_signals[TAGS_CHANGED_SIGNAL], 0);
	result = TRUE;
	return result;
}

static gpointer*
vala_g_array_remove_range (GArray* self,
                           guint index,
                           guint length,
                           gint* result_length1)
{
	gpointer* ga = NULL;
	gpointer* _tmp0_;
	gint ga_length1;
	gint _ga_size_;
	gpointer* _tmp6_;
	gint _tmp6__length1;
	gpointer* result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len >= (index + length), "this.length >= index + length");
	_tmp0_ = g_new0 (gpointer, length);
	ga = _tmp0_;
	ga_length1 = length;
	_ga_size_ = ga_length1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gpointer* _tmp3_;
				gint _tmp3__length1;
				gpointer* _tmp4_;
				gint _tmp4__length1;
				gpointer _tmp5_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < length)) {
					break;
				}
				_tmp3_ = ga;
				_tmp3__length1 = ga_length1;
				_tmp4_ = self->data;
				_tmp4__length1 = self->len;
				_tmp5_ = _tmp4_[i + index];
				_tmp4_[i + index] = NULL;
				_tmp3_[i] = _tmp5_;
			}
		}
	}
	g_array_remove_range (self, index, length);
	_tmp6_ = ga;
	_tmp6__length1 = ga_length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

void
tags_clear_tags (Tags* self)
{
	GArray* _tmp0_;
	GArray* _tmp1_;
	gint _tmp2_ = 0;
	gpointer* _tmp3_;
	Tag** _tmp4_;
	gint _tmp4__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_tags;
	_tmp1_ = self->priv->_tags;
	_tmp3_ = vala_g_array_remove_range (_tmp0_, (guint) 0, _tmp1_->len, &_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp2_;
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_object_unref), NULL);
	g_signal_emit (self, tags_signals[TAGS_CHANGED_SIGNAL], 0);
}

xmlNode*
tags_save (Tags* self)
{
	xmlNode* node = NULL;
	xmlNode* _tmp0_;
	xmlNode* _tmp8_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "tags");
	node = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				xmlNode* _tmp4_;
				GArray* _tmp5_;
				Tag* _tmp6_;
				xmlNode* _tmp7_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_tags;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = node;
				_tmp5_ = self->priv->_tags;
				_tmp6_ = g_array_index (_tmp5_, Tag*, (guint) i);
				_tmp7_ = tag_save (_tmp6_);
				xmlAddChild (_tmp4_, _tmp7_);
			}
		}
	}
	_tmp8_ = node;
	result = _tmp8_;
	return result;
}

static void
_vala_array_add47 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

xmlNode*
tags_save_indices (Tags* self,
                   Tags* all_tags)
{
	gchar** indices = NULL;
	gchar** _tmp0_;
	gint indices_length1;
	gint _indices_size_;
	xmlNode* node = NULL;
	xmlNode* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar* _tmp10_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (all_tags != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	indices = _tmp0_;
	indices_length1 = 0;
	_indices_size_ = indices_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				gint all_index = 0;
				GArray* _tmp4_;
				Tag* _tmp5_;
				gchar* _tmp6_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_tags;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = self->priv->_tags;
				_tmp5_ = g_array_index (_tmp4_, Tag*, (guint) i);
				all_index = tags_get_tag_index (all_tags, _tmp5_);
				_tmp6_ = g_strdup_printf ("%i", all_index);
				_vala_array_add47 (&indices, &indices_length1, &_indices_size_, _tmp6_);
			}
		}
	}
	_tmp7_ = xmlNewNode (NULL, (xmlChar*) "taglist");
	node = _tmp7_;
	_tmp8_ = indices;
	_tmp8__length1 = indices_length1;
	_tmp9_ = _vala_g_strjoinv (",", _tmp8_, (gint) _tmp8__length1);
	_tmp10_ = _tmp9_;
	xmlSetProp (node, (xmlChar*) "list", (xmlChar*) _tmp10_);
	_g_free0 (_tmp10_);
	result = node;
	indices = (_vala_array_free (indices, indices_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

GVariant*
tags_save_variant (Tags* self)
{
	GVariantBuilder* builder = NULL;
	GVariantType* _tmp0_;
	GVariantType* _tmp1_;
	GVariantBuilder* _tmp2_;
	GVariantBuilder* _tmp3_;
	GVariantBuilder* _tmp17_;
	GVariant* _tmp18_;
	GVariant* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_variant_type_new ("a(ss)");
	_tmp1_ = _tmp0_;
	_tmp2_ = g_variant_builder_new (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_variant_type_free0 (_tmp1_);
	builder = _tmp3_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GArray* _tmp6_;
				Tag* tag = NULL;
				Tag* _tmp7_;
				GVariantBuilder* _tmp8_;
				Tag* _tmp9_;
				const gchar* _tmp10_;
				const gchar* _tmp11_;
				Tag* _tmp12_;
				GdkRGBA _tmp13_ = {0};
				GdkRGBA _tmp14_;
				gchar* _tmp15_;
				gchar* _tmp16_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->priv->_tags;
				if (!(((guint) i) < _tmp6_->len)) {
					break;
				}
				_tmp7_ = tags_get_tag (self, i);
				tag = _tmp7_;
				_tmp8_ = builder;
				_tmp9_ = tag;
				_tmp10_ = tag_get_name (_tmp9_);
				_tmp11_ = _tmp10_;
				_tmp12_ = tag;
				tag_get_color (_tmp12_, &_tmp13_);
				_tmp14_ = _tmp13_;
				_tmp15_ = utils_color_from_rgba (&_tmp14_);
				_tmp16_ = _tmp15_;
				g_variant_builder_add (_tmp8_, "(ss)", _tmp11_, _tmp16_, NULL);
				_g_free0 (_tmp16_);
				_g_object_unref0 (tag);
			}
		}
	}
	_tmp17_ = builder;
	_tmp18_ = g_variant_builder_end (_tmp17_);
	g_variant_ref_sink (_tmp18_);
	result = _tmp18_;
	_g_variant_builder_unref0 (builder);
	return result;
}

void
tags_load (Tags* self,
           xmlNode* node)
{
	g_return_if_fail (self != NULL);
	{
		xmlNode* it = NULL;
		xmlNode* _tmp0_;
		_tmp0_ = node->children;
		it = _tmp0_;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp4_;
				gboolean _tmp5_ = FALSE;
				xmlNode* _tmp6_;
				if (!_tmp1_) {
					xmlNode* _tmp2_;
					xmlNode* _tmp3_;
					_tmp2_ = it;
					_tmp3_ = _tmp2_->next;
					it = _tmp3_;
				}
				_tmp1_ = FALSE;
				_tmp4_ = it;
				if (!(_tmp4_ != NULL)) {
					break;
				}
				_tmp6_ = it;
				if (_tmp6_->type == XML_ELEMENT_NODE) {
					xmlNode* _tmp7_;
					const gchar* _tmp8_;
					_tmp7_ = it;
					_tmp8_ = _tmp7_->name;
					_tmp5_ = g_strcmp0 (_tmp8_, "tag") == 0;
				} else {
					_tmp5_ = FALSE;
				}
				if (_tmp5_) {
					Tag* tag = NULL;
					xmlNode* _tmp9_;
					Tag* _tmp10_;
					GArray* _tmp11_;
					Tag* _tmp12_;
					Tag* _tmp13_;
					_tmp9_ = it;
					_tmp10_ = tag_new_from_xml (_tmp9_);
					tag = _tmp10_;
					_tmp11_ = self->priv->_tags;
					_tmp12_ = tag;
					_tmp13_ = _g_object_ref0 (_tmp12_);
					g_array_append_val (_tmp11_, _tmp13_);
					_g_object_unref0 (tag);
				}
			}
		}
	}
}

void
tags_load_indices (Tags* self,
                   xmlNode* node,
                   Tags* all_tags)
{
	gchar* l = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (all_tags != NULL);
	_tmp0_ = (gchar*) xmlGetProp (node, (xmlChar*) "list");
	l = _tmp0_;
	_tmp1_ = l;
	if (_tmp1_ != NULL) {
		gchar** indices = NULL;
		const gchar* _tmp2_;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gint indices_length1;
		gint _indices_size_;
		gchar** _tmp5_;
		gint _tmp5__length1;
		_tmp2_ = l;
		_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, ",", 0);
		indices = _tmp4_;
		indices_length1 = _vala_array_length (_tmp3_);
		_indices_size_ = indices_length1;
		_tmp5_ = indices;
		_tmp5__length1 = indices_length1;
		{
			gchar** index_collection = NULL;
			gint index_collection_length1 = 0;
			gint _index_collection_size_ = 0;
			gint index_it = 0;
			index_collection = _tmp5_;
			index_collection_length1 = _tmp5__length1;
			for (index_it = 0; index_it < index_collection_length1; index_it = index_it + 1) {
				gchar* _tmp6_;
				gchar* index = NULL;
				_tmp6_ = g_strdup (index_collection[index_it]);
				index = _tmp6_;
				{
					Tag* tag = NULL;
					const gchar* _tmp7_;
					Tag* _tmp8_;
					Tag* _tmp9_;
					_tmp7_ = index;
					_tmp8_ = tags_get_tag (all_tags, atoi (_tmp7_));
					tag = _tmp8_;
					_tmp9_ = tag;
					if (_tmp9_ != NULL) {
						Tag* _tmp10_;
						_tmp10_ = tag;
						tags_add_tag (self, _tmp10_, -1);
					}
					_g_object_unref0 (tag);
					_g_free0 (index);
				}
			}
		}
		indices = (_vala_array_free (indices, indices_length1, (GDestroyNotify) g_free), NULL);
	}
	_g_free0 (l);
}

void
tags_load_variant (Tags* self,
                   GVariant* variant)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (variant != NULL);
	{
		GVariantIter* _child_it = NULL;
		GVariantIter* _tmp0_;
		GVariant* child = NULL;
		_tmp0_ = g_variant_iter_new (variant);
		_child_it = _tmp0_;
		while (TRUE) {
			GVariantIter* _tmp1_;
			GVariant* _tmp2_;
			GVariant* _tmp3_;
			gchar* name = NULL;
			gchar* color = NULL;
			GVariant* _tmp4_;
			gchar* _tmp5_ = NULL;
			gchar* _tmp6_ = NULL;
			Tag* tag = NULL;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			GdkRGBA _tmp9_ = {0};
			Tag* _tmp10_;
			GArray* _tmp11_;
			Tag* _tmp12_;
			Tag* _tmp13_;
			_tmp1_ = _child_it;
			_tmp2_ = g_variant_iter_next_value (_tmp1_);
			_g_variant_unref0 (child);
			child = _tmp2_;
			_tmp3_ = child;
			if (!(_tmp3_ != NULL)) {
				break;
			}
			_tmp4_ = child;
			g_variant_get (_tmp4_, "(ss)", &_tmp5_, &_tmp6_, NULL);
			_g_free0 (name);
			name = _tmp5_;
			_g_free0 (color);
			color = _tmp6_;
			_tmp7_ = name;
			_tmp8_ = color;
			utils_color_from_string (_tmp8_, &_tmp9_);
			_tmp10_ = tag_new (_tmp7_, &_tmp9_);
			tag = _tmp10_;
			_tmp11_ = self->priv->_tags;
			_tmp12_ = tag;
			_tmp13_ = _g_object_ref0 (_tmp12_);
			g_array_append_val (_tmp11_, _tmp13_);
			_g_object_unref0 (tag);
			_g_free0 (color);
			_g_free0 (name);
		}
		_g_variant_unref0 (child);
		_g_variant_iter_free0 (_child_it);
	}
}

static void
_vala_array_add48 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

gchar*
tags_to_string (Tags* self)
{
	gchar** parts = NULL;
	gchar** _tmp0_;
	gint parts_length1;
	gint _parts_size_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar* _tmp10_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	parts = _tmp0_;
	parts_length1 = 0;
	_parts_size_ = parts_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				Tag* _tmp4_;
				Tag* _tmp5_;
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				gchar* _tmp8_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_tags;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = tags_get_tag (self, i);
				_tmp5_ = _tmp4_;
				_tmp6_ = tag_get_name (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = g_strdup (_tmp7_);
				_vala_array_add48 (&parts, &parts_length1, &_parts_size_, _tmp8_);
				_g_object_unref0 (_tmp5_);
			}
		}
	}
	_tmp9_ = parts;
	_tmp9__length1 = parts_length1;
	_tmp10_ = _vala_g_strjoinv (",", _tmp9_, (gint) _tmp9__length1);
	result = _tmp10_;
	parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

gchar*
tags_to_tooltip (Tags* self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	str = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				Tag* tag = NULL;
				GArray* _tmp4_;
				Tag* _tmp5_;
				Tag* _tmp6_;
				const gchar* _tmp7_;
				Tag* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_tags;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = self->priv->_tags;
				_tmp5_ = g_array_index (_tmp4_, Tag*, (guint) i);
				_tmp6_ = _g_object_ref0 (_tmp5_);
				tag = _tmp6_;
				_tmp7_ = str;
				_tmp8_ = tag;
				_tmp9_ = tag_to_tooltip (_tmp8_);
				_tmp10_ = _tmp9_;
				_tmp11_ = g_strconcat (_tmp7_, _tmp10_, NULL);
				_g_free0 (str);
				str = _tmp11_;
				_g_free0 (_tmp10_);
				_g_object_unref0 (tag);
			}
		}
	}
	result = str;
	return result;
}

Tags*
tags_intersect (Tags* first,
                Tags* second)
{
	Tags* tags = NULL;
	Tags* _tmp0_;
	Tags* result;
	g_return_val_if_fail (first != NULL, NULL);
	g_return_val_if_fail (second != NULL, NULL);
	_tmp0_ = tags_new ();
	tags = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				Tag* first_tag = NULL;
				Tag* _tmp3_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < tags_size (first))) {
					break;
				}
				_tmp3_ = tags_get_tag (first, i);
				first_tag = _tmp3_;
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							Tag* _tmp6_;
							Tag* _tmp7_;
							Tag* _tmp8_;
							gboolean _tmp9_;
							if (!_tmp4_) {
								gint _tmp5_;
								_tmp5_ = j;
								j = _tmp5_ + 1;
							}
							_tmp4_ = FALSE;
							if (!(j < tags_size (second))) {
								break;
							}
							_tmp6_ = first_tag;
							_tmp7_ = tags_get_tag (second, j);
							_tmp8_ = _tmp7_;
							_tmp9_ = _tmp6_ == _tmp8_;
							_g_object_unref0 (_tmp8_);
							if (_tmp9_) {
								Tags* _tmp10_;
								Tag* _tmp11_;
								_tmp10_ = tags;
								_tmp11_ = first_tag;
								tags_add_tag (_tmp10_, _tmp11_, -1);
								break;
							}
						}
					}
				}
				_g_object_unref0 (first_tag);
			}
		}
	}
	result = tags;
	return result;
}

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

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

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

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

static gchar*
value_tags_collect_value (GValue* value,
                          guint n_collect_values,
                          GTypeCValue* collect_values,
                          guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		Tags * 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 = tags_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_tags_lcopy_value (const GValue* value,
                        guint n_collect_values,
                        GTypeCValue* collect_values,
                        guint collect_flags)
{
	Tags ** 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 = tags_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_tags (const gchar* name,
                 const gchar* nick,
                 const gchar* blurb,
                 GType object_type,
                 GParamFlags flags)
{
	ParamSpecTags* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_TAGS), 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
value_get_tags (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TAGS), NULL);
	return value->data[0].v_pointer;
}

void
value_set_tags (GValue* value,
                gpointer v_object)
{
	Tags * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TAGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TAGS));
		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;
		tags_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tags_unref (old);
	}
}

void
value_take_tags (GValue* value,
                 gpointer v_object)
{
	Tags * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TAGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TAGS));
		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) {
		tags_unref (old);
	}
}

static void
tags_class_init (TagsClass * klass,
                 gpointer klass_data)
{
	tags_parent_class = g_type_class_peek_parent (klass);
	((TagsClass *) klass)->finalize = tags_finalize;
	g_type_class_adjust_private_offset (klass, &Tags_private_offset);
	tags_signals[TAGS_CHANGED_SIGNAL] = g_signal_new ("changed", TYPE_TAGS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
tags_instance_init (Tags * self,
                    gpointer klass)
{
	self->priv = tags_get_instance_private (self);
	self->ref_count = 1;
}

static void
tags_finalize (Tags * obj)
{
	Tags * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TAGS, Tags);
	g_signal_handlers_destroy (self);
	_g_array_unref0 (self->priv->_tags);
}

static GType
tags_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_tags_init, value_tags_free_value, value_tags_copy_value, value_tags_peek_pointer, "p", value_tags_collect_value, "p", value_tags_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TagsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tags_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Tags), 0, (GInstanceInitFunc) tags_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 tags_type_id;
	tags_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Tags", &g_define_type_info, &g_define_type_fundamental_info, 0);
	Tags_private_offset = g_type_add_instance_private (tags_type_id, sizeof (TagsPrivate));
	return tags_type_id;
}

GType
tags_get_type (void)
{
	static volatile gsize tags_type_id__once = 0;
	if (g_once_init_enter (&tags_type_id__once)) {
		GType tags_type_id;
		tags_type_id = tags_get_type_once ();
		g_once_init_leave (&tags_type_id__once, tags_type_id);
	}
	return tags_type_id__once;
}

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

void
tags_unref (gpointer instance)
{
	Tags * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TAGS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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;
}

