/* keymap.c generated by valac 0.56.19, the Vala compiler
 * generated from keymap.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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "libkkc/libkkc.h"
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <config.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

#define KKC_TYPE_KEYMAP_COMMAND_ENTRY (kkc_keymap_command_entry_get_type ())
typedef struct _KkcKeymapCommandEntry KkcKeymapCommandEntry;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	KKC_KEYMAP_0_PROPERTY,
	KKC_KEYMAP_PARENT_PROPERTY,
	KKC_KEYMAP_NUM_PROPERTIES
};
static GParamSpec* kkc_keymap_properties[KKC_KEYMAP_NUM_PROPERTIES];

struct _KkcKeymapCommandEntry {
	gchar* name;
	gchar* label;
};

struct _KkcKeymapPrivate {
	KkcKeymap* _parent;
	GeeMap* map_entries;
};

static gint KkcKeymap_private_offset;
static gpointer kkc_keymap_parent_class = NULL;
static GeeMap* kkc_keymap__CommandTable;
static GeeMap* kkc_keymap__CommandTable = NULL;

VALA_EXTERN GType kkc_keymap_command_entry_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcKeymapCommandEntry* kkc_keymap_command_entry_dup (const KkcKeymapCommandEntry* self);
VALA_EXTERN void kkc_keymap_command_entry_free (KkcKeymapCommandEntry* self);
VALA_EXTERN void kkc_keymap_command_entry_copy (const KkcKeymapCommandEntry* self,
                                    KkcKeymapCommandEntry* dest);
VALA_EXTERN void kkc_keymap_command_entry_destroy (KkcKeymapCommandEntry* self);
static guint kkc_keymap_key_hash (KkcKeyEvent* a);
static guint _kkc_keymap_key_hash_gee_hash_data_func (gconstpointer v,
                                               gpointer self);
static gboolean kkc_keymap_key_equal (KkcKeyEvent* a,
                               KkcKeyEvent* b);
static gboolean _kkc_keymap_key_equal_gee_equal_data_func (gconstpointer a,
                                                    gconstpointer b,
                                                    gpointer self);
static KkcKeymapEntry* kkc_keymap_map_entries_to_array (KkcKeymap* self,
                                                 GeeMap* map_entries,
                                                 gint* result_length1);
static void _vala_array_add2 (KkcKeymapEntry* * array,
                       gint* length,
                       gint* size,
                       const KkcKeymapEntry* value);
static void kkc_keymap_finalize (GObject * obj);
static GType kkc_keymap_get_type_once (void);
static void _vala_kkc_keymap_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static void _vala_kkc_keymap_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec);

static const KkcKeymapCommandEntry KKC_KEYMAP_Commands[28] = {{"abort", N_ ("Abort")}, {"first-segment", N_ ("First Segment")}, {"last-segment", N_ ("Last Segment")}, {"commit", N_ ("Commit")}, {"complete", N_ ("Complete")}, {"delete", N_ ("Delete")}, {"delete-forward", N_ ("Delete Next Character")}, {"quote", N_ ("Quoted Insert")}, {"register", N_ ("Register Word")}, {"next-candidate", N_ ("Next Candidate")}, {"previous-candidate", N_ ("Previous Candidate")}, {"purge-candidate", N_ ("Purge Candidate")}, {"next-segment", N_ ("Next Segment")}, {"previous-segment", N_ ("Previous Segment")}, {"expand-segment", N_ ("Expand Segment")}, {"shrink-segment", N_ ("Shrink Segment")}, {"set-input-mode-hiragana", N_ ("Switch to Hiragana Input Mode")}, {"set-input-mode-katakana", N_ ("Switch to Katakana Input Mode")}, {"set-input-mode-hankaku-katakana", N_ ("Switch to Hankaku Katakana Input Mode")}, {"set-input-mode-latin", N_ ("Switch to Latin Input Mode")}, {"set-input-mode-wide-latin", N_ ("Switch to Wide Latin Input Mode")}, {"set-input-mode-direct", N_ ("Switch to Direct Input Mode")}, {"convert-hiragana", N_ ("Convert to Hiragana")}, {"convert-katakana", N_ ("Convert to Katakana")}, {"convert-hankaku-katakana", N_ ("Convert to Hankaku Katakana")}, {"convert-latin", N_ ("Convert to Latin")}, {"convert-wide-latin", N_ ("Convert to Wide Latin")}, {"original-candidate", N_ ("Original Candidate")}};

void
kkc_keymap_command_entry_copy (const KkcKeymapCommandEntry* self,
                               KkcKeymapCommandEntry* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = (*self).name;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).name);
	(*dest).name = _tmp1_;
	_tmp2_ = (*self).label;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).label);
	(*dest).label = _tmp3_;
}

void
kkc_keymap_command_entry_destroy (KkcKeymapCommandEntry* self)
{
	_g_free0 ((*self).name);
	_g_free0 ((*self).label);
}

KkcKeymapCommandEntry*
kkc_keymap_command_entry_dup (const KkcKeymapCommandEntry* self)
{
	KkcKeymapCommandEntry* dup;
	dup = g_new0 (KkcKeymapCommandEntry, 1);
	kkc_keymap_command_entry_copy (self, dup);
	return dup;
}

void
kkc_keymap_command_entry_free (KkcKeymapCommandEntry* self)
{
	kkc_keymap_command_entry_destroy (self);
	g_free (self);
}

static GType
kkc_keymap_command_entry_get_type_once (void)
{
	GType kkc_keymap_command_entry_type_id;
	kkc_keymap_command_entry_type_id = g_boxed_type_register_static ("KkcKeymapCommandEntry", (GBoxedCopyFunc) kkc_keymap_command_entry_dup, (GBoxedFreeFunc) kkc_keymap_command_entry_free);
	return kkc_keymap_command_entry_type_id;
}

GType
kkc_keymap_command_entry_get_type (void)
{
	static volatile gsize kkc_keymap_command_entry_type_id__once = 0;
	if (g_once_init_enter (&kkc_keymap_command_entry_type_id__once)) {
		GType kkc_keymap_command_entry_type_id;
		kkc_keymap_command_entry_type_id = kkc_keymap_command_entry_get_type_once ();
		g_once_init_leave (&kkc_keymap_command_entry_type_id__once, kkc_keymap_command_entry_type_id);
	}
	return kkc_keymap_command_entry_type_id__once;
}

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

void
kkc_keymap_entry_copy (const KkcKeymapEntry* self,
                       KkcKeymapEntry* dest)
{
	KkcKeyEvent* _tmp0_;
	KkcKeyEvent* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = (*self).key;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 ((*dest).key);
	(*dest).key = _tmp1_;
	_tmp2_ = (*self).command;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).command);
	(*dest).command = _tmp3_;
}

void
kkc_keymap_entry_destroy (KkcKeymapEntry* self)
{
	_g_object_unref0 ((*self).key);
	_g_free0 ((*self).command);
}

KkcKeymapEntry*
kkc_keymap_entry_dup (const KkcKeymapEntry* self)
{
	KkcKeymapEntry* dup;
	dup = g_new0 (KkcKeymapEntry, 1);
	kkc_keymap_entry_copy (self, dup);
	return dup;
}

void
kkc_keymap_entry_free (KkcKeymapEntry* self)
{
	kkc_keymap_entry_destroy (self);
	g_free (self);
}

static GType
kkc_keymap_entry_get_type_once (void)
{
	GType kkc_keymap_entry_type_id;
	kkc_keymap_entry_type_id = g_boxed_type_register_static ("KkcKeymapEntry", (GBoxedCopyFunc) kkc_keymap_entry_dup, (GBoxedFreeFunc) kkc_keymap_entry_free);
	return kkc_keymap_entry_type_id;
}

GType
kkc_keymap_entry_get_type (void)
{
	static volatile gsize kkc_keymap_entry_type_id__once = 0;
	if (g_once_init_enter (&kkc_keymap_entry_type_id__once)) {
		GType kkc_keymap_entry_type_id;
		kkc_keymap_entry_type_id = kkc_keymap_entry_get_type_once ();
		g_once_init_leave (&kkc_keymap_entry_type_id__once, kkc_keymap_entry_type_id);
	}
	return kkc_keymap_entry_type_id__once;
}

static inline gpointer
kkc_keymap_get_instance_private (KkcKeymap* self)
{
	return G_STRUCT_MEMBER_P (self, KkcKeymap_private_offset);
}

static guint
_kkc_keymap_key_hash_gee_hash_data_func (gconstpointer v,
                                         gpointer self)
{
	guint result;
	result = kkc_keymap_key_hash ((KkcKeyEvent*) v);
	return result;
}

static gboolean
_kkc_keymap_key_equal_gee_equal_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self)
{
	gboolean result;
	result = kkc_keymap_key_equal ((KkcKeyEvent*) a, (KkcKeyEvent*) b);
	return result;
}

/**
         * List commands usable in keymap.
         *
         * @return array of commands
         */
gchar**
kkc_keymap_commands (gint* result_length1)
{
	GeeMap* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	gint _tmp4_ = 0;
	gpointer* _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar** result;
	_tmp0_ = kkc_keymap__CommandTable;
	_tmp1_ = gee_map_get_keys (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp5_ = gee_collection_to_array ((GeeCollection*) _tmp3_, &_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp4_;
	_g_object_unref0 (_tmp3_);
	_tmp7_ = _tmp6_;
	_tmp7__length1 = _tmp6__length1;
	if (result_length1) {
		*result_length1 = _tmp7__length1;
	}
	result = _tmp7_;
	return result;
}

/**
         * Return a label for a command
         *
         * @param command command
         * @return label
         */
gchar*
kkc_keymap_get_command_label (const gchar* command)
{
	gchar* label = NULL;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	const gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (command != NULL, NULL);
	_tmp0_ = kkc_keymap__CommandTable;
	_tmp1_ = gee_map_get (_tmp0_, command);
	label = (gchar*) _tmp1_;
	_tmp2_ = label;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = label;
		_tmp4_ = g_strdup (g_dgettext (GETTEXT_PACKAGE, _tmp3_));
		_g_free0 (label);
		label = _tmp4_;
	}
	result = label;
	return result;
}

static gboolean
kkc_keymap_key_equal (KkcKeyEvent* a,
                      KkcKeyEvent* b)
{
	gboolean _tmp0_ = FALSE;
	guint _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	guint _tmp4_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp1_ = kkc_key_event_get_keyval (a);
	_tmp2_ = _tmp1_;
	_tmp3_ = kkc_key_event_get_keyval (b);
	_tmp4_ = _tmp3_;
	if (_tmp2_ == _tmp4_) {
		KkcModifierType _tmp5_;
		KkcModifierType _tmp6_;
		KkcModifierType _tmp7_;
		KkcModifierType _tmp8_;
		_tmp5_ = kkc_key_event_get_modifiers (a);
		_tmp6_ = _tmp5_;
		_tmp7_ = kkc_key_event_get_modifiers (b);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp6_ == _tmp8_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static guint
kkc_keymap_key_hash (KkcKeyEvent* a)
{
	GHashFunc _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	gint _tmp3_;
	GHashFunc _tmp4_;
	KkcModifierType _tmp5_;
	KkcModifierType _tmp6_;
	gint _tmp7_;
	guint result;
	g_return_val_if_fail (a != NULL, 0U);
	_tmp0_ = g_int_hash;
	_tmp1_ = kkc_key_event_get_keyval (a);
	_tmp2_ = _tmp1_;
	_tmp3_ = (gint) _tmp2_;
	_tmp4_ = g_int_hash;
	_tmp5_ = kkc_key_event_get_modifiers (a);
	_tmp6_ = _tmp5_;
	_tmp7_ = (gint) _tmp6_;
	result = _tmp0_ (&_tmp3_) + _tmp4_ (&_tmp7_);
	return result;
}

/**
         * Return all the keymap entries including parent's.
         *
         * @return array of KeymapEntry
         */
KkcKeymapEntry*
kkc_keymap_entries (KkcKeymap* self,
                    gint* result_length1)
{
	GeeHashMap* _map_entries = NULL;
	GeeHashMap* _tmp0_;
	KkcKeymap* _tmp1_;
	GeeHashMap* _tmp5_;
	GeeMap* _tmp6_;
	GeeHashMap* _tmp7_;
	gint _tmp8_ = 0;
	KkcKeymapEntry* _tmp9_;
	KkcKeymapEntry* _tmp10_;
	gint _tmp10__length1;
	KkcKeymapEntry* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_hash_map_new (KKC_TYPE_KEY_EVENT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _kkc_keymap_key_hash_gee_hash_data_func, NULL, NULL, _kkc_keymap_key_equal_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	_map_entries = _tmp0_;
	_tmp1_ = self->priv->_parent;
	if (_tmp1_ != NULL) {
		GeeHashMap* _tmp2_;
		KkcKeymap* _tmp3_;
		GeeMap* _tmp4_;
		_tmp2_ = _map_entries;
		_tmp3_ = self->priv->_parent;
		_tmp4_ = _tmp3_->priv->map_entries;
		gee_map_set_all ((GeeMap*) _tmp2_, _tmp4_);
	}
	_tmp5_ = _map_entries;
	_tmp6_ = self->priv->map_entries;
	gee_map_set_all ((GeeMap*) _tmp5_, _tmp6_);
	_tmp7_ = _map_entries;
	_tmp9_ = kkc_keymap_map_entries_to_array (self, (GeeMap*) _tmp7_, &_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp10__length1 = _tmp8_;
	if (result_length1) {
		*result_length1 = _tmp10__length1;
	}
	result = _tmp10_;
	_g_object_unref0 (_map_entries);
	return result;
}

/**
         * Return keymap entries not including parent's.
         *
         * @return array of KeymapEntry
         */
KkcKeymapEntry*
kkc_keymap_local_entries (KkcKeymap* self,
                          gint* result_length1)
{
	GeeMap* _tmp0_;
	gint _tmp1_ = 0;
	KkcKeymapEntry* _tmp2_;
	KkcKeymapEntry* _tmp3_;
	gint _tmp3__length1;
	KkcKeymapEntry* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->map_entries;
	_tmp2_ = kkc_keymap_map_entries_to_array (self, _tmp0_, &_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1_;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}

static void
_vala_array_add2 (KkcKeymapEntry* * array,
                  gint* length,
                  gint* size,
                  const KkcKeymapEntry* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (KkcKeymapEntry, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static KkcKeymapEntry*
kkc_keymap_map_entries_to_array (KkcKeymap* self,
                                 GeeMap* map_entries,
                                 gint* result_length1)
{
	KkcKeymapEntry* _result_ = NULL;
	KkcKeymapEntry* _tmp0_;
	gint _result__length1;
	gint __result__size_;
	GeeMapIterator* iter = NULL;
	GeeMapIterator* _tmp1_;
	KkcKeymapEntry* _tmp15_;
	gint _tmp15__length1;
	KkcKeymapEntry* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (map_entries != NULL, NULL);
	_tmp0_ = g_new0 (KkcKeymapEntry, 0);
	_result_ = _tmp0_;
	_result__length1 = 0;
	__result__size_ = _result__length1;
	_tmp1_ = gee_map_map_iterator (map_entries);
	iter = _tmp1_;
	while (TRUE) {
		GeeMapIterator* _tmp2_;
		KkcKeyEvent* key = NULL;
		GeeMapIterator* _tmp3_;
		gpointer _tmp4_;
		gchar* command = NULL;
		GeeMapIterator* _tmp5_;
		gpointer _tmp6_;
		KkcKeymapEntry entry = {0};
		KkcKeyEvent* _tmp7_;
		KkcKeyEvent* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		KkcKeymapEntry _tmp11_ = {0};
		KkcKeymapEntry _tmp12_;
		KkcKeymapEntry _tmp13_;
		KkcKeymapEntry _tmp14_ = {0};
		_tmp2_ = iter;
		if (!gee_map_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = iter;
		_tmp4_ = gee_map_iterator_get_key (_tmp3_);
		key = (KkcKeyEvent*) _tmp4_;
		_tmp5_ = iter;
		_tmp6_ = gee_map_iterator_get_value (_tmp5_);
		command = (gchar*) _tmp6_;
		_tmp7_ = key;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		_tmp9_ = command;
		_tmp10_ = g_strdup (_tmp9_);
		_g_object_unref0 (_tmp11_.key);
		_tmp11_.key = _tmp8_;
		_g_free0 (_tmp11_.command);
		_tmp11_.command = _tmp10_;
		entry = _tmp11_;
		_tmp12_ = entry;
		_tmp13_ = _tmp12_;
		kkc_keymap_entry_copy (&_tmp13_, &_tmp14_);
		_vala_array_add2 (&_result_, &_result__length1, &__result__size_, &_tmp14_);
		kkc_keymap_entry_destroy (&entry);
		_g_free0 (command);
		_g_object_unref0 (key);
	}
	_tmp15_ = _result_;
	_tmp15__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp15__length1;
	}
	result = _tmp15_;
	_g_object_unref0 (iter);
	return result;
}

/**
         * Bind a key event to a command.
         *
         * @param key key event
         * @param command command or `null` to unset
         */
void
kkc_keymap_set (KkcKeymap* self,
                KkcKeyEvent* key,
                const gchar* command)
{
	GeeMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = self->priv->map_entries;
	gee_map_set (_tmp0_, key, command);
}

/**
         * Lookup a command bound to a key event.
         *
         * @param key key event
         * @return command or `null`
         */
gchar*
kkc_keymap_lookup_key (KkcKeymap* self,
                       KkcKeyEvent* key)
{
	GeeMap* _tmp0_;
	KkcKeymap* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	_tmp0_ = self->priv->map_entries;
	if (gee_map_has_key (_tmp0_, key)) {
		GeeMap* _tmp1_;
		gpointer _tmp2_;
		_tmp1_ = self->priv->map_entries;
		_tmp2_ = gee_map_get (_tmp1_, key);
		result = (gchar*) _tmp2_;
		return result;
	}
	_tmp3_ = self->priv->_parent;
	if (_tmp3_ != NULL) {
		KkcKeymap* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = self->priv->_parent;
		_tmp5_ = kkc_keymap_lookup_key (_tmp4_, key);
		result = _tmp5_;
		return result;
	}
	result = NULL;
	return result;
}

/**
         * Lookup a key event to which a command is bound.
         *
         * @param command command
         * @return a key event or `null`
         */
KkcKeyEvent*
kkc_keymap_where_is (KkcKeymap* self,
                     const gchar* command)
{
	GeeMapIterator* iter = NULL;
	GeeMap* _tmp0_;
	GeeMapIterator* _tmp1_;
	KkcKeymap* _tmp9_;
	KkcKeyEvent* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (command != NULL, NULL);
	_tmp0_ = self->priv->map_entries;
	_tmp1_ = gee_map_map_iterator (_tmp0_);
	iter = _tmp1_;
	while (TRUE) {
		GeeMapIterator* _tmp2_;
		GeeMapIterator* _tmp3_;
		gpointer _tmp4_;
		gchar* _tmp5_;
		gboolean _tmp6_;
		_tmp2_ = iter;
		if (!gee_map_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = iter;
		_tmp4_ = gee_map_iterator_get_value (_tmp3_);
		_tmp5_ = (gchar*) _tmp4_;
		_tmp6_ = g_strcmp0 (_tmp5_, command) == 0;
		_g_free0 (_tmp5_);
		if (_tmp6_) {
			GeeMapIterator* _tmp7_;
			gpointer _tmp8_;
			_tmp7_ = iter;
			_tmp8_ = gee_map_iterator_get_key (_tmp7_);
			result = (KkcKeyEvent*) _tmp8_;
			_g_object_unref0 (iter);
			return result;
		}
	}
	_tmp9_ = self->priv->_parent;
	if (_tmp9_ != NULL) {
		KkcKeymap* _tmp10_;
		KkcKeyEvent* _tmp11_;
		_tmp10_ = self->priv->_parent;
		_tmp11_ = kkc_keymap_where_is (_tmp10_, command);
		result = _tmp11_;
		_g_object_unref0 (iter);
		return result;
	}
	result = NULL;
	_g_object_unref0 (iter);
	return result;
}

KkcKeymap*
kkc_keymap_construct (GType object_type)
{
	KkcKeymap * self = NULL;
	self = (KkcKeymap*) g_object_new (object_type, NULL);
	return self;
}

KkcKeymap*
kkc_keymap_new (void)
{
	return kkc_keymap_construct (KKC_TYPE_KEYMAP);
}

KkcKeymap*
kkc_keymap_get_parent (KkcKeymap* self)
{
	KkcKeymap* result;
	KkcKeymap* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_parent;
	result = _tmp0_;
	return result;
}

void
kkc_keymap_set_parent (KkcKeymap* self,
                       KkcKeymap* value)
{
	KkcKeymap* old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_keymap_get_parent (self);
	if (old_value != value) {
		KkcKeymap* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_parent);
		self->priv->_parent = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, kkc_keymap_properties[KKC_KEYMAP_PARENT_PROPERTY]);
	}
}

static void
kkc_keymap_class_init (KkcKeymapClass * klass,
                       gpointer klass_data)
{
	GeeHashMap* _tmp0_;
	kkc_keymap_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcKeymap_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_keymap_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_kkc_keymap_set_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_keymap_finalize;
	/**
	         * Parent keymap.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_KEYMAP_PARENT_PROPERTY, kkc_keymap_properties[KKC_KEYMAP_PARENT_PROPERTY] = g_param_spec_object ("parent", "parent", "parent", KKC_TYPE_KEYMAP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	_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);
	kkc_keymap__CommandTable = (GeeMap*) _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GeeMap* _tmp3_;
				KkcKeymapCommandEntry _tmp4_;
				const gchar* _tmp5_;
				KkcKeymapCommandEntry _tmp6_;
				const gchar* _tmp7_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < G_N_ELEMENTS (KKC_KEYMAP_Commands))) {
					break;
				}
				_tmp3_ = kkc_keymap__CommandTable;
				_tmp4_ = KKC_KEYMAP_Commands[i];
				_tmp5_ = _tmp4_.name;
				_tmp6_ = KKC_KEYMAP_Commands[i];
				_tmp7_ = _tmp6_.label;
				gee_map_set (_tmp3_, _tmp5_, _tmp7_);
			}
		}
	}
}

static void
kkc_keymap_instance_init (KkcKeymap * self,
                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = kkc_keymap_get_instance_private (self);
	self->priv->_parent = NULL;
	_tmp0_ = gee_hash_map_new (KKC_TYPE_KEY_EVENT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _kkc_keymap_key_hash_gee_hash_data_func, NULL, NULL, _kkc_keymap_key_equal_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->map_entries = (GeeMap*) _tmp0_;
}

static void
kkc_keymap_finalize (GObject * obj)
{
	KkcKeymap * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_KEYMAP, KkcKeymap);
	_g_object_unref0 (self->priv->_parent);
	_g_object_unref0 (self->priv->map_entries);
	G_OBJECT_CLASS (kkc_keymap_parent_class)->finalize (obj);
}

/**
     * Object representing a keymap.
     */
static GType
kkc_keymap_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcKeymapClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_keymap_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcKeymap), 0, (GInstanceInitFunc) kkc_keymap_instance_init, NULL };
	GType kkc_keymap_type_id;
	kkc_keymap_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcKeymap", &g_define_type_info, 0);
	KkcKeymap_private_offset = g_type_add_instance_private (kkc_keymap_type_id, sizeof (KkcKeymapPrivate));
	return kkc_keymap_type_id;
}

GType
kkc_keymap_get_type (void)
{
	static volatile gsize kkc_keymap_type_id__once = 0;
	if (g_once_init_enter (&kkc_keymap_type_id__once)) {
		GType kkc_keymap_type_id;
		kkc_keymap_type_id = kkc_keymap_get_type_once ();
		g_once_init_leave (&kkc_keymap_type_id__once, kkc_keymap_type_id);
	}
	return kkc_keymap_type_id__once;
}

static void
_vala_kkc_keymap_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	KkcKeymap * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_KEYMAP, KkcKeymap);
	switch (property_id) {
		case KKC_KEYMAP_PARENT_PROPERTY:
		g_value_set_object (value, kkc_keymap_get_parent (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_kkc_keymap_set_property (GObject * object,
                               guint property_id,
                               const GValue * value,
                               GParamSpec * pspec)
{
	KkcKeymap * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_KEYMAP, KkcKeymap);
	switch (property_id) {
		case KKC_KEYMAP_PARENT_PROPERTY:
		kkc_keymap_set_parent (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

