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

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

#include "graphs.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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_GENERATE_DATA_DIALOG_0_PROPERTY,
	GRAPHS_GENERATE_DATA_DIALOG_NUM_PROPERTIES
};
static GParamSpec* graphs_generate_data_dialog_properties[GRAPHS_GENERATE_DATA_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))

struct _GraphsGenerateDataDialogPrivate {
	AdwEntryRow* _equation;
	AdwEntryRow* _xstart;
	AdwEntryRow* _xstop;
	AdwSpinRow* _steps;
	AdwComboRow* _scale;
	GtkButton* _confirm_button;
	AdwEntryRow* _item_name;
	GraphsWindow* window;
	GSettings* settings;
};

static gint GraphsGenerateDataDialog_private_offset;
static gpointer graphs_generate_data_dialog_parent_class = NULL;

static AdwEntryRow* graphs_generate_data_dialog_get_equation (GraphsGenerateDataDialog* self);
static AdwEntryRow* graphs_generate_data_dialog_get_xstart (GraphsGenerateDataDialog* self);
static AdwEntryRow* graphs_generate_data_dialog_get_xstop (GraphsGenerateDataDialog* self);
static AdwSpinRow* graphs_generate_data_dialog_get_steps (GraphsGenerateDataDialog* self);
static AdwComboRow* graphs_generate_data_dialog_get_scale (GraphsGenerateDataDialog* self);
static void graphs_generate_data_dialog_set_confirm_sensitivity (GraphsGenerateDataDialog* self);
static GtkButton* graphs_generate_data_dialog_get_confirm_button (GraphsGenerateDataDialog* self);
static void graphs_generate_data_dialog_on_accept (GraphsGenerateDataDialog* self);
static AdwEntryRow* graphs_generate_data_dialog_get_item_name (GraphsGenerateDataDialog* self);
static void _graphs_generate_data_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                                gpointer self);
static void graphs_generate_data_dialog_on_equation_change (GraphsGenerateDataDialog* self);
static void _graphs_generate_data_dialog_on_equation_change_g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self);
static void graphs_generate_data_dialog_on_entry_change (GraphsGenerateDataDialog* self,
                                                  GObject* object,
                                                  GParamSpec* _param_spec);
static void _graphs_generate_data_dialog_on_entry_change_g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self);
static gint graphs_generate_data_dialog_on_steps_input (GraphsGenerateDataDialog* self,
                                                 gdouble* val);
static gint _graphs_generate_data_dialog_on_steps_input_adw_spin_row_input (AdwSpinRow* _sender,
                                                                     gdouble* new_value,
                                                                     gpointer self);
static void graphs_generate_data_dialog_finalize (GObject * obj);
static GType graphs_generate_data_dialog_get_type_once (void);
static void _vala_graphs_generate_data_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_generate_data_dialog_get_instance_private (GraphsGenerateDataDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsGenerateDataDialog_private_offset);
}

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

GraphsGenerateDataDialog*
graphs_generate_data_dialog_construct (GType object_type,
                                       GraphsWindow* window)
{
	GraphsGenerateDataDialog * self = NULL;
	GraphsWindow* _tmp0_;
	GSettings* _tmp1_;
	AdwEntryRow* _tmp2_;
	GSettings* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	AdwEntryRow* _tmp6_;
	GSettings* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	AdwEntryRow* _tmp10_;
	GSettings* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	AdwSpinRow* _tmp14_;
	GSettings* _tmp15_;
	AdwComboRow* _tmp16_;
	GSettings* _tmp17_;
	g_return_val_if_fail (window != NULL, NULL);
	self = (GraphsGenerateDataDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (window);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp0_;
	_tmp1_ = graphs_application_get_settings_child ("generate-data");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = self->priv->_equation;
	_tmp3_ = self->priv->settings;
	_tmp4_ = g_settings_get_string (_tmp3_, "equation");
	_tmp5_ = _tmp4_;
	gtk_editable_set_text ((GtkEditable*) _tmp2_, _tmp5_);
	_g_free0 (_tmp5_);
	_tmp6_ = self->priv->_xstart;
	_tmp7_ = self->priv->settings;
	_tmp8_ = g_settings_get_string (_tmp7_, "xstart");
	_tmp9_ = _tmp8_;
	gtk_editable_set_text ((GtkEditable*) _tmp6_, _tmp9_);
	_g_free0 (_tmp9_);
	_tmp10_ = self->priv->_xstop;
	_tmp11_ = self->priv->settings;
	_tmp12_ = g_settings_get_string (_tmp11_, "xstop");
	_tmp13_ = _tmp12_;
	gtk_editable_set_text ((GtkEditable*) _tmp10_, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp14_ = self->priv->_steps;
	_tmp15_ = self->priv->settings;
	adw_spin_row_set_value (_tmp14_, (gdouble) g_settings_get_int (_tmp15_, "steps"));
	_tmp16_ = self->priv->_scale;
	_tmp17_ = self->priv->settings;
	adw_combo_row_set_selected (_tmp16_, (guint) g_settings_get_enum (_tmp17_, "scale"));
	adw_dialog_present ((AdwDialog*) self, (GtkWidget*) window);
	return self;
}

GraphsGenerateDataDialog*
graphs_generate_data_dialog_new (GraphsWindow* window)
{
	return graphs_generate_data_dialog_construct (GRAPHS_TYPE_GENERATE_DATA_DIALOG, window);
}

static void
graphs_generate_data_dialog_set_confirm_sensitivity (GraphsGenerateDataDialog* self)
{
	gboolean invalid = FALSE;
	GtkWidget** widgets = NULL;
	AdwEntryRow* _tmp0_;
	GtkWidget* _tmp1_;
	AdwEntryRow* _tmp2_;
	GtkWidget* _tmp3_;
	AdwEntryRow* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget** _tmp6_;
	gint widgets_length1;
	gint _widgets_size_;
	GtkWidget** _tmp7_;
	gint _tmp7__length1;
	GtkButton* _tmp11_;
	g_return_if_fail (self != NULL);
	invalid = FALSE;
	_tmp0_ = self->priv->_equation;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) _tmp0_);
	_tmp2_ = self->priv->_xstart;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	_tmp4_ = self->priv->_xstop;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	_tmp6_ = g_new0 (GtkWidget*, 3 + 1);
	_tmp6_[0] = _tmp1_;
	_tmp6_[1] = _tmp3_;
	_tmp6_[2] = _tmp5_;
	widgets = _tmp6_;
	widgets_length1 = 3;
	_widgets_size_ = widgets_length1;
	_tmp7_ = widgets;
	_tmp7__length1 = widgets_length1;
	{
		GtkWidget** widget_collection = NULL;
		gint widget_collection_length1 = 0;
		gint _widget_collection_size_ = 0;
		gint widget_it = 0;
		widget_collection = _tmp7_;
		widget_collection_length1 = _tmp7__length1;
		for (widget_it = 0; widget_it < widget_collection_length1; widget_it = widget_it + 1) {
			GtkWidget* _tmp8_;
			GtkWidget* widget = NULL;
			_tmp8_ = _g_object_ref0 (widget_collection[widget_it]);
			widget = _tmp8_;
			{
				gboolean _tmp9_ = FALSE;
				if (invalid) {
					_tmp9_ = TRUE;
				} else {
					GtkWidget* _tmp10_;
					_tmp10_ = widget;
					_tmp9_ = gtk_widget_has_css_class (_tmp10_, "error");
				}
				invalid = _tmp9_;
				_g_object_unref0 (widget);
			}
		}
	}
	_tmp11_ = self->priv->_confirm_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp11_, !invalid);
	widgets = (_vala_array_free (widgets, widgets_length1, (GDestroyNotify) g_object_unref), NULL);
}

static void
graphs_generate_data_dialog_on_accept (GraphsGenerateDataDialog* self)
{
	gchar* equation = NULL;
	AdwEntryRow* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* xstart = NULL;
	AdwEntryRow* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* xstop = NULL;
	AdwEntryRow* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gint steps = 0;
	AdwSpinRow* _tmp9_;
	GraphsScale scale = 0;
	AdwComboRow* _tmp10_;
	GSettings* _tmp11_;
	const gchar* _tmp12_;
	GSettings* _tmp13_;
	const gchar* _tmp14_;
	GSettings* _tmp15_;
	const gchar* _tmp16_;
	GSettings* _tmp17_;
	GSettings* _tmp18_;
	gchar* name = NULL;
	AdwEntryRow* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	const gchar* _tmp22_;
	GraphsItem* item = NULL;
	GraphsWindow* _tmp25_;
	GraphsData* _tmp26_;
	GraphsData* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	GraphsGeneratedDataItem* _tmp31_;
	const gchar* _tmp32_;
	GraphsItem** items = NULL;
	GraphsItem* _tmp33_;
	GraphsItem** _tmp34_;
	gint items_length1;
	gint _items_size_;
	GraphsWindow* _tmp35_;
	GraphsData* _tmp36_;
	GraphsData* _tmp37_;
	GraphsWindow* _tmp38_;
	GraphsData* _tmp39_;
	GraphsData* _tmp40_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_equation;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	equation = _tmp2_;
	_tmp3_ = self->priv->_xstart;
	_tmp4_ = gtk_editable_get_text ((GtkEditable*) _tmp3_);
	_tmp5_ = g_strdup (_tmp4_);
	xstart = _tmp5_;
	_tmp6_ = self->priv->_xstop;
	_tmp7_ = gtk_editable_get_text ((GtkEditable*) _tmp6_);
	_tmp8_ = g_strdup (_tmp7_);
	xstop = _tmp8_;
	_tmp9_ = self->priv->_steps;
	steps = (gint) adw_spin_row_get_value (_tmp9_);
	_tmp10_ = self->priv->_scale;
	scale = (GraphsScale) adw_combo_row_get_selected (_tmp10_);
	_tmp11_ = self->priv->settings;
	_tmp12_ = equation;
	g_settings_set_string (_tmp11_, "equation", _tmp12_);
	_tmp13_ = self->priv->settings;
	_tmp14_ = xstart;
	g_settings_set_string (_tmp13_, "xstart", _tmp14_);
	_tmp15_ = self->priv->settings;
	_tmp16_ = xstop;
	g_settings_set_string (_tmp15_, "xstop", _tmp16_);
	_tmp17_ = self->priv->settings;
	g_settings_set_int (_tmp17_, "steps", steps);
	_tmp18_ = self->priv->settings;
	g_settings_set_enum (_tmp18_, "scale", (gint) scale);
	_tmp19_ = self->priv->_item_name;
	_tmp20_ = gtk_editable_get_text ((GtkEditable*) _tmp19_);
	_tmp21_ = g_strdup (_tmp20_);
	name = _tmp21_;
	_tmp22_ = name;
	if (g_strcmp0 (_tmp22_, "") == 0) {
		const gchar* _tmp23_;
		gchar* _tmp24_;
		_tmp23_ = equation;
		_tmp24_ = g_strconcat ("Y = ", _tmp23_, NULL);
		_g_free0 (name);
		name = _tmp24_;
	}
	_tmp25_ = self->priv->window;
	_tmp26_ = graphs_window_get_data (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = equation;
	_tmp29_ = xstart;
	_tmp30_ = xstop;
	_tmp31_ = graphs_item_factory_new_generated_data_item (_tmp27_, _tmp28_, _tmp29_, _tmp30_, steps, scale);
	item = (GraphsItem*) _tmp31_;
	_tmp32_ = name;
	graphs_item_set_name (item, _tmp32_);
	_tmp33_ = _g_object_ref0 (item);
	_tmp34_ = g_new0 (GraphsItem*, 1 + 1);
	_tmp34_[0] = _tmp33_;
	items = _tmp34_;
	items_length1 = 1;
	_items_size_ = items_length1;
	_tmp35_ = self->priv->window;
	_tmp36_ = graphs_window_get_data (_tmp35_);
	_tmp37_ = _tmp36_;
	graphs_data_add_items (_tmp37_, items, (gint) items_length1);
	_tmp38_ = self->priv->window;
	_tmp39_ = graphs_window_get_data (_tmp38_);
	_tmp40_ = _tmp39_;
	graphs_data_optimize_limits (_tmp40_);
	adw_dialog_close ((AdwDialog*) self);
	items = (_vala_array_free (items, items_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (item);
	_g_free0 (name);
	_g_free0 (xstop);
	_g_free0 (xstart);
	_g_free0 (equation);
}

static void
_graphs_generate_data_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self)
{
	graphs_generate_data_dialog_on_accept ((GraphsGenerateDataDialog*) self);
}

static void
graphs_generate_data_dialog_on_equation_change (GraphsGenerateDataDialog* self)
{
	AdwEntryRow* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_equation;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	if (graphs_python_helper_validate_equation (_tmp1_)) {
		AdwEntryRow* _tmp2_;
		_tmp2_ = self->priv->_equation;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp2_, "error");
	} else {
		AdwEntryRow* _tmp3_;
		_tmp3_ = self->priv->_equation;
		gtk_widget_add_css_class ((GtkWidget*) _tmp3_, "error");
	}
	graphs_generate_data_dialog_set_confirm_sensitivity (self);
}

static void
_graphs_generate_data_dialog_on_equation_change_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self)
{
	graphs_generate_data_dialog_on_equation_change ((GraphsGenerateDataDialog*) self);
}

static void
graphs_generate_data_dialog_on_entry_change (GraphsGenerateDataDialog* self,
                                             GObject* object,
                                             GParamSpec* _param_spec)
{
	AdwEntryRow* entry = NULL;
	AdwEntryRow* _tmp0_;
	AdwEntryRow* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (_param_spec != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, adw_entry_row_get_type ()) ? ((AdwEntryRow*) object) : NULL);
	entry = _tmp0_;
	_tmp1_ = entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	if (graphs_try_evaluate_string (_tmp2_, NULL, (gunichar) '.')) {
		AdwEntryRow* _tmp3_;
		_tmp3_ = entry;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp3_, "error");
	} else {
		AdwEntryRow* _tmp4_;
		_tmp4_ = entry;
		gtk_widget_add_css_class ((GtkWidget*) _tmp4_, "error");
	}
	graphs_generate_data_dialog_set_confirm_sensitivity (self);
	_g_object_unref0 (entry);
}

static void
_graphs_generate_data_dialog_on_entry_change_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self)
{
	graphs_generate_data_dialog_on_entry_change ((GraphsGenerateDataDialog*) self, _sender, pspec);
}

static gint
graphs_generate_data_dialog_on_steps_input (GraphsGenerateDataDialog* self,
                                            gdouble* val)
{
	gdouble _vala_val = 0.0;
	AdwSpinRow* _tmp0_;
	const gchar* _tmp1_;
	gdouble* _tmp2_ = NULL;
	gboolean _tmp3_;
	gdouble* _tmp4_;
	gboolean _tmp5_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->_steps;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp3_ = graphs_try_evaluate_string (_tmp1_, &_tmp2_, (gunichar) '.');
	_tmp4_ = _tmp2_;
	_vala_val = *_tmp4_;
	_tmp5_ = _tmp3_;
	_g_free0 (_tmp4_);
	if (_tmp5_) {
		result = 1;
		if (val) {
			*val = _vala_val;
		}
		return result;
	} else {
		result = GTK_INPUT_ERROR;
		if (val) {
			*val = _vala_val;
		}
		return result;
	}
}

static gint
_graphs_generate_data_dialog_on_steps_input_adw_spin_row_input (AdwSpinRow* _sender,
                                                                gdouble* new_value,
                                                                gpointer self)
{
	gint result;
	result = graphs_generate_data_dialog_on_steps_input ((GraphsGenerateDataDialog*) self, new_value);
	return result;
}

static AdwEntryRow*
graphs_generate_data_dialog_get_equation (GraphsGenerateDataDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_equation;
	result = _tmp0_;
	return result;
}

static AdwEntryRow*
graphs_generate_data_dialog_get_xstart (GraphsGenerateDataDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_xstart;
	result = _tmp0_;
	return result;
}

static AdwEntryRow*
graphs_generate_data_dialog_get_xstop (GraphsGenerateDataDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_xstop;
	result = _tmp0_;
	return result;
}

static AdwSpinRow*
graphs_generate_data_dialog_get_steps (GraphsGenerateDataDialog* self)
{
	AdwSpinRow* result;
	AdwSpinRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_steps;
	result = _tmp0_;
	return result;
}

static AdwComboRow*
graphs_generate_data_dialog_get_scale (GraphsGenerateDataDialog* self)
{
	AdwComboRow* result;
	AdwComboRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_scale;
	result = _tmp0_;
	return result;
}

static GtkButton*
graphs_generate_data_dialog_get_confirm_button (GraphsGenerateDataDialog* self)
{
	GtkButton* result;
	GtkButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_confirm_button;
	result = _tmp0_;
	return result;
}

static AdwEntryRow*
graphs_generate_data_dialog_get_item_name (GraphsGenerateDataDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item_name;
	result = _tmp0_;
	return result;
}

static void
graphs_generate_data_dialog_class_init (GraphsGenerateDataDialogClass * klass,
                                        gpointer klass_data)
{
	graphs_generate_data_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsGenerateDataDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_generate_data_dialog_get_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_generate_data_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/generate-data.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "equation", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _equation));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "xstart", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _xstart));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "xstop", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _xstop));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "steps", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _steps));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "scale", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _scale));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "confirm_button", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _confirm_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "item_name", FALSE, GraphsGenerateDataDialog_private_offset + G_STRUCT_OFFSET (GraphsGenerateDataDialogPrivate, _item_name));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_accept", G_CALLBACK(_graphs_generate_data_dialog_on_accept_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_equation_change", G_CALLBACK(_graphs_generate_data_dialog_on_equation_change_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_entry_change", G_CALLBACK(_graphs_generate_data_dialog_on_entry_change_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_steps_input", G_CALLBACK(_graphs_generate_data_dialog_on_steps_input_adw_spin_row_input));
}

static void
graphs_generate_data_dialog_instance_init (GraphsGenerateDataDialog * self,
                                           gpointer klass)
{
	self->priv = graphs_generate_data_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_generate_data_dialog_finalize (GObject * obj)
{
	GraphsGenerateDataDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_GENERATE_DATA_DIALOG, GraphsGenerateDataDialog);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (graphs_generate_data_dialog_parent_class)->finalize (obj);
}

/**
     * Generate Data dialog.
     */
static GType
graphs_generate_data_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsGenerateDataDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_generate_data_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsGenerateDataDialog), 0, (GInstanceInitFunc) graphs_generate_data_dialog_instance_init, NULL };
	GType graphs_generate_data_dialog_type_id;
	graphs_generate_data_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "GraphsGenerateDataDialog", &g_define_type_info, 0);
	GraphsGenerateDataDialog_private_offset = g_type_add_instance_private (graphs_generate_data_dialog_type_id, sizeof (GraphsGenerateDataDialogPrivate));
	return graphs_generate_data_dialog_type_id;
}

GType
graphs_generate_data_dialog_get_type (void)
{
	static volatile gsize graphs_generate_data_dialog_type_id__once = 0;
	if (g_once_init_enter (&graphs_generate_data_dialog_type_id__once)) {
		GType graphs_generate_data_dialog_type_id;
		graphs_generate_data_dialog_type_id = graphs_generate_data_dialog_get_type_once ();
		g_once_init_leave (&graphs_generate_data_dialog_type_id__once, graphs_generate_data_dialog_type_id);
	}
	return graphs_generate_data_dialog_type_id__once;
}

static void
_vala_graphs_generate_data_dialog_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	GraphsGenerateDataDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_GENERATE_DATA_DIALOG, GraphsGenerateDataDialog);
	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 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;
}

