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

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include "graphs.h"
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <gee.h>
#include <adwaita.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 _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
enum  {
	GRAPHS_STYLE_MANAGER_0_PROPERTY,
	GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY,
	GRAPHS_STYLE_MANAGER_NUM_PROPERTIES
};
static GParamSpec* graphs_style_manager_properties[GRAPHS_STYLE_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GraphsStyleManagerOnFileChangeData GraphsStyleManagerOnFileChangeData;
enum  {
	GRAPHS_STYLE_MANAGER_STYLE_CHANGED_SIGNAL,
	GRAPHS_STYLE_MANAGER_STYLE_DELETED_SIGNAL,
	GRAPHS_STYLE_MANAGER_STYLE_RENAMED_SIGNAL,
	GRAPHS_STYLE_MANAGER_CREATE_STYLE_REQUEST_SIGNAL,
	GRAPHS_STYLE_MANAGER_STYLE_REQUEST_SIGNAL,
	GRAPHS_STYLE_MANAGER_NUM_SIGNALS
};
static guint graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_NUM_SIGNALS] = {0};
enum  {
	GRAPHS_STYLE_0_PROPERTY,
	GRAPHS_STYLE_NAME_PROPERTY,
	GRAPHS_STYLE_PREVIEW_PROPERTY,
	GRAPHS_STYLE_FILE_PROPERTY,
	GRAPHS_STYLE_MUTABLE_PROPERTY,
	GRAPHS_STYLE_LIGHT_PROPERTY,
	GRAPHS_STYLE_NUM_PROPERTIES
};
static GParamSpec* graphs_style_properties[GRAPHS_STYLE_NUM_PROPERTIES];

#define GRAPHS_TYPE_STYLE_PREVIEW (graphs_style_preview_get_type ())
#define GRAPHS_STYLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview))
#define GRAPHS_STYLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreviewClass))
#define GRAPHS_IS_STYLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRAPHS_TYPE_STYLE_PREVIEW))
#define GRAPHS_IS_STYLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRAPHS_TYPE_STYLE_PREVIEW))
#define GRAPHS_STYLE_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreviewClass))

typedef struct _GraphsStylePreview GraphsStylePreview;
typedef struct _GraphsStylePreviewClass GraphsStylePreviewClass;
typedef struct _GraphsStylePreviewPrivate GraphsStylePreviewPrivate;
enum  {
	GRAPHS_STYLE_PREVIEW_0_PROPERTY,
	GRAPHS_STYLE_PREVIEW_MENU_BUTTON_PROPERTY,
	GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY,
	GRAPHS_STYLE_PREVIEW_STYLENAME_PROPERTY,
	GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY,
	GRAPHS_STYLE_PREVIEW_NUM_PROPERTIES
};
static GParamSpec* graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_NUM_PROPERTIES];
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _GraphsImportStyleData GraphsImportStyleData;

struct _GraphsStyleManagerPrivate {
	GtkCssProvider* _css_provider;
};

struct _GraphsStyleManagerOnFileChangeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GFile* file;
	GFile* other_file;
	GFileMonitorEvent event_type;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	GraphsStyle* style;
	gint index;
	GraphsStyle* _tmp3_;
	gint _tmp4_;
	GListStore* _tmp5_;
	GListStore* _tmp6_;
	GraphsStyleManager* _tmp7_;
	GraphsStyleManager* _tmp8_;
	GraphsStyle* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GraphsStyle* _tmp12_;
	GraphsStyle* _tmp13_;
	GraphsStyleManager* _tmp14_;
	GraphsStyleManager* _tmp15_;
	GraphsStyle* _tmp16_;
	GraphsStyle* _tmp17_;
	GraphsStyle* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gint _tmp21_;
	gchar** _tmp22_;
	gchar** _tmp23_;
	gint _tmp23__length1;
	gchar* _tmp24_;
	gchar* _tmp25_;
	GCompareDataFunc cmp;
	gpointer cmp_target;
	GDestroyNotify cmp_target_destroy_notify;
	GListStore* _tmp26_;
	GListStore* _tmp27_;
	GraphsStyle* _tmp28_;
	GCompareDataFunc _tmp29_;
	gpointer _tmp29__target;
	GraphsStyle* tmp_style;
	GraphsStyleManager* _tmp30_;
	GraphsStyleManager* _tmp31_;
	GraphsStyle* _tmp32_;
	GraphsStyle* _tmp33_;
	GraphsStyle* _tmp34_;
	GdkTexture* _tmp35_;
	GdkTexture* _tmp36_;
	GraphsStyle* _tmp37_;
	GraphsStyle* _tmp38_;
	gboolean _tmp39_;
	gboolean _tmp40_;
	GraphsStyle* _tmp41_;
	const gchar* _tmp42_;
	const gchar* _tmp43_;
	GraphsStyle* _tmp44_;
	const gchar* _tmp45_;
	const gchar* _tmp46_;
	GraphsStyleManager* _tmp47_;
	GraphsStyleManager* _tmp48_;
	GraphsStyle* _tmp49_;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	gchar* old_name;
	GraphsStyle* _tmp52_;
	const gchar* _tmp53_;
	const gchar* _tmp54_;
	gchar* _tmp55_;
	GraphsStyle* _tmp56_;
	GraphsStyle* _tmp57_;
	const gchar* _tmp58_;
	const gchar* _tmp59_;
	gint _tmp60_;
	gchar** _tmp61_;
	gchar** _tmp62_;
	gint _tmp62__length1;
	gchar* _tmp63_;
	gchar* _tmp64_;
	GraphsStyleManager* _tmp65_;
	GraphsStyleManager* _tmp66_;
	const gchar* _tmp67_;
	GraphsStyle* _tmp68_;
	const gchar* _tmp69_;
	const gchar* _tmp70_;
};

struct _GraphsStylePrivate {
	gchar* _name;
	GdkTexture* _preview;
	GFile* _file;
	gboolean _mutable;
	gboolean _light;
};

struct _GraphsStylePreview {
	AdwBin parent_instance;
	GraphsStylePreviewPrivate * priv;
};

struct _GraphsStylePreviewClass {
	AdwBinClass parent_class;
};

struct _GraphsStylePreviewPrivate {
	GtkLabel* _label;
	GtkPicture* _picture;
	GtkMenuButton* _menu_button;
	GraphsStyle* _style;
	GtkCssProvider* provider;
};

struct _GraphsImportStyleData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GtkWindow* window;
	GtkFileDialog* dialog;
	GtkFileDialog* _tmp0_;
	GtkFileDialog* _tmp1_;
	GListModel* _tmp2_;
	GListModel* _tmp3_;
	GFile* file;
	GtkFileDialog* _tmp4_;
	GFile* _tmp5_;
	gchar* filename;
	GFile* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GFile* style_dir;
	GFile* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	GFile* destination;
	GFile* _tmp12_;
	const gchar* _tmp13_;
	GFile* _tmp14_;
	guint i;
	GFile* _tmp15_;
	GString* new_filename;
	GString* _tmp16_;
	GString* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GString* _tmp21_;
	GString* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	GString* _tmp25_;
	GFile* _tmp26_;
	GFile* _tmp27_;
	GString* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	GFile* _tmp31_;
	GFile* _tmp32_;
	GFile* _tmp33_;
	guint _tmp34_;
	GFile* _tmp35_;
	GFile* _tmp36_;
	GError* _inner_error0_;
};

static gint GraphsStyleManager_private_offset;
static gpointer graphs_style_manager_parent_class = NULL;
static GListStore* graphs_style_manager__style_model;
static GListStore* graphs_style_manager__style_model = NULL;
static GtkFilterListModel* graphs_style_manager__filtered_style_model;
static GtkFilterListModel* graphs_style_manager__filtered_style_model = NULL;
static GFile* graphs_style_manager__style_dir;
static GFile* graphs_style_manager__style_dir = NULL;
static GraphsStyleManager* graphs_style_manager__instance;
static GraphsStyleManager* graphs_style_manager__instance = NULL;
static gint GraphsStyle_private_offset;
static gpointer graphs_style_parent_class = NULL;
static gint GraphsStylePreview_private_offset;
static gpointer graphs_style_preview_parent_class = NULL;

VALA_EXTERN gboolean graphs_filter_system_style (GObject* style);
static void graphs_style_manager_set_instance (GraphsStyleManager* value);
static void graphs_style_manager_set_style_model (GListStore* value);
static gboolean _graphs_filter_system_style_gtk_custom_filter_func (GObject* item,
                                                             gpointer self);
static void graphs_style_manager_set_filtered_style_model (GtkFilterListModel* value);
static void graphs_style_manager_set_style_dir (GFile* value);
static gint _graphs_style_cmp_gcompare_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self);
static void graphs_style_manager_on_file_change (GFile* file,
                                          GFile* other_file,
                                          GFileMonitorEvent event_type,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void graphs_style_manager_on_file_change_finish (GAsyncResult* _res_);
static void _graphs_style_manager_on_file_change_g_file_monitor_changed (GFileMonitor* _sender,
                                                                  GFile* file,
                                                                  GFile* other_file,
                                                                  GFileMonitorEvent event_type,
                                                                  gpointer self);
static void graphs_style_manager_on_file_change_data_free (gpointer _data);
static gboolean graphs_style_manager_on_file_change_co (GraphsStyleManagerOnFileChangeData* _data_);
static gint graphs_style_manager_find_style_for_file (GFile* file,
                                               GraphsStyle** style);
static void graphs_style_manager_set_css_provider (GraphsStyleManager* self,
                                            GtkCssProvider* value);
static void g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_STRING (GClosure * closure,
                                                         GValue * return_value,
                                                         guint n_param_values,
                                                         const GValue * param_values,
                                                         gpointer invocation_hint,
                                                         gpointer marshal_data);
static void g_cclosure_user_marshal_OBJECT__OBJECT (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data);
static GObject * graphs_style_manager_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void graphs_style_manager_finalize (GObject * obj);
static GType graphs_style_manager_get_type_once (void);
static void _vala_graphs_style_manager_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_graphs_style_manager_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static void graphs_style_finalize (GObject * obj);
static GType graphs_style_get_type_once (void);
static void _vala_graphs_style_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_graphs_style_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);
VALA_EXTERN GType graphs_style_preview_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GraphsStylePreview* graphs_style_preview_new (void);
VALA_EXTERN GraphsStylePreview* graphs_style_preview_construct (GType object_type);
static GtkLabel* graphs_style_preview_get_label (GraphsStylePreview* self);
static GtkPicture* graphs_style_preview_get_picture (GraphsStylePreview* self);
VALA_EXTERN GtkMenuButton* graphs_style_preview_get_menu_button (GraphsStylePreview* self);
VALA_EXTERN GraphsStyle* graphs_style_preview_get_style (GraphsStylePreview* self);
VALA_EXTERN void graphs_style_preview_set_style (GraphsStylePreview* self,
                                     GraphsStyle* value);
VALA_EXTERN void graphs_style_preview_set_stylename (GraphsStylePreview* self,
                                         const gchar* value);
VALA_EXTERN GdkTexture* graphs_style_preview_get_preview (GraphsStylePreview* self);
VALA_EXTERN void graphs_style_preview_set_preview (GraphsStylePreview* self,
                                       GdkTexture* value);
static GObject * graphs_style_preview_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void graphs_style_preview_finalize (GObject * obj);
static GType graphs_style_preview_get_type_once (void);
static void _vala_graphs_style_preview_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_graphs_style_preview_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static void graphs_import_style_data_free (gpointer _data);
static gboolean graphs_import_style_co (GraphsImportStyleData* _data_);
static void graphs_import_style_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gint
graphs_style_cmp (GraphsStyle* a,
                  GraphsStyle* b)
{
	GFile* _tmp0_;
	GFile* _tmp1_;
	GCompareFunc _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gint _tmp13_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = graphs_style_get_file (a);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		result = -1;
		return result;
	} else {
		GFile* _tmp2_;
		GFile* _tmp3_;
		_tmp2_ = graphs_style_get_file (b);
		_tmp3_ = _tmp2_;
		if (_tmp3_ == NULL) {
			result = 1;
			return result;
		}
	}
	_tmp4_ = ((GCompareFunc) g_strcmp0);
	_tmp5_ = graphs_style_get_name (a);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_utf8_strdown (_tmp6_, (gssize) -1);
	_tmp8_ = _tmp7_;
	_tmp9_ = graphs_style_get_name (b);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_utf8_strdown (_tmp10_, (gssize) -1);
	_tmp12_ = _tmp11_;
	_tmp13_ = _tmp4_ (_tmp8_, _tmp12_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp8_);
	result = _tmp13_;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__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;
}

gchar*
graphs_filename_from_stylename (const gchar* name)
{
	gchar* filename = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = string_replace (name, " ", "-");
	filename = _tmp0_;
	_tmp1_ = filename;
	_tmp2_ = string_replace (_tmp1_, "(", "");
	_g_free0 (filename);
	filename = _tmp2_;
	_tmp3_ = filename;
	_tmp4_ = string_replace (_tmp3_, ")", "");
	_g_free0 (filename);
	filename = _tmp4_;
	_tmp5_ = filename;
	_tmp6_ = g_utf8_strdown (_tmp5_, (gssize) -1);
	_g_free0 (filename);
	filename = _tmp6_;
	_tmp7_ = filename;
	_tmp8_ = g_strconcat (_tmp7_, ".mplstyle", NULL);
	result = _tmp8_;
	_g_free0 (filename);
	return result;
}

gboolean
graphs_filter_system_style (GObject* style)
{
	GFile* _tmp0_;
	GFile* _tmp1_;
	gboolean result;
	g_return_val_if_fail (style != NULL, FALSE);
	_tmp0_ = graphs_style_get_file (G_TYPE_CHECK_INSTANCE_CAST (style, GRAPHS_TYPE_STYLE, GraphsStyle));
	_tmp1_ = _tmp0_;
	result = _tmp1_ != NULL;
	return result;
}

static inline gpointer
graphs_style_manager_get_instance_private (GraphsStyleManager* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsStyleManager_private_offset);
}

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

static gboolean
_graphs_filter_system_style_gtk_custom_filter_func (GObject* item,
                                                    gpointer self)
{
	gboolean result;
	result = graphs_filter_system_style (item);
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static gchar*
string_chomp (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strchomp (_result_);
	result = _result_;
	return result;
}

static gint
_graphs_style_cmp_gcompare_data_func (gconstpointer a,
                                      gconstpointer b,
                                      gpointer self)
{
	gint result;
	result = graphs_style_cmp ((GraphsStyle*) a, (GraphsStyle*) b);
	return result;
}

static void
_graphs_style_manager_on_file_change_g_file_monitor_changed (GFileMonitor* _sender,
                                                             GFile* file,
                                                             GFile* other_file,
                                                             GFileMonitorEvent event_type,
                                                             gpointer self)
{
	graphs_style_manager_on_file_change (file, other_file, event_type, NULL, NULL);
}

void
graphs_style_manager_setup (GraphsStyleManager* self,
                            const gchar* system_style)
{
	GListStore* _tmp0_;
	GListStore* _tmp1_;
	GListStore* _tmp2_;
	GListStore* _tmp3_;
	GListModel* _tmp4_;
	GtkCustomFilter* _tmp5_;
	GtkFilterListModel* _tmp6_;
	GtkFilterListModel* _tmp7_;
	GListStore* _tmp16_;
	GListStore* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GdkTexture* _tmp21_;
	GdkTexture* _tmp22_;
	GraphsStyle* _tmp23_;
	GraphsStyle* _tmp24_;
	GFile* style_list = NULL;
	GFile* _tmp25_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (system_style != NULL);
	graphs_style_manager_set_instance (self);
	_tmp0_ = g_list_store_new (GRAPHS_TYPE_STYLE);
	_tmp1_ = _tmp0_;
	graphs_style_manager_set_style_model (_tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = graphs_style_manager_get_style_model ();
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 ((GListModel*) _tmp3_);
	_tmp5_ = gtk_custom_filter_new (_graphs_filter_system_style_gtk_custom_filter_func, NULL, NULL);
	_tmp6_ = gtk_filter_list_model_new (_tmp4_, (GtkFilter*) _tmp5_);
	_tmp7_ = _tmp6_;
	graphs_style_manager_set_filtered_style_model (_tmp7_);
	_g_object_unref0 (_tmp7_);
	{
		GFile* config_dir = NULL;
		GFile* _tmp8_;
		GFile* _tmp9_ = NULL;
		GFile* _tmp10_;
		GFile* _tmp11_;
		GFile* _tmp12_;
		GFile* _tmp13_;
		_tmp8_ = graphs_tools_get_config_directory (&_inner_error0_);
		config_dir = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp10_ = config_dir;
		_tmp11_ = g_file_get_child_for_display_name (_tmp10_, "styles", &_inner_error0_);
		_tmp9_ = _tmp11_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (config_dir);
			goto __catch0_g_error;
		}
		graphs_style_manager_set_style_dir (_tmp9_);
		_tmp12_ = graphs_style_manager_get_style_dir ();
		_tmp13_ = _tmp12_;
		if (!g_file_query_exists (_tmp13_, NULL)) {
			GFile* _tmp14_;
			GFile* _tmp15_;
			_tmp14_ = graphs_style_manager_get_style_dir ();
			_tmp15_ = _tmp14_;
			g_file_make_directory_with_parents (_tmp15_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (_tmp9_);
				_g_object_unref0 (config_dir);
				goto __catch0_g_error;
			}
		}
		_g_object_unref0 (_tmp9_);
		_g_object_unref0 (config_dir);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__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_);
		return;
	}
	_tmp16_ = graphs_style_manager_get_style_model ();
	_tmp17_ = _tmp16_;
	_tmp18_ = string_to_string (system_style);
	_tmp19_ = g_strconcat ("/se/sjoerd/Graphs/system-style-", _tmp18_, ".png", NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = gdk_texture_new_from_resource (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = graphs_style_new (_ ("System"), NULL, _tmp22_, FALSE);
	_tmp24_ = _tmp23_;
	g_list_store_append (_tmp17_, (GObject*) _tmp24_);
	_g_object_unref0 (_tmp24_);
	_g_object_unref0 (_tmp22_);
	_g_free0 (_tmp20_);
	_tmp25_ = g_file_new_for_uri ("resource:///se/sjoerd/Graphs/styles.txt");
	style_list = _tmp25_;
	{
		GFileInputStream* _tmp26_ = NULL;
		GFile* _tmp27_;
		GFileInputStream* _tmp28_;
		GDataInputStream* stream = NULL;
		GDataInputStream* _tmp29_;
		gchar* line = NULL;
		_tmp27_ = style_list;
		_tmp28_ = g_file_read (_tmp27_, NULL, &_inner_error0_);
		_tmp26_ = _tmp28_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp29_ = g_data_input_stream_new ((GInputStream*) _tmp26_);
		stream = _tmp29_;
		while (TRUE) {
			gchar* _tmp30_ = NULL;
			GDataInputStream* _tmp31_;
			gchar* _tmp32_;
			gchar* _tmp33_;
			const gchar* _tmp34_;
			gchar** strings = NULL;
			const gchar* _tmp35_;
			gchar* _tmp36_;
			gchar* _tmp37_;
			gchar** _tmp38_;
			gchar** _tmp39_;
			gchar** _tmp40_;
			gint _tmp40__length1;
			gint strings_length1;
			gint _strings_size_;
			GListStore* _tmp41_;
			GListStore* _tmp42_;
			gchar** _tmp43_;
			gint _tmp43__length1;
			const gchar* _tmp44_;
			gchar** _tmp45_;
			gint _tmp45__length1;
			const gchar* _tmp46_;
			gchar* _tmp47_;
			gchar* _tmp48_;
			GFile* _tmp49_;
			GFile* _tmp50_;
			gchar** _tmp51_;
			gint _tmp51__length1;
			const gchar* _tmp52_;
			GdkTexture* _tmp53_;
			GdkTexture* _tmp54_;
			GraphsStyle* _tmp55_;
			GraphsStyle* _tmp56_;
			_tmp31_ = stream;
			_tmp32_ = g_data_input_stream_read_line (_tmp31_, NULL, NULL, &_inner_error0_);
			_tmp30_ = _tmp32_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (line);
				_g_object_unref0 (stream);
				_g_object_unref0 (_tmp26_);
				goto __catch1_g_error;
			}
			_tmp33_ = _tmp30_;
			_tmp30_ = NULL;
			_g_free0 (line);
			line = _tmp33_;
			_tmp34_ = line;
			if (!(_tmp34_ != NULL)) {
				_g_free0 (_tmp30_);
				break;
			}
			_tmp35_ = line;
			_tmp36_ = string_chomp (_tmp35_);
			_tmp37_ = _tmp36_;
			_tmp39_ = _tmp38_ = g_strsplit (_tmp37_, ";", 3);
			_tmp40_ = _tmp39_;
			_tmp40__length1 = _vala_array_length (_tmp38_);
			_g_free0 (_tmp37_);
			strings = _tmp40_;
			strings_length1 = _tmp40__length1;
			_strings_size_ = strings_length1;
			_tmp41_ = graphs_style_manager_get_style_model ();
			_tmp42_ = _tmp41_;
			_tmp43_ = strings;
			_tmp43__length1 = strings_length1;
			_tmp44_ = _tmp43_[0];
			_tmp45_ = strings;
			_tmp45__length1 = strings_length1;
			_tmp46_ = _tmp45_[1];
			_tmp47_ = g_strconcat ("resource://", _tmp46_, NULL);
			_tmp48_ = _tmp47_;
			_tmp49_ = g_file_new_for_uri (_tmp48_);
			_tmp50_ = _tmp49_;
			_tmp51_ = strings;
			_tmp51__length1 = strings_length1;
			_tmp52_ = _tmp51_[2];
			_tmp53_ = gdk_texture_new_from_resource (_tmp52_);
			_tmp54_ = _tmp53_;
			_tmp55_ = graphs_style_new (_tmp44_, _tmp50_, _tmp54_, FALSE);
			_tmp56_ = _tmp55_;
			g_list_store_append (_tmp42_, (GObject*) _tmp56_);
			_g_object_unref0 (_tmp56_);
			_g_object_unref0 (_tmp54_);
			_g_object_unref0 (_tmp50_);
			_g_free0 (_tmp48_);
			strings = (_vala_array_free (strings, strings_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (_tmp30_);
		}
		_g_free0 (line);
		_g_object_unref0 (stream);
		_g_object_unref0 (_tmp26_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (style_list);
		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;
	}
	{
		GFileEnumerator* enumerator = NULL;
		GFile* _tmp57_;
		GFile* _tmp58_;
		GFileEnumerator* _tmp59_;
		GeeList* stylenames = NULL;
		gint _tmp60_ = 0;
		gchar** _tmp61_;
		GeeArrayList* _tmp62_;
		GCompareDataFunc cmp = NULL;
		gpointer cmp_target;
		GDestroyNotify cmp_target_destroy_notify;
		GFileInfo* info = NULL;
		GFileEnumerator* _tmp98_;
		GFileMonitor* style_monitor = NULL;
		GFile* _tmp99_;
		GFile* _tmp100_;
		GFileMonitor* _tmp101_;
		GFileMonitor* _tmp102_;
		GFileMonitor* _tmp103_;
		_tmp57_ = graphs_style_manager_get_style_dir ();
		_tmp58_ = _tmp57_;
		_tmp59_ = g_file_enumerate_children (_tmp58_, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		enumerator = _tmp59_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
		_tmp61_ = graphs_style_manager_list_stylenames (&_tmp60_);
		_tmp62_ = gee_array_list_new_wrap (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp61_, _tmp60_, NULL, NULL, NULL);
		stylenames = (GeeList*) _tmp62_;
		cmp = _graphs_style_cmp_gcompare_data_func;
		cmp_target = NULL;
		cmp_target_destroy_notify = NULL;
		info = NULL;
		while (TRUE) {
			GFileInfo* _tmp63_ = NULL;
			GFileEnumerator* _tmp64_;
			GFileInfo* _tmp65_;
			GFileInfo* _tmp66_;
			GFileInfo* _tmp67_;
			GFile* file = NULL;
			GFileEnumerator* _tmp68_;
			GFileInfo* _tmp69_;
			GFile* _tmp70_;
			gboolean _tmp71_ = FALSE;
			GFile* _tmp72_;
			_tmp64_ = enumerator;
			_tmp65_ = g_file_enumerator_next_file (_tmp64_, NULL, &_inner_error0_);
			_tmp63_ = _tmp65_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (info);
				(cmp_target_destroy_notify == NULL) ? NULL : (cmp_target_destroy_notify (cmp_target), NULL);
				cmp = NULL;
				cmp_target = NULL;
				cmp_target_destroy_notify = NULL;
				_g_object_unref0 (stylenames);
				_g_object_unref0 (enumerator);
				goto __catch2_g_error;
			}
			_tmp66_ = _tmp63_;
			_tmp63_ = NULL;
			_g_object_unref0 (info);
			info = _tmp66_;
			_tmp67_ = info;
			if (!(_tmp67_ != NULL)) {
				_g_object_unref0 (_tmp63_);
				break;
			}
			_tmp68_ = enumerator;
			_tmp69_ = info;
			_tmp70_ = g_file_enumerator_get_child (_tmp68_, _tmp69_);
			file = _tmp70_;
			_tmp72_ = file;
			if (g_file_query_file_type (_tmp72_, 0, NULL) == 1) {
				GFile* _tmp73_;
				gchar* _tmp74_;
				gchar* _tmp75_;
				_tmp73_ = file;
				_tmp74_ = graphs_tools_get_filename (_tmp73_);
				_tmp75_ = _tmp74_;
				_tmp71_ = g_str_has_suffix (_tmp75_, ".mplstyle");
				_g_free0 (_tmp75_);
			} else {
				_tmp71_ = FALSE;
			}
			if (_tmp71_) {
				GraphsStyle* style = NULL;
				GraphsStyleManager* _tmp76_;
				GraphsStyleManager* _tmp77_;
				GFile* _tmp78_;
				GraphsStyle* _tmp79_ = NULL;
				GraphsStyle* _tmp80_;
				GraphsStyle* _tmp81_;
				const gchar* _tmp82_;
				const gchar* _tmp83_;
				GeeList* _tmp84_;
				gint _tmp85_ = 0;
				gpointer* _tmp86_;
				gchar** _tmp87_;
				gint _tmp87__length1;
				gchar* _tmp88_;
				gchar* _tmp89_;
				GListStore* _tmp90_;
				GListStore* _tmp91_;
				GraphsStyle* _tmp92_;
				GCompareDataFunc _tmp93_;
				gpointer _tmp93__target;
				GeeList* _tmp94_;
				GraphsStyle* _tmp95_;
				const gchar* _tmp96_;
				const gchar* _tmp97_;
				_tmp76_ = graphs_style_manager_get_instance ();
				_tmp77_ = _tmp76_;
				_tmp78_ = file;
				g_signal_emit (_tmp77_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_REQUEST_SIGNAL], 0, _tmp78_, &_tmp79_);
				style = _tmp79_;
				_tmp80_ = style;
				_tmp81_ = style;
				_tmp82_ = graphs_style_get_name (_tmp81_);
				_tmp83_ = _tmp82_;
				_tmp84_ = stylenames;
				_tmp86_ = gee_collection_to_array ((GeeCollection*) _tmp84_, &_tmp85_);
				_tmp87_ = _tmp86_;
				_tmp87__length1 = _tmp85_;
				_tmp88_ = graphs_tools_get_duplicate_string (_tmp83_, _tmp87_, (gint) _tmp85_);
				_tmp89_ = _tmp88_;
				graphs_style_set_name (_tmp80_, _tmp89_);
				_g_free0 (_tmp89_);
				_tmp87_ = (_vala_array_free (_tmp87_, _tmp87__length1, (GDestroyNotify) g_free), NULL);
				_tmp90_ = graphs_style_manager_get_style_model ();
				_tmp91_ = _tmp90_;
				_tmp92_ = style;
				_tmp93_ = cmp;
				_tmp93__target = cmp_target;
				g_list_store_insert_sorted (_tmp91_, (GObject*) _tmp92_, _tmp93_, _tmp93__target);
				_tmp94_ = stylenames;
				_tmp95_ = style;
				_tmp96_ = graphs_style_get_name (_tmp95_);
				_tmp97_ = _tmp96_;
				gee_collection_add ((GeeCollection*) _tmp94_, _tmp97_);
				_g_object_unref0 (style);
			}
			_g_object_unref0 (file);
			_g_object_unref0 (_tmp63_);
		}
		_tmp98_ = enumerator;
		g_file_enumerator_close (_tmp98_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (info);
			(cmp_target_destroy_notify == NULL) ? NULL : (cmp_target_destroy_notify (cmp_target), NULL);
			cmp = NULL;
			cmp_target = NULL;
			cmp_target_destroy_notify = NULL;
			_g_object_unref0 (stylenames);
			_g_object_unref0 (enumerator);
			goto __catch2_g_error;
		}
		_tmp99_ = graphs_style_manager_get_style_dir ();
		_tmp100_ = _tmp99_;
		_tmp101_ = g_file_monitor_directory (_tmp100_, G_FILE_MONITOR_NONE, NULL, &_inner_error0_);
		style_monitor = _tmp101_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (info);
			(cmp_target_destroy_notify == NULL) ? NULL : (cmp_target_destroy_notify (cmp_target), NULL);
			cmp = NULL;
			cmp_target = NULL;
			cmp_target_destroy_notify = NULL;
			_g_object_unref0 (stylenames);
			_g_object_unref0 (enumerator);
			goto __catch2_g_error;
		}
		_tmp102_ = style_monitor;
		g_signal_connect (_tmp102_, "changed", (GCallback) _graphs_style_manager_on_file_change_g_file_monitor_changed, NULL);
		_tmp103_ = style_monitor;
		g_object_ref ((GObject*) _tmp103_);
		_g_object_unref0 (style_monitor);
		_g_object_unref0 (info);
		(cmp_target_destroy_notify == NULL) ? NULL : (cmp_target_destroy_notify (cmp_target), NULL);
		cmp = NULL;
		cmp_target = NULL;
		cmp_target_destroy_notify = NULL;
		_g_object_unref0 (stylenames);
		_g_object_unref0 (enumerator);
	}
	goto __finally2;
	__catch2_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (style_list);
		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;
	}
	_g_object_unref0 (style_list);
}

static void
graphs_style_manager_on_file_change_data_free (gpointer _data)
{
	GraphsStyleManagerOnFileChangeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file);
	_g_object_unref0 (_data_->other_file);
	g_slice_free (GraphsStyleManagerOnFileChangeData, _data_);
}

static void
graphs_style_manager_on_file_change (GFile* file,
                                     GFile* other_file,
                                     GFileMonitorEvent event_type,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	GraphsStyleManagerOnFileChangeData* _data_;
	GFile* _tmp0_;
	GFile* _tmp1_;
	g_return_if_fail (file != NULL);
	_data_ = g_slice_new0 (GraphsStyleManagerOnFileChangeData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, graphs_style_manager_on_file_change_data_free);
	_tmp0_ = _g_object_ref0 (file);
	_g_object_unref0 (_data_->file);
	_data_->file = _tmp0_;
	_tmp1_ = _g_object_ref0 (other_file);
	_g_object_unref0 (_data_->other_file);
	_data_->other_file = _tmp1_;
	_data_->event_type = event_type;
	graphs_style_manager_on_file_change_co (_data_);
}

static void
graphs_style_manager_on_file_change_finish (GAsyncResult* _res_)
{
	GraphsStyleManagerOnFileChangeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static gboolean
graphs_style_manager_on_file_change_co (GraphsStyleManagerOnFileChangeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_file_get_basename (_data_->file);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = string_get (_data_->_tmp1_, (glong) 0) == '.';
	_g_free0 (_data_->_tmp1_);
	if (_data_->_tmp2_) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->style = NULL;
	switch (_data_->event_type) {
		case G_FILE_MONITOR_EVENT_DELETED:
		{
			_data_->_tmp3_ = NULL;
			_data_->_tmp4_ = graphs_style_manager_find_style_for_file (_data_->file, &_data_->_tmp3_);
			_g_object_unref0 (_data_->style);
			_data_->style = _data_->_tmp3_;
			_data_->index = _data_->_tmp4_;
			if (_data_->index == -1) {
				_g_object_unref0 (_data_->style);
				g_task_return_pointer (_data_->_async_result, _data_, NULL);
				if (_data_->_state_ != 0) {
					while (!g_task_get_completed (_data_->_async_result)) {
						g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
					}
				}
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp5_ = graphs_style_manager_get_style_model ();
			_data_->_tmp6_ = _data_->_tmp5_;
			g_list_store_remove (_data_->_tmp6_, (guint) _data_->index);
			_data_->_tmp7_ = graphs_style_manager_get_instance ();
			_data_->_tmp8_ = _data_->_tmp7_;
			_data_->_tmp9_ = _data_->style;
			_data_->_tmp10_ = graphs_style_get_name (_data_->_tmp9_);
			_data_->_tmp11_ = _data_->_tmp10_;
			g_signal_emit (_data_->_tmp8_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_DELETED_SIGNAL], 0, _data_->_tmp11_);
			_g_object_unref0 (_data_->style);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
		{
			_data_->_tmp12_ = NULL;
			graphs_style_manager_find_style_for_file (_data_->file, &_data_->_tmp12_);
			_g_object_unref0 (_data_->style);
			_data_->style = _data_->_tmp12_;
			_data_->_tmp13_ = _data_->style;
			if (_data_->_tmp13_ == NULL) {
				_data_->_tmp14_ = graphs_style_manager_get_instance ();
				_data_->_tmp15_ = _data_->_tmp14_;
				_data_->_tmp16_ = NULL;
				g_signal_emit (_data_->_tmp15_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_REQUEST_SIGNAL], 0, _data_->file, &_data_->_tmp16_);
				_g_object_unref0 (_data_->style);
				_data_->style = _data_->_tmp16_;
				_data_->_tmp17_ = _data_->style;
				_data_->_tmp18_ = _data_->style;
				_data_->_tmp19_ = graphs_style_get_name (_data_->_tmp18_);
				_data_->_tmp20_ = _data_->_tmp19_;
				_data_->_tmp21_ = 0;
				_data_->_tmp22_ = graphs_style_manager_list_stylenames (&_data_->_tmp21_);
				_data_->_tmp23_ = _data_->_tmp22_;
				_data_->_tmp23__length1 = _data_->_tmp21_;
				_data_->_tmp24_ = graphs_tools_get_duplicate_string (_data_->_tmp20_, _data_->_tmp23_, (gint) _data_->_tmp21_);
				_data_->_tmp25_ = _data_->_tmp24_;
				graphs_style_set_name (_data_->_tmp17_, _data_->_tmp25_);
				_g_free0 (_data_->_tmp25_);
				_data_->_tmp23_ = (_vala_array_free (_data_->_tmp23_, _data_->_tmp23__length1, (GDestroyNotify) g_free), NULL);
				_data_->cmp = _graphs_style_cmp_gcompare_data_func;
				_data_->cmp_target = NULL;
				_data_->cmp_target_destroy_notify = NULL;
				_data_->_tmp26_ = graphs_style_manager_get_style_model ();
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = _data_->style;
				_data_->_tmp29_ = _data_->cmp;
				_data_->_tmp29__target = _data_->cmp_target;
				g_list_store_insert_sorted (_data_->_tmp27_, (GObject*) _data_->_tmp28_, _data_->_tmp29_, _data_->_tmp29__target);
				(_data_->cmp_target_destroy_notify == NULL) ? NULL : (_data_->cmp_target_destroy_notify (_data_->cmp_target), NULL);
				_data_->cmp = NULL;
				_data_->cmp_target = NULL;
				_data_->cmp_target_destroy_notify = NULL;
				_g_object_unref0 (_data_->style);
				g_task_return_pointer (_data_->_async_result, _data_, NULL);
				if (_data_->_state_ != 0) {
					while (!g_task_get_completed (_data_->_async_result)) {
						g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
					}
				}
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp30_ = graphs_style_manager_get_instance ();
			_data_->_tmp31_ = _data_->_tmp30_;
			_data_->_tmp32_ = NULL;
			g_signal_emit (_data_->_tmp31_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_REQUEST_SIGNAL], 0, _data_->file, &_data_->_tmp32_);
			_data_->tmp_style = _data_->_tmp32_;
			_data_->_tmp33_ = _data_->style;
			_data_->_tmp34_ = _data_->tmp_style;
			_data_->_tmp35_ = graphs_style_get_preview (_data_->_tmp34_);
			_data_->_tmp36_ = _data_->_tmp35_;
			graphs_style_set_preview (_data_->_tmp33_, _data_->_tmp36_);
			_data_->_tmp37_ = _data_->style;
			_data_->_tmp38_ = _data_->tmp_style;
			_data_->_tmp39_ = graphs_style_get_light (_data_->_tmp38_);
			_data_->_tmp40_ = _data_->_tmp39_;
			graphs_style_set_light (_data_->_tmp37_, _data_->_tmp40_);
			_data_->_tmp41_ = _data_->style;
			_data_->_tmp42_ = graphs_style_get_name (_data_->_tmp41_);
			_data_->_tmp43_ = _data_->_tmp42_;
			_data_->_tmp44_ = _data_->tmp_style;
			_data_->_tmp45_ = graphs_style_get_name (_data_->_tmp44_);
			_data_->_tmp46_ = _data_->_tmp45_;
			if (g_strcmp0 (_data_->_tmp43_, _data_->_tmp46_) == 0) {
				_data_->_tmp47_ = graphs_style_manager_get_instance ();
				_data_->_tmp48_ = _data_->_tmp47_;
				_data_->_tmp49_ = _data_->style;
				_data_->_tmp50_ = graphs_style_get_name (_data_->_tmp49_);
				_data_->_tmp51_ = _data_->_tmp50_;
				g_signal_emit (_data_->_tmp48_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_CHANGED_SIGNAL], 0, _data_->_tmp51_);
				_g_object_unref0 (_data_->tmp_style);
				_g_object_unref0 (_data_->style);
				g_task_return_pointer (_data_->_async_result, _data_, NULL);
				if (_data_->_state_ != 0) {
					while (!g_task_get_completed (_data_->_async_result)) {
						g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
					}
				}
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp52_ = _data_->style;
			_data_->_tmp53_ = graphs_style_get_name (_data_->_tmp52_);
			_data_->_tmp54_ = _data_->_tmp53_;
			_data_->_tmp55_ = g_strdup (_data_->_tmp54_);
			_data_->old_name = _data_->_tmp55_;
			_data_->_tmp56_ = _data_->style;
			_data_->_tmp57_ = _data_->tmp_style;
			_data_->_tmp58_ = graphs_style_get_name (_data_->_tmp57_);
			_data_->_tmp59_ = _data_->_tmp58_;
			_data_->_tmp60_ = 0;
			_data_->_tmp61_ = graphs_style_manager_list_stylenames (&_data_->_tmp60_);
			_data_->_tmp62_ = _data_->_tmp61_;
			_data_->_tmp62__length1 = _data_->_tmp60_;
			_data_->_tmp63_ = graphs_tools_get_duplicate_string (_data_->_tmp59_, _data_->_tmp62_, (gint) _data_->_tmp60_);
			_data_->_tmp64_ = _data_->_tmp63_;
			graphs_style_set_name (_data_->_tmp56_, _data_->_tmp64_);
			_g_free0 (_data_->_tmp64_);
			_data_->_tmp62_ = (_vala_array_free (_data_->_tmp62_, _data_->_tmp62__length1, (GDestroyNotify) g_free), NULL);
			_data_->_tmp65_ = graphs_style_manager_get_instance ();
			_data_->_tmp66_ = _data_->_tmp65_;
			_data_->_tmp67_ = _data_->old_name;
			_data_->_tmp68_ = _data_->style;
			_data_->_tmp69_ = graphs_style_get_name (_data_->_tmp68_);
			_data_->_tmp70_ = _data_->_tmp69_;
			g_signal_emit (_data_->_tmp66_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_RENAMED_SIGNAL], 0, _data_->_tmp67_, _data_->_tmp70_);
			_g_free0 (_data_->old_name);
			_g_object_unref0 (_data_->tmp_style);
			_g_object_unref0 (_data_->style);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		default:
		{
			_g_object_unref0 (_data_->style);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

/**
         * List all stylenames
         *
         * The result is guaranteed to be sorted and excludes the system style.
         */
gchar**
graphs_style_manager_list_stylenames (gint* result_length1)
{
	gchar** stylenames = NULL;
	GtkFilterListModel* _tmp0_;
	GtkFilterListModel* _tmp1_;
	gchar** _tmp2_;
	gint stylenames_length1;
	gint _stylenames_size_;
	gchar** _tmp15_;
	gint _tmp15__length1;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar** result;
	_tmp0_ = graphs_style_manager_get_filtered_style_model ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_new0 (gchar*, g_list_model_get_n_items ((GListModel*) _tmp1_) + 1);
	stylenames = _tmp2_;
	stylenames_length1 = g_list_model_get_n_items ((GListModel*) _tmp1_);
	_stylenames_size_ = stylenames_length1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				GtkFilterListModel* _tmp5_;
				GtkFilterListModel* _tmp6_;
				GraphsStyle* style = NULL;
				GtkFilterListModel* _tmp7_;
				GtkFilterListModel* _tmp8_;
				GObject* _tmp9_;
				gchar** _tmp10_;
				gint _tmp10__length1;
				GraphsStyle* _tmp11_;
				const gchar* _tmp12_;
				const gchar* _tmp13_;
				gchar* _tmp14_;
				if (!_tmp3_) {
					guint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = graphs_style_manager_get_filtered_style_model ();
				_tmp6_ = _tmp5_;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp6_))) {
					break;
				}
				_tmp7_ = graphs_style_manager_get_filtered_style_model ();
				_tmp8_ = _tmp7_;
				_tmp9_ = g_list_model_get_item ((GListModel*) _tmp8_, i);
				style = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GRAPHS_TYPE_STYLE, GraphsStyle);
				_tmp10_ = stylenames;
				_tmp10__length1 = stylenames_length1;
				_tmp11_ = style;
				_tmp12_ = graphs_style_get_name (_tmp11_);
				_tmp13_ = _tmp12_;
				_tmp14_ = g_strdup (_tmp13_);
				_g_free0 (_tmp10_[i]);
				_tmp10_[i] = _tmp14_;
				_g_object_unref0 (style);
			}
		}
	}
	_tmp15_ = stylenames;
	_tmp15__length1 = stylenames_length1;
	stylenames = NULL;
	stylenames_length1 = 0;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = _tmp15__length1;
	if (result_length1) {
		*result_length1 = _tmp16__length1;
	}
	result = _tmp16_;
	stylenames = (_vala_array_free (stylenames, stylenames_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

GFile*
graphs_style_manager_create_style (guint template,
                                   const gchar* name)
{
	gchar* new_name = NULL;
	gint _tmp0_ = 0;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GraphsStyle* style = NULL;
	GListStore* _tmp5_;
	GListStore* _tmp6_;
	GObject* _tmp7_;
	gchar* filename = NULL;
	gchar* _tmp8_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp1_ = graphs_style_manager_list_stylenames (&_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp0_;
	_tmp3_ = graphs_tools_get_duplicate_string (name, _tmp2_, (gint) _tmp0_);
	_tmp4_ = _tmp3_;
	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
	new_name = _tmp4_;
	_tmp5_ = graphs_style_manager_get_style_model ();
	_tmp6_ = _tmp5_;
	_tmp7_ = g_list_model_get_item ((GListModel*) _tmp6_, template);
	style = G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GRAPHS_TYPE_STYLE, GraphsStyle);
	_tmp8_ = graphs_filename_from_stylename (new_name);
	filename = _tmp8_;
	{
		GFile* destination = NULL;
		GFile* _tmp9_;
		GFile* _tmp10_;
		GFile* _tmp11_;
		GraphsStyleManager* _tmp12_;
		GraphsStyleManager* _tmp13_;
		_tmp9_ = graphs_style_manager_get_style_dir ();
		_tmp10_ = _tmp9_;
		_tmp11_ = g_file_get_child_for_display_name (_tmp10_, filename, &_inner_error0_);
		destination = _tmp11_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp12_ = graphs_style_manager_get_instance ();
		_tmp13_ = _tmp12_;
		g_signal_emit (_tmp13_, graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_CREATE_STYLE_REQUEST_SIGNAL], 0, style, destination, new_name);
		result = destination;
		_g_free0 (filename);
		_g_object_unref0 (style);
		_g_free0 (new_name);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	_g_free0 (filename);
	_g_object_unref0 (style);
	_g_free0 (new_name);
	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;
}

static gint
graphs_style_manager_find_style_for_file (GFile* file,
                                          GraphsStyle** style)
{
	GraphsStyle* _vala_style = NULL;
	gint result;
	g_return_val_if_fail (file != NULL, -1);
	{
		guint i = 0U;
		i = (guint) 1;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GListStore* _tmp2_;
				GListStore* _tmp3_;
				GraphsStyle* i_style = NULL;
				GListStore* _tmp4_;
				GListStore* _tmp5_;
				GObject* _tmp6_;
				GraphsStyle* _tmp7_;
				GFile* _tmp8_;
				GFile* _tmp9_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = graphs_style_manager_get_style_model ();
				_tmp3_ = _tmp2_;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp3_))) {
					break;
				}
				_tmp4_ = graphs_style_manager_get_style_model ();
				_tmp5_ = _tmp4_;
				_tmp6_ = g_list_model_get_item ((GListModel*) _tmp5_, i);
				i_style = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GRAPHS_TYPE_STYLE, GraphsStyle);
				_tmp7_ = i_style;
				_tmp8_ = graphs_style_get_file (_tmp7_);
				_tmp9_ = _tmp8_;
				if (g_file_equal (_tmp9_, file)) {
					GraphsStyle* _tmp10_;
					GraphsStyle* _tmp11_;
					_tmp10_ = i_style;
					_tmp11_ = _g_object_ref0 (_tmp10_);
					_g_object_unref0 (_vala_style);
					_vala_style = _tmp11_;
					result = (gint) i;
					_g_object_unref0 (i_style);
					if (style) {
						*style = _vala_style;
					} else {
						_g_object_unref0 (_vala_style);
					}
					return result;
				}
				_g_object_unref0 (i_style);
			}
		}
	}
	_g_object_unref0 (_vala_style);
	_vala_style = NULL;
	result = -1;
	if (style) {
		*style = _vala_style;
	} else {
		_g_object_unref0 (_vala_style);
	}
	return result;
}

GraphsStyleManager*
graphs_style_manager_construct (GType object_type)
{
	GraphsStyleManager * self = NULL;
	self = (GraphsStyleManager*) g_object_new (object_type, NULL);
	return self;
}

GraphsStyleManager*
graphs_style_manager_new (void)
{
	return graphs_style_manager_construct (GRAPHS_TYPE_STYLE_MANAGER);
}

GListStore*
graphs_style_manager_get_style_model (void)
{
	GListStore* result;
	GListStore* _tmp0_;
	_tmp0_ = graphs_style_manager__style_model;
	result = _tmp0_;
	return result;
}

static void
graphs_style_manager_set_style_model (GListStore* value)
{
	GListStore* _tmp0_;
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (graphs_style_manager__style_model);
	graphs_style_manager__style_model = _tmp0_;
}

GtkFilterListModel*
graphs_style_manager_get_filtered_style_model (void)
{
	GtkFilterListModel* result;
	GtkFilterListModel* _tmp0_;
	_tmp0_ = graphs_style_manager__filtered_style_model;
	result = _tmp0_;
	return result;
}

static void
graphs_style_manager_set_filtered_style_model (GtkFilterListModel* value)
{
	GtkFilterListModel* _tmp0_;
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (graphs_style_manager__filtered_style_model);
	graphs_style_manager__filtered_style_model = _tmp0_;
}

GFile*
graphs_style_manager_get_style_dir (void)
{
	GFile* result;
	GFile* _tmp0_;
	_tmp0_ = graphs_style_manager__style_dir;
	result = _tmp0_;
	return result;
}

static void
graphs_style_manager_set_style_dir (GFile* value)
{
	GFile* _tmp0_;
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (graphs_style_manager__style_dir);
	graphs_style_manager__style_dir = _tmp0_;
}

GtkCssProvider*
graphs_style_manager_get_css_provider (GraphsStyleManager* self)
{
	GtkCssProvider* result;
	GtkCssProvider* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_css_provider;
	result = _tmp0_;
	return result;
}

static void
graphs_style_manager_set_css_provider (GraphsStyleManager* self,
                                       GtkCssProvider* value)
{
	GtkCssProvider* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_manager_get_css_provider (self);
	if (old_value != value) {
		GtkCssProvider* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_css_provider);
		self->priv->_css_provider = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_manager_properties[GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY]);
	}
}

GraphsStyleManager*
graphs_style_manager_get_instance (void)
{
	GraphsStyleManager* result;
	GraphsStyleManager* _tmp0_;
	_tmp0_ = graphs_style_manager__instance;
	result = _tmp0_;
	return result;
}

static void
graphs_style_manager_set_instance (GraphsStyleManager* value)
{
	GraphsStyleManager* _tmp0_;
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (graphs_style_manager__instance);
	graphs_style_manager__instance = _tmp0_;
}

static void
g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, const char* arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__STRING_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__OBJECT_OBJECT_STRING (GClosure * closure,
                                                    GValue * return_value,
                                                    guint n_param_values,
                                                    const GValue * param_values,
                                                    gpointer invocation_hint,
                                                    gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_STRING) (gpointer data1, gpointer arg_1, gpointer arg_2, const char* arg_3, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_OBJECT_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), g_value_get_string (param_values + 3), data2);
}

static void
g_cclosure_user_marshal_OBJECT__OBJECT (GClosure * closure,
                                        GValue * return_value,
                                        guint n_param_values,
                                        const GValue * param_values,
                                        gpointer invocation_hint,
                                        gpointer marshal_data)
{
	typedef gpointer (*GMarshalFunc_OBJECT__OBJECT) (gpointer data1, gpointer arg_1, gpointer data2);
	register GMarshalFunc_OBJECT__OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	gpointer v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 2);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_OBJECT__OBJECT) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, g_value_get_object (param_values + 1), data2);
	g_value_take_object (return_value, v_return);
}

static GObject *
graphs_style_manager_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraphsStyleManager * self;
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	GdkDisplay* _tmp2_;
	GtkCssProvider* _tmp3_;
	parent_class = G_OBJECT_CLASS (graphs_style_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_MANAGER, GraphsStyleManager);
	_tmp0_ = gtk_css_provider_new ();
	_tmp1_ = _tmp0_;
	graphs_style_manager_set_css_provider (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gdk_display_get_default ();
	_tmp3_ = self->priv->_css_provider;
	gtk_style_context_add_provider_for_display (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	return obj;
}

static void
graphs_style_manager_class_init (GraphsStyleManagerClass * klass,
                                 gpointer klass_data)
{
	graphs_style_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsStyleManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_style_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_style_manager_set_property;
	G_OBJECT_CLASS (klass)->constructor = graphs_style_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = graphs_style_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY, graphs_style_manager_properties[GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY] = g_param_spec_object ("css-provider", "css-provider", "css-provider", gtk_css_provider_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_CHANGED_SIGNAL] = g_signal_new ("style-changed", GRAPHS_TYPE_STYLE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_DELETED_SIGNAL] = g_signal_new ("style-deleted", GRAPHS_TYPE_STYLE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_RENAMED_SIGNAL] = g_signal_new ("style-renamed", GRAPHS_TYPE_STYLE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
	graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_CREATE_STYLE_REQUEST_SIGNAL] = g_signal_new ("create-style-request", GRAPHS_TYPE_STYLE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_STRING, G_TYPE_NONE, 3, GRAPHS_TYPE_STYLE, g_file_get_type (), G_TYPE_STRING);
	graphs_style_manager_signals[GRAPHS_STYLE_MANAGER_STYLE_REQUEST_SIGNAL] = g_signal_new ("style-request", GRAPHS_TYPE_STYLE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_OBJECT__OBJECT, GRAPHS_TYPE_STYLE, 1, g_file_get_type ());
}

static void
graphs_style_manager_instance_init (GraphsStyleManager * self,
                                    gpointer klass)
{
	self->priv = graphs_style_manager_get_instance_private (self);
}

static void
graphs_style_manager_finalize (GObject * obj)
{
	GraphsStyleManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_MANAGER, GraphsStyleManager);
	_g_object_unref0 (self->priv->_css_provider);
	G_OBJECT_CLASS (graphs_style_manager_parent_class)->finalize (obj);
}

/**
     * Style manager
     */
static GType
graphs_style_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsStyleManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_style_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsStyleManager), 0, (GInstanceInitFunc) graphs_style_manager_instance_init, NULL };
	GType graphs_style_manager_type_id;
	graphs_style_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsStyleManager", &g_define_type_info, 0);
	GraphsStyleManager_private_offset = g_type_add_instance_private (graphs_style_manager_type_id, sizeof (GraphsStyleManagerPrivate));
	return graphs_style_manager_type_id;
}

GType
graphs_style_manager_get_type (void)
{
	static volatile gsize graphs_style_manager_type_id__once = 0;
	if (g_once_init_enter (&graphs_style_manager_type_id__once)) {
		GType graphs_style_manager_type_id;
		graphs_style_manager_type_id = graphs_style_manager_get_type_once ();
		g_once_init_leave (&graphs_style_manager_type_id__once, graphs_style_manager_type_id);
	}
	return graphs_style_manager_type_id__once;
}

static void
_vala_graphs_style_manager_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GraphsStyleManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_MANAGER, GraphsStyleManager);
	switch (property_id) {
		case GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY:
		g_value_set_object (value, graphs_style_manager_get_css_provider (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_style_manager_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GraphsStyleManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_MANAGER, GraphsStyleManager);
	switch (property_id) {
		case GRAPHS_STYLE_MANAGER_CSS_PROVIDER_PROPERTY:
		graphs_style_manager_set_css_provider (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
graphs_style_get_instance_private (GraphsStyle* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsStyle_private_offset);
}

GraphsStyle*
graphs_style_construct (GType object_type,
                        const gchar* name,
                        GFile* file,
                        GdkTexture* preview,
                        gboolean mutable)
{
	GraphsStyle * self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (preview != NULL, NULL);
	self = (GraphsStyle*) g_object_new (object_type, "name", name, "file", file, "preview", preview, "mutable", mutable, NULL);
	return self;
}

GraphsStyle*
graphs_style_new (const gchar* name,
                  GFile* file,
                  GdkTexture* preview,
                  gboolean mutable)
{
	return graphs_style_construct (GRAPHS_TYPE_STYLE, name, file, preview, mutable);
}

const gchar*
graphs_style_get_name (GraphsStyle* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
graphs_style_set_name (GraphsStyle* self,
                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_properties[GRAPHS_STYLE_NAME_PROPERTY]);
	}
}

GdkTexture*
graphs_style_get_preview (GraphsStyle* self)
{
	GdkTexture* result;
	GdkTexture* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_preview;
	result = _tmp0_;
	return result;
}

void
graphs_style_set_preview (GraphsStyle* self,
                          GdkTexture* value)
{
	GdkTexture* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_get_preview (self);
	if (old_value != value) {
		GdkTexture* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_preview);
		self->priv->_preview = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_properties[GRAPHS_STYLE_PREVIEW_PROPERTY]);
	}
}

GFile*
graphs_style_get_file (GraphsStyle* self)
{
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

void
graphs_style_set_file (GraphsStyle* self,
                       GFile* value)
{
	GFile* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_get_file (self);
	if (old_value != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_properties[GRAPHS_STYLE_FILE_PROPERTY]);
	}
}

gboolean
graphs_style_get_mutable (GraphsStyle* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_mutable;
	return result;
}

void
graphs_style_set_mutable (GraphsStyle* self,
                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_get_mutable (self);
	if (old_value != value) {
		self->priv->_mutable = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_properties[GRAPHS_STYLE_MUTABLE_PROPERTY]);
	}
}

gboolean
graphs_style_get_light (GraphsStyle* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_light;
	return result;
}

void
graphs_style_set_light (GraphsStyle* self,
                        gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_get_light (self);
	if (old_value != value) {
		self->priv->_light = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_properties[GRAPHS_STYLE_LIGHT_PROPERTY]);
	}
}

static void
graphs_style_class_init (GraphsStyleClass * klass,
                         gpointer klass_data)
{
	graphs_style_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsStyle_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_style_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_style_set_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_style_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_NAME_PROPERTY, graphs_style_properties[GRAPHS_STYLE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_PREVIEW_PROPERTY, graphs_style_properties[GRAPHS_STYLE_PREVIEW_PROPERTY] = g_param_spec_object ("preview", "preview", "preview", gdk_texture_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_FILE_PROPERTY, graphs_style_properties[GRAPHS_STYLE_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_MUTABLE_PROPERTY, graphs_style_properties[GRAPHS_STYLE_MUTABLE_PROPERTY] = g_param_spec_boolean ("mutable", "mutable", "mutable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_LIGHT_PROPERTY, graphs_style_properties[GRAPHS_STYLE_LIGHT_PROPERTY] = g_param_spec_boolean ("light", "light", "light", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
graphs_style_instance_init (GraphsStyle * self,
                            gpointer klass)
{
	gchar* _tmp0_;
	self->priv = graphs_style_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_name = _tmp0_;
	self->priv->_light = TRUE;
}

static void
graphs_style_finalize (GObject * obj)
{
	GraphsStyle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE, GraphsStyle);
	_g_free0 (self->priv->_name);
	_g_object_unref0 (self->priv->_preview);
	_g_object_unref0 (self->priv->_file);
	G_OBJECT_CLASS (graphs_style_parent_class)->finalize (obj);
}

static GType
graphs_style_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsStyleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_style_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsStyle), 0, (GInstanceInitFunc) graphs_style_instance_init, NULL };
	GType graphs_style_type_id;
	graphs_style_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsStyle", &g_define_type_info, 0);
	GraphsStyle_private_offset = g_type_add_instance_private (graphs_style_type_id, sizeof (GraphsStylePrivate));
	return graphs_style_type_id;
}

GType
graphs_style_get_type (void)
{
	static volatile gsize graphs_style_type_id__once = 0;
	if (g_once_init_enter (&graphs_style_type_id__once)) {
		GType graphs_style_type_id;
		graphs_style_type_id = graphs_style_get_type_once ();
		g_once_init_leave (&graphs_style_type_id__once, graphs_style_type_id);
	}
	return graphs_style_type_id__once;
}

static void
_vala_graphs_style_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	GraphsStyle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE, GraphsStyle);
	switch (property_id) {
		case GRAPHS_STYLE_NAME_PROPERTY:
		g_value_set_string (value, graphs_style_get_name (self));
		break;
		case GRAPHS_STYLE_PREVIEW_PROPERTY:
		g_value_set_object (value, graphs_style_get_preview (self));
		break;
		case GRAPHS_STYLE_FILE_PROPERTY:
		g_value_set_object (value, graphs_style_get_file (self));
		break;
		case GRAPHS_STYLE_MUTABLE_PROPERTY:
		g_value_set_boolean (value, graphs_style_get_mutable (self));
		break;
		case GRAPHS_STYLE_LIGHT_PROPERTY:
		g_value_set_boolean (value, graphs_style_get_light (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_style_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	GraphsStyle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE, GraphsStyle);
	switch (property_id) {
		case GRAPHS_STYLE_NAME_PROPERTY:
		graphs_style_set_name (self, g_value_get_string (value));
		break;
		case GRAPHS_STYLE_PREVIEW_PROPERTY:
		graphs_style_set_preview (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_FILE_PROPERTY:
		graphs_style_set_file (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_MUTABLE_PROPERTY:
		graphs_style_set_mutable (self, g_value_get_boolean (value));
		break;
		case GRAPHS_STYLE_LIGHT_PROPERTY:
		graphs_style_set_light (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
graphs_style_preview_get_instance_private (GraphsStylePreview* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsStylePreview_private_offset);
}

GraphsStylePreview*
graphs_style_preview_construct (GType object_type)
{
	GraphsStylePreview * self = NULL;
	self = (GraphsStylePreview*) g_object_new (object_type, NULL);
	return self;
}

GraphsStylePreview*
graphs_style_preview_new (void)
{
	return graphs_style_preview_construct (GRAPHS_TYPE_STYLE_PREVIEW);
}

static GtkLabel*
graphs_style_preview_get_label (GraphsStylePreview* self)
{
	GtkLabel* result;
	GtkLabel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

static GtkPicture*
graphs_style_preview_get_picture (GraphsStylePreview* self)
{
	GtkPicture* result;
	GtkPicture* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_picture;
	result = _tmp0_;
	return result;
}

GtkMenuButton*
graphs_style_preview_get_menu_button (GraphsStylePreview* self)
{
	GtkMenuButton* result;
	GtkMenuButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_menu_button;
	result = _tmp0_;
	return result;
}

GraphsStyle*
graphs_style_preview_get_style (GraphsStylePreview* self)
{
	GraphsStyle* result;
	GraphsStyle* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_style;
	result = _tmp0_;
	return result;
}

void
graphs_style_preview_set_style (GraphsStylePreview* self,
                                GraphsStyle* value)
{
	GraphsStyle* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_style);
	self->priv->_style = _tmp0_;
	g_object_bind_property_with_closures ((GObject*) value, "name", (GObject*) self, "stylename", 2, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) value, "preview", (GObject*) self, "preview", 2, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_notify_by_pspec ((GObject *) self, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY]);
}

void
graphs_style_preview_set_stylename (GraphsStylePreview* self,
                                    const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_label;
	gtk_label_set_label (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_STYLENAME_PROPERTY]);
}

GdkTexture*
graphs_style_preview_get_preview (GraphsStylePreview* self)
{
	GdkTexture* result;
	GtkPicture* _tmp0_;
	GdkPaintable* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_picture;
	_tmp1_ = gtk_picture_get_paintable (_tmp0_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gdk_texture_get_type (), GdkTexture);
	return result;
}

void
graphs_style_preview_set_preview (GraphsStylePreview* self,
                                  GdkTexture* value)
{
	GtkPicture* _tmp0_;
	GraphsStyle* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_picture;
	gtk_picture_set_paintable (_tmp0_, (GdkPaintable*) value);
	_tmp1_ = self->priv->_style;
	_tmp2_ = graphs_style_get_mutable (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		gchar* color = NULL;
		GraphsStyle* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		GtkCssProvider* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp4_ = self->priv->_style;
		_tmp5_ = graphs_style_get_light (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			gchar* _tmp7_;
			_tmp7_ = g_strdup ("@light_1");
			_g_free0 (color);
			color = _tmp7_;
		} else {
			gchar* _tmp8_;
			_tmp8_ = g_strdup ("@dark_5");
			_g_free0 (color);
			color = _tmp8_;
		}
		_tmp9_ = self->priv->provider;
		_tmp10_ = color;
		_tmp11_ = string_to_string (_tmp10_);
		_tmp12_ = g_strconcat ("menubutton { color: ", _tmp11_, "; }", NULL);
		_tmp13_ = _tmp12_;
		gtk_css_provider_load_from_string (_tmp9_, _tmp13_);
		_g_free0 (_tmp13_);
		_g_free0 (color);
	}
	g_object_notify_by_pspec ((GObject *) self, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY]);
}

static GObject *
graphs_style_preview_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraphsStylePreview * self;
	GtkCssProvider* _tmp0_;
	GtkMenuButton* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkCssProvider* _tmp3_;
	parent_class = G_OBJECT_CLASS (graphs_style_preview_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview);
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (self->priv->provider);
	self->priv->provider = _tmp0_;
	_tmp1_ = self->priv->_menu_button;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	_tmp3_ = self->priv->provider;
	gtk_style_context_add_provider (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	return obj;
}

static void
graphs_style_preview_class_init (GraphsStylePreviewClass * klass,
                                 gpointer klass_data)
{
	graphs_style_preview_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsStylePreview_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_style_preview_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_style_preview_set_property;
	G_OBJECT_CLASS (klass)->constructor = graphs_style_preview_constructor;
	G_OBJECT_CLASS (klass)->finalize = graphs_style_preview_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_PREVIEW_MENU_BUTTON_PROPERTY, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_MENU_BUTTON_PROPERTY] = g_param_spec_object ("menu-button", "menu-button", "menu-button", gtk_menu_button_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY] = g_param_spec_object ("style", "style", "style", GRAPHS_TYPE_STYLE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_PREVIEW_STYLENAME_PROPERTY, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_STYLENAME_PROPERTY] = g_param_spec_string ("stylename", "stylename", "stylename", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY, graphs_style_preview_properties[GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY] = g_param_spec_object ("preview", "preview", "preview", gdk_texture_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/style-preview.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "label", FALSE, GraphsStylePreview_private_offset + G_STRUCT_OFFSET (GraphsStylePreviewPrivate, _label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "picture", FALSE, GraphsStylePreview_private_offset + G_STRUCT_OFFSET (GraphsStylePreviewPrivate, _picture));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "menu_button", FALSE, GraphsStylePreview_private_offset + G_STRUCT_OFFSET (GraphsStylePreviewPrivate, _menu_button));
}

static void
graphs_style_preview_instance_init (GraphsStylePreview * self,
                                    gpointer klass)
{
	self->priv = graphs_style_preview_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_style_preview_finalize (GObject * obj)
{
	GraphsStylePreview * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview);
	_g_object_unref0 (self->priv->_style);
	_g_object_unref0 (self->priv->provider);
	G_OBJECT_CLASS (graphs_style_preview_parent_class)->finalize (obj);
}

/**
     * Style Preview widget
     */
static GType
graphs_style_preview_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsStylePreviewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_style_preview_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsStylePreview), 0, (GInstanceInitFunc) graphs_style_preview_instance_init, NULL };
	GType graphs_style_preview_type_id;
	graphs_style_preview_type_id = g_type_register_static (adw_bin_get_type (), "GraphsStylePreview", &g_define_type_info, 0);
	GraphsStylePreview_private_offset = g_type_add_instance_private (graphs_style_preview_type_id, sizeof (GraphsStylePreviewPrivate));
	return graphs_style_preview_type_id;
}

GType
graphs_style_preview_get_type (void)
{
	static volatile gsize graphs_style_preview_type_id__once = 0;
	if (g_once_init_enter (&graphs_style_preview_type_id__once)) {
		GType graphs_style_preview_type_id;
		graphs_style_preview_type_id = graphs_style_preview_get_type_once ();
		g_once_init_leave (&graphs_style_preview_type_id__once, graphs_style_preview_type_id);
	}
	return graphs_style_preview_type_id__once;
}

static void
_vala_graphs_style_preview_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GraphsStylePreview * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview);
	switch (property_id) {
		case GRAPHS_STYLE_PREVIEW_MENU_BUTTON_PROPERTY:
		g_value_set_object (value, graphs_style_preview_get_menu_button (self));
		break;
		case GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY:
		g_value_set_object (value, graphs_style_preview_get_style (self));
		break;
		case GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY:
		g_value_set_object (value, graphs_style_preview_get_preview (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_style_preview_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GraphsStylePreview * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview);
	switch (property_id) {
		case GRAPHS_STYLE_PREVIEW_STYLE_PROPERTY:
		graphs_style_preview_set_style (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_PREVIEW_STYLENAME_PROPERTY:
		graphs_style_preview_set_stylename (self, g_value_get_string (value));
		break;
		case GRAPHS_STYLE_PREVIEW_PREVIEW_PROPERTY:
		graphs_style_preview_set_preview (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
graphs_import_style_data_free (gpointer _data)
{
	GraphsImportStyleData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->window);
	g_slice_free (GraphsImportStyleData, _data_);
}

void
graphs_import_style (GtkWindow* window,
                     GAsyncReadyCallback _callback_,
                     gpointer _user_data_)
{
	GraphsImportStyleData* _data_;
	GtkWindow* _tmp0_;
	g_return_if_fail (window != NULL);
	_data_ = g_slice_new0 (GraphsImportStyleData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, graphs_import_style_data_free);
	_tmp0_ = _g_object_ref0 (window);
	_g_object_unref0 (_data_->window);
	_data_->window = _tmp0_;
	graphs_import_style_co (_data_);
}

void
graphs_import_style_finish (GAsyncResult* _res_)
{
	GraphsImportStyleData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
graphs_import_style_ready (GObject* source_object,
                           GAsyncResult* _res_,
                           gpointer _user_data_)
{
	GraphsImportStyleData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	graphs_import_style_co (_data_);
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gboolean
graphs_import_style_co (GraphsImportStyleData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_file_dialog_new ();
	_data_->dialog = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->dialog;
	_data_->_tmp2_ = graphs_get_mplstyle_file_filters ();
	_data_->_tmp3_ = _data_->_tmp2_;
	gtk_file_dialog_set_filters (_data_->_tmp1_, _data_->_tmp3_);
	_g_object_unref0 (_data_->_tmp3_);
	{
		_data_->_tmp4_ = _data_->dialog;
		_data_->_state_ = 1;
		gtk_file_dialog_open (_data_->_tmp4_, _data_->window, NULL, graphs_import_style_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp5_ = gtk_file_dialog_open_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_data_->file = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = _data_->file;
		_data_->_tmp7_ = graphs_tools_get_filename (_data_->_tmp6_);
		_data_->filename = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->filename;
		if (!g_str_has_suffix (_data_->_tmp8_, ".mplstyle")) {
			_g_free0 (_data_->filename);
			_g_object_unref0 (_data_->file);
			_g_object_unref0 (_data_->dialog);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp9_ = graphs_style_manager_get_style_dir ();
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = _g_object_ref0 (_data_->_tmp10_);
		_data_->style_dir = _data_->_tmp11_;
		_data_->_tmp12_ = _data_->style_dir;
		_data_->_tmp13_ = _data_->filename;
		_data_->_tmp14_ = g_file_get_child_for_display_name (_data_->_tmp12_, _data_->_tmp13_, &_data_->_inner_error0_);
		_data_->destination = _data_->_tmp14_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->style_dir);
			_g_free0 (_data_->filename);
			_g_object_unref0 (_data_->file);
			goto __catch0_g_error;
		}
		_data_->i = (guint) 1;
		while (TRUE) {
			_data_->_tmp15_ = _data_->destination;
			if (!g_file_query_exists (_data_->_tmp15_, NULL)) {
				break;
			}
			_data_->_tmp16_ = g_string_new ("");
			_data_->new_filename = _data_->_tmp16_;
			_data_->_tmp17_ = _data_->new_filename;
			_data_->_tmp18_ = _data_->filename;
			_data_->_tmp19_ = string_slice (_data_->_tmp18_, (glong) 0, (glong) -9);
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp21_ = g_string_append (_data_->_tmp17_, _data_->_tmp20_);
			_data_->_tmp22_ = g_string_append (_data_->_tmp21_, "-");
			_data_->_tmp23_ = g_strdup_printf ("%u", _data_->i);
			_data_->_tmp24_ = _data_->_tmp23_;
			_data_->_tmp25_ = g_string_append (_data_->_tmp22_, _data_->_tmp24_);
			g_string_append (_data_->_tmp25_, ".mplstyle");
			_g_free0 (_data_->_tmp24_);
			_g_free0 (_data_->_tmp20_);
			_data_->_tmp27_ = _data_->style_dir;
			_data_->_tmp28_ = _data_->new_filename;
			_data_->new_filename = NULL;
			_data_->_tmp29_ = g_string_free_and_steal (_data_->_tmp28_);
			_data_->_tmp30_ = _data_->_tmp29_;
			_data_->_tmp31_ = g_file_get_child_for_display_name (_data_->_tmp27_, _data_->_tmp30_, &_data_->_inner_error0_);
			_data_->_tmp32_ = _data_->_tmp31_;
			_g_free0 (_data_->_tmp30_);
			_data_->_tmp26_ = _data_->_tmp32_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_string_free0 (_data_->new_filename);
				_g_object_unref0 (_data_->destination);
				_g_object_unref0 (_data_->style_dir);
				_g_free0 (_data_->filename);
				_g_object_unref0 (_data_->file);
				goto __catch0_g_error;
			}
			_data_->_tmp33_ = _data_->_tmp26_;
			_data_->_tmp26_ = NULL;
			_g_object_unref0 (_data_->destination);
			_data_->destination = _data_->_tmp33_;
			_data_->_tmp34_ = _data_->i;
			_data_->i = _data_->_tmp34_ + 1;
			_g_object_unref0 (_data_->_tmp26_);
			_g_string_free0 (_data_->new_filename);
		}
		_data_->_tmp35_ = _data_->file;
		_data_->_tmp36_ = _data_->destination;
		g_file_copy_async (_data_->_tmp35_, _data_->_tmp36_, G_FILE_COPY_NONE, G_PRIORITY_DEFAULT, NULL, NULL, NULL, NULL, NULL);
		_g_object_unref0 (_data_->destination);
		_g_object_unref0 (_data_->style_dir);
		_g_free0 (_data_->filename);
		_g_object_unref0 (_data_->file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->dialog);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->dialog);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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;
}

