/* love-icon.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from love-icon.vala, do not modify */

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

#include <glib-object.h>
#include "gnome-games.h"
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include "games-love-plugin.h"

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#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;
enum  {
	GAMES_LOVE_ICON_0_PROPERTY,
	GAMES_LOVE_ICON_NUM_PROPERTIES
};
static GParamSpec* games_love_icon_properties[GAMES_LOVE_ICON_NUM_PROPERTIES];
#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 gint GamesLoveIcon_private_offset;
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_register_type (GTypeModule * module);
VALA_EXTERN GType games_love_icon_get_type (void) G_GNUC_CONST ;
GType games_love_package_register_type (GTypeModule * module);
VALA_EXTERN GType games_love_package_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesLoveIcon* games_love_icon_new (GamesLovePackage* package);
VALA_EXTERN GamesLoveIcon* games_love_icon_construct (GType object_type,
                                          GamesLovePackage* package);
static GIcon* games_love_icon_real_get_icon (GamesIcon* base);
VALA_EXTERN gchar* games_love_package_get_config (GamesLovePackage* self,
                                      const gchar* key);
VALA_EXTERN GInputStream* games_love_package_get_file_input_stream (GamesLovePackage* self,
                                                        const gchar* path_in_archive);
static void games_love_icon_finalize (GObject * obj);

static inline gpointer
games_love_icon_get_instance_private (GamesLoveIcon* self)
{
	return G_STRUCT_MEMBER_P (self, GamesLoveIcon_private_offset);
}

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_;
	g_return_val_if_fail (package != NULL, NULL);
	self = (GamesLoveIcon*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (package);
	_g_object_unref0 (self->priv->package);
	self->priv->package = _tmp0_;
	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;
	GdkPixbuf* _tmp0_;
	gchar* icon_path = NULL;
	GamesLovePackage* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	GInputStream* stream = NULL;
	GamesLovePackage* _tmp8_;
	const gchar* _tmp9_;
	GInputStream* _tmp10_;
	GInputStream* _tmp11_;
	GdkPixbuf* _tmp18_;
	GIcon* _tmp21_;
	GIcon* _tmp22_;
	GError* _inner_error0_ = NULL;
	GIcon* result;
	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;
	}
	if (self->priv->already_parsed) {
		GIcon* _tmp3_;
		GIcon* _tmp4_;
		_tmp3_ = games_love_icon_love_icon;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		result = _tmp4_;
		return result;
	}
	self->priv->already_parsed = TRUE;
	_tmp5_ = self->priv->package;
	_tmp6_ = games_love_package_get_config (_tmp5_, "icon");
	icon_path = _tmp6_;
	_tmp7_ = icon_path;
	if (_tmp7_ == NULL) {
		result = NULL;
		_g_free0 (icon_path);
		return result;
	}
	_tmp8_ = self->priv->package;
	_tmp9_ = icon_path;
	_tmp10_ = games_love_package_get_file_input_stream (_tmp8_, _tmp9_);
	stream = _tmp10_;
	_tmp11_ = stream;
	if (_tmp11_ == NULL) {
		result = NULL;
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		return result;
	}
	{
		GdkPixbuf* _tmp12_ = NULL;
		GInputStream* _tmp13_;
		GdkPixbuf* _tmp14_;
		GdkPixbuf* _tmp15_;
		_tmp13_ = stream;
		_tmp14_ = gdk_pixbuf_new_from_stream (_tmp13_, NULL, &_inner_error0_);
		_tmp12_ = _tmp14_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp15_ = _tmp12_;
		_tmp12_ = NULL;
		_g_object_unref0 (self->priv->pixbuf);
		self->priv->pixbuf = _tmp15_;
		_g_object_unref0 (_tmp12_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp16_;
		const gchar* _tmp17_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		g_warning ("love-icon.vala:45: %s", _tmp17_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp18_ = self->priv->pixbuf;
	if (_tmp18_ != NULL) {
		GdkPixbuf* _tmp19_;
		GIcon* _tmp20_;
		_tmp19_ = self->priv->pixbuf;
		_tmp20_ = _g_object_ref0 ((GIcon*) _tmp19_);
		result = _tmp20_;
		_g_object_unref0 (stream);
		_g_free0 (icon_path);
		return result;
	}
	_tmp21_ = games_love_icon_love_icon;
	_tmp22_ = _g_object_ref0 (_tmp21_);
	result = _tmp22_;
	_g_object_unref0 (stream);
	_g_free0 (icon_path);
	return result;
}

static void
games_love_icon_class_init (GamesLoveIconClass * klass,
                            gpointer klass_data)
{
	GError* _inner_error0_ = NULL;
	games_love_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesLoveIcon_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_love_icon_finalize;
	{
		GIcon* _tmp0_ = NULL;
		GIcon* _tmp1_;
		GIcon* _tmp2_;
		_tmp1_ = g_icon_new_for_string ("love", &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_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 __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("love-icon.vala:20: %s\n", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
	}
}

static void
games_love_icon_games_icon_interface_init (GamesIconIface * iface,
                                           gpointer iface_data)
{
	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,
                               gpointer klass)
{
	self->priv = games_love_icon_get_instance_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);
	GamesLoveIcon_private_offset = sizeof (GamesLoveIconPrivate);
	return games_love_icon_type_id;
}

