/* nintendo-ds-icon.c generated by valac 0.35.5, the Vala compiler
 * generated from nintendo-ds-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 <stdlib.h>
#include <string.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 _g_free0(var) (var = (g_free (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 {
	gchar* 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_DUMMY_PROPERTY
};
GamesNintendoDsIcon* games_nintendo_ds_icon_new (const gchar* uri);
GamesNintendoDsIcon* games_nintendo_ds_icon_construct (GType object_type, const gchar* uri);
GdkPixbuf* games_nintendo_ds_icon_extract (const gchar* uri, GError** error);
static GIcon* games_nintendo_ds_icon_real_get_icon (GamesIcon* base);
static void games_nintendo_ds_icon_finalize (GObject * obj);


GamesNintendoDsIcon* games_nintendo_ds_icon_construct (GType object_type, const gchar* uri) {
	GamesNintendoDsIcon * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (uri != NULL, NULL);
	self = (GamesNintendoDsIcon*) g_object_new (object_type, NULL);
	_tmp0_ = uri;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->uri);
	self->priv->uri = _tmp1_;
	self->priv->extracted = FALSE;
	return self;
}


GamesNintendoDsIcon* games_nintendo_ds_icon_new (const gchar* 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_;
		const gchar* _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);
	_g_free0 (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;
}



