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

/*
Copyright (C) 2014 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library 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 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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  {
	BIRD_FONT_SPACINGCLASS_0_PROPERTY,
	BIRD_FONT_SPACINGCLASS_NUM_PROPERTIES
};
static GParamSpec* bird_font_spacingclass_properties[BIRD_FONT_SPACINGCLASS_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)))
enum  {
	BIRD_FONT_SPACINGCLASS_UPDATED_SIGNAL,
	BIRD_FONT_SPACINGCLASS_NUM_SIGNALS
};
static guint bird_font_spacingclass_signals[BIRD_FONT_SPACINGCLASS_NUM_SIGNALS] = {0};

struct _BirdFontSpacingClassPrivate {
	gboolean update_first;
	BirdFontTextListener* listener;
};

static gint BirdFontSpacingClass_private_offset;
static gpointer bird_font_spacingclass_parent_class = NULL;

static void bird_font_spacingclass_update (BirdFontSpacingClass* self,
                                    const gchar* val);
static void __lambda13_ (BirdFontSpacingClass* self,
                  const gchar* text);
static void ___lambda13__bird_font_text_listener_signal_text_input (BirdFontTextListener* _sender,
                                                             const gchar* text,
                                                             gpointer self);
static void __lambda14_ (BirdFontSpacingClass* self);
static void ___lambda14__bird_font_text_listener_signal_submit (BirdFontTextListener* _sender,
                                                         const gchar* text,
                                                         gpointer self);
static void bird_font_spacingclass_finalize (GObject * obj);
static GType bird_font_spacingclass_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_spacingclass_get_instance_private (BirdFontSpacingClass* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontSpacingClass_private_offset);
}

BirdFontSpacingClass*
bird_font_spacingclass_construct (GType object_type,
                                  const gchar* first,
                                  const gchar* next)
{
	BirdFontSpacingClass * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (first != NULL, NULL);
	g_return_val_if_fail (next != NULL, NULL);
	self = (BirdFontSpacingClass*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (first);
	_g_free0 (self->first);
	self->first = _tmp0_;
	_tmp1_ = g_strdup (next);
	_g_free0 (self->next);
	self->next = _tmp1_;
	return self;
}

BirdFontSpacingClass*
bird_font_spacingclass_new (const gchar* first,
                            const gchar* next)
{
	return bird_font_spacingclass_construct (BIRD_FONT_TYPE_SPACINGCLASS, first, next);
}

void
bird_font_spacingclass_set_first (BirdFontSpacingClass* self)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->update_first = TRUE;
	_tmp0_ = self->first;
	bird_font_spacingclass_update (self, _tmp0_);
}

void
bird_font_spacingclass_set_next (BirdFontSpacingClass* self)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->update_first = FALSE;
	_tmp0_ = self->next;
	bird_font_spacingclass_update (self, _tmp0_);
}

void
bird_font_spacingclass_update_class (BirdFontSpacingClass* self,
                                     const gchar* value,
                                     gboolean first)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (value != NULL);
	self->priv->update_first = first;
	bird_font_spacingclass_update (self, value);
}

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

static void
__lambda13_ (BirdFontSpacingClass* self,
             const gchar* text)
{
	gchar* v = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	g_return_if_fail (text != NULL);
	_tmp0_ = g_strdup (text);
	v = _tmp0_;
	_tmp2_ = v;
	if (g_str_has_prefix (_tmp2_, "U+")) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = v;
		_tmp1_ = g_str_has_prefix (_tmp3_, "u+");
	}
	if (_tmp1_) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = v;
		_tmp5_ = g_unichar_to_string (bird_font_font_to_unichar (_tmp4_));
		_tmp6_ = (gchar*) _tmp5_;
		_tmp7_ = g_strdup (_tmp6_);
		_g_free0 (v);
		v = _tmp7_;
		_g_free0 (_tmp6_);
	}
	if (self->priv->update_first) {
		const gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp8_ = v;
		_tmp9_ = g_strdup (_tmp8_);
		_g_free0 (self->first);
		self->first = _tmp9_;
	} else {
		const gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp10_ = v;
		_tmp11_ = g_strdup (_tmp10_);
		_g_free0 (self->next);
		self->next = _tmp11_;
	}
	_g_free0 (v);
}

static void
___lambda13__bird_font_text_listener_signal_text_input (BirdFontTextListener* _sender,
                                                        const gchar* text,
                                                        gpointer self)
{
	__lambda13_ ((BirdFontSpacingClass*) self, text);
}

static void
__lambda14_ (BirdFontSpacingClass* self)
{
	bird_font_tab_content_hide_text_input ();
	g_signal_emit (self, bird_font_spacingclass_signals[BIRD_FONT_SPACINGCLASS_UPDATED_SIGNAL], 0, self);
}

static void
___lambda14__bird_font_text_listener_signal_submit (BirdFontTextListener* _sender,
                                                    const gchar* text,
                                                    gpointer self)
{
	__lambda14_ ((BirdFontSpacingClass*) self);
}

static void
bird_font_spacingclass_update (BirdFontSpacingClass* self,
                               const gchar* val)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	BirdFontTextListener* _tmp4_;
	BirdFontTextListener* _tmp5_;
	BirdFontTextListener* _tmp6_;
	BirdFontTextListener* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (val != NULL);
	_tmp0_ = bird_font_t_ ("Character");
	_tmp1_ = _tmp0_;
	_tmp2_ = bird_font_t_ ("Set");
	_tmp3_ = _tmp2_;
	_tmp4_ = bird_font_text_listener_new (_tmp1_, val, _tmp3_);
	_g_object_unref0 (self->priv->listener);
	self->priv->listener = _tmp4_;
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	_tmp5_ = self->priv->listener;
	g_signal_connect_object (_tmp5_, "signal-text-input", (GCallback) ___lambda13__bird_font_text_listener_signal_text_input, self, 0);
	_tmp6_ = self->priv->listener;
	g_signal_connect_object (_tmp6_, "signal-submit", (GCallback) ___lambda14__bird_font_text_listener_signal_submit, self, 0);
	_tmp7_ = self->priv->listener;
	bird_font_tab_content_show_text_input (_tmp7_);
}

static void
bird_font_spacingclass_class_init (BirdFontSpacingClassClass * klass,
                                   gpointer klass_data)
{
	bird_font_spacingclass_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontSpacingClass_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_spacingclass_finalize;
	bird_font_spacingclass_signals[BIRD_FONT_SPACINGCLASS_UPDATED_SIGNAL] = g_signal_new ("updated", BIRD_FONT_TYPE_SPACINGCLASS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, BIRD_FONT_TYPE_SPACINGCLASS);
}

static void
bird_font_spacingclass_instance_init (BirdFontSpacingClass * self,
                                      gpointer klass)
{
	self->priv = bird_font_spacingclass_get_instance_private (self);
	self->priv->update_first = TRUE;
}

static void
bird_font_spacingclass_finalize (GObject * obj)
{
	BirdFontSpacingClass * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_SPACINGCLASS, BirdFontSpacingClass);
	_g_free0 (self->first);
	_g_free0 (self->next);
	_g_object_unref0 (self->priv->listener);
	G_OBJECT_CLASS (bird_font_spacingclass_parent_class)->finalize (obj);
}

static GType
bird_font_spacingclass_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontSpacingClassClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_spacingclass_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontSpacingClass), 0, (GInstanceInitFunc) bird_font_spacingclass_instance_init, NULL };
	GType bird_font_spacingclass_type_id;
	bird_font_spacingclass_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontSpacingClass", &g_define_type_info, 0);
	BirdFontSpacingClass_private_offset = g_type_add_instance_private (bird_font_spacingclass_type_id, sizeof (BirdFontSpacingClassPrivate));
	return bird_font_spacingclass_type_id;
}

GType
bird_font_spacingclass_get_type (void)
{
	static volatile gsize bird_font_spacingclass_type_id__once = 0;
	if (g_once_init_enter (&bird_font_spacingclass_type_id__once)) {
		GType bird_font_spacingclass_type_id;
		bird_font_spacingclass_type_id = bird_font_spacingclass_get_type_once ();
		g_once_init_leave (&bird_font_spacingclass_type_id__once, bird_font_spacingclass_type_id);
	}
	return bird_font_spacingclass_type_id__once;
}

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

