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

/*
Copyright (C) 2012 Johan Mattsson

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

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

typedef struct _BirdFontParamSpecKeyBindings BirdFontParamSpecKeyBindings;

struct _BirdFontParamSpecKeyBindings {
	GParamSpec parent_instance;
};

static gpointer bird_font_key_bindings_parent_class = NULL;
static gboolean bird_font_key_bindings_modifier_ctrl;
static gboolean bird_font_key_bindings_modifier_ctrl = FALSE;
static gboolean bird_font_key_bindings_modifier_alt;
static gboolean bird_font_key_bindings_modifier_alt = FALSE;
static gboolean bird_font_key_bindings_modifier_shift;
static gboolean bird_font_key_bindings_modifier_shift = FALSE;
static gboolean bird_font_key_bindings_modifier_logo;
static gboolean bird_font_key_bindings_modifier_logo = FALSE;
guint bird_font_key_bindings_modifier = (guint) 0;
gboolean bird_font_key_bindings_require_modifier = FALSE;

VALA_EXTERN gboolean bird_font_is_arrow_key (guint keyval);
VALA_EXTERN gboolean bird_font_is_modifier_key (guint i);
static void bird_font_key_bindings_finalize (BirdFontKeyBindings * obj);
static GType bird_font_key_bindings_get_type_once (void);

static GType
bird_font_key_get_type_once (void)
{
	static const GEnumValue values[] = {{BIRD_FONT_KEY_NONE, "BIRD_FONT_KEY_NONE", "none"}, {BIRD_FONT_KEY_UP, "BIRD_FONT_KEY_UP", "up"}, {BIRD_FONT_KEY_RIGHT, "BIRD_FONT_KEY_RIGHT", "right"}, {BIRD_FONT_KEY_DOWN, "BIRD_FONT_KEY_DOWN", "down"}, {BIRD_FONT_KEY_LEFT, "BIRD_FONT_KEY_LEFT", "left"}, {BIRD_FONT_KEY_PG_UP, "BIRD_FONT_KEY_PG_UP", "pg-up"}, {BIRD_FONT_KEY_PG_DOWN, "BIRD_FONT_KEY_PG_DOWN", "pg-down"}, {BIRD_FONT_KEY_ENTER, "BIRD_FONT_KEY_ENTER", "enter"}, {BIRD_FONT_KEY_BACK_SPACE, "BIRD_FONT_KEY_BACK_SPACE", "back-space"}, {BIRD_FONT_KEY_SHIFT_LEFT, "BIRD_FONT_KEY_SHIFT_LEFT", "shift-left"}, {BIRD_FONT_KEY_SHIFT_RIGHT, "BIRD_FONT_KEY_SHIFT_RIGHT", "shift-right"}, {BIRD_FONT_KEY_CTRL_LEFT, "BIRD_FONT_KEY_CTRL_LEFT", "ctrl-left"}, {BIRD_FONT_KEY_CTRL_RIGHT, "BIRD_FONT_KEY_CTRL_RIGHT", "ctrl-right"}, {BIRD_FONT_KEY_CAPS_LOCK, "BIRD_FONT_KEY_CAPS_LOCK", "caps-lock"}, {BIRD_FONT_KEY_ALT_LEFT, "BIRD_FONT_KEY_ALT_LEFT", "alt-left"}, {BIRD_FONT_KEY_ALT_RIGHT, "BIRD_FONT_KEY_ALT_RIGHT", "alt-right"}, {BIRD_FONT_KEY_ALT_GR, "BIRD_FONT_KEY_ALT_GR", "alt-gr"}, {BIRD_FONT_KEY_LOGO_LEFT, "BIRD_FONT_KEY_LOGO_LEFT", "logo-left"}, {BIRD_FONT_KEY_LOGO_RIGHT, "BIRD_FONT_KEY_LOGO_RIGHT", "logo-right"}, {BIRD_FONT_KEY_CONTEXT_MENU, "BIRD_FONT_KEY_CONTEXT_MENU", "context-menu"}, {BIRD_FONT_KEY_TAB, "BIRD_FONT_KEY_TAB", "tab"}, {BIRD_FONT_KEY_SHIFT_TAB, "BIRD_FONT_KEY_SHIFT_TAB", "shift-tab"}, {BIRD_FONT_KEY_DEL, "BIRD_FONT_KEY_DEL", "del"}, {BIRD_FONT_KEY_NUM_PLUS, "BIRD_FONT_KEY_NUM_PLUS", "num-plus"}, {BIRD_FONT_KEY_NUM_MINUS, "BIRD_FONT_KEY_NUM_MINUS", "num-minus"}, {BIRD_FONT_KEY_END, "BIRD_FONT_KEY_END", "end"}, {BIRD_FONT_KEY_HOME, "BIRD_FONT_KEY_HOME", "home"}, {0, NULL, NULL}};
	GType bird_font_key_type_id;
	bird_font_key_type_id = g_enum_register_static ("BirdFontKey", values);
	return bird_font_key_type_id;
}

GType
bird_font_key_get_type (void)
{
	static volatile gsize bird_font_key_type_id__once = 0;
	if (g_once_init_enter (&bird_font_key_type_id__once)) {
		GType bird_font_key_type_id;
		bird_font_key_type_id = bird_font_key_get_type_once ();
		g_once_init_leave (&bird_font_key_type_id__once, bird_font_key_type_id);
	}
	return bird_font_key_type_id__once;
}

gboolean
bird_font_is_arrow_key (guint keyval)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	if (keyval == ((guint) BIRD_FONT_KEY_UP)) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = keyval == ((guint) BIRD_FONT_KEY_DOWN);
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = keyval == ((guint) BIRD_FONT_KEY_LEFT);
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = keyval == ((guint) BIRD_FONT_KEY_RIGHT);
	}
	result = _tmp0_;
	return result;
}

gboolean
bird_font_is_modifier_key (guint i)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	gboolean result;
	if (((guint) BIRD_FONT_KEY_PG_UP) == i) {
		_tmp16_ = TRUE;
	} else {
		_tmp16_ = ((guint) BIRD_FONT_KEY_PG_DOWN) == i;
	}
	if (_tmp16_) {
		_tmp15_ = TRUE;
	} else {
		_tmp15_ = ((guint) BIRD_FONT_KEY_ENTER) == i;
	}
	if (_tmp15_) {
		_tmp14_ = TRUE;
	} else {
		_tmp14_ = ((guint) BIRD_FONT_KEY_BACK_SPACE) == i;
	}
	if (_tmp14_) {
		_tmp13_ = TRUE;
	} else {
		_tmp13_ = ((guint) BIRD_FONT_KEY_SHIFT_LEFT) == i;
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = ((guint) BIRD_FONT_KEY_SHIFT_RIGHT) == i;
	}
	if (_tmp12_) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = ((guint) BIRD_FONT_KEY_CTRL_LEFT) == i;
	}
	if (_tmp11_) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = ((guint) BIRD_FONT_KEY_CTRL_RIGHT) == i;
	}
	if (_tmp10_) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = ((guint) BIRD_FONT_KEY_ALT_LEFT) == i;
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = ((guint) BIRD_FONT_KEY_ALT_RIGHT) == i;
	}
	if (_tmp8_) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = ((guint) BIRD_FONT_KEY_ALT_GR) == i;
	}
	if (_tmp7_) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = ((guint) BIRD_FONT_KEY_LOGO_LEFT) == i;
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = ((guint) BIRD_FONT_KEY_LOGO_RIGHT) == i;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = ((guint) BIRD_FONT_KEY_TAB) == i;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = ((guint) BIRD_FONT_KEY_CAPS_LOCK) == i;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = ((guint) BIRD_FONT_KEY_LOGO_RIGHT) == i;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = ((guint) BIRD_FONT_KEY_ENTER) == i;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = ((guint) BIRD_FONT_KEY_DEL) == i;
	}
	result = _tmp0_;
	return result;
}

guint
bird_font_key_bindings_get_modifiers (void)
{
	guint result;
	result = bird_font_key_bindings_modifier;
	return result;
}

void
bird_font_key_bindings_reset (void)
{
	bird_font_key_bindings_modifier = BIRD_FONT_NONE;
	bird_font_key_bindings_modifier_ctrl = FALSE;
	bird_font_key_bindings_modifier_alt = FALSE;
	bird_font_key_bindings_modifier_shift = FALSE;
	bird_font_key_bindings_modifier_logo = FALSE;
}

void
bird_font_key_bindings_set_require_modifier (gboolean t)
{
	bird_font_key_bindings_require_modifier = t;
}

guint
bird_font_key_bindings_get_mod_from_key (guint keyval)
{
	guint mod = 0U;
	guint _tmp0_ = 0U;
	gboolean _tmp1_ = FALSE;
	guint _tmp2_ = 0U;
	gboolean _tmp3_ = FALSE;
	guint _tmp4_ = 0U;
	gboolean _tmp5_ = FALSE;
	guint _tmp6_ = 0U;
	gboolean _tmp7_ = FALSE;
	guint result;
	mod = BIRD_FONT_NONE;
	if (keyval == ((guint) BIRD_FONT_KEY_CTRL_RIGHT)) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = keyval == ((guint) BIRD_FONT_KEY_CTRL_LEFT);
	}
	if (_tmp1_) {
		_tmp0_ = BIRD_FONT_CTRL;
	} else {
		_tmp0_ = (guint) 0;
	}
	mod |= _tmp0_;
	if (keyval == ((guint) BIRD_FONT_KEY_SHIFT_RIGHT)) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = keyval == ((guint) BIRD_FONT_KEY_SHIFT_LEFT);
	}
	if (_tmp3_) {
		_tmp2_ = BIRD_FONT_SHIFT;
	} else {
		_tmp2_ = (guint) 0;
	}
	mod |= _tmp2_;
	if (keyval == ((guint) BIRD_FONT_KEY_ALT_LEFT)) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = keyval == ((guint) BIRD_FONT_KEY_ALT_GR);
	}
	if (_tmp5_) {
		_tmp4_ = BIRD_FONT_ALT;
	} else {
		_tmp4_ = (guint) 0;
	}
	mod |= _tmp4_;
	if (keyval == ((guint) BIRD_FONT_KEY_LOGO_LEFT)) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = keyval == ((guint) BIRD_FONT_KEY_LOGO_RIGHT);
	}
	if (_tmp7_) {
		_tmp6_ = BIRD_FONT_LOGO;
	} else {
		_tmp6_ = (guint) 0;
	}
	mod |= _tmp6_;
	result = mod;
	return result;
}

void
bird_font_key_bindings_remove_modifier_from_keyval (guint keyval)
{
	guint mod = 0U;
	mod = (guint) (0xFFFFFF ^ bird_font_key_bindings_get_mod_from_key (keyval));
	bird_font_key_bindings_set_modifier (bird_font_key_bindings_modifier & mod);
}

void
bird_font_key_bindings_add_modifier_from_keyval (guint keyval)
{
	guint mod = 0U;
	mod = bird_font_key_bindings_get_mod_from_key (keyval);
	bird_font_key_bindings_set_modifier (bird_font_key_bindings_modifier | mod);
}

void
bird_font_key_bindings_set_modifier (guint mod)
{
	bird_font_key_bindings_modifier = mod;
	bird_font_key_bindings_modifier_ctrl = (bird_font_key_bindings_modifier & BIRD_FONT_CTRL) > ((guint) 0);
	bird_font_key_bindings_modifier_alt = (bird_font_key_bindings_modifier & BIRD_FONT_ALT) > ((guint) 0);
	bird_font_key_bindings_modifier_shift = (bird_font_key_bindings_modifier & BIRD_FONT_SHIFT) > ((guint) 0);
	bird_font_key_bindings_modifier_logo = (bird_font_key_bindings_modifier & BIRD_FONT_LOGO) > ((guint) 0);
}

gboolean
bird_font_key_bindings_has_alt (void)
{
	gboolean result;
	result = bird_font_key_bindings_modifier_alt;
	return result;
}

gboolean
bird_font_key_bindings_has_shift (void)
{
	gboolean result;
	result = bird_font_key_bindings_modifier_shift;
	return result;
}

gboolean
bird_font_key_bindings_has_ctrl (void)
{
	gboolean result;
	result = bird_font_key_bindings_modifier_ctrl;
	return result;
}

gboolean
bird_font_key_bindings_has_logo (void)
{
	gboolean result;
	result = bird_font_key_bindings_modifier_logo;
	return result;
}

BirdFontKeyBindings*
bird_font_key_bindings_construct (GType object_type)
{
	BirdFontKeyBindings* self = NULL;
	self = (BirdFontKeyBindings*) g_type_create_instance (object_type);
	return self;
}

BirdFontKeyBindings*
bird_font_key_bindings_new (void)
{
	return bird_font_key_bindings_construct (BIRD_FONT_TYPE_KEY_BINDINGS);
}

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

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

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

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

static gchar*
bird_font_value_key_bindings_collect_value (GValue* value,
                                            guint n_collect_values,
                                            GTypeCValue* collect_values,
                                            guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		BirdFontKeyBindings * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = bird_font_key_bindings_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
bird_font_value_key_bindings_lcopy_value (const GValue* value,
                                          guint n_collect_values,
                                          GTypeCValue* collect_values,
                                          guint collect_flags)
{
	BirdFontKeyBindings ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = bird_font_key_bindings_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
bird_font_param_spec_key_bindings (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags)
{
	BirdFontParamSpecKeyBindings* spec;
	g_return_val_if_fail (g_type_is_a (object_type, BIRD_FONT_TYPE_KEY_BINDINGS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
bird_font_value_get_key_bindings (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_KEY_BINDINGS), NULL);
	return value->data[0].v_pointer;
}

void
bird_font_value_set_key_bindings (GValue* value,
                                  gpointer v_object)
{
	BirdFontKeyBindings * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_KEY_BINDINGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BIRD_FONT_TYPE_KEY_BINDINGS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		bird_font_key_bindings_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		bird_font_key_bindings_unref (old);
	}
}

void
bird_font_value_take_key_bindings (GValue* value,
                                   gpointer v_object)
{
	BirdFontKeyBindings * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_KEY_BINDINGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BIRD_FONT_TYPE_KEY_BINDINGS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		bird_font_key_bindings_unref (old);
	}
}

static void
bird_font_key_bindings_class_init (BirdFontKeyBindingsClass * klass,
                                   gpointer klass_data)
{
	bird_font_key_bindings_parent_class = g_type_class_peek_parent (klass);
	((BirdFontKeyBindingsClass *) klass)->finalize = bird_font_key_bindings_finalize;
}

static void
bird_font_key_bindings_instance_init (BirdFontKeyBindings * self,
                                      gpointer klass)
{
	self->ref_count = 1;
}

static void
bird_font_key_bindings_finalize (BirdFontKeyBindings * obj)
{
	BirdFontKeyBindings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_KEY_BINDINGS, BirdFontKeyBindings);
	g_signal_handlers_destroy (self);
}

static GType
bird_font_key_bindings_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { bird_font_value_key_bindings_init, bird_font_value_key_bindings_free_value, bird_font_value_key_bindings_copy_value, bird_font_value_key_bindings_peek_pointer, "p", bird_font_value_key_bindings_collect_value, "p", bird_font_value_key_bindings_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontKeyBindingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_key_bindings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontKeyBindings), 0, (GInstanceInitFunc) bird_font_key_bindings_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType bird_font_key_bindings_type_id;
	bird_font_key_bindings_type_id = g_type_register_fundamental (g_type_fundamental_next (), "BirdFontKeyBindings", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return bird_font_key_bindings_type_id;
}

GType
bird_font_key_bindings_get_type (void)
{
	static volatile gsize bird_font_key_bindings_type_id__once = 0;
	if (g_once_init_enter (&bird_font_key_bindings_type_id__once)) {
		GType bird_font_key_bindings_type_id;
		bird_font_key_bindings_type_id = bird_font_key_bindings_get_type_once ();
		g_once_init_leave (&bird_font_key_bindings_type_id__once, bird_font_key_bindings_type_id);
	}
	return bird_font_key_bindings_type_id__once;
}

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

void
bird_font_key_bindings_unref (gpointer instance)
{
	BirdFontKeyBindings * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		BIRD_FONT_KEY_BINDINGS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

