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


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#define TYPE_ADVANCED_PREFERENCES (advanced_preferences_get_type ())
#define ADVANCED_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADVANCED_PREFERENCES, AdvancedPreferences))
#define ADVANCED_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ADVANCED_PREFERENCES, AdvancedPreferencesClass))
#define IS_ADVANCED_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADVANCED_PREFERENCES))
#define IS_ADVANCED_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ADVANCED_PREFERENCES))
#define ADVANCED_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ADVANCED_PREFERENCES, AdvancedPreferencesClass))

typedef struct _AdvancedPreferences AdvancedPreferences;
typedef struct _AdvancedPreferencesClass AdvancedPreferencesClass;
typedef struct _AdvancedPreferencesPrivate AdvancedPreferencesPrivate;

#define TYPE_SETTINGS_CACHE (settings_cache_get_type ())
#define SETTINGS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SETTINGS_CACHE, SettingsCache))
#define SETTINGS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SETTINGS_CACHE, SettingsCacheClass))
#define IS_SETTINGS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SETTINGS_CACHE))
#define IS_SETTINGS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SETTINGS_CACHE))
#define SETTINGS_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SETTINGS_CACHE, SettingsCacheClass))

typedef struct _SettingsCache SettingsCache;
typedef struct _SettingsCacheClass SettingsCacheClass;

#define TYPE_COLOR_MAPPER (color_mapper_get_type ())
#define COLOR_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COLOR_MAPPER, ColorMapper))
#define COLOR_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COLOR_MAPPER, ColorMapperClass))
#define IS_COLOR_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COLOR_MAPPER))
#define IS_COLOR_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COLOR_MAPPER))
#define COLOR_MAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COLOR_MAPPER, ColorMapperClass))

typedef struct _ColorMapper ColorMapper;
typedef struct _ColorMapperClass ColorMapperClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))

struct _AdvancedPreferences {
	GObject parent_instance;
	AdvancedPreferencesPrivate * priv;
};

struct _AdvancedPreferencesClass {
	GObjectClass parent_class;
};

struct _AdvancedPreferencesPrivate {
	SettingsCache* settingscache;
	GtkDialog* preferences;
	GtkBuilder* builder;
	GtkTreeStore* itemstore;
	GtkTreeView* itemview;
	GtkNotebook* notebook;
	GObject* graphminimum;
	GObject* graphmaximum;
	GObject* graphenabled;
	GObject* graphsmooth;
	GObject* tracecolor;
	GObject* traceenabled;
	GObject* traceexpression;
	ColorMapper* _colormapper;
};


static gpointer advanced_preferences_parent_class = NULL;

GType advanced_preferences_get_type (void) G_GNUC_CONST;
GType settings_cache_get_type (void) G_GNUC_CONST;
GType color_mapper_get_type (void) G_GNUC_CONST;
#define ADVANCED_PREFERENCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_ADVANCED_PREFERENCES, AdvancedPreferencesPrivate))
enum  {
	ADVANCED_PREFERENCES_DUMMY_PROPERTY,
	ADVANCED_PREFERENCES_COLORMAPPER
};
AdvancedPreferences* advanced_preferences_new (ColorMapper* colormapper);
AdvancedPreferences* advanced_preferences_construct (GType object_type, ColorMapper* colormapper);
void advanced_preferences_show (AdvancedPreferences* self);
GObject* utils_get_ui (const gchar* objectid, GObject* signalhandlers, gchar** additional, int additional_length1, GtkBuilder** builder);
GSettings* settings_cache_generalsettings (SettingsCache* self);
GSettings* settings_cache_graphsettings (SettingsCache* self, const gchar* graphid);
static void advanced_preferences_revert (AdvancedPreferences* self);
GSettings* settings_cache_tracesettings (SettingsCache* self, const gchar* graphid, const gchar* traceid);
void advanced_preferences_on_advprefdialog_destroy (GtkWidget* source, AdvancedPreferences* self);
void advanced_preferences_on_advprefdialog_response (GtkDialog* source, gint response, AdvancedPreferences* self);
void advanced_preferences_on_graphtraceview_cursor_changed (GtkTreeView* source, AdvancedPreferences* self);
gboolean utils_get_settings_rgba (GValue* value, GVariant* variant, void* user_data);
static gboolean _utils_get_settings_rgba_gsettings_bind_get_mapping (GValue* value, GVariant* variant, void* user_data);
GVariant* utils_set_settings_rgba (GValue* value, const GVariantType* expected_type, void* user_data);
static void ___lambda2_ (void);
static void ____lambda2__gdestroy_notify (void* data);
ColorMapper* advanced_preferences_get_colormapper (AdvancedPreferences* self);
static void advanced_preferences_set_colormapper (AdvancedPreferences* self, ColorMapper* value);
static GObject * advanced_preferences_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
SettingsCache* settings_cache_new (void);
SettingsCache* settings_cache_construct (GType object_type);
static void advanced_preferences_finalize (GObject* obj);
static void _vala_advanced_preferences_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_advanced_preferences_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


AdvancedPreferences* advanced_preferences_construct (GType object_type, ColorMapper* colormapper) {
	AdvancedPreferences * self = NULL;
	ColorMapper* _tmp0_ = NULL;
	g_return_val_if_fail (IS_COLOR_MAPPER (colormapper), NULL);
	_tmp0_ = colormapper;
	self = (AdvancedPreferences*) g_object_new (object_type, "colormapper", _tmp0_, NULL);
	return self;
}


AdvancedPreferences* advanced_preferences_new (ColorMapper* colormapper) {
	return advanced_preferences_construct (TYPE_ADVANCED_PREFERENCES, colormapper);
}


void advanced_preferences_show (AdvancedPreferences* self) {
	GtkDialog* _tmp0_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gchar** _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	GtkBuilder* _tmp6_ = NULL;
	GObject* _tmp7_ = NULL;
	GtkDialog* _tmp8_ = NULL;
	GtkDialog* _tmp9_ = NULL;
	GtkBuilder* _tmp10_ = NULL;
	GObject* _tmp11_ = NULL;
	GtkBuilder* _tmp12_ = NULL;
	GObject* _tmp13_ = NULL;
	GtkBuilder* _tmp14_ = NULL;
	GObject* _tmp15_ = NULL;
	GtkBuilder* _tmp16_ = NULL;
	GObject* _tmp17_ = NULL;
	GtkBuilder* _tmp18_ = NULL;
	GObject* _tmp19_ = NULL;
	GtkBuilder* _tmp20_ = NULL;
	GObject* _tmp21_ = NULL;
	GtkBuilder* _tmp22_ = NULL;
	GObject* _tmp23_ = NULL;
	GtkBuilder* _tmp24_ = NULL;
	GObject* _tmp25_ = NULL;
	GtkBuilder* _tmp26_ = NULL;
	GObject* _tmp27_ = NULL;
	GtkBuilder* _tmp28_ = NULL;
	GObject* _tmp29_ = NULL;
	gchar** graphids = NULL;
	SettingsCache* _tmp30_ = NULL;
	GSettings* _tmp31_ = NULL;
	GSettings* _tmp32_ = NULL;
	gchar** _tmp33_ = NULL;
	gchar** _tmp34_ = NULL;
	gchar** _tmp35_ = NULL;
	gint _tmp35__length1 = 0;
	gint graphids_length1 = 0;
	gint _graphids_size_ = 0;
	gchar** _tmp36_ = NULL;
	gint _tmp36__length1 = 0;
	GtkTreeView* _tmp55_ = NULL;
	GtkDialog* _tmp56_ = NULL;
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	_tmp0_ = self->priv->preferences;
	if (_tmp0_ != NULL) {
		GtkDialog* _tmp1_ = NULL;
		_tmp1_ = self->priv->preferences;
		gtk_window_present (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GTK_TYPE_WINDOW, GtkWindow));
		return;
	}
	_tmp2_ = g_strdup ("graphtracestore");
	_tmp3_ = g_strdup ("advprefsizegroup");
	_tmp4_ = g_new0 (gchar*, 2 + 1);
	_tmp4_[0] = _tmp2_;
	_tmp4_[1] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 2;
	_tmp7_ = utils_get_ui ("advprefdialog", G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), _tmp5_, 2, &_tmp6_);
	_g_object_unref0 (self->priv->builder);
	self->priv->builder = _tmp6_;
	_tmp8_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, GTK_TYPE_DIALOG) ? ((GtkDialog*) _tmp7_) : NULL;
	if (_tmp8_ == NULL) {
		_g_object_unref0 (_tmp7_);
	}
	_g_object_unref0 (self->priv->preferences);
	self->priv->preferences = _tmp8_;
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = self->priv->preferences;
	g_return_if_fail (_tmp9_ != NULL);
	_tmp10_ = self->priv->builder;
	_tmp11_ = gtk_builder_get_object (_tmp10_, "graphtracestore");
	self->priv->itemstore = G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, GTK_TYPE_TREE_STORE) ? ((GtkTreeStore*) _tmp11_) : NULL;
	_tmp12_ = self->priv->builder;
	_tmp13_ = gtk_builder_get_object (_tmp12_, "graphtraceview");
	self->priv->itemview = G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, GTK_TYPE_TREE_VIEW) ? ((GtkTreeView*) _tmp13_) : NULL;
	_tmp14_ = self->priv->builder;
	_tmp15_ = gtk_builder_get_object (_tmp14_, "graphtracebook");
	self->priv->notebook = G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, GTK_TYPE_NOTEBOOK) ? ((GtkNotebook*) _tmp15_) : NULL;
	_tmp16_ = self->priv->builder;
	_tmp17_ = gtk_builder_get_object (_tmp16_, "graphminimum");
	self->priv->graphminimum = _tmp17_;
	_tmp18_ = self->priv->builder;
	_tmp19_ = gtk_builder_get_object (_tmp18_, "graphmaximum");
	self->priv->graphmaximum = _tmp19_;
	_tmp20_ = self->priv->builder;
	_tmp21_ = gtk_builder_get_object (_tmp20_, "graphenabled");
	self->priv->graphenabled = _tmp21_;
	_tmp22_ = self->priv->builder;
	_tmp23_ = gtk_builder_get_object (_tmp22_, "graphsmooth");
	self->priv->graphsmooth = _tmp23_;
	_tmp24_ = self->priv->builder;
	_tmp25_ = gtk_builder_get_object (_tmp24_, "tracecolor");
	self->priv->tracecolor = _tmp25_;
	_tmp26_ = self->priv->builder;
	_tmp27_ = gtk_builder_get_object (_tmp26_, "traceenabled");
	self->priv->traceenabled = _tmp27_;
	_tmp28_ = self->priv->builder;
	_tmp29_ = gtk_builder_get_object (_tmp28_, "traceexpression");
	self->priv->traceexpression = _tmp29_;
	_tmp30_ = self->priv->settingscache;
	_tmp31_ = settings_cache_generalsettings (_tmp30_);
	_tmp32_ = _tmp31_;
	_tmp34_ = _tmp33_ = g_settings_get_strv (_tmp32_, "graphs");
	_tmp35_ = _tmp34_;
	_tmp35__length1 = _vala_array_length (_tmp33_);
	_g_object_unref0 (_tmp32_);
	graphids = _tmp35_;
	graphids_length1 = _tmp35__length1;
	_graphids_size_ = graphids_length1;
	_tmp36_ = graphids;
	_tmp36__length1 = graphids_length1;
	{
		gchar** graphid_collection = NULL;
		gint graphid_collection_length1 = 0;
		gint _graphid_collection_size_ = 0;
		gint graphid_it = 0;
		graphid_collection = _tmp36_;
		graphid_collection_length1 = _tmp36__length1;
		for (graphid_it = 0; graphid_it < _tmp36__length1; graphid_it = graphid_it + 1) {
			gchar* _tmp37_ = NULL;
			gchar* graphid = NULL;
			_tmp37_ = g_strdup (graphid_collection[graphid_it]);
			graphid = _tmp37_;
			{
				GtkTreeIter parent = {0};
				GtkTreeStore* _tmp38_ = NULL;
				const gchar* _tmp39_ = NULL;
				const gchar* _tmp40_ = NULL;
				GtkTreeIter _tmp41_ = {0};
				GSettings* graphsettings = NULL;
				SettingsCache* _tmp42_ = NULL;
				const gchar* _tmp43_ = NULL;
				GSettings* _tmp44_ = NULL;
				gchar** traceids = NULL;
				GSettings* _tmp45_ = NULL;
				gchar** _tmp46_ = NULL;
				gchar** _tmp47_ = NULL;
				gint traceids_length1 = 0;
				gint _traceids_size_ = 0;
				gchar** _tmp48_ = NULL;
				gint _tmp48__length1 = 0;
				_tmp38_ = self->priv->itemstore;
				_tmp39_ = graphid;
				_tmp40_ = graphid;
				gtk_tree_store_insert_with_values (_tmp38_, &_tmp41_, NULL, -1, 0, _tmp39_, 1, _tmp40_, -1);
				parent = _tmp41_;
				_tmp42_ = self->priv->settingscache;
				_tmp43_ = graphid;
				_tmp44_ = settings_cache_graphsettings (_tmp42_, _tmp43_);
				graphsettings = _tmp44_;
				_tmp45_ = graphsettings;
				_tmp47_ = _tmp46_ = g_settings_get_strv (_tmp45_, "traces");
				traceids = _tmp47_;
				traceids_length1 = _vala_array_length (_tmp46_);
				_traceids_size_ = traceids_length1;
				_tmp48_ = traceids;
				_tmp48__length1 = traceids_length1;
				{
					gchar** traceid_collection = NULL;
					gint traceid_collection_length1 = 0;
					gint _traceid_collection_size_ = 0;
					gint traceid_it = 0;
					traceid_collection = _tmp48_;
					traceid_collection_length1 = _tmp48__length1;
					for (traceid_it = 0; traceid_it < _tmp48__length1; traceid_it = traceid_it + 1) {
						gchar* _tmp49_ = NULL;
						gchar* traceid = NULL;
						_tmp49_ = g_strdup (traceid_collection[traceid_it]);
						traceid = _tmp49_;
						{
							GtkTreeStore* _tmp50_ = NULL;
							GtkTreeIter _tmp51_ = {0};
							const gchar* _tmp52_ = NULL;
							const gchar* _tmp53_ = NULL;
							const gchar* _tmp54_ = NULL;
							_tmp50_ = self->priv->itemstore;
							_tmp51_ = parent;
							_tmp52_ = traceid;
							_tmp53_ = graphid;
							_tmp54_ = traceid;
							gtk_tree_store_insert_with_values (_tmp50_, NULL, &_tmp51_, -1, 0, _tmp52_, 1, _tmp53_, 2, _tmp54_, -1);
							_g_free0 (traceid);
						}
					}
				}
				traceids = (_vala_array_free (traceids, traceids_length1, (GDestroyNotify) g_free), NULL);
				_g_object_unref0 (graphsettings);
				_g_free0 (graphid);
			}
		}
	}
	_tmp55_ = self->priv->itemview;
	gtk_tree_view_expand_all (_tmp55_);
	_tmp56_ = self->priv->preferences;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp56_, GTK_TYPE_WIDGET, GtkWidget));
	graphids = (_vala_array_free (graphids, graphids_length1, (GDestroyNotify) g_free), NULL);
}


static void advanced_preferences_revert (AdvancedPreferences* self) {
	gchar** graphids = NULL;
	SettingsCache* _tmp0_ = NULL;
	GSettings* _tmp1_ = NULL;
	GSettings* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gchar** _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	gint graphids_length1 = 0;
	gint _graphids_size_ = 0;
	gchar** _tmp6_ = NULL;
	gint _tmp6__length1 = 0;
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	_tmp0_ = self->priv->settingscache;
	_tmp1_ = settings_cache_generalsettings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp4_ = _tmp3_ = g_settings_get_strv (_tmp2_, "graphs");
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _vala_array_length (_tmp3_);
	_g_object_unref0 (_tmp2_);
	graphids = _tmp5_;
	graphids_length1 = _tmp5__length1;
	_graphids_size_ = graphids_length1;
	_tmp6_ = graphids;
	_tmp6__length1 = graphids_length1;
	{
		gchar** graphid_collection = NULL;
		gint graphid_collection_length1 = 0;
		gint _graphid_collection_size_ = 0;
		gint graphid_it = 0;
		graphid_collection = _tmp6_;
		graphid_collection_length1 = _tmp6__length1;
		for (graphid_it = 0; graphid_it < _tmp6__length1; graphid_it = graphid_it + 1) {
			gchar* _tmp7_ = NULL;
			gchar* graphid = NULL;
			_tmp7_ = g_strdup (graphid_collection[graphid_it]);
			graphid = _tmp7_;
			{
				GSettings* graphsettings = NULL;
				SettingsCache* _tmp8_ = NULL;
				const gchar* _tmp9_ = NULL;
				GSettings* _tmp10_ = NULL;
				GSettings* _tmp11_ = NULL;
				gchar** _tmp12_ = NULL;
				gchar** _tmp13_ = NULL;
				GSettings* _tmp17_ = NULL;
				gchar** _tmp18_ = NULL;
				gchar** _tmp19_ = NULL;
				_tmp8_ = self->priv->settingscache;
				_tmp9_ = graphid;
				_tmp10_ = settings_cache_graphsettings (_tmp8_, _tmp9_);
				graphsettings = _tmp10_;
				_tmp11_ = graphsettings;
				_tmp13_ = _tmp12_ = g_settings_list_keys (_tmp11_);
				{
					gchar** key_collection = NULL;
					gint key_collection_length1 = 0;
					gint _key_collection_size_ = 0;
					gint key_it = 0;
					key_collection = _tmp13_;
					key_collection_length1 = _vala_array_length (_tmp12_);
					for (key_it = 0; key_it < _vala_array_length (_tmp12_); key_it = key_it + 1) {
						gchar* _tmp14_ = NULL;
						gchar* key = NULL;
						_tmp14_ = g_strdup (key_collection[key_it]);
						key = _tmp14_;
						{
							GSettings* _tmp15_ = NULL;
							const gchar* _tmp16_ = NULL;
							_tmp15_ = graphsettings;
							_tmp16_ = key;
							g_settings_reset (_tmp15_, _tmp16_);
							_g_free0 (key);
						}
					}
					key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
				}
				_tmp17_ = graphsettings;
				_tmp19_ = _tmp18_ = g_settings_get_strv (_tmp17_, "traces");
				{
					gchar** traceid_collection = NULL;
					gint traceid_collection_length1 = 0;
					gint _traceid_collection_size_ = 0;
					gint traceid_it = 0;
					traceid_collection = _tmp19_;
					traceid_collection_length1 = _vala_array_length (_tmp18_);
					for (traceid_it = 0; traceid_it < _vala_array_length (_tmp18_); traceid_it = traceid_it + 1) {
						gchar* _tmp20_ = NULL;
						gchar* traceid = NULL;
						_tmp20_ = g_strdup (traceid_collection[traceid_it]);
						traceid = _tmp20_;
						{
							GSettings* tracesettings = NULL;
							SettingsCache* _tmp21_ = NULL;
							const gchar* _tmp22_ = NULL;
							const gchar* _tmp23_ = NULL;
							GSettings* _tmp24_ = NULL;
							GSettings* _tmp25_ = NULL;
							gchar** _tmp26_ = NULL;
							gchar** _tmp27_ = NULL;
							_tmp21_ = self->priv->settingscache;
							_tmp22_ = graphid;
							_tmp23_ = traceid;
							_tmp24_ = settings_cache_tracesettings (_tmp21_, _tmp22_, _tmp23_);
							tracesettings = _tmp24_;
							_tmp25_ = tracesettings;
							_tmp27_ = _tmp26_ = g_settings_list_keys (_tmp25_);
							{
								gchar** key_collection = NULL;
								gint key_collection_length1 = 0;
								gint _key_collection_size_ = 0;
								gint key_it = 0;
								key_collection = _tmp27_;
								key_collection_length1 = _vala_array_length (_tmp26_);
								for (key_it = 0; key_it < _vala_array_length (_tmp26_); key_it = key_it + 1) {
									gchar* _tmp28_ = NULL;
									gchar* key = NULL;
									_tmp28_ = g_strdup (key_collection[key_it]);
									key = _tmp28_;
									{
										const gchar* _tmp29_ = NULL;
										_tmp29_ = key;
										if (g_strcmp0 (_tmp29_, "color") != 0) {
											GSettings* _tmp30_ = NULL;
											const gchar* _tmp31_ = NULL;
											_tmp30_ = tracesettings;
											_tmp31_ = key;
											g_settings_reset (_tmp30_, _tmp31_);
										}
										_g_free0 (key);
									}
								}
								key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
							}
							_g_object_unref0 (tracesettings);
							_g_free0 (traceid);
						}
					}
					traceid_collection = (_vala_array_free (traceid_collection, traceid_collection_length1, (GDestroyNotify) g_free), NULL);
				}
				_g_object_unref0 (graphsettings);
				_g_free0 (graphid);
			}
		}
	}
	g_signal_emit_by_name (self, "colorscheme-restore");
	graphids = (_vala_array_free (graphids, graphids_length1, (GDestroyNotify) g_free), NULL);
}


void advanced_preferences_on_advprefdialog_destroy (GtkWidget* source, AdvancedPreferences* self) {
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	g_return_if_fail (GTK_IS_WIDGET (source));
	_g_object_unref0 (self->priv->preferences);
	self->priv->preferences = NULL;
	_g_object_unref0 (self->priv->builder);
	self->priv->builder = NULL;
}


void advanced_preferences_on_advprefdialog_response (GtkDialog* source, gint response, AdvancedPreferences* self) {
	gint _tmp0_ = 0;
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	g_return_if_fail (GTK_IS_DIALOG (source));
	_tmp0_ = response;
	switch (_tmp0_) {
		case 0:
		{
			GtkDialog* _tmp1_ = NULL;
			_tmp1_ = source;
			gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GTK_TYPE_WIDGET, GtkWidget));
			return;
		}
		case 1:
		{
			advanced_preferences_revert (self);
			return;
		}
		case 2:
		{
			g_signal_emit_by_name (self, "itemhelp-show");
			return;
		}
		default:
		break;
	}
}


static gboolean _utils_get_settings_rgba_gsettings_bind_get_mapping (GValue* value, GVariant* variant, void* user_data) {
	gboolean result;
	result = utils_get_settings_rgba (value, variant, user_data);
	return result;
}


static void ___lambda2_ (void) {
}


static void ____lambda2__gdestroy_notify (void* data) {
	___lambda2_ ();
}


void advanced_preferences_on_graphtraceview_cursor_changed (GtkTreeView* source, AdvancedPreferences* self) {
	GtkTreePath* path = NULL;
	GtkTreeView* _tmp0_ = NULL;
	GtkTreePath* _tmp1_ = NULL;
	GtkTreePath* _tmp2_ = NULL;
	GtkTreeIter iter = {0};
	GtkTreeStore* _tmp3_ = NULL;
	GtkTreePath* _tmp4_ = NULL;
	GtkTreeIter _tmp5_ = {0};
	gboolean _tmp6_ = FALSE;
	GValue value = {0};
	GtkTreeStore* _tmp7_ = NULL;
	GtkTreeIter _tmp8_ = {0};
	GValue _tmp9_ = {0};
	gchar* graphid = NULL;
	GValue _tmp10_ = {0};
	gchar* _tmp11_ = NULL;
	GtkTreeStore* _tmp12_ = NULL;
	GtkTreeIter _tmp13_ = {0};
	GValue _tmp14_ = {0};
	gchar* traceid = NULL;
	GValue _tmp15_ = {0};
	gchar* _tmp16_ = NULL;
	const gchar* _tmp17_ = NULL;
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	g_return_if_fail (GTK_IS_TREE_VIEW (source));
	_tmp0_ = source;
	gtk_tree_view_get_cursor (_tmp0_, &_tmp1_, NULL);
	_gtk_tree_path_free0 (path);
	path = _tmp1_;
	_tmp2_ = path;
	if (_tmp2_ == NULL) {
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp3_ = self->priv->itemstore;
	_tmp4_ = path;
	_tmp6_ = gtk_tree_model_get_iter (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GTK_TYPE_TREE_MODEL, GtkTreeModel), &_tmp5_, _tmp4_);
	iter = _tmp5_;
	if (!_tmp6_) {
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp7_ = self->priv->itemstore;
	_tmp8_ = iter;
	gtk_tree_model_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GTK_TYPE_TREE_MODEL, GtkTreeModel), &_tmp8_, 1, &_tmp9_);
	G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL;
	value = _tmp9_;
	_tmp10_ = value;
	_tmp11_ = g_strdup (g_value_get_string (&_tmp10_));
	graphid = _tmp11_;
	_tmp12_ = self->priv->itemstore;
	_tmp13_ = iter;
	gtk_tree_model_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GTK_TYPE_TREE_MODEL, GtkTreeModel), &_tmp13_, 2, &_tmp14_);
	G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL;
	value = _tmp14_;
	_tmp15_ = value;
	_tmp16_ = g_strdup (g_value_get_string (&_tmp15_));
	traceid = _tmp16_;
	_tmp17_ = traceid;
	if (_tmp17_ == NULL) {
		GtkNotebook* _tmp18_ = NULL;
		GSettings* graphsettings = NULL;
		SettingsCache* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		GSettings* _tmp21_ = NULL;
		GObject* _tmp22_ = NULL;
		GSettings* _tmp23_ = NULL;
		GObject* _tmp24_ = NULL;
		GObject* _tmp25_ = NULL;
		GSettings* _tmp26_ = NULL;
		GObject* _tmp27_ = NULL;
		GObject* _tmp28_ = NULL;
		GSettings* _tmp29_ = NULL;
		GObject* _tmp30_ = NULL;
		GObject* _tmp31_ = NULL;
		GSettings* _tmp32_ = NULL;
		GObject* _tmp33_ = NULL;
		_tmp18_ = self->priv->notebook;
		gtk_notebook_set_current_page (_tmp18_, 0);
		_tmp19_ = self->priv->settingscache;
		_tmp20_ = graphid;
		_tmp21_ = settings_cache_graphsettings (_tmp19_, _tmp20_);
		graphsettings = _tmp21_;
		_tmp22_ = self->priv->graphminimum;
		g_settings_unbind (_tmp22_, "text");
		_tmp23_ = graphsettings;
		_tmp24_ = self->priv->graphminimum;
		g_settings_bind (_tmp23_, "minimum", _tmp24_, "text", G_SETTINGS_BIND_DEFAULT);
		_tmp25_ = self->priv->graphmaximum;
		g_settings_unbind (_tmp25_, "text");
		_tmp26_ = graphsettings;
		_tmp27_ = self->priv->graphmaximum;
		g_settings_bind (_tmp26_, "maximum", _tmp27_, "text", G_SETTINGS_BIND_DEFAULT);
		_tmp28_ = self->priv->graphenabled;
		g_settings_unbind (_tmp28_, "active");
		_tmp29_ = graphsettings;
		_tmp30_ = self->priv->graphenabled;
		g_settings_bind (_tmp29_, "enabled", _tmp30_, "active", G_SETTINGS_BIND_DEFAULT);
		_tmp31_ = self->priv->graphsmooth;
		g_settings_unbind (_tmp31_, "text");
		_tmp32_ = graphsettings;
		_tmp33_ = self->priv->graphsmooth;
		g_settings_bind (_tmp32_, "smooth", _tmp33_, "text", G_SETTINGS_BIND_DEFAULT);
		_g_object_unref0 (graphsettings);
	} else {
		GtkNotebook* _tmp34_ = NULL;
		GSettings* tracesettings = NULL;
		SettingsCache* _tmp35_ = NULL;
		const gchar* _tmp36_ = NULL;
		const gchar* _tmp37_ = NULL;
		GSettings* _tmp38_ = NULL;
		GObject* _tmp39_ = NULL;
		GSettings* _tmp40_ = NULL;
		GObject* _tmp41_ = NULL;
		GObject* _tmp42_ = NULL;
		GSettings* _tmp43_ = NULL;
		GObject* _tmp44_ = NULL;
		GObject* _tmp45_ = NULL;
		GSettings* _tmp46_ = NULL;
		GObject* _tmp47_ = NULL;
		_tmp34_ = self->priv->notebook;
		gtk_notebook_set_current_page (_tmp34_, 1);
		_tmp35_ = self->priv->settingscache;
		_tmp36_ = graphid;
		_tmp37_ = traceid;
		_tmp38_ = settings_cache_tracesettings (_tmp35_, _tmp36_, _tmp37_);
		tracesettings = _tmp38_;
		_tmp39_ = self->priv->tracecolor;
		g_settings_unbind (_tmp39_, "rgba");
		_tmp40_ = tracesettings;
		_tmp41_ = self->priv->tracecolor;
		g_settings_bind_with_mapping (_tmp40_, "color", _tmp41_, "rgba", G_SETTINGS_BIND_DEFAULT, _utils_get_settings_rgba_gsettings_bind_get_mapping, (GSettingsBindSetMapping) utils_set_settings_rgba, NULL, ____lambda2__gdestroy_notify);
		_tmp42_ = self->priv->traceenabled;
		g_settings_unbind (_tmp42_, "active");
		_tmp43_ = tracesettings;
		_tmp44_ = self->priv->traceenabled;
		g_settings_bind (_tmp43_, "enabled", _tmp44_, "active", G_SETTINGS_BIND_DEFAULT);
		_tmp45_ = self->priv->traceexpression;
		g_settings_unbind (_tmp45_, "text");
		_tmp46_ = tracesettings;
		_tmp47_ = self->priv->traceexpression;
		g_settings_bind (_tmp46_, "expression", _tmp47_, "text", G_SETTINGS_BIND_DEFAULT);
		_g_object_unref0 (tracesettings);
	}
	_g_free0 (traceid);
	_g_free0 (graphid);
	G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL;
	_gtk_tree_path_free0 (path);
}


ColorMapper* advanced_preferences_get_colormapper (AdvancedPreferences* self) {
	ColorMapper* result;
	ColorMapper* _tmp0_ = NULL;
	g_return_val_if_fail (IS_ADVANCED_PREFERENCES (self), NULL);
	_tmp0_ = self->priv->_colormapper;
	result = _tmp0_;
	return result;
}


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


static void advanced_preferences_set_colormapper (AdvancedPreferences* self, ColorMapper* value) {
	ColorMapper* _tmp0_ = NULL;
	ColorMapper* _tmp1_ = NULL;
	g_return_if_fail (IS_ADVANCED_PREFERENCES (self));
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_colormapper);
	self->priv->_colormapper = _tmp1_;
	g_object_notify ((GObject *) self, "colormapper");
}


static GObject * advanced_preferences_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	AdvancedPreferences * self;
	SettingsCache* _tmp0_ = NULL;
	parent_class = G_OBJECT_CLASS (advanced_preferences_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ADVANCED_PREFERENCES, AdvancedPreferences);
	_tmp0_ = settings_cache_new ();
	_g_object_unref0 (self->priv->settingscache);
	self->priv->settingscache = _tmp0_;
	return obj;
}


static void advanced_preferences_class_init (AdvancedPreferencesClass * klass) {
	advanced_preferences_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (AdvancedPreferencesPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_advanced_preferences_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_advanced_preferences_set_property;
	G_OBJECT_CLASS (klass)->constructor = advanced_preferences_constructor;
	G_OBJECT_CLASS (klass)->finalize = advanced_preferences_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ADVANCED_PREFERENCES_COLORMAPPER, g_param_spec_object ("colormapper", "colormapper", "colormapper", TYPE_COLOR_MAPPER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_signal_new ("itemhelp_show", TYPE_ADVANCED_PREFERENCES, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	g_signal_new ("colorscheme_restore", TYPE_ADVANCED_PREFERENCES, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void advanced_preferences_instance_init (AdvancedPreferences * self) {
	self->priv = ADVANCED_PREFERENCES_GET_PRIVATE (self);
}


static void advanced_preferences_finalize (GObject* obj) {
	AdvancedPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ADVANCED_PREFERENCES, AdvancedPreferences);
	_g_object_unref0 (self->priv->settingscache);
	_g_object_unref0 (self->priv->preferences);
	_g_object_unref0 (self->priv->builder);
	_g_object_unref0 (self->priv->_colormapper);
	G_OBJECT_CLASS (advanced_preferences_parent_class)->finalize (obj);
}


/******************************************************************************
 * Copyright (C) 2011-2013  Michael Hofmann <mh21@mh21.de>                    *
 *                                                                            *
 * This program is free software; you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation; either version 3 of the License, or          *
 * (at your option) any later version.                                        *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                *
 ******************************************************************************/
GType advanced_preferences_get_type (void) {
	static volatile gsize advanced_preferences_type_id__volatile = 0;
	if (g_once_init_enter (&advanced_preferences_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AdvancedPreferencesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) advanced_preferences_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AdvancedPreferences), 0, (GInstanceInitFunc) advanced_preferences_instance_init, NULL };
		GType advanced_preferences_type_id;
		advanced_preferences_type_id = g_type_register_static (G_TYPE_OBJECT, "AdvancedPreferences", &g_define_type_info, 0);
		g_once_init_leave (&advanced_preferences_type_id__volatile, advanced_preferences_type_id);
	}
	return advanced_preferences_type_id__volatile;
}


static void _vala_advanced_preferences_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	AdvancedPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ADVANCED_PREFERENCES, AdvancedPreferences);
	switch (property_id) {
		case ADVANCED_PREFERENCES_COLORMAPPER:
		g_value_set_object (value, advanced_preferences_get_colormapper (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_advanced_preferences_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	AdvancedPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ADVANCED_PREFERENCES, AdvancedPreferences);
	switch (property_id) {
		case ADVANCED_PREFERENCES_COLORMAPPER:
		advanced_preferences_set_colormapper (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



