/* gamepad-configurer.c generated by valac 0.36.6.6-c7bee, the Vala compiler
 * generated from gamepad-configurer.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <libmanette.h>
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>


#define GAMES_TYPE_GAMEPAD_CONFIGURER (games_gamepad_configurer_get_type ())
#define GAMES_GAMEPAD_CONFIGURER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurer))
#define GAMES_GAMEPAD_CONFIGURER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurerClass))
#define GAMES_IS_GAMEPAD_CONFIGURER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_CONFIGURER))
#define GAMES_IS_GAMEPAD_CONFIGURER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_CONFIGURER))
#define GAMES_GAMEPAD_CONFIGURER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurerClass))

typedef struct _GamesGamepadConfigurer GamesGamepadConfigurer;
typedef struct _GamesGamepadConfigurerClass GamesGamepadConfigurerClass;
typedef struct _GamesGamepadConfigurerPrivate GamesGamepadConfigurerPrivate;

#define GAMES_GAMEPAD_CONFIGURER_TYPE_STATE (games_gamepad_configurer_state_get_type ())

#define GAMES_TYPE_GAMEPAD_MAPPER (games_gamepad_mapper_get_type ())
#define GAMES_GAMEPAD_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapper))
#define GAMES_GAMEPAD_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapperClass))
#define GAMES_IS_GAMEPAD_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_MAPPER))
#define GAMES_IS_GAMEPAD_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_MAPPER))
#define GAMES_GAMEPAD_MAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapperClass))

typedef struct _GamesGamepadMapper GamesGamepadMapper;
typedef struct _GamesGamepadMapperClass GamesGamepadMapperClass;

#define GAMES_TYPE_GAMEPAD_TESTER (games_gamepad_tester_get_type ())
#define GAMES_GAMEPAD_TESTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTester))
#define GAMES_GAMEPAD_TESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTesterClass))
#define GAMES_IS_GAMEPAD_TESTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_TESTER))
#define GAMES_IS_GAMEPAD_TESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_TESTER))
#define GAMES_GAMEPAD_TESTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTesterClass))

typedef struct _GamesGamepadTester GamesGamepadTester;
typedef struct _GamesGamepadTesterClass GamesGamepadTesterClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_GAMEPAD_INPUT (games_gamepad_input_get_type ())
typedef struct _GamesGamepadInput GamesGamepadInput;

#define GAMES_TYPE_GAMEPAD_INPUT_PATH (games_gamepad_input_path_get_type ())
typedef struct _GamesGamepadInputPath GamesGamepadInputPath;

#define GAMES_TYPE_GAMEPAD_VIEW_CONFIGURATION (games_gamepad_view_configuration_get_type ())
typedef struct _GamesGamepadViewConfiguration GamesGamepadViewConfiguration;

#define GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG (games_reset_gamepad_mapping_dialog_get_type ())
#define GAMES_RESET_GAMEPAD_MAPPING_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG, GamesResetGamepadMappingDialog))
#define GAMES_RESET_GAMEPAD_MAPPING_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG, GamesResetGamepadMappingDialogClass))
#define GAMES_IS_RESET_GAMEPAD_MAPPING_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG))
#define GAMES_IS_RESET_GAMEPAD_MAPPING_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG))
#define GAMES_RESET_GAMEPAD_MAPPING_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_RESET_GAMEPAD_MAPPING_DIALOG, GamesResetGamepadMappingDialogClass))

typedef struct _GamesResetGamepadMappingDialog GamesResetGamepadMappingDialog;
typedef struct _GamesResetGamepadMappingDialogClass GamesResetGamepadMappingDialogClass;
typedef struct _Block9Data Block9Data;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	GAMES_GAMEPAD_CONFIGURER_BACK_SIGNAL,
	GAMES_GAMEPAD_CONFIGURER_NUM_SIGNALS
};
static guint games_gamepad_configurer_signals[GAMES_GAMEPAD_CONFIGURER_NUM_SIGNALS] = {0};

struct _GamesGamepadConfigurer {
	GtkBox parent_instance;
	GamesGamepadConfigurerPrivate * priv;
};

struct _GamesGamepadConfigurerClass {
	GtkBoxClass parent_class;
};

typedef enum  {
	GAMES_GAMEPAD_CONFIGURER_STATE_TEST,
	GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE
} GamesGamepadConfigurerState;

struct _GamesGamepadConfigurerPrivate {
	GamesGamepadConfigurerState _state;
	GtkHeaderBar* _header_bar;
	gboolean _immersive_mode;
	GtkStack* stack;
	GtkBox* gamepad_mapper_holder;
	GtkBox* gamepad_tester_holder;
	GtkActionBar* action_bar;
	GtkButton* reset_button;
	GtkButton* back_button;
	GtkButton* cancel_button;
	ManetteDevice* device;
	GamesGamepadMapper* mapper;
	GamesGamepadTester* tester;
};

struct _GamesGamepadInput {
	guint16 type;
	guint16 code;
};

struct _GamesGamepadInputPath {
	GamesGamepadInput input;
	gchar* path;
};

struct _GamesGamepadViewConfiguration {
	gchar* svg_path;
	GamesGamepadInputPath* input_paths;
	gint input_paths_length1;
	gint _input_paths_size_;
};

struct _Block9Data {
	int _ref_count_;
	GamesGamepadConfigurer* self;
	GamesResetGamepadMappingDialog* message_dialog;
};


static gpointer games_gamepad_configurer_parent_class = NULL;

GType games_gamepad_configurer_get_type (void) G_GNUC_CONST;
static GType games_gamepad_configurer_state_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
GType games_gamepad_mapper_get_type (void) G_GNUC_CONST;
GType games_gamepad_tester_get_type (void) G_GNUC_CONST;
#define GAMES_GAMEPAD_CONFIGURER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurerPrivate))
enum  {
	GAMES_GAMEPAD_CONFIGURER_0_PROPERTY,
	GAMES_GAMEPAD_CONFIGURER_HEADER_BAR_PROPERTY,
	GAMES_GAMEPAD_CONFIGURER_IMMERSIVE_MODE_PROPERTY
};
GType games_gamepad_input_get_type (void) G_GNUC_CONST;
GamesGamepadInput* games_gamepad_input_dup (const GamesGamepadInput* self);
void games_gamepad_input_free (GamesGamepadInput* self);
GType games_gamepad_input_path_get_type (void) G_GNUC_CONST;
GamesGamepadInputPath* games_gamepad_input_path_dup (const GamesGamepadInputPath* self);
void games_gamepad_input_path_free (GamesGamepadInputPath* self);
void games_gamepad_input_path_copy (const GamesGamepadInputPath* self, GamesGamepadInputPath* dest);
void games_gamepad_input_path_destroy (GamesGamepadInputPath* self);
GType games_gamepad_view_configuration_get_type (void) G_GNUC_CONST;
GamesGamepadViewConfiguration* games_gamepad_view_configuration_dup (const GamesGamepadViewConfiguration* self);
void games_gamepad_view_configuration_free (GamesGamepadViewConfiguration* self);
void games_gamepad_view_configuration_copy (const GamesGamepadViewConfiguration* self, GamesGamepadViewConfiguration* dest);
void games_gamepad_view_configuration_destroy (GamesGamepadViewConfiguration* self);
GamesGamepadConfigurer* games_gamepad_configurer_new (ManetteDevice* device);
GamesGamepadConfigurer* games_gamepad_configurer_construct (GType object_type, ManetteDevice* device);
GamesGamepadMapper* games_gamepad_mapper_new (ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1);
GamesGamepadMapper* games_gamepad_mapper_construct (GType object_type, ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1);
GamesGamepadTester* games_gamepad_tester_new (ManetteDevice* device, GamesGamepadViewConfiguration* configuration);
GamesGamepadTester* games_gamepad_tester_construct (GType object_type, ManetteDevice* device, GamesGamepadViewConfiguration* configuration);
static void games_gamepad_configurer_set_state (GamesGamepadConfigurer* self, GamesGamepadConfigurerState value);
static void games_gamepad_configurer_on_reset_clicked (GamesGamepadConfigurer* self);
static void games_gamepad_configurer_reset_mapping (GamesGamepadConfigurer* self);
static void _games_gamepad_configurer_on_reset_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void games_gamepad_configurer_on_configure_clicked (GamesGamepadConfigurer* self);
static void _games_gamepad_configurer_on_configure_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void games_gamepad_configurer_on_back_clicked (GamesGamepadConfigurer* self);
static void _games_gamepad_configurer_on_back_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void games_gamepad_configurer_on_cancel_clicked (GamesGamepadConfigurer* self);
static void _games_gamepad_configurer_on_cancel_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
GType games_reset_gamepad_mapping_dialog_get_type (void) G_GNUC_CONST;
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
GamesResetGamepadMappingDialog* games_reset_gamepad_mapping_dialog_new (void);
GamesResetGamepadMappingDialog* games_reset_gamepad_mapping_dialog_construct (GType object_type);
static void __lambda23_ (Block9Data* _data9_, gint response);
static void ___lambda23__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
static void games_gamepad_configurer_on_mapper_finished (GamesGamepadConfigurer* self, const gchar* sdl_string);
static GamesGamepadConfigurerState games_gamepad_configurer_get_state (GamesGamepadConfigurer* self);
static void games_gamepad_configurer_set_immersive_mode (GamesGamepadConfigurer* self, gboolean value);
GtkHeaderBar* games_gamepad_configurer_get_header_bar (GamesGamepadConfigurer* self);
void games_gamepad_tester_start (GamesGamepadTester* self);
void games_gamepad_mapper_stop (GamesGamepadMapper* self);
static void _games_gamepad_configurer_on_mapper_finished_games_gamepad_mapper_finished (GamesGamepadMapper* _sender, const gchar* sdl_string, gpointer self);
void games_gamepad_tester_stop (GamesGamepadTester* self);
void games_gamepad_mapper_start (GamesGamepadMapper* self);
static void games_gamepad_configurer_set_header_bar (GamesGamepadConfigurer* self, GtkHeaderBar* value);
gboolean games_gamepad_configurer_get_immersive_mode (GamesGamepadConfigurer* self);
static void games_gamepad_configurer_finalize (GObject * obj);
static void _vala_games_gamepad_configurer_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_games_gamepad_configurer_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);

static const GamesGamepadInput GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUTS[21] = {{EV_KEY, BTN_A}, {EV_KEY, BTN_B}, {EV_KEY, BTN_X}, {EV_KEY, BTN_Y}, {EV_KEY, BTN_START}, {EV_KEY, BTN_MODE}, {EV_KEY, BTN_SELECT}, {EV_KEY, BTN_THUMBL}, {EV_KEY, BTN_THUMBR}, {EV_KEY, BTN_TL}, {EV_KEY, BTN_TR}, {EV_KEY, BTN_DPAD_UP}, {EV_KEY, BTN_DPAD_LEFT}, {EV_KEY, BTN_DPAD_DOWN}, {EV_KEY, BTN_DPAD_RIGHT}, {EV_ABS, ABS_X}, {EV_ABS, ABS_Y}, {EV_ABS, ABS_RX}, {EV_ABS, ABS_RY}, {EV_KEY, BTN_TL2}, {EV_KEY, BTN_TR2}};
static const GamesGamepadInputPath GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUT_PATHS[21] = {{{EV_ABS, ABS_X}, "leftx"}, {{EV_ABS, ABS_Y}, "lefty"}, {{EV_ABS, ABS_RX}, "rightx"}, {{EV_ABS, ABS_RY}, "righty"}, {{EV_KEY, BTN_A}, "a"}, {{EV_KEY, BTN_B}, "b"}, {{EV_KEY, BTN_DPAD_DOWN}, "dpdown"}, {{EV_KEY, BTN_DPAD_LEFT}, "dpleft"}, {{EV_KEY, BTN_DPAD_RIGHT}, "dpright"}, {{EV_KEY, BTN_DPAD_UP}, "dpup"}, {{EV_KEY, BTN_MODE}, "guide"}, {{EV_KEY, BTN_SELECT}, "back"}, {{EV_KEY, BTN_TL}, "leftshoulder"}, {{EV_KEY, BTN_TR}, "rightshoulder"}, {{EV_KEY, BTN_START}, "start"}, {{EV_KEY, BTN_THUMBL}, "leftstick"}, {{EV_KEY, BTN_THUMBR}, "rightstick"}, {{EV_KEY, BTN_TL2}, "lefttrigger"}, {{EV_KEY, BTN_TR2}, "righttrigger"}, {{EV_KEY, BTN_Y}, "x"}, {{EV_KEY, BTN_X}, "y"}};
static const GamesGamepadViewConfiguration GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_VIEW_CONFIGURATION = {"resource:///org/gnome/Games/gamepads/standard-gamepad.svg", GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUT_PATHS, G_N_ELEMENTS (GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUT_PATHS)};

static GType games_gamepad_configurer_state_get_type (void) {
	static volatile gsize games_gamepad_configurer_state_type_id__volatile = 0;
	if (g_once_init_enter (&games_gamepad_configurer_state_type_id__volatile)) {
		static const GEnumValue values[] = {{GAMES_GAMEPAD_CONFIGURER_STATE_TEST, "GAMES_GAMEPAD_CONFIGURER_STATE_TEST", "test"}, {GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE, "GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE", "configure"}, {0, NULL, NULL}};
		GType games_gamepad_configurer_state_type_id;
		games_gamepad_configurer_state_type_id = g_enum_register_static ("GamesGamepadConfigurerState", values);
		g_once_init_leave (&games_gamepad_configurer_state_type_id__volatile, games_gamepad_configurer_state_type_id);
	}
	return games_gamepad_configurer_state_type_id__volatile;
}


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


GamesGamepadConfigurer* games_gamepad_configurer_construct (GType object_type, ManetteDevice* device) {
	GamesGamepadConfigurer * self = NULL;
	ManetteDevice* _tmp0_;
	ManetteDevice* _tmp1_;
	ManetteDevice* _tmp2_;
	GamesGamepadMapper* _tmp3_;
	GtkBox* _tmp4_;
	GamesGamepadMapper* _tmp5_;
	ManetteDevice* _tmp6_;
	GamesGamepadTester* _tmp7_;
	GtkBox* _tmp8_;
	GamesGamepadTester* _tmp9_;
	g_return_val_if_fail (device != NULL, NULL);
	self = (GamesGamepadConfigurer*) g_object_new (object_type, NULL);
	_tmp0_ = device;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->device);
	self->priv->device = _tmp1_;
	_tmp2_ = device;
	_tmp3_ = games_gamepad_mapper_new (_tmp2_, &GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_VIEW_CONFIGURATION, GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUTS, G_N_ELEMENTS (GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_INPUTS));
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->mapper);
	self->priv->mapper = _tmp3_;
	_tmp4_ = self->priv->gamepad_mapper_holder;
	_tmp5_ = self->priv->mapper;
	gtk_box_pack_start (_tmp4_, (GtkWidget*) _tmp5_, TRUE, TRUE, (guint) 0);
	_tmp6_ = device;
	_tmp7_ = games_gamepad_tester_new (_tmp6_, &GAMES_GAMEPAD_CONFIGURER_STANDARD_GAMEPAD_VIEW_CONFIGURATION);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->tester);
	self->priv->tester = _tmp7_;
	_tmp8_ = self->priv->gamepad_tester_holder;
	_tmp9_ = self->priv->tester;
	gtk_box_pack_start (_tmp8_, (GtkWidget*) _tmp9_, TRUE, TRUE, (guint) 0);
	games_gamepad_configurer_set_state (self, GAMES_GAMEPAD_CONFIGURER_STATE_TEST);
	return self;
}


GamesGamepadConfigurer* games_gamepad_configurer_new (ManetteDevice* device) {
	return games_gamepad_configurer_construct (GAMES_TYPE_GAMEPAD_CONFIGURER, device);
}


static void games_gamepad_configurer_on_reset_clicked (GamesGamepadConfigurer* self) {
	g_return_if_fail (self != NULL);
	games_gamepad_configurer_reset_mapping (self);
}


static void _games_gamepad_configurer_on_reset_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	games_gamepad_configurer_on_reset_clicked ((GamesGamepadConfigurer*) self);
}


static void games_gamepad_configurer_on_configure_clicked (GamesGamepadConfigurer* self) {
	g_return_if_fail (self != NULL);
	games_gamepad_configurer_set_state (self, GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE);
}


static void _games_gamepad_configurer_on_configure_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	games_gamepad_configurer_on_configure_clicked ((GamesGamepadConfigurer*) self);
}


static void games_gamepad_configurer_on_back_clicked (GamesGamepadConfigurer* self) {
	g_return_if_fail (self != NULL);
	g_signal_emit (self, games_gamepad_configurer_signals[GAMES_GAMEPAD_CONFIGURER_BACK_SIGNAL], 0);
}


static void _games_gamepad_configurer_on_back_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	games_gamepad_configurer_on_back_clicked ((GamesGamepadConfigurer*) self);
}


static void games_gamepad_configurer_on_cancel_clicked (GamesGamepadConfigurer* self) {
	g_return_if_fail (self != NULL);
	games_gamepad_configurer_set_state (self, GAMES_GAMEPAD_CONFIGURER_STATE_TEST);
}


static void _games_gamepad_configurer_on_cancel_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	games_gamepad_configurer_on_cancel_clicked ((GamesGamepadConfigurer*) self);
}


static Block9Data* block9_data_ref (Block9Data* _data9_) {
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}


static void block9_data_unref (void * _userdata_) {
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		GamesGamepadConfigurer* self;
		self = _data9_->self;
		_g_object_unref0 (_data9_->message_dialog);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}


static void __lambda23_ (Block9Data* _data9_, gint response) {
	GamesGamepadConfigurer* self;
	gint _tmp0_;
	self = _data9_->self;
	_tmp0_ = response;
	switch (_tmp0_) {
		case GTK_RESPONSE_ACCEPT:
		{
			ManetteDevice* _tmp1_;
			GtkButton* _tmp2_;
			_tmp1_ = self->priv->device;
			manette_device_remove_user_mapping (_tmp1_);
			_tmp2_ = self->priv->reset_button;
			gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, FALSE);
			break;
		}
		default:
		{
			break;
		}
	}
	gtk_widget_destroy ((GtkWidget*) _data9_->message_dialog);
}


static void ___lambda23__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
	__lambda23_ (self, response_id);
}


static void games_gamepad_configurer_reset_mapping (GamesGamepadConfigurer* self) {
	Block9Data* _data9_;
	GamesResetGamepadMappingDialog* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_if_fail (self != NULL);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_tmp0_ = games_reset_gamepad_mapping_dialog_new ();
	g_object_ref_sink (_tmp0_);
	_data9_->message_dialog = _tmp0_;
	_tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	gtk_window_set_transient_for ((GtkWindow*) _data9_->message_dialog, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_window_get_type (), GtkWindow));
	g_signal_connect_data ((GtkDialog*) _data9_->message_dialog, "response", (GCallback) ___lambda23__gtk_dialog_response, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	gtk_widget_show ((GtkWidget*) _data9_->message_dialog);
	block9_data_unref (_data9_);
	_data9_ = NULL;
}


static void games_gamepad_configurer_on_mapper_finished (GamesGamepadConfigurer* self, const gchar* sdl_string) {
	ManetteDevice* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sdl_string != NULL);
	_tmp0_ = self->priv->device;
	_tmp1_ = sdl_string;
	manette_device_save_user_mapping (_tmp0_, _tmp1_);
	games_gamepad_configurer_set_state (self, GAMES_GAMEPAD_CONFIGURER_STATE_TEST);
}


static GamesGamepadConfigurerState games_gamepad_configurer_get_state (GamesGamepadConfigurer* self) {
	GamesGamepadConfigurerState result;
	GamesGamepadConfigurerState _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_state;
	result = _tmp0_;
	return result;
}


static void _games_gamepad_configurer_on_mapper_finished_games_gamepad_mapper_finished (GamesGamepadMapper* _sender, const gchar* sdl_string, gpointer self) {
	games_gamepad_configurer_on_mapper_finished ((GamesGamepadConfigurer*) self, sdl_string);
}


static void games_gamepad_configurer_set_state (GamesGamepadConfigurer* self, GamesGamepadConfigurerState value) {
	GamesGamepadConfigurerState _tmp0_;
	GamesGamepadConfigurerState _tmp1_;
	GamesGamepadConfigurerState _tmp2_;
	GamesGamepadConfigurerState _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_state = _tmp0_;
	_tmp1_ = games_gamepad_configurer_get_state (self);
	_tmp2_ = _tmp1_;
	games_gamepad_configurer_set_immersive_mode (self, _tmp2_ == GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE);
	_tmp3_ = value;
	switch (_tmp3_) {
		case GAMES_GAMEPAD_CONFIGURER_STATE_TEST:
		{
			GtkButton* _tmp4_;
			ManetteDevice* _tmp5_;
			gboolean _tmp6_;
			GtkButton* _tmp7_;
			GtkButton* _tmp8_;
			GtkActionBar* _tmp9_;
			GtkHeaderBar* _tmp10_;
			GtkHeaderBar* _tmp11_;
			ManetteDevice* _tmp12_;
			const gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			GtkHeaderBar* _tmp16_;
			GtkHeaderBar* _tmp17_;
			GtkStyleContext* _tmp18_;
			GtkStack* _tmp19_;
			GamesGamepadTester* _tmp20_;
			GamesGamepadMapper* _tmp21_;
			GamesGamepadMapper* _tmp22_;
			guint _tmp23_;
			_tmp4_ = self->priv->reset_button;
			_tmp5_ = self->priv->device;
			_tmp6_ = manette_device_has_user_mapping (_tmp5_);
			gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, _tmp6_);
			_tmp7_ = self->priv->back_button;
			gtk_widget_show ((GtkWidget*) _tmp7_);
			_tmp8_ = self->priv->cancel_button;
			gtk_widget_hide ((GtkWidget*) _tmp8_);
			_tmp9_ = self->priv->action_bar;
			gtk_widget_show ((GtkWidget*) _tmp9_);
			_tmp10_ = games_gamepad_configurer_get_header_bar (self);
			_tmp11_ = _tmp10_;
			_tmp12_ = self->priv->device;
			_tmp13_ = manette_device_get_name (_tmp12_);
			_tmp14_ = g_strdup_printf (_ ("Testing %s"), _tmp13_);
			_tmp15_ = _tmp14_;
			gtk_header_bar_set_title (_tmp11_, _tmp15_);
			_g_free0 (_tmp15_);
			_tmp16_ = games_gamepad_configurer_get_header_bar (self);
			_tmp17_ = _tmp16_;
			_tmp18_ = gtk_widget_get_style_context ((GtkWidget*) _tmp17_);
			gtk_style_context_remove_class (_tmp18_, "selection-mode");
			_tmp19_ = self->priv->stack;
			gtk_stack_set_visible_child_name (_tmp19_, "gamepad_tester");
			_tmp20_ = self->priv->tester;
			games_gamepad_tester_start (_tmp20_);
			_tmp21_ = self->priv->mapper;
			games_gamepad_mapper_stop (_tmp21_);
			_tmp22_ = self->priv->mapper;
			g_signal_parse_name ("finished", GAMES_TYPE_GAMEPAD_MAPPER, &_tmp23_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp22_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp23_, 0, NULL, (GCallback) _games_gamepad_configurer_on_mapper_finished_games_gamepad_mapper_finished, self);
			break;
		}
		case GAMES_GAMEPAD_CONFIGURER_STATE_CONFIGURE:
		{
			GtkButton* _tmp24_;
			GtkButton* _tmp25_;
			GtkActionBar* _tmp26_;
			GtkHeaderBar* _tmp27_;
			GtkHeaderBar* _tmp28_;
			ManetteDevice* _tmp29_;
			const gchar* _tmp30_;
			gchar* _tmp31_;
			gchar* _tmp32_;
			GtkHeaderBar* _tmp33_;
			GtkHeaderBar* _tmp34_;
			GtkStyleContext* _tmp35_;
			GtkStack* _tmp36_;
			GamesGamepadTester* _tmp37_;
			GamesGamepadMapper* _tmp38_;
			GamesGamepadMapper* _tmp39_;
			_tmp24_ = self->priv->back_button;
			gtk_widget_hide ((GtkWidget*) _tmp24_);
			_tmp25_ = self->priv->cancel_button;
			gtk_widget_show ((GtkWidget*) _tmp25_);
			_tmp26_ = self->priv->action_bar;
			gtk_widget_hide ((GtkWidget*) _tmp26_);
			_tmp27_ = games_gamepad_configurer_get_header_bar (self);
			_tmp28_ = _tmp27_;
			_tmp29_ = self->priv->device;
			_tmp30_ = manette_device_get_name (_tmp29_);
			_tmp31_ = g_strdup_printf (_ ("Configuring %s"), _tmp30_);
			_tmp32_ = _tmp31_;
			gtk_header_bar_set_title (_tmp28_, _tmp32_);
			_g_free0 (_tmp32_);
			_tmp33_ = games_gamepad_configurer_get_header_bar (self);
			_tmp34_ = _tmp33_;
			_tmp35_ = gtk_widget_get_style_context ((GtkWidget*) _tmp34_);
			gtk_style_context_add_class (_tmp35_, "selection-mode");
			_tmp36_ = self->priv->stack;
			gtk_stack_set_visible_child_name (_tmp36_, "gamepad_mapper");
			_tmp37_ = self->priv->tester;
			games_gamepad_tester_stop (_tmp37_);
			_tmp38_ = self->priv->mapper;
			games_gamepad_mapper_start (_tmp38_);
			_tmp39_ = self->priv->mapper;
			g_signal_connect_object (_tmp39_, "finished", (GCallback) _games_gamepad_configurer_on_mapper_finished_games_gamepad_mapper_finished, self, 0);
			break;
		}
		default:
		break;
	}
}


GtkHeaderBar* games_gamepad_configurer_get_header_bar (GamesGamepadConfigurer* self) {
	GtkHeaderBar* result;
	GtkHeaderBar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_header_bar;
	result = _tmp0_;
	return result;
}


static void games_gamepad_configurer_set_header_bar (GamesGamepadConfigurer* self, GtkHeaderBar* value) {
	g_return_if_fail (self != NULL);
	g_object_notify ((GObject *) self, "header-bar");
}


gboolean games_gamepad_configurer_get_immersive_mode (GamesGamepadConfigurer* self) {
	gboolean result;
	gboolean _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_immersive_mode;
	result = _tmp0_;
	return result;
}


static void games_gamepad_configurer_set_immersive_mode (GamesGamepadConfigurer* self, gboolean value) {
	g_return_if_fail (self != NULL);
	if (games_gamepad_configurer_get_immersive_mode (self) != value) {
		gboolean _tmp0_;
		_tmp0_ = value;
		self->priv->_immersive_mode = _tmp0_;
		g_object_notify ((GObject *) self, "immersive-mode");
	}
}


static void games_gamepad_configurer_class_init (GamesGamepadConfigurerClass * klass) {
	gint GamesGamepadConfigurer_private_offset;
	games_gamepad_configurer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGamepadConfigurerPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_games_gamepad_configurer_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_gamepad_configurer_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_gamepad_configurer_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAMEPAD_CONFIGURER_HEADER_BAR_PROPERTY, g_param_spec_object ("header-bar", "header-bar", "header-bar", gtk_header_bar_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAMEPAD_CONFIGURER_IMMERSIVE_MODE_PROPERTY, g_param_spec_boolean ("immersive-mode", "immersive-mode", "immersive-mode", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	GamesGamepadConfigurer_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/gamepad-configurer.ui");
	games_gamepad_configurer_signals[GAMES_GAMEPAD_CONFIGURER_BACK_SIGNAL] = g_signal_new ("back", GAMES_TYPE_GAMEPAD_CONFIGURER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "header_bar", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, _header_bar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gamepad_mapper_holder", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, gamepad_mapper_holder));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gamepad_tester_holder", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, gamepad_tester_holder));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "action_bar", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, action_bar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "reset_button", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, reset_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "back_button", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, back_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "cancel_button", FALSE, GamesGamepadConfigurer_private_offset + G_STRUCT_OFFSET (GamesGamepadConfigurerPrivate, cancel_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_reset_clicked", G_CALLBACK(_games_gamepad_configurer_on_reset_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_configure_clicked", G_CALLBACK(_games_gamepad_configurer_on_configure_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_back_clicked", G_CALLBACK(_games_gamepad_configurer_on_back_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_cancel_clicked", G_CALLBACK(_games_gamepad_configurer_on_cancel_clicked_gtk_button_clicked));
}


static void games_gamepad_configurer_instance_init (GamesGamepadConfigurer * self) {
	self->priv = GAMES_GAMEPAD_CONFIGURER_GET_PRIVATE (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void games_gamepad_configurer_finalize (GObject * obj) {
	GamesGamepadConfigurer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurer);
	_g_object_unref0 (self->priv->_header_bar);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->gamepad_mapper_holder);
	_g_object_unref0 (self->priv->gamepad_tester_holder);
	_g_object_unref0 (self->priv->action_bar);
	_g_object_unref0 (self->priv->reset_button);
	_g_object_unref0 (self->priv->back_button);
	_g_object_unref0 (self->priv->cancel_button);
	_g_object_unref0 (self->priv->device);
	_g_object_unref0 (self->priv->mapper);
	_g_object_unref0 (self->priv->tester);
	G_OBJECT_CLASS (games_gamepad_configurer_parent_class)->finalize (obj);
}


GType games_gamepad_configurer_get_type (void) {
	static volatile gsize games_gamepad_configurer_type_id__volatile = 0;
	if (g_once_init_enter (&games_gamepad_configurer_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesGamepadConfigurerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_gamepad_configurer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGamepadConfigurer), 0, (GInstanceInitFunc) games_gamepad_configurer_instance_init, NULL };
		GType games_gamepad_configurer_type_id;
		games_gamepad_configurer_type_id = g_type_register_static (gtk_box_get_type (), "GamesGamepadConfigurer", &g_define_type_info, 0);
		g_once_init_leave (&games_gamepad_configurer_type_id__volatile, games_gamepad_configurer_type_id);
	}
	return games_gamepad_configurer_type_id__volatile;
}


static void _vala_games_gamepad_configurer_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GamesGamepadConfigurer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurer);
	switch (property_id) {
		case GAMES_GAMEPAD_CONFIGURER_HEADER_BAR_PROPERTY:
		g_value_set_object (value, games_gamepad_configurer_get_header_bar (self));
		break;
		case GAMES_GAMEPAD_CONFIGURER_IMMERSIVE_MODE_PROPERTY:
		g_value_set_boolean (value, games_gamepad_configurer_get_immersive_mode (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_games_gamepad_configurer_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GamesGamepadConfigurer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_GAMEPAD_CONFIGURER, GamesGamepadConfigurer);
	switch (property_id) {
		case GAMES_GAMEPAD_CONFIGURER_HEADER_BAR_PROPERTY:
		games_gamepad_configurer_set_header_bar (self, g_value_get_object (value));
		break;
		case GAMES_GAMEPAD_CONFIGURER_IMMERSIVE_MODE_PROPERTY:
		games_gamepad_configurer_set_immersive_mode (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



