/* nintendo-ds-icon.c generated by valac 0.36.9, the Vala compiler
 * generated from nintendo-ds-icon.vala, do not modify */

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

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>


#define GAMES_TYPE_NINTENDO_DS_ICON (games_nintendo_ds_icon_get_type ())
#define GAMES_NINTENDO_DS_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIcon))
#define GAMES_NINTENDO_DS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIconClass))
#define GAMES_IS_NINTENDO_DS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_NINTENDO_DS_ICON))
#define GAMES_IS_NINTENDO_DS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_NINTENDO_DS_ICON))
#define GAMES_NINTENDO_DS_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIconClass))

typedef struct _GamesNintendoDsIcon GamesNintendoDsIcon;
typedef struct _GamesNintendoDsIconClass GamesNintendoDsIconClass;
typedef struct _GamesNintendoDsIconPrivate GamesNintendoDsIconPrivate;
#define _games_uri_unref0(var) ((var == NULL) ? NULL : (var = (games_uri_unref (var), NULL)))
#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 _GamesNintendoDsIcon {
	GObject parent_instance;
	GamesNintendoDsIconPrivate * priv;
};

struct _GamesNintendoDsIconClass {
	GObjectClass parent_class;
};

struct _GamesNintendoDsIconPrivate {
	GamesUri* uri;
	gboolean extracted;
	GdkPixbuf* pixbuf;
};


static gpointer games_nintendo_ds_icon_parent_class = NULL;
static GamesIconIface * games_nintendo_ds_icon_games_icon_parent_iface = NULL;
static GType games_nintendo_ds_icon_type_id = 0;

GType games_nintendo_ds_icon_get_type (void) G_GNUC_CONST;
#define GAMES_NINTENDO_DS_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIconPrivate))
enum  {
	GAMES_NINTENDO_DS_ICON_0_PROPERTY
};
GamesNintendoDsIcon* games_nintendo_ds_icon_new (GamesUri* uri);
GamesNintendoDsIcon* games_nintendo_ds_icon_construct (GType object_type, GamesUri* uri);
GdkPixbuf* games_nintendo_ds_icon_extract (GamesUri* uri, GError** error);
static GIcon* games_nintendo_ds_icon_real_get_icon (GamesIcon* base);
static void games_nintendo_ds_icon_finalize (GObject * obj);


static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


GamesNintendoDsIcon* games_nintendo_ds_icon_construct (GType object_type, GamesUri* uri) {
	GamesNintendoDsIcon * self = NULL;
	GamesUri* _tmp0_;
	GamesUri* _tmp1_;
	g_return_val_if_fail (uri != NULL, NULL);
	self = (GamesNintendoDsIcon*) g_object_new (object_type, NULL);
	_tmp0_ = uri;
	_tmp1_ = _games_uri_ref0 (_tmp0_);
	_games_uri_unref0 (self->priv->uri);
	self->priv->uri = _tmp1_;
	self->priv->extracted = FALSE;
	return self;
}


GamesNintendoDsIcon* games_nintendo_ds_icon_new (GamesUri* uri) {
	return games_nintendo_ds_icon_construct (GAMES_TYPE_NINTENDO_DS_ICON, uri);
}


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


static GIcon* games_nintendo_ds_icon_real_get_icon (GamesIcon* base) {
	GamesNintendoDsIcon * self;
	GIcon* result = NULL;
	gboolean _tmp0_;
	GdkPixbuf* _tmp9_;
	GIcon* _tmp10_;
	GError * _inner_error_ = NULL;
	self = (GamesNintendoDsIcon*) base;
	_tmp0_ = self->priv->extracted;
	if (_tmp0_) {
		GdkPixbuf* _tmp1_;
		GIcon* _tmp2_;
		_tmp1_ = self->priv->pixbuf;
		_tmp2_ = _g_object_ref0 ((GIcon*) _tmp1_);
		result = _tmp2_;
		return result;
	}
	self->priv->extracted = TRUE;
	{
		GdkPixbuf* _tmp3_ = NULL;
		GamesUri* _tmp4_;
		GdkPixbuf* _tmp5_;
		GdkPixbuf* _tmp6_;
		_tmp4_ = self->priv->uri;
		_tmp5_ = games_nintendo_ds_icon_extract (_tmp4_, &_inner_error_);
		_tmp3_ = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp3_;
		_tmp3_ = NULL;
		_g_object_unref0 (self->priv->pixbuf);
		self->priv->pixbuf = _tmp6_;
		_g_object_unref0 (_tmp3_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("nintendo-ds-icon.vala:25: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		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;
	}
	_tmp9_ = self->priv->pixbuf;
	_tmp10_ = _g_object_ref0 ((GIcon*) _tmp9_);
	result = _tmp10_;
	return result;
}


static void games_nintendo_ds_icon_class_init (GamesNintendoDsIconClass * klass) {
	games_nintendo_ds_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesNintendoDsIconPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_nintendo_ds_icon_finalize;
}


static void games_nintendo_ds_icon_games_icon_interface_init (GamesIconIface * iface) {
	games_nintendo_ds_icon_games_icon_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_icon = (GIcon* (*) (GamesIcon *)) games_nintendo_ds_icon_real_get_icon;
}


static void games_nintendo_ds_icon_instance_init (GamesNintendoDsIcon * self) {
	self->priv = GAMES_NINTENDO_DS_ICON_GET_PRIVATE (self);
}


static void games_nintendo_ds_icon_finalize (GObject * obj) {
	GamesNintendoDsIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIcon);
	_games_uri_unref0 (self->priv->uri);
	_g_object_unref0 (self->priv->pixbuf);
	G_OBJECT_CLASS (games_nintendo_ds_icon_parent_class)->finalize (obj);
}


GType games_nintendo_ds_icon_get_type (void) {
	return games_nintendo_ds_icon_type_id;
}


GType games_nintendo_ds_icon_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesNintendoDsIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_nintendo_ds_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesNintendoDsIcon), 0, (GInstanceInitFunc) games_nintendo_ds_icon_instance_init, NULL };
	static const GInterfaceInfo games_icon_info = { (GInterfaceInitFunc) games_nintendo_ds_icon_games_icon_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_nintendo_ds_icon_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesNintendoDsIcon", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_nintendo_ds_icon_type_id, GAMES_TYPE_ICON, &games_icon_info);
	return games_nintendo_ds_icon_type_id;
}



