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

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

#include "graphs.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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_SQL_GROUP_0_PROPERTY,
	GRAPHS_SQL_GROUP_TABLE_ROW_PROPERTY,
	GRAPHS_SQL_GROUP_COLUMN_X_PROPERTY,
	GRAPHS_SQL_GROUP_COLUMN_Y_PROPERTY,
	GRAPHS_SQL_GROUP_USE_XERR_PROPERTY,
	GRAPHS_SQL_GROUP_USE_YERR_PROPERTY,
	GRAPHS_SQL_GROUP_COLUMN_XERR_PROPERTY,
	GRAPHS_SQL_GROUP_COLUMN_YERR_PROPERTY,
	GRAPHS_SQL_GROUP_NO_NUMERIC_WARNING_PROPERTY,
	GRAPHS_SQL_GROUP_NUM_PROPERTIES
};
static GParamSpec* graphs_sql_group_properties[GRAPHS_SQL_GROUP_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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GraphsSqlGroupPrivate {
	AdwComboRow* _table_row;
	AdwComboRow* _column_x;
	AdwComboRow* _column_y;
	AdwSwitchRow* _use_xerr;
	AdwSwitchRow* _use_yerr;
	AdwComboRow* _column_xerr;
	AdwComboRow* _column_yerr;
	GtkLabel* _no_numeric_warning;
	GraphsDatabaseReader* db_reader;
	GraphsImportSettings* settings;
	gboolean is_initial_setup;
};

static gint GraphsSqlGroup_private_offset;
static gpointer graphs_sql_group_parent_class = NULL;

static void graphs_sql_group_setup_ui (GraphsSqlGroup* self,
                                GError** error);
static gchar** _vala_array_dup7 (gchar** self,
                          gssize length);
static void graphs_sql_group_update_columns (GraphsSqlGroup* self,
                                      GError** error);
static void graphs_sql_group_on_table_changed (GraphsSqlGroup* self);
static void _graphs_sql_group_on_table_changed_g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self);
static void graphs_sql_group_on_err_toggled (GraphsSqlGroup* self);
static void _graphs_sql_group_on_err_toggled_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self);
static void graphs_sql_group_on_columns_changed (GraphsSqlGroup* self);
static void _graphs_sql_group_on_columns_changed_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self);
static void graphs_sql_group_finalize (GObject * obj);
static GType graphs_sql_group_get_type_once (void);
static void _vala_graphs_sql_group_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_sql_group_get_instance_private (GraphsSqlGroup* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsSqlGroup_private_offset);
}

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

GraphsSqlGroup*
graphs_sql_group_construct (GType object_type,
                            GraphsImportSettings* settings,
                            GError** error)
{
	GraphsSqlGroup * self = NULL;
	GObject* _tmp0_;
	GraphsImportSettings* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (settings != NULL, NULL);
	self = (GraphsSqlGroup*) g_object_new (object_type, NULL);
	_tmp0_ = graphs_import_settings_get_item (settings, "db-reader");
	_g_object_unref0 (self->priv->db_reader);
	self->priv->db_reader = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GRAPHS_TYPE_DATABASE_READER, GraphsDatabaseReader);
	_tmp1_ = _g_object_ref0 (settings);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	graphs_sql_group_setup_ui (self, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (self);
			return NULL;
		} else {
			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;
		}
	}
	return self;
}

GraphsSqlGroup*
graphs_sql_group_new (GraphsImportSettings* settings,
                      GError** error)
{
	return graphs_sql_group_construct (GRAPHS_TYPE_SQL_GROUP, settings, error);
}

static gchar**
_vala_array_dup7 (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 void
graphs_sql_group_setup_ui (GraphsSqlGroup* self,
                           GError** error)
{
	gchar** tables = NULL;
	GraphsDatabaseReader* _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gint tables_length1;
	gint _tables_size_;
	gchar* table_name = NULL;
	GraphsImportSettings* _tmp3_;
	gchar* _tmp4_;
	GtkStringList* table_model = NULL;
	GtkStringList* _tmp5_;
	AdwComboRow* _tmp6_;
	AdwComboRow* _tmp7_;
	AdwSwitchRow* _tmp8_;
	GraphsImportSettings* _tmp9_;
	AdwSwitchRow* _tmp10_;
	GraphsImportSettings* _tmp11_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db_reader;
	_tmp1_ = _tmp0_->table_names;
	_tmp1__length1 = _tmp0_->table_names_length1;
	_tmp2_ = (_tmp1_ != NULL) ? _vala_array_dup7 (_tmp1_, _tmp1__length1) : _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	tables = _tmp2_;
	tables_length1 = _tmp2__length1;
	_tables_size_ = tables_length1;
	_tmp3_ = self->priv->settings;
	_tmp4_ = graphs_import_settings_get_string (_tmp3_, "table-name");
	table_name = _tmp4_;
	_tmp5_ = gtk_string_list_new (tables);
	table_model = _tmp5_;
	_tmp6_ = self->priv->_table_row;
	adw_combo_row_set_model (_tmp6_, (GListModel*) table_model);
	_tmp7_ = self->priv->_table_row;
	adw_combo_row_set_selected (_tmp7_, gtk_string_list_find (table_model, table_name));
	_tmp8_ = self->priv->_use_xerr;
	_tmp9_ = self->priv->settings;
	adw_switch_row_set_active (_tmp8_, graphs_import_settings_get_boolean (_tmp9_, "use-xerr"));
	_tmp10_ = self->priv->_use_yerr;
	_tmp11_ = self->priv->settings;
	adw_switch_row_set_active (_tmp10_, graphs_import_settings_get_boolean (_tmp11_, "use-yerr"));
	graphs_sql_group_update_columns (self, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (table_model);
			_g_free0 (table_name);
			tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), NULL);
			return;
		} else {
			_g_object_unref0 (table_model);
			_g_free0 (table_name);
			tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), 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;
		}
	}
	self->priv->is_initial_setup = FALSE;
	_g_object_unref0 (table_model);
	_g_free0 (table_name);
	tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), NULL);
}

static void
graphs_sql_group_on_table_changed (GraphsSqlGroup* self)
{
	GtkStringObject* selected_item = NULL;
	AdwComboRow* _tmp0_;
	GObject* _tmp1_;
	GtkStringObject* _tmp2_;
	GtkStringObject* _tmp3_;
	GraphsImportSettings* _tmp4_;
	GtkStringObject* _tmp5_;
	const gchar* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	if (self->priv->is_initial_setup) {
		return;
	}
	_tmp0_ = self->priv->_table_row;
	_tmp1_ = adw_combo_row_get_selected_item (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_string_object_get_type (), GtkStringObject));
	selected_item = _tmp2_;
	_tmp3_ = selected_item;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (selected_item);
		return;
	}
	_tmp4_ = self->priv->settings;
	_tmp5_ = selected_item;
	_tmp6_ = gtk_string_object_get_string (_tmp5_);
	graphs_import_settings_set_string (_tmp4_, "table-name", _tmp6_);
	{
		graphs_sql_group_update_columns (self, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			_g_object_unref0 (selected_item);
			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;
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("ui.vala:62: Could not update columns: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (selected_item);
		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 (selected_item);
}

static void
_graphs_sql_group_on_table_changed_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self)
{
	graphs_sql_group_on_table_changed ((GraphsSqlGroup*) self);
}

static void
graphs_sql_group_on_err_toggled (GraphsSqlGroup* self)
{
	GraphsImportSettings* _tmp0_;
	AdwSwitchRow* _tmp1_;
	GraphsImportSettings* _tmp2_;
	AdwSwitchRow* _tmp3_;
	g_return_if_fail (self != NULL);
	if (self->priv->is_initial_setup) {
		return;
	}
	_tmp0_ = self->priv->settings;
	_tmp1_ = self->priv->_use_xerr;
	graphs_import_settings_set_boolean (_tmp0_, "use-xerr", adw_switch_row_get_active (_tmp1_));
	_tmp2_ = self->priv->settings;
	_tmp3_ = self->priv->_use_yerr;
	graphs_import_settings_set_boolean (_tmp2_, "use-yerr", adw_switch_row_get_active (_tmp3_));
}

static void
_graphs_sql_group_on_err_toggled_g_object_notify (GObject* _sender,
                                                  GParamSpec* pspec,
                                                  gpointer self)
{
	graphs_sql_group_on_err_toggled ((GraphsSqlGroup*) self);
}

static void
graphs_sql_group_on_columns_changed (GraphsSqlGroup* self)
{
	GtkStringObject* selected_x = NULL;
	AdwComboRow* _tmp0_;
	GObject* _tmp1_;
	GtkStringObject* _tmp2_;
	GtkStringObject* selected_y = NULL;
	AdwComboRow* _tmp3_;
	GObject* _tmp4_;
	GtkStringObject* _tmp5_;
	gboolean _tmp6_ = FALSE;
	GtkStringObject* _tmp7_;
	GraphsImportSettings* _tmp9_;
	GtkStringObject* _tmp10_;
	const gchar* _tmp11_;
	GraphsImportSettings* _tmp12_;
	GtkStringObject* _tmp13_;
	const gchar* _tmp14_;
	GtkStringObject* selected_xerr = NULL;
	AdwComboRow* _tmp15_;
	GObject* _tmp16_;
	GtkStringObject* _tmp17_;
	GtkStringObject* selected_yerr = NULL;
	AdwComboRow* _tmp18_;
	GObject* _tmp19_;
	GtkStringObject* _tmp20_;
	GtkStringObject* _tmp21_;
	GtkStringObject* _tmp25_;
	g_return_if_fail (self != NULL);
	if (self->priv->is_initial_setup) {
		return;
	}
	_tmp0_ = self->priv->_column_x;
	_tmp1_ = adw_combo_row_get_selected_item (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_string_object_get_type (), GtkStringObject));
	selected_x = _tmp2_;
	_tmp3_ = self->priv->_column_y;
	_tmp4_ = adw_combo_row_get_selected_item (_tmp3_);
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_string_object_get_type (), GtkStringObject));
	selected_y = _tmp5_;
	_tmp7_ = selected_x;
	if (_tmp7_ == NULL) {
		_tmp6_ = TRUE;
	} else {
		GtkStringObject* _tmp8_;
		_tmp8_ = selected_y;
		_tmp6_ = _tmp8_ == NULL;
	}
	if (_tmp6_) {
		_g_object_unref0 (selected_y);
		_g_object_unref0 (selected_x);
		return;
	}
	_tmp9_ = self->priv->settings;
	_tmp10_ = selected_x;
	_tmp11_ = gtk_string_object_get_string (_tmp10_);
	graphs_import_settings_set_string (_tmp9_, "x-column", _tmp11_);
	_tmp12_ = self->priv->settings;
	_tmp13_ = selected_y;
	_tmp14_ = gtk_string_object_get_string (_tmp13_);
	graphs_import_settings_set_string (_tmp12_, "y-column", _tmp14_);
	_tmp15_ = self->priv->_column_xerr;
	_tmp16_ = adw_combo_row_get_selected_item (_tmp15_);
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_string_object_get_type (), GtkStringObject));
	selected_xerr = _tmp17_;
	_tmp18_ = self->priv->_column_yerr;
	_tmp19_ = adw_combo_row_get_selected_item (_tmp18_);
	_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_string_object_get_type (), GtkStringObject));
	selected_yerr = _tmp20_;
	_tmp21_ = selected_xerr;
	if (_tmp21_ != NULL) {
		GraphsImportSettings* _tmp22_;
		GtkStringObject* _tmp23_;
		const gchar* _tmp24_;
		_tmp22_ = self->priv->settings;
		_tmp23_ = selected_xerr;
		_tmp24_ = gtk_string_object_get_string (_tmp23_);
		graphs_import_settings_set_string (_tmp22_, "xerr-column", _tmp24_);
	}
	_tmp25_ = selected_yerr;
	if (_tmp25_ != NULL) {
		GraphsImportSettings* _tmp26_;
		GtkStringObject* _tmp27_;
		const gchar* _tmp28_;
		_tmp26_ = self->priv->settings;
		_tmp27_ = selected_yerr;
		_tmp28_ = gtk_string_object_get_string (_tmp27_);
		graphs_import_settings_set_string (_tmp26_, "yerr-column", _tmp28_);
	}
	_g_object_unref0 (selected_yerr);
	_g_object_unref0 (selected_xerr);
	_g_object_unref0 (selected_y);
	_g_object_unref0 (selected_x);
}

static void
_graphs_sql_group_on_columns_changed_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self)
{
	graphs_sql_group_on_columns_changed ((GraphsSqlGroup*) self);
}

static void
graphs_sql_group_update_columns (GraphsSqlGroup* self,
                                 GError** error)
{
	gchar* x_column = NULL;
	GraphsImportSettings* _tmp0_;
	gchar* _tmp1_;
	gchar* y_column = NULL;
	GraphsImportSettings* _tmp2_;
	gchar* _tmp3_;
	gchar* xerr_column = NULL;
	GraphsImportSettings* _tmp4_;
	gchar* _tmp5_;
	gchar* yerr_column = NULL;
	GraphsImportSettings* _tmp6_;
	gchar* _tmp7_;
	gchar* table_name = NULL;
	GraphsImportSettings* _tmp8_;
	gchar* _tmp9_;
	gchar** columns = NULL;
	GraphsDatabaseReader* _tmp10_;
	gint _tmp11_ = 0;
	gchar** _tmp12_;
	gint columns_length1;
	gint _columns_size_;
	GtkStringList* column_model = NULL;
	GtkStringList* _tmp19_;
	AdwComboRow* _tmp20_;
	GtkStringList* _tmp21_;
	AdwComboRow* _tmp22_;
	GtkStringList* _tmp23_;
	AdwComboRow* _tmp24_;
	GtkStringList* _tmp25_;
	AdwComboRow* _tmp26_;
	GtkStringList* _tmp27_;
	guint found = 0U;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = graphs_import_settings_get_string (_tmp0_, "x-column");
	x_column = _tmp1_;
	_tmp2_ = self->priv->settings;
	_tmp3_ = graphs_import_settings_get_string (_tmp2_, "y-column");
	y_column = _tmp3_;
	_tmp4_ = self->priv->settings;
	_tmp5_ = graphs_import_settings_get_string (_tmp4_, "xerr-column");
	xerr_column = _tmp5_;
	_tmp6_ = self->priv->settings;
	_tmp7_ = graphs_import_settings_get_string (_tmp6_, "yerr-column");
	yerr_column = _tmp7_;
	_tmp8_ = self->priv->settings;
	_tmp9_ = graphs_import_settings_get_string (_tmp8_, "table-name");
	table_name = _tmp9_;
	_tmp10_ = self->priv->db_reader;
	_tmp12_ = graphs_database_reader_get_numeric_columns (_tmp10_, table_name, &_tmp11_, &_inner_error0_);
	columns = _tmp12_;
	columns_length1 = _tmp11_;
	_columns_size_ = columns_length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (table_name);
			_g_free0 (yerr_column);
			_g_free0 (xerr_column);
			_g_free0 (y_column);
			_g_free0 (x_column);
			return;
		} else {
			_g_free0 (table_name);
			_g_free0 (yerr_column);
			_g_free0 (xerr_column);
			_g_free0 (y_column);
			_g_free0 (x_column);
			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;
		}
	}
	if (columns_length1 == 0) {
		GtkLabel* _tmp13_;
		AdwComboRow* _tmp14_;
		AdwComboRow* _tmp15_;
		_tmp13_ = self->priv->_no_numeric_warning;
		gtk_widget_set_visible ((GtkWidget*) _tmp13_, TRUE);
		_tmp14_ = self->priv->_column_x;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp14_, FALSE);
		_tmp15_ = self->priv->_column_y;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp15_, FALSE);
	} else {
		GtkLabel* _tmp16_;
		AdwComboRow* _tmp17_;
		AdwComboRow* _tmp18_;
		_tmp16_ = self->priv->_no_numeric_warning;
		gtk_widget_set_visible ((GtkWidget*) _tmp16_, FALSE);
		_tmp17_ = self->priv->_column_x;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp17_, TRUE);
		_tmp18_ = self->priv->_column_y;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp18_, TRUE);
	}
	_tmp19_ = gtk_string_list_new (columns);
	column_model = _tmp19_;
	_tmp20_ = self->priv->_column_x;
	_tmp21_ = column_model;
	adw_combo_row_set_model (_tmp20_, (GListModel*) _tmp21_);
	_tmp22_ = self->priv->_column_y;
	_tmp23_ = column_model;
	adw_combo_row_set_model (_tmp22_, (GListModel*) _tmp23_);
	_tmp24_ = self->priv->_column_xerr;
	_tmp25_ = column_model;
	adw_combo_row_set_model (_tmp24_, (GListModel*) _tmp25_);
	_tmp26_ = self->priv->_column_yerr;
	_tmp27_ = column_model;
	adw_combo_row_set_model (_tmp26_, (GListModel*) _tmp27_);
	found = (guint) 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp28_ = FALSE;
			_tmp28_ = TRUE;
			while (TRUE) {
				const gchar* _tmp30_;
				const gchar* _tmp33_;
				const gchar* _tmp36_;
				const gchar* _tmp39_;
				if (!_tmp28_) {
					gint _tmp29_;
					_tmp29_ = i;
					i = _tmp29_ + 1;
				}
				_tmp28_ = FALSE;
				if (!(i < columns_length1)) {
					break;
				}
				_tmp30_ = columns[i];
				if (g_strcmp0 (_tmp30_, x_column) == 0) {
					AdwComboRow* _tmp31_;
					guint _tmp32_;
					_tmp31_ = self->priv->_column_x;
					adw_combo_row_set_selected (_tmp31_, (guint) i);
					_tmp32_ = found;
					found = _tmp32_ + 1;
				}
				_tmp33_ = columns[i];
				if (g_strcmp0 (_tmp33_, y_column) == 0) {
					AdwComboRow* _tmp34_;
					guint _tmp35_;
					_tmp34_ = self->priv->_column_y;
					adw_combo_row_set_selected (_tmp34_, (guint) i);
					_tmp35_ = found;
					found = _tmp35_ + 1;
				}
				_tmp36_ = columns[i];
				if (g_strcmp0 (_tmp36_, xerr_column) == 0) {
					AdwComboRow* _tmp37_;
					guint _tmp38_;
					_tmp37_ = self->priv->_column_xerr;
					adw_combo_row_set_selected (_tmp37_, (guint) i);
					_tmp38_ = found;
					found = _tmp38_ + 1;
				}
				_tmp39_ = columns[i];
				if (g_strcmp0 (_tmp39_, yerr_column) == 0) {
					AdwComboRow* _tmp40_;
					guint _tmp41_;
					_tmp40_ = self->priv->_column_yerr;
					adw_combo_row_set_selected (_tmp40_, (guint) i);
					_tmp41_ = found;
					found = _tmp41_ + 1;
				}
				if (found == ((guint) 4)) {
					break;
				}
			}
		}
	}
	_g_object_unref0 (column_model);
	columns = (_vala_array_free (columns, columns_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (table_name);
	_g_free0 (yerr_column);
	_g_free0 (xerr_column);
	_g_free0 (y_column);
	_g_free0 (x_column);
}

AdwComboRow*
graphs_sql_group_get_table_row (GraphsSqlGroup* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_table_row;
	result = _tmp0_;
	return result;
}

AdwComboRow*
graphs_sql_group_get_column_x (GraphsSqlGroup* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_column_x;
	result = _tmp0_;
	return result;
}

AdwComboRow*
graphs_sql_group_get_column_y (GraphsSqlGroup* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_column_y;
	result = _tmp0_;
	return result;
}

AdwSwitchRow*
graphs_sql_group_get_use_xerr (GraphsSqlGroup* self)
{
	AdwSwitchRow* result;
	AdwSwitchRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_use_xerr;
	result = _tmp0_;
	return result;
}

AdwSwitchRow*
graphs_sql_group_get_use_yerr (GraphsSqlGroup* self)
{
	AdwSwitchRow* result;
	AdwSwitchRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_use_yerr;
	result = _tmp0_;
	return result;
}

AdwComboRow*
graphs_sql_group_get_column_xerr (GraphsSqlGroup* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_column_xerr;
	result = _tmp0_;
	return result;
}

AdwComboRow*
graphs_sql_group_get_column_yerr (GraphsSqlGroup* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_column_yerr;
	result = _tmp0_;
	return result;
}

GtkLabel*
graphs_sql_group_get_no_numeric_warning (GraphsSqlGroup* self)
{
	GtkLabel* result;
	GtkLabel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_no_numeric_warning;
	result = _tmp0_;
	return result;
}

static void
graphs_sql_group_class_init (GraphsSqlGroupClass * klass,
                             gpointer klass_data)
{
	graphs_sql_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsSqlGroup_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_sql_group_get_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_sql_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_TABLE_ROW_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_TABLE_ROW_PROPERTY] = g_param_spec_object ("table-row", "table-row", "table-row", adw_combo_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_COLUMN_X_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_COLUMN_X_PROPERTY] = g_param_spec_object ("column-x", "column-x", "column-x", adw_combo_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_COLUMN_Y_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_COLUMN_Y_PROPERTY] = g_param_spec_object ("column-y", "column-y", "column-y", adw_combo_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_USE_XERR_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_USE_XERR_PROPERTY] = g_param_spec_object ("use-xerr", "use-xerr", "use-xerr", adw_switch_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_USE_YERR_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_USE_YERR_PROPERTY] = g_param_spec_object ("use-yerr", "use-yerr", "use-yerr", adw_switch_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_COLUMN_XERR_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_COLUMN_XERR_PROPERTY] = g_param_spec_object ("column-xerr", "column-xerr", "column-xerr", adw_combo_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_COLUMN_YERR_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_COLUMN_YERR_PROPERTY] = g_param_spec_object ("column-yerr", "column-yerr", "column-yerr", adw_combo_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SQL_GROUP_NO_NUMERIC_WARNING_PROPERTY, graphs_sql_group_properties[GRAPHS_SQL_GROUP_NO_NUMERIC_WARNING_PROPERTY] = g_param_spec_object ("no-numeric-warning", "no-numeric-warning", "no-numeric-warning", gtk_label_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/import/sql/main-group.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "table_row", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _table_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "column_x", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _column_x));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "column_y", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _column_y));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "use_xerr", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _use_xerr));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "use_yerr", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _use_yerr));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "column_xerr", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _column_xerr));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "column_yerr", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _column_yerr));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "no_numeric_warning", FALSE, GraphsSqlGroup_private_offset + G_STRUCT_OFFSET (GraphsSqlGroupPrivate, _no_numeric_warning));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_table_changed", G_CALLBACK(_graphs_sql_group_on_table_changed_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_err_toggled", G_CALLBACK(_graphs_sql_group_on_err_toggled_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_columns_changed", G_CALLBACK(_graphs_sql_group_on_columns_changed_g_object_notify));
}

static void
graphs_sql_group_instance_init (GraphsSqlGroup * self,
                                gpointer klass)
{
	self->priv = graphs_sql_group_get_instance_private (self);
	self->priv->is_initial_setup = TRUE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_sql_group_finalize (GObject * obj)
{
	GraphsSqlGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_SQL_GROUP, GraphsSqlGroup);
	_g_object_unref0 (self->priv->db_reader);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (graphs_sql_group_parent_class)->finalize (obj);
}

/**
     * UI Widget for SQL file import
     */
static GType
graphs_sql_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsSqlGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_sql_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsSqlGroup), 0, (GInstanceInitFunc) graphs_sql_group_instance_init, NULL };
	GType graphs_sql_group_type_id;
	graphs_sql_group_type_id = g_type_register_static (adw_preferences_group_get_type (), "GraphsSqlGroup", &g_define_type_info, 0);
	GraphsSqlGroup_private_offset = g_type_add_instance_private (graphs_sql_group_type_id, sizeof (GraphsSqlGroupPrivate));
	return graphs_sql_group_type_id;
}

GType
graphs_sql_group_get_type (void)
{
	static volatile gsize graphs_sql_group_type_id__once = 0;
	if (g_once_init_enter (&graphs_sql_group_type_id__once)) {
		GType graphs_sql_group_type_id;
		graphs_sql_group_type_id = graphs_sql_group_get_type_once ();
		g_once_init_leave (&graphs_sql_group_type_id__once, graphs_sql_group_type_id);
	}
	return graphs_sql_group_type_id__once;
}

static void
_vala_graphs_sql_group_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GraphsSqlGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_SQL_GROUP, GraphsSqlGroup);
	switch (property_id) {
		case GRAPHS_SQL_GROUP_TABLE_ROW_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_table_row (self));
		break;
		case GRAPHS_SQL_GROUP_COLUMN_X_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_column_x (self));
		break;
		case GRAPHS_SQL_GROUP_COLUMN_Y_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_column_y (self));
		break;
		case GRAPHS_SQL_GROUP_USE_XERR_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_use_xerr (self));
		break;
		case GRAPHS_SQL_GROUP_USE_YERR_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_use_yerr (self));
		break;
		case GRAPHS_SQL_GROUP_COLUMN_XERR_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_column_xerr (self));
		break;
		case GRAPHS_SQL_GROUP_COLUMN_YERR_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_column_yerr (self));
		break;
		case GRAPHS_SQL_GROUP_NO_NUMERIC_WARNING_PROPERTY:
		g_value_set_object (value, graphs_sql_group_get_no_numeric_warning (self));
		break;
		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 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;
}

