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

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

#include "graphs.h"
#include <adwaita.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.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_SMOOTHEN_DIALOG_0_PROPERTY,
	GRAPHS_SMOOTHEN_DIALOG_NUM_PROPERTIES
};
static GParamSpec* graphs_smoothen_dialog_properties[GRAPHS_SMOOTHEN_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GraphsSmoothenDialogPrivate {
	AdwSpinRow* _savgol_window;
	AdwSpinRow* _savgol_polynomial;
	AdwSpinRow* _moving_average_box;
	GSettings* _settings;
};

static gint GraphsSmoothenDialog_private_offset;
static gpointer graphs_smoothen_dialog_parent_class = NULL;

static void graphs_smoothen_dialog_set_settings (GraphsSmoothenDialog* self,
                                          GSettings* value);
static GSettings* graphs_smoothen_dialog_get_settings (GraphsSmoothenDialog* self);
static AdwSpinRow* graphs_smoothen_dialog_get_savgol_window (GraphsSmoothenDialog* self);
static AdwSpinRow* graphs_smoothen_dialog_get_savgol_polynomial (GraphsSmoothenDialog* self);
static AdwSpinRow* graphs_smoothen_dialog_get_moving_average_box (GraphsSmoothenDialog* self);
static void graphs_smoothen_dialog_on_reset (GraphsSmoothenDialog* self);
static void _graphs_smoothen_dialog_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void graphs_smoothen_dialog_finalize (GObject * obj);
static GType graphs_smoothen_dialog_get_type_once (void);
static void _vala_graphs_smoothen_dialog_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_graphs_smoothen_dialog_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_smoothen_dialog_get_instance_private (GraphsSmoothenDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsSmoothenDialog_private_offset);
}

GraphsSmoothenDialog*
graphs_smoothen_dialog_construct (GType object_type,
                                  GraphsWindow* window)
{
	GraphsSmoothenDialog * self = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GSettings* _tmp2_;
	AdwSpinRow* _tmp3_;
	GSettings* _tmp4_;
	AdwSpinRow* _tmp5_;
	GSettings* _tmp6_;
	AdwSpinRow* _tmp7_;
	g_return_val_if_fail (window != NULL, NULL);
	self = (GraphsSmoothenDialog*) g_object_new (object_type, NULL);
	_tmp0_ = graphs_application_get_settings_child ("actions/smoothen");
	_tmp1_ = _tmp0_;
	graphs_smoothen_dialog_set_settings (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = self->priv->_settings;
	_tmp3_ = self->priv->_savgol_window;
	g_settings_bind (_tmp2_, "savgol-window", (GObject*) _tmp3_, "value", 0);
	_tmp4_ = self->priv->_settings;
	_tmp5_ = self->priv->_savgol_polynomial;
	g_settings_bind (_tmp4_, "savgol-polynomial", (GObject*) _tmp5_, "value", 0);
	_tmp6_ = self->priv->_settings;
	_tmp7_ = self->priv->_moving_average_box;
	g_settings_bind (_tmp6_, "moving-average-box", (GObject*) _tmp7_, "value", 0);
	adw_dialog_present ((AdwDialog*) self, (GtkWidget*) window);
	return self;
}

GraphsSmoothenDialog*
graphs_smoothen_dialog_new (GraphsWindow* window)
{
	return graphs_smoothen_dialog_construct (GRAPHS_TYPE_SMOOTHEN_DIALOG, window);
}

static void
graphs_smoothen_dialog_on_reset (GraphsSmoothenDialog* self)
{
	GSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_settings;
	graphs_tools_reset_settings (_tmp0_);
}

static void
_graphs_smoothen_dialog_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	graphs_smoothen_dialog_on_reset ((GraphsSmoothenDialog*) self);
}

static AdwSpinRow*
graphs_smoothen_dialog_get_savgol_window (GraphsSmoothenDialog* self)
{
	AdwSpinRow* result;
	AdwSpinRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_savgol_window;
	result = _tmp0_;
	return result;
}

static AdwSpinRow*
graphs_smoothen_dialog_get_savgol_polynomial (GraphsSmoothenDialog* self)
{
	AdwSpinRow* result;
	AdwSpinRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_savgol_polynomial;
	result = _tmp0_;
	return result;
}

static AdwSpinRow*
graphs_smoothen_dialog_get_moving_average_box (GraphsSmoothenDialog* self)
{
	AdwSpinRow* result;
	AdwSpinRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_moving_average_box;
	result = _tmp0_;
	return result;
}

static GSettings*
graphs_smoothen_dialog_get_settings (GraphsSmoothenDialog* self)
{
	GSettings* result;
	GSettings* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_settings;
	result = _tmp0_;
	return result;
}

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

static void
graphs_smoothen_dialog_set_settings (GraphsSmoothenDialog* self,
                                     GSettings* value)
{
	GSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_settings);
	self->priv->_settings = _tmp0_;
}

static void
graphs_smoothen_dialog_class_init (GraphsSmoothenDialogClass * klass,
                                   gpointer klass_data)
{
	graphs_smoothen_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsSmoothenDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_smoothen_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_smoothen_dialog_set_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_smoothen_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/smoothen-settings.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "savgol_window", FALSE, GraphsSmoothenDialog_private_offset + G_STRUCT_OFFSET (GraphsSmoothenDialogPrivate, _savgol_window));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "savgol_polynomial", FALSE, GraphsSmoothenDialog_private_offset + G_STRUCT_OFFSET (GraphsSmoothenDialogPrivate, _savgol_polynomial));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "moving_average_box", FALSE, GraphsSmoothenDialog_private_offset + G_STRUCT_OFFSET (GraphsSmoothenDialogPrivate, _moving_average_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_reset", G_CALLBACK(_graphs_smoothen_dialog_on_reset_gtk_button_clicked));
}

static void
graphs_smoothen_dialog_instance_init (GraphsSmoothenDialog * self,
                                      gpointer klass)
{
	self->priv = graphs_smoothen_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_smoothen_dialog_finalize (GObject * obj)
{
	GraphsSmoothenDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_SMOOTHEN_DIALOG, GraphsSmoothenDialog);
	_g_object_unref0 (self->priv->_settings);
	G_OBJECT_CLASS (graphs_smoothen_dialog_parent_class)->finalize (obj);
}

/**
     * Smoothen settings dialog
     */
static GType
graphs_smoothen_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsSmoothenDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_smoothen_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsSmoothenDialog), 0, (GInstanceInitFunc) graphs_smoothen_dialog_instance_init, NULL };
	GType graphs_smoothen_dialog_type_id;
	graphs_smoothen_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "GraphsSmoothenDialog", &g_define_type_info, 0);
	GraphsSmoothenDialog_private_offset = g_type_add_instance_private (graphs_smoothen_dialog_type_id, sizeof (GraphsSmoothenDialogPrivate));
	return graphs_smoothen_dialog_type_id;
}

GType
graphs_smoothen_dialog_get_type (void)
{
	static volatile gsize graphs_smoothen_dialog_type_id__once = 0;
	if (g_once_init_enter (&graphs_smoothen_dialog_type_id__once)) {
		GType graphs_smoothen_dialog_type_id;
		graphs_smoothen_dialog_type_id = graphs_smoothen_dialog_get_type_once ();
		g_once_init_leave (&graphs_smoothen_dialog_type_id__once, graphs_smoothen_dialog_type_id);
	}
	return graphs_smoothen_dialog_type_id__once;
}

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

static void
_vala_graphs_smoothen_dialog_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	GraphsSmoothenDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_SMOOTHEN_DIALOG, GraphsSmoothenDialog);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

