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

/*
 * Copyright (c) 2021-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_ui.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <gtk/gtk.h>
#include <errno.h>
#include <graphene-gobject.h>
#include <gdk/gdk.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  {
	FT_MONOSPACE_LABEL_0_PROPERTY,
	FT_MONOSPACE_LABEL_TEXT_PROPERTY,
	FT_MONOSPACE_LABEL_XALIGN_PROPERTY,
	FT_MONOSPACE_LABEL_YALIGN_PROPERTY,
	FT_MONOSPACE_LABEL_SCALE_PROPERTY,
	FT_MONOSPACE_LABEL_NUM_PROPERTIES
};
static GParamSpec* ft_monospace_label_properties[FT_MONOSPACE_LABEL_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)))
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtMonospaceLabelPrivate {
	gchar* _text;
	gfloat _xalign;
	gfloat _yalign;
	gdouble _scale;
	PangoLayout* layout;
	gint layout_x;
	gint layout_y;
	gint layout_width;
	gint layout_height;
	gint layout_baseline;
};

static gint FtMonospaceLabel_private_offset;
static gpointer ft_monospace_label_parent_class = NULL;

VALA_EXTERN PangoLayout* ft_monospace_label_create_pango_layout_with_scale (FtMonospaceLabel* self,
                                                                const gchar* text,
                                                                gdouble scale);
static void ft_monospace_label_measure_pango_layout (FtMonospaceLabel* self,
                                              PangoLayout* layout,
                                              gint* width,
                                              gint* height,
                                              gint* baseline);
static void ft_monospace_label_ensure_layout (FtMonospaceLabel* self);
static void ft_monospace_label_clear_layout (FtMonospaceLabel* self);
static void ft_monospace_label_real_css_changed (GtkWidget* base,
                                          GtkCssStyleChange* change);
static GtkSizeRequestMode ft_monospace_label_real_get_request_mode (GtkWidget* base);
static void ft_monospace_label_real_measure (GtkWidget* base,
                                      GtkOrientation orientation,
                                      gint for_size,
                                      gint* minimum,
                                      gint* natural,
                                      gint* minimum_baseline,
                                      gint* natural_baseline);
static void ft_monospace_label_real_size_allocate (GtkWidget* base,
                                            gint width,
                                            gint height,
                                            gint baseline);
static void ft_monospace_label_real_snapshot (GtkWidget* base,
                                       GtkSnapshot* snapshot);
static gboolean ft_monospace_label_real_focus (GtkWidget* base,
                                        GtkDirectionType direction);
static gboolean ft_monospace_label_real_grab_focus (GtkWidget* base);
static void ft_monospace_label_real_unroot (GtkWidget* base);
static GObject * ft_monospace_label_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void ft_monospace_label_finalize (GObject * obj);
static GType ft_monospace_label_get_type_once (void);
static void _vala_ft_monospace_label_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_ft_monospace_label_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
ft_monospace_label_get_instance_private (FtMonospaceLabel* self)
{
	return G_STRUCT_MEMBER_P (self, FtMonospaceLabel_private_offset);
}

PangoLayout*
ft_monospace_label_create_pango_layout_with_scale (FtMonospaceLabel* self,
                                                   const gchar* text,
                                                   gdouble scale)
{
	PangoContext* context = NULL;
	PangoContext* _tmp0_;
	PangoAttrList* attributes = NULL;
	PangoAttrList* _tmp1_;
	PangoAttribute* _tmp2_;
	PangoAttrFontFeatures* _tmp3_;
	PangoLayout* layout = NULL;
	PangoLayout* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	PangoLayout* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = gtk_widget_create_pango_context ((GtkWidget*) self);
	context = _tmp0_;
	_tmp1_ = pango_attr_list_new ();
	attributes = _tmp1_;
	_tmp2_ = pango_attr_scale_new (scale);
	pango_attr_list_insert (attributes, _tmp2_);
	_tmp3_ = (PangoAttrFontFeatures*) pango_attr_font_features_new ("tnum");
	pango_attr_list_insert (attributes, (PangoAttribute*) _tmp3_);
	_tmp4_ = pango_layout_new (context);
	layout = _tmp4_;
	pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
	pango_layout_set_attributes (layout, attributes);
	_tmp5_ = strlen (text);
	_tmp6_ = _tmp5_;
	pango_layout_set_text (layout, text, _tmp6_);
	result = layout;
	_pango_attr_list_unref0 (attributes);
	_g_object_unref0 (context);
	return result;
}

static gboolean
int_try_parse (const gchar* str,
               gint* _result_,
               const gchar** unparsed,
               guint _base)
{
	gint _vala__result_ = 0;
	const gchar* _vala_unparsed = NULL;
	gchar* endptr = NULL;
	glong long_result = 0L;
	gchar* _tmp0_ = NULL;
	glong _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	glong _tmp6_;
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	errno = 0;
	_tmp1_ = strtol (str, &_tmp0_, (gint) _base);
	endptr = _tmp0_;
	long_result = _tmp1_;
	_tmp2_ = endptr;
	_tmp3_ = strlen (str);
	_tmp4_ = _tmp3_;
	if (_tmp2_ == (((gchar*) str) + _tmp4_)) {
		_vala_unparsed = "";
	} else {
		gchar* _tmp5_;
		_tmp5_ = endptr;
		_vala_unparsed = (const gchar*) _tmp5_;
	}
	_tmp6_ = long_result;
	if ((((glong) G_MININT) <= _tmp6_) && (_tmp6_ <= ((glong) G_MAXINT))) {
		gboolean _tmp7_ = FALSE;
		gboolean _tmp8_ = FALSE;
		_vala__result_ = (gint) long_result;
		if (errno != ERANGE) {
			_tmp8_ = errno != EINVAL;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			const gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = _vala_unparsed;
			_tmp10_ = endptr;
			_tmp7_ = _tmp9_ != _tmp10_;
		} else {
			_tmp7_ = FALSE;
		}
		result = _tmp7_;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	} else {
		_vala__result_ = G_MAXINT;
		result = FALSE;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	}
}

static void
ft_monospace_label_measure_pango_layout (FtMonospaceLabel* self,
                                         PangoLayout* layout,
                                         gint* width,
                                         gint* height,
                                         gint* baseline)
{
	gint _vala_width = 0;
	gint _vala_height = 0;
	gint _vala_baseline = 0;
	gchar* text = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean is_numeric = FALSE;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (layout != NULL);
	_tmp0_ = pango_layout_get_text (layout);
	_tmp1_ = g_strdup (_tmp0_);
	text = _tmp1_;
	_tmp2_ = text;
	is_numeric = int_try_parse (_tmp2_, NULL, NULL, (guint) 0);
	_vala_baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;
	if (is_numeric) {
		gchar* reference_text = NULL;
		const gchar* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gchar* _tmp6_;
		PangoLayout* reference_layout = NULL;
		PangoLayout* _tmp7_;
		PangoLayout* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		PangoLayout* _tmp13_;
		gint _tmp14_ = 0;
		gint _tmp15_ = 0;
		_tmp3_ = text;
		_tmp4_ = strlen (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_strnfill ((gsize) _tmp5_, '0');
		reference_text = _tmp6_;
		_tmp7_ = pango_layout_copy (layout);
		reference_layout = _tmp7_;
		_tmp8_ = reference_layout;
		_tmp9_ = reference_text;
		_tmp10_ = reference_text;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		pango_layout_set_text (_tmp8_, _tmp9_, _tmp12_);
		_tmp13_ = reference_layout;
		pango_layout_get_pixel_size (_tmp13_, &_tmp14_, &_tmp15_);
		_vala_width = _tmp14_;
		_vala_height = _tmp15_;
		_g_object_unref0 (reference_layout);
		_g_free0 (reference_text);
	} else {
		gint _tmp16_ = 0;
		gint _tmp17_ = 0;
		pango_layout_get_pixel_size (layout, &_tmp16_, &_tmp17_);
		_vala_width = _tmp16_;
		_vala_height = _tmp17_;
	}
	_g_free0 (text);
	if (width) {
		*width = _vala_width;
	}
	if (height) {
		*height = _vala_height;
	}
	if (baseline) {
		*baseline = _vala_baseline;
	}
}

static void
ft_monospace_label_ensure_layout (FtMonospaceLabel* self)
{
	PangoLayout* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->layout;
	if (_tmp0_ == NULL) {
		const gchar* _tmp1_;
		PangoLayout* _tmp2_;
		PangoLayout* _tmp3_;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		_tmp1_ = self->priv->_text;
		_tmp2_ = ft_monospace_label_create_pango_layout_with_scale (self, _tmp1_, self->priv->_scale);
		_g_object_unref0 (self->priv->layout);
		self->priv->layout = _tmp2_;
		_tmp3_ = self->priv->layout;
		ft_monospace_label_measure_pango_layout (self, _tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
		self->priv->layout_width = _tmp4_;
		self->priv->layout_height = _tmp5_;
		self->priv->layout_baseline = _tmp6_;
	}
}

static void
ft_monospace_label_clear_layout (FtMonospaceLabel* self)
{
	g_return_if_fail (self != NULL);
	_g_object_unref0 (self->priv->layout);
	self->priv->layout = NULL;
	self->priv->layout_x = 0;
	self->priv->layout_y = 0;
	self->priv->layout_width = 0;
	self->priv->layout_height = 0;
	self->priv->layout_baseline = -1;
}

static void
ft_monospace_label_real_css_changed (GtkWidget* base,
                                     GtkCssStyleChange* change)
{
	FtMonospaceLabel * self;
	self = (FtMonospaceLabel*) base;
	g_return_if_fail (change != NULL);
	GTK_WIDGET_CLASS (ft_monospace_label_parent_class)->css_changed (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), change);
	ft_monospace_label_clear_layout (self);
	gtk_widget_queue_resize ((GtkWidget*) self);
}

static GtkSizeRequestMode
ft_monospace_label_real_get_request_mode (GtkWidget* base)
{
	FtMonospaceLabel * self;
	GtkSizeRequestMode result;
	self = (FtMonospaceLabel*) base;
	result = GTK_SIZE_REQUEST_CONSTANT_SIZE;
	return result;
}

static void
ft_monospace_label_real_measure (GtkWidget* base,
                                 GtkOrientation orientation,
                                 gint for_size,
                                 gint* minimum,
                                 gint* natural,
                                 gint* minimum_baseline,
                                 gint* natural_baseline)
{
	FtMonospaceLabel * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	self = (FtMonospaceLabel*) base;
	ft_monospace_label_ensure_layout (self);
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		_vala_minimum = self->priv->layout_width;
		_vala_natural = _vala_minimum;
		_vala_minimum_baseline = -1;
		_vala_natural_baseline = -1;
	} else {
		_vala_minimum = self->priv->layout_height;
		_vala_natural = _vala_minimum;
		_vala_minimum_baseline = self->priv->layout_baseline;
		_vala_natural_baseline = self->priv->layout_baseline;
	}
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static void
ft_monospace_label_real_size_allocate (GtkWidget* base,
                                       gint width,
                                       gint height,
                                       gint baseline)
{
	FtMonospaceLabel * self;
	gint _tmp0_ = 0;
	self = (FtMonospaceLabel*) base;
	ft_monospace_label_ensure_layout (self);
	self->priv->layout_x = (gint) floorf (((gfloat) (width - self->priv->layout_width)) * self->priv->_xalign);
	if (baseline != -1) {
		_tmp0_ = baseline - self->priv->layout_baseline;
	} else {
		_tmp0_ = (gint) floorf (((gfloat) (height - self->priv->layout_height)) * self->priv->_yalign);
	}
	self->priv->layout_y = _tmp0_;
	if (gtk_widget_get_direction ((GtkWidget*) self) == GTK_TEXT_DIR_RTL) {
		self->priv->layout_x = width - self->priv->layout_x;
	}
}

static void
ft_monospace_label_real_snapshot (GtkWidget* base,
                                  GtkSnapshot* snapshot)
{
	FtMonospaceLabel * self;
	PangoLayout* _tmp0_;
	graphene_point_t origin = {0};
	graphene_point_t _tmp1_ = {0};
	graphene_point_t _tmp2_;
	PangoLayout* _tmp3_;
	GdkRGBA _tmp4_ = {0};
	self = (FtMonospaceLabel*) base;
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = self->priv->layout;
	_vala_return_if_fail (_tmp0_ != NULL, "this.layout != null");
	memset (&_tmp1_, 0, sizeof (graphene_point_t));
	_tmp1_.x = (gfloat) self->priv->layout_x;
	_tmp1_.y = (gfloat) self->priv->layout_y;
	origin = _tmp1_;
	_tmp2_ = origin;
	gtk_snapshot_translate (snapshot, &_tmp2_);
	_tmp3_ = self->priv->layout;
	gtk_widget_get_color ((GtkWidget*) self, &_tmp4_);
	gtk_snapshot_append_layout (snapshot, _tmp3_, &_tmp4_);
}

static gboolean
ft_monospace_label_real_focus (GtkWidget* base,
                               GtkDirectionType direction)
{
	FtMonospaceLabel * self;
	gboolean result;
	self = (FtMonospaceLabel*) base;
	result = FALSE;
	return result;
}

static gboolean
ft_monospace_label_real_grab_focus (GtkWidget* base)
{
	FtMonospaceLabel * self;
	gboolean result;
	self = (FtMonospaceLabel*) base;
	result = FALSE;
	return result;
}

static void
ft_monospace_label_real_unroot (GtkWidget* base)
{
	FtMonospaceLabel * self;
	self = (FtMonospaceLabel*) base;
	GTK_WIDGET_CLASS (ft_monospace_label_parent_class)->unroot (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	ft_monospace_label_clear_layout (self);
}

FtMonospaceLabel*
ft_monospace_label_construct (GType object_type)
{
	FtMonospaceLabel * self = NULL;
	self = (FtMonospaceLabel*) g_object_new (object_type, NULL);
	return self;
}

FtMonospaceLabel*
ft_monospace_label_new (void)
{
	return ft_monospace_label_construct (FT_TYPE_MONOSPACE_LABEL);
}

const gchar*
ft_monospace_label_get_text (FtMonospaceLabel* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}

void
ft_monospace_label_set_text (FtMonospaceLabel* self,
                             const gchar* value)
{
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	const gchar* _tmp2_;
	gint previous_text_length = 0;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	PangoLayout* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_text;
	if (g_strcmp0 (_tmp0_, value) == 0) {
		return;
	}
	_tmp2_ = self->priv->_text;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		_tmp3_ = self->priv->_text;
		_tmp4_ = strlen (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp1_ = _tmp5_;
	} else {
		_tmp1_ = 0;
	}
	previous_text_length = _tmp1_;
	_tmp6_ = g_strdup (value);
	_g_free0 (self->priv->_text);
	self->priv->_text = _tmp6_;
	_tmp8_ = self->priv->layout;
	if (_tmp8_ != NULL) {
		gint _tmp9_;
		gint _tmp10_;
		_tmp9_ = strlen (value);
		_tmp10_ = _tmp9_;
		_tmp7_ = previous_text_length == _tmp10_;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		PangoLayout* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp11_ = self->priv->layout;
		_tmp12_ = strlen (value);
		_tmp13_ = _tmp12_;
		pango_layout_set_text (_tmp11_, value, _tmp13_);
		gtk_widget_queue_draw ((GtkWidget*) self);
	} else {
		ft_monospace_label_clear_layout (self);
		gtk_widget_queue_resize ((GtkWidget*) self);
	}
	g_object_notify_by_pspec ((GObject *) self, ft_monospace_label_properties[FT_MONOSPACE_LABEL_TEXT_PROPERTY]);
}

gfloat
ft_monospace_label_get_xalign (FtMonospaceLabel* self)
{
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	result = self->priv->_xalign;
	return result;
}

void
ft_monospace_label_set_xalign (FtMonospaceLabel* self,
                               gfloat value)
{
	g_return_if_fail (self != NULL);
	self->priv->_xalign = value;
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_monospace_label_properties[FT_MONOSPACE_LABEL_XALIGN_PROPERTY]);
}

gfloat
ft_monospace_label_get_yalign (FtMonospaceLabel* self)
{
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	result = self->priv->_yalign;
	return result;
}

void
ft_monospace_label_set_yalign (FtMonospaceLabel* self,
                               gfloat value)
{
	g_return_if_fail (self != NULL);
	self->priv->_yalign = value;
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_monospace_label_properties[FT_MONOSPACE_LABEL_YALIGN_PROPERTY]);
}

gdouble
ft_monospace_label_get_scale (FtMonospaceLabel* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_scale;
	return result;
}

void
ft_monospace_label_set_scale (FtMonospaceLabel* self,
                              gdouble value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_scale == value) {
		return;
	}
	self->priv->_scale = value;
	ft_monospace_label_clear_layout (self);
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_monospace_label_properties[FT_MONOSPACE_LABEL_SCALE_PROPERTY]);
}

static GObject *
ft_monospace_label_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtMonospaceLabel * self;
	gchar* _tmp0_;
	parent_class = G_OBJECT_CLASS (ft_monospace_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_MONOSPACE_LABEL, FtMonospaceLabel);
	g_object_set ((GtkAccessible*) self, "accessible-role", GTK_ACCESSIBLE_ROLE_LABEL, NULL);
	_tmp0_ = g_strdup ("");
	_g_free0 (self->priv->_text);
	self->priv->_text = _tmp0_;
	_g_object_unref0 (self->priv->layout);
	self->priv->layout = NULL;
	return obj;
}

static void
ft_monospace_label_class_init (FtMonospaceLabelClass * klass,
                               gpointer klass_data)
{
	ft_monospace_label_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtMonospaceLabel_private_offset);
	((GtkWidgetClass *) klass)->css_changed = (void (*) (GtkWidget*, GtkCssStyleChange*)) ft_monospace_label_real_css_changed;
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) ft_monospace_label_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) ft_monospace_label_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) ft_monospace_label_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) ft_monospace_label_real_snapshot;
	((GtkWidgetClass *) klass)->focus = (gboolean (*) (GtkWidget*, GtkDirectionType)) ft_monospace_label_real_focus;
	((GtkWidgetClass *) klass)->grab_focus = (gboolean (*) (GtkWidget*)) ft_monospace_label_real_grab_focus;
	((GtkWidgetClass *) klass)->unroot = (void (*) (GtkWidget*)) ft_monospace_label_real_unroot;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_monospace_label_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_monospace_label_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_monospace_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_monospace_label_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONOSPACE_LABEL_TEXT_PROPERTY, ft_monospace_label_properties[FT_MONOSPACE_LABEL_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONOSPACE_LABEL_XALIGN_PROPERTY, ft_monospace_label_properties[FT_MONOSPACE_LABEL_XALIGN_PROPERTY] = g_param_spec_float ("xalign", "xalign", "xalign", -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONOSPACE_LABEL_YALIGN_PROPERTY, ft_monospace_label_properties[FT_MONOSPACE_LABEL_YALIGN_PROPERTY] = g_param_spec_float ("yalign", "yalign", "yalign", -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONOSPACE_LABEL_SCALE_PROPERTY, ft_monospace_label_properties[FT_MONOSPACE_LABEL_SCALE_PROPERTY] = g_param_spec_double ("scale", "scale", "scale", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "label");
}

static void
ft_monospace_label_instance_init (FtMonospaceLabel * self,
                                  gpointer klass)
{
	self->priv = ft_monospace_label_get_instance_private (self);
	self->priv->_text = NULL;
	self->priv->_xalign = 0.5f;
	self->priv->_yalign = 0.5f;
	self->priv->_scale = 1.0;
	self->priv->layout = NULL;
	self->priv->layout_x = 0;
	self->priv->layout_y = 0;
	self->priv->layout_width = 0;
	self->priv->layout_height = 0;
	self->priv->layout_baseline = -1;
}

static void
ft_monospace_label_finalize (GObject * obj)
{
	FtMonospaceLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_MONOSPACE_LABEL, FtMonospaceLabel);
	_g_free0 (self->priv->_text);
	_g_object_unref0 (self->priv->layout);
	G_OBJECT_CLASS (ft_monospace_label_parent_class)->finalize (obj);
}

/**
     * Optimized version of Gtk.Label that doesn't trigger size allocation on text changes.
     * It also simplifies scaling and uses monospace width for digits.
     */
static GType
ft_monospace_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtMonospaceLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_monospace_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtMonospaceLabel), 0, (GInstanceInitFunc) ft_monospace_label_instance_init, NULL };
	GType ft_monospace_label_type_id;
	ft_monospace_label_type_id = g_type_register_static (gtk_widget_get_type (), "FtMonospaceLabel", &g_define_type_info, 0);
	FtMonospaceLabel_private_offset = g_type_add_instance_private (ft_monospace_label_type_id, sizeof (FtMonospaceLabelPrivate));
	return ft_monospace_label_type_id;
}

GType
ft_monospace_label_get_type (void)
{
	static volatile gsize ft_monospace_label_type_id__once = 0;
	if (g_once_init_enter (&ft_monospace_label_type_id__once)) {
		GType ft_monospace_label_type_id;
		ft_monospace_label_type_id = ft_monospace_label_get_type_once ();
		g_once_init_leave (&ft_monospace_label_type_id__once, ft_monospace_label_type_id);
	}
	return ft_monospace_label_type_id__once;
}

static void
_vala_ft_monospace_label_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	FtMonospaceLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONOSPACE_LABEL, FtMonospaceLabel);
	switch (property_id) {
		case FT_MONOSPACE_LABEL_TEXT_PROPERTY:
		g_value_set_string (value, ft_monospace_label_get_text (self));
		break;
		case FT_MONOSPACE_LABEL_XALIGN_PROPERTY:
		g_value_set_float (value, ft_monospace_label_get_xalign (self));
		break;
		case FT_MONOSPACE_LABEL_YALIGN_PROPERTY:
		g_value_set_float (value, ft_monospace_label_get_yalign (self));
		break;
		case FT_MONOSPACE_LABEL_SCALE_PROPERTY:
		g_value_set_double (value, ft_monospace_label_get_scale (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_monospace_label_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	FtMonospaceLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONOSPACE_LABEL, FtMonospaceLabel);
	switch (property_id) {
		case FT_MONOSPACE_LABEL_TEXT_PROPERTY:
		ft_monospace_label_set_text (self, g_value_get_string (value));
		break;
		case FT_MONOSPACE_LABEL_XALIGN_PROPERTY:
		ft_monospace_label_set_xalign (self, g_value_get_float (value));
		break;
		case FT_MONOSPACE_LABEL_YALIGN_PROPERTY:
		ft_monospace_label_set_yalign (self, g_value_get_float (value));
		break;
		case FT_MONOSPACE_LABEL_SCALE_PROPERTY:
		ft_monospace_label_set_scale (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;
}

