/* preferences-page-controllers.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from preferences-page-controllers.vala, do not modify */

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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <handy.h>
#include <libmanette.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include "gnome-games.h"

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

#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_PREFERENCES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPageClass))
#define GAMES_IS_PREFERENCES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE))
#define GAMES_IS_PREFERENCES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_PAGE))
#define GAMES_PREFERENCES_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPageClass))

typedef struct _GamesPreferencesPage GamesPreferencesPage;
typedef struct _GamesPreferencesPageClass GamesPreferencesPageClass;
typedef struct _GamesPreferencesPagePrivate GamesPreferencesPagePrivate;

#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_0_PROPERTY,
	GAMES_PREFERENCES_PAGE_CONTROLLERS_NUM_PROPERTIES
};
static GParamSpec* games_preferences_page_controllers_properties[GAMES_PREFERENCES_PAGE_CONTROLLERS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block18Data Block18Data;

#define GAMES_TYPE_PREFERENCES_WINDOW (games_preferences_window_get_type ())
#define GAMES_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindow))
#define GAMES_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindowClass))
#define GAMES_IS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_WINDOW))
#define GAMES_IS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_WINDOW))
#define GAMES_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindowClass))

typedef struct _GamesPreferencesWindow GamesPreferencesWindow;
typedef struct _GamesPreferencesWindowClass GamesPreferencesWindowClass;

#define GAMES_TYPE_PREFERENCES_SUBPAGE (games_preferences_subpage_get_type ())
#define GAMES_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpage))
#define GAMES_IS_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE))
#define GAMES_PREFERENCES_SUBPAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpageIface))

typedef struct _GamesPreferencesSubpage GamesPreferencesSubpage;
typedef struct _GamesPreferencesSubpageIface GamesPreferencesSubpageIface;

#define GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD (games_preferences_subpage_gamepad_get_type ())
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad))
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepadClass))
#define GAMES_IS_PREFERENCES_SUBPAGE_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD))
#define GAMES_IS_PREFERENCES_SUBPAGE_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD))
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepadClass))

typedef struct _GamesPreferencesSubpageGamepad GamesPreferencesSubpageGamepad;
typedef struct _GamesPreferencesSubpageGamepadClass GamesPreferencesSubpageGamepadClass;
#define __vala_ManetteMonitorIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_ManetteMonitorIter_free (var), NULL)))

#define GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD (games_preferences_subpage_keyboard_get_type ())
#define GAMES_PREFERENCES_SUBPAGE_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD, GamesPreferencesSubpageKeyboard))
#define GAMES_PREFERENCES_SUBPAGE_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD, GamesPreferencesSubpageKeyboardClass))
#define GAMES_IS_PREFERENCES_SUBPAGE_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD))
#define GAMES_IS_PREFERENCES_SUBPAGE_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD))
#define GAMES_PREFERENCES_SUBPAGE_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_KEYBOARD, GamesPreferencesSubpageKeyboardClass))

typedef struct _GamesPreferencesSubpageKeyboard GamesPreferencesSubpageKeyboard;
typedef struct _GamesPreferencesSubpageKeyboardClass GamesPreferencesSubpageKeyboardClass;

struct _GamesPreferencesPage {
	GtkBin parent_instance;
	GamesPreferencesPagePrivate * priv;
};

struct _GamesPreferencesPageClass {
	GtkBinClass parent_class;
};

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

struct _GamesPreferencesPageControllersClass {
	GamesPreferencesPageClass parent_class;
};

struct _GamesPreferencesPageControllersPrivate {
	HdyPreferencesGroup* gamepads_group;
	HdyPreferencesGroup* keyboard_group;
	ManetteMonitor* monitor;
};

struct _Block18Data {
	int _ref_count_;
	GamesPreferencesPageControllers* self;
	ManetteDevice* this_device;
};

struct _GamesPreferencesSubpageIface {
	GTypeInterface parent_iface;
	gboolean (*get_allow_back) (GamesPreferencesSubpage* self);
	void (*set_allow_back) (GamesPreferencesSubpage* self, gboolean value);
};

static gint GamesPreferencesPageControllers_private_offset;
static gpointer games_preferences_page_controllers_parent_class = NULL;

VALA_EXTERN GType games_preferences_page_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_preferences_page_controllers_get_type (void) G_GNUC_CONST ;
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 Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static void ___lambda84_ (Block18Data* _data18_);
VALA_EXTERN GType games_preferences_window_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesPreferencesWindow* games_preferences_page_get_window (GamesPreferencesPage* self);
VALA_EXTERN GType games_preferences_subpage_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void games_preferences_window_open_subpage (GamesPreferencesWindow* self,
                                            GamesPreferencesSubpage* subpage);
VALA_EXTERN GamesPreferencesSubpageGamepad* games_preferences_subpage_gamepad_new (ManetteDevice* device);
VALA_EXTERN GamesPreferencesSubpageGamepad* games_preferences_subpage_gamepad_construct (GType object_type,
                                                                             ManetteDevice* device);
VALA_EXTERN GType games_preferences_subpage_gamepad_get_type (void) G_GNUC_CONST ;
static void ____lambda84__hdy_action_row_activated (HdyActionRow* _sender,
                                             gpointer self);
static void _vala_ManetteMonitorIter_free (ManetteMonitorIter* self);
static void __lambda83_ (GamesPreferencesPageControllers* self,
                  GtkWidget* child);
static void ___lambda83__gtk_callback (GtkWidget* widget,
                                gpointer self);
static void games_preferences_page_controllers_build_keyboard_list (GamesPreferencesPageControllers* self);
static void __lambda86_ (GamesPreferencesPageControllers* self);
VALA_EXTERN GamesPreferencesSubpageKeyboard* games_preferences_subpage_keyboard_new (void);
VALA_EXTERN GamesPreferencesSubpageKeyboard* games_preferences_subpage_keyboard_construct (GType object_type);
VALA_EXTERN GType games_preferences_subpage_keyboard_get_type (void) G_GNUC_CONST ;
static void ___lambda86__hdy_action_row_activated (HdyActionRow* _sender,
                                            gpointer self);
VALA_EXTERN GamesPreferencesPageControllers* games_preferences_page_controllers_new (void);
VALA_EXTERN GamesPreferencesPageControllers* games_preferences_page_controllers_construct (GType object_type);
VALA_EXTERN GamesPreferencesPage* games_preferences_page_new (void);
VALA_EXTERN GamesPreferencesPage* games_preferences_page_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_manette_monitor_device_connected (ManetteMonitor* _sender,
                                                                                                ManetteDevice* device,
                                                                                                gpointer self);
static void _games_preferences_page_controllers_rebuild_gamepad_list_manette_monitor_device_disconnected (ManetteMonitor* _sender,
                                                                                                   ManetteDevice* device,
                                                                                                   gpointer self);
static void games_preferences_page_controllers_finalize (GObject * obj);
static GType games_preferences_page_controllers_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_preferences_page_controllers_get_instance_private (GamesPreferencesPageControllers* self)
{
	return G_STRUCT_MEMBER_P (self, GamesPreferencesPageControllers_private_offset);
}

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 Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		GamesPreferencesPageControllers* self;
		self = _data18_->self;
		_g_object_unref0 (_data18_->this_device);
		_g_object_unref0 (self);
		g_slice_free (Block18Data, _data18_);
	}
}

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

static void
___lambda84_ (Block18Data* _data18_)
{
	GamesPreferencesPageControllers* self;
	GamesPreferencesWindow* _tmp0_;
	GamesPreferencesWindow* _tmp1_;
	ManetteDevice* _tmp2_;
	GamesPreferencesSubpageGamepad* _tmp3_;
	GamesPreferencesSubpageGamepad* _tmp4_;
	self = _data18_->self;
	_tmp0_ = games_preferences_page_get_window ((GamesPreferencesPage*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _data18_->this_device;
	_tmp3_ = games_preferences_subpage_gamepad_new (_tmp2_);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	games_preferences_window_open_subpage (_tmp1_, (GamesPreferencesSubpage*) _tmp4_);
	_g_object_unref0 (_tmp4_);
}

static void
____lambda84__hdy_action_row_activated (HdyActionRow* _sender,
                                        gpointer self)
{
	___lambda84_ (self);
}

static void
_vala_ManetteMonitorIter_free (ManetteMonitorIter* self)
{
	g_boxed_free (manette_monitor_iter_get_type (), self);
}

static void
games_preferences_page_controllers_build_gamepad_list (GamesPreferencesPageControllers* self)
{
	ManetteDevice* device = NULL;
	gint i = 0;
	ManetteMonitorIter* iterator = NULL;
	ManetteMonitor* _tmp0_;
	ManetteMonitorIter* _tmp1_;
	HdyPreferencesGroup* _tmp20_;
	g_return_if_fail (self != NULL);
	device = NULL;
	i = 0;
	_tmp0_ = self->priv->monitor;
	_tmp1_ = manette_monitor_iterate (_tmp0_);
	iterator = _tmp1_;
	while (TRUE) {
		Block18Data* _data18_;
		ManetteMonitorIter* _tmp2_;
		ManetteDevice* _tmp3_ = NULL;
		gboolean _tmp4_;
		ManetteDevice* _tmp5_;
		HdyActionRow* row = NULL;
		HdyActionRow* _tmp6_;
		HdyActionRow* _tmp7_;
		ManetteDevice* _tmp8_;
		const gchar* _tmp9_;
		HdyActionRow* _tmp10_;
		GtkImage* _tmp11_;
		GtkImage* _tmp12_;
		HdyActionRow* _tmp13_;
		ManetteDevice* _tmp14_;
		ManetteDevice* _tmp15_;
		HdyActionRow* _tmp16_;
		HdyActionRow* _tmp17_;
		HdyPreferencesGroup* _tmp18_;
		HdyActionRow* _tmp19_;
		_data18_ = g_slice_new0 (Block18Data);
		_data18_->_ref_count_ = 1;
		_data18_->self = g_object_ref (self);
		_tmp2_ = iterator;
		_tmp4_ = manette_monitor_iter_next (_tmp2_, &_tmp3_);
		_g_object_unref0 (device);
		_tmp5_ = _g_object_ref0 (_tmp3_);
		device = _tmp5_;
		if (!_tmp4_) {
			block18_data_unref (_data18_);
			_data18_ = NULL;
			break;
		}
		_tmp6_ = (HdyActionRow*) hdy_action_row_new ();
		g_object_ref_sink (_tmp6_);
		row = _tmp6_;
		_tmp7_ = row;
		_tmp8_ = device;
		_tmp9_ = manette_device_get_name (_tmp8_);
		hdy_preferences_row_set_title ((HdyPreferencesRow*) _tmp7_, _tmp9_);
		_tmp10_ = row;
		_tmp11_ = (GtkImage*) gtk_image_new_from_icon_name ("go-next-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
		g_object_ref_sink (_tmp11_);
		_tmp12_ = _tmp11_;
		gtk_container_add ((GtkContainer*) _tmp10_, (GtkWidget*) _tmp12_);
		_g_object_unref0 (_tmp12_);
		_tmp13_ = row;
		gtk_list_box_row_set_activatable ((GtkListBoxRow*) _tmp13_, TRUE);
		_tmp14_ = device;
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_data18_->this_device = _tmp15_;
		_tmp16_ = row;
		g_signal_connect_data (_tmp16_, "activated", (GCallback) ____lambda84__hdy_action_row_activated, block18_data_ref (_data18_), (GClosureNotify) block18_data_unref, 0);
		_tmp17_ = row;
		gtk_widget_show_all ((GtkWidget*) _tmp17_);
		_tmp18_ = self->priv->gamepads_group;
		_tmp19_ = row;
		gtk_container_add ((GtkContainer*) _tmp18_, (GtkWidget*) _tmp19_);
		i += 1;
		_g_object_unref0 (row);
		block18_data_unref (_data18_);
		_data18_ = NULL;
	}
	_tmp20_ = self->priv->gamepads_group;
	gtk_widget_set_visible ((GtkWidget*) _tmp20_, i > 0);
	__vala_ManetteMonitorIter_free0 (iterator);
	_g_object_unref0 (device);
}

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

static void
___lambda83__gtk_callback (GtkWidget* widget,
                           gpointer self)
{
	__lambda83_ ((GamesPreferencesPageControllers*) self, widget);
}

static void
games_preferences_page_controllers_clear_gamepad_list (GamesPreferencesPageControllers* self)
{
	HdyPreferencesGroup* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->gamepads_group;
	gtk_container_foreach ((GtkContainer*) _tmp0_, ___lambda83__gtk_callback, self);
}

static void
__lambda86_ (GamesPreferencesPageControllers* self)
{
	GamesPreferencesWindow* _tmp0_;
	GamesPreferencesWindow* _tmp1_;
	GamesPreferencesSubpageKeyboard* _tmp2_;
	GamesPreferencesSubpageKeyboard* _tmp3_;
	_tmp0_ = games_preferences_page_get_window ((GamesPreferencesPage*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = games_preferences_subpage_keyboard_new ();
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	games_preferences_window_open_subpage (_tmp1_, (GamesPreferencesSubpage*) _tmp3_);
	_g_object_unref0 (_tmp3_);
}

static void
___lambda86__hdy_action_row_activated (HdyActionRow* _sender,
                                       gpointer self)
{
	__lambda86_ ((GamesPreferencesPageControllers*) self);
}

static void
games_preferences_page_controllers_build_keyboard_list (GamesPreferencesPageControllers* self)
{
	HdyActionRow* row = NULL;
	HdyActionRow* _tmp0_;
	GtkImage* _tmp1_;
	GtkImage* _tmp2_;
	HdyPreferencesGroup* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (HdyActionRow*) hdy_action_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	hdy_preferences_row_set_title ((HdyPreferencesRow*) row, _ ("Keyboard"));
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("go-next-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_container_add ((GtkContainer*) row, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) row, TRUE);
	g_signal_connect_object (row, "activated", (GCallback) ___lambda86__hdy_action_row_activated, self, 0);
	gtk_widget_show_all ((GtkWidget*) row);
	_tmp3_ = self->priv->keyboard_group;
	gtk_container_add ((GtkContainer*) _tmp3_, (GtkWidget*) row);
	_g_object_unref0 (row);
}

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

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

static void
_games_preferences_page_controllers_rebuild_gamepad_list_manette_monitor_device_connected (ManetteMonitor* _sender,
                                                                                           ManetteDevice* device,
                                                                                           gpointer self)
{
	games_preferences_page_controllers_rebuild_gamepad_list ((GamesPreferencesPageControllers*) self);
}

static void
_games_preferences_page_controllers_rebuild_gamepad_list_manette_monitor_device_disconnected (ManetteMonitor* _sender,
                                                                                              ManetteDevice* device,
                                                                                              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;
	ManetteMonitor* _tmp0_;
	ManetteMonitor* _tmp1_;
	ManetteMonitor* _tmp2_;
	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_ = manette_monitor_new ();
	_g_object_unref0 (self->priv->monitor);
	self->priv->monitor = _tmp0_;
	_tmp1_ = self->priv->monitor;
	g_signal_connect_object (_tmp1_, "device-connected", (GCallback) _games_preferences_page_controllers_rebuild_gamepad_list_manette_monitor_device_connected, self, 0);
	_tmp2_ = self->priv->monitor;
	g_signal_connect_object (_tmp2_, "device-disconnected", (GCallback) _games_preferences_page_controllers_rebuild_gamepad_list_manette_monitor_device_disconnected, self, 0);
	games_preferences_page_controllers_build_gamepad_list (self);
	games_preferences_page_controllers_build_keyboard_list (self);
	return obj;
}

static void
games_preferences_page_controllers_class_init (GamesPreferencesPageControllersClass * klass,
                                               gpointer klass_data)
{
	games_preferences_page_controllers_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesPreferencesPageControllers_private_offset);
	G_OBJECT_CLASS (klass)->constructor = games_preferences_page_controllers_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_preferences_page_controllers_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/preferences/preferences-page-controllers.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gamepads_group", FALSE, GamesPreferencesPageControllers_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageControllersPrivate, gamepads_group));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "keyboard_group", FALSE, GamesPreferencesPageControllers_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageControllersPrivate, keyboard_group));
}

static void
games_preferences_page_controllers_instance_init (GamesPreferencesPageControllers * self,
                                                  gpointer klass)
{
	self->priv = games_preferences_page_controllers_get_instance_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->monitor);
	G_OBJECT_CLASS (games_preferences_page_controllers_parent_class)->finalize (obj);
}

static GType
games_preferences_page_controllers_get_type_once (void)
{
	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 };
	GType games_preferences_page_controllers_type_id;
	games_preferences_page_controllers_type_id = g_type_register_static (GAMES_TYPE_PREFERENCES_PAGE, "GamesPreferencesPageControllers", &g_define_type_info, 0);
	GamesPreferencesPageControllers_private_offset = g_type_add_instance_private (games_preferences_page_controllers_type_id, sizeof (GamesPreferencesPageControllersPrivate));
	return games_preferences_page_controllers_type_id;
}

GType
games_preferences_page_controllers_get_type (void)
{
	static volatile gsize games_preferences_page_controllers_type_id__once = 0;
	if (g_once_init_enter (&games_preferences_page_controllers_type_id__once)) {
		GType games_preferences_page_controllers_type_id;
		games_preferences_page_controllers_type_id = games_preferences_page_controllers_get_type_once ();
		g_once_init_leave (&games_preferences_page_controllers_type_id__once, games_preferences_page_controllers_type_id);
	}
	return games_preferences_page_controllers_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

