/* scanner.c generated by valac 0.30.0.3-b11d, the Vala compiler
 * generated from scanner.vala, do not modify */


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


#define CARIBOU_TYPE_SCANNER (caribou_scanner_get_type ())
#define CARIBOU_SCANNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_SCANNER, CaribouScanner))
#define CARIBOU_SCANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_SCANNER, CaribouScannerClass))
#define CARIBOU_IS_SCANNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_SCANNER))
#define CARIBOU_IS_SCANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_SCANNER))
#define CARIBOU_SCANNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_SCANNER, CaribouScannerClass))

typedef struct _CaribouScanner CaribouScanner;
typedef struct _CaribouScannerClass CaribouScannerClass;
typedef struct _CaribouScannerPrivate CaribouScannerPrivate;

#define CARIBOU_TYPE_SCAN_GROUPING (caribou_scan_grouping_get_type ())

#define CARIBOU_TYPE_KEYBOARD_MODEL (caribou_keyboard_model_get_type ())
#define CARIBOU_KEYBOARD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_KEYBOARD_MODEL, CaribouKeyboardModel))
#define CARIBOU_KEYBOARD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_KEYBOARD_MODEL, CaribouKeyboardModelClass))
#define CARIBOU_IS_KEYBOARD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_KEYBOARD_MODEL))
#define CARIBOU_IS_KEYBOARD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_KEYBOARD_MODEL))
#define CARIBOU_KEYBOARD_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_KEYBOARD_MODEL, CaribouKeyboardModelClass))

typedef struct _CaribouKeyboardModel CaribouKeyboardModel;
typedef struct _CaribouKeyboardModelClass CaribouKeyboardModelClass;

#define CARIBOU_TYPE_ISCANNABLE_GROUP (caribou_iscannable_group_get_type ())
#define CARIBOU_ISCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup))
#define CARIBOU_IS_ISCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP))
#define CARIBOU_ISCANNABLE_GROUP_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroupIface))

typedef struct _CaribouIScannableGroup CaribouIScannableGroup;
typedef struct _CaribouIScannableGroupIface CaribouIScannableGroupIface;

#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 _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_GROUP_MODEL (caribou_group_model_get_type ())
#define CARIBOU_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModel))
#define CARIBOU_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))
#define CARIBOU_IS_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_IS_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_GROUP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))

typedef struct _CaribouGroupModel CaribouGroupModel;
typedef struct _CaribouGroupModelClass CaribouGroupModelClass;

#define CARIBOU_TYPE_SCANNABLE_GROUP (caribou_scannable_group_get_type ())
#define CARIBOU_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup))
#define CARIBOU_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))
#define CARIBOU_IS_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_IS_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_SCANNABLE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))

typedef struct _CaribouScannableGroup CaribouScannableGroup;
typedef struct _CaribouScannableGroupClass CaribouScannableGroupClass;

#define CARIBOU_TYPE_LEVEL_MODEL (caribou_level_model_get_type ())
#define CARIBOU_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModel))
#define CARIBOU_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))
#define CARIBOU_IS_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_IS_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_LEVEL_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))

typedef struct _CaribouLevelModel CaribouLevelModel;
typedef struct _CaribouLevelModelClass CaribouLevelModelClass;

#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;
typedef struct _Block1Data Block1Data;
typedef struct _Block2Data Block2Data;

struct _CaribouScanner {
	GObject parent_instance;
	CaribouScannerPrivate * priv;
};

struct _CaribouScannerClass {
	GObjectClass parent_class;
};

typedef enum  {
	CARIBOU_SCAN_GROUPING_NONE,
	CARIBOU_SCAN_GROUPING_SUBGROUPS,
	CARIBOU_SCAN_GROUPING_ROWS,
	CARIBOU_SCAN_GROUPING_LINEAR
} CaribouScanGrouping;

typedef void (*CaribouScannerUnconfigureSwitchFunc) (void* user_data);
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 _CaribouIScannableGroupIface {
	GTypeInterface parent_iface;
	CaribouIScannableItem* (*child_select) (CaribouIScannableGroup* self);
	void (*scan_reset) (CaribouIScannableGroup* self);
	CaribouIScannableItem** (*get_scan_children) (CaribouIScannableGroup* self, int* result_length1);
	CaribouIScannableItem* (*child_step) (CaribouIScannableGroup* self, gint cycles);
	CaribouIScannableItem** (*get_step_path) (CaribouIScannableGroup* self, int* result_length1);
	CaribouIScannableItem** (*get_selected_path) (CaribouIScannableGroup* self, int* result_length1);
	CaribouScanGrouping (*get_scan_grouping) (CaribouIScannableGroup* self);
	void (*set_scan_grouping) (CaribouIScannableGroup* self, CaribouScanGrouping value);
};

struct _CaribouScannerPrivate {
	gboolean _bind_settings;
	CaribouScanGrouping _scan_grouping;
	gboolean _scan_enabled;
	gdouble _step_time;
	gchar* _switch_device;
	gchar* _keyboard_key;
	gint _mouse_button;
	gint _scan_cycles;
	gboolean _autorestart;
	gboolean _inverse_scanning;
	CaribouScannerUnconfigureSwitchFunc unconfigure_switch_func;
	gpointer unconfigure_switch_func_target;
	GDestroyNotify unconfigure_switch_func_target_destroy_notify;
	guint scan_tid;
	CaribouKeyboardModel* keyboard;
	CaribouIScannableGroup* root_group;
	gboolean started;
};

struct _Block1Data {
	int _ref_count_;
	CaribouScanner* self;
	CaribouDisplayAdapter* xadapter;
};

struct _Block2Data {
	int _ref_count_;
	Block1Data * _data1_;
	guint keyval;
};

typedef void (*CaribouKeyButtonCallback) (guint keybuttoncode, gboolean pressed, void* user_data);

static gpointer caribou_scanner_parent_class = NULL;

GType caribou_scanner_get_type (void) G_GNUC_CONST;
GType caribou_scan_grouping_get_type (void) G_GNUC_CONST;
GType caribou_keyboard_model_get_type (void) G_GNUC_CONST;
GType caribou_iscannable_item_get_type (void) G_GNUC_CONST;
GType caribou_iscannable_group_get_type (void) G_GNUC_CONST;
#define CARIBOU_SCANNER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_TYPE_SCANNER, CaribouScannerPrivate))
enum  {
	CARIBOU_SCANNER_DUMMY_PROPERTY,
	CARIBOU_SCANNER_BIND_SETTINGS,
	CARIBOU_SCANNER_SCAN_GROUPING,
	CARIBOU_SCANNER_SCAN_ENABLED,
	CARIBOU_SCANNER_STEP_TIME,
	CARIBOU_SCANNER_SWITCH_DEVICE,
	CARIBOU_SCANNER_KEYBOARD_KEY,
	CARIBOU_SCANNER_MOUSE_BUTTON,
	CARIBOU_SCANNER_SCAN_CYCLES,
	CARIBOU_SCANNER_AUTORESTART,
	CARIBOU_SCANNER_INVERSE_SCANNING
};
static void caribou_scanner_do_bind_settings (CaribouScanner* self);
static gboolean caribou_scanner_select (CaribouScanner* self);
CaribouIScannableItem* caribou_iscannable_group_child_select (CaribouIScannableGroup* self);
static CaribouIScannableItem* caribou_scanner_step (CaribouScanner* self);
void caribou_scanner_reset (CaribouScanner* self);
static void caribou_scanner_switch_pressed (CaribouScanner* self, guint code, gboolean pressed);
static void caribou_scanner_start (CaribouScanner* self);
static void caribou_scanner_stop (CaribouScanner* self);
gboolean caribou_scanner_get_inverse_scanning (CaribouScanner* self);
gboolean caribou_scanner_get_autorestart (CaribouScanner* self);
void caribou_scanner_set_keyboard (CaribouScanner* self, CaribouKeyboardModel* keyboard);
GType caribou_group_model_get_type (void) G_GNUC_CONST;
CaribouGroupModel* caribou_keyboard_model_get_group (CaribouKeyboardModel* self, const gchar* group_name);
const gchar* caribou_keyboard_model_get_active_group (CaribouKeyboardModel* self);
static void caribou_scanner_on_group_changed (CaribouScanner* self, GObject* obj, GParamSpec* prop);
static void _caribou_scanner_on_group_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
GType caribou_scannable_group_get_type (void) G_GNUC_CONST;
GType caribou_level_model_get_type (void) G_GNUC_CONST;
static void caribou_scanner_set_active_level (CaribouScanner* self, CaribouLevelModel* level);
CaribouLevelModel* caribou_group_model_get_level (CaribouGroupModel* self, const gchar* level_name);
const gchar* caribou_group_model_get_active_level (CaribouGroupModel* self);
gchar** caribou_keyboard_model_get_groups (CaribouKeyboardModel* self, int* result_length1);
static void caribou_scanner_on_level_changed (CaribouScanner* self, GObject* obj, GParamSpec* prop);
static void _caribou_scanner_on_level_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
void caribou_iscannable_group_set_scan_grouping (CaribouIScannableGroup* self, CaribouScanGrouping value);
void caribou_iscannable_group_scan_reset (CaribouIScannableGroup* self);
static void caribou_scanner_enable (CaribouScanner* self);
static void caribou_scanner_configure_switch (CaribouScanner* self);
static void caribou_scanner_disable (CaribouScanner* self);
static void caribou_scanner_unconfigure_switch (CaribouScanner* self);
static gboolean caribou_scanner_scan (CaribouScanner* self);
static gboolean _caribou_scanner_scan_gsource_func (gpointer self);
CaribouIScannableItem* caribou_iscannable_group_child_step (CaribouIScannableGroup* self, gint cycles);
gint caribou_scanner_get_scan_cycles (CaribouScanner* self);
GType caribou_display_adapter_get_type (void) G_GNUC_CONST;
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
gboolean caribou_scanner_get_scan_enabled (CaribouScanner* self);
CaribouDisplayAdapter* caribou_display_adapter_get_default (void);
const gchar* caribou_scanner_get_switch_device (CaribouScanner* self);
const gchar* caribou_scanner_get_keyboard_key (CaribouScanner* self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
void caribou_display_adapter_register_key_func (CaribouDisplayAdapter* self, guint keyval, CaribouKeyButtonCallback func, void* func_target);
static void _caribou_scanner_switch_pressed_caribou_key_button_callback (guint keybuttoncode, gboolean pressed, gpointer self);
static void ___lambda16_ (Block2Data* _data2_);
static void ____lambda16__caribou_scanner_unconfigure_switch_func (gpointer self);
gint caribou_scanner_get_mouse_button (CaribouScanner* self);
void caribou_display_adapter_register_button_func (CaribouDisplayAdapter* self, guint button, CaribouKeyButtonCallback func, void* func_target);
static void ____lambda17_ (Block1Data* _data1_);
static void _____lambda17__caribou_scanner_unconfigure_switch_func (gpointer self);
CaribouScanner* caribou_scanner_new (void);
CaribouScanner* caribou_scanner_construct (GType object_type);
gboolean caribou_scanner_get_bind_settings (CaribouScanner* self);
static void caribou_scanner_set_bind_settings (CaribouScanner* self, gboolean value);
gint caribou_scanner_get_scan_grouping (CaribouScanner* self);
void caribou_scanner_set_scan_grouping (CaribouScanner* self, gint value);
void caribou_scanner_set_scan_enabled (CaribouScanner* self, gboolean value);
gdouble caribou_scanner_get_step_time (CaribouScanner* self);
void caribou_scanner_set_step_time (CaribouScanner* self, gdouble value);
void caribou_scanner_set_switch_device (CaribouScanner* self, const gchar* value);
void caribou_scanner_set_keyboard_key (CaribouScanner* self, const gchar* value);
void caribou_scanner_set_mouse_button (CaribouScanner* self, gint value);
void caribou_scanner_set_scan_cycles (CaribouScanner* self, gint value);
void caribou_scanner_set_autorestart (CaribouScanner* self, gboolean value);
void caribou_scanner_set_inverse_scanning (CaribouScanner* self, gboolean value);
static GObject * caribou_scanner_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void caribou_scanner_finalize (GObject* obj);
static void _vala_caribou_scanner_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_caribou_scanner_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void caribou_scanner_do_bind_settings (CaribouScanner* self) {
	GSettings* caribou_settings = NULL;
	GSettings* _tmp0_ = NULL;
	gchar** settings = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar** _tmp10_ = NULL;
	gint settings_length1 = 0;
	gint _settings_size_ = 0;
	gchar** _tmp11_ = NULL;
	gint _tmp11__length1 = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_settings_new ("org.gnome.caribou");
	caribou_settings = _tmp0_;
	_tmp1_ = g_strdup ("scan-grouping");
	_tmp2_ = g_strdup ("step-time");
	_tmp3_ = g_strdup ("scan-cycles");
	_tmp4_ = g_strdup ("autorestart");
	_tmp5_ = g_strdup ("inverse-scanning");
	_tmp6_ = g_strdup ("switch-device");
	_tmp7_ = g_strdup ("keyboard-key");
	_tmp8_ = g_strdup ("mouse-button");
	_tmp9_ = g_strdup ("scan-enabled");
	_tmp10_ = g_new0 (gchar*, 9 + 1);
	_tmp10_[0] = _tmp1_;
	_tmp10_[1] = _tmp2_;
	_tmp10_[2] = _tmp3_;
	_tmp10_[3] = _tmp4_;
	_tmp10_[4] = _tmp5_;
	_tmp10_[5] = _tmp6_;
	_tmp10_[6] = _tmp7_;
	_tmp10_[7] = _tmp8_;
	_tmp10_[8] = _tmp9_;
	settings = _tmp10_;
	settings_length1 = 9;
	_settings_size_ = settings_length1;
	_tmp11_ = settings;
	_tmp11__length1 = settings_length1;
	{
		gchar** setting_collection = NULL;
		gint setting_collection_length1 = 0;
		gint _setting_collection_size_ = 0;
		gint setting_it = 0;
		setting_collection = _tmp11_;
		setting_collection_length1 = _tmp11__length1;
		for (setting_it = 0; setting_it < _tmp11__length1; setting_it = setting_it + 1) {
			gchar* _tmp12_ = NULL;
			gchar* setting = NULL;
			_tmp12_ = g_strdup (setting_collection[setting_it]);
			setting = _tmp12_;
			{
				GSettings* _tmp13_ = NULL;
				const gchar* _tmp14_ = NULL;
				const gchar* _tmp15_ = NULL;
				_tmp13_ = caribou_settings;
				_tmp14_ = setting;
				_tmp15_ = setting;
				g_settings_bind (_tmp13_, _tmp14_, (GObject*) self, _tmp15_, G_SETTINGS_BIND_GET);
				_g_free0 (setting);
			}
		}
	}
	settings = (_vala_array_free (settings, settings_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (caribou_settings);
}


static gboolean caribou_scanner_select (CaribouScanner* self) {
	gboolean result = FALSE;
	CaribouIScannableItem* item = NULL;
	CaribouIScannableGroup* _tmp0_ = NULL;
	CaribouIScannableItem* _tmp1_ = NULL;
	CaribouIScannableItem* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->root_group;
	_tmp1_ = caribou_iscannable_group_child_select (_tmp0_);
	item = _tmp1_;
	_tmp2_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, CARIBOU_TYPE_ISCANNABLE_GROUP)) {
		CaribouIScannableItem* _tmp3_ = NULL;
		CaribouIScannableItem* _tmp4_ = NULL;
		_tmp3_ = caribou_scanner_step (self);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp4_);
		result = TRUE;
		_g_object_unref0 (item);
		return result;
	} else {
		caribou_scanner_reset (self);
		result = FALSE;
		_g_object_unref0 (item);
		return result;
	}
	_g_object_unref0 (item);
}


static void caribou_scanner_switch_pressed (CaribouScanner* self, guint code, gboolean pressed) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = pressed;
	if (_tmp0_) {
		gboolean _tmp1_ = FALSE;
		gboolean _tmp4_ = FALSE;
		_tmp1_ = self->priv->started;
		if (!_tmp1_) {
			CaribouIScannableItem* _tmp2_ = NULL;
			CaribouIScannableItem* _tmp3_ = NULL;
			_tmp2_ = caribou_scanner_step (self);
			_tmp3_ = _tmp2_;
			_g_object_unref0 (_tmp3_);
			caribou_scanner_start (self);
			return;
		}
		caribou_scanner_stop (self);
		_tmp4_ = self->priv->_inverse_scanning;
		if (_tmp4_) {
			CaribouIScannableItem* _tmp5_ = NULL;
			CaribouIScannableItem* _tmp6_ = NULL;
			_tmp5_ = caribou_scanner_step (self);
			_tmp6_ = _tmp5_;
			_g_object_unref0 (_tmp6_);
			caribou_scanner_start (self);
		} else {
			gboolean _tmp7_ = FALSE;
			gboolean _tmp8_ = FALSE;
			_tmp8_ = caribou_scanner_select (self);
			if (_tmp8_) {
				_tmp7_ = TRUE;
			} else {
				gboolean _tmp9_ = FALSE;
				_tmp9_ = self->priv->_autorestart;
				_tmp7_ = _tmp9_;
			}
			if (_tmp7_) {
				caribou_scanner_start (self);
			}
		}
	}
}


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


static void _caribou_scanner_on_group_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	caribou_scanner_on_group_changed ((CaribouScanner*) self, _sender, pspec);
}


static void _caribou_scanner_on_level_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	caribou_scanner_on_level_changed ((CaribouScanner*) self, _sender, pspec);
}


void caribou_scanner_set_keyboard (CaribouScanner* self, CaribouKeyboardModel* keyboard) {
	CaribouGroupModel* group = NULL;
	CaribouKeyboardModel* _tmp0_ = NULL;
	CaribouKeyboardModel* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	CaribouGroupModel* _tmp4_ = NULL;
	CaribouKeyboardModel* _tmp5_ = NULL;
	CaribouKeyboardModel* _tmp6_ = NULL;
	CaribouKeyboardModel* _tmp7_ = NULL;
	CaribouGroupModel* _tmp8_ = NULL;
	CaribouGroupModel* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	CaribouLevelModel* _tmp12_ = NULL;
	CaribouLevelModel* _tmp13_ = NULL;
	CaribouKeyboardModel* _tmp14_ = NULL;
	gint _tmp15_ = 0;
	gchar** _tmp16_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (keyboard != NULL);
	_tmp0_ = keyboard;
	_tmp1_ = keyboard;
	_tmp2_ = caribou_keyboard_model_get_active_group (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = caribou_keyboard_model_get_group (_tmp0_, _tmp3_);
	group = _tmp4_;
	_tmp5_ = keyboard;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_g_object_unref0 (self->priv->keyboard);
	self->priv->keyboard = _tmp6_;
	_tmp7_ = self->priv->keyboard;
	g_signal_connect_object ((GObject*) _tmp7_, "notify::active-group", (GCallback) _caribou_scanner_on_group_changed_g_object_notify, self, 0);
	_tmp8_ = group;
	_tmp9_ = group;
	_tmp10_ = caribou_group_model_get_active_level (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = caribou_group_model_get_level (_tmp8_, _tmp11_);
	_tmp13_ = _tmp12_;
	caribou_scanner_set_active_level (self, _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = keyboard;
	_tmp16_ = caribou_keyboard_model_get_groups (_tmp14_, &_tmp15_);
	{
		gchar** group_name_collection = NULL;
		gint group_name_collection_length1 = 0;
		gint _group_name_collection_size_ = 0;
		gint group_name_it = 0;
		group_name_collection = _tmp16_;
		group_name_collection_length1 = _tmp15_;
		for (group_name_it = 0; group_name_it < _tmp15_; group_name_it = group_name_it + 1) {
			gchar* _tmp17_ = NULL;
			gchar* group_name = NULL;
			_tmp17_ = g_strdup (group_name_collection[group_name_it]);
			group_name = _tmp17_;
			{
				CaribouKeyboardModel* _tmp18_ = NULL;
				const gchar* _tmp19_ = NULL;
				CaribouGroupModel* _tmp20_ = NULL;
				CaribouGroupModel* _tmp21_ = NULL;
				_tmp18_ = keyboard;
				_tmp19_ = group_name;
				_tmp20_ = caribou_keyboard_model_get_group (_tmp18_, _tmp19_);
				_g_object_unref0 (group);
				group = _tmp20_;
				_tmp21_ = group;
				g_signal_connect_object ((GObject*) _tmp21_, "notify::active-level", (GCallback) _caribou_scanner_on_level_changed_g_object_notify, self, 0);
				_g_free0 (group_name);
			}
		}
		group_name_collection = (_vala_array_free (group_name_collection, group_name_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_g_object_unref0 (group);
}


static void caribou_scanner_on_level_changed (CaribouScanner* self, GObject* obj, GParamSpec* prop) {
	CaribouGroupModel* group = NULL;
	GObject* _tmp0_ = NULL;
	CaribouGroupModel* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	CaribouLevelModel* _tmp4_ = NULL;
	CaribouLevelModel* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (obj != NULL);
	g_return_if_fail (prop != NULL);
	_tmp0_ = obj;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModel));
	group = _tmp1_;
	_tmp2_ = caribou_group_model_get_active_level (group);
	_tmp3_ = _tmp2_;
	_tmp4_ = caribou_group_model_get_level (group, _tmp3_);
	_tmp5_ = _tmp4_;
	caribou_scanner_set_active_level (self, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (group);
}


static void caribou_scanner_on_group_changed (CaribouScanner* self, GObject* obj, GParamSpec* prop) {
	CaribouGroupModel* group = NULL;
	CaribouKeyboardModel* _tmp0_ = NULL;
	CaribouKeyboardModel* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	CaribouGroupModel* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	CaribouLevelModel* _tmp7_ = NULL;
	CaribouLevelModel* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (obj != NULL);
	g_return_if_fail (prop != NULL);
	_tmp0_ = self->priv->keyboard;
	_tmp1_ = self->priv->keyboard;
	_tmp2_ = caribou_keyboard_model_get_active_group (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = caribou_keyboard_model_get_group (_tmp0_, _tmp3_);
	group = _tmp4_;
	_tmp5_ = caribou_group_model_get_active_level (group);
	_tmp6_ = _tmp5_;
	_tmp7_ = caribou_group_model_get_level (group, _tmp6_);
	_tmp8_ = _tmp7_;
	caribou_scanner_set_active_level (self, _tmp8_);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (group);
}


static void caribou_scanner_set_active_level (CaribouScanner* self, CaribouLevelModel* level) {
	CaribouLevelModel* _tmp0_ = NULL;
	CaribouIScannableGroup* _tmp1_ = NULL;
	CaribouIScannableGroup* _tmp2_ = NULL;
	CaribouScanGrouping _tmp3_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (level != NULL);
	_tmp0_ = level;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup));
	_g_object_unref0 (self->priv->root_group);
	self->priv->root_group = _tmp1_;
	_tmp2_ = self->priv->root_group;
	_tmp3_ = self->priv->_scan_grouping;
	caribou_iscannable_group_set_scan_grouping (_tmp2_, _tmp3_);
}


void caribou_scanner_reset (CaribouScanner* self) {
	CaribouIScannableGroup* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->root_group;
	if (_tmp0_ != NULL) {
		CaribouIScannableGroup* _tmp1_ = NULL;
		_tmp1_ = self->priv->root_group;
		caribou_iscannable_group_scan_reset (_tmp1_);
	}
}


static void caribou_scanner_enable (CaribouScanner* self) {
	g_return_if_fail (self != NULL);
	caribou_scanner_configure_switch (self);
}


static void caribou_scanner_disable (CaribouScanner* self) {
	g_return_if_fail (self != NULL);
	caribou_scanner_unconfigure_switch (self);
}


static gboolean _caribou_scanner_scan_gsource_func (gpointer self) {
	gboolean result;
	result = caribou_scanner_scan ((CaribouScanner*) self);
	return result;
}


static void caribou_scanner_start (CaribouScanner* self) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gdouble _tmp3_ = 0.0;
	guint _tmp4_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->started;
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		CaribouIScannableGroup* _tmp2_ = NULL;
		_tmp2_ = self->priv->root_group;
		_tmp0_ = _tmp2_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	self->priv->started = TRUE;
	_tmp3_ = self->priv->_step_time;
	_tmp4_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) ((gint) (_tmp3_ * 1000)), _caribou_scanner_scan_gsource_func, g_object_ref (self), g_object_unref);
	self->priv->scan_tid = _tmp4_;
}


static void caribou_scanner_stop (CaribouScanner* self) {
	gboolean _tmp0_ = FALSE;
	guint _tmp1_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->started;
	if (!_tmp0_) {
		return;
	}
	self->priv->started = FALSE;
	_tmp1_ = self->priv->scan_tid;
	if (_tmp1_ != ((guint) 0)) {
		guint _tmp2_ = 0U;
		_tmp2_ = self->priv->scan_tid;
		g_source_remove (_tmp2_);
	}
	self->priv->scan_tid = (guint) 0;
}


static CaribouIScannableItem* caribou_scanner_step (CaribouScanner* self) {
	CaribouIScannableItem* result = NULL;
	CaribouIScannableItem* item = NULL;
	CaribouIScannableGroup* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	CaribouIScannableItem* _tmp2_ = NULL;
	CaribouIScannableItem* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->root_group;
	_tmp1_ = self->priv->_scan_cycles;
	_tmp2_ = caribou_iscannable_group_child_step (_tmp0_, _tmp1_);
	item = _tmp2_;
	_tmp3_ = item;
	if (_tmp3_ == NULL) {
		caribou_scanner_reset (self);
	}
	result = item;
	return result;
}


static gboolean caribou_scanner_scan (CaribouScanner* self) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_inverse_scanning;
	if (_tmp0_) {
		caribou_scanner_select (self);
	} else {
		CaribouIScannableItem* _tmp1_ = NULL;
		CaribouIScannableItem* _tmp2_ = NULL;
		gboolean _tmp3_ = FALSE;
		_tmp1_ = caribou_scanner_step (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_ != NULL;
		_g_object_unref0 (_tmp2_);
		result = _tmp3_;
		return result;
	}
	result = TRUE;
	return result;
}


static void caribou_scanner_unconfigure_switch (CaribouScanner* self) {
	CaribouScannerUnconfigureSwitchFunc _tmp0_ = NULL;
	void* _tmp0__target = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->unconfigure_switch_func;
	_tmp0__target = self->priv->unconfigure_switch_func_target;
	if (_tmp0_ != NULL) {
		CaribouScannerUnconfigureSwitchFunc _tmp1_ = NULL;
		void* _tmp1__target = NULL;
		_tmp1_ = self->priv->unconfigure_switch_func;
		_tmp1__target = self->priv->unconfigure_switch_func_target;
		_tmp1_ (_tmp1__target);
	}
	(self->priv->unconfigure_switch_func_target_destroy_notify == NULL) ? NULL : (self->priv->unconfigure_switch_func_target_destroy_notify (self->priv->unconfigure_switch_func_target), NULL);
	self->priv->unconfigure_switch_func = NULL;
	self->priv->unconfigure_switch_func_target = NULL;
	self->priv->unconfigure_switch_func_target_destroy_notify = NULL;
	self->priv->unconfigure_switch_func = NULL;
	self->priv->unconfigure_switch_func_target = NULL;
	self->priv->unconfigure_switch_func_target_destroy_notify = NULL;
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (void * _userdata_) {
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		CaribouScanner* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->xadapter);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		CaribouScanner* self;
		self = _data2_->_data1_->self;
		block1_data_unref (_data2_->_data1_);
		_data2_->_data1_ = NULL;
		g_slice_free (Block2Data, _data2_);
	}
}


static void _caribou_scanner_switch_pressed_caribou_key_button_callback (guint keybuttoncode, gboolean pressed, gpointer self) {
	caribou_scanner_switch_pressed ((CaribouScanner*) self, keybuttoncode, pressed);
}


static void ___lambda16_ (Block2Data* _data2_) {
	Block1Data* _data1_;
	CaribouScanner* self;
	CaribouDisplayAdapter* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	_data1_ = _data2_->_data1_;
	self = _data1_->self;
	_tmp0_ = _data1_->xadapter;
	_tmp1_ = _data2_->keyval;
	caribou_display_adapter_register_key_func (_tmp0_, _tmp1_, NULL, NULL);
}


static void ____lambda16__caribou_scanner_unconfigure_switch_func (gpointer self) {
	___lambda16_ (self);
}


static void ____lambda17_ (Block1Data* _data1_) {
	CaribouScanner* self;
	CaribouDisplayAdapter* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	self = _data1_->self;
	_tmp0_ = _data1_->xadapter;
	_tmp1_ = caribou_scanner_get_mouse_button (self);
	_tmp2_ = _tmp1_;
	caribou_display_adapter_register_key_func (_tmp0_, (guint) _tmp2_, NULL, NULL);
}


static void _____lambda17__caribou_scanner_unconfigure_switch_func (gpointer self) {
	____lambda17_ (self);
}


static void caribou_scanner_configure_switch (CaribouScanner* self) {
	Block1Data* _data1_;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	CaribouDisplayAdapter* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = caribou_scanner_get_scan_enabled (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		block1_data_unref (_data1_);
		_data1_ = NULL;
		return;
	}
	caribou_scanner_unconfigure_switch (self);
	_tmp2_ = caribou_display_adapter_get_default ();
	_data1_->xadapter = _tmp2_;
	_tmp4_ = caribou_scanner_get_switch_device (self);
	_tmp5_ = _tmp4_;
	if (g_strcmp0 (_tmp5_, "keyboard") == 0) {
		const gchar* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		_tmp6_ = caribou_scanner_get_keyboard_key (self);
		_tmp7_ = _tmp6_;
		_tmp3_ = _tmp7_ != NULL;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		Block2Data* _data2_;
		const gchar* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		guint _tmp10_ = 0U;
		CaribouDisplayAdapter* _tmp11_ = NULL;
		guint _tmp12_ = 0U;
		_data2_ = g_slice_new0 (Block2Data);
		_data2_->_ref_count_ = 1;
		_data2_->_data1_ = block1_data_ref (_data1_);
		_tmp8_ = caribou_scanner_get_keyboard_key (self);
		_tmp9_ = _tmp8_;
		_tmp10_ = gdk_keyval_from_name (_tmp9_);
		_data2_->keyval = _tmp10_;
		_tmp11_ = _data1_->xadapter;
		_tmp12_ = _data2_->keyval;
		caribou_display_adapter_register_key_func (_tmp11_, _tmp12_, _caribou_scanner_switch_pressed_caribou_key_button_callback, self);
		(self->priv->unconfigure_switch_func_target_destroy_notify == NULL) ? NULL : (self->priv->unconfigure_switch_func_target_destroy_notify (self->priv->unconfigure_switch_func_target), NULL);
		self->priv->unconfigure_switch_func = NULL;
		self->priv->unconfigure_switch_func_target = NULL;
		self->priv->unconfigure_switch_func_target_destroy_notify = NULL;
		self->priv->unconfigure_switch_func = ____lambda16__caribou_scanner_unconfigure_switch_func;
		self->priv->unconfigure_switch_func_target = block2_data_ref (_data2_);
		self->priv->unconfigure_switch_func_target_destroy_notify = block2_data_unref;
		block2_data_unref (_data2_);
		_data2_ = NULL;
	} else {
		gboolean _tmp13_ = FALSE;
		const gchar* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		_tmp14_ = caribou_scanner_get_switch_device (self);
		_tmp15_ = _tmp14_;
		if (g_strcmp0 (_tmp15_, "mouse") == 0) {
			gint _tmp16_ = 0;
			gint _tmp17_ = 0;
			_tmp16_ = caribou_scanner_get_mouse_button (self);
			_tmp17_ = _tmp16_;
			_tmp13_ = _tmp17_ != 0;
		} else {
			_tmp13_ = FALSE;
		}
		if (_tmp13_) {
			CaribouDisplayAdapter* _tmp18_ = NULL;
			gint _tmp19_ = 0;
			gint _tmp20_ = 0;
			_tmp18_ = _data1_->xadapter;
			_tmp19_ = caribou_scanner_get_mouse_button (self);
			_tmp20_ = _tmp19_;
			caribou_display_adapter_register_button_func (_tmp18_, (guint) _tmp20_, _caribou_scanner_switch_pressed_caribou_key_button_callback, self);
			(self->priv->unconfigure_switch_func_target_destroy_notify == NULL) ? NULL : (self->priv->unconfigure_switch_func_target_destroy_notify (self->priv->unconfigure_switch_func_target), NULL);
			self->priv->unconfigure_switch_func = NULL;
			self->priv->unconfigure_switch_func_target = NULL;
			self->priv->unconfigure_switch_func_target_destroy_notify = NULL;
			self->priv->unconfigure_switch_func = _____lambda17__caribou_scanner_unconfigure_switch_func;
			self->priv->unconfigure_switch_func_target = block1_data_ref (_data1_);
			self->priv->unconfigure_switch_func_target_destroy_notify = block1_data_unref;
		}
	}
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


CaribouScanner* caribou_scanner_construct (GType object_type) {
	CaribouScanner * self = NULL;
	self = (CaribouScanner*) g_object_new (object_type, NULL);
	return self;
}


CaribouScanner* caribou_scanner_new (void) {
	return caribou_scanner_construct (CARIBOU_TYPE_SCANNER);
}


gboolean caribou_scanner_get_bind_settings (CaribouScanner* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_bind_settings;
	result = _tmp0_;
	return result;
}


static void caribou_scanner_set_bind_settings (CaribouScanner* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_bind_settings = _tmp0_;
	g_object_notify ((GObject *) self, "bind-settings");
}


gint caribou_scanner_get_scan_grouping (CaribouScanner* self) {
	gint result;
	CaribouScanGrouping _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_scan_grouping;
	result = (gint) _tmp0_;
	return result;
}


void caribou_scanner_set_scan_grouping (CaribouScanner* self, gint value) {
	gint _tmp0_ = 0;
	CaribouIScannableGroup* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_scan_grouping = (CaribouScanGrouping) _tmp0_;
	_tmp1_ = self->priv->root_group;
	if (_tmp1_ != NULL) {
		CaribouIScannableGroup* _tmp2_ = NULL;
		CaribouScanGrouping _tmp3_ = 0;
		_tmp2_ = self->priv->root_group;
		_tmp3_ = self->priv->_scan_grouping;
		caribou_iscannable_group_set_scan_grouping (_tmp2_, _tmp3_);
	}
	caribou_scanner_reset (self);
	g_object_notify ((GObject *) self, "scan-grouping");
}


gboolean caribou_scanner_get_scan_enabled (CaribouScanner* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_scan_enabled;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_scan_enabled (CaribouScanner* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_scan_enabled = _tmp0_;
	_tmp1_ = self->priv->_scan_enabled;
	if (_tmp1_) {
		caribou_scanner_enable (self);
	} else {
		caribou_scanner_disable (self);
	}
	g_object_notify ((GObject *) self, "scan-enabled");
}


gdouble caribou_scanner_get_step_time (CaribouScanner* self) {
	gdouble result;
	gdouble _tmp0_ = 0.0;
	g_return_val_if_fail (self != NULL, 0.0);
	_tmp0_ = self->priv->_step_time;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_step_time (CaribouScanner* self, gdouble value) {
	gdouble _tmp0_ = 0.0;
	guint _tmp1_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_step_time = _tmp0_;
	_tmp1_ = self->priv->scan_tid;
	if (_tmp1_ != ((guint) 0)) {
		guint _tmp2_ = 0U;
		gdouble _tmp3_ = 0.0;
		guint _tmp4_ = 0U;
		_tmp2_ = self->priv->scan_tid;
		g_source_remove (_tmp2_);
		_tmp3_ = self->priv->_step_time;
		_tmp4_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) ((gint) (_tmp3_ * 1000)), _caribou_scanner_scan_gsource_func, g_object_ref (self), g_object_unref);
		self->priv->scan_tid = _tmp4_;
	}
	g_object_notify ((GObject *) self, "step-time");
}


const gchar* caribou_scanner_get_switch_device (CaribouScanner* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_switch_device;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_switch_device (CaribouScanner* 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->_switch_device);
	self->priv->_switch_device = _tmp1_;
	caribou_scanner_configure_switch (self);
	g_object_notify ((GObject *) self, "switch-device");
}


const gchar* caribou_scanner_get_keyboard_key (CaribouScanner* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_keyboard_key;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_keyboard_key (CaribouScanner* 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->_keyboard_key);
	self->priv->_keyboard_key = _tmp1_;
	caribou_scanner_configure_switch (self);
	g_object_notify ((GObject *) self, "keyboard-key");
}


gint caribou_scanner_get_mouse_button (CaribouScanner* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_mouse_button;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_mouse_button (CaribouScanner* self, gint value) {
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_mouse_button = _tmp0_;
	caribou_scanner_configure_switch (self);
	g_object_notify ((GObject *) self, "mouse-button");
}


gint caribou_scanner_get_scan_cycles (CaribouScanner* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_scan_cycles;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_scan_cycles (CaribouScanner* self, gint value) {
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_scan_cycles = _tmp0_;
	g_object_notify ((GObject *) self, "scan-cycles");
}


gboolean caribou_scanner_get_autorestart (CaribouScanner* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_autorestart;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_autorestart (CaribouScanner* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_autorestart = _tmp0_;
	g_object_notify ((GObject *) self, "autorestart");
}


gboolean caribou_scanner_get_inverse_scanning (CaribouScanner* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_inverse_scanning;
	result = _tmp0_;
	return result;
}


void caribou_scanner_set_inverse_scanning (CaribouScanner* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_inverse_scanning = _tmp0_;
	g_object_notify ((GObject *) self, "inverse-scanning");
}


static GObject * caribou_scanner_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	CaribouScanner * self;
	gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	parent_class = G_OBJECT_CLASS (caribou_scanner_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CARIBOU_TYPE_SCANNER, CaribouScanner);
	self->priv->_scan_grouping = CARIBOU_SCAN_GROUPING_SUBGROUPS;
	self->priv->_step_time = 1.0;
	_tmp0_ = g_strdup ("keyboard");
	_g_free0 (self->priv->_switch_device);
	self->priv->_switch_device = _tmp0_;
	_tmp1_ = self->priv->_bind_settings;
	if (_tmp1_) {
		caribou_scanner_do_bind_settings (self);
	}
	return obj;
}


static void caribou_scanner_class_init (CaribouScannerClass * klass) {
	caribou_scanner_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (CaribouScannerPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_caribou_scanner_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_caribou_scanner_set_property;
	G_OBJECT_CLASS (klass)->constructor = caribou_scanner_constructor;
	G_OBJECT_CLASS (klass)->finalize = caribou_scanner_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_BIND_SETTINGS, g_param_spec_boolean ("bind-settings", "bind-settings", "bind-settings", TRUE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_SCAN_GROUPING, g_param_spec_int ("scan-grouping", "scan-grouping", "scan-grouping", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_SCAN_ENABLED, g_param_spec_boolean ("scan-enabled", "scan-enabled", "scan-enabled", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_STEP_TIME, g_param_spec_double ("step-time", "step-time", "step-time", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_SWITCH_DEVICE, g_param_spec_string ("switch-device", "switch-device", "switch-device", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_KEYBOARD_KEY, g_param_spec_string ("keyboard-key", "keyboard-key", "keyboard-key", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_MOUSE_BUTTON, g_param_spec_int ("mouse-button", "mouse-button", "mouse-button", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_SCAN_CYCLES, g_param_spec_int ("scan-cycles", "scan-cycles", "scan-cycles", G_MININT, G_MAXINT, 1, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_AUTORESTART, g_param_spec_boolean ("autorestart", "autorestart", "autorestart", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNER_INVERSE_SCANNING, g_param_spec_boolean ("inverse-scanning", "inverse-scanning", "inverse-scanning", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void caribou_scanner_instance_init (CaribouScanner * self) {
	self->priv = CARIBOU_SCANNER_GET_PRIVATE (self);
	self->priv->_bind_settings = TRUE;
	self->priv->_scan_cycles = 1;
	self->priv->_autorestart = FALSE;
	self->priv->_inverse_scanning = FALSE;
}


static void caribou_scanner_finalize (GObject* obj) {
	CaribouScanner * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CARIBOU_TYPE_SCANNER, CaribouScanner);
	_g_free0 (self->priv->_switch_device);
	_g_free0 (self->priv->_keyboard_key);
	(self->priv->unconfigure_switch_func_target_destroy_notify == NULL) ? NULL : (self->priv->unconfigure_switch_func_target_destroy_notify (self->priv->unconfigure_switch_func_target), NULL);
	self->priv->unconfigure_switch_func = NULL;
	self->priv->unconfigure_switch_func_target = NULL;
	self->priv->unconfigure_switch_func_target_destroy_notify = NULL;
	_g_object_unref0 (self->priv->keyboard);
	_g_object_unref0 (self->priv->root_group);
	G_OBJECT_CLASS (caribou_scanner_parent_class)->finalize (obj);
}


/**
     * Object providing access to keyboard in scanning mode.
     */
GType caribou_scanner_get_type (void) {
	static volatile gsize caribou_scanner_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_scanner_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (CaribouScannerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_scanner_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouScanner), 0, (GInstanceInitFunc) caribou_scanner_instance_init, NULL };
		GType caribou_scanner_type_id;
		caribou_scanner_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouScanner", &g_define_type_info, 0);
		g_once_init_leave (&caribou_scanner_type_id__volatile, caribou_scanner_type_id);
	}
	return caribou_scanner_type_id__volatile;
}


static void _vala_caribou_scanner_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	CaribouScanner * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_SCANNER, CaribouScanner);
	switch (property_id) {
		case CARIBOU_SCANNER_BIND_SETTINGS:
		g_value_set_boolean (value, caribou_scanner_get_bind_settings (self));
		break;
		case CARIBOU_SCANNER_SCAN_GROUPING:
		g_value_set_int (value, caribou_scanner_get_scan_grouping (self));
		break;
		case CARIBOU_SCANNER_SCAN_ENABLED:
		g_value_set_boolean (value, caribou_scanner_get_scan_enabled (self));
		break;
		case CARIBOU_SCANNER_STEP_TIME:
		g_value_set_double (value, caribou_scanner_get_step_time (self));
		break;
		case CARIBOU_SCANNER_SWITCH_DEVICE:
		g_value_set_string (value, caribou_scanner_get_switch_device (self));
		break;
		case CARIBOU_SCANNER_KEYBOARD_KEY:
		g_value_set_string (value, caribou_scanner_get_keyboard_key (self));
		break;
		case CARIBOU_SCANNER_MOUSE_BUTTON:
		g_value_set_int (value, caribou_scanner_get_mouse_button (self));
		break;
		case CARIBOU_SCANNER_SCAN_CYCLES:
		g_value_set_int (value, caribou_scanner_get_scan_cycles (self));
		break;
		case CARIBOU_SCANNER_AUTORESTART:
		g_value_set_boolean (value, caribou_scanner_get_autorestart (self));
		break;
		case CARIBOU_SCANNER_INVERSE_SCANNING:
		g_value_set_boolean (value, caribou_scanner_get_inverse_scanning (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_caribou_scanner_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	CaribouScanner * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_SCANNER, CaribouScanner);
	switch (property_id) {
		case CARIBOU_SCANNER_BIND_SETTINGS:
		caribou_scanner_set_bind_settings (self, g_value_get_boolean (value));
		break;
		case CARIBOU_SCANNER_SCAN_GROUPING:
		caribou_scanner_set_scan_grouping (self, g_value_get_int (value));
		break;
		case CARIBOU_SCANNER_SCAN_ENABLED:
		caribou_scanner_set_scan_enabled (self, g_value_get_boolean (value));
		break;
		case CARIBOU_SCANNER_STEP_TIME:
		caribou_scanner_set_step_time (self, g_value_get_double (value));
		break;
		case CARIBOU_SCANNER_SWITCH_DEVICE:
		caribou_scanner_set_switch_device (self, g_value_get_string (value));
		break;
		case CARIBOU_SCANNER_KEYBOARD_KEY:
		caribou_scanner_set_keyboard_key (self, g_value_get_string (value));
		break;
		case CARIBOU_SCANNER_MOUSE_BUTTON:
		caribou_scanner_set_mouse_button (self, g_value_get_int (value));
		break;
		case CARIBOU_SCANNER_SCAN_CYCLES:
		caribou_scanner_set_scan_cycles (self, g_value_get_int (value));
		break;
		case CARIBOU_SCANNER_AUTORESTART:
		caribou_scanner_set_autorestart (self, g_value_get_boolean (value));
		break;
		case CARIBOU_SCANNER_INVERSE_SCANNING:
		caribou_scanner_set_inverse_scanning (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



