/* libretro-icon.c generated by valac 0.35.5, the Vala compiler
 * generated from libretro-icon.vala, do not modify */

/* This file is part of GNOME Games. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <retro-gtk.h>
#include <gio/gio.h>


#define GAMES_TYPE_LIBRETRO_ICON (games_libretro_icon_get_type ())
#define GAMES_LIBRETRO_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIcon))
#define GAMES_LIBRETRO_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIconClass))
#define GAMES_IS_LIBRETRO_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LIBRETRO_ICON))
#define GAMES_IS_LIBRETRO_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LIBRETRO_ICON))
#define GAMES_LIBRETRO_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIconClass))

typedef struct _GamesLibretroIcon GamesLibretroIcon;
typedef struct _GamesLibretroIconClass GamesLibretroIconClass;
typedef struct _GamesLibretroIconPrivate GamesLibretroIconPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GamesLibretroIcon {
	GObject parent_instance;
	GamesLibretroIconPrivate * priv;
};

struct _GamesLibretroIconClass {
	GObjectClass parent_class;
};

struct _GamesLibretroIconPrivate {
	RetroCoreDescriptor* core_descriptor;
};


static gpointer games_libretro_icon_parent_class = NULL;
static GamesIconIface * games_libretro_icon_games_icon_parent_iface = NULL;
static GType games_libretro_icon_type_id = 0;

GType games_libretro_icon_get_type (void) G_GNUC_CONST;
#define GAMES_LIBRETRO_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIconPrivate))
enum  {
	GAMES_LIBRETRO_ICON_DUMMY_PROPERTY
};
GamesLibretroIcon* games_libretro_icon_new (RetroCoreDescriptor* core_descriptor);
GamesLibretroIcon* games_libretro_icon_construct (GType object_type, RetroCoreDescriptor* core_descriptor);
static GIcon* games_libretro_icon_real_get_icon (GamesIcon* base);
static void games_libretro_icon_finalize (GObject * obj);


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


GamesLibretroIcon* games_libretro_icon_construct (GType object_type, RetroCoreDescriptor* core_descriptor) {
	GamesLibretroIcon * self = NULL;
	RetroCoreDescriptor* _tmp0_;
	RetroCoreDescriptor* _tmp1_;
	g_return_val_if_fail (core_descriptor != NULL, NULL);
	self = (GamesLibretroIcon*) g_object_new (object_type, NULL);
	_tmp0_ = core_descriptor;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->core_descriptor);
	self->priv->core_descriptor = _tmp1_;
	return self;
}


GamesLibretroIcon* games_libretro_icon_new (RetroCoreDescriptor* core_descriptor) {
	return games_libretro_icon_construct (GAMES_TYPE_LIBRETRO_ICON, core_descriptor);
}


static GIcon* games_libretro_icon_real_get_icon (GamesIcon* base) {
	GamesLibretroIcon * self;
	GIcon* result = NULL;
	GError * _inner_error_ = NULL;
	self = (GamesLibretroIcon*) base;
	{
		gboolean _tmp0_;
		RetroCoreDescriptor* _tmp1_;
		gboolean _tmp2_;
		GIcon* _tmp3_;
		RetroCoreDescriptor* _tmp4_;
		GIcon* _tmp5_;
		GIcon* _tmp6_;
		_tmp1_ = self->priv->core_descriptor;
		_tmp2_ = retro_core_descriptor_has_icon (_tmp1_, &_inner_error_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		if (!_tmp0_) {
			result = NULL;
			return result;
		}
		_tmp4_ = self->priv->core_descriptor;
		_tmp5_ = retro_core_descriptor_get_icon (_tmp4_, &_inner_error_);
		_tmp3_ = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp6_ = _tmp3_;
		_tmp3_ = NULL;
		result = _tmp6_;
		_g_object_unref0 (_tmp3_);
		return result;
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_debug ("libretro-icon.vala:18: %s", _tmp8_);
		result = NULL;
		_g_error_free0 (e);
		return result;
	}
	__finally1:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


static void games_libretro_icon_class_init (GamesLibretroIconClass * klass) {
	games_libretro_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLibretroIconPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_libretro_icon_finalize;
}


static void games_libretro_icon_games_icon_interface_init (GamesIconIface * iface) {
	games_libretro_icon_games_icon_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_icon = (GIcon* (*) (GamesIcon *)) games_libretro_icon_real_get_icon;
}


static void games_libretro_icon_instance_init (GamesLibretroIcon * self) {
	self->priv = GAMES_LIBRETRO_ICON_GET_PRIVATE (self);
}


static void games_libretro_icon_finalize (GObject * obj) {
	GamesLibretroIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIcon);
	_g_object_unref0 (self->priv->core_descriptor);
	G_OBJECT_CLASS (games_libretro_icon_parent_class)->finalize (obj);
}


GType games_libretro_icon_get_type (void) {
	return games_libretro_icon_type_id;
}


GType games_libretro_icon_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLibretroIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_libretro_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLibretroIcon), 0, (GInstanceInitFunc) games_libretro_icon_instance_init, NULL };
	static const GInterfaceInfo games_icon_info = { (GInterfaceInitFunc) games_libretro_icon_games_icon_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_libretro_icon_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLibretroIcon", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_libretro_icon_type_id, GAMES_TYPE_ICON, &games_icon_info);
	return games_libretro_icon_type_id;
}



