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

/*
 * Copyright (C) 2011-2014 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2011-2014 Red Hat, Inc.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

#include "libkkc/libkkc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gee.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  {
	KKC_KEY_EVENT_0_PROPERTY,
	KKC_KEY_EVENT_NAME_PROPERTY,
	KKC_KEY_EVENT_UNICODE_PROPERTY,
	KKC_KEY_EVENT_KEYVAL_PROPERTY,
	KKC_KEY_EVENT_KEYCODE_PROPERTY,
	KKC_KEY_EVENT_MODIFIERS_PROPERTY,
	KKC_KEY_EVENT_NUM_PROPERTIES
};
static GParamSpec* kkc_key_event_properties[KKC_KEY_EVENT_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 _KkcKeyEventPrivate {
	gchar* _name;
	gunichar _unicode;
	guint _keyval;
	guint _keycode;
	KkcModifierType _modifiers;
};

static gint KkcKeyEvent_private_offset;
static gpointer kkc_key_event_parent_class = NULL;

VALA_EXTERN guint kkc_key_event_utils_keyval_from_name (const gchar* name);
VALA_EXTERN gchar* kkc_key_event_utils_keyval_name (guint keyval);
VALA_EXTERN gunichar kkc_key_event_utils_keyval_unicode (guint keyval);
static void kkc_key_event_finalize (GObject * obj);
static GType kkc_key_event_get_type_once (void);
static void _vala_kkc_key_event_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_kkc_key_event_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec);
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);

GQuark
kkc_key_event_format_error_quark (void)
{
	return g_quark_from_static_string ("kkc-key-event-format-error-quark");
}

static GType
kkc_key_event_format_error_get_type_once (void)
{
	static const GEnumValue values[] = {{KKC_KEY_EVENT_FORMAT_ERROR_PARSE_FAILED, "KKC_KEY_EVENT_FORMAT_ERROR_PARSE_FAILED", "parse-failed"}, {KKC_KEY_EVENT_FORMAT_ERROR_KEYSYM_NOT_FOUND, "KKC_KEY_EVENT_FORMAT_ERROR_KEYSYM_NOT_FOUND", "keysym-not-found"}, {0, NULL, NULL}};
	GType kkc_key_event_format_error_type_id;
	kkc_key_event_format_error_type_id = g_enum_register_static ("KkcKeyEventFormatError", values);
	return kkc_key_event_format_error_type_id;
}

GType
kkc_key_event_format_error_get_type (void)
{
	static volatile gsize kkc_key_event_format_error_type_id__once = 0;
	if (g_once_init_enter (&kkc_key_event_format_error_type_id__once)) {
		GType kkc_key_event_format_error_type_id;
		kkc_key_event_format_error_type_id = kkc_key_event_format_error_get_type_once ();
		g_once_init_leave (&kkc_key_event_format_error_type_id__once, kkc_key_event_format_error_type_id);
	}
	return kkc_key_event_format_error_type_id__once;
}

/**
     * A set of bit-flags to indicate the state of modifier keys.
     */
static GType
kkc_modifier_type_get_type_once (void)
{
	static const GFlagsValue values[] = {{KKC_MODIFIER_TYPE_NONE, "KKC_MODIFIER_TYPE_NONE", "none"}, {KKC_MODIFIER_TYPE_SHIFT_MASK, "KKC_MODIFIER_TYPE_SHIFT_MASK", "shift-mask"}, {KKC_MODIFIER_TYPE_LOCK_MASK, "KKC_MODIFIER_TYPE_LOCK_MASK", "lock-mask"}, {KKC_MODIFIER_TYPE_CONTROL_MASK, "KKC_MODIFIER_TYPE_CONTROL_MASK", "control-mask"}, {KKC_MODIFIER_TYPE_MOD1_MASK, "KKC_MODIFIER_TYPE_MOD1_MASK", "mod1-mask"}, {KKC_MODIFIER_TYPE_MOD2_MASK, "KKC_MODIFIER_TYPE_MOD2_MASK", "mod2-mask"}, {KKC_MODIFIER_TYPE_MOD3_MASK, "KKC_MODIFIER_TYPE_MOD3_MASK", "mod3-mask"}, {KKC_MODIFIER_TYPE_MOD4_MASK, "KKC_MODIFIER_TYPE_MOD4_MASK", "mod4-mask"}, {KKC_MODIFIER_TYPE_MOD5_MASK, "KKC_MODIFIER_TYPE_MOD5_MASK", "mod5-mask"}, {KKC_MODIFIER_TYPE_LSHIFT_MASK, "KKC_MODIFIER_TYPE_LSHIFT_MASK", "lshift-mask"}, {KKC_MODIFIER_TYPE_RSHIFT_MASK, "KKC_MODIFIER_TYPE_RSHIFT_MASK", "rshift-mask"}, {KKC_MODIFIER_TYPE_SUPER_MASK, "KKC_MODIFIER_TYPE_SUPER_MASK", "super-mask"}, {KKC_MODIFIER_TYPE_HYPER_MASK, "KKC_MODIFIER_TYPE_HYPER_MASK", "hyper-mask"}, {KKC_MODIFIER_TYPE_META_MASK, "KKC_MODIFIER_TYPE_META_MASK", "meta-mask"}, {KKC_MODIFIER_TYPE_RELEASE_MASK, "KKC_MODIFIER_TYPE_RELEASE_MASK", "release-mask"}, {0, NULL, NULL}};
	GType kkc_modifier_type_type_id;
	kkc_modifier_type_type_id = g_flags_register_static ("KkcModifierType", values);
	return kkc_modifier_type_type_id;
}

GType
kkc_modifier_type_get_type (void)
{
	static volatile gsize kkc_modifier_type_type_id__once = 0;
	if (g_once_init_enter (&kkc_modifier_type_type_id__once)) {
		GType kkc_modifier_type_type_id;
		kkc_modifier_type_type_id = kkc_modifier_type_get_type_once ();
		g_once_init_leave (&kkc_modifier_type_type_id__once, kkc_modifier_type_type_id);
	}
	return kkc_modifier_type_type_id__once;
}

static inline gpointer
kkc_key_event_get_instance_private (KkcKeyEvent* self)
{
	return G_STRUCT_MEMBER_P (self, KkcKeyEvent_private_offset);
}

/**
         * Create a key event from string.
         *
         * @param key a string representation of a key event
         *
         * @return a new KeyEvent
         */
static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

KkcKeyEvent*
kkc_key_event_construct_from_string (GType object_type,
                                     const gchar* key,
                                     GError** error)
{
	KkcKeyEvent * self = NULL;
	KkcModifierType _modifiers = 0U;
	guint _keyval = 0U;
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (key != NULL, NULL);
	_modifiers = 0;
	_keyval = KKC_KEYSYMS_VoidSymbol;
	if (g_str_has_prefix (key, "(")) {
		_tmp0_ = g_str_has_suffix (key, ")");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar** strv = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gchar** _tmp5_;
		gint _tmp5__length1;
		gint strv_length1;
		gint _strv_size_;
		gint index = 0;
		gchar** _tmp30_;
		gint _tmp30__length1;
		const gchar* _tmp31_;
		_tmp1_ = string_slice (key, (glong) 1, (glong) -1);
		_tmp2_ = _tmp1_;
		_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, " ", 0);
		_tmp5_ = _tmp4_;
		_tmp5__length1 = _vala_array_length (_tmp3_);
		_g_free0 (_tmp2_);
		strv = _tmp5_;
		strv_length1 = _tmp5__length1;
		_strv_size_ = strv_length1;
		index = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				gchar** _tmp8_;
				gint _tmp8__length1;
				gchar** _tmp9_;
				gint _tmp9__length1;
				const gchar* _tmp10_;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = index;
					index = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				_tmp8_ = strv;
				_tmp8__length1 = strv_length1;
				if (!(index < (_tmp8__length1 - 1))) {
					break;
				}
				_tmp9_ = strv;
				_tmp9__length1 = strv_length1;
				_tmp10_ = _tmp9_[index];
				if (g_strcmp0 (_tmp10_, "shift") == 0) {
					_modifiers |= KKC_MODIFIER_TYPE_SHIFT_MASK;
				} else {
					gchar** _tmp11_;
					gint _tmp11__length1;
					const gchar* _tmp12_;
					_tmp11_ = strv;
					_tmp11__length1 = strv_length1;
					_tmp12_ = _tmp11_[index];
					if (g_strcmp0 (_tmp12_, "control") == 0) {
						_modifiers |= KKC_MODIFIER_TYPE_CONTROL_MASK;
					} else {
						gchar** _tmp13_;
						gint _tmp13__length1;
						const gchar* _tmp14_;
						_tmp13_ = strv;
						_tmp13__length1 = strv_length1;
						_tmp14_ = _tmp13_[index];
						if (g_strcmp0 (_tmp14_, "meta") == 0) {
							_modifiers |= KKC_MODIFIER_TYPE_META_MASK;
						} else {
							gchar** _tmp15_;
							gint _tmp15__length1;
							const gchar* _tmp16_;
							_tmp15_ = strv;
							_tmp15__length1 = strv_length1;
							_tmp16_ = _tmp15_[index];
							if (g_strcmp0 (_tmp16_, "hyper") == 0) {
								_modifiers |= KKC_MODIFIER_TYPE_HYPER_MASK;
							} else {
								gchar** _tmp17_;
								gint _tmp17__length1;
								const gchar* _tmp18_;
								_tmp17_ = strv;
								_tmp17__length1 = strv_length1;
								_tmp18_ = _tmp17_[index];
								if (g_strcmp0 (_tmp18_, "super") == 0) {
									_modifiers |= KKC_MODIFIER_TYPE_SUPER_MASK;
								} else {
									gchar** _tmp19_;
									gint _tmp19__length1;
									const gchar* _tmp20_;
									_tmp19_ = strv;
									_tmp19__length1 = strv_length1;
									_tmp20_ = _tmp19_[index];
									if (g_strcmp0 (_tmp20_, "alt") == 0) {
										_modifiers |= KKC_MODIFIER_TYPE_MOD1_MASK;
									} else {
										gchar** _tmp21_;
										gint _tmp21__length1;
										const gchar* _tmp22_;
										_tmp21_ = strv;
										_tmp21__length1 = strv_length1;
										_tmp22_ = _tmp21_[index];
										if (g_strcmp0 (_tmp22_, "lshift") == 0) {
											_modifiers |= KKC_MODIFIER_TYPE_LSHIFT_MASK;
										} else {
											gchar** _tmp23_;
											gint _tmp23__length1;
											const gchar* _tmp24_;
											_tmp23_ = strv;
											_tmp23__length1 = strv_length1;
											_tmp24_ = _tmp23_[index];
											if (g_strcmp0 (_tmp24_, "rshift") == 0) {
												_modifiers |= KKC_MODIFIER_TYPE_RSHIFT_MASK;
											} else {
												gchar** _tmp25_;
												gint _tmp25__length1;
												const gchar* _tmp26_;
												_tmp25_ = strv;
												_tmp25__length1 = strv_length1;
												_tmp26_ = _tmp25_[index];
												if (g_strcmp0 (_tmp26_, "release") == 0) {
													_modifiers |= KKC_MODIFIER_TYPE_RELEASE_MASK;
												} else {
													gchar** _tmp27_;
													gint _tmp27__length1;
													const gchar* _tmp28_;
													GError* _tmp29_;
													_tmp27_ = strv;
													_tmp27__length1 = strv_length1;
													_tmp28_ = _tmp27_[index];
													_tmp29_ = g_error_new (KKC_KEY_EVENT_FORMAT_ERROR, KKC_KEY_EVENT_FORMAT_ERROR_PARSE_FAILED, "unknown modifier %s", _tmp28_);
													_inner_error0_ = _tmp29_;
													if (_inner_error0_->domain == KKC_KEY_EVENT_FORMAT_ERROR) {
														g_propagate_error (error, _inner_error0_);
														strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
														_g_object_unref0 (self);
														return NULL;
													} else {
														strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
														g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
														g_clear_error (&_inner_error0_);
														return NULL;
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		_tmp30_ = strv;
		_tmp30__length1 = strv_length1;
		_tmp31_ = _tmp30_[index];
		_keyval = kkc_key_event_utils_keyval_from_name (_tmp31_);
		if (_keyval == KKC_KEYSYMS_VoidSymbol) {
			gchar** _tmp32_;
			gint _tmp32__length1;
			const gchar* _tmp33_;
			GError* _tmp34_;
			_tmp32_ = strv;
			_tmp32__length1 = strv_length1;
			_tmp33_ = _tmp32_[index];
			_tmp34_ = g_error_new (KKC_KEY_EVENT_FORMAT_ERROR, KKC_KEY_EVENT_FORMAT_ERROR_PARSE_FAILED, "unknown keyval %s", _tmp33_);
			_inner_error0_ = _tmp34_;
			if (_inner_error0_->domain == KKC_KEY_EVENT_FORMAT_ERROR) {
				g_propagate_error (error, _inner_error0_);
				strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
				_g_object_unref0 (self);
				return NULL;
			} else {
				strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
	} else {
		gint index = 0;
		gchar* _name = NULL;
		const gchar* _tmp49_;
		index = string_last_index_of (key, "-", 0);
		_name = NULL;
		if (index > 0) {
			gchar** mods = NULL;
			gchar* _tmp35_;
			gchar* _tmp36_;
			gchar** _tmp37_;
			gchar** _tmp38_;
			gchar** _tmp39_;
			gint _tmp39__length1;
			gint mods_length1;
			gint _mods_size_;
			gchar** _tmp40_;
			gint _tmp40__length1;
			gchar* _tmp47_;
			_tmp35_ = string_substring (key, (glong) 0, (glong) index);
			_tmp36_ = _tmp35_;
			_tmp38_ = _tmp37_ = g_strsplit (_tmp36_, "-", 0);
			_tmp39_ = _tmp38_;
			_tmp39__length1 = _vala_array_length (_tmp37_);
			_g_free0 (_tmp36_);
			mods = _tmp39_;
			mods_length1 = _tmp39__length1;
			_mods_size_ = mods_length1;
			_tmp40_ = mods;
			_tmp40__length1 = mods_length1;
			{
				gchar** mod_collection = NULL;
				gint mod_collection_length1 = 0;
				gint _mod_collection_size_ = 0;
				gint mod_it = 0;
				mod_collection = _tmp40_;
				mod_collection_length1 = _tmp40__length1;
				for (mod_it = 0; mod_it < mod_collection_length1; mod_it = mod_it + 1) {
					gchar* _tmp41_;
					gchar* mod = NULL;
					_tmp41_ = g_strdup (mod_collection[mod_it]);
					mod = _tmp41_;
					{
						const gchar* _tmp42_;
						_tmp42_ = mod;
						if (g_strcmp0 (_tmp42_, "S") == 0) {
							_modifiers |= KKC_MODIFIER_TYPE_SHIFT_MASK;
						} else {
							const gchar* _tmp43_;
							_tmp43_ = mod;
							if (g_strcmp0 (_tmp43_, "C") == 0) {
								_modifiers |= KKC_MODIFIER_TYPE_CONTROL_MASK;
							} else {
								const gchar* _tmp44_;
								_tmp44_ = mod;
								if (g_strcmp0 (_tmp44_, "A") == 0) {
									_modifiers |= KKC_MODIFIER_TYPE_MOD1_MASK;
								} else {
									const gchar* _tmp45_;
									_tmp45_ = mod;
									if (g_strcmp0 (_tmp45_, "M") == 0) {
										_modifiers |= KKC_MODIFIER_TYPE_META_MASK;
									} else {
										const gchar* _tmp46_;
										_tmp46_ = mod;
										if (g_strcmp0 (_tmp46_, "G") == 0) {
											_modifiers |= KKC_MODIFIER_TYPE_MOD5_MASK;
										}
									}
								}
							}
						}
						_g_free0 (mod);
					}
				}
			}
			_tmp47_ = string_substring (key, (glong) (index + 1), (glong) -1);
			_g_free0 (_name);
			_name = _tmp47_;
			mods = (_vala_array_free (mods, mods_length1, (GDestroyNotify) g_free), NULL);
		} else {
			gchar* _tmp48_;
			_modifiers = KKC_MODIFIER_TYPE_NONE;
			_tmp48_ = g_strdup (key);
			_g_free0 (_name);
			_name = _tmp48_;
		}
		_tmp49_ = _name;
		_keyval = kkc_key_event_utils_keyval_from_name (_tmp49_);
		if (_keyval == KKC_KEYSYMS_VoidSymbol) {
			const gchar* _tmp50_;
			GError* _tmp51_;
			_tmp50_ = _name;
			_tmp51_ = g_error_new (KKC_KEY_EVENT_FORMAT_ERROR, KKC_KEY_EVENT_FORMAT_ERROR_PARSE_FAILED, "unknown keyval %s", _tmp50_);
			_inner_error0_ = _tmp51_;
			if (_inner_error0_->domain == KKC_KEY_EVENT_FORMAT_ERROR) {
				g_propagate_error (error, _inner_error0_);
				_g_free0 (_name);
				_g_object_unref0 (self);
				return NULL;
			} else {
				_g_free0 (_name);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		_g_free0 (_name);
	}
	self = (KkcKeyEvent*) kkc_key_event_construct_from_x_event (object_type, _keyval, (guint) 0, _modifiers);
	return self;
}

KkcKeyEvent*
kkc_key_event_new_from_string (const gchar* key,
                               GError** error)
{
	return kkc_key_event_construct_from_string (KKC_TYPE_KEY_EVENT, key, error);
}

/**
         * Convert the KeyEvent to string.
         *
         * @return a string representing the KeyEvent
         */
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 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;
	}
}

gchar*
kkc_key_event_to_string (KkcKeyEvent* self)
{
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	gchar* _base = NULL;
	gchar* _tmp6_;
	KkcModifierType _tmp7_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->_name;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = self->priv->_name;
		_tmp3_ = g_strdup (_tmp2_);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	} else {
		gunichar _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = self->priv->_unicode;
		_tmp5_ = g_unichar_to_string (_tmp4_);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp5_;
	}
	_tmp6_ = _tmp0_;
	_tmp0_ = NULL;
	_base = _tmp6_;
	_tmp7_ = self->priv->_modifiers;
	if (_tmp7_ != 0) {
		GeeArrayList* elements = NULL;
		GeeArrayList* _tmp8_;
		KkcModifierType _tmp9_;
		KkcModifierType _tmp11_;
		KkcModifierType _tmp13_;
		KkcModifierType _tmp15_;
		KkcModifierType _tmp17_;
		KkcModifierType _tmp19_;
		KkcModifierType _tmp21_;
		KkcModifierType _tmp23_;
		KkcModifierType _tmp25_;
		GeeArrayList* _tmp27_;
		const gchar* _tmp28_;
		GeeArrayList* _tmp29_;
		gchar** array = NULL;
		GeeArrayList* _tmp30_;
		gint _tmp31_ = 0;
		gpointer* _tmp32_;
		gint array_length1;
		gint _array_size_;
		gchar** _tmp33_;
		gint _tmp33__length1;
		gchar* _tmp34_;
		gchar* _tmp35_;
		gchar* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		gchar* _tmp39_;
		_tmp8_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
		elements = _tmp8_;
		_tmp9_ = self->priv->_modifiers;
		if ((_tmp9_ & KKC_MODIFIER_TYPE_SHIFT_MASK) != 0) {
			GeeArrayList* _tmp10_;
			_tmp10_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, "shift");
		}
		_tmp11_ = self->priv->_modifiers;
		if ((_tmp11_ & KKC_MODIFIER_TYPE_CONTROL_MASK) != 0) {
			GeeArrayList* _tmp12_;
			_tmp12_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, "control");
		}
		_tmp13_ = self->priv->_modifiers;
		if ((_tmp13_ & KKC_MODIFIER_TYPE_META_MASK) != 0) {
			GeeArrayList* _tmp14_;
			_tmp14_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, "meta");
		}
		_tmp15_ = self->priv->_modifiers;
		if ((_tmp15_ & KKC_MODIFIER_TYPE_HYPER_MASK) != 0) {
			GeeArrayList* _tmp16_;
			_tmp16_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, "hyper");
		}
		_tmp17_ = self->priv->_modifiers;
		if ((_tmp17_ & KKC_MODIFIER_TYPE_SUPER_MASK) != 0) {
			GeeArrayList* _tmp18_;
			_tmp18_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp18_, "super");
		}
		_tmp19_ = self->priv->_modifiers;
		if ((_tmp19_ & KKC_MODIFIER_TYPE_MOD1_MASK) != 0) {
			GeeArrayList* _tmp20_;
			_tmp20_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp20_, "alt");
		}
		_tmp21_ = self->priv->_modifiers;
		if ((_tmp21_ & KKC_MODIFIER_TYPE_LSHIFT_MASK) != 0) {
			GeeArrayList* _tmp22_;
			_tmp22_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp22_, "lshift");
		}
		_tmp23_ = self->priv->_modifiers;
		if ((_tmp23_ & KKC_MODIFIER_TYPE_RSHIFT_MASK) != 0) {
			GeeArrayList* _tmp24_;
			_tmp24_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp24_, "rshift");
		}
		_tmp25_ = self->priv->_modifiers;
		if ((_tmp25_ & KKC_MODIFIER_TYPE_RELEASE_MASK) != 0) {
			GeeArrayList* _tmp26_;
			_tmp26_ = elements;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp26_, "release");
		}
		_tmp27_ = elements;
		_tmp28_ = _base;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp27_, _tmp28_);
		_tmp29_ = elements;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp29_, NULL);
		_tmp30_ = elements;
		_tmp32_ = gee_collection_to_array ((GeeCollection*) _tmp30_, &_tmp31_);
		array = _tmp32_;
		array_length1 = _tmp31_;
		_array_size_ = array_length1;
		array_length1 = -1;
		_tmp33_ = array;
		_tmp33__length1 = array_length1;
		_tmp34_ = _vala_g_strjoinv (" ", _tmp33_, (gint) _tmp33__length1);
		_tmp35_ = _tmp34_;
		_tmp36_ = g_strconcat ("(", _tmp35_, NULL);
		_tmp37_ = _tmp36_;
		_tmp38_ = g_strconcat (_tmp37_, ")", NULL);
		_tmp39_ = _tmp38_;
		_g_free0 (_tmp37_);
		_g_free0 (_tmp35_);
		result = _tmp39_;
		array = (_vala_array_free (array, array_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (elements);
		_g_free0 (_base);
		_g_free0 (_tmp0_);
		return result;
	} else {
		result = _base;
		_g_free0 (_tmp0_);
		return result;
	}
}

KkcKeyEvent*
kkc_key_event_construct_from_x_event (GType object_type,
                                      guint keyval,
                                      guint keycode,
                                      KkcModifierType modifiers)
{
	KkcKeyEvent * self = NULL;
	self = (KkcKeyEvent*) kkc_key_event_construct (object_type, keyval, keycode, modifiers);
	return self;
}

KkcKeyEvent*
kkc_key_event_new_from_x_event (guint keyval,
                                guint keycode,
                                KkcModifierType modifiers)
{
	return kkc_key_event_construct_from_x_event (KKC_TYPE_KEY_EVENT, keyval, keycode, modifiers);
}

/**
         * Create a key event from an X event.
         *
         * @param keyval an X keysym
         * @param keycode an X keycode
         * @param modifiers modifier mask
         *
         * @return a new KeyEvent
         */
KkcKeyEvent*
kkc_key_event_construct (GType object_type,
                         guint keyval,
                         guint keycode,
                         KkcModifierType modifiers)
{
	KkcKeyEvent * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	self = (KkcKeyEvent*) g_object_new (object_type, NULL);
	_tmp0_ = kkc_key_event_utils_keyval_name (keyval);
	_tmp1_ = _tmp0_;
	kkc_key_event_set_name (self, _tmp1_);
	_g_free0 (_tmp1_);
	kkc_key_event_set_unicode (self, kkc_key_event_utils_keyval_unicode (keyval));
	if (((guint) 0x21) <= keyval) {
		_tmp2_ = keyval < ((guint) 0x7F);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		modifiers = modifiers & (~(KKC_MODIFIER_TYPE_SHIFT_MASK | KKC_MODIFIER_TYPE_MOD5_MASK));
	}
	kkc_key_event_set_keyval (self, keyval);
	kkc_key_event_set_keycode (self, keycode);
	kkc_key_event_set_modifiers (self, modifiers);
	return self;
}

KkcKeyEvent*
kkc_key_event_new (guint keyval,
                   guint keycode,
                   KkcModifierType modifiers)
{
	return kkc_key_event_construct (KKC_TYPE_KEY_EVENT, keyval, keycode, modifiers);
}

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

void
kkc_key_event_set_name (KkcKeyEvent* self,
                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_key_event_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, kkc_key_event_properties[KKC_KEY_EVENT_NAME_PROPERTY]);
	}
}

gunichar
kkc_key_event_get_unicode (KkcKeyEvent* self)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_unicode;
	return result;
}

void
kkc_key_event_set_unicode (KkcKeyEvent* self,
                           gunichar value)
{
	gunichar old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_key_event_get_unicode (self);
	if (old_value != value) {
		self->priv->_unicode = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_key_event_properties[KKC_KEY_EVENT_UNICODE_PROPERTY]);
	}
}

guint
kkc_key_event_get_keyval (KkcKeyEvent* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_keyval;
	return result;
}

void
kkc_key_event_set_keyval (KkcKeyEvent* self,
                          guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_key_event_get_keyval (self);
	if (old_value != value) {
		self->priv->_keyval = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_key_event_properties[KKC_KEY_EVENT_KEYVAL_PROPERTY]);
	}
}

guint
kkc_key_event_get_keycode (KkcKeyEvent* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_keycode;
	return result;
}

void
kkc_key_event_set_keycode (KkcKeyEvent* self,
                           guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_key_event_get_keycode (self);
	if (old_value != value) {
		self->priv->_keycode = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_key_event_properties[KKC_KEY_EVENT_KEYCODE_PROPERTY]);
	}
}

KkcModifierType
kkc_key_event_get_modifiers (KkcKeyEvent* self)
{
	KkcModifierType result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_modifiers;
	return result;
}

void
kkc_key_event_set_modifiers (KkcKeyEvent* self,
                             KkcModifierType value)
{
	KkcModifierType old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_key_event_get_modifiers (self);
	if (old_value != value) {
		self->priv->_modifiers = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_key_event_properties[KKC_KEY_EVENT_MODIFIERS_PROPERTY]);
	}
}

static void
kkc_key_event_class_init (KkcKeyEventClass * klass,
                          gpointer klass_data)
{
	kkc_key_event_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcKeyEvent_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_key_event_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_kkc_key_event_set_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_key_event_finalize;
	/**
	         * The base name of the KeyEvent.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEY_EVENT_NAME_PROPERTY, kkc_key_event_properties[KKC_KEY_EVENT_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	         * The base unicode output of the KeyEvent.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEY_EVENT_UNICODE_PROPERTY, kkc_key_event_properties[KKC_KEY_EVENT_UNICODE_PROPERTY] = g_param_spec_uint ("unicode", "unicode", "unicode", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	         * X keyval.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEY_EVENT_KEYVAL_PROPERTY, kkc_key_event_properties[KKC_KEY_EVENT_KEYVAL_PROPERTY] = g_param_spec_uint ("keyval", "keyval", "keyval", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	         * X keycode.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEY_EVENT_KEYCODE_PROPERTY, kkc_key_event_properties[KKC_KEY_EVENT_KEYCODE_PROPERTY] = g_param_spec_uint ("keycode", "keycode", "keycode", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	         * Modifier mask.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEY_EVENT_MODIFIERS_PROPERTY, kkc_key_event_properties[KKC_KEY_EVENT_MODIFIERS_PROPERTY] = g_param_spec_flags ("modifiers", "modifiers", "modifiers", KKC_TYPE_MODIFIER_TYPE, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
kkc_key_event_instance_init (KkcKeyEvent * self,
                             gpointer klass)
{
	self->priv = kkc_key_event_get_instance_private (self);
}

static void
kkc_key_event_finalize (GObject * obj)
{
	KkcKeyEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_KEY_EVENT, KkcKeyEvent);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (kkc_key_event_parent_class)->finalize (obj);
}

/**
     * Object representing a key event.
     */
static GType
kkc_key_event_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcKeyEventClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_key_event_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcKeyEvent), 0, (GInstanceInitFunc) kkc_key_event_instance_init, NULL };
	GType kkc_key_event_type_id;
	kkc_key_event_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcKeyEvent", &g_define_type_info, 0);
	KkcKeyEvent_private_offset = g_type_add_instance_private (kkc_key_event_type_id, sizeof (KkcKeyEventPrivate));
	return kkc_key_event_type_id;
}

GType
kkc_key_event_get_type (void)
{
	static volatile gsize kkc_key_event_type_id__once = 0;
	if (g_once_init_enter (&kkc_key_event_type_id__once)) {
		GType kkc_key_event_type_id;
		kkc_key_event_type_id = kkc_key_event_get_type_once ();
		g_once_init_leave (&kkc_key_event_type_id__once, kkc_key_event_type_id);
	}
	return kkc_key_event_type_id__once;
}

static void
_vala_kkc_key_event_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	KkcKeyEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_KEY_EVENT, KkcKeyEvent);
	switch (property_id) {
		case KKC_KEY_EVENT_NAME_PROPERTY:
		g_value_set_string (value, kkc_key_event_get_name (self));
		break;
		case KKC_KEY_EVENT_UNICODE_PROPERTY:
		g_value_set_uint (value, kkc_key_event_get_unicode (self));
		break;
		case KKC_KEY_EVENT_KEYVAL_PROPERTY:
		g_value_set_uint (value, kkc_key_event_get_keyval (self));
		break;
		case KKC_KEY_EVENT_KEYCODE_PROPERTY:
		g_value_set_uint (value, kkc_key_event_get_keycode (self));
		break;
		case KKC_KEY_EVENT_MODIFIERS_PROPERTY:
		g_value_set_flags (value, kkc_key_event_get_modifiers (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_kkc_key_event_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	KkcKeyEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_KEY_EVENT, KkcKeyEvent);
	switch (property_id) {
		case KKC_KEY_EVENT_NAME_PROPERTY:
		kkc_key_event_set_name (self, g_value_get_string (value));
		break;
		case KKC_KEY_EVENT_UNICODE_PROPERTY:
		kkc_key_event_set_unicode (self, g_value_get_uint (value));
		break;
		case KKC_KEY_EVENT_KEYVAL_PROPERTY:
		kkc_key_event_set_keyval (self, g_value_get_uint (value));
		break;
		case KKC_KEY_EVENT_KEYCODE_PROPERTY:
		kkc_key_event_set_keycode (self, g_value_get_uint (value));
		break;
		case KKC_KEY_EVENT_MODIFIERS_PROPERTY:
		kkc_key_event_set_modifiers (self, g_value_get_flags (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

