/* love-icon.c generated by valac 0.36.9, the Vala compiler
 * generated from love-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>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_LOVE_ICON (games_love_icon_get_type ())
#define GAMES_LOVE_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_ICON, GamesLoveIcon))
#define GAMES_LOVE_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_ICON, GamesLoveIconClass))
#define GAMES_IS_LOVE_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_ICON))
#define GAMES_IS_LOVE_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_ICON))
#define GAMES_LOVE_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_ICON, GamesLoveIconClass))

typedef struct _GamesLoveIcon GamesLoveIcon;
typedef struct _GamesLoveIconClass GamesLoveIconClass;
typedef struct _GamesLoveIconPrivate GamesLoveIconPrivate;

#define GAMES_TYPE_LOVE_PACKAGE (games_love_package_get_type ())
#define GAMES_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackage))
#define GAMES_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))
#define GAMES_IS_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_IS_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_LOVE_PACKAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))

typedef struct _GamesLovePackage GamesLovePackage;
typedef struct _GamesLovePackageClass GamesLovePackageClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GamesLoveIcon {
	GObject parent_instance;
	GamesLoveIconPrivate * priv;
};

struct _GamesLoveIconClass {
	GObjectClass parent_class;
};

struct _GamesLoveIconPrivate {
	GamesLovePackage* package;
	gboolean already_parsed;
	GdkPixbuf* pixbuf;
};


static gpointer games_love_icon_parent_class = NULL;
static GIcon* games_love_icon_love_icon;
static GIcon* games_love_icon_love_icon = NULL;
static GamesIconIface * games_love_icon_games_icon_parent_iface = NULL;
static GType games_love_icon_type_id = 0;

GType games_love_icon_get_type (void) G_GNUC_CONST;
GType games_love_package_get_type (void) G_GNUC_CONST;
#define GAMES_LOVE_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LOVE_ICON, GamesLoveIconPrivate))
enum  {
	GAMES_LOVE_ICON_0_PROPERTY
};
GamesLoveIcon* games_love_icon_new (GamesLovePackage* package);
GamesLoveIcon* games_love_icon_construct (GType object_type, GamesLovePackage* package);
static GIcon* games_love_icon_real_get_icon (GamesIcon* base);
gchar* games_love_package_get_config (GamesLovePackage* self, const gchar* key);
GInputStream* games_love_package_get_file_input_stream (GamesLovePackage* self, const gchar* path_in_archive);
static void games_love_icon_finalize (GObject * obj);


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


GamesLoveIcon* games_love_icon_construct (GType object_type, GamesLovePackage* package) {
	GamesLoveIcon * self = NULL;
	GamesLovePackage* _tmp0_;
	GamesLovePackage* _tmp1_;
	g_return_val_if_fail (package != NULL, NULL);
	self = (GamesLoveIcon*) g_object_new (object_type, NULL);
	_tmp0_ = package;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->package);
	self->priv->package = _tmp1_;
	self->priv->already_parsed = FALSE;
	return self;
}


GamesLoveIcon* games_love_icon_new (GamesLovePackage* package) {
	return games_love_icon_construct (GAMES_TYPE_LOVE_ICON, package);
}


static GIcon* games_love_icon_real_get_icon (GamesIcon* base) {
	GamesLoveIcon * self;
	GIcon* result = NULL;
	GdkPixbuf* _tmp0_;
	gboolean _tmp3_;
	gchar* icon_path = NULL;
	GamesLovePackage* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GInputStream* stream = NULL;
	GamesLovePackage* _tmp9_;
	const gchar* _tmp10_;
	GInputStream* _tmp11_;
	GInputStream* _tmp12_;
	GdkPixbuf* _tmp19_;
	GIcon* _tmp22_;
	GIcon* _tmp23_;
	GError * _inner_error_ = NULL;
	self = (GamesLoveIcon*) base;
	_tmp0_ = self->priv->pixbuf;
	if (_tmp0_ != NULL) {
		GdkPixbuf* _tmp1_;
		GIcon* _tmp2_;
		_tmp1_ = self->priv->pixbuf;
		_tmp2_ = _g_object_ref0 ((GIcon*) _tmp1_);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = self->priv->already_parsed;
	if (_tmp3_) {
		GIcon* _tmp4_;
		GIcon* _tmp5_;
		_tmp4_ = games_love_icon_love_icon;
		_tmp5_ = _g_object_ref0 (_tmp4_);
		result = _tmp5_;
		return result;
	}
	self->priv->already_parsed = TRUE;
	_tmp6_ = self->priv->package;
	_tmp7_ = games_love_package_get_config (_tmp6_, "icon");
	icon_path = _tmp7_;
	_tmp8_ = icon_path;
	if (_tmp8_ == NULL) {
		result = NULL;
		_g_free0 (icon_path);
		return result;
	}
	_tmp9_ = self->priv->package;
	_tmp10_ = icon_path;
	_tmp11_ = games_love_package_get_file_input_stream (_tmp9_, _tmp10_);
	stream = _tmp11_;
	_tmp12_ = stream;
	if (_tmp12_ == NULL) {
		result = NULL;
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		return result;
	}
	{
		GdkPixbuf* _tmp13_ = NULL;
		GInputStream* _tmp14_;
		GdkPixbuf* _tmp15_;
		GdkPixbuf* _tmp16_;
		_tmp14_ = stream;
		_tmp15_ = gdk_pixbuf_new_from_stream (_tmp14_, NULL, &_inner_error_);
		_tmp13_ = _tmp15_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp16_ = _tmp13_;
		_tmp13_ = NULL;
		_g_object_unref0 (self->priv->pixbuf);
		self->priv->pixbuf = _tmp16_;
		_g_object_unref0 (_tmp13_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp17_;
		const gchar* _tmp18_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		g_warning ("love-icon.vala:45: %s", _tmp18_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		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;
	}
	_tmp19_ = self->priv->pixbuf;
	if (_tmp19_ != NULL) {
		GdkPixbuf* _tmp20_;
		GIcon* _tmp21_;
		_tmp20_ = self->priv->pixbuf;
		_tmp21_ = _g_object_ref0 ((GIcon*) _tmp20_);
		result = _tmp21_;
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		return result;
	}
	_tmp22_ = games_love_icon_love_icon;
	_tmp23_ = _g_object_ref0 (_tmp22_);
	result = _tmp23_;
	_g_object_unref0 (stream);
	_g_free0 (icon_path);
	return result;
}


static void games_love_icon_class_init (GamesLoveIconClass * klass) {
	GError * _inner_error_ = NULL;
	games_love_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLoveIconPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_love_icon_finalize;
	{
		GIcon* _tmp0_ = NULL;
		GIcon* _tmp1_;
		GIcon* _tmp2_;
		_tmp1_ = g_icon_new_for_string ("love", &_inner_error_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (games_love_icon_love_icon);
		games_love_icon_love_icon = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("love-icon.vala:20: %s\n", _tmp4_);
		_g_error_free0 (e);
	}
	__finally1:
	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_);
	}
}


static void games_love_icon_games_icon_interface_init (GamesIconIface * iface) {
	games_love_icon_games_icon_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_icon = (GIcon* (*) (GamesIcon *)) games_love_icon_real_get_icon;
}


static void games_love_icon_instance_init (GamesLoveIcon * self) {
	self->priv = GAMES_LOVE_ICON_GET_PRIVATE (self);
}


static void games_love_icon_finalize (GObject * obj) {
	GamesLoveIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LOVE_ICON, GamesLoveIcon);
	_g_object_unref0 (self->priv->package);
	_g_object_unref0 (self->priv->pixbuf);
	G_OBJECT_CLASS (games_love_icon_parent_class)->finalize (obj);
}


GType games_love_icon_get_type (void) {
	return games_love_icon_type_id;
}


GType games_love_icon_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLoveIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_love_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLoveIcon), 0, (GInstanceInitFunc) games_love_icon_instance_init, NULL };
	static const GInterfaceInfo games_icon_info = { (GInterfaceInitFunc) games_love_icon_games_icon_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_love_icon_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLoveIcon", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_love_icon_type_id, GAMES_TYPE_ICON, &games_icon_info);
	return games_love_icon_type_id;
}



