/* themeImporter.c generated by valac 0.56.18, the Vala compiler
 * generated from themeImporter.vala, do not modify */

/*///////////////////////////////////////////////////////////////////////*/
/* Copyright 2011-2021 Simon Schneegans*/
/**/
/* Permission is hereby granted, free of charge, to any person obtaining*/
/* a copy of this software and associated documentation files (the*/
/* "Software"), to deal in the Software without restriction, including*/
/* without limitation the rights to use, copy, modify, merge, publish,*/
/* distribute, sublicense, and/or sell copies of the Software, and to*/
/* permit persons to whom the Software is furnished to do so, subject to*/
/* the following conditions:*/
/* */
/* The above copyright notice and this permission notice shall be*/
/* included in all copies or substantial portions of the Software.*/
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,*/
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF*/
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY*/
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,*/
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE*/
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
/*///////////////////////////////////////////////////////////////////////*/

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GNOME_PIE_TYPE_ARCHIVE_READER (gnome_pie_archive_reader_get_type ())
#define GNOME_PIE_ARCHIVE_READER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_ARCHIVE_READER, GnomePieArchiveReader))
#define GNOME_PIE_ARCHIVE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_ARCHIVE_READER, GnomePieArchiveReaderClass))
#define GNOME_PIE_IS_ARCHIVE_READER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_ARCHIVE_READER))
#define GNOME_PIE_IS_ARCHIVE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_ARCHIVE_READER))
#define GNOME_PIE_ARCHIVE_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_ARCHIVE_READER, GnomePieArchiveReaderClass))

typedef struct _GnomePieArchiveReader GnomePieArchiveReader;
typedef struct _GnomePieArchiveReaderClass GnomePieArchiveReaderClass;
typedef struct _GnomePieArchiveReaderPrivate GnomePieArchiveReaderPrivate;

#define GNOME_PIE_TYPE_THEME_IMPORTER (gnome_pie_theme_importer_get_type ())
#define GNOME_PIE_THEME_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_THEME_IMPORTER, GnomePieThemeImporter))
#define GNOME_PIE_THEME_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_THEME_IMPORTER, GnomePieThemeImporterClass))
#define GNOME_PIE_IS_THEME_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_THEME_IMPORTER))
#define GNOME_PIE_IS_THEME_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_THEME_IMPORTER))
#define GNOME_PIE_THEME_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_THEME_IMPORTER, GnomePieThemeImporterClass))

typedef struct _GnomePieThemeImporter GnomePieThemeImporter;
typedef struct _GnomePieThemeImporterClass GnomePieThemeImporterClass;
typedef struct _GnomePieThemeImporterPrivate GnomePieThemeImporterPrivate;
enum  {
	GNOME_PIE_THEME_IMPORTER_0_PROPERTY,
	GNOME_PIE_THEME_IMPORTER_NUM_PROPERTIES
};
static GParamSpec* gnome_pie_theme_importer_properties[GNOME_PIE_THEME_IMPORTER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define GNOME_PIE_TYPE_THEME (gnome_pie_theme_get_type ())
#define GNOME_PIE_THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_THEME, GnomePieTheme))
#define GNOME_PIE_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_THEME, GnomePieThemeClass))
#define GNOME_PIE_IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_THEME))
#define GNOME_PIE_IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_THEME))
#define GNOME_PIE_THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_THEME, GnomePieThemeClass))

typedef struct _GnomePieTheme GnomePieTheme;
typedef struct _GnomePieThemeClass GnomePieThemeClass;
#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 _GnomePieArchiveReader {
	GObject parent_instance;
	GnomePieArchiveReaderPrivate * priv;
};

struct _GnomePieArchiveReaderClass {
	GObjectClass parent_class;
};

struct _GnomePieThemeImporter {
	GnomePieArchiveReader parent_instance;
	GnomePieThemeImporterPrivate * priv;
	gboolean is_valid_theme;
	gchar* theme_name;
};

struct _GnomePieThemeImporterClass {
	GnomePieArchiveReaderClass parent_class;
};

static gpointer gnome_pie_theme_importer_parent_class = NULL;

VALA_EXTERN GType gnome_pie_archive_reader_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieArchiveReader, g_object_unref)
VALA_EXTERN GType gnome_pie_theme_importer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieThemeImporter, g_object_unref)
VALA_EXTERN gboolean gnome_pie_theme_importer_open (GnomePieThemeImporter* self,
                                        const gchar* path);
VALA_EXTERN GnomePieArchiveReader* gnome_pie_archive_reader_new (void);
VALA_EXTERN GnomePieArchiveReader* gnome_pie_archive_reader_construct (GType object_type);
VALA_EXTERN gboolean gnome_pie_archive_reader_open (GnomePieArchiveReader* self,
                                        const gchar* path);
VALA_EXTERN gboolean gnome_pie_archive_reader_extract_to (GnomePieArchiveReader* self,
                                              const gchar* directory);
VALA_EXTERN GType gnome_pie_theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieTheme, g_object_unref)
VALA_EXTERN GnomePieTheme* gnome_pie_theme_new (const gchar* dir);
VALA_EXTERN GnomePieTheme* gnome_pie_theme_construct (GType object_type,
                                          const gchar* dir);
VALA_EXTERN gboolean gnome_pie_theme_load (GnomePieTheme* self);
VALA_EXTERN const gchar* gnome_pie_theme_get_name (GnomePieTheme* self);
VALA_EXTERN void gnome_pie_archive_reader_close (GnomePieArchiveReader* self);
VALA_EXTERN GnomePieThemeImporter* gnome_pie_theme_importer_new (void);
VALA_EXTERN GnomePieThemeImporter* gnome_pie_theme_importer_construct (GType object_type);
static void gnome_pie_theme_importer_finalize (GObject * obj);
static GType gnome_pie_theme_importer_get_type_once (void);

gboolean
gnome_pie_theme_importer_open (GnomePieThemeImporter* self,
                               const gchar* path)
{
	gchar* _tmp0_;
	GnomePieArchiveReader* tmp_reader = NULL;
	GnomePieArchiveReader* _tmp1_;
	GnomePieArchiveReader* _tmp2_;
	GnomePieArchiveReader* _tmp16_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	self->is_valid_theme = FALSE;
	_tmp0_ = g_strdup ("");
	_g_free0 (self->theme_name);
	self->theme_name = _tmp0_;
	_tmp1_ = gnome_pie_archive_reader_new ();
	tmp_reader = _tmp1_;
	_tmp2_ = tmp_reader;
	if (gnome_pie_archive_reader_open (_tmp2_, path)) {
		{
			gchar* tmp_dir = NULL;
			gchar* _tmp3_;
			GnomePieArchiveReader* _tmp4_;
			const gchar* _tmp5_;
			_tmp3_ = g_dir_make_tmp ("gnomepieXXXXXX", &_inner_error0_);
			tmp_dir = _tmp3_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp4_ = tmp_reader;
			_tmp5_ = tmp_dir;
			if (gnome_pie_archive_reader_extract_to (_tmp4_, _tmp5_)) {
				GnomePieTheme* tmp_theme = NULL;
				const gchar* _tmp6_;
				GnomePieTheme* _tmp7_;
				GnomePieTheme* _tmp8_;
				_tmp6_ = tmp_dir;
				_tmp7_ = gnome_pie_theme_new (_tmp6_);
				tmp_theme = _tmp7_;
				_tmp8_ = tmp_theme;
				if (gnome_pie_theme_load (_tmp8_)) {
					GnomePieTheme* _tmp9_;
					const gchar* _tmp10_;
					const gchar* _tmp11_;
					gchar* _tmp12_;
					self->is_valid_theme = TRUE;
					_tmp9_ = tmp_theme;
					_tmp10_ = gnome_pie_theme_get_name (_tmp9_);
					_tmp11_ = _tmp10_;
					_tmp12_ = g_strdup (_tmp11_);
					_g_free0 (self->theme_name);
					self->theme_name = _tmp12_;
				}
				_g_object_unref0 (tmp_theme);
			}
			_g_free0 (tmp_dir);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp13_;
			const gchar* _tmp14_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp13_ = e;
			_tmp14_ = _tmp13_->message;
			g_warning ("themeImporter.vala:58: %s", _tmp14_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp15_ = FALSE;
			_g_object_unref0 (tmp_reader);
			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 _tmp15_;
		}
	}
	_tmp16_ = tmp_reader;
	gnome_pie_archive_reader_close (_tmp16_);
	result = gnome_pie_archive_reader_open (G_TYPE_CHECK_INSTANCE_CAST (self, GNOME_PIE_TYPE_ARCHIVE_READER, GnomePieArchiveReader), path);
	_g_object_unref0 (tmp_reader);
	return result;
}

GnomePieThemeImporter*
gnome_pie_theme_importer_construct (GType object_type)
{
	GnomePieThemeImporter * self = NULL;
	self = (GnomePieThemeImporter*) gnome_pie_archive_reader_construct (object_type);
	return self;
}

GnomePieThemeImporter*
gnome_pie_theme_importer_new (void)
{
	return gnome_pie_theme_importer_construct (GNOME_PIE_TYPE_THEME_IMPORTER);
}

static void
gnome_pie_theme_importer_class_init (GnomePieThemeImporterClass * klass,
                                     gpointer klass_data)
{
	gnome_pie_theme_importer_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = gnome_pie_theme_importer_finalize;
}

static void
gnome_pie_theme_importer_instance_init (GnomePieThemeImporter * self,
                                        gpointer klass)
{
}

static void
gnome_pie_theme_importer_finalize (GObject * obj)
{
	GnomePieThemeImporter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GNOME_PIE_TYPE_THEME_IMPORTER, GnomePieThemeImporter);
	_g_free0 (self->theme_name);
	G_OBJECT_CLASS (gnome_pie_theme_importer_parent_class)->finalize (obj);
}

static GType
gnome_pie_theme_importer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GnomePieThemeImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gnome_pie_theme_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GnomePieThemeImporter), 0, (GInstanceInitFunc) gnome_pie_theme_importer_instance_init, NULL };
	GType gnome_pie_theme_importer_type_id;
	gnome_pie_theme_importer_type_id = g_type_register_static (GNOME_PIE_TYPE_ARCHIVE_READER, "GnomePieThemeImporter", &g_define_type_info, 0);
	return gnome_pie_theme_importer_type_id;
}

GType
gnome_pie_theme_importer_get_type (void)
{
	static volatile gsize gnome_pie_theme_importer_type_id__once = 0;
	if (g_once_init_enter (&gnome_pie_theme_importer_type_id__once)) {
		GType gnome_pie_theme_importer_type_id;
		gnome_pie_theme_importer_type_id = gnome_pie_theme_importer_get_type_once ();
		g_once_init_leave (&gnome_pie_theme_importer_type_id__once, gnome_pie_theme_importer_type_id);
	}
	return gnome_pie_theme_importer_type_id__once;
}

