/* preferences-page-controllers.c generated by valac 0.36.1.39-72bb2, the Vala compiler
 * generated from preferences-page-controllers.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 <gamepad-monitor.h>
#include <gamepad.h>


#define GAMES_TYPE_PREFERENCES_PAGE (games_preferences_page_get_type ())
#define GAMES_PREFERENCES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPage))
#define GAMES_IS_PREFERENCES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE))
#define GAMES_PREFERENCES_PAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPageIface))

typedef struct _GamesPreferencesPage GamesPreferencesPage;
typedef struct _GamesPreferencesPageIface GamesPreferencesPageIface;

#define GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS (games_preferences_page_controllers_get_type ())
#define GAMES_PREFERENCES_PAGE_CONTROLLERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllers))
#define GAMES_PREFERENCES_PAGE_CONTROLLERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllersClass))
#define GAMES_IS_PREFERENCES_PAGE_CONTROLLERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS))
#define GAMES_IS_PREFERENCES_PAGE_CONTROLLERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS))
#define GAMES_PREFERENCES_PAGE_CONTROLLERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllersClass))

typedef struct _GamesPreferencesPageControllers GamesPreferencesPageControllers;
typedef struct _GamesPreferencesPageControllersClass GamesPreferencesPageControllersClass;
typedef struct _GamesPreferencesPageControllersPrivate GamesPreferencesPageControllersPrivate;
enum  {
	GAMES_PREFERENCES_PAGE_CONTROLLERS_DUMMY_PROPERTY,
	GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR,
	GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE,
	GAMES_PREFERENCES_PAGE_CONTROLLERS_LAST_PROPERTY
};
static GParamSpec* games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_LAST_PROPERTY];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block12Data Block12Data;
typedef struct _Block13Data Block13Data;

#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;

struct _GamesPreferencesPageIface {
	GTypeInterface parent_iface;
	void (*visible_page_changed) (GamesPreferencesPage* self);
	GtkHeaderBar* (*get_header_bar) (GamesPreferencesPage* self);
	void (*set_header_bar) (GamesPreferencesPage* self, GtkHeaderBar* value);
	gboolean (*get_immersive_mode) (GamesPreferencesPage* self);
	void (*set_immersive_mode) (GamesPreferencesPage* self, gboolean value);
};

struct _GamesPreferencesPageControllers {
	GtkStack parent_instance;
	GamesPreferencesPageControllersPrivate * priv;
};

struct _GamesPreferencesPageControllersClass {
	GtkStackClass parent_class;
};

struct _GamesPreferencesPageControllersPrivate {
	GtkHeaderBar* _header_bar;
	gboolean _immersive_mode;
	GtkListBox* gamepads_list_box;
	GtkBox* extra_stack_child_holder;
	GtkHeaderBar* default_header_bar;
	GamesGamepadMonitor* gamepad_monitor;
	GBinding* header_bar_binding;
	GBinding* immersive_mode_binding;
	gulong back_handler_id;
};

struct _Block12Data {
	int _ref_count_;
	GamesPreferencesPageControllers* self;
	gint i;
};

struct _Block13Data {
	int _ref_count_;
	GamesPreferencesPageControllers* self;
	GamesGamepad* gamepad;
	gint i;
	gint row_index;
};


static gpointer games_preferences_page_controllers_parent_class = NULL;
static GamesPreferencesPageIface * games_preferences_page_controllers_games_preferences_page_parent_iface = NULL;

GType games_preferences_page_get_type (void) G_GNUC_CONST;
GType games_preferences_page_controllers_get_type (void) G_GNUC_CONST;
#define GAMES_PREFERENCES_PAGE_CONTROLLERS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllersPrivate))
static void games_preferences_page_controllers_real_visible_page_changed (GamesPreferencesPage* base);
static void games_preferences_page_controllers_on_back (GamesPreferencesPageControllers* self, GObject* emitter);
static void games_preferences_page_controllers_rebuild_gamepad_list (GamesPreferencesPageControllers* self);
static void games_preferences_page_controllers_clear_gamepad_list (GamesPreferencesPageControllers* self);
static void games_preferences_page_controllers_build_gamepad_list (GamesPreferencesPageControllers* self);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static void __lambda35_ (Block12Data* _data12_, GamesGamepad* gamepad);
static void ___lambda35__games_gamepad_callback (GamesGamepad* gamepad, gpointer self);
static void __lambda34_ (GamesPreferencesPageControllers* self, GtkWidget* child);
static void ___lambda34__gtk_callback (GtkWidget* widget, gpointer self);
static void games_preferences_page_controllers_gamepads_list_box_row_activated (GamesPreferencesPageControllers* self, GtkListBoxRow* row_item);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void __lambda36_ (Block13Data* _data13_, GamesGamepad* gamepad_);
static void ___lambda36__games_gamepad_callback (GamesGamepad* gamepad, gpointer self);
GType games_gamepad_configurer_get_type (void) G_GNUC_CONST;
GamesGamepadConfigurer* games_gamepad_configurer_new (GamesGamepad* gamepad);
GamesGamepadConfigurer* games_gamepad_configurer_construct (GType object_type, GamesGamepad* gamepad);
static void _games_preferences_page_controllers_on_back_games_gamepad_configurer_back (GamesGamepadConfigurer* _sender, gpointer self);
static void _games_preferences_page_controllers_gamepads_list_box_row_activated_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self);
void games_preferences_page_set_header_bar (GamesPreferencesPage* self, GtkHeaderBar* value);
void games_preferences_page_set_immersive_mode (GamesPreferencesPage* self, gboolean value);
static void __lambda33_ (GamesPreferencesPageControllers* self, GtkWidget* child);
static void ___lambda33__gtk_callback (GtkWidget* widget, gpointer self);
GamesPreferencesPageControllers* games_preferences_page_controllers_new (void);
GamesPreferencesPageControllers* games_preferences_page_controllers_construct (GType object_type);
static GObject * games_preferences_page_controllers_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_unplugged (GamesGamepadMonitor* _sender, gpointer self);
static void _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_plugged (GamesGamepadMonitor* _sender, GamesGamepad* gamepad, gpointer self);
static void games_preferences_page_controllers_finalize (GObject * obj);
GtkHeaderBar* games_preferences_page_get_header_bar (GamesPreferencesPage* self);
gboolean games_preferences_page_get_immersive_mode (GamesPreferencesPage* self);
static void _vala_games_preferences_page_controllers_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_games_preferences_page_controllers_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void games_preferences_page_controllers_real_visible_page_changed (GamesPreferencesPage* base) {
	GamesPreferencesPageControllers * self;
	self = (GamesPreferencesPageControllers*) base;
	games_preferences_page_controllers_on_back (self, NULL);
}


static void games_preferences_page_controllers_rebuild_gamepad_list (GamesPreferencesPageControllers* self) {
	g_return_if_fail (self != NULL);
	games_preferences_page_controllers_clear_gamepad_list (self);
	games_preferences_page_controllers_build_gamepad_list (self);
}


static Block12Data* block12_data_ref (Block12Data* _data12_) {
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}


static void block12_data_unref (void * _userdata_) {
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		GamesPreferencesPageControllers* self;
		self = _data12_->self;
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}


static void __lambda35_ (Block12Data* _data12_, GamesGamepad* gamepad) {
	GamesPreferencesPageControllers* self;
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GamesGamepad* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkListBox* _tmp6_;
	self = _data12_->self;
	g_return_if_fail (gamepad != NULL);
	_data12_->i = _data12_->i + 1;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = gamepad;
	_tmp2_ = games_gamepad_get_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	gtk_box_pack_start (box, (GtkWidget*) _tmp5_, FALSE, FALSE, (guint) 0);
	_g_object_unref0 (_tmp5_);
	g_object_set ((GtkWidget*) box, "margin", 6, NULL);
	gtk_widget_show_all ((GtkWidget*) box);
	_tmp6_ = self->priv->gamepads_list_box;
	gtk_container_add ((GtkContainer*) _tmp6_, (GtkWidget*) box);
	_g_object_unref0 (box);
}


static void ___lambda35__games_gamepad_callback (GamesGamepad* gamepad, gpointer self) {
	__lambda35_ (self, gamepad);
}


static void games_preferences_page_controllers_build_gamepad_list (GamesPreferencesPageControllers* self) {
	Block12Data* _data12_;
	GamesGamepadMonitor* _tmp0_;
	g_return_if_fail (self != NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	_data12_->i = 0;
	_tmp0_ = self->priv->gamepad_monitor;
	games_gamepad_monitor_foreach_gamepad (_tmp0_, ___lambda35__games_gamepad_callback, _data12_);
	block12_data_unref (_data12_);
	_data12_ = NULL;
}


static void __lambda34_ (GamesPreferencesPageControllers* self, GtkWidget* child) {
	GtkWidget* _tmp0_;
	g_return_if_fail (child != NULL);
	_tmp0_ = child;
	gtk_widget_destroy (_tmp0_);
}


static void ___lambda34__gtk_callback (GtkWidget* widget, gpointer self) {
	__lambda34_ ((GamesPreferencesPageControllers*) self, widget);
}


static void games_preferences_page_controllers_clear_gamepad_list (GamesPreferencesPageControllers* self) {
	GtkListBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->gamepads_list_box;
	gtk_container_foreach ((GtkContainer*) _tmp0_, ___lambda34__gtk_callback, self);
}


static Block13Data* block13_data_ref (Block13Data* _data13_) {
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}


static void block13_data_unref (void * _userdata_) {
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		GamesPreferencesPageControllers* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->gamepad);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}


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


static void __lambda36_ (Block13Data* _data13_, GamesGamepad* gamepad_) {
	GamesPreferencesPageControllers* self;
	gint _tmp0_;
	gint _tmp1_;
	self = _data13_->self;
	g_return_if_fail (gamepad_ != NULL);
	_tmp0_ = _data13_->i;
	_data13_->i = _tmp0_ + 1;
	_tmp1_ = _data13_->row_index;
	if (_tmp0_ == _tmp1_) {
		GamesGamepad* _tmp2_;
		GamesGamepad* _tmp3_;
		_tmp2_ = gamepad_;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		_g_object_unref0 (_data13_->gamepad);
		_data13_->gamepad = _tmp3_;
	}
}


static void ___lambda36__games_gamepad_callback (GamesGamepad* gamepad, gpointer self) {
	__lambda36_ (self, gamepad);
}


static void _games_preferences_page_controllers_on_back_games_gamepad_configurer_back (GamesGamepadConfigurer* _sender, gpointer self) {
	games_preferences_page_controllers_on_back ((GamesPreferencesPageControllers*) self, _sender);
}


static void games_preferences_page_controllers_gamepads_list_box_row_activated (GamesPreferencesPageControllers* self, GtkListBoxRow* row_item) {
	Block13Data* _data13_;
	GtkListBoxRow* _tmp0_;
	gint _tmp1_;
	GamesGamepadMonitor* _tmp2_;
	GamesGamepad* _tmp3_;
	GamesGamepadConfigurer* configurer = NULL;
	GamesGamepad* _tmp4_;
	GamesGamepadConfigurer* _tmp5_;
	GamesGamepadConfigurer* _tmp6_;
	gulong _tmp7_;
	GamesGamepadConfigurer* _tmp8_;
	GBinding* _tmp9_;
	GBinding* _tmp10_;
	GamesGamepadConfigurer* _tmp11_;
	GBinding* _tmp12_;
	GBinding* _tmp13_;
	GtkBox* _tmp14_;
	GamesGamepadConfigurer* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row_item != NULL);
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->self = g_object_ref (self);
	_data13_->gamepad = NULL;
	_data13_->i = 0;
	_tmp0_ = row_item;
	_tmp1_ = gtk_list_box_row_get_index (_tmp0_);
	_data13_->row_index = _tmp1_;
	_tmp2_ = self->priv->gamepad_monitor;
	games_gamepad_monitor_foreach_gamepad (_tmp2_, ___lambda36__games_gamepad_callback, _data13_);
	_tmp3_ = _data13_->gamepad;
	if (_tmp3_ == NULL) {
		block13_data_unref (_data13_);
		_data13_ = NULL;
		return;
	}
	_tmp4_ = _data13_->gamepad;
	_tmp5_ = games_gamepad_configurer_new (_tmp4_);
	g_object_ref_sink (_tmp5_);
	configurer = _tmp5_;
	_tmp6_ = configurer;
	_tmp7_ = g_signal_connect_object (_tmp6_, "back", (GCallback) _games_preferences_page_controllers_on_back_games_gamepad_configurer_back, self, 0);
	self->priv->back_handler_id = _tmp7_;
	_tmp8_ = configurer;
	_tmp9_ = g_object_bind_property_with_closures ((GObject*) _tmp8_, "header-bar", (GObject*) self, "header-bar", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp10_ = _g_object_ref0 (_tmp9_);
	_g_object_unref0 (self->priv->header_bar_binding);
	self->priv->header_bar_binding = _tmp10_;
	_tmp11_ = configurer;
	_tmp12_ = g_object_bind_property_with_closures ((GObject*) _tmp11_, "immersive-mode", (GObject*) self, "immersive-mode", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp13_ = _g_object_ref0 (_tmp12_);
	_g_object_unref0 (self->priv->immersive_mode_binding);
	self->priv->immersive_mode_binding = _tmp13_;
	_tmp14_ = self->priv->extra_stack_child_holder;
	_tmp15_ = configurer;
	gtk_box_pack_start (_tmp14_, (GtkWidget*) _tmp15_, TRUE, TRUE, (guint) 0);
	gtk_stack_set_visible_child_name ((GtkStack*) self, "extra_stack_child");
	_g_object_unref0 (configurer);
	block13_data_unref (_data13_);
	_data13_ = NULL;
}


static void _games_preferences_page_controllers_gamepads_list_box_row_activated_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self) {
	games_preferences_page_controllers_gamepads_list_box_row_activated ((GamesPreferencesPageControllers*) self, row);
}


static void __lambda33_ (GamesPreferencesPageControllers* self, GtkWidget* child) {
	GtkWidget* _tmp0_;
	g_return_if_fail (child != NULL);
	_tmp0_ = child;
	gtk_widget_destroy (_tmp0_);
}


static void ___lambda33__gtk_callback (GtkWidget* widget, gpointer self) {
	__lambda33_ ((GamesPreferencesPageControllers*) self, widget);
}


static void games_preferences_page_controllers_on_back (GamesPreferencesPageControllers* self, GObject* emitter) {
	gulong _tmp0_;
	GtkHeaderBar* _tmp4_;
	GtkBox* _tmp5_;
	g_return_if_fail (self != NULL);
	_g_object_unref0 (self->priv->header_bar_binding);
	self->priv->header_bar_binding = NULL;
	_g_object_unref0 (self->priv->immersive_mode_binding);
	self->priv->immersive_mode_binding = NULL;
	_tmp0_ = self->priv->back_handler_id;
	if (_tmp0_ != ((gulong) 0)) {
		GObject* _tmp1_;
		_tmp1_ = emitter;
		if (_tmp1_ != NULL) {
			GObject* _tmp2_;
			gulong _tmp3_;
			_tmp2_ = emitter;
			_tmp3_ = self->priv->back_handler_id;
			g_signal_handler_disconnect (_tmp2_, _tmp3_);
		}
		self->priv->back_handler_id = (gulong) 0;
	}
	_tmp4_ = self->priv->default_header_bar;
	games_preferences_page_set_header_bar ((GamesPreferencesPage*) self, _tmp4_);
	games_preferences_page_set_immersive_mode ((GamesPreferencesPage*) self, FALSE);
	gtk_stack_set_visible_child_name ((GtkStack*) self, "main_stack_child");
	_tmp5_ = self->priv->extra_stack_child_holder;
	gtk_container_foreach ((GtkContainer*) _tmp5_, ___lambda33__gtk_callback, self);
}


GamesPreferencesPageControllers* games_preferences_page_controllers_construct (GType object_type) {
	GamesPreferencesPageControllers * self = NULL;
	self = (GamesPreferencesPageControllers*) g_object_new (object_type, NULL);
	return self;
}


GamesPreferencesPageControllers* games_preferences_page_controllers_new (void) {
	return games_preferences_page_controllers_construct (GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS);
}


static GtkHeaderBar* games_preferences_page_controllers_real_get_header_bar (GamesPreferencesPage* base) {
	GtkHeaderBar* result;
	GamesPreferencesPageControllers* self;
	GtkHeaderBar* _tmp0_;
	self = (GamesPreferencesPageControllers*) base;
	_tmp0_ = self->priv->_header_bar;
	result = _tmp0_;
	return result;
}


static void games_preferences_page_controllers_real_set_header_bar (GamesPreferencesPage* base, GtkHeaderBar* value) {
	GamesPreferencesPageControllers* self;
	self = (GamesPreferencesPageControllers*) base;
	if (games_preferences_page_controllers_real_get_header_bar (base) != value) {
		GtkHeaderBar* _tmp0_;
		GtkHeaderBar* _tmp1_;
		_tmp0_ = value;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (self->priv->_header_bar);
		self->priv->_header_bar = _tmp1_;
		g_object_notify_by_pspec ((GObject *) self, games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR]);
	}
}


static gboolean games_preferences_page_controllers_real_get_immersive_mode (GamesPreferencesPage* base) {
	gboolean result;
	GamesPreferencesPageControllers* self;
	gboolean _tmp0_;
	self = (GamesPreferencesPageControllers*) base;
	_tmp0_ = self->priv->_immersive_mode;
	result = _tmp0_;
	return result;
}


static void games_preferences_page_controllers_real_set_immersive_mode (GamesPreferencesPage* base, gboolean value) {
	GamesPreferencesPageControllers* self;
	self = (GamesPreferencesPageControllers*) base;
	if (games_preferences_page_controllers_real_get_immersive_mode (base) != value) {
		gboolean _tmp0_;
		_tmp0_ = value;
		self->priv->_immersive_mode = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE]);
	}
}


static void _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_unplugged (GamesGamepadMonitor* _sender, gpointer self) {
	games_preferences_page_controllers_rebuild_gamepad_list ((GamesPreferencesPageControllers*) self);
}


static void _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_plugged (GamesGamepadMonitor* _sender, GamesGamepad* gamepad, gpointer self) {
	games_preferences_page_controllers_rebuild_gamepad_list ((GamesPreferencesPageControllers*) self);
}


static GObject * games_preferences_page_controllers_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GamesPreferencesPageControllers * self;
	GtkHeaderBar* _tmp0_;
	GamesGamepadMonitor* _tmp1_;
	GamesGamepadMonitor* _tmp2_;
	GamesGamepadMonitor* _tmp3_;
	parent_class = G_OBJECT_CLASS (games_preferences_page_controllers_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllers);
	_tmp0_ = self->priv->default_header_bar;
	games_preferences_page_set_header_bar ((GamesPreferencesPage*) self, _tmp0_);
	games_preferences_page_set_immersive_mode ((GamesPreferencesPage*) self, FALSE);
	_tmp1_ = games_gamepad_monitor_get_instance ();
	_g_object_unref0 (self->priv->gamepad_monitor);
	self->priv->gamepad_monitor = _tmp1_;
	_tmp2_ = self->priv->gamepad_monitor;
	g_signal_connect_object (_tmp2_, "gamepad-unplugged", (GCallback) _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_unplugged, self, 0);
	_tmp3_ = self->priv->gamepad_monitor;
	g_signal_connect_object (_tmp3_, "gamepad-plugged", (GCallback) _games_preferences_page_controllers_rebuild_gamepad_list_games_gamepad_monitor_gamepad_plugged, self, 0);
	games_preferences_page_controllers_build_gamepad_list (self);
	return obj;
}


static void games_preferences_page_controllers_class_init (GamesPreferencesPageControllersClass * klass) {
	gint GamesPreferencesPageControllers_private_offset;
	games_preferences_page_controllers_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesPreferencesPageControllersPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_games_preferences_page_controllers_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_preferences_page_controllers_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_preferences_page_controllers_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_preferences_page_controllers_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR, games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR] = 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_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE, games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE] = 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 | G_PARAM_WRITABLE));
	GamesPreferencesPageControllers_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/preferences-page-controllers.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gamepads_list_box", FALSE, GamesPreferencesPageControllers_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageControllersPrivate, gamepads_list_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "extra_stack_child_holder", FALSE, GamesPreferencesPageControllers_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageControllersPrivate, extra_stack_child_holder));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "default_header_bar", FALSE, GamesPreferencesPageControllers_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageControllersPrivate, default_header_bar));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "gamepads_list_box_row_activated", G_CALLBACK(_games_preferences_page_controllers_gamepads_list_box_row_activated_gtk_list_box_row_activated));
}


static void games_preferences_page_controllers_games_preferences_page_interface_init (GamesPreferencesPageIface * iface) {
	games_preferences_page_controllers_games_preferences_page_parent_iface = g_type_interface_peek_parent (iface);
	iface->visible_page_changed = (void (*) (GamesPreferencesPage *)) games_preferences_page_controllers_real_visible_page_changed;
	iface->get_header_bar = games_preferences_page_controllers_real_get_header_bar;
	iface->set_header_bar = games_preferences_page_controllers_real_set_header_bar;
	iface->get_immersive_mode = games_preferences_page_controllers_real_get_immersive_mode;
	iface->set_immersive_mode = games_preferences_page_controllers_real_set_immersive_mode;
}


static void games_preferences_page_controllers_instance_init (GamesPreferencesPageControllers * self) {
	self->priv = GAMES_PREFERENCES_PAGE_CONTROLLERS_GET_PRIVATE (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void games_preferences_page_controllers_finalize (GObject * obj) {
	GamesPreferencesPageControllers * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllers);
	_g_object_unref0 (self->priv->_header_bar);
	_g_object_unref0 (self->priv->gamepads_list_box);
	_g_object_unref0 (self->priv->extra_stack_child_holder);
	_g_object_unref0 (self->priv->default_header_bar);
	_g_object_unref0 (self->priv->gamepad_monitor);
	_g_object_unref0 (self->priv->header_bar_binding);
	_g_object_unref0 (self->priv->immersive_mode_binding);
	G_OBJECT_CLASS (games_preferences_page_controllers_parent_class)->finalize (obj);
}


GType games_preferences_page_controllers_get_type (void) {
	static volatile gsize games_preferences_page_controllers_type_id__volatile = 0;
	if (g_once_init_enter (&games_preferences_page_controllers_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesPreferencesPageControllersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_preferences_page_controllers_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPreferencesPageControllers), 0, (GInstanceInitFunc) games_preferences_page_controllers_instance_init, NULL };
		static const GInterfaceInfo games_preferences_page_info = { (GInterfaceInitFunc) games_preferences_page_controllers_games_preferences_page_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_preferences_page_controllers_type_id;
		games_preferences_page_controllers_type_id = g_type_register_static (gtk_stack_get_type (), "GamesPreferencesPageControllers", &g_define_type_info, 0);
		g_type_add_interface_static (games_preferences_page_controllers_type_id, GAMES_TYPE_PREFERENCES_PAGE, &games_preferences_page_info);
		g_once_init_leave (&games_preferences_page_controllers_type_id__volatile, games_preferences_page_controllers_type_id);
	}
	return games_preferences_page_controllers_type_id__volatile;
}


static void _vala_games_preferences_page_controllers_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GamesPreferencesPageControllers * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllers);
	switch (property_id) {
		case GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR:
		g_value_set_object (value, games_preferences_page_get_header_bar ((GamesPreferencesPage*) self));
		break;
		case GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE:
		g_value_set_boolean (value, games_preferences_page_get_immersive_mode ((GamesPreferencesPage*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_games_preferences_page_controllers_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GamesPreferencesPageControllers * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_PAGE_CONTROLLERS, GamesPreferencesPageControllers);
	switch (property_id) {
		case GAMES_PREFERENCES_PAGE_CONTROLLERS_HEADER_BAR:
		games_preferences_page_set_header_bar ((GamesPreferencesPage*) self, g_value_get_object (value));
		break;
		case GAMES_PREFERENCES_PAGE_CONTROLLERS_IMMERSIVE_MODE:
		games_preferences_page_set_immersive_mode ((GamesPreferencesPage*) self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



