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

/*
* Copyright (c) 2019 Felipe Escoto (https://github.com/Philip-Scott/Notes-up)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authored by: Felipe Escoto <felescoto95@hotmail.com>
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <granite.h>
#include <gobject/gvaluecollector.h>

#define ENOTES_STYLE_LOADER_RESOURCE_PATH "resource:///com/github/philip-scott/notes-up/styles/%s.css"
#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 ENOTES_TYPE_STYLE_LOADER (enotes_style_loader_get_type ())
#define ENOTES_STYLE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_STYLE_LOADER, ENotesStyleLoader))
#define ENOTES_STYLE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_STYLE_LOADER, ENotesStyleLoaderClass))
#define ENOTES_IS_STYLE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_STYLE_LOADER))
#define ENOTES_IS_STYLE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_STYLE_LOADER))
#define ENOTES_STYLE_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_STYLE_LOADER, ENotesStyleLoaderClass))

typedef struct _ENotesStyleLoader ENotesStyleLoader;
typedef struct _ENotesStyleLoaderClass ENotesStyleLoaderClass;
typedef struct _ENotesStyleLoaderPrivate ENotesStyleLoaderPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define ENOTES_SERVICES_TYPE_SETTINGS (enotes_services_settings_get_type ())
#define ENOTES_SERVICES_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettings))
#define ENOTES_SERVICES_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettingsClass))
#define ENOTES_SERVICES_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_SERVICES_TYPE_SETTINGS))
#define ENOTES_SERVICES_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_SERVICES_TYPE_SETTINGS))
#define ENOTES_SERVICES_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettingsClass))

typedef struct _ENotesServicesSettings ENotesServicesSettings;
typedef struct _ENotesServicesSettingsClass ENotesServicesSettingsClass;

#define TYPE_DATABASE_TABLE (database_table_get_type ())
#define DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_TABLE, DatabaseTable))
#define DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_TABLE, DatabaseTableClass))
#define IS_DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_TABLE))
#define IS_DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_TABLE))
#define DATABASE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_TABLE, DatabaseTableClass))

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define ENOTES_TYPE_NOTEBOOK_TABLE (enotes_notebook_table_get_type ())
#define ENOTES_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTable))
#define ENOTES_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))
#define ENOTES_IS_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_IS_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_NOTEBOOK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))

typedef struct _ENotesNotebookTable ENotesNotebookTable;
typedef struct _ENotesNotebookTableClass ENotesNotebookTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _enotes_style_loader_unref0(var) ((var == NULL) ? NULL : (var = (enotes_style_loader_unref (var), NULL)))
typedef struct _ENotesParamSpecStyleLoader ENotesParamSpecStyleLoader;

struct _ENotesStyleLoader {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ENotesStyleLoaderPrivate * priv;
};

struct _ENotesStyleLoaderClass {
	GTypeClass parent_class;
	void (*finalize) (ENotesStyleLoader *self);
};

struct _ENotesParamSpecStyleLoader {
	GParamSpec parent_instance;
};

static gpointer enotes_style_loader_parent_class = NULL;
VALA_EXTERN gchar** enotes_style_loader_STYLES;
VALA_EXTERN gint enotes_style_loader_STYLES_length1;
gchar** enotes_style_loader_STYLES = NULL;
gint enotes_style_loader_STYLES_length1 = 0;
static ENotesStyleLoader* enotes_style_loader__instance;
static ENotesStyleLoader* enotes_style_loader__instance = NULL;
VALA_EXTERN ENotesServicesSettings* enotes_settings;

VALA_EXTERN gpointer enotes_style_loader_ref (gpointer instance);
VALA_EXTERN void enotes_style_loader_unref (gpointer instance);
VALA_EXTERN GParamSpec* enotes_param_spec_style_loader (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags);
VALA_EXTERN void enotes_value_set_style_loader (GValue* value,
                                    gpointer v_object);
VALA_EXTERN void enotes_value_take_style_loader (GValue* value,
                                     gpointer v_object);
VALA_EXTERN gpointer enotes_value_get_style_loader (const GValue* value);
VALA_EXTERN GType enotes_style_loader_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesStyleLoader, enotes_style_loader_unref)
VALA_EXTERN gchar* enotes_style_loader_get_styleshet (ENotesStyleLoader* self,
                                          const gchar* stylesheet,
                                          gint64 current_page_id,
                                          gboolean trying_global);
static gchar* enotes_style_loader_get_data (GFile* file);
VALA_EXTERN GType enotes_services_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesServicesSettings, g_object_unref)
VALA_EXTERN const gchar* enotes_services_settings_get_stylesheet (ENotesServicesSettings* self);
VALA_EXTERN const gchar* enotes_services_settings_get_render_stylesheet (ENotesServicesSettings* self);
VALA_EXTERN gpointer database_table_ref (gpointer instance);
VALA_EXTERN void database_table_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_database_table (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_database_table (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_database_table (const GValue* value);
VALA_EXTERN GType database_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseTable, database_table_unref)
VALA_EXTERN GType enotes_notebook_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookTable, database_table_unref)
VALA_EXTERN ENotesNotebookTable* enotes_notebook_table_get_instance (void);
VALA_EXTERN gchar* enotes_notebook_table_get_css_from_page (ENotesNotebookTable* self,
                                                gint64 page_id);
VALA_EXTERN ENotesStyleLoader* enotes_style_loader_new (void);
VALA_EXTERN ENotesStyleLoader* enotes_style_loader_construct (GType object_type);
VALA_EXTERN ENotesStyleLoader* enotes_style_loader_get_instance (void);
static void enotes_style_loader_finalize (ENotesStyleLoader * obj);
static GType enotes_style_loader_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gchar*
enotes_style_loader_get_styleshet (ENotesStyleLoader* self,
                                   const gchar* stylesheet,
                                   gint64 current_page_id,
                                   gboolean trying_global)
{
	gchar* css = NULL;
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (stylesheet == NULL) {
		stylesheet = "";
	}
	_tmp0_ = stylesheet;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (((_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("elementary")))) || (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("Modest"))))) || (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("Air"))))) {
		switch (0) {
			default:
			{
				GFile* file = NULL;
				gchar* _tmp3_;
				gchar* _tmp4_;
				GFile* _tmp5_;
				GFile* _tmp6_;
				GFile* _tmp7_;
				gchar* _tmp8_;
				_tmp3_ = g_strdup_printf (ENOTES_STYLE_LOADER_RESOURCE_PATH, stylesheet);
				_tmp4_ = _tmp3_;
				_tmp5_ = g_file_new_for_uri (_tmp4_);
				_tmp6_ = _tmp5_;
				_g_free0 (_tmp4_);
				file = _tmp6_;
				_tmp7_ = file;
				_tmp8_ = enotes_style_loader_get_data (_tmp7_);
				_g_free0 (css);
				css = _tmp8_;
				_g_object_unref0 (file);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				if (trying_global == FALSE) {
					ENotesServicesSettings* _tmp9_;
					const gchar* _tmp10_;
					const gchar* _tmp11_;
					gchar* _tmp12_;
					_tmp9_ = enotes_settings;
					_tmp10_ = enotes_services_settings_get_stylesheet (_tmp9_);
					_tmp11_ = _tmp10_;
					_tmp12_ = enotes_style_loader_get_styleshet (self, _tmp11_, current_page_id, TRUE);
					_g_free0 (css);
					css = _tmp12_;
				} else {
					GFile* file = NULL;
					gchar* _tmp13_;
					gchar* _tmp14_;
					GFile* _tmp15_;
					GFile* _tmp16_;
					GFile* _tmp17_;
					gchar* _tmp18_;
					_tmp13_ = g_strdup_printf (ENOTES_STYLE_LOADER_RESOURCE_PATH, "elementary");
					_tmp14_ = _tmp13_;
					_tmp15_ = g_file_new_for_uri (_tmp14_);
					_tmp16_ = _tmp15_;
					_g_free0 (_tmp14_);
					file = _tmp16_;
					_tmp17_ = file;
					_tmp18_ = enotes_style_loader_get_data (_tmp17_);
					_g_free0 (css);
					css = _tmp18_;
					_g_object_unref0 (file);
				}
				break;
			}
		}
	}
	if (!trying_global) {
		const gchar* _tmp19_;
		ENotesServicesSettings* _tmp20_;
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		ENotesNotebookTable* _tmp25_;
		ENotesNotebookTable* _tmp26_;
		gchar* _tmp27_;
		gchar* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		_tmp19_ = css;
		_tmp20_ = enotes_settings;
		_tmp21_ = enotes_services_settings_get_render_stylesheet (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = g_strconcat (_tmp19_, _tmp22_, NULL);
		_tmp24_ = _tmp23_;
		_tmp25_ = enotes_notebook_table_get_instance ();
		_tmp26_ = _tmp25_;
		_tmp27_ = enotes_notebook_table_get_css_from_page (_tmp26_, current_page_id);
		_tmp28_ = _tmp27_;
		_tmp29_ = g_strconcat (_tmp24_, _tmp28_, NULL);
		_tmp30_ = _tmp29_;
		_g_free0 (_tmp28_);
		_database_table_unref0 (_tmp26_);
		_g_free0 (_tmp24_);
		result = _tmp30_;
		_g_free0 (css);
		return result;
	}
	result = css;
	return result;
}

static gchar*
enotes_style_loader_get_data (GFile* file)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (file != NULL, NULL);
	{
		GFileInputStream* _tmp0_ = NULL;
		GFileInputStream* _tmp1_;
		GDataInputStream* dis = NULL;
		GDataInputStream* _tmp2_;
		gsize size = 0UL;
		gchar* _tmp3_ = NULL;
		GDataInputStream* _tmp4_;
		gsize _tmp5_ = 0UL;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp1_ = g_file_read (file, NULL, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = g_data_input_stream_new ((GInputStream*) _tmp0_);
		dis = _tmp2_;
		_tmp4_ = dis;
		_tmp6_ = g_data_input_stream_read_upto (_tmp4_, "\0", (gssize) -1, &_tmp5_, NULL, &_inner_error0_);
		size = _tmp5_;
		_tmp3_ = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (dis);
			_g_object_unref0 (_tmp0_);
			goto __catch0_g_error;
		}
		_tmp7_ = _tmp3_;
		_tmp3_ = NULL;
		result = _tmp7_;
		_g_free0 (_tmp3_);
		_g_object_unref0 (dis);
		_g_object_unref0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		g_warning ("StyleLoader.vala:73: Could not load from gresource %s", _tmp9_);
		_tmp10_ = g_strdup ("");
		result = _tmp10_;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	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;
}

ENotesStyleLoader*
enotes_style_loader_construct (GType object_type)
{
	ENotesStyleLoader* self = NULL;
	self = (ENotesStyleLoader*) g_type_create_instance (object_type);
	return self;
}

ENotesStyleLoader*
enotes_style_loader_new (void)
{
	return enotes_style_loader_construct (ENOTES_TYPE_STYLE_LOADER);
}

ENotesStyleLoader*
enotes_style_loader_get_instance (void)
{
	ENotesStyleLoader* result;
	ENotesStyleLoader* _tmp0_;
	ENotesStyleLoader* _tmp2_;
	_tmp0_ = enotes_style_loader__instance;
	if (_tmp0_ == NULL) {
		ENotesStyleLoader* _tmp1_;
		_tmp1_ = enotes_style_loader_new ();
		_enotes_style_loader_unref0 (enotes_style_loader__instance);
		enotes_style_loader__instance = _tmp1_;
	}
	_tmp2_ = enotes_style_loader__instance;
	result = _tmp2_;
	return result;
}

static void
enotes_value_style_loader_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
enotes_value_style_loader_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		enotes_style_loader_unref (value->data[0].v_pointer);
	}
}

static void
enotes_value_style_loader_copy_value (const GValue* src_value,
                                      GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = enotes_style_loader_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
enotes_value_style_loader_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
enotes_value_style_loader_collect_value (GValue* value,
                                         guint n_collect_values,
                                         GTypeCValue* collect_values,
                                         guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		ENotesStyleLoader * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = enotes_style_loader_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
enotes_value_style_loader_lcopy_value (const GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
	ENotesStyleLoader ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = enotes_style_loader_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
enotes_param_spec_style_loader (const gchar* name,
                                const gchar* nick,
                                const gchar* blurb,
                                GType object_type,
                                GParamFlags flags)
{
	ENotesParamSpecStyleLoader* spec;
	g_return_val_if_fail (g_type_is_a (object_type, ENOTES_TYPE_STYLE_LOADER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
enotes_value_get_style_loader (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ENOTES_TYPE_STYLE_LOADER), NULL);
	return value->data[0].v_pointer;
}

void
enotes_value_set_style_loader (GValue* value,
                               gpointer v_object)
{
	ENotesStyleLoader * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ENOTES_TYPE_STYLE_LOADER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, ENOTES_TYPE_STYLE_LOADER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		enotes_style_loader_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		enotes_style_loader_unref (old);
	}
}

void
enotes_value_take_style_loader (GValue* value,
                                gpointer v_object)
{
	ENotesStyleLoader * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, ENOTES_TYPE_STYLE_LOADER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, ENOTES_TYPE_STYLE_LOADER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		enotes_style_loader_unref (old);
	}
}

static void
enotes_style_loader_class_init (ENotesStyleLoaderClass * klass,
                                gpointer klass_data)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	enotes_style_loader_parent_class = g_type_class_peek_parent (klass);
	((ENotesStyleLoaderClass *) klass)->finalize = enotes_style_loader_finalize;
	_tmp0_ = g_strdup (_ ("Default"));
	_tmp1_ = g_strdup ("elementary");
	_tmp2_ = g_strdup ("Air");
	_tmp3_ = g_strdup ("Modest");
	_tmp4_ = g_new0 (gchar*, 4 + 1);
	_tmp4_[0] = _tmp0_;
	_tmp4_[1] = _tmp1_;
	_tmp4_[2] = _tmp2_;
	_tmp4_[3] = _tmp3_;
	enotes_style_loader_STYLES = _tmp4_;
	enotes_style_loader_STYLES_length1 = 4;
}

static void
enotes_style_loader_instance_init (ENotesStyleLoader * self,
                                   gpointer klass)
{
	self->ref_count = 1;
}

static void
enotes_style_loader_finalize (ENotesStyleLoader * obj)
{
	ENotesStyleLoader * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_STYLE_LOADER, ENotesStyleLoader);
	g_signal_handlers_destroy (self);
}

static GType
enotes_style_loader_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { enotes_value_style_loader_init, enotes_value_style_loader_free_value, enotes_value_style_loader_copy_value, enotes_value_style_loader_peek_pointer, "p", enotes_value_style_loader_collect_value, "p", enotes_value_style_loader_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ENotesStyleLoaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_style_loader_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesStyleLoader), 0, (GInstanceInitFunc) enotes_style_loader_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType enotes_style_loader_type_id;
	enotes_style_loader_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ENotesStyleLoader", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return enotes_style_loader_type_id;
}

GType
enotes_style_loader_get_type (void)
{
	static volatile gsize enotes_style_loader_type_id__once = 0;
	if (g_once_init_enter (&enotes_style_loader_type_id__once)) {
		GType enotes_style_loader_type_id;
		enotes_style_loader_type_id = enotes_style_loader_get_type_once ();
		g_once_init_leave (&enotes_style_loader_type_id__once, enotes_style_loader_type_id);
	}
	return enotes_style_loader_type_id__once;
}

gpointer
enotes_style_loader_ref (gpointer instance)
{
	ENotesStyleLoader * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
enotes_style_loader_unref (gpointer instance)
{
	ENotesStyleLoader * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		ENOTES_STYLE_LOADER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

