/* 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 <glib-object.h>
#include <glib.h>
#include <gio/gio.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_SAVGOL_WINDOW_PROPERTY,
	GRAPHS_SMOOTHEN_DIALOG_SAVGOL_POLYNOMIAL_PROPERTY,
	GRAPHS_SMOOTHEN_DIALOG_MOVING_AVERAGE_BOX_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;
	GraphsApplication* _application;
};

static gint GraphsSmoothenDialog_private_offset;
static gpointer graphs_smoothen_dialog_parent_class = NULL;

static void graphs_smoothen_dialog_set_application (GraphsSmoothenDialog* self,
                                             GraphsApplication* value);
static void graphs_smoothen_dialog_on_reset (GraphsSmoothenDialog* self);
static GraphsApplication* graphs_smoothen_dialog_get_application (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,
                                  GraphsApplication* application)
{
	GraphsSmoothenDialog * self = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GraphsWindow* _tmp2_;
	GraphsWindow* _tmp3_;
	g_return_val_if_fail (application != NULL, NULL);
	self = (GraphsSmoothenDialog*) g_object_new (object_type, NULL);
	graphs_smoothen_dialog_set_application (self, application);
	_tmp0_ = graphs_application_get_settings_child (application, "actions/smoothen");
	_tmp1_ = _tmp0_;
	graphs_tools_bind_settings_to_widgets (_tmp1_, (GtkWidget*) self);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = graphs_application_get_window (application);
	_tmp3_ = _tmp2_;
	adw_dialog_present ((AdwDialog*) self, (GtkWidget*) _tmp3_);
	return self;
}

GraphsSmoothenDialog*
graphs_smoothen_dialog_new (GraphsApplication* application)
{
	return graphs_smoothen_dialog_construct (GRAPHS_TYPE_SMOOTHEN_DIALOG, application);
}

static void
graphs_smoothen_dialog_on_reset (GraphsSmoothenDialog* self)
{
	GSettings* settings = NULL;
	GraphsApplication* _tmp0_;
	GSettings* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_application;
	_tmp1_ = graphs_application_get_settings_child (_tmp0_, "actions/smoothen");
	settings = _tmp1_;
	graphs_tools_reset_settings (settings);
	_g_object_unref0 (settings);
}

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

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

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

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 GraphsApplication*
graphs_smoothen_dialog_get_application (GraphsSmoothenDialog* self)
{
	GraphsApplication* result;
	GraphsApplication* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_application;
	result = _tmp0_;
	return result;
}

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

static void
graphs_smoothen_dialog_set_application (GraphsSmoothenDialog* self,
                                        GraphsApplication* value)
{
	GraphsApplication* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_application);
	self->priv->_application = _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;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SMOOTHEN_DIALOG_SAVGOL_WINDOW_PROPERTY, graphs_smoothen_dialog_properties[GRAPHS_SMOOTHEN_DIALOG_SAVGOL_WINDOW_PROPERTY] = g_param_spec_object ("savgol-window", "savgol-window", "savgol-window", adw_spin_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SMOOTHEN_DIALOG_SAVGOL_POLYNOMIAL_PROPERTY, graphs_smoothen_dialog_properties[GRAPHS_SMOOTHEN_DIALOG_SAVGOL_POLYNOMIAL_PROPERTY] = g_param_spec_object ("savgol-polynomial", "savgol-polynomial", "savgol-polynomial", adw_spin_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_SMOOTHEN_DIALOG_MOVING_AVERAGE_BOX_PROPERTY, graphs_smoothen_dialog_properties[GRAPHS_SMOOTHEN_DIALOG_MOVING_AVERAGE_BOX_PROPERTY] = g_param_spec_object ("moving-average-box", "moving-average-box", "moving-average-box", adw_spin_row_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	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->_application);
	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) {
		case GRAPHS_SMOOTHEN_DIALOG_SAVGOL_WINDOW_PROPERTY:
		g_value_set_object (value, graphs_smoothen_dialog_get_savgol_window (self));
		break;
		case GRAPHS_SMOOTHEN_DIALOG_SAVGOL_POLYNOMIAL_PROPERTY:
		g_value_set_object (value, graphs_smoothen_dialog_get_savgol_polynomial (self));
		break;
		case GRAPHS_SMOOTHEN_DIALOG_MOVING_AVERAGE_BOX_PROPERTY:
		g_value_set_object (value, graphs_smoothen_dialog_get_moving_average_box (self));
		break;
		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;
}

