/* gameinfo-disc-id-game-title.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from gameinfo-disc-id-game-title.vala, do not modify */

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

#include "gnome-games.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.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_GAMEINFO_DISC_ID_GAME_TITLE_0_PROPERTY,
	GAMES_GAMEINFO_DISC_ID_GAME_TITLE_NUM_PROPERTIES
};
static GParamSpec* games_gameinfo_disc_id_game_title_properties[GAMES_GAMEINFO_DISC_ID_GAME_TITLE_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 _GamesGameinfoDiscIdGameTitlePrivate {
	GamesGameinfoDoc* gameinfo;
	gchar* disc_id;
	gchar* domain;
	gchar* title;
};

static gint GamesGameinfoDiscIdGameTitle_private_offset;
static gpointer games_gameinfo_disc_id_game_title_parent_class = NULL;
static GamesTitleIface * games_gameinfo_disc_id_game_title_games_title_parent_iface = NULL;

static gchar* games_gameinfo_disc_id_game_title_real_get_title (GamesTitle* base,
                                                         GError** error);
static void games_gameinfo_disc_id_game_title_finalize (GObject * obj);
static GType games_gameinfo_disc_id_game_title_get_type_once (void);

static inline gpointer
games_gameinfo_disc_id_game_title_get_instance_private (GamesGameinfoDiscIdGameTitle* self)
{
	return G_STRUCT_MEMBER_P (self, GamesGameinfoDiscIdGameTitle_private_offset);
}

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

GamesGameinfoDiscIdGameTitle*
games_gameinfo_disc_id_game_title_construct (GType object_type,
                                             GamesGameinfoDoc* gameinfo,
                                             const gchar* disc_id,
                                             const gchar* domain)
{
	GamesGameinfoDiscIdGameTitle * self = NULL;
	GamesGameinfoDoc* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (gameinfo != NULL, NULL);
	g_return_val_if_fail (disc_id != NULL, NULL);
	self = (GamesGameinfoDiscIdGameTitle*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (gameinfo);
	_g_object_unref0 (self->priv->gameinfo);
	self->priv->gameinfo = _tmp0_;
	_tmp1_ = g_strdup (disc_id);
	_g_free0 (self->priv->disc_id);
	self->priv->disc_id = _tmp1_;
	_tmp2_ = g_strdup (domain);
	_g_free0 (self->priv->domain);
	self->priv->domain = _tmp2_;
	return self;
}

GamesGameinfoDiscIdGameTitle*
games_gameinfo_disc_id_game_title_new (GamesGameinfoDoc* gameinfo,
                                       const gchar* disc_id,
                                       const gchar* domain)
{
	return games_gameinfo_disc_id_game_title_construct (GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, gameinfo, disc_id, domain);
}

static gchar*
games_gameinfo_disc_id_game_title_real_get_title (GamesTitle* base,
                                                  GError** error)
{
	GamesGameinfoDiscIdGameTitle * self;
	const gchar* _tmp0_;
	gchar* _tmp4_ = NULL;
	GamesGameinfoDoc* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	self = (GamesGameinfoDiscIdGameTitle*) base;
	_tmp0_ = self->priv->title;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = self->priv->domain;
		_tmp2_ = self->priv->title;
		_tmp3_ = g_strdup (g_dgettext (_tmp1_, _tmp2_));
		result = _tmp3_;
		return result;
	}
	_tmp5_ = self->priv->gameinfo;
	_tmp6_ = self->priv->disc_id;
	_tmp7_ = games_gameinfo_doc_get_game_title_for_disc_id (_tmp5_, _tmp6_, &_inner_error0_);
	_tmp4_ = _tmp7_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp8_ = _tmp4_;
	_tmp4_ = NULL;
	_g_free0 (self->priv->title);
	self->priv->title = _tmp8_;
	_tmp9_ = self->priv->domain;
	_tmp10_ = self->priv->title;
	_tmp11_ = g_strdup (g_dgettext (_tmp9_, _tmp10_));
	result = _tmp11_;
	_g_free0 (_tmp4_);
	return result;
}

static void
games_gameinfo_disc_id_game_title_class_init (GamesGameinfoDiscIdGameTitleClass * klass,
                                              gpointer klass_data)
{
	games_gameinfo_disc_id_game_title_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesGameinfoDiscIdGameTitle_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_gameinfo_disc_id_game_title_finalize;
}

static void
games_gameinfo_disc_id_game_title_games_title_interface_init (GamesTitleIface * iface,
                                                              gpointer iface_data)
{
	games_gameinfo_disc_id_game_title_games_title_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_title = (gchar* (*) (GamesTitle*, GError**)) games_gameinfo_disc_id_game_title_real_get_title;
}

static void
games_gameinfo_disc_id_game_title_instance_init (GamesGameinfoDiscIdGameTitle * self,
                                                 gpointer klass)
{
	self->priv = games_gameinfo_disc_id_game_title_get_instance_private (self);
}

static void
games_gameinfo_disc_id_game_title_finalize (GObject * obj)
{
	GamesGameinfoDiscIdGameTitle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, GamesGameinfoDiscIdGameTitle);
	_g_object_unref0 (self->priv->gameinfo);
	_g_free0 (self->priv->disc_id);
	_g_free0 (self->priv->domain);
	_g_free0 (self->priv->title);
	G_OBJECT_CLASS (games_gameinfo_disc_id_game_title_parent_class)->finalize (obj);
}

static GType
games_gameinfo_disc_id_game_title_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesGameinfoDiscIdGameTitleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_gameinfo_disc_id_game_title_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGameinfoDiscIdGameTitle), 0, (GInstanceInitFunc) games_gameinfo_disc_id_game_title_instance_init, NULL };
	static const GInterfaceInfo games_title_info = { (GInterfaceInitFunc) games_gameinfo_disc_id_game_title_games_title_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType games_gameinfo_disc_id_game_title_type_id;
	games_gameinfo_disc_id_game_title_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesGameinfoDiscIdGameTitle", &g_define_type_info, 0);
	g_type_add_interface_static (games_gameinfo_disc_id_game_title_type_id, GAMES_TYPE_TITLE, &games_title_info);
	GamesGameinfoDiscIdGameTitle_private_offset = g_type_add_instance_private (games_gameinfo_disc_id_game_title_type_id, sizeof (GamesGameinfoDiscIdGameTitlePrivate));
	return games_gameinfo_disc_id_game_title_type_id;
}

GType
games_gameinfo_disc_id_game_title_get_type (void)
{
	static volatile gsize games_gameinfo_disc_id_game_title_type_id__once = 0;
	if (g_once_init_enter (&games_gameinfo_disc_id_game_title_type_id__once)) {
		GType games_gameinfo_disc_id_game_title_type_id;
		games_gameinfo_disc_id_game_title_type_id = games_gameinfo_disc_id_game_title_get_type_once ();
		g_once_init_leave (&games_gameinfo_disc_id_game_title_type_id__once, games_gameinfo_disc_id_game_title_type_id);
	}
	return games_gameinfo_disc_id_game_title_type_id__once;
}

