/* transform.c generated by valac 0.56.19, the Vala compiler
 * generated from transform.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 <gtk/gtk.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_TRANSFORM_DIALOG_0_PROPERTY,
	GRAPHS_TRANSFORM_DIALOG_NUM_PROPERTIES
};
static GParamSpec* graphs_transform_dialog_properties[GRAPHS_TRANSFORM_DIALOG_NUM_PROPERTIES];
enum  {
	GRAPHS_TRANSFORM_DIALOG_ACCEPT_SIGNAL,
	GRAPHS_TRANSFORM_DIALOG_NUM_SIGNALS
};
static guint graphs_transform_dialog_signals[GRAPHS_TRANSFORM_DIALOG_NUM_SIGNALS] = {0};

struct _GraphsTransformDialogPrivate {
	AdwEntryRow* _transform_x;
	AdwEntryRow* _transform_y;
	AdwSwitchRow* _discard;
};

static gint GraphsTransformDialog_private_offset;
static gpointer graphs_transform_dialog_parent_class = NULL;

static AdwEntryRow* graphs_transform_dialog_get_transform_x (GraphsTransformDialog* self);
static AdwEntryRow* graphs_transform_dialog_get_transform_y (GraphsTransformDialog* self);
static AdwSwitchRow* graphs_transform_dialog_get_discard (GraphsTransformDialog* self);
static void graphs_transform_dialog_on_accept (GraphsTransformDialog* self);
static void _graphs_transform_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self);
static void g_cclosure_user_marshal_VOID__STRING_STRING_BOOLEAN (GClosure * closure,
                                                          GValue * return_value,
                                                          guint n_param_values,
                                                          const GValue * param_values,
                                                          gpointer invocation_hint,
                                                          gpointer marshal_data);
static void graphs_transform_dialog_finalize (GObject * obj);
static GType graphs_transform_dialog_get_type_once (void);
static void _vala_graphs_transform_dialog_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_transform_dialog_get_instance_private (GraphsTransformDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsTransformDialog_private_offset);
}

GraphsTransformDialog*
graphs_transform_dialog_construct (GType object_type,
                                   GraphsWindow* window)
{
	GraphsTransformDialog * self = NULL;
	AdwEntryRow* _tmp0_;
	AdwEntryRow* _tmp1_;
	AdwSwitchRow* _tmp2_;
	GraphsCanvas* _tmp3_;
	GraphsCanvas* _tmp4_;
	GraphsMode _tmp5_;
	GraphsMode _tmp6_;
	g_return_val_if_fail (window != NULL, NULL);
	self = (GraphsTransformDialog*) g_object_new (object_type, NULL);
	_tmp0_ = self->priv->_transform_x;
	gtk_editable_set_text ((GtkEditable*) _tmp0_, "X");
	_tmp1_ = self->priv->_transform_y;
	gtk_editable_set_text ((GtkEditable*) _tmp1_, "Y");
	_tmp2_ = self->priv->_discard;
	_tmp3_ = graphs_window_get_canvas (window);
	_tmp4_ = _tmp3_;
	_tmp5_ = graphs_canvas_get_mode (_tmp4_);
	_tmp6_ = _tmp5_;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, _tmp6_ == 2);
	adw_dialog_present ((AdwDialog*) self, (GtkWidget*) window);
	return self;
}

GraphsTransformDialog*
graphs_transform_dialog_new (GraphsWindow* window)
{
	return graphs_transform_dialog_construct (GRAPHS_TYPE_TRANSFORM_DIALOG, window);
}

static void
graphs_transform_dialog_on_accept (GraphsTransformDialog* self)
{
	AdwEntryRow* _tmp0_;
	const gchar* _tmp1_;
	AdwEntryRow* _tmp2_;
	const gchar* _tmp3_;
	AdwSwitchRow* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_transform_x;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = self->priv->_transform_y;
	_tmp3_ = gtk_editable_get_text ((GtkEditable*) _tmp2_);
	_tmp4_ = self->priv->_discard;
	g_signal_emit (self, graphs_transform_dialog_signals[GRAPHS_TRANSFORM_DIALOG_ACCEPT_SIGNAL], 0, _tmp1_, _tmp3_, adw_switch_row_get_active (_tmp4_));
	adw_dialog_close ((AdwDialog*) self);
}

static void
_graphs_transform_dialog_on_accept_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self)
{
	graphs_transform_dialog_on_accept ((GraphsTransformDialog*) self);
}

static AdwEntryRow*
graphs_transform_dialog_get_transform_x (GraphsTransformDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_transform_x;
	result = _tmp0_;
	return result;
}

static AdwEntryRow*
graphs_transform_dialog_get_transform_y (GraphsTransformDialog* self)
{
	AdwEntryRow* result;
	AdwEntryRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_transform_y;
	result = _tmp0_;
	return result;
}

static AdwSwitchRow*
graphs_transform_dialog_get_discard (GraphsTransformDialog* self)
{
	AdwSwitchRow* result;
	AdwSwitchRow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_discard;
	result = _tmp0_;
	return result;
}

static void
g_cclosure_user_marshal_VOID__STRING_STRING_BOOLEAN (GClosure * closure,
                                                     GValue * return_value,
                                                     guint n_param_values,
                                                     const GValue * param_values,
                                                     gpointer invocation_hint,
                                                     gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__STRING_STRING_BOOLEAN) (gpointer data1, const char* arg_1, const char* arg_2, gboolean arg_3, gpointer data2);
	register GMarshalFunc_VOID__STRING_STRING_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__STRING_STRING_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_string (param_values + 2), g_value_get_boolean (param_values + 3), data2);
}

static void
graphs_transform_dialog_class_init (GraphsTransformDialogClass * klass,
                                    gpointer klass_data)
{
	graphs_transform_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsTransformDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_transform_dialog_get_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_transform_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/transform.ui");
	graphs_transform_dialog_signals[GRAPHS_TRANSFORM_DIALOG_ACCEPT_SIGNAL] = g_signal_new ("accept", GRAPHS_TYPE_TRANSFORM_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING_BOOLEAN, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transform_x", FALSE, GraphsTransformDialog_private_offset + G_STRUCT_OFFSET (GraphsTransformDialogPrivate, _transform_x));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transform_y", FALSE, GraphsTransformDialog_private_offset + G_STRUCT_OFFSET (GraphsTransformDialogPrivate, _transform_y));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "discard", FALSE, GraphsTransformDialog_private_offset + G_STRUCT_OFFSET (GraphsTransformDialogPrivate, _discard));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_accept", G_CALLBACK(_graphs_transform_dialog_on_accept_gtk_button_clicked));
}

static void
graphs_transform_dialog_instance_init (GraphsTransformDialog * self,
                                       gpointer klass)
{
	self->priv = graphs_transform_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_transform_dialog_finalize (GObject * obj)
{
	GraphsTransformDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_TRANSFORM_DIALOG, GraphsTransformDialog);
	G_OBJECT_CLASS (graphs_transform_dialog_parent_class)->finalize (obj);
}

/**
     * Transform dialog
     */
static GType
graphs_transform_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsTransformDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_transform_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsTransformDialog), 0, (GInstanceInitFunc) graphs_transform_dialog_instance_init, NULL };
	GType graphs_transform_dialog_type_id;
	graphs_transform_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "GraphsTransformDialog", &g_define_type_info, 0);
	GraphsTransformDialog_private_offset = g_type_add_instance_private (graphs_transform_dialog_type_id, sizeof (GraphsTransformDialogPrivate));
	return graphs_transform_dialog_type_id;
}

GType
graphs_transform_dialog_get_type (void)
{
	static volatile gsize graphs_transform_dialog_type_id__once = 0;
	if (g_once_init_enter (&graphs_transform_dialog_type_id__once)) {
		GType graphs_transform_dialog_type_id;
		graphs_transform_dialog_type_id = graphs_transform_dialog_get_type_once ();
		g_once_init_leave (&graphs_transform_dialog_type_id__once, graphs_transform_dialog_type_id);
	}
	return graphs_transform_dialog_type_id__once;
}

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

