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

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

#include "graphs.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <glib-object.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_CANVAS_0_PROPERTY,
	GRAPHS_CANVAS_MODE_PROPERTY,
	GRAPHS_CANVAS_MIN_SELECTED_PROPERTY,
	GRAPHS_CANVAS_MAX_SELECTED_PROPERTY,
	GRAPHS_CANVAS_NUM_PROPERTIES
};
static GParamSpec* graphs_canvas_properties[GRAPHS_CANVAS_NUM_PROPERTIES];
enum  {
	GRAPHS_CANVAS_EDIT_REQUEST_SIGNAL,
	GRAPHS_CANVAS_VIEW_CHANGED_SIGNAL,
	GRAPHS_CANVAS_NUM_SIGNALS
};
static guint graphs_canvas_signals[GRAPHS_CANVAS_NUM_SIGNALS] = {0};

struct _GraphsCanvasPrivate {
	GraphsMode _mode;
	gdouble _min_selected;
	gdouble _max_selected;
};

static gint GraphsCanvas_private_offset;
static gpointer graphs_canvas_parent_class = NULL;

static void graphs_canvas_finalize (GObject * obj);
static GType graphs_canvas_get_type_once (void);
static void _vala_graphs_canvas_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_graphs_canvas_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_canvas_get_instance_private (GraphsCanvas* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsCanvas_private_offset);
}

GraphsCanvas*
graphs_canvas_construct (GType object_type)
{
	GraphsCanvas * self = NULL;
	self = (GraphsCanvas*) g_object_new (object_type, NULL);
	return self;
}

GraphsCanvas*
graphs_canvas_new (void)
{
	return graphs_canvas_construct (GRAPHS_TYPE_CANVAS);
}

GraphsMode
graphs_canvas_get_mode (GraphsCanvas* self)
{
	GraphsMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_mode;
	return result;
}

void
graphs_canvas_set_mode (GraphsCanvas* self,
                        GraphsMode value)
{
	GraphsMode old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_canvas_get_mode (self);
	if (old_value != value) {
		self->priv->_mode = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_canvas_properties[GRAPHS_CANVAS_MODE_PROPERTY]);
	}
}

gdouble
graphs_canvas_get_min_selected (GraphsCanvas* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_min_selected;
	return result;
}

void
graphs_canvas_set_min_selected (GraphsCanvas* self,
                                gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_canvas_get_min_selected (self);
	if (old_value != value) {
		self->priv->_min_selected = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_canvas_properties[GRAPHS_CANVAS_MIN_SELECTED_PROPERTY]);
	}
}

gdouble
graphs_canvas_get_max_selected (GraphsCanvas* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_max_selected;
	return result;
}

void
graphs_canvas_set_max_selected (GraphsCanvas* self,
                                gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_canvas_get_max_selected (self);
	if (old_value != value) {
		self->priv->_max_selected = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_canvas_properties[GRAPHS_CANVAS_MAX_SELECTED_PROPERTY]);
	}
}

static void
graphs_canvas_class_init (GraphsCanvasClass * klass,
                          gpointer klass_data)
{
	graphs_canvas_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsCanvas_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_canvas_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_canvas_set_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_canvas_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_CANVAS_MODE_PROPERTY, graphs_canvas_properties[GRAPHS_CANVAS_MODE_PROPERTY] = g_param_spec_enum ("mode", "mode", "mode", GRAPHS_TYPE_MODE, GRAPHS_MODE_PAN, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_CANVAS_MIN_SELECTED_PROPERTY, graphs_canvas_properties[GRAPHS_CANVAS_MIN_SELECTED_PROPERTY] = g_param_spec_double ("min-selected", "min-selected", "min-selected", -G_MAXDOUBLE, G_MAXDOUBLE, (gdouble) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_CANVAS_MAX_SELECTED_PROPERTY, graphs_canvas_properties[GRAPHS_CANVAS_MAX_SELECTED_PROPERTY] = g_param_spec_double ("max-selected", "max-selected", "max-selected", -G_MAXDOUBLE, G_MAXDOUBLE, (gdouble) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	graphs_canvas_signals[GRAPHS_CANVAS_EDIT_REQUEST_SIGNAL] = g_signal_new ("edit-request", GRAPHS_TYPE_CANVAS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	graphs_canvas_signals[GRAPHS_CANVAS_VIEW_CHANGED_SIGNAL] = g_signal_new ("view-changed", GRAPHS_TYPE_CANVAS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
graphs_canvas_instance_init (GraphsCanvas * self,
                             gpointer klass)
{
	self->priv = graphs_canvas_get_instance_private (self);
	self->priv->_mode = GRAPHS_MODE_PAN;
	self->priv->_min_selected = (gdouble) 0;
	self->priv->_max_selected = (gdouble) 0;
}

static void
graphs_canvas_finalize (GObject * obj)
{
	GraphsCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_CANVAS, GraphsCanvas);
	G_OBJECT_CLASS (graphs_canvas_parent_class)->finalize (obj);
}

/**
     * Custom Canvas implementation.
     */
static GType
graphs_canvas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsCanvas), 0, (GInstanceInitFunc) graphs_canvas_instance_init, NULL };
	GType graphs_canvas_type_id;
	graphs_canvas_type_id = g_type_register_static (gtk_drawing_area_get_type (), "GraphsCanvas", &g_define_type_info, 0);
	GraphsCanvas_private_offset = g_type_add_instance_private (graphs_canvas_type_id, sizeof (GraphsCanvasPrivate));
	return graphs_canvas_type_id;
}

GType
graphs_canvas_get_type (void)
{
	static volatile gsize graphs_canvas_type_id__once = 0;
	if (g_once_init_enter (&graphs_canvas_type_id__once)) {
		GType graphs_canvas_type_id;
		graphs_canvas_type_id = graphs_canvas_get_type_once ();
		g_once_init_leave (&graphs_canvas_type_id__once, graphs_canvas_type_id);
	}
	return graphs_canvas_type_id__once;
}

static void
_vala_graphs_canvas_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	GraphsCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_CANVAS, GraphsCanvas);
	switch (property_id) {
		case GRAPHS_CANVAS_MODE_PROPERTY:
		g_value_set_enum (value, graphs_canvas_get_mode (self));
		break;
		case GRAPHS_CANVAS_MIN_SELECTED_PROPERTY:
		g_value_set_double (value, graphs_canvas_get_min_selected (self));
		break;
		case GRAPHS_CANVAS_MAX_SELECTED_PROPERTY:
		g_value_set_double (value, graphs_canvas_get_max_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_canvas_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	GraphsCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_CANVAS, GraphsCanvas);
	switch (property_id) {
		case GRAPHS_CANVAS_MODE_PROPERTY:
		graphs_canvas_set_mode (self, g_value_get_enum (value));
		break;
		case GRAPHS_CANVAS_MIN_SELECTED_PROPERTY:
		graphs_canvas_set_min_selected (self, g_value_get_double (value));
		break;
		case GRAPHS_CANVAS_MAX_SELECTED_PROPERTY:
		graphs_canvas_set_max_selected (self, g_value_get_double (value));
		break;
		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;
}

