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

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

#include "games-nintendo-ds-plugin.h"
#include "gnome-games.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.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

enum  {
	GAMES_NINTENDO_DS_SNAPSHOT_0_PROPERTY,
	GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY,
	GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY,
	GAMES_NINTENDO_DS_SNAPSHOT_NUM_PROPERTIES
};
static GParamSpec* games_nintendo_ds_snapshot_properties[GAMES_NINTENDO_DS_SNAPSHOT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesNintendoDsSnapshotPrivate {
	GamesScreenLayout _screen_layout;
	gboolean _view_bottom_screen;
};

static gint GamesNintendoDsSnapshot_private_offset;
static gpointer games_nintendo_ds_snapshot_parent_class = NULL;
static GType games_nintendo_ds_snapshot_type_id = 0;

static void games_nintendo_ds_snapshot_real_load_metadata (GamesSnapshot* base,
                                                    GKeyFile* keyfile,
                                                    GError** error);
VALA_EXTERN GamesScreenLayout* games_nintendo_ds_layout_from_value (const gchar* value);
static void games_nintendo_ds_snapshot_real_save_metadata (GamesSnapshot* base,
                                                    GKeyFile* keyfile);
VALA_EXTERN gchar* games_nintendo_ds_layout_get_value (GamesScreenLayout layout);
static void games_nintendo_ds_snapshot_finalize (GObject * obj);
static void _vala_games_nintendo_ds_snapshot_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_games_nintendo_ds_snapshot_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
games_nintendo_ds_snapshot_get_instance_private (GamesNintendoDsSnapshot* self)
{
	return G_STRUCT_MEMBER_P (self, GamesNintendoDsSnapshot_private_offset);
}

static void
games_nintendo_ds_snapshot_real_load_metadata (GamesSnapshot* base,
                                               GKeyFile* keyfile,
                                               GError** error)
{
	GamesNintendoDsSnapshot * self;
	gchar* layout_value = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	GamesScreenLayout* _tmp3_;
	GamesScreenLayout* _tmp4_;
	GError* _inner_error0_ = NULL;
	self = (GamesNintendoDsSnapshot*) base;
	g_return_if_fail (keyfile != NULL);
	GAMES_SNAPSHOT_CLASS (games_nintendo_ds_snapshot_parent_class)->load_metadata (G_TYPE_CHECK_INSTANCE_CAST (self, GAMES_TYPE_SNAPSHOT, GamesSnapshot), keyfile, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_KEY_FILE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp0_ = g_key_file_get_string (keyfile, "Nintendo DS", "Screen Layout", &_inner_error0_);
	layout_value = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_KEY_FILE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp1_ = g_key_file_get_boolean (keyfile, "Nintendo DS", "View Bottom Screen", &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_KEY_FILE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (layout_value);
			return;
		} else {
			_g_free0 (layout_value);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	games_nintendo_ds_snapshot_set_view_bottom_screen (self, _tmp1_);
	_tmp2_ = layout_value;
	_tmp3_ = games_nintendo_ds_layout_from_value (_tmp2_);
	_tmp4_ = _tmp3_;
	games_nintendo_ds_snapshot_set_screen_layout (self, *_tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (layout_value);
}

static void
games_nintendo_ds_snapshot_real_save_metadata (GamesSnapshot* base,
                                               GKeyFile* keyfile)
{
	GamesNintendoDsSnapshot * self;
	GamesScreenLayout _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_;
	self = (GamesNintendoDsSnapshot*) base;
	g_return_if_fail (keyfile != NULL);
	GAMES_SNAPSHOT_CLASS (games_nintendo_ds_snapshot_parent_class)->save_metadata (G_TYPE_CHECK_INSTANCE_CAST (self, GAMES_TYPE_SNAPSHOT, GamesSnapshot), keyfile);
	_tmp0_ = self->priv->_screen_layout;
	_tmp1_ = games_nintendo_ds_layout_get_value (_tmp0_);
	_tmp2_ = _tmp1_;
	g_key_file_set_string (keyfile, "Nintendo DS", "Screen Layout", _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->_view_bottom_screen;
	g_key_file_set_boolean (keyfile, "Nintendo DS", "View Bottom Screen", _tmp3_);
}

GamesNintendoDsSnapshot*
games_nintendo_ds_snapshot_construct (GType object_type)
{
	GamesNintendoDsSnapshot * self = NULL;
	self = (GamesNintendoDsSnapshot*) games_snapshot_construct (object_type);
	return self;
}

GamesNintendoDsSnapshot*
games_nintendo_ds_snapshot_new (void)
{
	return games_nintendo_ds_snapshot_construct (GAMES_TYPE_NINTENDO_DS_SNAPSHOT);
}

GamesScreenLayout
games_nintendo_ds_snapshot_get_screen_layout (GamesNintendoDsSnapshot* self)
{
	GamesScreenLayout result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_screen_layout;
	return result;
}

void
games_nintendo_ds_snapshot_set_screen_layout (GamesNintendoDsSnapshot* self,
                                              GamesScreenLayout value)
{
	GamesScreenLayout old_value;
	g_return_if_fail (self != NULL);
	old_value = games_nintendo_ds_snapshot_get_screen_layout (self);
	if (old_value != value) {
		self->priv->_screen_layout = value;
		g_object_notify_by_pspec ((GObject *) self, games_nintendo_ds_snapshot_properties[GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY]);
	}
}

gboolean
games_nintendo_ds_snapshot_get_view_bottom_screen (GamesNintendoDsSnapshot* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_view_bottom_screen;
	return result;
}

void
games_nintendo_ds_snapshot_set_view_bottom_screen (GamesNintendoDsSnapshot* self,
                                                   gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_nintendo_ds_snapshot_get_view_bottom_screen (self);
	if (old_value != value) {
		self->priv->_view_bottom_screen = value;
		g_object_notify_by_pspec ((GObject *) self, games_nintendo_ds_snapshot_properties[GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY]);
	}
}

static void
games_nintendo_ds_snapshot_class_init (GamesNintendoDsSnapshotClass * klass,
                                       gpointer klass_data)
{
	games_nintendo_ds_snapshot_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesNintendoDsSnapshot_private_offset);
	((GamesSnapshotClass *) klass)->load_metadata = (void (*) (GamesSnapshot*, GKeyFile*, GError**)) games_nintendo_ds_snapshot_real_load_metadata;
	((GamesSnapshotClass *) klass)->save_metadata = (void (*) (GamesSnapshot*, GKeyFile*)) games_nintendo_ds_snapshot_real_save_metadata;
	G_OBJECT_CLASS (klass)->get_property = _vala_games_nintendo_ds_snapshot_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_nintendo_ds_snapshot_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_nintendo_ds_snapshot_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY, games_nintendo_ds_snapshot_properties[GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY] = g_param_spec_enum ("screen-layout", "screen-layout", "screen-layout", GAMES_TYPE_SCREEN_LAYOUT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY, games_nintendo_ds_snapshot_properties[GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY] = g_param_spec_boolean ("view-bottom-screen", "view-bottom-screen", "view-bottom-screen", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
games_nintendo_ds_snapshot_instance_init (GamesNintendoDsSnapshot * self,
                                          gpointer klass)
{
	self->priv = games_nintendo_ds_snapshot_get_instance_private (self);
}

static void
games_nintendo_ds_snapshot_finalize (GObject * obj)
{
	GamesNintendoDsSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_NINTENDO_DS_SNAPSHOT, GamesNintendoDsSnapshot);
	G_OBJECT_CLASS (games_nintendo_ds_snapshot_parent_class)->finalize (obj);
}

GType
games_nintendo_ds_snapshot_get_type (void)
{
	return games_nintendo_ds_snapshot_type_id;
}

GType
games_nintendo_ds_snapshot_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesNintendoDsSnapshotClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_nintendo_ds_snapshot_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesNintendoDsSnapshot), 0, (GInstanceInitFunc) games_nintendo_ds_snapshot_instance_init, NULL };
	games_nintendo_ds_snapshot_type_id = g_type_module_register_type (module, GAMES_TYPE_SNAPSHOT, "GamesNintendoDsSnapshot", &g_define_type_info, 0);
	GamesNintendoDsSnapshot_private_offset = sizeof (GamesNintendoDsSnapshotPrivate);
	return games_nintendo_ds_snapshot_type_id;
}

static void
_vala_games_nintendo_ds_snapshot_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GamesNintendoDsSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_NINTENDO_DS_SNAPSHOT, GamesNintendoDsSnapshot);
	switch (property_id) {
		case GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY:
		g_value_set_enum (value, games_nintendo_ds_snapshot_get_screen_layout (self));
		break;
		case GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY:
		g_value_set_boolean (value, games_nintendo_ds_snapshot_get_view_bottom_screen (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_nintendo_ds_snapshot_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GamesNintendoDsSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_NINTENDO_DS_SNAPSHOT, GamesNintendoDsSnapshot);
	switch (property_id) {
		case GAMES_NINTENDO_DS_SNAPSHOT_SCREEN_LAYOUT_PROPERTY:
		games_nintendo_ds_snapshot_set_screen_layout (self, g_value_get_enum (value));
		break;
		case GAMES_NINTENDO_DS_SNAPSHOT_VIEW_BOTTOM_SCREEN_PROPERTY:
		games_nintendo_ds_snapshot_set_view_bottom_screen (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

