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

/*
Copyright (C) 2013 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gee.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  {
	BIRD_FONT_POINT_SELECTION_0_PROPERTY,
	BIRD_FONT_POINT_SELECTION_NUM_PROPERTIES
};
static GParamSpec* bird_font_point_selection_properties[BIRD_FONT_POINT_SELECTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer bird_font_point_selection_parent_class = NULL;

static void bird_font_point_selection_finalize (GObject * obj);
static GType bird_font_point_selection_get_type_once (void);

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

BirdFontPointSelection*
bird_font_point_selection_construct (GType object_type,
                                     BirdFontEditPoint* ep,
                                     BirdFontPath* p)
{
	BirdFontPointSelection * self = NULL;
	BirdFontPath* _tmp0_;
	BirdFontEditPoint* _tmp1_;
	BirdFontEditPointHandle* _tmp2_;
	g_return_val_if_fail (ep != NULL, NULL);
	g_return_val_if_fail (p != NULL, NULL);
	self = (BirdFontPointSelection*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (p);
	_g_object_unref0 (self->path);
	self->path = _tmp0_;
	_tmp1_ = _g_object_ref0 (ep);
	_g_object_unref0 (self->point);
	self->point = _tmp1_;
	_tmp2_ = bird_font_edit_point_handle_new_empty ();
	_g_object_unref0 (self->handle);
	self->handle = _tmp2_;
	return self;
}

BirdFontPointSelection*
bird_font_point_selection_new (BirdFontEditPoint* ep,
                               BirdFontPath* p)
{
	return bird_font_point_selection_construct (BIRD_FONT_TYPE_POINT_SELECTION, ep, p);
}

BirdFontPointSelection*
bird_font_point_selection_construct_handle_selection (GType object_type,
                                                      BirdFontEditPointHandle* h,
                                                      BirdFontPath* p)
{
	BirdFontPointSelection * self = NULL;
	BirdFontPath* _tmp0_;
	BirdFontEditPoint* _tmp1_;
	BirdFontEditPointHandle* _tmp2_;
	g_return_val_if_fail (h != NULL, NULL);
	g_return_val_if_fail (p != NULL, NULL);
	self = (BirdFontPointSelection*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (p);
	_g_object_unref0 (self->path);
	self->path = _tmp0_;
	_tmp1_ = bird_font_edit_point_new ((gdouble) 0, (gdouble) 0, BIRD_FONT_POINT_TYPE_NONE);
	_g_object_unref0 (self->point);
	self->point = _tmp1_;
	_tmp2_ = _g_object_ref0 (h);
	_g_object_unref0 (self->handle);
	self->handle = _tmp2_;
	return self;
}

BirdFontPointSelection*
bird_font_point_selection_new_handle_selection (BirdFontEditPointHandle* h,
                                                BirdFontPath* p)
{
	return bird_font_point_selection_construct_handle_selection (BIRD_FONT_TYPE_POINT_SELECTION, h, p);
}

BirdFontPointSelection*
bird_font_point_selection_construct_empty (GType object_type)
{
	BirdFontPointSelection * self = NULL;
	BirdFontPath* _tmp0_;
	BirdFontEditPoint* _tmp1_;
	BirdFontEditPointHandle* _tmp2_;
	self = (BirdFontPointSelection*) g_object_new (object_type, NULL);
	_tmp0_ = bird_font_path_new ();
	_g_object_unref0 (self->path);
	self->path = _tmp0_;
	_tmp1_ = bird_font_edit_point_new ((gdouble) 0, (gdouble) 0, BIRD_FONT_POINT_TYPE_NONE);
	_g_object_unref0 (self->point);
	self->point = _tmp1_;
	_tmp2_ = bird_font_edit_point_handle_new_empty ();
	_g_object_unref0 (self->handle);
	self->handle = _tmp2_;
	return self;
}

BirdFontPointSelection*
bird_font_point_selection_new_empty (void)
{
	return bird_font_point_selection_construct_empty (BIRD_FONT_TYPE_POINT_SELECTION);
}

/** @return true if this point is the first point in the path. */
gboolean
bird_font_point_selection_is_first (BirdFontPointSelection* self)
{
	BirdFontPath* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	BirdFontPath* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	gpointer _tmp8_;
	BirdFontEditPoint* _tmp9_;
	BirdFontEditPoint* _tmp10_;
	gboolean _tmp11_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->path;
	_tmp1_ = bird_font_path_get_points (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	g_return_val_if_fail (_tmp4_ > 0, FALSE);
	_tmp5_ = self->path;
	_tmp6_ = bird_font_path_get_points (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, 0);
	_tmp9_ = (BirdFontEditPoint*) _tmp8_;
	_tmp10_ = self->point;
	_tmp11_ = _tmp9_ == _tmp10_;
	_g_object_unref0 (_tmp9_);
	result = _tmp11_;
	return result;
}

/** @return true if this point is the last point in the path. */
gboolean
bird_font_point_selection_is_last (BirdFontPointSelection* self)
{
	BirdFontPath* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	BirdFontPath* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	BirdFontPath* _tmp8_;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	gpointer _tmp13_;
	BirdFontEditPoint* _tmp14_;
	BirdFontEditPoint* _tmp15_;
	gboolean _tmp16_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->path;
	_tmp1_ = bird_font_path_get_points (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	g_return_val_if_fail (_tmp4_ > 0, FALSE);
	_tmp5_ = self->path;
	_tmp6_ = bird_font_path_get_points (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->path;
	_tmp9_ = bird_font_path_get_points (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _tmp12_ - 1);
	_tmp14_ = (BirdFontEditPoint*) _tmp13_;
	_tmp15_ = self->point;
	_tmp16_ = _tmp14_ == _tmp15_;
	_g_object_unref0 (_tmp14_);
	result = _tmp16_;
	return result;
}

gboolean
bird_font_point_selection_is_endpoint (BirdFontPointSelection* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (bird_font_point_selection_is_first (self)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = bird_font_point_selection_is_last (self);
	}
	result = _tmp0_;
	return result;
}

static void
bird_font_point_selection_class_init (BirdFontPointSelectionClass * klass,
                                      gpointer klass_data)
{
	bird_font_point_selection_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_point_selection_finalize;
}

static void
bird_font_point_selection_instance_init (BirdFontPointSelection * self,
                                         gpointer klass)
{
}

static void
bird_font_point_selection_finalize (GObject * obj)
{
	BirdFontPointSelection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_POINT_SELECTION, BirdFontPointSelection);
	_g_object_unref0 (self->handle);
	_g_object_unref0 (self->point);
	_g_object_unref0 (self->path);
	G_OBJECT_CLASS (bird_font_point_selection_parent_class)->finalize (obj);
}

/** One selected point and its path. */
static GType
bird_font_point_selection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontPointSelectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_point_selection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontPointSelection), 0, (GInstanceInitFunc) bird_font_point_selection_instance_init, NULL };
	GType bird_font_point_selection_type_id;
	bird_font_point_selection_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontPointSelection", &g_define_type_info, 0);
	return bird_font_point_selection_type_id;
}

GType
bird_font_point_selection_get_type (void)
{
	static volatile gsize bird_font_point_selection_type_id__once = 0;
	if (g_once_init_enter (&bird_font_point_selection_type_id__once)) {
		GType bird_font_point_selection_type_id;
		bird_font_point_selection_type_id = bird_font_point_selection_get_type_once ();
		g_once_init_leave (&bird_font_point_selection_type_id__once, bird_font_point_selection_type_id);
	}
	return bird_font_point_selection_type_id__once;
}

