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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include "libdino.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 DINO_UI_TYPE_SMILEY_CONVERTER (dino_ui_smiley_converter_get_type ())
#define DINO_UI_SMILEY_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_SMILEY_CONVERTER, DinoUiSmileyConverter))
#define DINO_UI_SMILEY_CONVERTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_SMILEY_CONVERTER, DinoUiSmileyConverterClass))
#define DINO_UI_IS_SMILEY_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_SMILEY_CONVERTER))
#define DINO_UI_IS_SMILEY_CONVERTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_SMILEY_CONVERTER))
#define DINO_UI_SMILEY_CONVERTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_SMILEY_CONVERTER, DinoUiSmileyConverterClass))

typedef struct _DinoUiSmileyConverter DinoUiSmileyConverter;
typedef struct _DinoUiSmileyConverterClass DinoUiSmileyConverterClass;
typedef struct _DinoUiSmileyConverterPrivate DinoUiSmileyConverterPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __vala_GtkTextIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTextIter_free (var), NULL)))
typedef struct _DinoUiParamSpecSmileyConverter DinoUiParamSpecSmileyConverter;

struct _DinoUiSmileyConverter {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DinoUiSmileyConverterPrivate * priv;
};

struct _DinoUiSmileyConverterClass {
	GTypeClass parent_class;
	void (*finalize) (DinoUiSmileyConverter *self);
};

struct _DinoUiSmileyConverterPrivate {
	GtkTextView* text_input;
	GRegex* whitespace_regex;
};

struct _DinoUiParamSpecSmileyConverter {
	GParamSpec parent_instance;
};

static gint DinoUiSmileyConverter_private_offset;
static gpointer dino_ui_smiley_converter_parent_class = NULL;
static GeeHashMap* dino_ui_smiley_converter_smiley_translations;
static GeeHashMap* dino_ui_smiley_converter_smiley_translations = NULL;

VALA_EXTERN gpointer dino_ui_smiley_converter_ref (gpointer instance);
VALA_EXTERN void dino_ui_smiley_converter_unref (gpointer instance);
VALA_EXTERN GParamSpec* dino_ui_param_spec_smiley_converter (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void dino_ui_value_set_smiley_converter (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void dino_ui_value_take_smiley_converter (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer dino_ui_value_get_smiley_converter (const GValue* value);
VALA_EXTERN GType dino_ui_smiley_converter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiSmileyConverter, dino_ui_smiley_converter_unref)
VALA_EXTERN DinoUiSmileyConverter* dino_ui_smiley_converter_new (GtkTextView* text_input);
VALA_EXTERN DinoUiSmileyConverter* dino_ui_smiley_converter_construct (GType object_type,
                                                           GtkTextView* text_input);
VALA_EXTERN gboolean dino_ui_smiley_converter_on_text_input_key_press (DinoUiSmileyConverter* self,
                                                           guint keyval,
                                                           guint keycode,
                                                           GdkModifierType state);
static gboolean _dino_ui_smiley_converter_on_text_input_key_press_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                                 guint keyval,
                                                                                                 guint keycode,
                                                                                                 GdkModifierType state,
                                                                                                 gpointer self);
static void dino_ui_smiley_converter_check_convert (DinoUiSmileyConverter* self);
static void _vala_GtkTextIter_free (GtkTextIter* self);
static GtkTextIter* _vala_GtkTextIter_copy (GtkTextIter* self);
static void dino_ui_smiley_converter_finalize (DinoUiSmileyConverter * obj);
static GType dino_ui_smiley_converter_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GRegex* _tmp_regex_0 = NULL;

static inline gpointer
dino_ui_smiley_converter_get_instance_private (DinoUiSmileyConverter* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiSmileyConverter_private_offset);
}

static inline GRegex*
_thread_safe_regex_init (GRegex** re,
                         const gchar * pattern,
                         GRegexCompileFlags compile_flags)
{
	if (g_once_init_enter ((volatile gsize*) re)) {
		GRegex* val = g_regex_new (pattern, compile_flags, 0, NULL);
		g_once_init_leave ((volatile gsize*) re, (gsize) val);
	}
	return *re;
}

static gpointer
_g_regex_ref0 (gpointer self)
{
	return self ? g_regex_ref (self) : NULL;
}

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

static gboolean
_dino_ui_smiley_converter_on_text_input_key_press_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                        guint keyval,
                                                                                        guint keycode,
                                                                                        GdkModifierType state,
                                                                                        gpointer self)
{
	gboolean result;
	result = dino_ui_smiley_converter_on_text_input_key_press ((DinoUiSmileyConverter*) self, keyval, keycode, state);
	return result;
}

DinoUiSmileyConverter*
dino_ui_smiley_converter_construct (GType object_type,
                                    GtkTextView* text_input)
{
	DinoUiSmileyConverter* self = NULL;
	GtkTextView* _tmp0_;
	GtkEventControllerKey* text_input_key_events = NULL;
	gchar* _tmp1_;
	GtkEventControllerKey* _tmp2_ = NULL;
	GtkEventController* _tmp3_;
	g_return_val_if_fail (text_input != NULL, NULL);
	self = (DinoUiSmileyConverter*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (text_input);
	_g_object_unref0 (self->priv->text_input);
	self->priv->text_input = _tmp0_;
	_tmp1_ = g_strdup ("dino-smiley-converter-key-events");
	_tmp2_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	gtk_event_controller_set_name ((GtkEventController*) _tmp2_, _tmp1_);
	_g_free0 (_tmp1_);
	text_input_key_events = _tmp2_;
	g_signal_connect (text_input_key_events, "key-pressed", (GCallback) _dino_ui_smiley_converter_on_text_input_key_press_gtk_event_controller_key_key_pressed, self);
	_tmp3_ = _g_object_ref0 ((GtkEventController*) text_input_key_events);
	gtk_widget_add_controller ((GtkWidget*) text_input, _tmp3_);
	_g_object_unref0 (text_input_key_events);
	return self;
}

DinoUiSmileyConverter*
dino_ui_smiley_converter_new (GtkTextView* text_input)
{
	return dino_ui_smiley_converter_construct (DINO_UI_TYPE_SMILEY_CONVERTER, text_input);
}

gboolean
dino_ui_smiley_converter_on_text_input_key_press (DinoUiSmileyConverter* self,
                                                  guint keyval,
                                                  guint keycode,
                                                  GdkModifierType state)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (keyval == GDK_KEY_space) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = keyval == GDK_KEY_Return;
	}
	if (_tmp0_) {
		dino_ui_smiley_converter_check_convert (self);
	}
	result = FALSE;
	return result;
}

static void
_vala_GtkTextIter_free (GtkTextIter* self)
{
	g_boxed_free (gtk_text_iter_get_type (), self);
}

static GtkTextIter*
_vala_GtkTextIter_copy (GtkTextIter* self)
{
	return g_boxed_copy (gtk_text_iter_get_type (), self);
}

static gpointer
__vala_GtkTextIter_copy0 (gpointer self)
{
	return self ? _vala_GtkTextIter_copy (self) : NULL;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static void
dino_ui_smiley_converter_check_convert (DinoUiSmileyConverter* self)
{
	DinoApplication* _tmp0_;
	DinoEntitiesSettings* _tmp1_;
	DinoEntitiesSettings* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GtkTextIter* start_iter = NULL;
	GtkTextView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextIter _tmp8_ = {0};
	GtkTextIter _tmp9_;
	GtkTextIter* _tmp10_;
	GtkTextIter* cursor_iter = NULL;
	GtkTextView* _tmp11_;
	GtkTextBuffer* _tmp12_;
	GtkTextBuffer* _tmp13_;
	GtkTextView* _tmp14_;
	GtkTextBuffer* _tmp15_;
	GtkTextBuffer* _tmp16_;
	GtkTextMark* _tmp17_;
	GtkTextIter _tmp18_ = {0};
	GtkTextIter _tmp19_;
	GtkTextIter* _tmp20_;
	gboolean _tmp21_ = FALSE;
	GtkTextIter* _tmp22_;
	gchar* text = NULL;
	GtkTextView* _tmp24_;
	GtkTextBuffer* _tmp25_;
	GtkTextBuffer* _tmp26_;
	GtkTextIter* _tmp27_;
	GtkTextIter* _tmp28_;
	GtkTextIter _tmp29_;
	GtkTextIter _tmp30_;
	gchar* _tmp31_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dino_application_get_default ();
	_tmp1_ = dino_application_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_entities_settings_get_convert_utf8_smileys (_tmp2_);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		return;
	}
	_tmp5_ = self->priv->text_input;
	_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_text_buffer_get_start_iter (_tmp7_, &_tmp8_);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp9_ = _tmp8_;
	_tmp10_ = __vala_GtkTextIter_copy0 (&_tmp9_);
	start_iter = _tmp10_;
	_tmp11_ = self->priv->text_input;
	_tmp12_ = gtk_text_view_get_buffer (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->text_input;
	_tmp15_ = gtk_text_view_get_buffer (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = gtk_text_buffer_get_insert (_tmp16_);
	gtk_text_buffer_get_iter_at_mark (_tmp13_, &_tmp18_, _tmp17_);
	__vala_GtkTextIter_free0 (cursor_iter);
	_tmp19_ = _tmp18_;
	_tmp20_ = __vala_GtkTextIter_copy0 (&_tmp19_);
	cursor_iter = _tmp20_;
	_tmp22_ = start_iter;
	if (_tmp22_ == NULL) {
		_tmp21_ = TRUE;
	} else {
		GtkTextIter* _tmp23_;
		_tmp23_ = cursor_iter;
		_tmp21_ = _tmp23_ == NULL;
	}
	if (_tmp21_) {
		__vala_GtkTextIter_free0 (cursor_iter);
		__vala_GtkTextIter_free0 (start_iter);
		return;
	}
	_tmp24_ = self->priv->text_input;
	_tmp25_ = gtk_text_view_get_buffer (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = start_iter;
	_tmp28_ = cursor_iter;
	_tmp29_ = *_tmp27_;
	_tmp30_ = *_tmp28_;
	_tmp31_ = gtk_text_buffer_get_text (_tmp26_, &_tmp29_, &_tmp30_, TRUE);
	text = _tmp31_;
	{
		GeeIterator* _smiley_it = NULL;
		GeeHashMap* _tmp32_;
		GeeSet* _tmp33_;
		GeeSet* _tmp34_;
		GeeSet* _tmp35_;
		GeeIterator* _tmp36_;
		GeeIterator* _tmp37_;
		_tmp32_ = dino_ui_smiley_converter_smiley_translations;
		_tmp33_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = _tmp34_;
		_tmp36_ = gee_iterable_iterator ((GeeIterable*) _tmp35_);
		_tmp37_ = _tmp36_;
		_g_object_unref0 (_tmp35_);
		_smiley_it = _tmp37_;
		while (TRUE) {
			GeeIterator* _tmp38_;
			gchar* smiley = NULL;
			GeeIterator* _tmp39_;
			gpointer _tmp40_;
			const gchar* _tmp41_;
			const gchar* _tmp42_;
			_tmp38_ = _smiley_it;
			if (!gee_iterator_next (_tmp38_)) {
				break;
			}
			_tmp39_ = _smiley_it;
			_tmp40_ = gee_iterator_get (_tmp39_);
			smiley = (gchar*) _tmp40_;
			_tmp41_ = text;
			_tmp42_ = smiley;
			if (g_str_has_suffix (_tmp41_, _tmp42_)) {
				gboolean _tmp43_ = FALSE;
				const gchar* _tmp44_;
				gint _tmp45_;
				gint _tmp46_;
				const gchar* _tmp47_;
				gint _tmp48_;
				gint _tmp49_;
				_tmp44_ = text;
				_tmp45_ = strlen (_tmp44_);
				_tmp46_ = _tmp45_;
				_tmp47_ = smiley;
				_tmp48_ = strlen (_tmp47_);
				_tmp49_ = _tmp48_;
				if (_tmp46_ == _tmp49_) {
					_tmp43_ = TRUE;
				} else {
					GRegex* _tmp50_;
					const gchar* _tmp51_;
					const gchar* _tmp52_;
					gint _tmp53_;
					gint _tmp54_;
					const gchar* _tmp55_;
					gint _tmp56_;
					gint _tmp57_;
					gchar* _tmp58_;
					gchar* _tmp59_;
					_tmp50_ = self->priv->whitespace_regex;
					_tmp51_ = text;
					_tmp52_ = text;
					_tmp53_ = strlen (_tmp52_);
					_tmp54_ = _tmp53_;
					_tmp55_ = smiley;
					_tmp56_ = strlen (_tmp55_);
					_tmp57_ = _tmp56_;
					_tmp58_ = g_strdup_printf ("%c", string_get (_tmp51_, (glong) ((_tmp54_ - _tmp57_) - 1)));
					_tmp59_ = _tmp58_;
					_tmp43_ = g_regex_match (_tmp50_, _tmp59_, 0, NULL);
					_g_free0 (_tmp59_);
				}
				if (_tmp43_) {
					GtkTextIter* end_iter = NULL;
					GtkTextView* _tmp60_;
					GtkTextBuffer* _tmp61_;
					GtkTextBuffer* _tmp62_;
					GtkTextIter _tmp63_ = {0};
					GtkTextIter _tmp64_;
					GtkTextIter* _tmp65_;
					GtkTextIter* _tmp66_;
					GtkTextIter smiley_start_iter = {0};
					GtkTextIter* _tmp67_;
					const gchar* _tmp68_;
					gint _tmp69_;
					gint _tmp70_;
					GtkTextView* _tmp71_;
					GtkTextBuffer* _tmp72_;
					GtkTextBuffer* _tmp73_;
					GtkTextView* _tmp74_;
					GtkTextBuffer* _tmp75_;
					GtkTextBuffer* _tmp76_;
					GeeHashMap* _tmp77_;
					const gchar* _tmp78_;
					gpointer _tmp79_;
					gchar* _tmp80_;
					GeeHashMap* _tmp81_;
					const gchar* _tmp82_;
					gpointer _tmp83_;
					gchar* _tmp84_;
					gint _tmp85_;
					gint _tmp86_;
					_tmp60_ = self->priv->text_input;
					_tmp61_ = gtk_text_view_get_buffer (_tmp60_);
					_tmp62_ = _tmp61_;
					gtk_text_buffer_get_end_iter (_tmp62_, &_tmp63_);
					__vala_GtkTextIter_free0 (end_iter);
					_tmp64_ = _tmp63_;
					_tmp65_ = __vala_GtkTextIter_copy0 (&_tmp64_);
					end_iter = _tmp65_;
					_tmp66_ = end_iter;
					if (_tmp66_ == NULL) {
						__vala_GtkTextIter_free0 (end_iter);
						_g_free0 (smiley);
						continue;
					}
					_tmp67_ = cursor_iter;
					smiley_start_iter = *_tmp67_;
					_tmp68_ = smiley;
					_tmp69_ = strlen (_tmp68_);
					_tmp70_ = _tmp69_;
					gtk_text_iter_backward_chars (&smiley_start_iter, _tmp70_);
					_tmp71_ = self->priv->text_input;
					_tmp72_ = gtk_text_view_get_buffer (_tmp71_);
					_tmp73_ = _tmp72_;
					gtk_text_buffer_delete (_tmp73_, &smiley_start_iter, cursor_iter);
					_tmp74_ = self->priv->text_input;
					_tmp75_ = gtk_text_view_get_buffer (_tmp74_);
					_tmp76_ = _tmp75_;
					_tmp77_ = dino_ui_smiley_converter_smiley_translations;
					_tmp78_ = smiley;
					_tmp79_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp77_, _tmp78_);
					_tmp80_ = (gchar*) _tmp79_;
					_tmp81_ = dino_ui_smiley_converter_smiley_translations;
					_tmp82_ = smiley;
					_tmp83_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp81_, _tmp82_);
					_tmp84_ = (gchar*) _tmp83_;
					_tmp85_ = strlen (_tmp84_);
					_tmp86_ = _tmp85_;
					g_signal_emit_by_name (_tmp76_, "insert-text", cursor_iter, _tmp80_, _tmp86_);
					_g_free0 (_tmp84_);
					_g_free0 (_tmp80_);
					__vala_GtkTextIter_free0 (end_iter);
				}
			}
			_g_free0 (smiley);
		}
		_g_object_unref0 (_smiley_it);
	}
	_g_free0 (text);
	__vala_GtkTextIter_free0 (cursor_iter);
	__vala_GtkTextIter_free0 (start_iter);
}

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

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

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

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

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

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

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

void
dino_ui_value_set_smiley_converter (GValue* value,
                                    gpointer v_object)
{
	DinoUiSmileyConverter * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_UI_TYPE_SMILEY_CONVERTER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_UI_TYPE_SMILEY_CONVERTER));
		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;
		dino_ui_smiley_converter_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_ui_smiley_converter_unref (old);
	}
}

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

static void
dino_ui_smiley_converter_class_init (DinoUiSmileyConverterClass * klass,
                                     gpointer klass_data)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	GeeHashMap* _tmp4_;
	GeeHashMap* _tmp5_;
	GeeHashMap* _tmp6_;
	GeeHashMap* _tmp7_;
	GeeHashMap* _tmp8_;
	GeeHashMap* _tmp9_;
	GeeHashMap* _tmp10_;
	GeeHashMap* _tmp11_;
	GeeHashMap* _tmp12_;
	GeeHashMap* _tmp13_;
	GeeHashMap* _tmp14_;
	GeeHashMap* _tmp15_;
	dino_ui_smiley_converter_parent_class = g_type_class_peek_parent (klass);
	((DinoUiSmileyConverterClass *) klass)->finalize = dino_ui_smiley_converter_finalize;
	g_type_class_adjust_private_offset (klass, &DinoUiSmileyConverter_private_offset);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	dino_ui_smiley_converter_smiley_translations = _tmp0_;
	_tmp1_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, ":)", "🙂");
	_tmp2_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, ":D", "😀");
	_tmp3_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, ";)", "😉");
	_tmp4_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, "O:)", "😇");
	_tmp5_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, "O:-)", "😇");
	_tmp6_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, "]:>", "😈");
	_tmp7_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp7_, ":o", "😮");
	_tmp8_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp8_, ":P", "😛");
	_tmp9_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, ";P", "😜");
	_tmp10_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp10_, ":(", "🙁");
	_tmp11_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp11_, ":'(", "😢");
	_tmp12_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, ":/", "😕");
	_tmp13_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, "<3", "❤️");
	_tmp14_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp14_, ":*", "😘️");
	_tmp15_ = dino_ui_smiley_converter_smiley_translations;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp15_, ":-*", "😘️");
}

static void
dino_ui_smiley_converter_instance_init (DinoUiSmileyConverter * self,
                                        gpointer klass)
{
	GRegex* _tmp0_;
	self->priv = dino_ui_smiley_converter_get_instance_private (self);
	_tmp0_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_0, "\\s", 0));
	self->priv->whitespace_regex = _tmp0_;
	self->ref_count = 1;
}

static void
dino_ui_smiley_converter_finalize (DinoUiSmileyConverter * obj)
{
	DinoUiSmileyConverter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_SMILEY_CONVERTER, DinoUiSmileyConverter);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->text_input);
	_g_regex_unref0 (self->priv->whitespace_regex);
}

static GType
dino_ui_smiley_converter_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_ui_value_smiley_converter_init, dino_ui_value_smiley_converter_free_value, dino_ui_value_smiley_converter_copy_value, dino_ui_value_smiley_converter_peek_pointer, "p", dino_ui_value_smiley_converter_collect_value, "p", dino_ui_value_smiley_converter_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiSmileyConverterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_smiley_converter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiSmileyConverter), 0, (GInstanceInitFunc) dino_ui_smiley_converter_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 dino_ui_smiley_converter_type_id;
	dino_ui_smiley_converter_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoUiSmileyConverter", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoUiSmileyConverter_private_offset = g_type_add_instance_private (dino_ui_smiley_converter_type_id, sizeof (DinoUiSmileyConverterPrivate));
	return dino_ui_smiley_converter_type_id;
}

GType
dino_ui_smiley_converter_get_type (void)
{
	static volatile gsize dino_ui_smiley_converter_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_smiley_converter_type_id__once)) {
		GType dino_ui_smiley_converter_type_id;
		dino_ui_smiley_converter_type_id = dino_ui_smiley_converter_get_type_once ();
		g_once_init_leave (&dino_ui_smiley_converter_type_id__once, dino_ui_smiley_converter_type_id);
	}
	return dino_ui_smiley_converter_type_id__once;
}

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

void
dino_ui_smiley_converter_unref (gpointer instance)
{
	DinoUiSmileyConverter * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_UI_SMILEY_CONVERTER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

