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

/*
Copyright (C) 2012 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.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.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_TAB_0_PROPERTY,
	BIRD_FONT_TAB_NUM_PROPERTIES
};
static GParamSpec* bird_font_tab_properties[BIRD_FONT_TAB_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BirdFontTabPrivate {
	gboolean always_open;
	gdouble width;
	gchar* label;
	BirdFontFontDisplay* display;
	BirdFontGlyphCollection* glyph_collection;
};

static gint BirdFontTab_private_offset;
static gpointer bird_font_tab_parent_class = NULL;

static void bird_font_tab_finalize (GObject * obj);
static GType bird_font_tab_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_tab_get_instance_private (BirdFontTab* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontTab_private_offset);
}

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

BirdFontTab*
bird_font_tab_construct (GType object_type,
                         BirdFontFontDisplay* glyph,
                         gdouble tab_width,
                         gboolean always_open)
{
	BirdFontTab * self = NULL;
	BirdFontFontDisplay* _tmp0_;
	BirdFontFontDisplay* _tmp1_;
	gchar* _tmp2_;
	BirdFontGlyphCollection* _tmp3_;
	g_return_val_if_fail (glyph != NULL, NULL);
	self = (BirdFontTab*) g_object_new (object_type, NULL);
	self->priv->width = tab_width;
	_tmp0_ = _g_object_ref0 (glyph);
	_g_object_unref0 (self->priv->display);
	self->priv->display = _tmp0_;
	self->priv->always_open = always_open;
	_tmp1_ = self->priv->display;
	_tmp2_ = bird_font_font_display_get_label (_tmp1_);
	_g_free0 (self->priv->label);
	self->priv->label = _tmp2_;
	_tmp3_ = bird_font_glyph_collection_new_with_glyph ((gunichar) '\0', "");
	_g_object_unref0 (self->priv->glyph_collection);
	self->priv->glyph_collection = _tmp3_;
	return self;
}

BirdFontTab*
bird_font_tab_new (BirdFontFontDisplay* glyph,
                   gdouble tab_width,
                   gboolean always_open)
{
	return bird_font_tab_construct (BIRD_FONT_TYPE_TAB, glyph, tab_width, always_open);
}

gboolean
bird_font_tab_has_close_button (BirdFontTab* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = !self->priv->always_open;
	return result;
}

BirdFontGlyphCollection*
bird_font_tab_get_glyph_collection (BirdFontTab* self)
{
	BirdFontGlyphCollection* _tmp0_;
	BirdFontGlyphCollection* _tmp1_;
	BirdFontGlyphCollection* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->glyph_collection;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
bird_font_tab_set_glyph_collection (BirdFontTab* self,
                                    BirdFontGlyphCollection* gc)
{
	BirdFontGlyphCollection* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gc != NULL);
	_tmp0_ = _g_object_ref0 (gc);
	_g_object_unref0 (self->priv->glyph_collection);
	self->priv->glyph_collection = _tmp0_;
}

void
bird_font_tab_set_display (BirdFontTab* self,
                           BirdFontFontDisplay* fd)
{
	BirdFontFontDisplay* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (fd != NULL);
	_tmp0_ = _g_object_ref0 (fd);
	_g_object_unref0 (self->priv->display);
	self->priv->display = _tmp0_;
}

BirdFontFontDisplay*
bird_font_tab_get_display (BirdFontTab* self)
{
	BirdFontFontDisplay* _tmp0_;
	BirdFontFontDisplay* _tmp1_;
	BirdFontFontDisplay* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->display;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

gdouble
bird_font_tab_get_width (BirdFontTab* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->width;
	return result;
}

gchar*
bird_font_tab_get_label (BirdFontTab* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->label;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
bird_font_tab_class_init (BirdFontTabClass * klass,
                          gpointer klass_data)
{
	bird_font_tab_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontTab_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_tab_finalize;
}

static void
bird_font_tab_instance_init (BirdFontTab * self,
                             gpointer klass)
{
	self->priv = bird_font_tab_get_instance_private (self);
}

static void
bird_font_tab_finalize (GObject * obj)
{
	BirdFontTab * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TAB, BirdFontTab);
	_g_free0 (self->priv->label);
	_g_object_unref0 (self->priv->display);
	_g_object_unref0 (self->priv->glyph_collection);
	G_OBJECT_CLASS (bird_font_tab_parent_class)->finalize (obj);
}

static GType
bird_font_tab_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontTabClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_tab_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontTab), 0, (GInstanceInitFunc) bird_font_tab_instance_init, NULL };
	GType bird_font_tab_type_id;
	bird_font_tab_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontTab", &g_define_type_info, 0);
	BirdFontTab_private_offset = g_type_add_instance_private (bird_font_tab_type_id, sizeof (BirdFontTabPrivate));
	return bird_font_tab_type_id;
}

GType
bird_font_tab_get_type (void)
{
	static volatile gsize bird_font_tab_type_id__once = 0;
	if (g_once_init_enter (&bird_font_tab_type_id__once)) {
		GType bird_font_tab_type_id;
		bird_font_tab_type_id = bird_font_tab_get_type_once ();
		g_once_init_leave (&bird_font_tab_type_id__once, bird_font_tab_type_id);
	}
	return bird_font_tab_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;
}

