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

/*
Copyright (C) 2013 2015 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 <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.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_TOOL_COLLECTION_0_PROPERTY,
	BIRD_FONT_TOOL_COLLECTION_NUM_PROPERTIES
};
static GParamSpec* bird_font_tool_collection_properties[BIRD_FONT_TOOL_COLLECTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BirdFontToolCollectionPrivate {
	BirdFontTool* current_tool;
};

static gint BirdFontToolCollection_private_offset;
static gpointer bird_font_tool_collection_parent_class = NULL;

static GeeArrayList* bird_font_tool_collection_real_get_expanders (BirdFontToolCollection* self);
static GeeArrayList* bird_font_tool_collection_real_get_displays (BirdFontToolCollection* self);
static void bird_font_tool_collection_real_selected (BirdFontToolCollection* self);
static void bird_font_tool_collection_real_reset_selection (BirdFontToolCollection* self,
                                                     BirdFontTool* current_tool);
static void bird_font_tool_collection_finalize (GObject * obj);
static GType bird_font_tool_collection_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_tool_collection_get_instance_private (BirdFontToolCollection* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontToolCollection_private_offset);
}

static GeeArrayList*
bird_font_tool_collection_real_get_expanders (BirdFontToolCollection* self)
{
	g_critical ("Type `%s' does not implement abstract method `bird_font_tool_collection_get_expanders'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

GeeArrayList*
bird_font_tool_collection_get_expanders (BirdFontToolCollection* self)
{
	BirdFontToolCollectionClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = BIRD_FONT_TOOL_COLLECTION_GET_CLASS (self);
	if (_klass_->get_expanders) {
		return _klass_->get_expanders (self);
	}
	return NULL;
}

static GeeArrayList*
bird_font_tool_collection_real_get_displays (BirdFontToolCollection* self)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* result;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	result = _tmp0_;
	return result;
}

GeeArrayList*
bird_font_tool_collection_get_displays (BirdFontToolCollection* self)
{
	BirdFontToolCollectionClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = BIRD_FONT_TOOL_COLLECTION_GET_CLASS (self);
	if (_klass_->get_displays) {
		return _klass_->get_displays (self);
	}
	return NULL;
}

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

void
bird_font_tool_collection_set_current_tool (BirdFontToolCollection* self,
                                            BirdFontTool* tool)
{
	BirdFontTool* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tool != NULL);
	_tmp0_ = _g_object_ref0 (tool);
	_g_object_unref0 (self->priv->current_tool);
	self->priv->current_tool = _tmp0_;
}

BirdFontTool*
bird_font_tool_collection_get_current_tool (BirdFontToolCollection* self)
{
	BirdFontTool* _tmp0_;
	BirdFontTool* _tmp1_;
	BirdFontTool* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->current_tool;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
bird_font_tool_collection_cache (BirdFontToolCollection* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _e_list = NULL;
		GeeArrayList* _tmp0_;
		gint _e_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _e_index = 0;
		_tmp0_ = bird_font_tool_collection_get_expanders (self);
		_e_list = _tmp0_;
		_tmp1_ = _e_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_e_size = _tmp3_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontExpander* e = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontExpander* _tmp8_;
			_e_index = _e_index + 1;
			_tmp4_ = _e_index;
			_tmp5_ = _e_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _e_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _e_index);
			e = (BirdFontExpander*) _tmp7_;
			_tmp8_ = e;
			bird_font_expander_cache (_tmp8_);
			_g_object_unref0 (e);
		}
		_g_object_unref0 (_e_list);
	}
}

void
bird_font_tool_collection_clear_cache (BirdFontToolCollection* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _e_list = NULL;
		GeeArrayList* _tmp0_;
		gint _e_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _e_index = 0;
		_tmp0_ = bird_font_tool_collection_get_expanders (self);
		_e_list = _tmp0_;
		_tmp1_ = _e_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_e_size = _tmp3_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontExpander* e = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontExpander* _tmp8_;
			_e_index = _e_index + 1;
			_tmp4_ = _e_index;
			_tmp5_ = _e_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _e_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _e_index);
			e = (BirdFontExpander*) _tmp7_;
			_tmp8_ = e;
			bird_font_expander_clear_cache (_tmp8_);
			_g_object_unref0 (e);
		}
		_g_object_unref0 (_e_list);
	}
}

void
bird_font_tool_collection_redraw (BirdFontToolCollection* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _e_list = NULL;
		GeeArrayList* _tmp0_;
		gint _e_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _e_index = 0;
		_tmp0_ = bird_font_tool_collection_get_expanders (self);
		_e_list = _tmp0_;
		_tmp1_ = _e_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_e_size = _tmp3_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontExpander* e = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontExpander* _tmp8_;
			_e_index = _e_index + 1;
			_tmp4_ = _e_index;
			_tmp5_ = _e_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _e_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _e_index);
			e = (BirdFontExpander*) _tmp7_;
			_tmp8_ = e;
			bird_font_expander_redraw (_tmp8_);
			_g_object_unref0 (e);
		}
		_g_object_unref0 (_e_list);
	}
}

static void
bird_font_tool_collection_real_selected (BirdFontToolCollection* self)
{
	BirdFontTool* _tmp0_;
	BirdFontTool* _tmp1_;
	_tmp0_ = self->priv->current_tool;
	bird_font_tool_collection_reset_selection (self, _tmp0_);
	_tmp1_ = self->priv->current_tool;
	bird_font_tool_set_selected (_tmp1_, TRUE);
}

void
bird_font_tool_collection_selected (BirdFontToolCollection* self)
{
	BirdFontToolCollectionClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_TOOL_COLLECTION_GET_CLASS (self);
	if (_klass_->selected) {
		_klass_->selected (self);
	}
}

static void
bird_font_tool_collection_real_reset_selection (BirdFontToolCollection* self,
                                                BirdFontTool* current_tool)
{
	g_return_if_fail (current_tool != NULL);
}

void
bird_font_tool_collection_reset_selection (BirdFontToolCollection* self,
                                           BirdFontTool* current_tool)
{
	BirdFontToolCollectionClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BIRD_FONT_TOOL_COLLECTION_GET_CLASS (self);
	if (_klass_->reset_selection) {
		_klass_->reset_selection (self, current_tool);
	}
}

BirdFontToolCollection*
bird_font_tool_collection_construct (GType object_type)
{
	BirdFontToolCollection * self = NULL;
	self = (BirdFontToolCollection*) g_object_new (object_type, NULL);
	return self;
}

static void
bird_font_tool_collection_class_init (BirdFontToolCollectionClass * klass,
                                      gpointer klass_data)
{
	bird_font_tool_collection_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontToolCollection_private_offset);
	((BirdFontToolCollectionClass *) klass)->get_expanders = (GeeArrayList* (*) (BirdFontToolCollection*)) bird_font_tool_collection_real_get_expanders;
	((BirdFontToolCollectionClass *) klass)->get_displays = (GeeArrayList* (*) (BirdFontToolCollection*)) bird_font_tool_collection_real_get_displays;
	((BirdFontToolCollectionClass *) klass)->selected = (void (*) (BirdFontToolCollection*)) bird_font_tool_collection_real_selected;
	((BirdFontToolCollectionClass *) klass)->reset_selection = (void (*) (BirdFontToolCollection*, BirdFontTool*)) bird_font_tool_collection_real_reset_selection;
	G_OBJECT_CLASS (klass)->finalize = bird_font_tool_collection_finalize;
}

static void
bird_font_tool_collection_instance_init (BirdFontToolCollection * self,
                                         gpointer klass)
{
	BirdFontTool* _tmp0_;
	self->priv = bird_font_tool_collection_get_instance_private (self);
	self->scroll = (gdouble) 0;
	self->content_height = (gdouble) 0;
	_tmp0_ = bird_font_tool_new ("no_icon", "");
	self->priv->current_tool = _tmp0_;
}

static void
bird_font_tool_collection_finalize (GObject * obj)
{
	BirdFontToolCollection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TOOL_COLLECTION, BirdFontToolCollection);
	_g_object_unref0 (self->priv->current_tool);
	G_OBJECT_CLASS (bird_font_tool_collection_parent_class)->finalize (obj);
}

static GType
bird_font_tool_collection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontToolCollectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_tool_collection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontToolCollection), 0, (GInstanceInitFunc) bird_font_tool_collection_instance_init, NULL };
	GType bird_font_tool_collection_type_id;
	bird_font_tool_collection_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontToolCollection", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	BirdFontToolCollection_private_offset = g_type_add_instance_private (bird_font_tool_collection_type_id, sizeof (BirdFontToolCollectionPrivate));
	return bird_font_tool_collection_type_id;
}

GType
bird_font_tool_collection_get_type (void)
{
	static volatile gsize bird_font_tool_collection_type_id__once = 0;
	if (g_once_init_enter (&bird_font_tool_collection_type_id__once)) {
		GType bird_font_tool_collection_type_id;
		bird_font_tool_collection_type_id = bird_font_tool_collection_get_type_once ();
		g_once_init_leave (&bird_font_tool_collection_type_id__once, bird_font_tool_collection_type_id);
	}
	return bird_font_tool_collection_type_id__once;
}

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

