/* gameinfo-disc-id-game-title.c generated by valac 0.36.1.39-72bb2, 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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>


#define GAMES_TYPE_TITLE (games_title_get_type ())
#define GAMES_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_TITLE, GamesTitle))
#define GAMES_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_TITLE))
#define GAMES_TITLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_TITLE, GamesTitleIface))

typedef struct _GamesTitle GamesTitle;
typedef struct _GamesTitleIface GamesTitleIface;

#define GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE (games_gameinfo_disc_id_game_title_get_type ())
#define GAMES_GAMEINFO_DISC_ID_GAME_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, GamesGameinfoDiscIdGameTitle))
#define GAMES_GAMEINFO_DISC_ID_GAME_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, GamesGameinfoDiscIdGameTitleClass))
#define GAMES_IS_GAMEINFO_DISC_ID_GAME_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE))
#define GAMES_IS_GAMEINFO_DISC_ID_GAME_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE))
#define GAMES_GAMEINFO_DISC_ID_GAME_TITLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, GamesGameinfoDiscIdGameTitleClass))

typedef struct _GamesGameinfoDiscIdGameTitle GamesGameinfoDiscIdGameTitle;
typedef struct _GamesGameinfoDiscIdGameTitleClass GamesGameinfoDiscIdGameTitleClass;
typedef struct _GamesGameinfoDiscIdGameTitlePrivate GamesGameinfoDiscIdGameTitlePrivate;

#define GAMES_TYPE_GAMEINFO_DOC (games_gameinfo_doc_get_type ())
#define GAMES_GAMEINFO_DOC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEINFO_DOC, GamesGameinfoDoc))
#define GAMES_GAMEINFO_DOC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEINFO_DOC, GamesGameinfoDocClass))
#define GAMES_IS_GAMEINFO_DOC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEINFO_DOC))
#define GAMES_IS_GAMEINFO_DOC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEINFO_DOC))
#define GAMES_GAMEINFO_DOC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEINFO_DOC, GamesGameinfoDocClass))

typedef struct _GamesGameinfoDoc GamesGameinfoDoc;
typedef struct _GamesGameinfoDocClass GamesGameinfoDocClass;
enum  {
	GAMES_GAMEINFO_DISC_ID_GAME_TITLE_DUMMY_PROPERTY,
	GAMES_GAMEINFO_DISC_ID_GAME_TITLE_LAST_PROPERTY
};
static GParamSpec* games_gameinfo_disc_id_game_title_properties[GAMES_GAMEINFO_DISC_ID_GAME_TITLE_LAST_PROPERTY];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesTitleIface {
	GTypeInterface parent_iface;
	gchar* (*get_title) (GamesTitle* self, GError** error);
};

struct _GamesGameinfoDiscIdGameTitle {
	GObject parent_instance;
	GamesGameinfoDiscIdGameTitlePrivate * priv;
};

struct _GamesGameinfoDiscIdGameTitleClass {
	GObjectClass parent_class;
};

struct _GamesGameinfoDiscIdGameTitlePrivate {
	GamesGameinfoDoc* gameinfo;
	gchar* disc_id;
	gchar* domain;
	gchar* title;
};


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

GType games_title_get_type (void) G_GNUC_CONST;
GType games_gameinfo_disc_id_game_title_get_type (void) G_GNUC_CONST;
GType games_gameinfo_doc_get_type (void) G_GNUC_CONST;
#define GAMES_GAMEINFO_DISC_ID_GAME_TITLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GAMEINFO_DISC_ID_GAME_TITLE, GamesGameinfoDiscIdGameTitlePrivate))
GamesGameinfoDiscIdGameTitle* games_gameinfo_disc_id_game_title_new (GamesGameinfoDoc* gameinfo, const gchar* disc_id, const gchar* domain);
GamesGameinfoDiscIdGameTitle* games_gameinfo_disc_id_game_title_construct (GType object_type, GamesGameinfoDoc* gameinfo, const gchar* disc_id, const gchar* domain);
static gchar* games_gameinfo_disc_id_game_title_real_get_title (GamesTitle* base, GError** error);
gchar* games_gameinfo_doc_get_game_title_for_disc_id (GamesGameinfoDoc* self, const gchar* disc_id, GError** error);
static void games_gameinfo_disc_id_game_title_finalize (GObject * obj);


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_;
	GamesGameinfoDoc* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	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_ = gameinfo;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->gameinfo);
	self->priv->gameinfo = _tmp1_;
	_tmp2_ = disc_id;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->disc_id);
	self->priv->disc_id = _tmp3_;
	_tmp4_ = domain;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 (self->priv->domain);
	self->priv->domain = _tmp5_;
	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;
	gchar* result = NULL;
	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_error_ = NULL;
	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_error_);
	_tmp4_ = _tmp7_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		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) {
	games_gameinfo_disc_id_game_title_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGameinfoDiscIdGameTitlePrivate));
	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) {
	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) {
	self->priv = GAMES_GAMEINFO_DISC_ID_GAME_TITLE_GET_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);
}


GType games_gameinfo_disc_id_game_title_get_type (void) {
	static volatile gsize games_gameinfo_disc_id_game_title_type_id__volatile = 0;
	if (g_once_init_enter (&games_gameinfo_disc_id_game_title_type_id__volatile)) {
		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);
		g_once_init_leave (&games_gameinfo_disc_id_game_title_type_id__volatile, games_gameinfo_disc_id_game_title_type_id);
	}
	return games_gameinfo_disc_id_game_title_type_id__volatile;
}



