/* key-model.c generated by valac 0.32.0.49-00a57, the Vala compiler
 * generated from key-model.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gee.h>


#define CARIBOU_TYPE_ISCANNABLE_ITEM (caribou_iscannable_item_get_type ())
#define CARIBOU_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItem))
#define CARIBOU_IS_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM))
#define CARIBOU_ISCANNABLE_ITEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItemIface))

typedef struct _CaribouIScannableItem CaribouIScannableItem;
typedef struct _CaribouIScannableItemIface CaribouIScannableItemIface;

#define CARIBOU_TYPE_IKEYBOARD_OBJECT (caribou_ikeyboard_object_get_type ())
#define CARIBOU_IKEYBOARD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT, CaribouIKeyboardObject))
#define CARIBOU_IS_IKEYBOARD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT))
#define CARIBOU_IKEYBOARD_OBJECT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT, CaribouIKeyboardObjectIface))

typedef struct _CaribouIKeyboardObject CaribouIKeyboardObject;
typedef struct _CaribouIKeyboardObjectIface CaribouIKeyboardObjectIface;

#define CARIBOU_TYPE_KEY_MODEL (caribou_key_model_get_type ())
#define CARIBOU_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel))
#define CARIBOU_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))
#define CARIBOU_IS_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_IS_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_KEY_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))

typedef struct _CaribouKeyModel CaribouKeyModel;
typedef struct _CaribouKeyModelClass CaribouKeyModelClass;
typedef struct _CaribouKeyModelPrivate CaribouKeyModelPrivate;

#define CARIBOU_TYPE_MODIFIER_STATE (caribou_modifier_state_get_type ())

#define CARIBOU_TYPE_DISPLAY_ADAPTER (caribou_display_adapter_get_type ())
#define CARIBOU_DISPLAY_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_DISPLAY_ADAPTER, CaribouDisplayAdapter))
#define CARIBOU_DISPLAY_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_DISPLAY_ADAPTER, CaribouDisplayAdapterClass))
#define CARIBOU_IS_DISPLAY_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_DISPLAY_ADAPTER))
#define CARIBOU_IS_DISPLAY_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_DISPLAY_ADAPTER))
#define CARIBOU_DISPLAY_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_DISPLAY_ADAPTER, CaribouDisplayAdapterClass))

typedef struct _CaribouDisplayAdapter CaribouDisplayAdapter;
typedef struct _CaribouDisplayAdapterClass CaribouDisplayAdapterClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define CARIBOU_TYPE_MODIFIER_MAP_ENTRY (caribou_modifier_map_entry_get_type ())
typedef struct _CaribouModifierMapEntry CaribouModifierMapEntry;

#define CARIBOU_TYPE_LABEL_MAP_ENTRY (caribou_label_map_entry_get_type ())
typedef struct _CaribouLabelMapEntry CaribouLabelMapEntry;

struct _CaribouIScannableItemIface {
	GTypeInterface parent_iface;
	gboolean (*get_scan_stepping) (CaribouIScannableItem* self);
	void (*set_scan_stepping) (CaribouIScannableItem* self, gboolean value);
	gboolean (*get_scan_selected) (CaribouIScannableItem* self);
	void (*set_scan_selected) (CaribouIScannableItem* self, gboolean value);
};

struct _CaribouIKeyboardObjectIface {
	GTypeInterface parent_iface;
	CaribouIKeyboardObject** (*get_children) (CaribouIKeyboardObject* self, int* result_length1);
	CaribouKeyModel** (*get_keys) (CaribouIKeyboardObject* self, int* result_length1);
};

typedef enum  {
	CARIBOU_MODIFIER_STATE_NONE,
	CARIBOU_MODIFIER_STATE_LATCHED,
	CARIBOU_MODIFIER_STATE_LOCKED
} CaribouModifierState;

struct _CaribouKeyModel {
	GObject parent_instance;
	CaribouKeyModelPrivate * priv;
	CaribouModifierState modifier_state;
};

struct _CaribouKeyModelClass {
	GObjectClass parent_class;
};

struct _CaribouKeyModelPrivate {
	gchar* _align;
	gdouble _width;
	gchar* _toggle;
	gboolean _repeatable;
	GdkModifierType mod_mask;
	gboolean _show_subkeys;
	gchar* _name;
	guint _keyval;
	gchar* _text;
	guint* _keyvals;
	gint _keyvals_length1;
	gint __keyvals_size_;
	gchar* _label;
	gboolean _scan_stepping;
	gboolean _scan_selected;
	guint hold_tid;
	CaribouDisplayAdapter* xadapter;
	GeeArrayList* extended_keys;
};

struct _CaribouModifierMapEntry {
	gchar* name;
	GdkModifierType mask;
};

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


static gpointer caribou_key_model_parent_class = NULL;
static CaribouIScannableItemIface* caribou_key_model_caribou_iscannable_item_parent_iface = NULL;
static CaribouIKeyboardObjectIface* caribou_key_model_caribou_ikeyboard_object_parent_iface = NULL;

GType caribou_iscannable_item_get_type (void) G_GNUC_CONST;
GType caribou_key_model_get_type (void) G_GNUC_CONST;
GType caribou_ikeyboard_object_get_type (void) G_GNUC_CONST;
GType caribou_modifier_state_get_type (void) G_GNUC_CONST;
GType caribou_display_adapter_get_type (void) G_GNUC_CONST;
#define CARIBOU_KEY_MODEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelPrivate))
enum  {
	CARIBOU_KEY_MODEL_DUMMY_PROPERTY,
	CARIBOU_KEY_MODEL_ALIGN,
	CARIBOU_KEY_MODEL_WIDTH,
	CARIBOU_KEY_MODEL_TOGGLE,
	CARIBOU_KEY_MODEL_REPEATABLE,
	CARIBOU_KEY_MODEL_IS_MODIFIER,
	CARIBOU_KEY_MODEL_SHOW_SUBKEYS,
	CARIBOU_KEY_MODEL_NAME,
	CARIBOU_KEY_MODEL_KEYVAL,
	CARIBOU_KEY_MODEL_TEXT,
	CARIBOU_KEY_MODEL_LABEL,
	CARIBOU_KEY_MODEL_SCAN_STEPPING,
	CARIBOU_KEY_MODEL_SCAN_SELECTED
};
GType caribou_modifier_map_entry_get_type (void) G_GNUC_CONST;
CaribouModifierMapEntry* caribou_modifier_map_entry_dup (const CaribouModifierMapEntry* self);
void caribou_modifier_map_entry_free (CaribouModifierMapEntry* self);
void caribou_modifier_map_entry_copy (const CaribouModifierMapEntry* self, CaribouModifierMapEntry* dest);
void caribou_modifier_map_entry_destroy (CaribouModifierMapEntry* self);
GType caribou_label_map_entry_get_type (void) G_GNUC_CONST;
CaribouLabelMapEntry* caribou_label_map_entry_dup (const CaribouLabelMapEntry* self);
void caribou_label_map_entry_free (CaribouLabelMapEntry* self);
void caribou_label_map_entry_copy (const CaribouLabelMapEntry* self, CaribouLabelMapEntry* dest);
void caribou_label_map_entry_destroy (CaribouLabelMapEntry* self);
CaribouKeyModel* caribou_key_model_new (const gchar* name, const gchar* text);
CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name, const gchar* text);
static void caribou_key_model_set_name (CaribouKeyModel* self, const gchar* value);
static void caribou_key_model_set_text (CaribouKeyModel* self, const gchar* value);
static void _vala_array_add3 (guint** array, int* length, int* size, guint value);
static void _vala_array_add4 (guint** array, int* length, int* size, guint value);
static void caribou_key_model_set_keyval (CaribouKeyModel* self, guint value);
void caribou_key_model_set_label (CaribouKeyModel* self, const gchar* value);
const gchar* caribou_key_model_get_label (CaribouKeyModel* self);
CaribouDisplayAdapter* caribou_display_adapter_get_default (void);
void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key);
static void caribou_key_model_on_subkey_released (CaribouKeyModel* self, CaribouKeyModel* key);
static void _caribou_key_model_on_subkey_released_caribou_ikeyboard_object_key_released (CaribouIKeyboardObject* _sender, CaribouKeyModel* key, gpointer self);
static void caribou_key_model_set_show_subkeys (CaribouKeyModel* self, gboolean value);
void caribou_key_model_press (CaribouKeyModel* self);
gboolean caribou_key_model_get_is_modifier (CaribouKeyModel* self);
void caribou_display_adapter_mod_lock (CaribouDisplayAdapter* self, guint mask);
gboolean caribou_key_model_get_repeatable (CaribouKeyModel* self);
void caribou_display_adapter_keyval_press (CaribouDisplayAdapter* self, guint keyval);
guint caribou_key_model_get_keyval (CaribouKeyModel* self);
static gboolean caribou_key_model_on_key_held (CaribouKeyModel* self);
static gboolean _caribou_key_model_on_key_held_gsource_func (gpointer self);
void caribou_key_model_release (CaribouKeyModel* self);
void caribou_display_adapter_mod_unlock (CaribouDisplayAdapter* self, guint mask);
void caribou_display_adapter_keyval_release (CaribouDisplayAdapter* self, guint keyval);
CaribouKeyModel** caribou_key_model_get_extended_keys (CaribouKeyModel* self, int* result_length1);
static CaribouKeyModel** caribou_key_model_real_get_keys (CaribouIKeyboardObject* base, int* result_length1);
static CaribouIKeyboardObject** caribou_key_model_real_get_children (CaribouIKeyboardObject* base, int* result_length1);
void caribou_key_model_activate (CaribouKeyModel* self);
static gboolean __lambda4_ (CaribouKeyModel* self);
static gboolean ___lambda4__gsource_func (gpointer self);
const gchar* caribou_key_model_get_align (CaribouKeyModel* self);
void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value);
gdouble caribou_key_model_get_width (CaribouKeyModel* self);
void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value);
const gchar* caribou_key_model_get_toggle (CaribouKeyModel* self);
void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_repeatable (CaribouKeyModel* self, gboolean value);
void caribou_key_model_set_is_modifier (CaribouKeyModel* self, gboolean value);
gboolean caribou_key_model_get_show_subkeys (CaribouKeyModel* self);
const gchar* caribou_key_model_get_name (CaribouKeyModel* self);
const gchar* caribou_key_model_get_text (CaribouKeyModel* self);
static void caribou_key_model_finalize (GObject* obj);
gboolean caribou_iscannable_item_get_scan_stepping (CaribouIScannableItem* self);
gboolean caribou_iscannable_item_get_scan_selected (CaribouIScannableItem* self);
static void _vala_caribou_key_model_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
void caribou_iscannable_item_set_scan_stepping (CaribouIScannableItem* self, gboolean value);
void caribou_iscannable_item_set_scan_selected (CaribouIScannableItem* self, gboolean value);
static void _vala_caribou_key_model_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);

static const CaribouModifierMapEntry CARIBOU_KEY_MODEL_mod_map[3] = {{"Control_L", GDK_CONTROL_MASK}, {"Alt_L", GDK_MOD1_MASK}, {NULL, 0}};
static const CaribouLabelMapEntry CARIBOU_KEY_MODEL_label_map[24] = {{"BackSpace", "\xe2\x8c\xab"}, {"space", " "}, {"Delete", "\xe2\x8c\xa6"}, {"Return", "\xe2\x8f\x8e"}, {"Escape", "Esc"}, {"Tab", "\xe2\x86\xb9"}, {"Control_L", "Ctrl"}, {"Control_R", "Ctrl"}, {"Alt_L", "Alt"}, {"Alt_R", "Alt"}, {"Up", "\xe2\x87\xa1"}, {"Down", "\xe2\x87\xa3"}, {"Left", "\xe2\x87\xa0"}, {"Right", "\xe2\x87\xa2"}, {"Prior", "Page\nUp"}, {"Next", "Page\nDown"}, {"Caribou_Prefs", "\xe2\x8c\xa8"}, {"Caribou_ShiftUp", "\xe2\xac\x86"}, {"Caribou_ShiftDown", "\xe2\xac\x87"}, {"Caribou_Emoticons", "\xe2\x98\xba"}, {"Caribou_Symbols", "123"}, {"Caribou_Symbols_More", "{#*"}, {"Caribou_Alpha", "Abc"}, {"Caribou_Repeat", "\xe2\x99\xbb"}};

static gboolean string_get_next_char (const gchar* self, gint* index, gunichar* c) {
	gunichar _vala_c = 0U;
	gboolean result = FALSE;
	gint _tmp0_ = 0;
	gunichar _tmp1_ = 0U;
	gunichar _tmp2_ = 0U;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = *index;
	_tmp1_ = g_utf8_get_char (((gchar*) self) + _tmp0_);
	_vala_c = _tmp1_;
	_tmp2_ = _vala_c;
	if (_tmp2_ != ((gunichar) 0)) {
		gint _tmp3_ = 0;
		gchar* _tmp4_ = NULL;
		_tmp3_ = *index;
		_tmp4_ = g_utf8_next_char (((gchar*) self) + _tmp3_);
		*index = (gint) (_tmp4_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
	if (c) {
		*c = _vala_c;
	}
}


static void _vala_array_add3 (guint** array, int* length, int* size, guint value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (guint, *array, *size);
	}
	(*array)[(*length)++] = value;
}


static void _vala_array_add4 (guint** array, int* length, int* size, guint value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (guint, *array, *size);
	}
	(*array)[(*length)++] = value;
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	glong _tmp2_ = 0L;
	glong _tmp5_ = 0L;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_ = 0L;
	gboolean _tmp12_ = FALSE;
	glong _tmp13_ = 0L;
	glong _tmp16_ = 0L;
	glong _tmp17_ = 0L;
	glong _tmp18_ = 0L;
	glong _tmp19_ = 0L;
	glong _tmp20_ = 0L;
	gchar* _tmp21_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_ = 0L;
		glong _tmp4_ = 0L;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_ = 0L;
		glong _tmp7_ = 0L;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_ = 0L;
		glong _tmp11_ = 0L;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	g_return_val_if_fail (_tmp8_, NULL);
	_tmp13_ = end;
	if (_tmp13_ >= ((glong) 0)) {
		glong _tmp14_ = 0L;
		glong _tmp15_ = 0L;
		_tmp14_ = end;
		_tmp15_ = string_length;
		_tmp12_ = _tmp14_ <= _tmp15_;
	} else {
		_tmp12_ = FALSE;
	}
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp16_ = start;
	_tmp17_ = end;
	g_return_val_if_fail (_tmp16_ <= _tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	_tmp20_ = start;
	_tmp21_ = g_strndup (((gchar*) self) + _tmp18_, (gsize) (_tmp19_ - _tmp20_));
	result = _tmp21_;
	return result;
}


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


CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name, const gchar* text) {
	CaribouKeyModel * self = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gint i = 0;
	GdkModifierType _tmp17_ = 0;
	gint _tmp46_ = 0;
	CaribouDisplayAdapter* _tmp97_ = NULL;
	GeeArrayList* _tmp98_ = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (CaribouKeyModel*) g_object_new (object_type, NULL);
	_tmp0_ = name;
	caribou_key_model_set_name (self, _tmp0_);
	_tmp1_ = text;
	caribou_key_model_set_text (self, _tmp1_);
	self->priv->mod_mask = (GdkModifierType) 0;
	i = 0;
	{
		CaribouModifierMapEntry entry = {0};
		gint _tmp2_ = 0;
		CaribouModifierMapEntry _tmp3_ = {0};
		CaribouModifierMapEntry _tmp4_ = {0};
		_tmp2_ = i;
		_tmp3_ = CARIBOU_KEY_MODEL_mod_map[_tmp2_];
		caribou_modifier_map_entry_copy (&_tmp3_, &_tmp4_);
		entry = _tmp4_;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				CaribouModifierMapEntry _tmp10_ = {0};
				const gchar* _tmp11_ = NULL;
				const gchar* _tmp12_ = NULL;
				CaribouModifierMapEntry _tmp13_ = {0};
				const gchar* _tmp14_ = NULL;
				if (!_tmp5_) {
					gint _tmp6_ = 0;
					gint _tmp7_ = 0;
					CaribouModifierMapEntry _tmp8_ = {0};
					CaribouModifierMapEntry _tmp9_ = {0};
					_tmp6_ = i;
					i = _tmp6_ + 1;
					_tmp7_ = i;
					_tmp8_ = CARIBOU_KEY_MODEL_mod_map[_tmp7_];
					caribou_modifier_map_entry_copy (&_tmp8_, &_tmp9_);
					caribou_modifier_map_entry_destroy (&entry);
					entry = _tmp9_;
				}
				_tmp5_ = FALSE;
				_tmp10_ = entry;
				_tmp11_ = _tmp10_.name;
				if (!(_tmp11_ != NULL)) {
					break;
				}
				_tmp12_ = name;
				_tmp13_ = entry;
				_tmp14_ = _tmp13_.name;
				if (g_strcmp0 (_tmp12_, _tmp14_) == 0) {
					CaribouModifierMapEntry _tmp15_ = {0};
					GdkModifierType _tmp16_ = 0;
					_tmp15_ = entry;
					_tmp16_ = _tmp15_.mask;
					self->priv->mod_mask = _tmp16_;
				}
			}
		}
		caribou_modifier_map_entry_destroy (&entry);
	}
	_tmp17_ = self->priv->mod_mask;
	if (_tmp17_ == 0) {
		const gchar* _tmp18_ = NULL;
		_tmp18_ = text;
		if (_tmp18_ != NULL) {
			gint index = 0;
			gunichar uc = 0U;
			index = 0;
			while (TRUE) {
				const gchar* _tmp19_ = NULL;
				gunichar _tmp20_ = 0U;
				gboolean _tmp21_ = FALSE;
				guint keyval = 0U;
				gunichar _tmp22_ = 0U;
				guint _tmp23_ = 0U;
				guint _tmp24_ = 0U;
				gunichar _tmp25_ = 0U;
				_tmp19_ = text;
				_tmp21_ = string_get_next_char (_tmp19_, &index, &_tmp20_);
				uc = _tmp20_;
				if (!_tmp21_) {
					break;
				}
				_tmp22_ = uc;
				_tmp23_ = gdk_unicode_to_keyval ((guint32) _tmp22_);
				keyval = _tmp23_;
				_tmp24_ = keyval;
				_tmp25_ = uc;
				if ((_tmp24_ != ((guint) _tmp25_)) | 0x01000000) {
					guint* _tmp26_ = NULL;
					gint _tmp26__length1 = 0;
					guint _tmp27_ = 0U;
					_tmp26_ = self->priv->_keyvals;
					_tmp26__length1 = self->priv->_keyvals_length1;
					_tmp27_ = keyval;
					_vala_array_add3 (&self->priv->_keyvals, &self->priv->_keyvals_length1, &self->priv->__keyvals_size_, _tmp27_);
				}
			}
		} else {
			guint keyval = 0U;
			const gchar* _tmp28_ = NULL;
			guint _tmp29_ = 0U;
			gboolean _tmp30_ = FALSE;
			guint _tmp31_ = 0U;
			guint _tmp35_ = 0U;
			_tmp28_ = name;
			_tmp29_ = gdk_keyval_from_name (_tmp28_);
			keyval = _tmp29_;
			_tmp31_ = keyval;
			if (_tmp31_ != ((guint) GDK_KEY_VoidSymbol)) {
				guint _tmp32_ = 0U;
				_tmp32_ = keyval;
				_tmp30_ = _tmp32_ != ((guint) 0);
			} else {
				_tmp30_ = FALSE;
			}
			if (_tmp30_) {
				guint* _tmp33_ = NULL;
				gint _tmp33__length1 = 0;
				guint _tmp34_ = 0U;
				_tmp33_ = self->priv->_keyvals;
				_tmp33__length1 = self->priv->_keyvals_length1;
				_tmp34_ = keyval;
				_vala_array_add4 (&self->priv->_keyvals, &self->priv->_keyvals_length1, &self->priv->__keyvals_size_, _tmp34_);
			}
			_tmp35_ = keyval;
			caribou_key_model_set_keyval (self, _tmp35_);
		}
	}
	{
		gboolean _tmp36_ = FALSE;
		i = 0;
		_tmp36_ = TRUE;
		while (TRUE) {
			gint _tmp38_ = 0;
			gint _tmp39_ = 0;
			CaribouLabelMapEntry _tmp40_ = {0};
			const gchar* _tmp41_ = NULL;
			const gchar* _tmp42_ = NULL;
			if (!_tmp36_) {
				gint _tmp37_ = 0;
				_tmp37_ = i;
				i = _tmp37_ + 1;
			}
			_tmp36_ = FALSE;
			_tmp38_ = i;
			if (!(_tmp38_ < G_N_ELEMENTS (CARIBOU_KEY_MODEL_label_map))) {
				break;
			}
			_tmp39_ = i;
			_tmp40_ = CARIBOU_KEY_MODEL_label_map[_tmp39_];
			_tmp41_ = _tmp40_.name;
			_tmp42_ = name;
			if (g_strcmp0 (_tmp41_, _tmp42_) == 0) {
				gint _tmp43_ = 0;
				CaribouLabelMapEntry _tmp44_ = {0};
				const gchar* _tmp45_ = NULL;
				_tmp43_ = i;
				_tmp44_ = CARIBOU_KEY_MODEL_label_map[_tmp43_];
				_tmp45_ = _tmp44_.label;
				caribou_key_model_set_label (self, _tmp45_);
				break;
			}
		}
	}
	_tmp46_ = i;
	if (_tmp46_ == G_N_ELEMENTS (CARIBOU_KEY_MODEL_label_map)) {
		const gchar* _tmp47_ = NULL;
		_tmp47_ = text;
		if (_tmp47_ != NULL) {
			const gchar* _tmp48_ = NULL;
			_tmp48_ = text;
			caribou_key_model_set_label (self, _tmp48_);
		} else {
			const gchar* _tmp49_ = NULL;
			gboolean _tmp50_ = FALSE;
			_tmp49_ = name;
			_tmp50_ = g_str_has_prefix (_tmp49_, "Caribou_");
			if (_tmp50_) {
				const gchar* _tmp51_ = NULL;
				gint _tmp52_ = 0;
				gint _tmp53_ = 0;
				const gchar* _tmp54_ = NULL;
				gint _tmp55_ = 0;
				gint _tmp56_ = 0;
				gchar* _tmp57_ = NULL;
				gchar* _tmp58_ = NULL;
				_tmp51_ = name;
				_tmp52_ = strlen ("Caribou_");
				_tmp53_ = _tmp52_;
				_tmp54_ = name;
				_tmp55_ = strlen (_tmp54_);
				_tmp56_ = _tmp55_;
				_tmp57_ = string_slice (_tmp51_, (glong) _tmp53_, (glong) _tmp56_);
				_tmp58_ = _tmp57_;
				caribou_key_model_set_label (self, _tmp58_);
				_g_free0 (_tmp58_);
			} else {
				guint* _tmp59_ = NULL;
				gint _tmp59__length1 = 0;
				gboolean _tmp70_ = FALSE;
				const gchar* _tmp71_ = NULL;
				gboolean _tmp93_ = FALSE;
				const gchar* _tmp94_ = NULL;
				_tmp59_ = self->priv->_keyvals;
				_tmp59__length1 = self->priv->_keyvals_length1;
				if (_tmp59__length1 > 0) {
					gunichar uc = 0U;
					guint* _tmp60_ = NULL;
					gint _tmp60__length1 = 0;
					guint _tmp61_ = 0U;
					guint32 _tmp62_ = 0U;
					gboolean _tmp63_ = FALSE;
					gunichar _tmp64_ = 0U;
					gboolean _tmp65_ = FALSE;
					_tmp60_ = self->priv->_keyvals;
					_tmp60__length1 = self->priv->_keyvals_length1;
					_tmp61_ = _tmp60_[0];
					_tmp62_ = gdk_keyval_to_unicode (_tmp61_);
					uc = (gunichar) _tmp62_;
					_tmp64_ = uc;
					_tmp65_ = g_unichar_isspace (_tmp64_);
					if (!_tmp65_) {
						gunichar _tmp66_ = 0U;
						_tmp66_ = uc;
						_tmp63_ = _tmp66_ != ((gunichar) 0);
					} else {
						_tmp63_ = FALSE;
					}
					if (_tmp63_) {
						gunichar _tmp67_ = 0U;
						gchar* _tmp68_ = NULL;
						gchar* _tmp69_ = NULL;
						_tmp67_ = uc;
						_tmp68_ = g_unichar_to_string (_tmp67_);
						_tmp69_ = _tmp68_;
						caribou_key_model_set_label (self, _tmp69_);
						_g_free0 (_tmp69_);
					}
				}
				_tmp71_ = self->priv->_label;
				if (g_strcmp0 (_tmp71_, "") == 0) {
					const gchar* _tmp72_ = NULL;
					gboolean _tmp73_ = FALSE;
					_tmp72_ = name;
					_tmp73_ = g_str_has_prefix (_tmp72_, "dead_");
					_tmp70_ = _tmp73_;
				} else {
					_tmp70_ = FALSE;
				}
				if (_tmp70_) {
					guint keyval = 0U;
					const gchar* _tmp74_ = NULL;
					gint _tmp75_ = 0;
					gint _tmp76_ = 0;
					const gchar* _tmp77_ = NULL;
					gint _tmp78_ = 0;
					gint _tmp79_ = 0;
					gchar* _tmp80_ = NULL;
					gchar* _tmp81_ = NULL;
					guint _tmp82_ = 0U;
					guint _tmp83_ = 0U;
					gunichar uc = 0U;
					guint _tmp84_ = 0U;
					guint32 _tmp85_ = 0U;
					gboolean _tmp86_ = FALSE;
					gunichar _tmp87_ = 0U;
					gboolean _tmp88_ = FALSE;
					_tmp74_ = name;
					_tmp75_ = strlen ("dead_");
					_tmp76_ = _tmp75_;
					_tmp77_ = name;
					_tmp78_ = strlen (_tmp77_);
					_tmp79_ = _tmp78_;
					_tmp80_ = string_slice (_tmp74_, (glong) _tmp76_, (glong) _tmp79_);
					_tmp81_ = _tmp80_;
					_tmp82_ = gdk_keyval_from_name (_tmp81_);
					_tmp83_ = _tmp82_;
					_g_free0 (_tmp81_);
					keyval = _tmp83_;
					_tmp84_ = keyval;
					_tmp85_ = gdk_keyval_to_unicode (_tmp84_);
					uc = (gunichar) _tmp85_;
					_tmp87_ = uc;
					_tmp88_ = g_unichar_isspace (_tmp87_);
					if (!_tmp88_) {
						gunichar _tmp89_ = 0U;
						_tmp89_ = uc;
						_tmp86_ = _tmp89_ != ((gunichar) 0);
					} else {
						_tmp86_ = FALSE;
					}
					if (_tmp86_) {
						gunichar _tmp90_ = 0U;
						gchar* _tmp91_ = NULL;
						gchar* _tmp92_ = NULL;
						_tmp90_ = uc;
						_tmp91_ = g_unichar_to_string (_tmp90_);
						_tmp92_ = _tmp91_;
						caribou_key_model_set_label (self, _tmp92_);
						_g_free0 (_tmp92_);
					}
				}
				_tmp94_ = self->priv->_label;
				if (g_strcmp0 (_tmp94_, "") == 0) {
					guint* _tmp95_ = NULL;
					gint _tmp95__length1 = 0;
					_tmp95_ = self->priv->_keyvals;
					_tmp95__length1 = self->priv->_keyvals_length1;
					_tmp93_ = _tmp95__length1 > 0;
				} else {
					_tmp93_ = FALSE;
				}
				if (_tmp93_) {
					const gchar* _tmp96_ = NULL;
					_tmp96_ = name;
					caribou_key_model_set_label (self, _tmp96_);
				}
			}
		}
	}
	_tmp97_ = caribou_display_adapter_get_default ();
	_g_object_unref0 (self->priv->xadapter);
	self->priv->xadapter = _tmp97_;
	_tmp98_ = gee_array_list_new (CARIBOU_TYPE_KEY_MODEL, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->extended_keys);
	self->priv->extended_keys = _tmp98_;
	return self;
}


CaribouKeyModel* caribou_key_model_new (const gchar* name, const gchar* text) {
	return caribou_key_model_construct (CARIBOU_TYPE_KEY_MODEL, name, text);
}


static void _caribou_key_model_on_subkey_released_caribou_ikeyboard_object_key_released (CaribouIKeyboardObject* _sender, CaribouKeyModel* key, gpointer self) {
	caribou_key_model_on_subkey_released ((CaribouKeyModel*) self, key);
}


void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key) {
	CaribouKeyModel* _tmp0_ = NULL;
	GeeArrayList* _tmp1_ = NULL;
	CaribouKeyModel* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = key;
	g_signal_connect_object ((CaribouIKeyboardObject*) _tmp0_, "key-released", (GCallback) _caribou_key_model_on_subkey_released_caribou_ikeyboard_object_key_released, self, 0);
	_tmp1_ = self->priv->extended_keys;
	_tmp2_ = key;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, _tmp2_);
}


static void caribou_key_model_on_subkey_released (CaribouKeyModel* self, CaribouKeyModel* key) {
	CaribouKeyModel* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = key;
	g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-released", _tmp0_);
	caribou_key_model_set_show_subkeys (self, FALSE);
}


static gboolean _caribou_key_model_on_key_held_gsource_func (gpointer self) {
	gboolean result;
	result = caribou_key_model_on_key_held ((CaribouKeyModel*) self);
	return result;
}


void caribou_key_model_press (CaribouKeyModel* self) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp5_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = caribou_key_model_get_is_modifier (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		CaribouModifierState _tmp2_ = 0;
		_tmp2_ = self->modifier_state;
		if (_tmp2_ == CARIBOU_MODIFIER_STATE_NONE) {
			CaribouDisplayAdapter* _tmp3_ = NULL;
			GdkModifierType _tmp4_ = 0;
			self->modifier_state = CARIBOU_MODIFIER_STATE_LATCHED;
			_tmp3_ = self->priv->xadapter;
			_tmp4_ = self->priv->mod_mask;
			caribou_display_adapter_mod_lock (_tmp3_, (guint) _tmp4_);
		} else {
			self->modifier_state = CARIBOU_MODIFIER_STATE_NONE;
		}
	}
	_tmp5_ = self->priv->_repeatable;
	if (_tmp5_) {
		CaribouDisplayAdapter* _tmp6_ = NULL;
		guint _tmp7_ = 0U;
		_tmp6_ = self->priv->xadapter;
		_tmp7_ = self->priv->_keyval;
		caribou_display_adapter_keyval_press (_tmp6_, _tmp7_);
	} else {
		guint _tmp8_ = 0U;
		_tmp8_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1000, _caribou_key_model_on_key_held_gsource_func, g_object_ref (self), g_object_unref);
		self->priv->hold_tid = _tmp8_;
	}
	g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-pressed", self);
}


void caribou_key_model_release (CaribouKeyModel* self) {
	guint _tmp0_ = 0U;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp7_ = FALSE;
	guint _tmp15_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->hold_tid;
	if (_tmp0_ != ((guint) 0)) {
		guint _tmp1_ = 0U;
		_tmp1_ = self->priv->hold_tid;
		g_source_remove (_tmp1_);
	}
	_tmp2_ = caribou_key_model_get_is_modifier (self);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		CaribouModifierState _tmp4_ = 0;
		_tmp4_ = self->modifier_state;
		if (_tmp4_ == CARIBOU_MODIFIER_STATE_NONE) {
			CaribouDisplayAdapter* _tmp5_ = NULL;
			GdkModifierType _tmp6_ = 0;
			_tmp5_ = self->priv->xadapter;
			_tmp6_ = self->priv->mod_mask;
			caribou_display_adapter_mod_unlock (_tmp5_, (guint) _tmp6_);
		} else {
			return;
		}
	}
	_tmp7_ = self->priv->_repeatable;
	if (_tmp7_) {
		CaribouDisplayAdapter* _tmp8_ = NULL;
		guint _tmp9_ = 0U;
		_tmp8_ = self->priv->xadapter;
		_tmp9_ = self->priv->_keyval;
		caribou_display_adapter_keyval_release (_tmp8_, _tmp9_);
	} else {
		guint* _tmp10_ = NULL;
		gint _tmp10__length1 = 0;
		_tmp10_ = self->priv->_keyvals;
		_tmp10__length1 = self->priv->_keyvals_length1;
		{
			guint* keyval_collection = NULL;
			gint keyval_collection_length1 = 0;
			gint _keyval_collection_size_ = 0;
			gint keyval_it = 0;
			keyval_collection = _tmp10_;
			keyval_collection_length1 = _tmp10__length1;
			for (keyval_it = 0; keyval_it < _tmp10__length1; keyval_it = keyval_it + 1) {
				guint keyval = 0U;
				keyval = keyval_collection[keyval_it];
				{
					CaribouDisplayAdapter* _tmp11_ = NULL;
					guint _tmp12_ = 0U;
					CaribouDisplayAdapter* _tmp13_ = NULL;
					guint _tmp14_ = 0U;
					_tmp11_ = self->priv->xadapter;
					_tmp12_ = keyval;
					caribou_display_adapter_keyval_press (_tmp11_, _tmp12_);
					_tmp13_ = self->priv->xadapter;
					_tmp14_ = keyval;
					caribou_display_adapter_keyval_release (_tmp13_, _tmp14_);
				}
			}
		}
	}
	g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-released", self);
	_tmp15_ = self->priv->hold_tid;
	if (_tmp15_ != ((guint) 0)) {
		g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-clicked", self);
		self->priv->hold_tid = (guint) 0;
	} else {
		g_signal_emit_by_name (self, "key-hold-end");
	}
}


static gboolean caribou_key_model_on_key_held (CaribouKeyModel* self) {
	gboolean result = FALSE;
	GeeArrayList* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	self->priv->hold_tid = (guint) 0;
	_tmp0_ = self->priv->extended_keys;
	_tmp1_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != 0) {
		caribou_key_model_set_show_subkeys (self, TRUE);
	}
	_tmp4_ = caribou_key_model_get_is_modifier (self);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		CaribouModifierState _tmp6_ = 0;
		_tmp6_ = self->modifier_state;
		_tmp3_ = _tmp6_ == CARIBOU_MODIFIER_STATE_LATCHED;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		self->modifier_state = CARIBOU_MODIFIER_STATE_LOCKED;
	}
	g_signal_emit_by_name (self, "key-hold");
	result = FALSE;
	return result;
}


CaribouKeyModel** caribou_key_model_get_extended_keys (CaribouKeyModel* self, int* result_length1) {
	CaribouKeyModel** result = NULL;
	GeeArrayList* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gpointer* _tmp2_ = NULL;
	CaribouKeyModel** _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->extended_keys;
	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
	_tmp3_ = (CaribouKeyModel**) _tmp2_;
	_tmp3__length1 = (_tmp1_ * sizeof (CaribouKeyModel*)) / sizeof (CaribouKeyModel*);
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}


static CaribouKeyModel** caribou_key_model_real_get_keys (CaribouIKeyboardObject* base, int* result_length1) {
	CaribouKeyModel * self;
	CaribouKeyModel** result = NULL;
	GeeArrayList* all_keys = NULL;
	GeeArrayList* _tmp0_ = NULL;
	GeeArrayList* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gpointer* _tmp3_ = NULL;
	CaribouKeyModel** _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	self = (CaribouKeyModel*) base;
	_tmp0_ = gee_array_list_new (CARIBOU_TYPE_KEY_MODEL, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	all_keys = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) all_keys, self);
	_tmp1_ = self->priv->extended_keys;
	gee_array_list_add_all (all_keys, (GeeCollection*) _tmp1_);
	_tmp3_ = gee_collection_to_array ((GeeCollection*) all_keys, &_tmp2_);
	_tmp4_ = (CaribouKeyModel**) _tmp3_;
	_tmp4__length1 = (_tmp2_ * sizeof (CaribouKeyModel*)) / sizeof (CaribouKeyModel*);
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	_g_object_unref0 (all_keys);
	return result;
}


static CaribouIKeyboardObject** caribou_key_model_real_get_children (CaribouIKeyboardObject* base, int* result_length1) {
	CaribouKeyModel * self;
	CaribouIKeyboardObject** result = NULL;
	GeeArrayList* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gpointer* _tmp2_ = NULL;
	CaribouIKeyboardObject** _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	self = (CaribouKeyModel*) base;
	_tmp0_ = self->priv->extended_keys;
	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
	_tmp3_ = (CaribouIKeyboardObject**) _tmp2_;
	_tmp3__length1 = (_tmp1_ * sizeof (CaribouKeyModel*)) / sizeof (CaribouIKeyboardObject*);
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}


static gboolean __lambda4_ (CaribouKeyModel* self) {
	gboolean result = FALSE;
	caribou_key_model_release (self);
	result = FALSE;
	return result;
}


static gboolean ___lambda4__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda4_ ((CaribouKeyModel*) self);
	return result;
}


void caribou_key_model_activate (CaribouKeyModel* self) {
	g_return_if_fail (self != NULL);
	caribou_key_model_press (self);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, ___lambda4__gsource_func, g_object_ref (self), g_object_unref);
}


const gchar* caribou_key_model_get_align (CaribouKeyModel* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_align;
	result = _tmp0_;
	return result;
}


void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_align);
	self->priv->_align = _tmp1_;
	g_object_notify ((GObject *) self, "align");
}


gdouble caribou_key_model_get_width (CaribouKeyModel* self) {
	gdouble result;
	gdouble _tmp0_ = 0.0;
	g_return_val_if_fail (self != NULL, 0.0);
	_tmp0_ = self->priv->_width;
	result = _tmp0_;
	return result;
}


void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value) {
	gdouble _tmp0_ = 0.0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_width = _tmp0_;
	g_object_notify ((GObject *) self, "width");
}


const gchar* caribou_key_model_get_toggle (CaribouKeyModel* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_toggle;
	result = _tmp0_;
	return result;
}


void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_toggle);
	self->priv->_toggle = _tmp1_;
	g_object_notify ((GObject *) self, "toggle");
}


gboolean caribou_key_model_get_repeatable (CaribouKeyModel* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_repeatable;
	result = _tmp0_;
	return result;
}


void caribou_key_model_set_repeatable (CaribouKeyModel* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_repeatable = _tmp0_;
	g_object_notify ((GObject *) self, "repeatable");
}


gboolean caribou_key_model_get_is_modifier (CaribouKeyModel* self) {
	gboolean result;
	GdkModifierType _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->mod_mask;
	result = _tmp0_ != 0;
	return result;
}


void caribou_key_model_set_is_modifier (CaribouKeyModel* self, gboolean value) {
	g_return_if_fail (self != NULL);
	g_object_notify ((GObject *) self, "is-modifier");
}


gboolean caribou_key_model_get_show_subkeys (CaribouKeyModel* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_show_subkeys;
	result = _tmp0_;
	return result;
}


static void caribou_key_model_set_show_subkeys (CaribouKeyModel* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_show_subkeys = _tmp0_;
	g_object_notify ((GObject *) self, "show-subkeys");
}


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


static void caribou_key_model_set_name (CaribouKeyModel* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp1_;
	g_object_notify ((GObject *) self, "name");
}


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


static void caribou_key_model_set_keyval (CaribouKeyModel* self, guint value) {
	guint _tmp0_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_keyval = _tmp0_;
	g_object_notify ((GObject *) self, "keyval");
}


const gchar* caribou_key_model_get_text (CaribouKeyModel* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}


static void caribou_key_model_set_text (CaribouKeyModel* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_text);
	self->priv->_text = _tmp1_;
	g_object_notify ((GObject *) self, "text");
}


const gchar* caribou_key_model_get_label (CaribouKeyModel* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}


void caribou_key_model_set_label (CaribouKeyModel* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_label);
	self->priv->_label = _tmp1_;
	g_object_notify ((GObject *) self, "label");
}


static gboolean caribou_key_model_real_get_scan_stepping (CaribouIScannableItem* base) {
	gboolean result;
	CaribouKeyModel* self;
	gboolean _tmp0_ = FALSE;
	self = (CaribouKeyModel*) base;
	_tmp0_ = self->priv->_scan_stepping;
	result = _tmp0_;
	return result;
}


static void caribou_key_model_real_set_scan_stepping (CaribouIScannableItem* base, gboolean value) {
	CaribouKeyModel* self;
	gboolean _tmp0_ = FALSE;
	self = (CaribouKeyModel*) base;
	_tmp0_ = value;
	self->priv->_scan_stepping = _tmp0_;
	g_object_notify ((GObject *) self, "scan-stepping");
}


static gboolean caribou_key_model_real_get_scan_selected (CaribouIScannableItem* base) {
	gboolean result;
	CaribouKeyModel* self;
	gboolean _tmp0_ = FALSE;
	self = (CaribouKeyModel*) base;
	_tmp0_ = self->priv->_scan_selected;
	result = _tmp0_;
	return result;
}


static void caribou_key_model_real_set_scan_selected (CaribouIScannableItem* base, gboolean value) {
	CaribouKeyModel* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	self = (CaribouKeyModel*) base;
	_tmp0_ = value;
	self->priv->_scan_selected = _tmp0_;
	_tmp1_ = self->priv->_scan_selected;
	if (_tmp1_) {
		caribou_key_model_activate (self);
	}
	g_object_notify ((GObject *) self, "scan-selected");
}


static void caribou_key_model_class_init (CaribouKeyModelClass * klass) {
	caribou_key_model_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (CaribouKeyModelPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_caribou_key_model_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_caribou_key_model_set_property;
	G_OBJECT_CLASS (klass)->finalize = caribou_key_model_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_ALIGN, g_param_spec_string ("align", "align", "align", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_WIDTH, g_param_spec_double ("width", "width", "width", -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_TOGGLE, g_param_spec_string ("toggle", "toggle", "toggle", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_REPEATABLE, g_param_spec_boolean ("repeatable", "repeatable", "repeatable", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_IS_MODIFIER, g_param_spec_boolean ("is-modifier", "is-modifier", "is-modifier", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SHOW_SUBKEYS, g_param_spec_boolean ("show-subkeys", "show-subkeys", "show-subkeys", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_KEYVAL, g_param_spec_uint ("keyval", "keyval", "keyval", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_TEXT, g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_LABEL, g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SCAN_STEPPING, g_param_spec_boolean ("scan-stepping", "scan-stepping", "scan-stepping", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SCAN_SELECTED, g_param_spec_boolean ("scan-selected", "scan-selected", "scan-selected", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_signal_new ("key_hold_end", CARIBOU_TYPE_KEY_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	g_signal_new ("key_hold", CARIBOU_TYPE_KEY_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void caribou_key_model_caribou_iscannable_item_interface_init (CaribouIScannableItemIface * iface) {
	caribou_key_model_caribou_iscannable_item_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_scan_stepping = caribou_key_model_real_get_scan_stepping;
	iface->set_scan_stepping = caribou_key_model_real_set_scan_stepping;
	iface->get_scan_selected = caribou_key_model_real_get_scan_selected;
	iface->set_scan_selected = caribou_key_model_real_set_scan_selected;
}


static void caribou_key_model_caribou_ikeyboard_object_interface_init (CaribouIKeyboardObjectIface * iface) {
	caribou_key_model_caribou_ikeyboard_object_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_keys = (CaribouKeyModel** (*)(CaribouIKeyboardObject*, int*)) caribou_key_model_real_get_keys;
	iface->get_children = (CaribouIKeyboardObject** (*)(CaribouIKeyboardObject*, int*)) caribou_key_model_real_get_children;
}


static void caribou_key_model_instance_init (CaribouKeyModel * self) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	guint* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	self->priv = CARIBOU_KEY_MODEL_GET_PRIVATE (self);
	_tmp0_ = g_strdup ("center");
	self->priv->_align = _tmp0_;
	self->priv->_width = 1.0;
	_tmp1_ = g_strdup ("");
	self->priv->_toggle = _tmp1_;
	self->priv->_repeatable = FALSE;
	self->priv->_show_subkeys = FALSE;
	self->priv->_text = NULL;
	_tmp2_ = g_new0 (guint, 0);
	self->priv->_keyvals = _tmp2_;
	self->priv->_keyvals_length1 = 0;
	self->priv->__keyvals_size_ = self->priv->_keyvals_length1;
	_tmp3_ = g_strdup ("");
	self->priv->_label = _tmp3_;
}


static void caribou_key_model_finalize (GObject* obj) {
	CaribouKeyModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel);
	_g_free0 (self->priv->_align);
	_g_free0 (self->priv->_toggle);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_text);
	self->priv->_keyvals = (g_free (self->priv->_keyvals), NULL);
	_g_free0 (self->priv->_label);
	_g_object_unref0 (self->priv->xadapter);
	_g_object_unref0 (self->priv->extended_keys);
	G_OBJECT_CLASS (caribou_key_model_parent_class)->finalize (obj);
}


/**
     * Object representing a key in a column.
     *
     * This is used for implementing custom keyboard service.
     */
GType caribou_key_model_get_type (void) {
	static volatile gsize caribou_key_model_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_key_model_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (CaribouKeyModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_key_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouKeyModel), 0, (GInstanceInitFunc) caribou_key_model_instance_init, NULL };
		static const GInterfaceInfo caribou_iscannable_item_info = { (GInterfaceInitFunc) caribou_key_model_caribou_iscannable_item_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo caribou_ikeyboard_object_info = { (GInterfaceInitFunc) caribou_key_model_caribou_ikeyboard_object_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType caribou_key_model_type_id;
		caribou_key_model_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouKeyModel", &g_define_type_info, 0);
		g_type_add_interface_static (caribou_key_model_type_id, CARIBOU_TYPE_ISCANNABLE_ITEM, &caribou_iscannable_item_info);
		g_type_add_interface_static (caribou_key_model_type_id, CARIBOU_TYPE_IKEYBOARD_OBJECT, &caribou_ikeyboard_object_info);
		g_once_init_leave (&caribou_key_model_type_id__volatile, caribou_key_model_type_id);
	}
	return caribou_key_model_type_id__volatile;
}


static void _vala_caribou_key_model_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	CaribouKeyModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel);
	switch (property_id) {
		case CARIBOU_KEY_MODEL_ALIGN:
		g_value_set_string (value, caribou_key_model_get_align (self));
		break;
		case CARIBOU_KEY_MODEL_WIDTH:
		g_value_set_double (value, caribou_key_model_get_width (self));
		break;
		case CARIBOU_KEY_MODEL_TOGGLE:
		g_value_set_string (value, caribou_key_model_get_toggle (self));
		break;
		case CARIBOU_KEY_MODEL_REPEATABLE:
		g_value_set_boolean (value, caribou_key_model_get_repeatable (self));
		break;
		case CARIBOU_KEY_MODEL_IS_MODIFIER:
		g_value_set_boolean (value, caribou_key_model_get_is_modifier (self));
		break;
		case CARIBOU_KEY_MODEL_SHOW_SUBKEYS:
		g_value_set_boolean (value, caribou_key_model_get_show_subkeys (self));
		break;
		case CARIBOU_KEY_MODEL_NAME:
		g_value_set_string (value, caribou_key_model_get_name (self));
		break;
		case CARIBOU_KEY_MODEL_KEYVAL:
		g_value_set_uint (value, caribou_key_model_get_keyval (self));
		break;
		case CARIBOU_KEY_MODEL_TEXT:
		g_value_set_string (value, caribou_key_model_get_text (self));
		break;
		case CARIBOU_KEY_MODEL_LABEL:
		g_value_set_string (value, caribou_key_model_get_label (self));
		break;
		case CARIBOU_KEY_MODEL_SCAN_STEPPING:
		g_value_set_boolean (value, caribou_iscannable_item_get_scan_stepping ((CaribouIScannableItem*) self));
		break;
		case CARIBOU_KEY_MODEL_SCAN_SELECTED:
		g_value_set_boolean (value, caribou_iscannable_item_get_scan_selected ((CaribouIScannableItem*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_caribou_key_model_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	CaribouKeyModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel);
	switch (property_id) {
		case CARIBOU_KEY_MODEL_ALIGN:
		caribou_key_model_set_align (self, g_value_get_string (value));
		break;
		case CARIBOU_KEY_MODEL_WIDTH:
		caribou_key_model_set_width (self, g_value_get_double (value));
		break;
		case CARIBOU_KEY_MODEL_TOGGLE:
		caribou_key_model_set_toggle (self, g_value_get_string (value));
		break;
		case CARIBOU_KEY_MODEL_REPEATABLE:
		caribou_key_model_set_repeatable (self, g_value_get_boolean (value));
		break;
		case CARIBOU_KEY_MODEL_IS_MODIFIER:
		caribou_key_model_set_is_modifier (self, g_value_get_boolean (value));
		break;
		case CARIBOU_KEY_MODEL_SHOW_SUBKEYS:
		caribou_key_model_set_show_subkeys (self, g_value_get_boolean (value));
		break;
		case CARIBOU_KEY_MODEL_NAME:
		caribou_key_model_set_name (self, g_value_get_string (value));
		break;
		case CARIBOU_KEY_MODEL_KEYVAL:
		caribou_key_model_set_keyval (self, g_value_get_uint (value));
		break;
		case CARIBOU_KEY_MODEL_TEXT:
		caribou_key_model_set_text (self, g_value_get_string (value));
		break;
		case CARIBOU_KEY_MODEL_LABEL:
		caribou_key_model_set_label (self, g_value_get_string (value));
		break;
		case CARIBOU_KEY_MODEL_SCAN_STEPPING:
		caribou_iscannable_item_set_scan_stepping ((CaribouIScannableItem*) self, g_value_get_boolean (value));
		break;
		case CARIBOU_KEY_MODEL_SCAN_SELECTED:
		caribou_iscannable_item_set_scan_selected ((CaribouIScannableItem*) self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


GType caribou_modifier_state_get_type (void) {
	static volatile gsize caribou_modifier_state_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_modifier_state_type_id__volatile)) {
		static const GEnumValue values[] = {{CARIBOU_MODIFIER_STATE_NONE, "CARIBOU_MODIFIER_STATE_NONE", "none"}, {CARIBOU_MODIFIER_STATE_LATCHED, "CARIBOU_MODIFIER_STATE_LATCHED", "latched"}, {CARIBOU_MODIFIER_STATE_LOCKED, "CARIBOU_MODIFIER_STATE_LOCKED", "locked"}, {0, NULL, NULL}};
		GType caribou_modifier_state_type_id;
		caribou_modifier_state_type_id = g_enum_register_static ("CaribouModifierState", values);
		g_once_init_leave (&caribou_modifier_state_type_id__volatile, caribou_modifier_state_type_id);
	}
	return caribou_modifier_state_type_id__volatile;
}


void caribou_modifier_map_entry_copy (const CaribouModifierMapEntry* self, CaribouModifierMapEntry* dest) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	GdkModifierType _tmp2_ = 0;
	_tmp0_ = (*self).name;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).name);
	(*dest).name = _tmp1_;
	_tmp2_ = (*self).mask;
	(*dest).mask = _tmp2_;
}


void caribou_modifier_map_entry_destroy (CaribouModifierMapEntry* self) {
	_g_free0 ((*self).name);
}


CaribouModifierMapEntry* caribou_modifier_map_entry_dup (const CaribouModifierMapEntry* self) {
	CaribouModifierMapEntry* dup;
	dup = g_new0 (CaribouModifierMapEntry, 1);
	caribou_modifier_map_entry_copy (self, dup);
	return dup;
}


void caribou_modifier_map_entry_free (CaribouModifierMapEntry* self) {
	caribou_modifier_map_entry_destroy (self);
	g_free (self);
}


GType caribou_modifier_map_entry_get_type (void) {
	static volatile gsize caribou_modifier_map_entry_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_modifier_map_entry_type_id__volatile)) {
		GType caribou_modifier_map_entry_type_id;
		caribou_modifier_map_entry_type_id = g_boxed_type_register_static ("CaribouModifierMapEntry", (GBoxedCopyFunc) caribou_modifier_map_entry_dup, (GBoxedFreeFunc) caribou_modifier_map_entry_free);
		g_once_init_leave (&caribou_modifier_map_entry_type_id__volatile, caribou_modifier_map_entry_type_id);
	}
	return caribou_modifier_map_entry_type_id__volatile;
}


void caribou_label_map_entry_copy (const CaribouLabelMapEntry* self, CaribouLabelMapEntry* dest) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	_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 caribou_label_map_entry_destroy (CaribouLabelMapEntry* self) {
	_g_free0 ((*self).name);
	_g_free0 ((*self).label);
}


CaribouLabelMapEntry* caribou_label_map_entry_dup (const CaribouLabelMapEntry* self) {
	CaribouLabelMapEntry* dup;
	dup = g_new0 (CaribouLabelMapEntry, 1);
	caribou_label_map_entry_copy (self, dup);
	return dup;
}


void caribou_label_map_entry_free (CaribouLabelMapEntry* self) {
	caribou_label_map_entry_destroy (self);
	g_free (self);
}


GType caribou_label_map_entry_get_type (void) {
	static volatile gsize caribou_label_map_entry_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_label_map_entry_type_id__volatile)) {
		GType caribou_label_map_entry_type_id;
		caribou_label_map_entry_type_id = g_boxed_type_register_static ("CaribouLabelMapEntry", (GBoxedCopyFunc) caribou_label_map_entry_dup, (GBoxedFreeFunc) caribou_label_map_entry_free);
		g_once_init_leave (&caribou_label_map_entry_type_id__volatile, caribou_label_map_entry_type_id);
	}
	return caribou_label_map_entry_type_id__volatile;
}



