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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <pango/pango.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <graphene-gobject.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define G4_TYPE_PEAK_BAR (g4_peak_bar_get_type ())
#define G4_PEAK_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_PEAK_BAR, G4PeakBar))
#define G4_PEAK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_PEAK_BAR, G4PeakBarClass))
#define G4_IS_PEAK_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_PEAK_BAR))
#define G4_IS_PEAK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_PEAK_BAR))
#define G4_PEAK_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_PEAK_BAR, G4PeakBarClass))

typedef struct _G4PeakBar G4PeakBar;
typedef struct _G4PeakBarClass G4PeakBarClass;
typedef struct _G4PeakBarPrivate G4PeakBarPrivate;
enum  {
	G4_PEAK_BAR_0_PROPERTY,
	G4_PEAK_BAR_ALIGN_PROPERTY,
	G4_PEAK_BAR_CHARACTERS_PROPERTY,
	G4_PEAK_BAR_PEAK_PROPERTY,
	G4_PEAK_BAR_NUM_PROPERTIES
};
static GParamSpec* g4_peak_bar_properties[G4_PEAK_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _G4PeakBar {
	GtkWidget parent_instance;
	G4PeakBarPrivate * priv;
};

struct _G4PeakBarClass {
	GtkWidgetClass parent_class;
};

struct _G4PeakBarPrivate {
	gunichar* _chars;
	gint _chars_length1;
	gint __chars_size_;
	gint _char_count;
	gint* _char_widths;
	gint _char_widths_length1;
	gint __char_widths_size_;
	gint _char_height;
	PangoLayout* _layout;
	GString* _sbuilder;
	gdouble _value;
};

static gint G4PeakBar_private_offset;
static gpointer g4_peak_bar_parent_class = NULL;

VALA_EXTERN GType g4_peak_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4PeakBar, g_object_unref)
static void g4_peak_bar_real_measure (GtkWidget* base,
                               GtkOrientation orientation,
                               gint for_size,
                               gint* minimum,
                               gint* natural,
                               gint* minimum_baseline,
                               gint* natural_baseline);
static void g4_peak_bar_real_snapshot (GtkWidget* base,
                                GtkSnapshot* snapshot);
VALA_EXTERN G4PeakBar* g4_peak_bar_new (void);
VALA_EXTERN G4PeakBar* g4_peak_bar_construct (GType object_type);
VALA_EXTERN PangoAlignment g4_peak_bar_get_align (G4PeakBar* self);
VALA_EXTERN void g4_peak_bar_set_align (G4PeakBar* self,
                            PangoAlignment value);
VALA_EXTERN const gchar* g4_peak_bar_get_characters (G4PeakBar* self);
VALA_EXTERN void g4_peak_bar_set_characters (G4PeakBar* self,
                                 const gchar* value);
VALA_EXTERN gdouble g4_peak_bar_get_peak (G4PeakBar* self);
VALA_EXTERN void g4_peak_bar_set_peak (G4PeakBar* self,
                           gdouble value);
static GObject * g4_peak_bar_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
static void g4_peak_bar_finalize (GObject * obj);
static GType g4_peak_bar_get_type_once (void);
static void _vala_g4_peak_bar_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_g4_peak_bar_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
g4_peak_bar_get_instance_private (G4PeakBar* self)
{
	return G_STRUCT_MEMBER_P (self, G4PeakBar_private_offset);
}

static void
g4_peak_bar_real_measure (GtkWidget* base,
                          GtkOrientation orientation,
                          gint for_size,
                          gint* minimum,
                          gint* natural,
                          gint* minimum_baseline,
                          gint* natural_baseline)
{
	G4PeakBar * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	self = (G4PeakBar*) base;
	if (orientation == GTK_ORIENTATION_VERTICAL) {
		_vala_natural_baseline = self->priv->_char_height;
		_vala_minimum_baseline = _vala_natural_baseline;
		_vala_natural = _vala_minimum_baseline;
		_vala_minimum = _vala_natural;
	} else {
		_vala_natural_baseline = for_size;
		_vala_minimum_baseline = _vala_natural_baseline;
		_vala_natural = _vala_minimum_baseline;
		_vala_minimum = _vala_natural;
	}
	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
g4_peak_bar_real_snapshot (GtkWidget* base,
                           GtkSnapshot* snapshot)
{
	G4PeakBar * self;
	gint width = 0;
	gint height = 0;
	gboolean center = FALSE;
	PangoLayout* _tmp0_;
	gdouble value_width = 0.0;
	PangoLayout* _tmp1_;
	PangoLayout* _tmp2_;
	gint char_count = 0;
	gint char_width = 0;
	GString* _tmp3_;
	GdkRGBA color = {0};
	GdkRGBA _tmp44_ = {0};
	gdouble _tmp45_ = 0.0;
	gdouble opacity = 0.0;
	PangoRectangle ink_rect = {0};
	PangoRectangle logic_rect = {0};
	PangoLayout* _tmp46_;
	GString* _tmp47_;
	const gchar* _tmp48_;
	GString* _tmp49_;
	PangoLayout* _tmp50_;
	PangoRectangle _tmp51_ = {0};
	PangoRectangle _tmp52_ = {0};
	graphene_point_t pt = {0};
	gfloat _tmp53_ = 0.0F;
	PangoRectangle _tmp56_;
	PangoRectangle _tmp57_;
	graphene_point_t _tmp58_;
	PangoLayout* _tmp59_;
	GdkRGBA _tmp60_;
	graphene_point_t _tmp61_;
	graphene_point_t _tmp62_;
	graphene_point_t _tmp63_;
	self = (G4PeakBar*) base;
	g_return_if_fail (snapshot != NULL);
	width = gtk_widget_get_width ((GtkWidget*) self);
	height = gtk_widget_get_height ((GtkWidget*) self);
	_tmp0_ = self->priv->_layout;
	center = pango_layout_get_alignment (_tmp0_) == PANGO_ALIGN_CENTER;
	value_width = self->priv->_value * width;
	_tmp1_ = self->priv->_layout;
	pango_layout_set_width (_tmp1_, -1);
	_tmp2_ = self->priv->_layout;
	pango_layout_set_height (_tmp2_, height * PANGO_SCALE);
	char_count = 0;
	char_width = 0;
	_tmp3_ = self->priv->_sbuilder;
	g_string_truncate (_tmp3_, (gsize) 0);
	if (self->priv->_char_count > 0) {
		gint last = 0;
		GString* _tmp4_;
		gunichar* _tmp5_;
		gint _tmp5__length1;
		gunichar _tmp6_;
		gint _tmp7_;
		gint* _tmp8_;
		gint _tmp8__length1;
		gint _tmp9_;
		gint _tmp13_ = 0;
		gunichar char1 = 0U;
		gunichar* _tmp14_;
		gint _tmp14__length1;
		gunichar _tmp15_;
		gint _tmp16_ = 0;
		gint cx1 = 0;
		gint* _tmp17_;
		gint _tmp17__length1;
		gint _tmp18_;
		gint _tmp19_ = 0;
		gunichar char2 = 0U;
		gunichar* _tmp20_;
		gint _tmp20__length1;
		gunichar _tmp21_;
		gint _tmp22_ = 0;
		gint cx2 = 0;
		gint* _tmp23_;
		gint _tmp23__length1;
		gint _tmp24_;
		last = self->priv->_char_count - 1;
		_tmp4_ = self->priv->_sbuilder;
		_tmp5_ = self->priv->_chars;
		_tmp5__length1 = self->priv->_chars_length1;
		_tmp6_ = _tmp5_[0];
		g_string_append_unichar (_tmp4_, _tmp6_);
		_tmp7_ = char_count;
		char_count = _tmp7_ + 1;
		_tmp8_ = self->priv->_char_widths;
		_tmp8__length1 = self->priv->_char_widths_length1;
		_tmp9_ = _tmp8_[0];
		char_width += _tmp9_;
		if (self->priv->_char_count >= 2) {
			gint _tmp10_;
			gint* _tmp11_;
			gint _tmp11__length1;
			gint _tmp12_;
			_tmp10_ = char_count;
			char_count = _tmp10_ + 1;
			_tmp11_ = self->priv->_char_widths;
			_tmp11__length1 = self->priv->_char_widths_length1;
			_tmp12_ = _tmp11_[last];
			char_width += _tmp12_;
		}
		if (self->priv->_char_count >= 3) {
			_tmp13_ = 1;
		} else {
			_tmp13_ = 0;
		}
		_tmp14_ = self->priv->_chars;
		_tmp14__length1 = self->priv->_chars_length1;
		_tmp15_ = _tmp14_[_tmp13_];
		char1 = _tmp15_;
		if (self->priv->_char_count >= 3) {
			_tmp16_ = 1;
		} else {
			_tmp16_ = 0;
		}
		_tmp17_ = self->priv->_char_widths;
		_tmp17__length1 = self->priv->_char_widths_length1;
		_tmp18_ = _tmp17_[_tmp16_];
		cx1 = _tmp18_;
		if (self->priv->_char_count >= 3) {
			_tmp19_ = self->priv->_char_count - 2;
		} else {
			_tmp19_ = self->priv->_char_count - 1;
		}
		_tmp20_ = self->priv->_chars;
		_tmp20__length1 = self->priv->_chars_length1;
		_tmp21_ = _tmp20_[_tmp19_];
		char2 = _tmp21_;
		if (self->priv->_char_count >= 3) {
			_tmp22_ = self->priv->_char_count - 2;
		} else {
			_tmp22_ = self->priv->_char_count - 1;
		}
		_tmp23_ = self->priv->_char_widths;
		_tmp23__length1 = self->priv->_char_widths_length1;
		_tmp24_ = _tmp23_[_tmp22_];
		cx2 = _tmp24_;
		if (char1 == char2) {
			gint count = 0;
			gboolean _tmp25_ = FALSE;
			count = (gint) (((value_width - char_width) / cx1) + 0.5);
			if (center) {
				_tmp25_ = ((count + self->priv->_char_count) % 2) == 0;
			} else {
				_tmp25_ = FALSE;
			}
			if (_tmp25_) {
				gint _tmp26_;
				_tmp26_ = count;
				count = _tmp26_ - 1;
			}
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp27_ = FALSE;
					_tmp27_ = TRUE;
					while (TRUE) {
						GString* _tmp29_;
						gint _tmp30_;
						if (!_tmp27_) {
							gint _tmp28_;
							_tmp28_ = i;
							i = _tmp28_ + 1;
						}
						_tmp27_ = FALSE;
						if (!(i < count)) {
							break;
						}
						_tmp29_ = self->priv->_sbuilder;
						g_string_append_unichar (_tmp29_, char1);
						_tmp30_ = char_count;
						char_count = _tmp30_ + 1;
						char_width += cx1;
					}
				}
			}
		} else {
			gint count = 0;
			gboolean _tmp31_ = FALSE;
			count = (gint) (((value_width - char_width) / (cx1 + cx2)) + 0.5);
			if (center) {
				_tmp31_ = ((count + self->priv->_char_count) % 2) == 0;
			} else {
				_tmp31_ = FALSE;
			}
			if (_tmp31_) {
				gint _tmp32_;
				_tmp32_ = count;
				count = _tmp32_ - 1;
			}
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp33_ = FALSE;
					_tmp33_ = TRUE;
					while (TRUE) {
						GString* _tmp35_;
						gint _tmp36_;
						if (!_tmp33_) {
							gint _tmp34_;
							_tmp34_ = i;
							i = _tmp34_ + 1;
						}
						_tmp33_ = FALSE;
						if (!(i < count)) {
							break;
						}
						_tmp35_ = self->priv->_sbuilder;
						g_string_append_unichar (_tmp35_, char1);
						_tmp36_ = char_count;
						char_count = _tmp36_ + 1;
						char_width += cx1;
					}
				}
			}
			{
				gint j = 0;
				j = 0;
				{
					gboolean _tmp37_ = FALSE;
					_tmp37_ = TRUE;
					while (TRUE) {
						GString* _tmp39_;
						gint _tmp40_;
						if (!_tmp37_) {
							gint _tmp38_;
							_tmp38_ = j;
							j = _tmp38_ + 1;
						}
						_tmp37_ = FALSE;
						if (!(j < count)) {
							break;
						}
						_tmp39_ = self->priv->_sbuilder;
						g_string_append_unichar (_tmp39_, char2);
						_tmp40_ = char_count;
						char_count = _tmp40_ + 1;
						char_width += cx2;
					}
				}
			}
		}
		if (self->priv->_char_count >= 2) {
			GString* _tmp41_;
			gunichar* _tmp42_;
			gint _tmp42__length1;
			gunichar _tmp43_;
			_tmp41_ = self->priv->_sbuilder;
			_tmp42_ = self->priv->_chars;
			_tmp42__length1 = self->priv->_chars_length1;
			_tmp43_ = _tmp42_[last];
			g_string_append_unichar (_tmp41_, _tmp43_);
		}
	}
	gtk_widget_get_color ((GtkWidget*) self, &_tmp44_);
	color = _tmp44_;
	if (((gdouble) char_width) > value_width) {
		_tmp45_ = value_width / char_width;
	} else {
		_tmp45_ = (gdouble) 1;
	}
	opacity = _tmp45_;
	_tmp46_ = self->priv->_layout;
	_tmp47_ = self->priv->_sbuilder;
	_tmp48_ = _tmp47_->str;
	_tmp49_ = self->priv->_sbuilder;
	pango_layout_set_text (_tmp46_, _tmp48_, (gint) _tmp49_->len);
	_tmp50_ = self->priv->_layout;
	pango_layout_get_pixel_extents (_tmp50_, &_tmp51_, &_tmp52_);
	ink_rect = _tmp51_;
	logic_rect = _tmp52_;
	memset (&pt, 0, sizeof (graphene_point_t));
	if (center) {
		PangoRectangle _tmp54_;
		PangoRectangle _tmp55_;
		_tmp54_ = ink_rect;
		_tmp55_ = ink_rect;
		_tmp53_ = (-_tmp54_.x) + ((width - _tmp55_.width) * 0.5f);
	} else {
		_tmp53_ = (gfloat) 0;
	}
	pt.x = _tmp53_;
	_tmp56_ = ink_rect;
	_tmp57_ = ink_rect;
	pt.y = (-_tmp56_.y) + ((height - _tmp57_.height) * 0.5f);
	_tmp58_ = pt;
	gtk_snapshot_translate (snapshot, &_tmp58_);
	if (opacity < ((gdouble) 1)) {
		gtk_snapshot_push_opacity (snapshot, opacity);
	}
	_tmp59_ = self->priv->_layout;
	_tmp60_ = color;
	gtk_snapshot_append_layout (snapshot, _tmp59_, &_tmp60_);
	if (opacity < ((gdouble) 1)) {
		gtk_snapshot_pop (snapshot);
	}
	_tmp61_ = pt;
	pt.x = -_tmp61_.x;
	_tmp62_ = pt;
	pt.y = -_tmp62_.y;
	_tmp63_ = pt;
	gtk_snapshot_translate (snapshot, &_tmp63_);
}

G4PeakBar*
g4_peak_bar_construct (GType object_type)
{
	G4PeakBar * self = NULL;
	self = (G4PeakBar*) g_object_new (object_type, NULL);
	return self;
}

G4PeakBar*
g4_peak_bar_new (void)
{
	return g4_peak_bar_construct (G4_TYPE_PEAK_BAR);
}

PangoAlignment
g4_peak_bar_get_align (G4PeakBar* self)
{
	PangoAlignment result;
	PangoLayout* _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_layout;
	result = pango_layout_get_alignment (_tmp0_);
	return result;
}

void
g4_peak_bar_set_align (G4PeakBar* self,
                       PangoAlignment value)
{
	PangoLayout* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_layout;
	pango_layout_set_alignment (_tmp0_, value);
	gtk_widget_queue_draw ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, g4_peak_bar_properties[G4_PEAK_BAR_ALIGN_PROPERTY]);
}

static gchar*
string32_to_string (const gunichar* self)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_ucs4_to_utf8 (self, (glong) -1, NULL, NULL, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_CONVERT_ERROR) {
				goto __catch0_g_convert_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp2_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_convert_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

const gchar*
g4_peak_bar_get_characters (G4PeakBar* self)
{
	const gchar* result;
	gchar* _tmp0_ = NULL;
	gunichar* _tmp1_;
	gint _tmp1__length1;
	gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->_chars;
	_tmp1__length1 = self->priv->_chars_length1;
	_tmp2_ = string32_to_string ((const gunichar*) _tmp1_);
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	}
	result = (const gchar*) _tmp0_;
	_g_free0 (_tmp0_);
	return result;
}

static gboolean
string_get_next_char (const gchar* self,
                      gint* index,
                      gunichar* c)
{
	gunichar _vala_c = 0U;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_c = g_utf8_get_char (((gchar*) self) + (*index));
	if (_vala_c != ((gunichar) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_utf8_next_char (((gchar*) self) + (*index));
		*index = (gint) (_tmp0_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
}

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

void
g4_peak_bar_set_characters (G4PeakBar* self,
                            const gchar* value)
{
	gint count = 0;
	gunichar* _tmp0_;
	gint next = 0;
	gunichar c = 0U;
	gunichar* _tmp18_;
	gint _tmp18__length1;
	gint* _tmp19_;
	gint _tmp19__length1;
	g_return_if_fail (self != NULL);
	count = g_utf8_strlen (value, (gssize) -1);
	_tmp0_ = g_new0 (gunichar, count + 1);
	self->priv->_chars = (g_free (self->priv->_chars), NULL);
	self->priv->_chars = _tmp0_;
	self->priv->_chars_length1 = count + 1;
	self->priv->__chars_size_ = self->priv->_chars_length1;
	self->priv->_char_count = 0;
	self->priv->_char_height = 0;
	next = 0;
	c = (gunichar) 0;
	while (TRUE) {
		gunichar _tmp1_ = 0U;
		gboolean _tmp2_;
		_tmp2_ = string_get_next_char (value, &next, &_tmp1_);
		c = _tmp1_;
		if (!_tmp2_) {
			break;
		}
		if (!g_unichar_ismark (c)) {
			PangoRectangle ink_rect = {0};
			PangoRectangle logic_rect = {0};
			gchar* text = NULL;
			gchar* _tmp3_;
			PangoLayout* _tmp4_;
			const gchar* _tmp5_;
			const gchar* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			PangoLayout* _tmp9_;
			PangoRectangle _tmp10_ = {0};
			PangoRectangle _tmp11_ = {0};
			gunichar* _tmp12_;
			gint _tmp12__length1;
			gint* _tmp13_;
			gint _tmp13__length1;
			PangoRectangle _tmp14_;
			PangoRectangle _tmp15_;
			gint _tmp17_;
			_tmp3_ = g_unichar_to_string (c);
			text = _tmp3_;
			_tmp4_ = self->priv->_layout;
			_tmp5_ = text;
			_tmp6_ = text;
			_tmp7_ = strlen (_tmp6_);
			_tmp8_ = _tmp7_;
			pango_layout_set_text (_tmp4_, _tmp5_, _tmp8_);
			_tmp9_ = self->priv->_layout;
			pango_layout_get_pixel_extents (_tmp9_, &_tmp10_, &_tmp11_);
			ink_rect = _tmp10_;
			logic_rect = _tmp11_;
			_tmp12_ = self->priv->_chars;
			_tmp12__length1 = self->priv->_chars_length1;
			_tmp12_[self->priv->_char_count] = c;
			_tmp13_ = self->priv->_char_widths;
			_tmp13__length1 = self->priv->_char_widths_length1;
			_tmp14_ = logic_rect;
			_tmp13_[self->priv->_char_count] = _tmp14_.width;
			_tmp15_ = logic_rect;
			if (self->priv->_char_height < _tmp15_.height) {
				PangoRectangle _tmp16_;
				_tmp16_ = logic_rect;
				self->priv->_char_height = _tmp16_.height;
			}
			_tmp17_ = self->priv->_char_count;
			self->priv->_char_count = _tmp17_ + 1;
			_g_free0 (text);
		}
	}
	_tmp18_ = self->priv->_chars;
	_tmp18__length1 = self->priv->_chars_length1;
	_tmp18_[self->priv->_char_count] = (gunichar) 0;
	_tmp19_ = self->priv->_char_widths;
	_tmp19__length1 = self->priv->_char_widths_length1;
	_tmp19_[self->priv->_char_count] = 0;
	gtk_widget_queue_resize ((GtkWidget*) self);
	gtk_widget_queue_draw ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, g4_peak_bar_properties[G4_PEAK_BAR_CHARACTERS_PROPERTY]);
}

gdouble
g4_peak_bar_get_peak (G4PeakBar* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_value;
	return result;
}

void
g4_peak_bar_set_peak (G4PeakBar* self,
                      gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_value = value;
	gtk_widget_queue_draw ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, g4_peak_bar_properties[G4_PEAK_BAR_PEAK_PROPERTY]);
}

static GObject *
g4_peak_bar_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	G4PeakBar * self;
	PangoLayout* _tmp0_;
	PangoAlignment _tmp1_ = 0;
	PangoLayout* _tmp2_;
	parent_class = G_OBJECT_CLASS (g4_peak_bar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_PEAK_BAR, G4PeakBar);
	_tmp0_ = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
	_g_object_unref0 (self->priv->_layout);
	self->priv->_layout = _tmp0_;
	if (gtk_widget_get_direction ((GtkWidget*) self) == GTK_TEXT_DIR_RTL) {
		_tmp1_ = PANGO_ALIGN_RIGHT;
	} else {
		_tmp1_ = PANGO_ALIGN_LEFT;
	}
	_tmp2_ = self->priv->_layout;
	pango_layout_set_alignment (_tmp2_, _tmp1_);
	return obj;
}

static void
g4_peak_bar_class_init (G4PeakBarClass * klass,
                        gpointer klass_data)
{
	g4_peak_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4PeakBar_private_offset);
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) g4_peak_bar_real_measure;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) g4_peak_bar_real_snapshot;
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_peak_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_peak_bar_set_property;
	G_OBJECT_CLASS (klass)->constructor = g4_peak_bar_constructor;
	G_OBJECT_CLASS (klass)->finalize = g4_peak_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_PEAK_BAR_ALIGN_PROPERTY, g4_peak_bar_properties[G4_PEAK_BAR_ALIGN_PROPERTY] = g_param_spec_enum ("align", "align", "align", pango_alignment_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_PEAK_BAR_CHARACTERS_PROPERTY, g4_peak_bar_properties[G4_PEAK_BAR_CHARACTERS_PROPERTY] = g_param_spec_string ("characters", "characters", "characters", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_PEAK_BAR_PEAK_PROPERTY, g4_peak_bar_properties[G4_PEAK_BAR_PEAK_PROPERTY] = g_param_spec_double ("peak", "peak", "peak", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
g4_peak_bar_instance_init (G4PeakBar * self,
                           gpointer klass)
{
	gunichar* _tmp0_;
	gint* _tmp1_;
	GString* _tmp2_;
	self->priv = g4_peak_bar_get_instance_private (self);
	_tmp0_ = g_new0 (gunichar, 2);
	_tmp0_[0] = (gunichar) '=';
	_tmp0_[1] = (gunichar) 0;
	self->priv->_chars = _tmp0_;
	self->priv->_chars_length1 = 2;
	self->priv->__chars_size_ = self->priv->_chars_length1;
	self->priv->_char_count = 1;
	_tmp1_ = g_new0 (gint, 1);
	_tmp1_[0] = 10;
	self->priv->_char_widths = _tmp1_;
	self->priv->_char_widths_length1 = 1;
	self->priv->__char_widths_size_ = self->priv->_char_widths_length1;
	self->priv->_char_height = 0;
	_tmp2_ = g_string_new ("");
	self->priv->_sbuilder = _tmp2_;
	self->priv->_value = (gdouble) 0;
}

static void
g4_peak_bar_finalize (GObject * obj)
{
	G4PeakBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_PEAK_BAR, G4PeakBar);
	self->priv->_chars = (g_free (self->priv->_chars), NULL);
	self->priv->_char_widths = (g_free (self->priv->_char_widths), NULL);
	_g_object_unref0 (self->priv->_layout);
	_g_string_free0 (self->priv->_sbuilder);
	G_OBJECT_CLASS (g4_peak_bar_parent_class)->finalize (obj);
}

static GType
g4_peak_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4PeakBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_peak_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4PeakBar), 0, (GInstanceInitFunc) g4_peak_bar_instance_init, NULL };
	GType g4_peak_bar_type_id;
	g4_peak_bar_type_id = g_type_register_static (gtk_widget_get_type (), "G4PeakBar", &g_define_type_info, 0);
	G4PeakBar_private_offset = g_type_add_instance_private (g4_peak_bar_type_id, sizeof (G4PeakBarPrivate));
	return g4_peak_bar_type_id;
}

GType
g4_peak_bar_get_type (void)
{
	static volatile gsize g4_peak_bar_type_id__once = 0;
	if (g_once_init_enter (&g4_peak_bar_type_id__once)) {
		GType g4_peak_bar_type_id;
		g4_peak_bar_type_id = g4_peak_bar_get_type_once ();
		g_once_init_leave (&g4_peak_bar_type_id__once, g4_peak_bar_type_id);
	}
	return g4_peak_bar_type_id__once;
}

static void
_vala_g4_peak_bar_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	G4PeakBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_PEAK_BAR, G4PeakBar);
	switch (property_id) {
		case G4_PEAK_BAR_ALIGN_PROPERTY:
		g_value_set_enum (value, g4_peak_bar_get_align (self));
		break;
		case G4_PEAK_BAR_CHARACTERS_PROPERTY:
		g_value_set_string (value, g4_peak_bar_get_characters (self));
		break;
		case G4_PEAK_BAR_PEAK_PROPERTY:
		g_value_set_double (value, g4_peak_bar_get_peak (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_peak_bar_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	G4PeakBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_PEAK_BAR, G4PeakBar);
	switch (property_id) {
		case G4_PEAK_BAR_ALIGN_PROPERTY:
		g4_peak_bar_set_align (self, g_value_get_enum (value));
		break;
		case G4_PEAK_BAR_CHARACTERS_PROPERTY:
		g4_peak_bar_set_characters (self, g_value_get_string (value));
		break;
		case G4_PEAK_BAR_PEAK_PROPERTY:
		g4_peak_bar_set_peak (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;
}

