/* nintendo-64-pak-controller.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from nintendo-64-pak-controller.vala, do not modify */

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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <retro-gtk.h>
#include <glib.h>
#include "games-nintendo-64-plugin.h"
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.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_NINTENDO64_PAK_CONTROLLER (games_nintendo64_pak_controller_get_type ())
#define GAMES_NINTENDO64_PAK_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakController))
#define GAMES_NINTENDO64_PAK_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakControllerClass))
#define GAMES_IS_NINTENDO64_PAK_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_NINTENDO64_PAK_CONTROLLER))
#define GAMES_IS_NINTENDO64_PAK_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_NINTENDO64_PAK_CONTROLLER))
#define GAMES_NINTENDO64_PAK_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakControllerClass))

typedef struct _GamesNintendo64PakController GamesNintendo64PakController;
typedef struct _GamesNintendo64PakControllerClass GamesNintendo64PakControllerClass;
typedef struct _GamesNintendo64PakControllerPrivate GamesNintendo64PakControllerPrivate;
enum  {
	GAMES_NINTENDO64_PAK_CONTROLLER_0_PROPERTY,
	GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY,
	GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY,
	GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY,
	GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY,
	GAMES_NINTENDO64_PAK_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesNintendo64PakController {
	GtkBox parent_instance;
	GamesNintendo64PakControllerPrivate * priv;
};

struct _GamesNintendo64PakControllerClass {
	GtkBoxClass parent_class;
};

struct _GamesNintendo64PakControllerPrivate {
	GtkLabel* title;
	GtkModelButton* memory_btn;
	GtkModelButton* rumble_btn;
	RetroController* _gamepad;
	guint _port;
	gboolean _show_title;
	GamesNintendo64Pak _pak;
};

static gint GamesNintendo64PakController_private_offset;
static gpointer games_nintendo64_pak_controller_parent_class = NULL;
static GType games_nintendo64_pak_controller_type_id = 0;

GType games_nintendo64_pak_controller_register_type (GTypeModule * module);
VALA_EXTERN GType games_nintendo64_pak_controller_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesNintendo64PakController* games_nintendo64_pak_controller_new (RetroController* gamepad,
                                                                   guint port);
VALA_EXTERN GamesNintendo64PakController* games_nintendo64_pak_controller_construct (GType object_type,
                                                                         RetroController* gamepad,
                                                                         guint port);
VALA_EXTERN void games_nintendo64_pak_controller_memory_btn_clicked (GamesNintendo64PakController* self);
VALA_EXTERN void games_nintendo64_pak_controller_set_pak (GamesNintendo64PakController* self,
                                              GamesNintendo64Pak value);
static void _games_nintendo64_pak_controller_memory_btn_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                             gpointer self);
VALA_EXTERN void games_nintendo64_pak_controller_rumble_btn_clicked (GamesNintendo64PakController* self);
static void _games_nintendo64_pak_controller_rumble_btn_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                             gpointer self);
VALA_EXTERN RetroController* games_nintendo64_pak_controller_get_gamepad (GamesNintendo64PakController* self);
static void games_nintendo64_pak_controller_set_gamepad (GamesNintendo64PakController* self,
                                                  RetroController* value);
VALA_EXTERN guint games_nintendo64_pak_controller_get_port (GamesNintendo64PakController* self);
static void games_nintendo64_pak_controller_set_port (GamesNintendo64PakController* self,
                                               guint value);
VALA_EXTERN gboolean games_nintendo64_pak_controller_get_show_title (GamesNintendo64PakController* self);
VALA_EXTERN void games_nintendo64_pak_controller_set_show_title (GamesNintendo64PakController* self,
                                                     gboolean value);
VALA_EXTERN GamesNintendo64Pak games_nintendo64_pak_controller_get_pak (GamesNintendo64PakController* self);
static GObject * games_nintendo64_pak_controller_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void games_nintendo64_pak_controller_finalize (GObject * obj);
static void _vala_games_nintendo64_pak_controller_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_games_nintendo64_pak_controller_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);

static inline gpointer
games_nintendo64_pak_controller_get_instance_private (GamesNintendo64PakController* self)
{
	return G_STRUCT_MEMBER_P (self, GamesNintendo64PakController_private_offset);
}

GamesNintendo64PakController*
games_nintendo64_pak_controller_construct (GType object_type,
                                           RetroController* gamepad,
                                           guint port)
{
	GamesNintendo64PakController * self = NULL;
	g_return_val_if_fail (gamepad != NULL, NULL);
	self = (GamesNintendo64PakController*) g_object_new (object_type, "gamepad", gamepad, "port", port, NULL);
	return self;
}

GamesNintendo64PakController*
games_nintendo64_pak_controller_new (RetroController* gamepad,
                                     guint port)
{
	return games_nintendo64_pak_controller_construct (GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, gamepad, port);
}

void
games_nintendo64_pak_controller_memory_btn_clicked (GamesNintendo64PakController* self)
{
	g_return_if_fail (self != NULL);
	games_nintendo64_pak_controller_set_pak (self, GAMES_NINTENDO64_PAK_MEMORY);
}

static void
_games_nintendo64_pak_controller_memory_btn_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                        gpointer self)
{
	games_nintendo64_pak_controller_memory_btn_clicked ((GamesNintendo64PakController*) self);
}

void
games_nintendo64_pak_controller_rumble_btn_clicked (GamesNintendo64PakController* self)
{
	g_return_if_fail (self != NULL);
	games_nintendo64_pak_controller_set_pak (self, GAMES_NINTENDO64_PAK_RUMBLE);
}

static void
_games_nintendo64_pak_controller_rumble_btn_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                        gpointer self)
{
	games_nintendo64_pak_controller_rumble_btn_clicked ((GamesNintendo64PakController*) self);
}

RetroController*
games_nintendo64_pak_controller_get_gamepad (GamesNintendo64PakController* self)
{
	RetroController* result;
	RetroController* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_gamepad;
	result = _tmp0_;
	return result;
}

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

static void
games_nintendo64_pak_controller_set_gamepad (GamesNintendo64PakController* self,
                                             RetroController* value)
{
	RetroController* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_nintendo64_pak_controller_get_gamepad (self);
	if (old_value != value) {
		RetroController* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_gamepad);
		self->priv->_gamepad = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY]);
	}
}

guint
games_nintendo64_pak_controller_get_port (GamesNintendo64PakController* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_port;
	return result;
}

static void
games_nintendo64_pak_controller_set_port (GamesNintendo64PakController* self,
                                          guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = games_nintendo64_pak_controller_get_port (self);
	if (old_value != value) {
		self->priv->_port = value;
		g_object_notify_by_pspec ((GObject *) self, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY]);
	}
}

gboolean
games_nintendo64_pak_controller_get_show_title (GamesNintendo64PakController* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_show_title;
	return result;
}

void
games_nintendo64_pak_controller_set_show_title (GamesNintendo64PakController* self,
                                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_nintendo64_pak_controller_get_show_title (self);
	if (old_value != value) {
		self->priv->_show_title = value;
		g_object_notify_by_pspec ((GObject *) self, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY]);
	}
}

GamesNintendo64Pak
games_nintendo64_pak_controller_get_pak (GamesNintendo64PakController* self)
{
	GamesNintendo64Pak result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_pak;
	return result;
}

void
games_nintendo64_pak_controller_set_pak (GamesNintendo64PakController* self,
                                         GamesNintendo64Pak value)
{
	GtkModelButton* _tmp0_;
	GamesNintendo64Pak _tmp1_;
	GamesNintendo64Pak _tmp2_;
	GtkModelButton* _tmp3_;
	GamesNintendo64Pak _tmp4_;
	GamesNintendo64Pak _tmp5_;
	g_return_if_fail (self != NULL);
	self->priv->_pak = value;
	_tmp0_ = self->priv->memory_btn;
	_tmp1_ = games_nintendo64_pak_controller_get_pak (self);
	_tmp2_ = _tmp1_;
	g_object_set (_tmp0_, "active", _tmp2_ == GAMES_NINTENDO64_PAK_MEMORY, NULL);
	_tmp3_ = self->priv->rumble_btn;
	_tmp4_ = games_nintendo64_pak_controller_get_pak (self);
	_tmp5_ = _tmp4_;
	g_object_set (_tmp3_, "active", _tmp5_ == GAMES_NINTENDO64_PAK_RUMBLE, NULL);
	g_object_notify_by_pspec ((GObject *) self, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY]);
}

static GObject *
games_nintendo64_pak_controller_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesNintendo64PakController * self;
	GtkLabel* _tmp0_;
	guint _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkModelButton* _tmp4_;
	RetroController* _tmp5_;
	parent_class = G_OBJECT_CLASS (games_nintendo64_pak_controller_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakController);
	_tmp0_ = self->priv->title;
	_tmp1_ = self->priv->_port;
	_tmp2_ = g_strdup_printf (_ ("Player %u"), _tmp1_ + 1);
	_tmp3_ = _tmp2_;
	gtk_label_set_label (_tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
	_tmp4_ = self->priv->rumble_btn;
	_tmp5_ = self->priv->_gamepad;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, retro_controller_get_supports_rumble (_tmp5_));
	return obj;
}

static void
games_nintendo64_pak_controller_class_init (GamesNintendo64PakControllerClass * klass,
                                            gpointer klass_data)
{
	games_nintendo64_pak_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesNintendo64PakController_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_nintendo64_pak_controller_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_nintendo64_pak_controller_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_nintendo64_pak_controller_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_nintendo64_pak_controller_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY] = g_param_spec_object ("gamepad", "gamepad", "gamepad", retro_controller_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY] = g_param_spec_uint ("port", "port", "port", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY] = g_param_spec_boolean ("show-title", "show-title", "show-title", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY, games_nintendo64_pak_controller_properties[GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY] = g_param_spec_enum ("pak", "pak", "pak", GAMES_TYPE_NINTENDO64_PAK, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/plugins/nintendo-64/nintendo-64-pak-controller.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title", FALSE, GamesNintendo64PakController_private_offset + G_STRUCT_OFFSET (GamesNintendo64PakControllerPrivate, title));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "memory_btn", FALSE, GamesNintendo64PakController_private_offset + G_STRUCT_OFFSET (GamesNintendo64PakControllerPrivate, memory_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "rumble_btn", FALSE, GamesNintendo64PakController_private_offset + G_STRUCT_OFFSET (GamesNintendo64PakControllerPrivate, rumble_btn));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "memory_btn_clicked", G_CALLBACK(_games_nintendo64_pak_controller_memory_btn_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "rumble_btn_clicked", G_CALLBACK(_games_nintendo64_pak_controller_rumble_btn_clicked_gtk_button_clicked));
}

static void
games_nintendo64_pak_controller_instance_init (GamesNintendo64PakController * self,
                                               gpointer klass)
{
	self->priv = games_nintendo64_pak_controller_get_instance_private (self);
	self->priv->_show_title = TRUE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_nintendo64_pak_controller_finalize (GObject * obj)
{
	GamesNintendo64PakController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakController);
	_g_object_unref0 (self->priv->_gamepad);
	G_OBJECT_CLASS (games_nintendo64_pak_controller_parent_class)->finalize (obj);
}

GType
games_nintendo64_pak_controller_get_type (void)
{
	return games_nintendo64_pak_controller_type_id;
}

GType
games_nintendo64_pak_controller_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesNintendo64PakControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_nintendo64_pak_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesNintendo64PakController), 0, (GInstanceInitFunc) games_nintendo64_pak_controller_instance_init, NULL };
	games_nintendo64_pak_controller_type_id = g_type_module_register_type (module, gtk_box_get_type (), "GamesNintendo64PakController", &g_define_type_info, 0);
	GamesNintendo64PakController_private_offset = sizeof (GamesNintendo64PakControllerPrivate);
	return games_nintendo64_pak_controller_type_id;
}

static void
_vala_games_nintendo64_pak_controller_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	GamesNintendo64PakController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakController);
	switch (property_id) {
		case GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY:
		g_value_set_object (value, games_nintendo64_pak_controller_get_gamepad (self));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY:
		g_value_set_uint (value, games_nintendo64_pak_controller_get_port (self));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY:
		g_value_set_boolean (value, games_nintendo64_pak_controller_get_show_title (self));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY:
		g_value_set_enum (value, games_nintendo64_pak_controller_get_pak (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_nintendo64_pak_controller_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	GamesNintendo64PakController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_NINTENDO64_PAK_CONTROLLER, GamesNintendo64PakController);
	switch (property_id) {
		case GAMES_NINTENDO64_PAK_CONTROLLER_GAMEPAD_PROPERTY:
		games_nintendo64_pak_controller_set_gamepad (self, g_value_get_object (value));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_PORT_PROPERTY:
		games_nintendo64_pak_controller_set_port (self, g_value_get_uint (value));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_SHOW_TITLE_PROPERTY:
		games_nintendo64_pak_controller_set_show_title (self, g_value_get_boolean (value));
		break;
		case GAMES_NINTENDO64_PAK_CONTROLLER_PAK_PROPERTY:
		games_nintendo64_pak_controller_set_pak (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

