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

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

#include "graphs.h"
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <adwaita.h>
#include <glib/gi18n-lib.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

enum  {
	GRAPHS_IMPORT_DIALOG_0_PROPERTY,
	GRAPHS_IMPORT_DIALOG_NUM_PROPERTIES
};
static GParamSpec* graphs_import_dialog_properties[GRAPHS_IMPORT_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_settings_schema_unref0(var) ((var == NULL) ? NULL : (var = (g_settings_schema_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _Block8Data Block8Data;
typedef struct _Block9Data Block9Data;
typedef struct _Block10Data Block10Data;
enum  {
	GRAPHS_IMPORT_DIALOG_ACCEPT_SIGNAL,
	GRAPHS_IMPORT_DIALOG_NUM_SIGNALS
};
static guint graphs_import_dialog_signals[GRAPHS_IMPORT_DIALOG_NUM_SIGNALS] = {0};

struct _GraphsImportDialogPrivate {
	GtkBox* _mode_box;
	GSettings* settings;
	gchar** modes;
	gint modes_length1;
	gint _modes_size_;
};

struct _Block8Data {
	int _ref_count_;
	GraphsImportDialog* self;
	AdwComboRow* delimiter;
	AdwEntryRow* custom_delimiter;
};

struct _Block9Data {
	int _ref_count_;
	GSettings* settings;
	gchar* key;
};

struct _Block10Data {
	int _ref_count_;
	Block9Data * _data9_;
	AdwComboRow* comborow;
};

static gint GraphsImportDialog_private_offset;
static gpointer graphs_import_dialog_parent_class = NULL;

static gchar** _vala_array_dup4 (gchar** self,
                          gssize length);
static void graphs_import_dialog_bind_setting (GSettings* settings,
                                        GObject* object,
                                        const gchar* key);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void ______lambda31_ (Block8Data* _data8_);
static void _______lambda31__g_object_notify (GObject* _sender,
                                       GParamSpec* pspec,
                                       gpointer self);
static GtkBox* graphs_import_dialog_get_mode_box (GraphsImportDialog* self);
static void graphs_import_dialog_on_accept (GraphsImportDialog* self);
static void _graphs_import_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self);
static void graphs_import_dialog_on_reset (GraphsImportDialog* self);
static void __lambda32_ (GraphsImportDialog* self,
                  AdwAlertDialog* d,
                  const gchar* response);
static void ___lambda32__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                             const gchar* response,
                                             gpointer self);
static void _graphs_import_dialog_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static void ____lambda29_ (Block10Data* _data10_);
static void _____lambda29__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static void ____lambda30_ (Block10Data* _data10_);
static void _____lambda30__g_settings_changed (GSettings* _sender,
                                        const gchar* key,
                                        gpointer self);
static void graphs_import_dialog_finalize (GObject * obj);
static GType graphs_import_dialog_get_type_once (void);
static void _vala_graphs_import_dialog_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
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);

static inline gpointer
graphs_import_dialog_get_instance_private (GraphsImportDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsImportDialog_private_offset);
}

static gchar**
_vala_array_dup4 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

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 gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

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

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		GraphsImportDialog* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->custom_delimiter);
		_g_object_unref0 (_data8_->delimiter);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static void
______lambda31_ (Block8Data* _data8_)
{
	GraphsImportDialog* self;
	AdwEntryRow* _tmp0_;
	AdwComboRow* _tmp1_;
	self = _data8_->self;
	_tmp0_ = _data8_->custom_delimiter;
	_tmp1_ = _data8_->delimiter;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, adw_combo_row_get_selected (_tmp1_) == ((guint) 6));
}

static void
_______lambda31__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self)
{
	______lambda31_ (self);
}

GraphsImportDialog*
graphs_import_dialog_construct (GType object_type,
                                GraphsApplication* application,
                                gchar** modes,
                                gint modes_length1)
{
	GraphsImportDialog * self = NULL;
	GSettings* _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp2_;
	GraphsWindow* _tmp57_;
	GraphsWindow* _tmp58_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (application != NULL, NULL);
	self = (GraphsImportDialog*) g_object_new (object_type, NULL);
	_tmp0_ = graphs_application_get_settings_child (application, "import-params");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp0_;
	_tmp1_ = (modes != NULL) ? _vala_array_dup4 (modes, modes_length1) : modes;
	_tmp1__length1 = modes_length1;
	self->priv->modes = (_vala_array_free (self->priv->modes, self->priv->modes_length1, (GDestroyNotify) g_free), NULL);
	self->priv->modes = _tmp1_;
	self->priv->modes_length1 = _tmp1__length1;
	self->priv->_modes_size_ = self->priv->modes_length1;
	_tmp2_ = gtk_builder_new ();
	builder = _tmp2_;
	{
		gchar** mode_collection = NULL;
		gint mode_collection_length1 = 0;
		gint _mode_collection_size_ = 0;
		gint mode_it = 0;
		mode_collection = modes;
		mode_collection_length1 = modes_length1;
		for (mode_it = 0; mode_it < mode_collection_length1; mode_it = mode_it + 1) {
			gchar* _tmp3_;
			gchar* mode = NULL;
			_tmp3_ = g_strdup (mode_collection[mode_it]);
			mode = _tmp3_;
			{
				AdwPreferencesGroup* group = NULL;
				GtkBuilder* _tmp9_;
				const gchar* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				GObject* _tmp13_;
				AdwPreferencesGroup* _tmp14_;
				AdwPreferencesGroup* _tmp15_;
				GSettings* mode_settings = NULL;
				GSettings* _tmp16_;
				const gchar* _tmp17_;
				GSettings* _tmp18_;
				GSettings* _tmp19_;
				GSettingsSchema* _tmp20_;
				GSettingsSchema* _tmp21_;
				GSettingsSchema* _tmp22_;
				gchar** _tmp23_;
				gchar** _tmp24_;
				gchar** _tmp25_;
				gint _tmp25__length1;
				const gchar* _tmp42_;
				const gchar* _tmp43_;
				GQuark _tmp45_ = 0U;
				static GQuark _tmp44_label0 = 0;
				GtkBox* _tmp55_;
				AdwPreferencesGroup* _tmp56_;
				{
					GtkBuilder* _tmp4_;
					const gchar* _tmp5_;
					const gchar* _tmp6_;
					gchar* _tmp7_;
					gchar* _tmp8_;
					_tmp4_ = builder;
					_tmp5_ = mode;
					_tmp6_ = string_to_string (_tmp5_);
					_tmp7_ = g_strconcat ("/se/sjoerd/Graphs/ui/import-", _tmp6_, ".ui", NULL);
					_tmp8_ = _tmp7_;
					gtk_builder_add_from_resource (_tmp4_, _tmp8_, &_inner_error0_);
					_g_free0 (_tmp8_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
				}
				goto __finally0;
				__catch0_g_error:
				{
					g_clear_error (&_inner_error0_);
					g_assert_not_reached ();
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (mode);
					_g_object_unref0 (builder);
					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;
				}
				_tmp9_ = builder;
				_tmp10_ = mode;
				_tmp11_ = g_strconcat (_tmp10_, "_group", NULL);
				_tmp12_ = _tmp11_;
				_tmp13_ = gtk_builder_get_object (_tmp9_, _tmp12_);
				_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, adw_preferences_group_get_type (), AdwPreferencesGroup));
				_tmp15_ = _tmp14_;
				_g_free0 (_tmp12_);
				group = _tmp15_;
				_tmp16_ = self->priv->settings;
				_tmp17_ = mode;
				_tmp18_ = g_settings_get_child (_tmp16_, _tmp17_);
				mode_settings = _tmp18_;
				_tmp19_ = mode_settings;
				g_object_get (_tmp19_, "settings-schema", &_tmp20_, NULL);
				_tmp21_ = _tmp20_;
				_tmp22_ = _tmp21_;
				_tmp24_ = _tmp23_ = g_settings_schema_list_keys (_tmp22_);
				_tmp25_ = _tmp24_;
				_tmp25__length1 = _vala_array_length (_tmp23_);
				_g_settings_schema_unref0 (_tmp22_);
				{
					gchar** key_collection = NULL;
					gint key_collection_length1 = 0;
					gint _key_collection_size_ = 0;
					gint key_it = 0;
					key_collection = _tmp25_;
					key_collection_length1 = _tmp25__length1;
					for (key_it = 0; key_it < key_collection_length1; key_it = key_it + 1) {
						gchar* _tmp26_;
						gchar* key = NULL;
						_tmp26_ = g_strdup (key_collection[key_it]);
						key = _tmp26_;
						{
							GObject* object = NULL;
							GtkBuilder* _tmp27_;
							const gchar* _tmp28_;
							gchar* _tmp29_;
							gchar* _tmp30_;
							const gchar* _tmp31_;
							gchar* _tmp32_;
							gchar* _tmp33_;
							gchar* _tmp34_;
							gchar* _tmp35_;
							GObject* _tmp36_;
							GObject* _tmp37_;
							GObject* _tmp38_;
							GSettings* _tmp39_;
							GObject* _tmp40_;
							const gchar* _tmp41_;
							_tmp27_ = builder;
							_tmp28_ = mode;
							_tmp29_ = g_strconcat (_tmp28_, "_", NULL);
							_tmp30_ = _tmp29_;
							_tmp31_ = key;
							_tmp32_ = string_replace (_tmp31_, "-", "_");
							_tmp33_ = _tmp32_;
							_tmp34_ = g_strconcat (_tmp30_, _tmp33_, NULL);
							_tmp35_ = _tmp34_;
							_tmp36_ = gtk_builder_get_object (_tmp27_, _tmp35_);
							_tmp37_ = _g_object_ref0 (_tmp36_);
							_tmp38_ = _tmp37_;
							_g_free0 (_tmp35_);
							_g_free0 (_tmp33_);
							_g_free0 (_tmp30_);
							object = _tmp38_;
							_tmp39_ = mode_settings;
							_tmp40_ = object;
							_tmp41_ = key;
							graphs_import_dialog_bind_setting (_tmp39_, _tmp40_, _tmp41_);
							_g_object_unref0 (object);
							_g_free0 (key);
						}
					}
					key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
				}
				_tmp42_ = mode;
				_tmp43_ = _tmp42_;
				_tmp45_ = (NULL == _tmp43_) ? 0 : g_quark_from_string (_tmp43_);
				if (_tmp45_ == ((0 != _tmp44_label0) ? _tmp44_label0 : (_tmp44_label0 = g_quark_from_static_string ("columns")))) {
					switch (0) {
						default:
						{
							{
								Block8Data* _data8_;
								GtkBuilder* _tmp46_;
								GObject* _tmp47_;
								AdwComboRow* _tmp48_;
								GtkBuilder* _tmp49_;
								GObject* _tmp50_;
								AdwEntryRow* _tmp51_;
								AdwComboRow* _tmp52_;
								AdwComboRow* _tmp54_;
								_data8_ = g_slice_new0 (Block8Data);
								_data8_->_ref_count_ = 1;
								_data8_->self = g_object_ref (self);
								_tmp46_ = builder;
								_tmp47_ = gtk_builder_get_object (_tmp46_, "columns_delimiter");
								_tmp48_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, adw_combo_row_get_type (), AdwComboRow));
								_data8_->delimiter = _tmp48_;
								_tmp49_ = builder;
								_tmp50_ = gtk_builder_get_object (_tmp49_, "columns_custom_delimiter");
								_tmp51_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, adw_entry_row_get_type (), AdwEntryRow));
								_data8_->custom_delimiter = _tmp51_;
								_tmp52_ = _data8_->delimiter;
								if (adw_combo_row_get_selected (_tmp52_) == ((guint) 6)) {
									AdwEntryRow* _tmp53_;
									_tmp53_ = _data8_->custom_delimiter;
									gtk_widget_set_visible ((GtkWidget*) _tmp53_, TRUE);
								}
								_tmp54_ = _data8_->delimiter;
								g_signal_connect_data ((GObject*) _tmp54_, "notify::selected", (GCallback) _______lambda31__g_object_notify, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
								block8_data_unref (_data8_);
								_data8_ = NULL;
								break;
							}
						}
					}
				} else {
					switch (0) {
						default:
						{
							{
								break;
							}
						}
					}
				}
				_tmp55_ = self->priv->_mode_box;
				_tmp56_ = group;
				gtk_box_append (_tmp55_, (GtkWidget*) _tmp56_);
				_g_object_unref0 (mode_settings);
				_g_object_unref0 (group);
				_g_free0 (mode);
			}
		}
	}
	_tmp57_ = graphs_application_get_window (application);
	_tmp58_ = _tmp57_;
	adw_dialog_present ((AdwDialog*) self, (GtkWidget*) _tmp58_);
	_g_object_unref0 (builder);
	return self;
}

GraphsImportDialog*
graphs_import_dialog_new (GraphsApplication* application,
                          gchar** modes,
                          gint modes_length1)
{
	return graphs_import_dialog_construct (GRAPHS_TYPE_IMPORT_DIALOG, application, modes, modes_length1);
}

static void
graphs_import_dialog_on_accept (GraphsImportDialog* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, graphs_import_dialog_signals[GRAPHS_IMPORT_DIALOG_ACCEPT_SIGNAL], 0);
	adw_dialog_close ((AdwDialog*) self);
}

static void
_graphs_import_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self)
{
	graphs_import_dialog_on_accept ((GraphsImportDialog*) self);
}

static void
__lambda32_ (GraphsImportDialog* self,
             AdwAlertDialog* d,
             const gchar* response)
{
	g_return_if_fail (d != NULL);
	g_return_if_fail (response != NULL);
	if (g_strcmp0 (response, "reset") == 0) {
		gchar** _tmp0_;
		gint _tmp0__length1;
		_tmp0_ = self->priv->modes;
		_tmp0__length1 = self->priv->modes_length1;
		{
			gchar** mode_collection = NULL;
			gint mode_collection_length1 = 0;
			gint _mode_collection_size_ = 0;
			gint mode_it = 0;
			mode_collection = _tmp0_;
			mode_collection_length1 = _tmp0__length1;
			for (mode_it = 0; mode_it < mode_collection_length1; mode_it = mode_it + 1) {
				gchar* _tmp1_;
				gchar* mode = NULL;
				_tmp1_ = g_strdup (mode_collection[mode_it]);
				mode = _tmp1_;
				{
					GSettings* _tmp2_;
					const gchar* _tmp3_;
					GSettings* _tmp4_;
					GSettings* _tmp5_;
					_tmp2_ = self->priv->settings;
					_tmp3_ = mode;
					_tmp4_ = g_settings_get_child (_tmp2_, _tmp3_);
					_tmp5_ = _tmp4_;
					graphs_tools_reset_settings (_tmp5_);
					_g_object_unref0 (_tmp5_);
					_g_free0 (mode);
				}
			}
		}
	}
}

static void
___lambda32__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                        const gchar* response,
                                        gpointer self)
{
	__lambda32_ ((GraphsImportDialog*) self, _sender, response);
}

static void
graphs_import_dialog_on_reset (GraphsImportDialog* self)
{
	AdwAlertDialog* dialog = NULL;
	GObject* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = graphs_tools_build_dialog ("reset_to_defaults");
	dialog = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, adw_alert_dialog_get_type (), AdwAlertDialog);
	adw_alert_dialog_set_body (dialog, _ ("Are you sure you want to reset the import settings?"));
	g_signal_connect_object (dialog, "response", (GCallback) ___lambda32__adw_alert_dialog_response, self, 0);
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
_graphs_import_dialog_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                   gpointer self)
{
	graphs_import_dialog_on_reset ((GraphsImportDialog*) self);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		_g_object_unref0 (_data9_->settings);
		_g_free0 (_data9_->key);
		g_slice_free (Block9Data, _data9_);
	}
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		_g_object_unref0 (_data10_->comborow);
		block9_data_unref (_data10_->_data9_);
		_data10_->_data9_ = NULL;
		g_slice_free (Block10Data, _data10_);
	}
}

static void
____lambda29_ (Block10Data* _data10_)
{
	Block9Data* _data9_;
	AdwComboRow* _tmp0_;
	_data9_ = _data10_->_data9_;
	_tmp0_ = _data10_->comborow;
	if (((guint) g_settings_get_enum (_data9_->settings, _data9_->key)) != adw_combo_row_get_selected (_tmp0_)) {
		AdwComboRow* _tmp1_;
		_tmp1_ = _data10_->comborow;
		g_settings_set_enum (_data9_->settings, _data9_->key, (gint) adw_combo_row_get_selected (_tmp1_));
	}
}

static void
_____lambda29__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	____lambda29_ (self);
}

static void
____lambda30_ (Block10Data* _data10_)
{
	Block9Data* _data9_;
	AdwComboRow* _tmp0_;
	_data9_ = _data10_->_data9_;
	_tmp0_ = _data10_->comborow;
	adw_combo_row_set_selected (_tmp0_, (guint) g_settings_get_enum (_data9_->settings, _data9_->key));
}

static void
_____lambda30__g_settings_changed (GSettings* _sender,
                                   const gchar* key,
                                   gpointer self)
{
	____lambda30_ (self);
}

static void
graphs_import_dialog_bind_setting (GSettings* settings,
                                   GObject* object,
                                   const gchar* key)
{
	Block9Data* _data9_;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (settings != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (key != NULL);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (settings);
	_g_object_unref0 (_data9_->settings);
	_data9_->settings = _tmp0_;
	_tmp1_ = g_strdup (key);
	_g_free0 (_data9_->key);
	_data9_->key = _tmp1_;
	if (G_TYPE_CHECK_INSTANCE_TYPE (object, adw_entry_row_get_type ())) {
		g_settings_bind (_data9_->settings, _data9_->key, object, "text", 0);
	} else {
		if (G_TYPE_CHECK_INSTANCE_TYPE (object, adw_combo_row_get_type ())) {
			Block10Data* _data10_;
			AdwComboRow* _tmp2_;
			AdwComboRow* _tmp3_;
			AdwComboRow* _tmp4_;
			gchar* _tmp5_;
			_data10_ = g_slice_new0 (Block10Data);
			_data10_->_ref_count_ = 1;
			_data10_->_data9_ = block9_data_ref (_data9_);
			_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (object, adw_combo_row_get_type (), AdwComboRow));
			_data10_->comborow = _tmp2_;
			_tmp3_ = _data10_->comborow;
			adw_combo_row_set_selected (_tmp3_, (guint) g_settings_get_enum (_data9_->settings, _data9_->key));
			_tmp4_ = _data10_->comborow;
			g_signal_connect_data ((GObject*) _tmp4_, "notify::selected", (GCallback) _____lambda29__g_object_notify, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
			_tmp5_ = g_strconcat ("changed::", _data9_->key, NULL);
			g_signal_connect_data (_data9_->settings, _tmp5_, (GCallback) _____lambda30__g_settings_changed, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
			_g_free0 (_tmp5_);
			block10_data_unref (_data10_);
			_data10_ = NULL;
		} else {
			if (G_TYPE_CHECK_INSTANCE_TYPE (object, adw_spin_row_get_type ())) {
				g_settings_bind (_data9_->settings, _data9_->key, object, "value", 0);
			}
		}
	}
	block9_data_unref (_data9_);
	_data9_ = NULL;
}

static GtkBox*
graphs_import_dialog_get_mode_box (GraphsImportDialog* self)
{
	GtkBox* result;
	GtkBox* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_mode_box;
	result = _tmp0_;
	return result;
}

static void
graphs_import_dialog_class_init (GraphsImportDialogClass * klass,
                                 gpointer klass_data)
{
	graphs_import_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsImportDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_import_dialog_get_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_import_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/import.ui");
	graphs_import_dialog_signals[GRAPHS_IMPORT_DIALOG_ACCEPT_SIGNAL] = g_signal_new ("accept", GRAPHS_TYPE_IMPORT_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "mode_box", FALSE, GraphsImportDialog_private_offset + G_STRUCT_OFFSET (GraphsImportDialogPrivate, _mode_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_accept", G_CALLBACK(_graphs_import_dialog_on_accept_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_reset", G_CALLBACK(_graphs_import_dialog_on_reset_gtk_button_clicked));
}

static void
graphs_import_dialog_instance_init (GraphsImportDialog * self,
                                    gpointer klass)
{
	self->priv = graphs_import_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_import_dialog_finalize (GObject * obj)
{
	GraphsImportDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_IMPORT_DIALOG, GraphsImportDialog);
	_g_object_unref0 (self->priv->settings);
	self->priv->modes = (_vala_array_free (self->priv->modes, self->priv->modes_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (graphs_import_dialog_parent_class)->finalize (obj);
}

/**
     * Import dialog
     */
static GType
graphs_import_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsImportDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_import_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsImportDialog), 0, (GInstanceInitFunc) graphs_import_dialog_instance_init, NULL };
	GType graphs_import_dialog_type_id;
	graphs_import_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "GraphsImportDialog", &g_define_type_info, 0);
	GraphsImportDialog_private_offset = g_type_add_instance_private (graphs_import_dialog_type_id, sizeof (GraphsImportDialogPrivate));
	return graphs_import_dialog_type_id;
}

GType
graphs_import_dialog_get_type (void)
{
	static volatile gsize graphs_import_dialog_type_id__once = 0;
	if (g_once_init_enter (&graphs_import_dialog_type_id__once)) {
		GType graphs_import_dialog_type_id;
		graphs_import_dialog_type_id = graphs_import_dialog_get_type_once ();
		g_once_init_leave (&graphs_import_dialog_type_id__once, graphs_import_dialog_type_id);
	}
	return graphs_import_dialog_type_id__once;
}

static void
_vala_graphs_import_dialog_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GraphsImportDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_IMPORT_DIALOG, GraphsImportDialog);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

