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

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

#include "ft_ui.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include "ft_core.h"
#include <gtk/gtk.h>
#include <graphene-gobject.h>
#include <gsk/gsk.h>
#include <cairo-gobject.h>

#define FT_BAR_CHART_MIN_BAR_WIDTH 16
#define FT_BAR_CHART_MAX_BAR_WIDTH 30
#define FT_BAR_CHART_BAR_SPACING 0.25f
#define FT_BAR_CHART_MIN_BAR_SPACING 2
#define FT_BAR_CHART_ASPECT_RATIO 1.66f
#define FT_BAR_CHART_BAR_HIT_ZONE_PADDING 10.0f
#define FT_BAR_CHART_EPSILON 0.00001
#define FT_BAR_CHART_DEFAULT_VALUE 0.0
#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

#define FT_TYPE_BUCKET (ft_bucket_get_type ())
typedef struct _FtBucket FtBucket;

#define FT_TYPE_CATEGORY (ft_category_get_type ())
typedef struct _FtCategory FtCategory;
enum  {
	FT_BAR_CHART_0_PROPERTY,
	FT_BAR_CHART_STACKED_PROPERTY,
	FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY,
	FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY,
	FT_BAR_CHART_REFERENCE_VALUE_PROPERTY,
	FT_BAR_CHART_NUM_PROPERTIES
};
static GParamSpec* ft_bar_chart_properties[FT_BAR_CHART_NUM_PROPERTIES];
typedef struct _FtCanvas FtCanvas;
typedef struct _FtCanvasClass FtCanvasClass;
#define _ft_matrix_free0(var) ((var == NULL) ? NULL : (var = (ft_matrix_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _ft_vector_free0(var) ((var == NULL) ? NULL : (var = (ft_vector_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _FtGizmo FtGizmo;
typedef struct _FtGizmoClass FtGizmoClass;
typedef struct _Block3Data Block3Data;
typedef struct _FtCanvasLayoutChild FtCanvasLayoutChild;
typedef struct _FtCanvasLayoutChildClass FtCanvasLayoutChildClass;
typedef struct _FtChartContents FtChartContents;
typedef struct _FtChartContentsClass FtChartContentsClass;
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;
enum  {
	FT_BAR_CHART_BAR_ACTIVATED_SIGNAL,
	FT_BAR_CHART_NUM_SIGNALS
};
static guint ft_bar_chart_signals[FT_BAR_CHART_NUM_SIGNALS] = {0};
#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 _FtBucket {
	gchar* label;
	gchar* tooltip_label;
};

struct _FtCategory {
	gchar* label;
	GdkRGBA color;
	FtUnit unit;
	gboolean visible;
};

struct _FtBarChartPrivate {
	gboolean _activate_on_click;
	gboolean _stacked;
	gboolean _show_empty_bars;
	gdouble transform_slope;
	gdouble transform_intercept;
	FtBucket* buckets;
	gint buckets_length1;
	gint _buckets_size_;
	FtCategory* categories;
	gint categories_length1;
	gint _categories_size_;
	FtMatrix* data;
	gint bar_width;
	gint bar_height;
	gint bar_radius;
	gint tooltip_bar_index;
	GtkWidget* tooltip_widget;
};

struct _Block3Data {
	int _ref_count_;
	FtBarChart* self;
	FtGizmo* weak_bar;
};

struct _Block4Data {
	int _ref_count_;
	FtBarChart* self;
	guint bars_count;
	guint bar_index;
	FtCanvas* canvas;
};

struct _Block5Data {
	int _ref_count_;
	FtBarChart* self;
	FtCanvas* canvas;
};

static gint FtBarChart_private_offset;
static gpointer ft_bar_chart_parent_class = NULL;

VALA_EXTERN GType ft_bucket_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FtBucket* ft_bucket_dup (const FtBucket* self);
VALA_EXTERN void ft_bucket_free (FtBucket* self);
VALA_EXTERN void ft_bucket_copy (const FtBucket* self,
                     FtBucket* dest);
VALA_EXTERN void ft_bucket_destroy (FtBucket* self);
VALA_EXTERN GType ft_category_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FtCategory* ft_category_dup (const FtCategory* self);
VALA_EXTERN void ft_category_free (FtCategory* self);
VALA_EXTERN void ft_category_copy (const FtCategory* self,
                       FtCategory* dest);
VALA_EXTERN void ft_category_destroy (FtCategory* self);
static void _vala_FtBucket_array_free (FtBucket * array,
                                gssize array_length);
static void _vala_FtCategory_array_free (FtCategory * array,
                                  gssize array_length);
static gdouble ft_bar_chart_calculate_bucket_sum (FtBarChart* self,
                                           guint bucket_index);
static gdouble ft_bar_chart_calculate_bucket_max (FtBarChart* self,
                                           guint bucket_index);
static inline gdouble ft_bar_chart_calculate_bucket_total_value (FtBarChart* self,
                                                   guint bucket_index);
static void ft_bar_chart_ensure_categories (FtBarChart* self,
                                     guint count);
static void ft_bar_chart_ensure_buckets (FtBarChart* self,
                                  guint count);
static inline void ft_bar_chart_ensure_data (FtBarChart* self);
static inline void ft_bar_chart_grow_data (FtBarChart* self,
                             guint bucket_count,
                             guint category_count);
static gboolean ft_bar_chart_is_bucket_empty (FtBarChart* self,
                                       guint bucket_index);
static gboolean ft_bar_chart_on_query_tooltip (FtBarChart* self,
                                        GtkWidget* widget,
                                        gint x,
                                        gint y,
                                        gboolean keyboard_tooltip,
                                        GtkTooltip* tooltip);
static GtkWidget* ft_bar_chart_create_tooltip_widget (FtBarChart* self,
                                               guint bar_index);
static gchar* ft_bar_chart_format_tooltip_value (FtBarChart* self,
                                          guint category_index,
                                          gdouble value);
static GtkWidget* ft_bar_chart_create_bar (FtBarChart* self);
static void ft_bar_chart_measure_bar_cb (FtGizmo* gizmo,
                                  GtkOrientation orientation,
                                  gint for_size,
                                  gint* minimum,
                                  gint* natural,
                                  gint* minimum_baseline,
                                  gint* natural_baseline);
static void _ft_bar_chart_measure_bar_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                         GtkOrientation orientation,
                                                         gint for_size,
                                                         gint* minimum,
                                                         gint* natural,
                                                         gint* minimum_baseline,
                                                         gint* natural_baseline,
                                                         gpointer self);
static void ft_bar_chart_snapshot_bar_cb (FtGizmo* gizmo,
                                   GtkSnapshot* snapshot);
static void _ft_bar_chart_snapshot_bar_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                           GtkSnapshot* snapshot,
                                                           gpointer self);
static gboolean ft_bar_chart_contains_bar_cb (FtGizmo* gizmo,
                                       gdouble x,
                                       gdouble y);
static gboolean _ft_bar_chart_contains_bar_cb_ft_gizmo_contains_func (FtGizmo* gizmo,
                                                               gdouble x,
                                                               gdouble y,
                                                               gpointer self);
static gboolean ft_bar_chart_on_query_tooltip_cb (GtkWidget* widget,
                                           gint x,
                                           gint y,
                                           gboolean keyboard_tooltip,
                                           GtkTooltip* tooltip);
static gboolean _ft_bar_chart_on_query_tooltip_cb_gtk_widget_query_tooltip (GtkWidget* _sender,
                                                                     gint x,
                                                                     gint y,
                                                                     gboolean keyboard_tooltip,
                                                                     GtkTooltip* tooltip,
                                                                     gpointer self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void ___lambda15_ (Block3Data* _data3_,
                   gint n_press,
                   gdouble x,
                   gdouble y);
static void ft_bar_chart_on_clicked_cb (GtkWidget* widget);
static void ____lambda15__gtk_gesture_click_released (GtkGestureClick* _sender,
                                               gint n_press,
                                               gdouble x,
                                               gdouble y,
                                               gpointer self);
static FtBarChart* ft_bar_chart_from_gizmo (FtGizmo* gizmo);
static FtBarChart* ft_bar_chart_from_widget (GtkWidget* widget);
static void ft_bar_chart_measure_bar (FtBarChart* self,
                               FtGizmo* gizmo,
                               GtkOrientation orientation,
                               gint for_size,
                               gint* minimum,
                               gint* natural,
                               gint* minimum_baseline,
                               gint* natural_baseline);
static void ft_bar_chart_snapshot_bar (FtBarChart* self,
                                FtGizmo* gizmo,
                                GtkSnapshot* snapshot);
static gboolean ft_bar_chart_contains_bar (FtBarChart* self,
                                    FtGizmo* gizmo,
                                    gdouble x,
                                    gdouble y);
static inline void ft_bar_chart_update_bar (FtBarChart* self,
                              GtkWidget* bar,
                              guint bar_index);
VALA_EXTERN FtCanvasLayoutChild* ft_canvas_get_layout_child (FtCanvas* self,
                                                 GtkWidget* child);
static inline void ft_bar_chart_foreach_bar (FtBarChart* self,
                               GFunc func,
                               gpointer func_target);
static GtkSizeRequestMode ft_bar_chart_real_get_contents_request_mode (FtChart* base,
                                                                FtCanvas* canvas);
static void ft_bar_chart_real_update_canvas (FtChart* base,
                                      FtCanvas* canvas);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda16_ (Block4Data* _data4_,
                  GtkWidget* bar);
static void ___lambda16__gfunc (gconstpointer data,
                         gpointer self);
static void ft_bar_chart_real_measure_canvas (FtChart* base,
                                       FtCanvas* canvas,
                                       GtkOrientation orientation,
                                       gint for_size,
                                       gint* minimum,
                                       gint* natural);
static void ft_bar_chart_real_measure_working_area (FtChart* base,
                                             FtCanvas* canvas,
                                             gint available_width,
                                             gint available_height,
                                             GdkRectangle* working_area);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static void __lambda17_ (Block5Data* _data5_,
                  GtkWidget* bar);
static void ___lambda17__gfunc (gconstpointer data,
                         gpointer self);
static gchar* ft_bar_chart_real_format_x_value (FtChart* base,
                                         gdouble value);
static void ft_bar_chart_real_dispose (GObject* base);
static GObject * ft_bar_chart_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void ft_bar_chart_finalize (GObject * obj);
static GType ft_bar_chart_get_type_once (void);
static void _vala_ft_bar_chart_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_ft_bar_chart_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);

static inline gpointer
ft_bar_chart_get_instance_private (FtBarChart* self)
{
	return G_STRUCT_MEMBER_P (self, FtBarChart_private_offset);
}

static void
_vala_FtBucket_array_free (FtBucket * array,
                           gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			ft_bucket_destroy (&array[i]);
		}
	}
	g_free (array);
}

static void
_vala_FtCategory_array_free (FtCategory * array,
                             gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			ft_category_destroy (&array[i]);
		}
	}
	g_free (array);
}

static gdouble
ft_bar_chart_calculate_bucket_sum (FtBarChart* self,
                                   guint bucket_index)
{
	FtMatrix* _tmp0_;
	FtVector* values = NULL;
	FtMatrix* _tmp1_;
	FtVector* _tmp2_;
	gdouble _tmp9_ = 0.0;
	FtVector* _tmp10_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->data;
	if (_tmp0_ == NULL) {
		result = 0.0;
		return result;
	}
	_tmp1_ = self->priv->data;
	_tmp2_ = ft_matrix_get_vector (_tmp1_, 0, (gint) bucket_index);
	values = _tmp2_;
	{
		gint category_index = 0;
		category_index = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				FtCategory* _tmp5_;
				gint _tmp5__length1;
				FtCategory* _tmp6_;
				gint _tmp6__length1;
				FtCategory _tmp7_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = category_index;
					category_index = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = self->priv->categories;
				_tmp5__length1 = self->priv->categories_length1;
				if (!(category_index < _tmp5__length1)) {
					break;
				}
				_tmp6_ = self->priv->categories;
				_tmp6__length1 = self->priv->categories_length1;
				_tmp7_ = _tmp6_[category_index];
				if (!_tmp7_.visible) {
					FtVector* _tmp8_;
					_tmp8_ = values;
					ft_vector_set (_tmp8_, category_index, 0.0);
				}
			}
		}
	}
	_tmp10_ = values;
	if (_tmp10_ != NULL) {
		FtVector* _tmp11_;
		_tmp11_ = values;
		_tmp9_ = ft_vector_sum (_tmp11_);
	} else {
		_tmp9_ = 0.0;
	}
	result = _tmp9_;
	_ft_vector_free0 (values);
	return result;
}

static gdouble
ft_bar_chart_calculate_bucket_max (FtBarChart* self,
                                   guint bucket_index)
{
	FtMatrix* _tmp0_;
	FtVector* values = NULL;
	FtMatrix* _tmp1_;
	FtVector* _tmp2_;
	gdouble _tmp9_ = 0.0;
	FtVector* _tmp10_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->data;
	if (_tmp0_ == NULL) {
		result = 0.0;
		return result;
	}
	_tmp1_ = self->priv->data;
	_tmp2_ = ft_matrix_get_vector (_tmp1_, 0, (gint) bucket_index);
	values = _tmp2_;
	{
		gint category_index = 0;
		category_index = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				FtCategory* _tmp5_;
				gint _tmp5__length1;
				FtCategory* _tmp6_;
				gint _tmp6__length1;
				FtCategory _tmp7_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = category_index;
					category_index = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = self->priv->categories;
				_tmp5__length1 = self->priv->categories_length1;
				if (!(category_index < _tmp5__length1)) {
					break;
				}
				_tmp6_ = self->priv->categories;
				_tmp6__length1 = self->priv->categories_length1;
				_tmp7_ = _tmp6_[category_index];
				if (!_tmp7_.visible) {
					FtVector* _tmp8_;
					_tmp8_ = values;
					ft_vector_set (_tmp8_, category_index, 0.0);
				}
			}
		}
	}
	_tmp10_ = values;
	if (_tmp10_ != NULL) {
		FtVector* _tmp11_;
		_tmp11_ = values;
		_tmp9_ = ft_vector_max (_tmp11_);
	} else {
		_tmp9_ = 0.0;
	}
	result = _tmp9_;
	_ft_vector_free0 (values);
	return result;
}

static inline gdouble
ft_bar_chart_calculate_bucket_total_value (FtBarChart* self,
                                           guint bucket_index)
{
	gdouble _tmp0_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	if (self->priv->_stacked) {
		_tmp0_ = ft_bar_chart_calculate_bucket_sum (self, bucket_index);
	} else {
		_tmp0_ = ft_bar_chart_calculate_bucket_max (self, bucket_index);
	}
	result = _tmp0_;
	return result;
}

static void
ft_bar_chart_ensure_categories (FtBarChart* self,
                                guint count)
{
	gint previous_count = 0;
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	previous_count = _tmp0__length1;
	if (((guint) previous_count) >= count) {
		return;
	}
	_tmp1_ = (gint) count;
	self->priv->categories = g_renew (FtCategory, self->priv->categories, (gint) count);
	(_tmp1_ > self->priv->categories_length1) ? memset (self->priv->categories + self->priv->categories_length1, 0, sizeof (FtCategory) * (_tmp1_ - self->priv->categories_length1)) : NULL;
	self->priv->categories_length1 = _tmp1_;
	self->priv->_categories_size_ = _tmp1_;
	{
		gint index = 0;
		index = previous_count;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				FtCategory* _tmp4_;
				gint _tmp4__length1;
				gchar* _tmp5_;
				GdkRGBA _tmp6_ = {0};
				FtCategory _tmp7_ = {0};
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = index;
					index = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(((guint) index) < count)) {
					break;
				}
				_tmp4_ = self->priv->categories;
				_tmp4__length1 = self->priv->categories_length1;
				_tmp5_ = g_strdup ("");
				gtk_widget_get_color ((GtkWidget*) self, &_tmp6_);
				memset (&_tmp7_, 0, sizeof (FtCategory));
				_g_free0 (_tmp7_.label);
				_tmp7_.label = _tmp5_;
				_tmp7_.color = _tmp6_;
				_tmp7_.visible = TRUE;
				ft_category_destroy (&_tmp4_[index]);
				_tmp4_[index] = _tmp7_;
			}
		}
	}
	ft_chart_queue_update ((FtChart*) self);
}

static void
ft_bar_chart_ensure_buckets (FtBarChart* self,
                             guint count)
{
	gint previous_count = 0;
	FtBucket* _tmp0_;
	gint _tmp0__length1;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->buckets;
	_tmp0__length1 = self->priv->buckets_length1;
	previous_count = _tmp0__length1;
	if (((guint) previous_count) >= count) {
		return;
	}
	_tmp1_ = (gint) count;
	self->priv->buckets = g_renew (FtBucket, self->priv->buckets, (gint) count);
	(_tmp1_ > self->priv->buckets_length1) ? memset (self->priv->buckets + self->priv->buckets_length1, 0, sizeof (FtBucket) * (_tmp1_ - self->priv->buckets_length1)) : NULL;
	self->priv->buckets_length1 = _tmp1_;
	self->priv->_buckets_size_ = _tmp1_;
	{
		gint index = 0;
		index = previous_count;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				FtBucket* _tmp4_;
				gint _tmp4__length1;
				gchar* _tmp5_;
				FtBucket _tmp6_ = {0};
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = index;
					index = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(((guint) index) < count)) {
					break;
				}
				_tmp4_ = self->priv->buckets;
				_tmp4__length1 = self->priv->buckets_length1;
				_tmp5_ = g_strdup ("");
				memset (&_tmp6_, 0, sizeof (FtBucket));
				_g_free0 (_tmp6_.label);
				_tmp6_.label = _tmp5_;
				ft_bucket_destroy (&_tmp4_[index]);
				_tmp4_[index] = _tmp6_;
			}
		}
	}
	ft_chart_queue_update ((FtChart*) self);
}

static inline void
ft_bar_chart_ensure_data (FtBarChart* self)
{
	FtMatrix* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->data;
	if (_tmp0_ == NULL) {
		gint bucket_count = 0;
		FtBucket* _tmp1_;
		gint _tmp1__length1;
		gint category_count = 0;
		FtCategory* _tmp2_;
		gint _tmp2__length1;
		FtMatrix* _tmp3_;
		_tmp1_ = self->priv->buckets;
		_tmp1__length1 = self->priv->buckets_length1;
		bucket_count = _tmp1__length1;
		_tmp2_ = self->priv->categories;
		_tmp2__length1 = self->priv->categories_length1;
		category_count = _tmp2__length1;
		_tmp3_ = ft_matrix_new ((guint) bucket_count, (guint) category_count);
		_ft_matrix_free0 (self->priv->data);
		self->priv->data = _tmp3_;
	}
}

static inline void
ft_bar_chart_grow_data (FtBarChart* self,
                        guint bucket_count,
                        guint category_count)
{
	FtMatrix* _tmp0_;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	FtMatrix* _tmp3_;
	guint* _tmp4_;
	gint _tmp4__length1;
	guint _tmp5_;
	gboolean _tmp6_ = FALSE;
	FtMatrix* _tmp7_;
	guint* _tmp8_;
	gint _tmp8__length1;
	guint _tmp9_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (bucket_count < ((guint) 1000), "bucket_count < 1000");
	ft_bar_chart_ensure_data (self);
	_tmp0_ = self->priv->data;
	_tmp1_ = _tmp0_->shape;
	_tmp1__length1 = _tmp0_->shape_length1;
	_tmp2_ = _tmp1_[0];
	bucket_count = MAX (_tmp2_, bucket_count);
	_tmp3_ = self->priv->data;
	_tmp4_ = _tmp3_->shape;
	_tmp4__length1 = _tmp3_->shape_length1;
	_tmp5_ = _tmp4_[1];
	category_count = MAX (_tmp5_, category_count);
	_tmp7_ = self->priv->data;
	_tmp8_ = _tmp7_->shape;
	_tmp8__length1 = _tmp7_->shape_length1;
	_tmp9_ = _tmp8_[0];
	if (_tmp9_ != bucket_count) {
		_tmp6_ = TRUE;
	} else {
		FtMatrix* _tmp10_;
		guint* _tmp11_;
		gint _tmp11__length1;
		guint _tmp12_;
		_tmp10_ = self->priv->data;
		_tmp11_ = _tmp10_->shape;
		_tmp11__length1 = _tmp10_->shape_length1;
		_tmp12_ = _tmp11_[1];
		_tmp6_ = _tmp12_ != category_count;
	}
	if (_tmp6_) {
		FtMatrix* _tmp13_;
		_tmp13_ = self->priv->data;
		ft_matrix_resize (_tmp13_, bucket_count, category_count, FT_BAR_CHART_DEFAULT_VALUE);
	}
}

static gboolean
ft_bar_chart_is_bucket_empty (FtBarChart* self,
                              guint bucket_index)
{
	gint category_count = 0;
	FtMatrix* _tmp0_;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	FtCategory* _tmp3_;
	gint _tmp3__length1;
	gdouble total_abs_value = 0.0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->data;
	_tmp1_ = _tmp0_->shape;
	_tmp1__length1 = _tmp0_->shape_length1;
	_tmp2_ = _tmp1_[1];
	_tmp3_ = self->priv->categories;
	_tmp3__length1 = self->priv->categories_length1;
	category_count = MIN ((gint) _tmp2_, _tmp3__length1);
	total_abs_value = 0.0;
	{
		gint category_index = 0;
		category_index = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gdouble category_value = 0.0;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = category_index;
					category_index = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (!(category_index < category_count)) {
					break;
				}
				category_value = ft_bar_chart_get_value (self, bucket_index, (guint) category_index);
				if (isfinite (category_value)) {
					total_abs_value += fabs (category_value);
				}
			}
		}
	}
	result = fabs (total_abs_value) <= FT_BAR_CHART_EPSILON;
	return result;
}

guint
ft_bar_chart_get_bars_count (FtBarChart* self)
{
	FtBucket* _tmp0_;
	gint _tmp0__length1;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->buckets;
	_tmp0__length1 = self->priv->buckets_length1;
	result = (guint) _tmp0__length1;
	return result;
}

guint
ft_bar_chart_get_categories_count (FtBarChart* self)
{
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	result = (guint) _tmp0__length1;
	return result;
}

gdouble
ft_bar_chart_get_category_total (FtBarChart* self,
                                 guint category_index)
{
	gdouble total = 0.0;
	FtMatrix* _tmp0_;
	FtVector* _tmp1_;
	FtVector* _tmp2_;
	gdouble _tmp3_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->data;
	_tmp1_ = ft_matrix_get_vector (_tmp0_, -1, (gint) category_index);
	_tmp2_ = _tmp1_;
	_tmp3_ = ft_vector_sum (_tmp2_);
	_ft_vector_free0 (_tmp2_);
	total = _tmp3_;
	if (self->priv->_stacked) {
		{
			gint index = 0;
			index = 0;
			{
				gboolean _tmp4_ = FALSE;
				_tmp4_ = TRUE;
				while (TRUE) {
					FtMatrix* _tmp6_;
					FtVector* _tmp7_;
					FtVector* _tmp8_;
					if (!_tmp4_) {
						gint _tmp5_;
						_tmp5_ = index;
						index = _tmp5_ + 1;
					}
					_tmp4_ = FALSE;
					if (!(((guint) index) < category_index)) {
						break;
					}
					_tmp6_ = self->priv->data;
					_tmp7_ = ft_matrix_get_vector (_tmp6_, -1, index);
					_tmp8_ = _tmp7_;
					total += ft_vector_sum (_tmp8_);
					_ft_vector_free0 (_tmp8_);
				}
			}
		}
	}
	result = total;
	return result;
}

void
ft_bar_chart_remove_all_bars (FtBarChart* self)
{
	g_return_if_fail (self != NULL);
	self->priv->buckets = (_vala_FtBucket_array_free (self->priv->buckets, self->priv->buckets_length1), NULL);
	self->priv->buckets = NULL;
	self->priv->buckets_length1 = 0;
	self->priv->_buckets_size_ = self->priv->buckets_length1;
}

void
ft_bar_chart_set_bar_label (FtBarChart* self,
                            guint bar_index,
                            const gchar* label,
                            const gchar* tooltip_label)
{
	FtBucket* _tmp0_;
	gint _tmp0__length1;
	gchar* _tmp1_;
	FtBucket* _tmp2_;
	gint _tmp2__length1;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (label != NULL);
	g_return_if_fail (tooltip_label != NULL);
	if (g_strcmp0 (tooltip_label, "") == 0) {
		tooltip_label = label;
	}
	ft_bar_chart_ensure_buckets (self, bar_index + 1);
	_tmp0_ = self->priv->buckets;
	_tmp0__length1 = self->priv->buckets_length1;
	_tmp1_ = g_strdup (label);
	_g_free0 (_tmp0_[bar_index].label);
	_tmp0_[bar_index].label = _tmp1_;
	_tmp2_ = self->priv->buckets;
	_tmp2__length1 = self->priv->buckets_length1;
	_tmp3_ = g_strdup (tooltip_label);
	_g_free0 (_tmp2_[bar_index].tooltip_label);
	_tmp2_[bar_index].tooltip_label = _tmp3_;
}

void
ft_bar_chart_set_category_label (FtBarChart* self,
                                 guint category_index,
                                 const gchar* label)
{
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (label != NULL);
	ft_bar_chart_ensure_categories (self, category_index + 1);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	_tmp1_ = g_strdup (label);
	_g_free0 (_tmp0_[category_index].label);
	_tmp0_[category_index].label = _tmp1_;
}

void
ft_bar_chart_set_category_color (FtBarChart* self,
                                 guint category_index,
                                 GdkRGBA* color)
{
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	GdkRGBA _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	ft_bar_chart_ensure_categories (self, category_index + 1);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	_tmp1_ = *color;
	_tmp0_[category_index].color = _tmp1_;
	gtk_widget_queue_draw ((GtkWidget*) self);
}

void
ft_bar_chart_set_category_unit (FtBarChart* self,
                                guint category_index,
                                FtUnit unit)
{
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	ft_bar_chart_ensure_categories (self, category_index + 1);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	_tmp0_[category_index].unit = unit;
}

void
ft_bar_chart_set_category_visible (FtBarChart* self,
                                   guint category_index,
                                   gboolean visible)
{
	FtCategory* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	ft_bar_chart_ensure_categories (self, category_index + 1);
	_tmp0_ = self->priv->categories;
	_tmp0__length1 = self->priv->categories_length1;
	_tmp0_[category_index].visible = visible;
	gtk_widget_queue_draw ((GtkWidget*) self);
}

void
ft_bar_chart_fill (FtBarChart* self,
                   gdouble value)
{
	FtBucket* _tmp0_;
	gint _tmp0__length1;
	FtCategory* _tmp1_;
	gint _tmp1__length1;
	FtMatrix* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->buckets;
	_tmp0__length1 = self->priv->buckets_length1;
	_tmp1_ = self->priv->categories;
	_tmp1__length1 = self->priv->categories_length1;
	ft_bar_chart_grow_data (self, (guint) _tmp0__length1, (guint) _tmp1__length1);
	_tmp2_ = self->priv->data;
	ft_matrix_fill (_tmp2_, value);
	ft_chart_queue_update ((FtChart*) self);
}

void
ft_bar_chart_set_values (FtBarChart* self,
                         guint bar_index,
                         gdouble* values,
                         gint values_length1)
{
	FtMatrix* _tmp0_;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	gint category_index = 0;
	g_return_if_fail (self != NULL);
	ft_bar_chart_grow_data (self, bar_index + 1, (guint) values_length1);
	_tmp0_ = self->priv->data;
	_tmp1_ = _tmp0_->shape;
	_tmp1__length1 = _tmp0_->shape_length1;
	_tmp2_ = _tmp1_[1];
	if (((guint) values_length1) > _tmp2_) {
		FtMatrix* _tmp3_;
		guint* _tmp4_;
		gint _tmp4__length1;
		guint _tmp5_;
		_tmp3_ = self->priv->data;
		_tmp4_ = _tmp3_->shape;
		_tmp4__length1 = _tmp3_->shape_length1;
		_tmp5_ = _tmp4_[1];
		g_warning ("bar-chart.vala:326: BarChart.set_values received a vector with length " \
"%d when there are only %u categories", values_length1, _tmp5_);
	}
	category_index = 0;
	{
		gboolean _tmp6_ = FALSE;
		_tmp6_ = TRUE;
		while (TRUE) {
			FtMatrix* _tmp8_;
			gdouble _tmp9_;
			if (!_tmp6_) {
				gint _tmp7_;
				_tmp7_ = category_index;
				category_index = _tmp7_ + 1;
			}
			_tmp6_ = FALSE;
			if (!(category_index < values_length1)) {
				break;
			}
			_tmp8_ = self->priv->data;
			_tmp9_ = values[category_index];
			ft_matrix_set (_tmp8_, (gint) bar_index, category_index, _tmp9_);
		}
	}
	{
		gboolean _tmp10_ = FALSE;
		_tmp10_ = TRUE;
		while (TRUE) {
			FtMatrix* _tmp12_;
			guint* _tmp13_;
			gint _tmp13__length1;
			guint _tmp14_;
			FtMatrix* _tmp15_;
			if (!_tmp10_) {
				gint _tmp11_;
				_tmp11_ = category_index;
				category_index = _tmp11_ + 1;
			}
			_tmp10_ = FALSE;
			_tmp12_ = self->priv->data;
			_tmp13_ = _tmp12_->shape;
			_tmp13__length1 = _tmp12_->shape_length1;
			_tmp14_ = _tmp13_[1];
			if (!(((guint) category_index) < _tmp14_)) {
				break;
			}
			_tmp15_ = self->priv->data;
			ft_matrix_set (_tmp15_, (gint) bar_index, category_index, 0.0);
		}
	}
	ft_chart_queue_update ((FtChart*) self);
}

gdouble
ft_bar_chart_get_value (FtBarChart* self,
                        guint bar_index,
                        guint category_index)
{
	gdouble _tmp0_ = 0.0;
	FtMatrix* _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp1_ = self->priv->data;
	if (_tmp1_ != NULL) {
		FtMatrix* _tmp2_;
		_tmp2_ = self->priv->data;
		_tmp0_ = ft_matrix_get (_tmp2_, (gint) bar_index, (gint) category_index, FT_BAR_CHART_DEFAULT_VALUE);
	} else {
		_tmp0_ = FT_BAR_CHART_DEFAULT_VALUE;
	}
	result = _tmp0_;
	return result;
}

void
ft_bar_chart_set_value (FtBarChart* self,
                        guint bar_index,
                        guint category_index,
                        gdouble value)
{
	FtMatrix* _tmp0_;
	gboolean _tmp1_ = FALSE;
	FtCategory* _tmp2_;
	gint _tmp2__length1;
	g_return_if_fail (self != NULL);
	ft_bar_chart_grow_data (self, bar_index + 1, category_index + 1);
	_tmp0_ = self->priv->data;
	ft_matrix_set (_tmp0_, (gint) bar_index, (gint) category_index, value);
	_tmp2_ = self->priv->categories;
	_tmp2__length1 = self->priv->categories_length1;
	if (category_index < ((guint) _tmp2__length1)) {
		FtCategory* _tmp3_;
		gint _tmp3__length1;
		FtCategory _tmp4_;
		_tmp3_ = self->priv->categories;
		_tmp3__length1 = self->priv->categories_length1;
		_tmp4_ = _tmp3_[category_index];
		_tmp1_ = _tmp4_.visible;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ft_chart_queue_update ((FtChart*) self);
	}
}

inline void
ft_bar_chart_add_value (FtBarChart* self,
                        guint bar_index,
                        guint category_index,
                        gdouble value)
{
	g_return_if_fail (self != NULL);
	ft_bar_chart_set_value (self, bar_index, category_index, value + ft_bar_chart_get_value (self, bar_index, category_index));
}

static gboolean
ft_bar_chart_on_query_tooltip (FtBarChart* self,
                               GtkWidget* widget,
                               gint x,
                               gint y,
                               gboolean keyboard_tooltip,
                               GtkTooltip* tooltip)
{
	guint bar_index = 0U;
	gconstpointer _tmp0_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (tooltip != NULL, FALSE);
	_tmp0_ = g_object_get_data ((GObject*) widget, "index");
	bar_index = (guint) ((guintptr) _tmp0_);
	if (((guint) self->priv->tooltip_bar_index) != bar_index) {
		GtkWidget* _tmp1_;
		self->priv->tooltip_bar_index = (gint) bar_index;
		_tmp1_ = ft_bar_chart_create_tooltip_widget (self, bar_index);
		_g_object_unref0 (self->priv->tooltip_widget);
		self->priv->tooltip_widget = _tmp1_;
	}
	_tmp2_ = self->priv->tooltip_widget;
	gtk_tooltip_set_custom (tooltip, _tmp2_);
	_tmp3_ = self->priv->tooltip_widget;
	result = _tmp3_ != NULL;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static GtkWidget*
ft_bar_chart_create_tooltip_widget (FtBarChart* self,
                                    guint bar_index)
{
	FtBucket bucket = {0};
	FtBucket* _tmp0_;
	gint _tmp0__length1;
	FtBucket _tmp1_;
	FtBucket _tmp2_;
	FtBucket _tmp3_ = {0};
	gint category_count = 0;
	FtCategory* _tmp4_;
	gint _tmp4__length1;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp5_;
	GtkGrid* _tmp6_;
	GtkGrid* _tmp7_;
	GtkGrid* _tmp8_;
	GtkGrid* _tmp9_;
	GtkLabel* header_label = NULL;
	FtBucket _tmp10_;
	const gchar* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkGrid* _tmp14_;
	GtkLabel* _tmp15_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->buckets;
	_tmp0__length1 = self->priv->buckets_length1;
	_tmp1_ = _tmp0_[bar_index];
	_tmp2_ = _tmp1_;
	ft_bucket_copy (&_tmp2_, &_tmp3_);
	bucket = _tmp3_;
	_tmp4_ = self->priv->categories;
	_tmp4__length1 = self->priv->categories_length1;
	category_count = _tmp4__length1;
	_tmp5_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp5_);
	grid = _tmp5_;
	_tmp6_ = grid;
	gtk_grid_set_column_spacing (_tmp6_, 10);
	_tmp7_ = grid;
	gtk_grid_set_row_spacing (_tmp7_, 5);
	_tmp8_ = grid;
	gtk_grid_set_row_homogeneous (_tmp8_, TRUE);
	_tmp9_ = grid;
	gtk_widget_add_css_class ((GtkWidget*) _tmp9_, "tooltip-contents");
	_tmp10_ = bucket;
	_tmp11_ = _tmp10_.tooltip_label;
	_tmp12_ = (GtkLabel*) gtk_label_new (_tmp11_);
	g_object_ref_sink (_tmp12_);
	header_label = _tmp12_;
	_tmp13_ = header_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp13_, "tooltip-header");
	_tmp14_ = grid;
	_tmp15_ = header_label;
	gtk_grid_attach (_tmp14_, (GtkWidget*) _tmp15_, 0, 0, 2, 1);
	{
		gint category_index = 0;
		category_index = category_count - 1;
		{
			gboolean _tmp16_ = FALSE;
			_tmp16_ = TRUE;
			while (TRUE) {
				FtCategory category = {0};
				FtCategory* _tmp18_;
				gint _tmp18__length1;
				FtCategory _tmp19_;
				FtCategory _tmp20_;
				FtCategory _tmp21_ = {0};
				gdouble category_value = 0.0;
				GtkLabel* category_label = NULL;
				FtCategory _tmp22_;
				const gchar* _tmp23_;
				const gchar* _tmp24_;
				gchar* _tmp25_;
				gchar* _tmp26_;
				GtkLabel* _tmp27_;
				GtkLabel* _tmp28_;
				GtkLabel* _tmp29_;
				GtkGrid* _tmp30_;
				GtkLabel* _tmp31_;
				GtkLabel* value_label = NULL;
				gchar* _tmp32_;
				gchar* _tmp33_;
				GtkLabel* _tmp34_;
				GtkLabel* _tmp35_;
				GtkLabel* _tmp36_;
				GtkGrid* _tmp37_;
				GtkLabel* _tmp38_;
				if (!_tmp16_) {
					gint _tmp17_;
					_tmp17_ = category_index;
					category_index = _tmp17_ - 1;
				}
				_tmp16_ = FALSE;
				if (!(category_index >= 0)) {
					break;
				}
				_tmp18_ = self->priv->categories;
				_tmp18__length1 = self->priv->categories_length1;
				_tmp19_ = _tmp18_[category_index];
				_tmp20_ = _tmp19_;
				ft_category_copy (&_tmp20_, &_tmp21_);
				category = _tmp21_;
				category_value = ft_bar_chart_get_value (self, bar_index, (guint) category_index);
				_tmp22_ = category;
				_tmp23_ = _tmp22_.label;
				_tmp24_ = string_to_string (_tmp23_);
				_tmp25_ = g_strconcat (_tmp24_, ":", NULL);
				_tmp26_ = _tmp25_;
				_tmp27_ = (GtkLabel*) gtk_label_new (_tmp26_);
				g_object_ref_sink (_tmp27_);
				_tmp28_ = _tmp27_;
				_g_free0 (_tmp26_);
				category_label = _tmp28_;
				_tmp29_ = category_label;
				gtk_widget_set_halign ((GtkWidget*) _tmp29_, GTK_ALIGN_START);
				_tmp30_ = grid;
				_tmp31_ = category_label;
				gtk_grid_attach (_tmp30_, (GtkWidget*) _tmp31_, 0, 1 + category_index, 1, 1);
				_tmp32_ = ft_bar_chart_format_tooltip_value (self, (guint) category_index, category_value);
				_tmp33_ = _tmp32_;
				_tmp34_ = (GtkLabel*) gtk_label_new (_tmp33_);
				g_object_ref_sink (_tmp34_);
				_tmp35_ = _tmp34_;
				_g_free0 (_tmp33_);
				value_label = _tmp35_;
				_tmp36_ = value_label;
				gtk_widget_set_halign ((GtkWidget*) _tmp36_, GTK_ALIGN_END);
				_tmp37_ = grid;
				_tmp38_ = value_label;
				gtk_grid_attach (_tmp37_, (GtkWidget*) _tmp38_, 1, 1 + category_index, 1, 1);
				_g_object_unref0 (value_label);
				_g_object_unref0 (category_label);
				ft_category_destroy (&category);
			}
		}
	}
	result = (GtkWidget*) grid;
	_g_object_unref0 (header_label);
	ft_bucket_destroy (&bucket);
	return result;
}

static void
_ft_bar_chart_measure_bar_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                    GtkOrientation orientation,
                                                    gint for_size,
                                                    gint* minimum,
                                                    gint* natural,
                                                    gint* minimum_baseline,
                                                    gint* natural_baseline,
                                                    gpointer self)
{
	ft_bar_chart_measure_bar_cb (gizmo, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
}

static void
_ft_bar_chart_snapshot_bar_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                      GtkSnapshot* snapshot,
                                                      gpointer self)
{
	ft_bar_chart_snapshot_bar_cb (gizmo, snapshot);
}

static gboolean
_ft_bar_chart_contains_bar_cb_ft_gizmo_contains_func (FtGizmo* gizmo,
                                                      gdouble x,
                                                      gdouble y,
                                                      gpointer self)
{
	gboolean result;
	result = ft_bar_chart_contains_bar_cb (gizmo, x, y);
	return result;
}

static gboolean
_ft_bar_chart_on_query_tooltip_cb_gtk_widget_query_tooltip (GtkWidget* _sender,
                                                            gint x,
                                                            gint y,
                                                            gboolean keyboard_tooltip,
                                                            GtkTooltip* tooltip,
                                                            gpointer self)
{
	gboolean result;
	result = ft_bar_chart_on_query_tooltip_cb (_sender, x, y, keyboard_tooltip, tooltip);
	return result;
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		FtBarChart* self;
		self = _data3_->self;
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
___lambda15_ (Block3Data* _data3_,
              gint n_press,
              gdouble x,
              gdouble y)
{
	FtBarChart* self;
	FtGizmo* _tmp0_;
	self = _data3_->self;
	_tmp0_ = _data3_->weak_bar;
	ft_bar_chart_on_clicked_cb ((GtkWidget*) _tmp0_);
}

static void
____lambda15__gtk_gesture_click_released (GtkGestureClick* _sender,
                                          gint n_press,
                                          gdouble x,
                                          gdouble y,
                                          gpointer self)
{
	___lambda15_ (self, n_press, x, y);
}

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

static GtkWidget*
ft_bar_chart_create_bar (FtBarChart* self)
{
	FtGizmo* bar = NULL;
	FtGizmo* _tmp0_;
	FtGizmo* _tmp1_;
	FtGizmo* _tmp2_;
	FtGizmo* _tmp3_;
	FtGizmo* _tmp4_;
	gboolean _tmp5_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ft_gizmo_new (_ft_bar_chart_measure_bar_cb_ft_gizmo_measure_func, NULL, NULL, NULL, NULL, NULL, _ft_bar_chart_snapshot_bar_cb_ft_gizmo_snapshot_func, NULL, NULL, _ft_bar_chart_contains_bar_cb_ft_gizmo_contains_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	g_object_ref_sink (_tmp0_);
	bar = _tmp0_;
	_tmp1_ = bar;
	gtk_widget_set_focusable ((GtkWidget*) _tmp1_, FALSE);
	_tmp2_ = bar;
	gtk_widget_set_has_tooltip ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = bar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp3_, "bar");
	_tmp4_ = bar;
	g_signal_connect ((GtkWidget*) _tmp4_, "query-tooltip", (GCallback) _ft_bar_chart_on_query_tooltip_cb_gtk_widget_query_tooltip, NULL);
	_tmp5_ = self->priv->_activate_on_click;
	if (_tmp5_) {
		Block3Data* _data3_;
		FtGizmo* _tmp6_;
		GtkGestureClick* click_gesture = NULL;
		GtkGestureClick* _tmp7_;
		GtkGestureClick* _tmp8_;
		GtkGestureClick* _tmp9_;
		FtGizmo* _tmp10_;
		GtkGestureClick* _tmp11_;
		GtkEventController* _tmp12_;
		_data3_ = g_slice_new0 (Block3Data);
		_data3_->_ref_count_ = 1;
		_data3_->self = g_object_ref (self);
		_tmp6_ = bar;
		_data3_->weak_bar = _tmp6_;
		_tmp7_ = (GtkGestureClick*) gtk_gesture_click_new ();
		click_gesture = _tmp7_;
		_tmp8_ = click_gesture;
		gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp8_, (guint) GDK_BUTTON_PRIMARY);
		_tmp9_ = click_gesture;
		g_signal_connect_data (_tmp9_, "released", (GCallback) ____lambda15__gtk_gesture_click_released, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
		_tmp10_ = bar;
		_tmp11_ = click_gesture;
		_tmp12_ = _g_object_ref0 ((GtkEventController*) _tmp11_);
		gtk_widget_add_controller ((GtkWidget*) _tmp10_, _tmp12_);
		_g_object_unref0 (click_gesture);
		block3_data_unref (_data3_);
		_data3_ = NULL;
	} else {
		FtGizmo* _tmp13_;
		_tmp13_ = bar;
		gtk_widget_set_state_flags ((GtkWidget*) _tmp13_, GTK_STATE_FLAG_INSENSITIVE, FALSE);
	}
	result = (GtkWidget*) bar;
	return result;
}

static FtBarChart*
ft_bar_chart_from_gizmo (FtGizmo* gizmo)
{
	GtkWidget* widget = NULL;
	GtkWidget* _tmp0_;
	FtBarChart* result;
	g_return_val_if_fail (gizmo != NULL, NULL);
	_tmp0_ = _g_object_ref0 ((GtkWidget*) gizmo);
	widget = _tmp0_;
	while (TRUE) {
		GtkWidget* _tmp1_;
		FtBarChart* chart = NULL;
		GtkWidget* _tmp2_;
		FtBarChart* _tmp3_;
		FtBarChart* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp1_ = widget;
		if (!(_tmp1_ != NULL)) {
			break;
		}
		_tmp2_ = widget;
		_tmp3_ = _g_object_ref0 (FT_IS_BAR_CHART (_tmp2_) ? ((FtBarChart*) _tmp2_) : NULL);
		chart = _tmp3_;
		_tmp4_ = chart;
		if (_tmp4_ != NULL) {
			result = chart;
			_g_object_unref0 (widget);
			return result;
		}
		_tmp5_ = widget;
		_tmp6_ = gtk_widget_get_parent (_tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		_g_object_unref0 (widget);
		widget = _tmp7_;
		_g_object_unref0 (chart);
	}
	result = NULL;
	_g_object_unref0 (widget);
	return result;
}

static FtBarChart*
ft_bar_chart_from_widget (GtkWidget* widget)
{
	GtkWidget* current = NULL;
	GtkWidget* _tmp0_;
	FtBarChart* result;
	g_return_val_if_fail (widget != NULL, NULL);
	_tmp0_ = _g_object_ref0 (widget);
	current = _tmp0_;
	while (TRUE) {
		GtkWidget* _tmp1_;
		FtBarChart* chart = NULL;
		GtkWidget* _tmp2_;
		FtBarChart* _tmp3_;
		FtBarChart* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp1_ = current;
		if (!(_tmp1_ != NULL)) {
			break;
		}
		_tmp2_ = current;
		_tmp3_ = _g_object_ref0 (FT_IS_BAR_CHART (_tmp2_) ? ((FtBarChart*) _tmp2_) : NULL);
		chart = _tmp3_;
		_tmp4_ = chart;
		if (_tmp4_ != NULL) {
			result = chart;
			_g_object_unref0 (current);
			return result;
		}
		_tmp5_ = current;
		_tmp6_ = gtk_widget_get_parent (_tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		_g_object_unref0 (current);
		current = _tmp7_;
		_g_object_unref0 (chart);
	}
	result = NULL;
	_g_object_unref0 (current);
	return result;
}

static void
ft_bar_chart_measure_bar_cb (FtGizmo* gizmo,
                             GtkOrientation orientation,
                             gint for_size,
                             gint* minimum,
                             gint* natural,
                             gint* minimum_baseline,
                             gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	FtBarChart* _self_ = NULL;
	FtBarChart* _tmp0_;
	FtBarChart* _tmp1_;
	g_return_if_fail (gizmo != NULL);
	_tmp0_ = ft_bar_chart_from_gizmo (gizmo);
	_self_ = _tmp0_;
	_tmp1_ = _self_;
	if (_tmp1_ != NULL) {
		FtBarChart* _tmp2_;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		_tmp2_ = _self_;
		ft_bar_chart_measure_bar (_tmp2_, gizmo, orientation, for_size, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
		_vala_minimum = _tmp3_;
		_vala_natural = _tmp4_;
		_vala_minimum_baseline = _tmp5_;
		_vala_natural_baseline = _tmp6_;
	} else {
		_vala_minimum = 0;
		_vala_natural = 0;
		_vala_minimum_baseline = -1;
		_vala_natural_baseline = -1;
	}
	_g_object_unref0 (_self_);
	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_bar_chart_snapshot_bar_cb (FtGizmo* gizmo,
                              GtkSnapshot* snapshot)
{
	FtBarChart* _self_ = NULL;
	FtBarChart* _tmp0_;
	FtBarChart* _tmp1_;
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = ft_bar_chart_from_gizmo (gizmo);
	_self_ = _tmp0_;
	_tmp1_ = _self_;
	if (_tmp1_ != NULL) {
		FtBarChart* _tmp2_;
		_tmp2_ = _self_;
		ft_bar_chart_snapshot_bar (_tmp2_, gizmo, snapshot);
	}
	_g_object_unref0 (_self_);
}

static gboolean
ft_bar_chart_contains_bar_cb (FtGizmo* gizmo,
                              gdouble x,
                              gdouble y)
{
	FtBarChart* _self_ = NULL;
	FtBarChart* _tmp0_;
	gboolean _tmp1_ = FALSE;
	FtBarChart* _tmp2_;
	gboolean result;
	g_return_val_if_fail (gizmo != NULL, FALSE);
	_tmp0_ = ft_bar_chart_from_gizmo (gizmo);
	_self_ = _tmp0_;
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtBarChart* _tmp3_;
		_tmp3_ = _self_;
		_tmp1_ = ft_bar_chart_contains_bar (_tmp3_, gizmo, x, y);
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	_g_object_unref0 (_self_);
	return result;
}

static gboolean
ft_bar_chart_on_query_tooltip_cb (GtkWidget* widget,
                                  gint x,
                                  gint y,
                                  gboolean keyboard_tooltip,
                                  GtkTooltip* tooltip)
{
	FtBarChart* _self_ = NULL;
	FtBarChart* _tmp0_;
	gboolean _tmp1_ = FALSE;
	FtBarChart* _tmp2_;
	gboolean result;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (tooltip != NULL, FALSE);
	_tmp0_ = ft_bar_chart_from_widget (widget);
	_self_ = _tmp0_;
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtBarChart* _tmp3_;
		_tmp3_ = _self_;
		_tmp1_ = ft_bar_chart_on_query_tooltip (_tmp3_, widget, x, y, keyboard_tooltip, tooltip);
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	_g_object_unref0 (_self_);
	return result;
}

static void
ft_bar_chart_on_clicked_cb (GtkWidget* widget)
{
	FtBarChart* _self_ = NULL;
	FtBarChart* _tmp0_;
	guint bar_index = 0U;
	gconstpointer _tmp1_;
	FtBarChart* _tmp2_;
	g_return_if_fail (widget != NULL);
	_tmp0_ = ft_bar_chart_from_gizmo (G_TYPE_CHECK_INSTANCE_CAST (widget, FT_TYPE_GIZMO, FtGizmo));
	_self_ = _tmp0_;
	_tmp1_ = g_object_get_data ((GObject*) widget, "index");
	bar_index = (guint) ((guintptr) _tmp1_);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtBarChart* _tmp3_;
		_tmp3_ = _self_;
		g_signal_emit (_tmp3_, ft_bar_chart_signals[FT_BAR_CHART_BAR_ACTIVATED_SIGNAL], 0, bar_index);
	}
	_g_object_unref0 (_self_);
}

static inline void
ft_bar_chart_update_bar (FtBarChart* self,
                         GtkWidget* bar,
                         guint bar_index)
{
	FtCanvasLayoutChild* layout_child = NULL;
	FtChartContents* _tmp0_;
	FtCanvas* _tmp1_;
	FtCanvas* _tmp2_;
	FtCanvasLayoutChild* _tmp3_;
	FtCanvasLayoutChild* _tmp4_;
	FtCanvasLayoutChild* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (bar != NULL);
	g_object_set_data_full ((GObject*) bar, "index", (gpointer) ((guintptr) bar_index), NULL);
	_tmp0_ = ((FtChart*) self)->contents;
	_tmp1_ = ft_chart_contents_get_canvas (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = ft_canvas_get_layout_child (_tmp2_, bar);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	layout_child = _tmp4_;
	_tmp5_ = layout_child;
	if (_tmp5_ != NULL) {
		gdouble total_value = 0.0;
		gdouble bar_x = 0.0;
		FtCanvasLayoutChild* _tmp6_;
		FtCanvasLayoutChild* _tmp7_;
		FtCanvasLayoutChild* _tmp8_;
		total_value = ft_bar_chart_calculate_bucket_total_value (self, bar_index);
		bar_x = (((gdouble) bar_index) * self->priv->transform_slope) + self->priv->transform_intercept;
		_tmp6_ = layout_child;
		ft_canvas_layout_child_set_x (_tmp6_, (gfloat) bar_x);
		_tmp7_ = layout_child;
		ft_canvas_layout_child_set_y (_tmp7_, 0.0f);
		_tmp8_ = layout_child;
		ft_canvas_layout_child_set_range (_tmp8_, (gfloat) bar_x, (gfloat) bar_x, 0.0f, (gfloat) total_value);
	}
	_g_object_unref0 (layout_child);
}

static void
ft_bar_chart_measure_bar (FtBarChart* self,
                          FtGizmo* gizmo,
                          GtkOrientation orientation,
                          gint for_size,
                          gint* minimum,
                          gint* natural,
                          gint* minimum_baseline,
                          gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		_tmp0_ = self->priv->bar_width;
	} else {
		_tmp0_ = self->priv->bar_height;
	}
	_vala_minimum = _tmp0_;
	_vala_natural = _vala_minimum;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	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_bar_chart_snapshot_bar (FtBarChart* self,
                           FtGizmo* gizmo,
                           GtkSnapshot* snapshot)
{
	guint bar_index = 0U;
	gconstpointer _tmp0_;
	FtMatrix* _tmp1_;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gint category_count = 0;
	FtMatrix* _tmp7_;
	guint* _tmp8_;
	gint _tmp8__length1;
	guint _tmp9_;
	FtCategory* _tmp10_;
	gint _tmp10__length1;
	gdouble base_value = 0.0;
	gfloat bar_width = 0.0F;
	gfloat bar_height = 0.0F;
	gdouble y_scale = 0.0;
	FtChartContents* _tmp11_;
	FtCanvas* _tmp12_;
	FtCanvas* _tmp13_;
	gfloat _tmp14_;
	gfloat _tmp15_;
	gboolean is_shown = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = g_object_get_data ((GObject*) gizmo, "index");
	bar_index = (guint) ((guintptr) _tmp0_);
	_tmp1_ = self->priv->data;
	_tmp2_ = _tmp1_->shape;
	_tmp2__length1 = _tmp1_->shape_length1;
	_tmp3_ = _tmp2_[0];
	if (bar_index >= _tmp3_) {
		g_warning ("bar-chart.vala:608: Unable to snapshot bar %u: No data", bar_index);
		return;
	}
	_tmp5_ = ft_bar_chart_get_show_empty_bars (self);
	_tmp6_ = _tmp5_;
	if (!_tmp6_) {
		_tmp4_ = ft_bar_chart_is_bucket_empty (self, bar_index);
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		return;
	}
	_tmp7_ = self->priv->data;
	_tmp8_ = _tmp7_->shape;
	_tmp8__length1 = _tmp7_->shape_length1;
	_tmp9_ = _tmp8_[1];
	_tmp10_ = self->priv->categories;
	_tmp10__length1 = self->priv->categories_length1;
	category_count = MIN ((gint) _tmp9_, _tmp10__length1);
	base_value = 0.0;
	bar_width = (gfloat) self->priv->bar_width;
	bar_height = (gfloat) self->priv->bar_height;
	_tmp11_ = ((FtChart*) self)->contents;
	_tmp12_ = ft_chart_contents_get_canvas (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = ft_canvas_get_y_scale (_tmp13_);
	_tmp15_ = _tmp14_;
	y_scale = (gdouble) _tmp15_;
	is_shown = FALSE;
	if (self->priv->_stacked) {
		{
			gint category_index = 0;
			category_index = 0;
			{
				gboolean _tmp16_ = FALSE;
				_tmp16_ = TRUE;
				while (TRUE) {
					gdouble category_value = 0.0;
					if (!_tmp16_) {
						gint _tmp17_;
						_tmp17_ = category_index;
						category_index = _tmp17_ + 1;
					}
					_tmp16_ = FALSE;
					if (!(category_index < category_count)) {
						break;
					}
					category_value = ft_bar_chart_get_value (self, bar_index, (guint) category_index);
					if (isfinite (category_value)) {
						base_value += category_value;
					}
				}
			}
		}
	}
	{
		gint category_index = 0;
		category_index = category_count - 1;
		{
			gboolean _tmp18_ = FALSE;
			_tmp18_ = TRUE;
			while (TRUE) {
				gdouble category_value = 0.0;
				GdkRGBA category_color = {0};
				FtCategory* _tmp20_;
				gint _tmp20__length1;
				FtCategory _tmp21_;
				GdkRGBA _tmp22_;
				gboolean _tmp23_ = FALSE;
				graphene_rect_t bounds = {0};
				GskRoundedRect outline = {0};
				graphene_rect_t _tmp25_;
				GskRoundedRect _tmp26_;
				GdkRGBA _tmp27_;
				graphene_rect_t _tmp28_;
				if (!_tmp18_) {
					gint _tmp19_;
					_tmp19_ = category_index;
					category_index = _tmp19_ - 1;
				}
				_tmp18_ = FALSE;
				if (!(category_index >= 0)) {
					break;
				}
				category_value = ft_bar_chart_get_value (self, bar_index, (guint) category_index);
				_tmp20_ = self->priv->categories;
				_tmp20__length1 = self->priv->categories_length1;
				_tmp21_ = _tmp20_[category_index];
				_tmp22_ = _tmp21_.color;
				category_color = _tmp22_;
				if (!isfinite (category_value)) {
					continue;
				}
				if (!self->priv->_stacked) {
					base_value = category_value;
				}
				if ((category_value * y_scale) <= 0.0) {
					gboolean _tmp24_ = FALSE;
					if (category_index != 0) {
						_tmp24_ = TRUE;
					} else {
						_tmp24_ = is_shown;
					}
					_tmp23_ = _tmp24_;
				} else {
					_tmp23_ = FALSE;
				}
				if (_tmp23_) {
					base_value -= category_value;
					continue;
				}
				memset (&bounds, 0, sizeof (graphene_rect_t));
				graphene_rect_init (&bounds, 0.0f, (bar_height - bar_width) - ((gfloat) (base_value * y_scale)), bar_width, ((gfloat) (category_value * y_scale)) + bar_width);
				memset (&outline, 0, sizeof (GskRoundedRect));
				_tmp25_ = bounds;
				gsk_rounded_rect_init_from_rect (&outline, &_tmp25_, bar_width / 2.0f);
				_tmp26_ = outline;
				gtk_snapshot_push_rounded_clip (snapshot, &_tmp26_);
				_tmp27_ = category_color;
				_tmp28_ = bounds;
				gtk_snapshot_append_color (snapshot, &_tmp27_, &_tmp28_);
				gtk_snapshot_pop (snapshot);
				base_value -= category_value;
				is_shown = TRUE;
			}
		}
	}
}

static gboolean
ft_bar_chart_contains_bar (FtBarChart* self,
                           FtGizmo* gizmo,
                           gdouble x,
                           gdouble y)
{
	graphene_point_t point = {0};
	graphene_point_t _tmp0_ = {0};
	graphene_rect_t bounds = {0};
	gboolean _tmp1_ = FALSE;
	graphene_rect_t _tmp2_ = {0};
	gboolean _tmp3_;
	guint bar_index = 0U;
	gconstpointer _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gfloat total_value = 0.0F;
	FtChartContents* _tmp9_;
	FtCanvas* _tmp10_;
	FtCanvas* _tmp11_;
	graphene_point_t _tmp12_;
	graphene_point_t _tmp13_ = {0};
	graphene_point_t _tmp14_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (gizmo != NULL, FALSE);
	if (!gtk_widget_get_mapped ((GtkWidget*) gizmo)) {
		result = FALSE;
		return result;
	}
	memset (&_tmp0_, 0, sizeof (graphene_point_t));
	_tmp0_.x = (gfloat) x;
	_tmp0_.y = (gfloat) y;
	point = _tmp0_;
	_tmp3_ = gtk_widget_compute_bounds ((GtkWidget*) gizmo, (GtkWidget*) gizmo, &_tmp2_);
	bounds = _tmp2_;
	if (!_tmp3_) {
		_tmp1_ = TRUE;
	} else {
		graphene_point_t _tmp4_;
		_tmp4_ = point;
		_tmp1_ = !graphene_rect_contains_point (&bounds, &_tmp4_);
	}
	if (_tmp1_) {
		result = FALSE;
		return result;
	}
	_tmp5_ = g_object_get_data ((GObject*) gizmo, "index");
	bar_index = (guint) ((guintptr) _tmp5_);
	_tmp7_ = ft_bar_chart_get_show_empty_bars (self);
	_tmp8_ = _tmp7_;
	if (!_tmp8_) {
		_tmp6_ = ft_bar_chart_is_bucket_empty (self, bar_index);
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		result = FALSE;
		return result;
	}
	total_value = (gfloat) ft_bar_chart_calculate_bucket_total_value (self, bar_index);
	point.y = point.y + (self->priv->bar_radius + FT_BAR_CHART_BAR_HIT_ZONE_PADDING);
	_tmp9_ = ((FtChart*) self)->contents;
	_tmp10_ = ft_chart_contents_get_canvas (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = point;
	ft_canvas_transform_point (_tmp11_, &_tmp12_, &_tmp13_);
	point = _tmp13_;
	_tmp14_ = point;
	result = _tmp14_.y <= total_value;
	return result;
}

static inline void
ft_bar_chart_foreach_bar (FtBarChart* self,
                          GFunc func,
                          gpointer func_target)
{
	GtkWidget* child = NULL;
	FtChartContents* _tmp0_;
	FtCanvas* _tmp1_;
	FtCanvas* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ((FtChart*) self)->contents;
	_tmp1_ = ft_chart_contents_get_canvas (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_widget_get_first_child ((GtkWidget*) _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	child = _tmp4_;
	while (TRUE) {
		GtkWidget* _tmp5_;
		GtkWidget* next_child = NULL;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		_tmp5_ = child;
		if (!(_tmp5_ != NULL)) {
			break;
		}
		_tmp6_ = child;
		_tmp7_ = gtk_widget_get_next_sibling (_tmp6_);
		_tmp8_ = _g_object_ref0 (_tmp7_);
		next_child = _tmp8_;
		_tmp9_ = child;
		func (_tmp9_, func_target);
		_tmp10_ = next_child;
		_tmp11_ = _g_object_ref0 (_tmp10_);
		_g_object_unref0 (child);
		child = _tmp11_;
		_g_object_unref0 (next_child);
	}
	_g_object_unref0 (child);
}

/**
         * Charts `width` depends more on content and can be scrolled horizontally.
         * `height` is determined by the `Chart` using aspect-ratio.
         */
static GtkSizeRequestMode
ft_bar_chart_real_get_contents_request_mode (FtChart* base,
                                             FtCanvas* canvas)
{
	FtBarChart * self;
	GtkSizeRequestMode result;
	self = (FtBarChart*) base;
	g_return_val_if_fail (canvas != NULL, 0);
	result = GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
	return result;
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		FtBarChart* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->canvas);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static void
__lambda16_ (Block4Data* _data4_,
             GtkWidget* bar)
{
	FtBarChart* self;
	self = _data4_->self;
	g_return_if_fail (bar != NULL);
	if (_data4_->bar_index < _data4_->bars_count) {
		guint _tmp0_;
		ft_bar_chart_update_bar (self, bar, _data4_->bar_index);
		_tmp0_ = _data4_->bar_index;
		_data4_->bar_index = _tmp0_ + 1;
	} else {
		ft_canvas_remove_child (_data4_->canvas, bar);
	}
}

static void
___lambda16__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda16_ (self, (GtkWidget*) data);
}

static void
ft_bar_chart_real_update_canvas (FtChart* base,
                                 FtCanvas* canvas)
{
	FtBarChart * self;
	Block4Data* _data4_;
	FtCanvas* _tmp0_;
	self = (FtBarChart*) base;
	g_return_if_fail (canvas != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (canvas);
	_g_object_unref0 (_data4_->canvas);
	_data4_->canvas = _tmp0_;
	_data4_->bars_count = ft_bar_chart_get_bars_count (self);
	_data4_->bar_index = 0U;
	ft_bar_chart_foreach_bar (self, ___lambda16__gfunc, _data4_);
	while (TRUE) {
		GtkWidget* bar = NULL;
		GtkWidget* _tmp1_;
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		guint _tmp4_;
		if (!(_data4_->bar_index < _data4_->bars_count)) {
			break;
		}
		_tmp1_ = ft_bar_chart_create_bar (self);
		bar = _tmp1_;
		_tmp2_ = bar;
		ft_canvas_add_child (_data4_->canvas, _tmp2_, 0.0f, 0.0f);
		_tmp3_ = bar;
		ft_bar_chart_update_bar (self, _tmp3_, _data4_->bar_index);
		_tmp4_ = _data4_->bar_index;
		_data4_->bar_index = _tmp4_ + 1;
		_g_object_unref0 (bar);
	}
	ft_chart_set_x_spacing ((FtChart*) self, (gfloat) self->priv->transform_slope);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

static void
ft_bar_chart_real_measure_canvas (FtChart* base,
                                  FtCanvas* canvas,
                                  GtkOrientation orientation,
                                  gint for_size,
                                  gint* minimum,
                                  gint* natural)
{
	FtBarChart * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	self = (FtBarChart*) base;
	g_return_if_fail (canvas != NULL);
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		gint bars_count = 0;
		FtBucket* _tmp0_;
		gint _tmp0__length1;
		gint label_width = 0;
		FtChartContents* _tmp1_;
		FtChartAxis* _tmp2_;
		FtChartAxis* _tmp3_;
		gint min_margins = 0;
		gint max_margins = 0;
		gint max_bar_spacing = 0;
		gint min_width = 0;
		gint max_width = 0;
		gint nat_width = 0;
		gint _tmp4_ = 0;
		gint segment_width = 0;
		gint bar_spacing = 0;
		gint bar_width = 0;
		_tmp0_ = self->priv->buckets;
		_tmp0__length1 = self->priv->buckets_length1;
		bars_count = (gint) _tmp0__length1;
		_tmp1_ = ((FtChart*) self)->contents;
		_tmp2_ = ft_chart_contents_get_x_axis (_tmp1_);
		_tmp3_ = _tmp2_;
		label_width = _tmp3_->label_width;
		min_margins = MAX (label_width - FT_BAR_CHART_MIN_BAR_WIDTH, 0);
		max_margins = MAX (label_width - FT_BAR_CHART_MAX_BAR_WIDTH, 0);
		max_bar_spacing = MAX ((gint) floorf (((gfloat) FT_BAR_CHART_MAX_BAR_WIDTH) * FT_BAR_CHART_BAR_SPACING), FT_BAR_CHART_MIN_BAR_SPACING);
		min_width = (((FT_BAR_CHART_MIN_BAR_WIDTH + FT_BAR_CHART_MIN_BAR_SPACING) * bars_count) - FT_BAR_CHART_MIN_BAR_SPACING) + min_margins;
		max_width = (((FT_BAR_CHART_MAX_BAR_WIDTH + max_bar_spacing) * bars_count) - max_bar_spacing) + max_margins;
		nat_width = (gint) roundf (FT_BAR_CHART_ASPECT_RATIO * ((gfloat) max_width));
		if (bars_count != 0) {
			_tmp4_ = nat_width / bars_count;
		} else {
			_tmp4_ = 0;
		}
		segment_width = _tmp4_;
		bar_spacing = MAX ((gint) floorf (FT_BAR_CHART_BAR_SPACING * ((gfloat) segment_width)), FT_BAR_CHART_MIN_BAR_SPACING);
		bar_width = MIN (segment_width - bar_spacing, FT_BAR_CHART_MAX_BAR_WIDTH);
		_vala_minimum = min_width;
		_vala_natural = (bars_count * (bar_width + bar_spacing)) - bar_spacing;
	} else {
		gint _tmp5_;
		gint _tmp6_;
		g_object_get ((GtkWidget*) self, "height-request", &_tmp5_, NULL);
		_tmp6_ = _tmp5_;
		_vala_minimum = _tmp6_;
		_vala_natural = _vala_minimum;
	}
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		FtBarChart* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->canvas);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static void
__lambda17_ (Block5Data* _data5_,
             GtkWidget* bar)
{
	FtBarChart* self;
	FtCanvasLayoutChild* layout_child = NULL;
	FtCanvasLayoutChild* _tmp0_;
	FtCanvasLayoutChild* _tmp1_;
	FtCanvasLayoutChild* _tmp2_;
	self = _data5_->self;
	g_return_if_fail (bar != NULL);
	_tmp0_ = ft_canvas_get_layout_child (_data5_->canvas, bar);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	layout_child = _tmp1_;
	_tmp2_ = layout_child;
	if (_tmp2_ != NULL) {
		FtCanvasLayoutChild* _tmp3_;
		FtCanvasLayoutChild* _tmp4_;
		_tmp3_ = layout_child;
		ft_canvas_layout_child_set_x_origin (_tmp3_, self->priv->bar_radius);
		_tmp4_ = layout_child;
		ft_canvas_layout_child_set_y_origin (_tmp4_, self->priv->bar_height - self->priv->bar_radius);
	}
	_g_object_unref0 (layout_child);
}

static void
___lambda17__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda17_ (self, (GtkWidget*) data);
}

static void
ft_bar_chart_real_measure_working_area (FtChart* base,
                                        FtCanvas* canvas,
                                        gint available_width,
                                        gint available_height,
                                        GdkRectangle* working_area)
{
	FtBarChart * self;
	GdkRectangle _vala_working_area = {0};
	Block5Data* _data5_;
	FtCanvas* _tmp0_;
	gint bars_count = 0;
	gint _tmp1_ = 0;
	gint segment_width = 0;
	gint bar_spacing = 0;
	gint bar_width = 0;
	gint bar_height = 0;
	gint bar_radius = 0;
	GdkRectangle _tmp2_ = {0};
	self = (FtBarChart*) base;
	g_return_if_fail (canvas != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (canvas);
	_g_object_unref0 (_data5_->canvas);
	_data5_->canvas = _tmp0_;
	bars_count = (gint) ft_bar_chart_get_bars_count (self);
	if (bars_count != 0) {
		_tmp1_ = available_width / bars_count;
	} else {
		_tmp1_ = 0;
	}
	segment_width = _tmp1_;
	bar_spacing = MAX ((gint) floorf (FT_BAR_CHART_BAR_SPACING * ((gfloat) segment_width)), FT_BAR_CHART_MIN_BAR_SPACING);
	bar_width = MIN (segment_width - bar_spacing, FT_BAR_CHART_MAX_BAR_WIDTH);
	bar_height = available_height;
	bar_radius = bar_width / 2;
	memset (&_tmp2_, 0, sizeof (GdkRectangle));
	_tmp2_.x = bar_width / 2;
	_tmp2_.y = bar_width - bar_radius;
	_tmp2_.width = segment_width * (bars_count - 1);
	_tmp2_.height = bar_height - (2 * bar_radius);
	_vala_working_area = _tmp2_;
	self->priv->bar_width = bar_width;
	self->priv->bar_height = bar_height;
	self->priv->bar_radius = bar_radius;
	ft_bar_chart_foreach_bar (self, ___lambda17__gfunc, _data5_);
	if (working_area) {
		*working_area = _vala_working_area;
	}
	block5_data_unref (_data5_);
	_data5_ = NULL;
}

/**
         * Modify bars `x` position to concrete values rather than bar indices. Used for zooming.
         */
void
ft_bar_chart_set_transform (FtBarChart* self,
                            gdouble slope,
                            gdouble intercept)
{
	g_return_if_fail (self != NULL);
	self->priv->transform_slope = slope;
	self->priv->transform_intercept = intercept;
}

static gchar*
ft_bar_chart_real_format_x_value (FtChart* base,
                                  gdouble value)
{
	FtBarChart * self;
	gint bar_index = 0;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gchar* _tmp6_;
	gchar* result;
	self = (FtBarChart*) base;
	bar_index = (gint) round ((value - self->priv->transform_intercept) / self->priv->transform_slope);
	if (bar_index >= 0) {
		FtBucket* _tmp2_;
		gint _tmp2__length1;
		_tmp2_ = self->priv->buckets;
		_tmp2__length1 = self->priv->buckets_length1;
		_tmp1_ = bar_index < _tmp2__length1;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		FtBucket* _tmp3_;
		gint _tmp3__length1;
		FtBucket _tmp4_;
		const gchar* _tmp5_;
		_tmp3_ = self->priv->buckets;
		_tmp3__length1 = self->priv->buckets_length1;
		_tmp4_ = _tmp3_[bar_index];
		_tmp5_ = _tmp4_.label;
		_tmp0_ = _tmp5_;
	} else {
		_tmp0_ = "∅";
	}
	_tmp6_ = g_strdup (_tmp0_);
	result = _tmp6_;
	return result;
}

static gchar*
ft_bar_chart_format_tooltip_value (FtBarChart* self,
                                   guint category_index,
                                   gdouble value)
{
	gchar* _tmp0_ = NULL;
	FtCategory* _tmp1_;
	gint _tmp1__length1;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->categories;
	_tmp1__length1 = self->priv->categories_length1;
	if (category_index < ((guint) _tmp1__length1)) {
		FtCategory* _tmp2_;
		gint _tmp2__length1;
		FtCategory _tmp3_;
		gchar* _tmp4_;
		_tmp2_ = self->priv->categories;
		_tmp2__length1 = self->priv->categories_length1;
		_tmp3_ = _tmp2_[category_index];
		_tmp4_ = ft_unit_format (_tmp3_.unit, value);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp4_;
	} else {
		gchar* _tmp5_;
		_tmp5_ = g_strdup_printf ("%.2f", value);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp5_;
	}
	_tmp6_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp6_;
	_g_free0 (_tmp0_);
	return result;
}

static void
ft_bar_chart_real_dispose (GObject* base)
{
	FtBarChart * self;
	GtkWidget* _tmp0_;
	self = (FtBarChart*) base;
	_tmp0_ = self->priv->tooltip_widget;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->tooltip_widget;
		gtk_widget_unparent (_tmp1_);
		_g_object_unref0 (self->priv->tooltip_widget);
		self->priv->tooltip_widget = NULL;
	}
	_ft_matrix_free0 (self->priv->data);
	self->priv->data = NULL;
	self->priv->categories = (_vala_FtCategory_array_free (self->priv->categories, self->priv->categories_length1), NULL);
	self->priv->categories = NULL;
	self->priv->categories_length1 = 0;
	self->priv->_categories_size_ = self->priv->categories_length1;
	self->priv->buckets = (_vala_FtBucket_array_free (self->priv->buckets, self->priv->buckets_length1), NULL);
	self->priv->buckets = NULL;
	self->priv->buckets_length1 = 0;
	self->priv->_buckets_size_ = self->priv->buckets_length1;
	_g_object_unref0 (self->priv->tooltip_widget);
	self->priv->tooltip_widget = NULL;
	G_OBJECT_CLASS (ft_bar_chart_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_CHART, FtChart));
}

FtBarChart*
ft_bar_chart_construct (GType object_type)
{
	FtBarChart * self = NULL;
	self = (FtBarChart*) ft_chart_construct (object_type);
	return self;
}

FtBarChart*
ft_bar_chart_new (void)
{
	return ft_bar_chart_construct (FT_TYPE_BAR_CHART);
}

gboolean
ft_bar_chart_get_stacked (FtBarChart* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_stacked;
	return result;
}

void
ft_bar_chart_set_stacked (FtBarChart* self,
                          gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_stacked == value) {
		return;
	}
	self->priv->_stacked = value;
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_bar_chart_properties[FT_BAR_CHART_STACKED_PROPERTY]);
}

gboolean
ft_bar_chart_get_show_empty_bars (FtBarChart* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_show_empty_bars;
	return result;
}

void
ft_bar_chart_set_show_empty_bars (FtBarChart* self,
                                  gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_show_empty_bars == value) {
		return;
	}
	self->priv->_show_empty_bars = value;
	gtk_widget_queue_draw ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_bar_chart_properties[FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY]);
}

gboolean
ft_bar_chart_get_activate_on_click (FtBarChart* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_activate_on_click;
	return result;
}

void
ft_bar_chart_set_activate_on_click (FtBarChart* self,
                                    gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_bar_chart_get_activate_on_click (self);
	if (old_value != value) {
		self->priv->_activate_on_click = value;
		g_object_notify_by_pspec ((GObject *) self, ft_bar_chart_properties[FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY]);
	}
}

gfloat
ft_bar_chart_get_reference_value (FtBarChart* self)
{
	gfloat result;
	FtChartContents* _tmp0_;
	gfloat _tmp1_;
	gfloat _tmp2_;
	g_return_val_if_fail (self != NULL, -1.0F);
	_tmp0_ = ((FtChart*) self)->contents;
	_tmp1_ = ft_chart_contents_get_y_value_to (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
ft_bar_chart_set_reference_value (FtBarChart* self,
                                  gfloat value)
{
	FtChartContents* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ((FtChart*) self)->contents;
	ft_chart_contents_set_y_value_to (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, ft_bar_chart_properties[FT_BAR_CHART_REFERENCE_VALUE_PROPERTY]);
}

static GObject *
ft_bar_chart_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtBarChart * self;
	FtBucket* _tmp0_;
	FtCategory* _tmp1_;
	FtChartContents* _tmp2_;
	FtChartGrid* _tmp3_;
	FtChartGrid* _tmp4_;
	FtChartContents* _tmp5_;
	FtChartAxis* _tmp6_;
	FtChartAxis* _tmp7_;
	FtChartContents* _tmp8_;
	FtChartContents* _tmp9_;
	parent_class = G_OBJECT_CLASS (ft_bar_chart_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_BAR_CHART, FtBarChart);
	_tmp0_ = g_new0 (FtBucket, 0);
	self->priv->buckets = (_vala_FtBucket_array_free (self->priv->buckets, self->priv->buckets_length1), NULL);
	self->priv->buckets = _tmp0_;
	self->priv->buckets_length1 = 0;
	self->priv->_buckets_size_ = self->priv->buckets_length1;
	_tmp1_ = g_new0 (FtCategory, 0);
	self->priv->categories = (_vala_FtCategory_array_free (self->priv->categories, self->priv->categories_length1), NULL);
	self->priv->categories = _tmp1_;
	self->priv->categories_length1 = 0;
	self->priv->_categories_size_ = self->priv->categories_length1;
	_tmp2_ = ((FtChart*) self)->contents;
	_tmp3_ = ft_chart_contents_get_grid (_tmp2_);
	_tmp4_ = _tmp3_;
	ft_chart_grid_set_vertical (_tmp4_, FALSE);
	_tmp5_ = ((FtChart*) self)->contents;
	_tmp6_ = ft_chart_contents_get_x_axis (_tmp5_);
	_tmp7_ = _tmp6_;
	ft_chart_axis_set_continous (_tmp7_, FALSE);
	_tmp8_ = ((FtChart*) self)->contents;
	ft_chart_contents_set_y_value_from (_tmp8_, 0.0f);
	_tmp9_ = ((FtChart*) self)->contents;
	ft_chart_contents_set_y_value_to (_tmp9_, NAN);
	return obj;
}

static void
ft_bar_chart_class_init (FtBarChartClass * klass,
                         gpointer klass_data)
{
	ft_bar_chart_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtBarChart_private_offset);
	((FtChartClass *) klass)->get_contents_request_mode = (GtkSizeRequestMode (*) (FtChart*, FtCanvas*)) ft_bar_chart_real_get_contents_request_mode;
	((FtChartClass *) klass)->update_canvas = (void (*) (FtChart*, FtCanvas*)) ft_bar_chart_real_update_canvas;
	((FtChartClass *) klass)->measure_canvas = (void (*) (FtChart*, FtCanvas*, GtkOrientation, gint, gint*, gint*)) ft_bar_chart_real_measure_canvas;
	((FtChartClass *) klass)->measure_working_area = (void (*) (FtChart*, FtCanvas*, gint, gint, GdkRectangle*)) ft_bar_chart_real_measure_working_area;
	((FtChartClass *) klass)->format_x_value = (gchar* (*) (FtChart*, gdouble)) ft_bar_chart_real_format_x_value;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_bar_chart_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_bar_chart_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_bar_chart_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_bar_chart_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_bar_chart_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BAR_CHART_STACKED_PROPERTY, ft_bar_chart_properties[FT_BAR_CHART_STACKED_PROPERTY] = g_param_spec_boolean ("stacked", "stacked", "stacked", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY, ft_bar_chart_properties[FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY] = g_param_spec_boolean ("show-empty-bars", "show-empty-bars", "show-empty-bars", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY, ft_bar_chart_properties[FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY] = g_param_spec_boolean ("activate-on-click", "activate-on-click", "activate-on-click", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BAR_CHART_REFERENCE_VALUE_PROPERTY, ft_bar_chart_properties[FT_BAR_CHART_REFERENCE_VALUE_PROPERTY] = g_param_spec_float ("reference-value", "reference-value", "reference-value", -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	ft_bar_chart_signals[FT_BAR_CHART_BAR_ACTIVATED_SIGNAL] = g_signal_new ("bar-activated", FT_TYPE_BAR_CHART, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
}

static void
ft_bar_chart_instance_init (FtBarChart * self,
                            gpointer klass)
{
	self->priv = ft_bar_chart_get_instance_private (self);
	self->priv->_activate_on_click = FALSE;
	self->priv->_stacked = TRUE;
	self->priv->_show_empty_bars = FALSE;
	self->priv->transform_slope = 1.0;
	self->priv->transform_intercept = 0.0;
	self->priv->tooltip_bar_index = -1;
}

static void
ft_bar_chart_finalize (GObject * obj)
{
	FtBarChart * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_BAR_CHART, FtBarChart);
	self->priv->buckets = (_vala_FtBucket_array_free (self->priv->buckets, self->priv->buckets_length1), NULL);
	self->priv->categories = (_vala_FtCategory_array_free (self->priv->categories, self->priv->categories_length1), NULL);
	_ft_matrix_free0 (self->priv->data);
	_g_object_unref0 (self->priv->tooltip_widget);
	G_OBJECT_CLASS (ft_bar_chart_parent_class)->finalize (obj);
}

/**
     * Widget for displaying a bar chart or a histogram.
     */
static GType
ft_bar_chart_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtBarChartClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_bar_chart_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtBarChart), 0, (GInstanceInitFunc) ft_bar_chart_instance_init, NULL };
	GType ft_bar_chart_type_id;
	ft_bar_chart_type_id = g_type_register_static (FT_TYPE_CHART, "FtBarChart", &g_define_type_info, 0);
	FtBarChart_private_offset = g_type_add_instance_private (ft_bar_chart_type_id, sizeof (FtBarChartPrivate));
	return ft_bar_chart_type_id;
}

GType
ft_bar_chart_get_type (void)
{
	static volatile gsize ft_bar_chart_type_id__once = 0;
	if (g_once_init_enter (&ft_bar_chart_type_id__once)) {
		GType ft_bar_chart_type_id;
		ft_bar_chart_type_id = ft_bar_chart_get_type_once ();
		g_once_init_leave (&ft_bar_chart_type_id__once, ft_bar_chart_type_id);
	}
	return ft_bar_chart_type_id__once;
}

static void
_vala_ft_bar_chart_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	FtBarChart * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_BAR_CHART, FtBarChart);
	switch (property_id) {
		case FT_BAR_CHART_STACKED_PROPERTY:
		g_value_set_boolean (value, ft_bar_chart_get_stacked (self));
		break;
		case FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY:
		g_value_set_boolean (value, ft_bar_chart_get_show_empty_bars (self));
		break;
		case FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY:
		g_value_set_boolean (value, ft_bar_chart_get_activate_on_click (self));
		break;
		case FT_BAR_CHART_REFERENCE_VALUE_PROPERTY:
		g_value_set_float (value, ft_bar_chart_get_reference_value (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_bar_chart_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	FtBarChart * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_BAR_CHART, FtBarChart);
	switch (property_id) {
		case FT_BAR_CHART_STACKED_PROPERTY:
		ft_bar_chart_set_stacked (self, g_value_get_boolean (value));
		break;
		case FT_BAR_CHART_SHOW_EMPTY_BARS_PROPERTY:
		ft_bar_chart_set_show_empty_bars (self, g_value_get_boolean (value));
		break;
		case FT_BAR_CHART_ACTIVATE_ON_CLICK_PROPERTY:
		ft_bar_chart_set_activate_on_click (self, g_value_get_boolean (value));
		break;
		case FT_BAR_CHART_REFERENCE_VALUE_PROPERTY:
		ft_bar_chart_set_reference_value (self, g_value_get_float (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

