/* baobab-ringschart.c generated by valac 0.29.3.14-c8b1, the Vala compiler
 * generated from baobab-ringschart.vala, do not modify */

/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Baobab - disk usage analyzer
 *
 * Copyright (C) 2008  Igalia
 * Copyright (C) 2013  Stefano Facchini <stefano.facchini@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 *
 * Authors of the original code:
 *   Felipe Erias <femorandeira@igalia.com>
 *   Pablo Santamaria <psantamaria@igalia.com>
 *   Jacobo Aragunde <jaragunde@igalia.com>
 *   Eduardo Lima <elima@igalia.com>
 *   Mario Sanchez <msanchez@igalia.com>
 *   Miguel Gomez <magomez@igalia.com>
 *   Henrique Ferreiro <hferreiro@igalia.com>
 *   Alejandro Pinheiro <apinheiro@igalia.com>
 *   Carlos Sanmartin <csanmartin@igalia.com>
 *   Alejandro Garcia <alex@igalia.com>
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <cairo.h>
#include <pango/pango.h>


#define BAOBAB_TYPE_CHART_ITEM (baobab_chart_item_get_type ())
#define BAOBAB_CHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_CHART_ITEM, BaobabChartItem))
#define BAOBAB_CHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_CHART_ITEM, BaobabChartItemClass))
#define BAOBAB_IS_CHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_CHART_ITEM))
#define BAOBAB_IS_CHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_CHART_ITEM))
#define BAOBAB_CHART_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_CHART_ITEM, BaobabChartItemClass))

typedef struct _BaobabChartItem BaobabChartItem;
typedef struct _BaobabChartItemClass BaobabChartItemClass;
typedef struct _BaobabChartItemPrivate BaobabChartItemPrivate;

#define BAOBAB_TYPE_RINGSCHART_ITEM (baobab_ringschart_item_get_type ())
#define BAOBAB_RINGSCHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_RINGSCHART_ITEM, BaobabRingschartItem))
#define BAOBAB_RINGSCHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_RINGSCHART_ITEM, BaobabRingschartItemClass))
#define BAOBAB_IS_RINGSCHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_RINGSCHART_ITEM))
#define BAOBAB_IS_RINGSCHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_RINGSCHART_ITEM))
#define BAOBAB_RINGSCHART_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_RINGSCHART_ITEM, BaobabRingschartItemClass))

typedef struct _BaobabRingschartItem BaobabRingschartItem;
typedef struct _BaobabRingschartItemClass BaobabRingschartItemClass;
typedef struct _BaobabRingschartItemPrivate BaobabRingschartItemPrivate;

#define BAOBAB_TYPE_CHART (baobab_chart_get_type ())
#define BAOBAB_CHART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_CHART, BaobabChart))
#define BAOBAB_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_CHART, BaobabChartClass))
#define BAOBAB_IS_CHART(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_CHART))
#define BAOBAB_IS_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_CHART))
#define BAOBAB_CHART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_CHART, BaobabChartClass))

typedef struct _BaobabChart BaobabChart;
typedef struct _BaobabChartClass BaobabChartClass;
typedef struct _BaobabChartPrivate BaobabChartPrivate;

#define BAOBAB_TYPE_RINGSCHART (baobab_ringschart_get_type ())
#define BAOBAB_RINGSCHART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_RINGSCHART, BaobabRingschart))
#define BAOBAB_RINGSCHART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_RINGSCHART, BaobabRingschartClass))
#define BAOBAB_IS_RINGSCHART(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_RINGSCHART))
#define BAOBAB_IS_RINGSCHART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_RINGSCHART))
#define BAOBAB_RINGSCHART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_RINGSCHART, BaobabRingschartClass))

typedef struct _BaobabRingschart BaobabRingschart;
typedef struct _BaobabRingschartClass BaobabRingschartClass;
typedef struct _BaobabRingschartPrivate BaobabRingschartPrivate;
#define __g_list_free__baobab_chart_item_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__baobab_chart_item_unref0_ (var), NULL)))
#define _baobab_chart_item_unref0(var) ((var == NULL) ? NULL : (var = (baobab_chart_item_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BaobabChartItem {
	GTypeInstance parent_instance;
	volatile int ref_count;
	BaobabChartItemPrivate * priv;
	gchar* name;
	gchar* size;
	guint depth;
	gdouble rel_start;
	gdouble rel_size;
	GtkTreeIter iter;
	gboolean visible;
	gboolean has_any_child;
	gboolean has_visible_children;
	GdkRectangle rect;
	GList* parent;
};

struct _BaobabChartItemClass {
	GTypeClass parent_class;
	void (*finalize) (BaobabChartItem *self);
};

struct _BaobabRingschartItem {
	BaobabChartItem parent_instance;
	BaobabRingschartItemPrivate * priv;
	gdouble min_radius;
	gdouble max_radius;
	gdouble start_angle;
	gdouble angle;
	gboolean continued;
};

struct _BaobabRingschartItemClass {
	BaobabChartItemClass parent_class;
};

struct _BaobabChart {
	GtkDrawingArea parent_instance;
	BaobabChartPrivate * priv;
};

struct _BaobabChartClass {
	GtkDrawingAreaClass parent_class;
	void (*post_draw) (BaobabChart* self, cairo_t* cr);
	void (*draw_item) (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted);
	void (*calculate_item_geometry) (BaobabChart* self, BaobabChartItem* item);
	gboolean (*is_point_over_item) (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y);
	void (*get_item_rectangle) (BaobabChart* self, BaobabChartItem* item);
	gboolean (*can_zoom_in) (BaobabChart* self);
	gboolean (*can_zoom_out) (BaobabChart* self);
	BaobabChartItem* (*create_new_chartitem) (BaobabChart* self);
	void (*item_activated) (BaobabChart* self, GtkTreeIter* iter);
};

struct _BaobabRingschart {
	BaobabChart parent_instance;
	BaobabRingschartPrivate * priv;
};

struct _BaobabRingschartClass {
	BaobabChartClass parent_class;
};

struct _BaobabRingschartPrivate {
	guint tips_timeout_id;
	gboolean drawing_subtips;
	GList* subtip_items;
};


static gpointer baobab_ringschart_item_parent_class = NULL;
static gpointer baobab_ringschart_parent_class = NULL;

gpointer baobab_chart_item_ref (gpointer instance);
void baobab_chart_item_unref (gpointer instance);
GParamSpec* baobab_param_spec_chart_item (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void baobab_value_set_chart_item (GValue* value, gpointer v_object);
void baobab_value_take_chart_item (GValue* value, gpointer v_object);
gpointer baobab_value_get_chart_item (const GValue* value);
GType baobab_chart_item_get_type (void) G_GNUC_CONST;
GType baobab_ringschart_item_get_type (void) G_GNUC_CONST;
enum  {
	BAOBAB_RINGSCHART_ITEM_DUMMY_PROPERTY
};
BaobabRingschartItem* baobab_ringschart_item_new (void);
BaobabRingschartItem* baobab_ringschart_item_construct (GType object_type);
BaobabChartItem* baobab_chart_item_construct (GType object_type);
static void baobab_ringschart_item_finalize (BaobabChartItem* obj);
GType baobab_chart_get_type (void) G_GNUC_CONST;
GType baobab_ringschart_get_type (void) G_GNUC_CONST;
#define BAOBAB_RINGSCHART_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAOBAB_TYPE_RINGSCHART, BaobabRingschartPrivate))
enum  {
	BAOBAB_RINGSCHART_DUMMY_PROPERTY
};
static void _baobab_chart_item_unref0_ (gpointer var);
static void _g_list_free__baobab_chart_item_unref0_ (GList* self);
#define BAOBAB_RINGSCHART_ITEM_BORDER_WIDTH 1
#define BAOBAB_RINGSCHART_ITEM_MIN_ANGLE 0.03
#define BAOBAB_RINGSCHART_EDGE_ANGLE 0.004
#define BAOBAB_RINGSCHART_SUBTIP_TIMEOUT 1000
static void baobab_ringschart_subtips_update (BaobabRingschart* self);
BaobabChartItem* baobab_chart_get_highlighted_item (BaobabChart* self);
static gboolean ___lambda21_ (BaobabRingschart* self);
static gboolean ____lambda21__gsource_func (gpointer self);
static BaobabChartItem* baobab_ringschart_real_create_new_chartitem (BaobabChart* base);
static void baobab_ringschart_real_post_draw (BaobabChart* base, cairo_t* cr);
static void baobab_ringschart_real_draw_item (BaobabChart* base, cairo_t* cr, BaobabChartItem* item, gboolean highlighted);
void baobab_chart_get_item_color (BaobabChart* self, gdouble rel_position, guint depth, gboolean highlighted, GdkRGBA* result);
static void baobab_ringschart_real_calculate_item_geometry (BaobabChart* base, BaobabChartItem* item);
guint baobab_chart_get_max_depth (BaobabChart* self);
void baobab_chart_get_item_rectangle (BaobabChart* self, BaobabChartItem* item);
static void baobab_ringschart_get_point_min_rect (BaobabRingschart* self, gdouble cx, gdouble cy, gdouble radius, gdouble angle, GdkRectangle* r);
static void baobab_ringschart_real_get_item_rectangle (BaobabChart* base, BaobabChartItem* item);
static gboolean baobab_ringschart_real_is_point_over_item (BaobabChart* base, BaobabChartItem* item, gdouble x, gdouble y);
static gboolean baobab_ringschart_real_can_zoom_out (BaobabChart* base);
#define BAOBAB_CHART_MAX_DEPTH ((guint) 5)
static gboolean baobab_ringschart_real_can_zoom_in (BaobabChart* base);
#define BAOBAB_CHART_MIN_DEPTH ((guint) 1)
BaobabRingschart* baobab_ringschart_new (void);
BaobabRingschart* baobab_ringschart_construct (GType object_type);
BaobabChart* baobab_chart_construct (GType object_type);
static GObject * baobab_ringschart_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _baobab_ringschart_subtips_update_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void baobab_ringschart_finalize (GObject* obj);


BaobabRingschartItem* baobab_ringschart_item_construct (GType object_type) {
	BaobabRingschartItem* self = NULL;
	self = (BaobabRingschartItem*) baobab_chart_item_construct (object_type);
	return self;
}


BaobabRingschartItem* baobab_ringschart_item_new (void) {
	return baobab_ringschart_item_construct (BAOBAB_TYPE_RINGSCHART_ITEM);
}


static void baobab_ringschart_item_class_init (BaobabRingschartItemClass * klass) {
	baobab_ringschart_item_parent_class = g_type_class_peek_parent (klass);
	((BaobabChartItemClass *) klass)->finalize = baobab_ringschart_item_finalize;
}


static void baobab_ringschart_item_instance_init (BaobabRingschartItem * self) {
}


static void baobab_ringschart_item_finalize (BaobabChartItem* obj) {
	BaobabRingschartItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_RINGSCHART_ITEM, BaobabRingschartItem);
	BAOBAB_CHART_ITEM_CLASS (baobab_ringschart_item_parent_class)->finalize (obj);
}


GType baobab_ringschart_item_get_type (void) {
	static volatile gsize baobab_ringschart_item_type_id__volatile = 0;
	if (g_once_init_enter (&baobab_ringschart_item_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BaobabRingschartItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) baobab_ringschart_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BaobabRingschartItem), 0, (GInstanceInitFunc) baobab_ringschart_item_instance_init, NULL };
		GType baobab_ringschart_item_type_id;
		baobab_ringschart_item_type_id = g_type_register_static (BAOBAB_TYPE_CHART_ITEM, "BaobabRingschartItem", &g_define_type_info, 0);
		g_once_init_leave (&baobab_ringschart_item_type_id__volatile, baobab_ringschart_item_type_id);
	}
	return baobab_ringschart_item_type_id__volatile;
}


static void _baobab_chart_item_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (baobab_chart_item_unref (var), NULL));
}


static void _g_list_free__baobab_chart_item_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _baobab_chart_item_unref0_, NULL);
	g_list_free (self);
}


static gboolean ___lambda21_ (BaobabRingschart* self) {
	gboolean result = FALSE;
	self->priv->drawing_subtips = TRUE;
	self->priv->tips_timeout_id = (guint) 0;
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}


static gboolean ____lambda21__gsource_func (gpointer self) {
	gboolean result;
	result = ___lambda21_ ((BaobabRingschart*) self);
	return result;
}


static void baobab_ringschart_subtips_update (BaobabRingschart* self) {
	gboolean _tmp0_ = FALSE;
	guint _tmp1_ = 0U;
	BaobabChartItem* _tmp3_ = NULL;
	BaobabChartItem* _tmp4_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->drawing_subtips;
	if (_tmp0_) {
		gtk_widget_queue_draw ((GtkWidget*) self);
	}
	self->priv->drawing_subtips = FALSE;
	_tmp1_ = self->priv->tips_timeout_id;
	if (_tmp1_ != ((guint) 0)) {
		guint _tmp2_ = 0U;
		_tmp2_ = self->priv->tips_timeout_id;
		g_source_remove (_tmp2_);
		self->priv->tips_timeout_id = (guint) 0;
	}
	__g_list_free__baobab_chart_item_unref0_0 (self->priv->subtip_items);
	self->priv->subtip_items = NULL;
	_tmp3_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != NULL) {
		guint _tmp5_ = 0U;
		_tmp5_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) BAOBAB_RINGSCHART_SUBTIP_TIMEOUT, ____lambda21__gsource_func, g_object_ref (self), g_object_unref);
		self->priv->tips_timeout_id = _tmp5_;
	}
}


static BaobabChartItem* baobab_ringschart_real_create_new_chartitem (BaobabChart* base) {
	BaobabRingschart * self;
	BaobabChartItem* result = NULL;
	BaobabRingschartItem* _tmp0_ = NULL;
	BaobabChartItem* _tmp1_ = NULL;
	self = (BaobabRingschart*) base;
	_tmp0_ = baobab_ringschart_item_new ();
	_tmp1_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_CHART_ITEM) ? ((BaobabChartItem*) _tmp0_) : NULL;
	if (_tmp1_ == NULL) {
		_baobab_chart_item_unref0 (_tmp0_);
	}
	result = _tmp1_;
	return result;
}


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


static gpointer _baobab_chart_item_ref0 (gpointer self) {
	return self ? baobab_chart_item_ref (self) : NULL;
}


static void baobab_ringschart_real_post_draw (BaobabChart* base, cairo_t* cr) {
	BaobabRingschart * self;
	gboolean _tmp0_ = FALSE;
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	GtkStyleContext* _tmp2_ = NULL;
	GtkStateFlags context_state = 0;
	GtkStyleContext* _tmp3_ = NULL;
	GtkStateFlags _tmp4_ = 0;
	GtkStyleContext* _tmp5_ = NULL;
	GtkStyleContext* _tmp6_ = NULL;
	GtkStyleContext* _tmp7_ = NULL;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp8_ = {0};
	gint q_width = 0;
	GtkAllocation _tmp9_ = {0};
	gint _tmp10_ = 0;
	gint q_height = 0;
	GtkAllocation _tmp11_ = {0};
	gint _tmp12_ = 0;
	gdouble q_angle = 0.0;
	gint _tmp13_ = 0;
	gint _tmp14_ = 0;
	gdouble _tmp15_ = 0.0;
	GdkRectangle last_rect = {0};
	GtkBorder padding = {0};
	GtkStyleContext* _tmp16_ = NULL;
	GtkStateFlags _tmp17_ = 0;
	GtkBorder _tmp18_ = {0};
	gint16 vpadding = 0;
	GtkBorder _tmp19_ = {0};
	gint16 _tmp20_ = 0;
	GtkBorder _tmp21_ = {0};
	gint16 _tmp22_ = 0;
	gint16 hpadding = 0;
	GtkBorder _tmp23_ = {0};
	gint16 _tmp24_ = 0;
	GtkBorder _tmp25_ = {0};
	gint16 _tmp26_ = 0;
	GList* _tmp27_ = NULL;
	GtkStyleContext* _tmp213_ = NULL;
	self = (BaobabRingschart*) base;
	g_return_if_fail (cr != NULL);
	_tmp0_ = self->priv->drawing_subtips;
	if (!_tmp0_) {
		return;
	}
	_tmp1_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	context = _tmp2_;
	_tmp3_ = context;
	_tmp4_ = gtk_style_context_get_state (_tmp3_);
	context_state = _tmp4_;
	_tmp5_ = context;
	gtk_style_context_save (_tmp5_);
	_tmp6_ = context;
	gtk_style_context_add_class (_tmp6_, "subfolder-tip");
	_tmp7_ = context;
	gtk_style_context_add_class (_tmp7_, "tooltip");
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp8_);
	allocation = _tmp8_;
	_tmp9_ = allocation;
	_tmp10_ = _tmp9_.width;
	q_width = _tmp10_ / 2;
	_tmp11_ = allocation;
	_tmp12_ = _tmp11_.height;
	q_height = _tmp12_ / 2;
	_tmp13_ = q_height;
	_tmp14_ = q_width;
	_tmp15_ = atan2 ((gdouble) _tmp13_, (gdouble) _tmp14_);
	q_angle = _tmp15_;
	memset (&last_rect, 0, sizeof (GdkRectangle));
	_tmp16_ = context;
	_tmp17_ = context_state;
	gtk_style_context_get_padding (_tmp16_, _tmp17_, &_tmp18_);
	padding = _tmp18_;
	_tmp19_ = padding;
	_tmp20_ = _tmp19_.top;
	_tmp21_ = padding;
	_tmp22_ = _tmp21_.bottom;
	vpadding = _tmp20_ + _tmp22_;
	_tmp23_ = padding;
	_tmp24_ = _tmp23_.left;
	_tmp25_ = padding;
	_tmp26_ = _tmp25_.right;
	hpadding = _tmp24_ + _tmp26_;
	_tmp27_ = self->priv->subtip_items;
	{
		GList* item_collection = NULL;
		GList* item_it = NULL;
		item_collection = _tmp27_;
		for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
			BaobabChartItem* _tmp28_ = NULL;
			BaobabChartItem* item = NULL;
			_tmp28_ = _baobab_chart_item_ref0 ((BaobabChartItem*) item_it->data);
			item = _tmp28_;
			{
				BaobabRingschartItem* ringsitem = NULL;
				BaobabChartItem* _tmp29_ = NULL;
				BaobabRingschartItem* _tmp30_ = NULL;
				gdouble middle_angle = 0.0;
				BaobabRingschartItem* _tmp31_ = NULL;
				gdouble _tmp32_ = 0.0;
				BaobabRingschartItem* _tmp33_ = NULL;
				gdouble _tmp34_ = 0.0;
				gdouble middle_angle_n = 0.0;
				gdouble _tmp35_ = 0.0;
				gdouble _tmp38_ = 0.0;
				gdouble _tmp39_ = 0.0;
				PangoLayout* layout = NULL;
				PangoLayout* _tmp40_ = NULL;
				gchar* markup = NULL;
				BaobabChartItem* _tmp41_ = NULL;
				const gchar* _tmp42_ = NULL;
				gchar* _tmp43_ = NULL;
				gchar* _tmp44_ = NULL;
				gchar* _tmp45_ = NULL;
				gchar* _tmp46_ = NULL;
				gchar* _tmp47_ = NULL;
				gchar* _tmp48_ = NULL;
				PangoLayout* _tmp49_ = NULL;
				const gchar* _tmp50_ = NULL;
				PangoLayout* _tmp51_ = NULL;
				PangoLayout* _tmp52_ = NULL;
				PangoLayout* _tmp53_ = NULL;
				gint _tmp54_ = 0;
				PangoLayout* _tmp55_ = NULL;
				PangoRectangle layout_rect = {0};
				PangoLayout* _tmp56_ = NULL;
				PangoRectangle _tmp57_ = {0};
				gdouble tip_x = 0.0;
				gdouble tip_y = 0.0;
				gdouble _tmp58_ = 0.0;
				gdouble _tmp59_ = 0.0;
				cairo_rectangle_t tooltip_rect = {0};
				gint _tmp74_ = 0;
				gdouble _tmp75_ = 0.0;
				PangoRectangle _tmp76_ = {0};
				gint _tmp77_ = 0;
				GtkBorder _tmp78_ = {0};
				gint16 _tmp79_ = 0;
				gint _tmp80_ = 0;
				gdouble _tmp81_ = 0.0;
				PangoRectangle _tmp82_ = {0};
				gint _tmp83_ = 0;
				GtkBorder _tmp84_ = {0};
				gint16 _tmp85_ = 0;
				PangoRectangle _tmp86_ = {0};
				gint _tmp87_ = 0;
				gint16 _tmp88_ = 0;
				PangoRectangle _tmp89_ = {0};
				gint _tmp90_ = 0;
				gint16 _tmp91_ = 0;
				gdouble a = 0.0;
				gdouble _tmp92_ = 0.0;
				gint i = 0;
				GdkRectangle _rect = {0};
				cairo_rectangle_t _tmp109_ = {0};
				gdouble _tmp110_ = 0.0;
				cairo_rectangle_t _tmp111_ = {0};
				gdouble _tmp112_ = 0.0;
				cairo_rectangle_t _tmp113_ = {0};
				gdouble _tmp114_ = 0.0;
				cairo_rectangle_t _tmp115_ = {0};
				gdouble _tmp116_ = 0.0;
				GdkRectangle _tmp117_ = {0};
				gboolean _tmp118_ = FALSE;
				_tmp29_ = item;
				_tmp30_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp29_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp29_) : NULL);
				ringsitem = _tmp30_;
				_tmp31_ = ringsitem;
				_tmp32_ = _tmp31_->start_angle;
				_tmp33_ = ringsitem;
				_tmp34_ = _tmp33_->angle;
				middle_angle = _tmp32_ + (_tmp34_ / 2);
				_tmp35_ = middle_angle;
				middle_angle_n = _tmp35_;
				while (TRUE) {
					gdouble _tmp36_ = 0.0;
					gdouble _tmp37_ = 0.0;
					_tmp36_ = middle_angle_n;
					if (!(_tmp36_ > (G_PI / 2))) {
						break;
					}
					_tmp37_ = middle_angle_n;
					middle_angle_n = _tmp37_ - G_PI;
				}
				_tmp38_ = middle_angle_n;
				_tmp39_ = fabs (_tmp38_);
				middle_angle_n = _tmp39_;
				_tmp40_ = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
				layout = _tmp40_;
				_tmp41_ = item;
				_tmp42_ = _tmp41_->name;
				_tmp43_ = g_markup_escape_text (_tmp42_, (gssize) -1);
				_tmp44_ = _tmp43_;
				_tmp45_ = g_strconcat ("<span size=\"small\">", _tmp44_, NULL);
				_tmp46_ = _tmp45_;
				_tmp47_ = g_strconcat (_tmp46_, "</span>", NULL);
				_tmp48_ = _tmp47_;
				_g_free0 (_tmp46_);
				_g_free0 (_tmp44_);
				markup = _tmp48_;
				_tmp49_ = layout;
				_tmp50_ = markup;
				pango_layout_set_markup (_tmp49_, _tmp50_, -1);
				_tmp51_ = layout;
				pango_layout_set_indent (_tmp51_, 0);
				_tmp52_ = layout;
				pango_layout_set_spacing (_tmp52_, 0);
				_tmp53_ = layout;
				_tmp54_ = q_width;
				pango_layout_set_width (_tmp53_, (PANGO_SCALE * _tmp54_) / 2);
				_tmp55_ = layout;
				pango_layout_set_ellipsize (_tmp55_, PANGO_ELLIPSIZE_END);
				_tmp56_ = layout;
				pango_layout_get_pixel_extents (_tmp56_, NULL, &_tmp57_);
				layout_rect = _tmp57_;
				_tmp58_ = middle_angle_n;
				_tmp59_ = q_angle;
				if (_tmp58_ < _tmp59_) {
					gint _tmp60_ = 0;
					PangoRectangle _tmp61_ = {0};
					gint _tmp62_ = 0;
					gint16 _tmp63_ = 0;
					gdouble _tmp64_ = 0.0;
					gdouble _tmp65_ = 0.0;
					gdouble _tmp66_ = 0.0;
					_tmp60_ = q_width;
					_tmp61_ = layout_rect;
					_tmp62_ = _tmp61_.width;
					_tmp63_ = hpadding;
					tip_x = (gdouble) ((_tmp60_ - (_tmp62_ / 2)) - _tmp63_);
					_tmp64_ = middle_angle_n;
					_tmp65_ = tan (_tmp64_);
					_tmp66_ = tip_x;
					tip_y = _tmp65_ * _tmp66_;
				} else {
					gint _tmp67_ = 0;
					PangoRectangle _tmp68_ = {0};
					gint _tmp69_ = 0;
					gint16 _tmp70_ = 0;
					gdouble _tmp71_ = 0.0;
					gdouble _tmp72_ = 0.0;
					gdouble _tmp73_ = 0.0;
					_tmp67_ = q_height;
					_tmp68_ = layout_rect;
					_tmp69_ = _tmp68_.height;
					_tmp70_ = vpadding;
					tip_y = (gdouble) ((_tmp67_ - (_tmp69_ / 2)) - _tmp70_);
					_tmp71_ = tip_y;
					_tmp72_ = middle_angle_n;
					_tmp73_ = tan (_tmp72_);
					tip_x = _tmp71_ / _tmp73_;
				}
				memset (&tooltip_rect, 0, sizeof (cairo_rectangle_t));
				_tmp74_ = q_width;
				_tmp75_ = tip_x;
				_tmp76_ = layout_rect;
				_tmp77_ = _tmp76_.width;
				_tmp78_ = padding;
				_tmp79_ = _tmp78_.left;
				tooltip_rect.x = ((_tmp74_ + _tmp75_) - (_tmp77_ / 2)) - _tmp79_;
				_tmp80_ = q_height;
				_tmp81_ = tip_y;
				_tmp82_ = layout_rect;
				_tmp83_ = _tmp82_.height;
				_tmp84_ = padding;
				_tmp85_ = _tmp84_.top;
				tooltip_rect.y = ((_tmp80_ + _tmp81_) - (_tmp83_ / 2)) - _tmp85_;
				_tmp86_ = layout_rect;
				_tmp87_ = _tmp86_.width;
				_tmp88_ = hpadding;
				tooltip_rect.width = (gdouble) (_tmp87_ + _tmp88_);
				_tmp89_ = layout_rect;
				_tmp90_ = _tmp89_.height;
				_tmp91_ = vpadding;
				tooltip_rect.height = (gdouble) (_tmp90_ + _tmp91_);
				_tmp92_ = middle_angle;
				a = _tmp92_;
				i = 0;
				while (TRUE) {
					gdouble _tmp93_ = 0.0;
					gint _tmp94_ = 0;
					gint _tmp107_ = 0;
					gdouble _tmp108_ = 0.0;
					_tmp93_ = a;
					if (!(_tmp93_ > (G_PI / 2))) {
						break;
					}
					_tmp94_ = i;
					if ((_tmp94_ % 2) == 0) {
						GtkAllocation _tmp95_ = {0};
						gint _tmp96_ = 0;
						cairo_rectangle_t _tmp97_ = {0};
						gdouble _tmp98_ = 0.0;
						cairo_rectangle_t _tmp99_ = {0};
						gdouble _tmp100_ = 0.0;
						_tmp95_ = allocation;
						_tmp96_ = _tmp95_.width;
						_tmp97_ = tooltip_rect;
						_tmp98_ = _tmp97_.x;
						_tmp99_ = tooltip_rect;
						_tmp100_ = _tmp99_.width;
						tooltip_rect.x = (_tmp96_ - _tmp98_) - _tmp100_;
					} else {
						GtkAllocation _tmp101_ = {0};
						gint _tmp102_ = 0;
						cairo_rectangle_t _tmp103_ = {0};
						gdouble _tmp104_ = 0.0;
						cairo_rectangle_t _tmp105_ = {0};
						gdouble _tmp106_ = 0.0;
						_tmp101_ = allocation;
						_tmp102_ = _tmp101_.height;
						_tmp103_ = tooltip_rect;
						_tmp104_ = _tmp103_.y;
						_tmp105_ = tooltip_rect;
						_tmp106_ = _tmp105_.height;
						tooltip_rect.y = (_tmp102_ - _tmp104_) - _tmp106_;
					}
					_tmp107_ = i;
					i = _tmp107_ + 1;
					_tmp108_ = a;
					a = _tmp108_ - (G_PI / 2);
				}
				memset (&_rect, 0, sizeof (GdkRectangle));
				_tmp109_ = tooltip_rect;
				_tmp110_ = _tmp109_.x;
				_rect.x = (gint) (_tmp110_ - 1);
				_tmp111_ = tooltip_rect;
				_tmp112_ = _tmp111_.y;
				_rect.y = (gint) (_tmp112_ - 1);
				_tmp113_ = tooltip_rect;
				_tmp114_ = _tmp113_.width;
				_rect.width = (gint) (_tmp114_ + 2);
				_tmp115_ = tooltip_rect;
				_tmp116_ = _tmp115_.height;
				_rect.height = (gint) (_tmp116_ + 2);
				_tmp117_ = last_rect;
				_tmp118_ = gdk_rectangle_intersect (&_rect, &_tmp117_, NULL);
				if (!_tmp118_) {
					GdkRectangle _tmp119_ = {0};
					cairo_rectangle_t _tmp120_ = {0};
					gdouble _tmp121_ = 0.0;
					gdouble _tmp122_ = 0.0;
					cairo_rectangle_t _tmp123_ = {0};
					gdouble _tmp124_ = 0.0;
					gdouble _tmp125_ = 0.0;
					gdouble middle_radius = 0.0;
					BaobabRingschartItem* _tmp126_ = NULL;
					gdouble _tmp127_ = 0.0;
					BaobabRingschartItem* _tmp128_ = NULL;
					gdouble _tmp129_ = 0.0;
					BaobabRingschartItem* _tmp130_ = NULL;
					gdouble _tmp131_ = 0.0;
					gdouble sector_center_x = 0.0;
					gint _tmp132_ = 0;
					gdouble _tmp133_ = 0.0;
					gdouble _tmp134_ = 0.0;
					gdouble _tmp135_ = 0.0;
					gdouble sector_center_y = 0.0;
					gint _tmp136_ = 0;
					gdouble _tmp137_ = 0.0;
					gdouble _tmp138_ = 0.0;
					gdouble _tmp139_ = 0.0;
					cairo_t* _tmp140_ = NULL;
					cairo_t* _tmp141_ = NULL;
					GtkAllocation _tmp142_ = {0};
					gint _tmp143_ = 0;
					GtkAllocation _tmp144_ = {0};
					gint _tmp145_ = 0;
					cairo_t* _tmp146_ = NULL;
					cairo_rectangle_t _tmp147_ = {0};
					gdouble _tmp148_ = 0.0;
					cairo_rectangle_t _tmp149_ = {0};
					gdouble _tmp150_ = 0.0;
					cairo_rectangle_t _tmp151_ = {0};
					gdouble _tmp152_ = 0.0;
					cairo_rectangle_t _tmp153_ = {0};
					gdouble _tmp154_ = 0.0;
					cairo_rectangle_t _tmp155_ = {0};
					gdouble _tmp156_ = 0.0;
					cairo_t* _tmp157_ = NULL;
					GdkRGBA bg_color = {0};
					GtkStyleContext* _tmp158_ = NULL;
					GtkStateFlags _tmp159_ = 0;
					GdkRGBA _tmp160_ = {0};
					cairo_t* _tmp161_ = NULL;
					cairo_t* _tmp162_ = NULL;
					gdouble _tmp163_ = 0.0;
					gdouble _tmp164_ = 0.0;
					cairo_t* _tmp165_ = NULL;
					GdkRGBA _tmp166_ = {0};
					cairo_t* _tmp167_ = NULL;
					cairo_rectangle_t _tmp168_ = {0};
					gdouble _tmp169_ = 0.0;
					cairo_rectangle_t _tmp170_ = {0};
					gdouble _tmp171_ = 0.0;
					cairo_rectangle_t _tmp172_ = {0};
					gdouble _tmp173_ = 0.0;
					cairo_rectangle_t _tmp174_ = {0};
					gdouble _tmp175_ = 0.0;
					cairo_t* _tmp176_ = NULL;
					cairo_t* _tmp177_ = NULL;
					cairo_t* _tmp178_ = NULL;
					gdouble _tmp179_ = 0.0;
					gdouble _tmp180_ = 0.0;
					cairo_t* _tmp181_ = NULL;
					GtkStyleContext* _tmp182_ = NULL;
					cairo_t* _tmp183_ = NULL;
					cairo_rectangle_t _tmp184_ = {0};
					gdouble _tmp185_ = 0.0;
					cairo_rectangle_t _tmp186_ = {0};
					gdouble _tmp187_ = 0.0;
					cairo_rectangle_t _tmp188_ = {0};
					gdouble _tmp189_ = 0.0;
					cairo_rectangle_t _tmp190_ = {0};
					gdouble _tmp191_ = 0.0;
					GtkStyleContext* _tmp192_ = NULL;
					cairo_t* _tmp193_ = NULL;
					cairo_rectangle_t _tmp194_ = {0};
					gdouble _tmp195_ = 0.0;
					cairo_rectangle_t _tmp196_ = {0};
					gdouble _tmp197_ = 0.0;
					cairo_rectangle_t _tmp198_ = {0};
					gdouble _tmp199_ = 0.0;
					cairo_rectangle_t _tmp200_ = {0};
					gdouble _tmp201_ = 0.0;
					GtkStyleContext* _tmp202_ = NULL;
					cairo_t* _tmp203_ = NULL;
					cairo_rectangle_t _tmp204_ = {0};
					gdouble _tmp205_ = 0.0;
					GtkBorder _tmp206_ = {0};
					gint16 _tmp207_ = 0;
					cairo_rectangle_t _tmp208_ = {0};
					gdouble _tmp209_ = 0.0;
					GtkBorder _tmp210_ = {0};
					gint16 _tmp211_ = 0;
					PangoLayout* _tmp212_ = NULL;
					_tmp119_ = _rect;
					last_rect = _tmp119_;
					_tmp120_ = tooltip_rect;
					_tmp121_ = _tmp120_.x;
					_tmp122_ = floor (_tmp121_);
					tooltip_rect.x = _tmp122_;
					_tmp123_ = tooltip_rect;
					_tmp124_ = _tmp123_.y;
					_tmp125_ = floor (_tmp124_);
					tooltip_rect.y = _tmp125_;
					_tmp126_ = ringsitem;
					_tmp127_ = _tmp126_->min_radius;
					_tmp128_ = ringsitem;
					_tmp129_ = _tmp128_->max_radius;
					_tmp130_ = ringsitem;
					_tmp131_ = _tmp130_->min_radius;
					middle_radius = _tmp127_ + ((_tmp129_ - _tmp131_) / 2);
					_tmp132_ = q_width;
					_tmp133_ = middle_radius;
					_tmp134_ = middle_angle;
					_tmp135_ = cos (_tmp134_);
					sector_center_x = _tmp132_ + (_tmp133_ * _tmp135_);
					_tmp136_ = q_height;
					_tmp137_ = middle_radius;
					_tmp138_ = middle_angle;
					_tmp139_ = sin (_tmp138_);
					sector_center_y = _tmp136_ + (_tmp137_ * _tmp139_);
					_tmp140_ = cr;
					cairo_save (_tmp140_);
					_tmp141_ = cr;
					_tmp142_ = allocation;
					_tmp143_ = _tmp142_.width;
					_tmp144_ = allocation;
					_tmp145_ = _tmp144_.height;
					cairo_rectangle (_tmp141_, (gdouble) 0, (gdouble) 0, (gdouble) _tmp143_, (gdouble) _tmp145_);
					_tmp146_ = cr;
					_tmp147_ = tooltip_rect;
					_tmp148_ = _tmp147_.x;
					_tmp149_ = tooltip_rect;
					_tmp150_ = _tmp149_.width;
					_tmp151_ = tooltip_rect;
					_tmp152_ = _tmp151_.y;
					_tmp153_ = tooltip_rect;
					_tmp154_ = _tmp153_.width;
					_tmp155_ = tooltip_rect;
					_tmp156_ = _tmp155_.height;
					cairo_rectangle (_tmp146_, _tmp148_ + _tmp150_, _tmp152_, -_tmp154_, _tmp156_);
					_tmp157_ = cr;
					cairo_clip (_tmp157_);
					_tmp158_ = context;
					_tmp159_ = context_state;
					gtk_style_context_get_background_color (_tmp158_, _tmp159_, &_tmp160_);
					bg_color = _tmp160_;
					_tmp161_ = cr;
					cairo_set_line_width (_tmp161_, (gdouble) 1);
					_tmp162_ = cr;
					_tmp163_ = sector_center_x;
					_tmp164_ = sector_center_y;
					cairo_move_to (_tmp162_, _tmp163_, _tmp164_);
					_tmp165_ = cr;
					_tmp166_ = bg_color;
					gdk_cairo_set_source_rgba (_tmp165_, &_tmp166_);
					_tmp167_ = cr;
					_tmp168_ = tooltip_rect;
					_tmp169_ = _tmp168_.x;
					_tmp170_ = tooltip_rect;
					_tmp171_ = _tmp170_.width;
					_tmp172_ = tooltip_rect;
					_tmp173_ = _tmp172_.y;
					_tmp174_ = tooltip_rect;
					_tmp175_ = _tmp174_.height;
					cairo_line_to (_tmp167_, _tmp169_ + (_tmp171_ / 2), _tmp173_ + (_tmp175_ / 2));
					_tmp176_ = cr;
					cairo_stroke (_tmp176_);
					_tmp177_ = cr;
					cairo_restore (_tmp177_);
					_tmp178_ = cr;
					_tmp179_ = sector_center_x;
					_tmp180_ = sector_center_y;
					cairo_arc (_tmp178_, _tmp179_, _tmp180_, 1.0, (gdouble) 0, 2 * G_PI);
					_tmp181_ = cr;
					cairo_stroke (_tmp181_);
					_tmp182_ = context;
					_tmp183_ = cr;
					_tmp184_ = tooltip_rect;
					_tmp185_ = _tmp184_.x;
					_tmp186_ = tooltip_rect;
					_tmp187_ = _tmp186_.y;
					_tmp188_ = tooltip_rect;
					_tmp189_ = _tmp188_.width;
					_tmp190_ = tooltip_rect;
					_tmp191_ = _tmp190_.height;
					gtk_render_background (_tmp182_, _tmp183_, _tmp185_, _tmp187_, _tmp189_, _tmp191_);
					_tmp192_ = context;
					_tmp193_ = cr;
					_tmp194_ = tooltip_rect;
					_tmp195_ = _tmp194_.x;
					_tmp196_ = tooltip_rect;
					_tmp197_ = _tmp196_.y;
					_tmp198_ = tooltip_rect;
					_tmp199_ = _tmp198_.width;
					_tmp200_ = tooltip_rect;
					_tmp201_ = _tmp200_.height;
					gtk_render_frame (_tmp192_, _tmp193_, _tmp195_, _tmp197_, _tmp199_, _tmp201_);
					_tmp202_ = context;
					_tmp203_ = cr;
					_tmp204_ = tooltip_rect;
					_tmp205_ = _tmp204_.x;
					_tmp206_ = padding;
					_tmp207_ = _tmp206_.left;
					_tmp208_ = tooltip_rect;
					_tmp209_ = _tmp208_.y;
					_tmp210_ = padding;
					_tmp211_ = _tmp210_.top;
					_tmp212_ = layout;
					gtk_render_layout (_tmp202_, _tmp203_, _tmp205_ + _tmp207_, _tmp209_ + _tmp211_, _tmp212_);
				}
				_g_free0 (markup);
				_g_object_unref0 (layout);
				_baobab_chart_item_unref0 (ringsitem);
				_baobab_chart_item_unref0 (item);
			}
		}
	}
	_tmp213_ = context;
	gtk_style_context_restore (_tmp213_);
	_g_object_unref0 (context);
}


static void baobab_ringschart_real_draw_item (BaobabChart* base, cairo_t* cr, BaobabChartItem* item, gboolean highlighted) {
	BaobabRingschart * self;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabChartItem* _tmp0_ = NULL;
	BaobabRingschartItem* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	cairo_t* _tmp16_ = NULL;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp17_ = {0};
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp18_ = NULL;
	GtkStyleContext* _tmp19_ = NULL;
	GtkStateFlags context_state = 0;
	GtkStyleContext* _tmp20_ = NULL;
	GtkStateFlags _tmp21_ = 0;
	GtkStyleContext* _tmp22_ = NULL;
	GtkStyleContext* toplevel_context = NULL;
	GtkWidget* _tmp23_ = NULL;
	GtkStyleContext* _tmp24_ = NULL;
	GtkStyleContext* _tmp25_ = NULL;
	GtkStateFlags toplevel_context_state = 0;
	GtkStyleContext* _tmp26_ = NULL;
	GtkStateFlags _tmp27_ = 0;
	GdkRGBA border_color = {0};
	GtkStyleContext* _tmp28_ = NULL;
	GtkStateFlags _tmp29_ = 0;
	GdkRGBA _tmp30_ = {0};
	GdkRGBA bg_color = {0};
	GtkStyleContext* _tmp31_ = NULL;
	GtkStateFlags _tmp32_ = 0;
	GdkRGBA _tmp33_ = {0};
	gint center_x = 0;
	GtkAllocation _tmp34_ = {0};
	gint _tmp35_ = 0;
	gint center_y = 0;
	GtkAllocation _tmp36_ = {0};
	gint _tmp37_ = 0;
	gdouble final_angle = 0.0;
	BaobabRingschartItem* _tmp38_ = NULL;
	gdouble _tmp39_ = 0.0;
	BaobabRingschartItem* _tmp40_ = NULL;
	gdouble _tmp41_ = 0.0;
	BaobabChartItem* _tmp42_ = NULL;
	guint _tmp43_ = 0U;
	GtkStyleContext* _tmp128_ = NULL;
	self = (BaobabRingschart*) base;
	g_return_if_fail (cr != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	_tmp1_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp0_) : NULL);
	ringsitem = _tmp1_;
	_tmp2_ = self->priv->drawing_subtips;
	if (_tmp2_) {
		gboolean _tmp3_ = FALSE;
		gboolean _tmp4_ = FALSE;
		BaobabChartItem* _tmp5_ = NULL;
		BaobabChartItem* _tmp6_ = NULL;
		_tmp5_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
		_tmp6_ = _tmp5_;
		if (_tmp6_ != NULL) {
			BaobabChartItem* _tmp7_ = NULL;
			GList* _tmp8_ = NULL;
			_tmp7_ = item;
			_tmp8_ = _tmp7_->parent;
			_tmp4_ = _tmp8_ != NULL;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			BaobabChartItem* _tmp9_ = NULL;
			GList* _tmp10_ = NULL;
			gconstpointer _tmp11_ = NULL;
			BaobabChartItem* _tmp12_ = NULL;
			BaobabChartItem* _tmp13_ = NULL;
			_tmp9_ = item;
			_tmp10_ = _tmp9_->parent;
			_tmp11_ = _tmp10_->data;
			_tmp12_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
			_tmp13_ = _tmp12_;
			_tmp3_ = ((BaobabChartItem*) _tmp11_) == _tmp13_;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			BaobabChartItem* _tmp14_ = NULL;
			BaobabChartItem* _tmp15_ = NULL;
			_tmp14_ = item;
			_tmp15_ = _baobab_chart_item_ref0 (_tmp14_);
			self->priv->subtip_items = g_list_append (self->priv->subtip_items, _tmp15_);
		}
	}
	_tmp16_ = cr;
	cairo_set_line_width (_tmp16_, (gdouble) BAOBAB_RINGSCHART_ITEM_BORDER_WIDTH);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp17_);
	allocation = _tmp17_;
	_tmp18_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp19_ = _g_object_ref0 (_tmp18_);
	context = _tmp19_;
	_tmp20_ = context;
	_tmp21_ = gtk_style_context_get_state (_tmp20_);
	context_state = _tmp21_;
	_tmp22_ = context;
	gtk_style_context_save (_tmp22_);
	_tmp23_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	_tmp24_ = gtk_widget_get_style_context (_tmp23_);
	_tmp25_ = _g_object_ref0 (_tmp24_);
	toplevel_context = _tmp25_;
	_tmp26_ = toplevel_context;
	_tmp27_ = gtk_style_context_get_state (_tmp26_);
	toplevel_context_state = _tmp27_;
	_tmp28_ = context;
	_tmp29_ = context_state;
	gtk_style_context_get_border_color (_tmp28_, _tmp29_, &_tmp30_);
	border_color = _tmp30_;
	_tmp31_ = toplevel_context;
	_tmp32_ = toplevel_context_state;
	gtk_style_context_get_background_color (_tmp31_, _tmp32_, &_tmp33_);
	bg_color = _tmp33_;
	_tmp34_ = allocation;
	_tmp35_ = _tmp34_.width;
	center_x = _tmp35_ / 2;
	_tmp36_ = allocation;
	_tmp37_ = _tmp36_.height;
	center_y = _tmp37_ / 2;
	_tmp38_ = ringsitem;
	_tmp39_ = _tmp38_->start_angle;
	_tmp40_ = ringsitem;
	_tmp41_ = _tmp40_->angle;
	final_angle = _tmp39_ + _tmp41_;
	_tmp42_ = item;
	_tmp43_ = _tmp42_->depth;
	if (_tmp43_ == ((guint) 0)) {
		PangoLayout* layout = NULL;
		PangoLayout* _tmp44_ = NULL;
		gchar* markup = NULL;
		BaobabChartItem* _tmp45_ = NULL;
		const gchar* _tmp46_ = NULL;
		gchar* _tmp47_ = NULL;
		gchar* _tmp48_ = NULL;
		gchar* _tmp49_ = NULL;
		gchar* _tmp50_ = NULL;
		gchar* _tmp51_ = NULL;
		gchar* _tmp52_ = NULL;
		PangoLayout* _tmp53_ = NULL;
		const gchar* _tmp54_ = NULL;
		PangoLayout* _tmp55_ = NULL;
		PangoLayout* _tmp56_ = NULL;
		PangoRectangle layout_rect = {0};
		PangoLayout* _tmp57_ = NULL;
		PangoRectangle _tmp58_ = {0};
		PangoRectangle _tmp59_ = {0};
		gint _tmp60_ = 0;
		BaobabRingschartItem* _tmp61_ = NULL;
		gdouble _tmp62_ = 0.0;
		cairo_t* _tmp77_ = NULL;
		gint _tmp78_ = 0;
		gint _tmp79_ = 0;
		BaobabRingschartItem* _tmp80_ = NULL;
		gdouble _tmp81_ = 0.0;
		cairo_t* _tmp82_ = NULL;
		GdkRGBA _tmp83_ = {0};
		cairo_t* _tmp84_ = NULL;
		_tmp44_ = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
		layout = _tmp44_;
		_tmp45_ = item;
		_tmp46_ = _tmp45_->size;
		_tmp47_ = g_markup_escape_text (_tmp46_, (gssize) -1);
		_tmp48_ = _tmp47_;
		_tmp49_ = g_strconcat ("<span size=\"small\">", _tmp48_, NULL);
		_tmp50_ = _tmp49_;
		_tmp51_ = g_strconcat (_tmp50_, "</span>", NULL);
		_tmp52_ = _tmp51_;
		_g_free0 (_tmp50_);
		_g_free0 (_tmp48_);
		markup = _tmp52_;
		_tmp53_ = layout;
		_tmp54_ = markup;
		pango_layout_set_markup (_tmp53_, _tmp54_, -1);
		_tmp55_ = layout;
		pango_layout_set_indent (_tmp55_, 0);
		_tmp56_ = layout;
		pango_layout_set_spacing (_tmp56_, 0);
		_tmp57_ = layout;
		pango_layout_get_pixel_extents (_tmp57_, NULL, &_tmp58_);
		layout_rect = _tmp58_;
		_tmp59_ = layout_rect;
		_tmp60_ = _tmp59_.width;
		_tmp61_ = ringsitem;
		_tmp62_ = _tmp61_->max_radius;
		if (((gdouble) _tmp60_) < (2 * _tmp62_)) {
			GtkStyleContext* _tmp63_ = NULL;
			cairo_t* _tmp64_ = NULL;
			gint _tmp65_ = 0;
			PangoRectangle _tmp66_ = {0};
			gint _tmp67_ = 0;
			gint _tmp68_ = 0;
			PangoRectangle _tmp69_ = {0};
			gint _tmp70_ = 0;
			PangoLayout* _tmp71_ = NULL;
			cairo_t* _tmp72_ = NULL;
			gint _tmp73_ = 0;
			BaobabRingschartItem* _tmp74_ = NULL;
			gdouble _tmp75_ = 0.0;
			gint _tmp76_ = 0;
			_tmp63_ = context;
			_tmp64_ = cr;
			_tmp65_ = center_x;
			_tmp66_ = layout_rect;
			_tmp67_ = _tmp66_.width;
			_tmp68_ = center_y;
			_tmp69_ = layout_rect;
			_tmp70_ = _tmp69_.height;
			_tmp71_ = layout;
			gtk_render_layout (_tmp63_, _tmp64_, (gdouble) (_tmp65_ - (_tmp67_ / 2)), (gdouble) (_tmp68_ - (_tmp70_ / 2)), _tmp71_);
			_tmp72_ = cr;
			_tmp73_ = center_x;
			_tmp74_ = ringsitem;
			_tmp75_ = _tmp74_->max_radius;
			_tmp76_ = center_y;
			cairo_move_to (_tmp72_, (_tmp73_ + _tmp75_) + 1, (gdouble) _tmp76_);
		}
		_tmp77_ = cr;
		_tmp78_ = center_x;
		_tmp79_ = center_y;
		_tmp80_ = ringsitem;
		_tmp81_ = _tmp80_->max_radius;
		cairo_arc (_tmp77_, (gdouble) _tmp78_, (gdouble) _tmp79_, _tmp81_ + 1, (gdouble) 0, 2 * G_PI);
		_tmp82_ = cr;
		_tmp83_ = border_color;
		gdk_cairo_set_source_rgba (_tmp82_, &_tmp83_);
		_tmp84_ = cr;
		cairo_stroke (_tmp84_);
		_g_free0 (markup);
		_g_object_unref0 (layout);
	} else {
		GdkRGBA fill_color = {0};
		BaobabRingschartItem* _tmp85_ = NULL;
		gdouble _tmp86_ = 0.0;
		BaobabChartItem* _tmp87_ = NULL;
		guint _tmp88_ = 0U;
		gboolean _tmp89_ = FALSE;
		GdkRGBA _tmp90_ = {0};
		cairo_t* _tmp91_ = NULL;
		gint _tmp92_ = 0;
		gint _tmp93_ = 0;
		BaobabRingschartItem* _tmp94_ = NULL;
		gdouble _tmp95_ = 0.0;
		BaobabRingschartItem* _tmp96_ = NULL;
		gdouble _tmp97_ = 0.0;
		gdouble _tmp98_ = 0.0;
		cairo_t* _tmp99_ = NULL;
		gint _tmp100_ = 0;
		gint _tmp101_ = 0;
		BaobabRingschartItem* _tmp102_ = NULL;
		gdouble _tmp103_ = 0.0;
		gdouble _tmp104_ = 0.0;
		BaobabRingschartItem* _tmp105_ = NULL;
		gdouble _tmp106_ = 0.0;
		cairo_t* _tmp107_ = NULL;
		cairo_t* _tmp108_ = NULL;
		GdkRGBA _tmp109_ = {0};
		cairo_t* _tmp110_ = NULL;
		cairo_t* _tmp111_ = NULL;
		GdkRGBA _tmp112_ = {0};
		cairo_t* _tmp113_ = NULL;
		BaobabRingschartItem* _tmp114_ = NULL;
		gboolean _tmp115_ = FALSE;
		_tmp85_ = ringsitem;
		_tmp86_ = _tmp85_->start_angle;
		_tmp87_ = item;
		_tmp88_ = _tmp87_->depth;
		_tmp89_ = highlighted;
		baobab_chart_get_item_color ((BaobabChart*) self, (_tmp86_ / G_PI) * 99, _tmp88_, _tmp89_, &_tmp90_);
		fill_color = _tmp90_;
		_tmp91_ = cr;
		_tmp92_ = center_x;
		_tmp93_ = center_y;
		_tmp94_ = ringsitem;
		_tmp95_ = _tmp94_->min_radius;
		_tmp96_ = ringsitem;
		_tmp97_ = _tmp96_->start_angle;
		_tmp98_ = final_angle;
		cairo_arc (_tmp91_, (gdouble) _tmp92_, (gdouble) _tmp93_, _tmp95_, _tmp97_, _tmp98_);
		_tmp99_ = cr;
		_tmp100_ = center_x;
		_tmp101_ = center_y;
		_tmp102_ = ringsitem;
		_tmp103_ = _tmp102_->max_radius;
		_tmp104_ = final_angle;
		_tmp105_ = ringsitem;
		_tmp106_ = _tmp105_->start_angle;
		cairo_arc_negative (_tmp99_, (gdouble) _tmp100_, (gdouble) _tmp101_, _tmp103_, _tmp104_, _tmp106_);
		_tmp107_ = cr;
		cairo_close_path (_tmp107_);
		_tmp108_ = cr;
		_tmp109_ = fill_color;
		gdk_cairo_set_source_rgba (_tmp108_, &_tmp109_);
		_tmp110_ = cr;
		cairo_fill_preserve (_tmp110_);
		_tmp111_ = cr;
		_tmp112_ = bg_color;
		gdk_cairo_set_source_rgba (_tmp111_, &_tmp112_);
		_tmp113_ = cr;
		cairo_stroke (_tmp113_);
		_tmp114_ = ringsitem;
		_tmp115_ = _tmp114_->continued;
		if (_tmp115_) {
			cairo_t* _tmp116_ = NULL;
			GdkRGBA _tmp117_ = {0};
			cairo_t* _tmp118_ = NULL;
			cairo_t* _tmp119_ = NULL;
			gint _tmp120_ = 0;
			gint _tmp121_ = 0;
			BaobabRingschartItem* _tmp122_ = NULL;
			gdouble _tmp123_ = 0.0;
			BaobabRingschartItem* _tmp124_ = NULL;
			gdouble _tmp125_ = 0.0;
			gdouble _tmp126_ = 0.0;
			cairo_t* _tmp127_ = NULL;
			_tmp116_ = cr;
			_tmp117_ = border_color;
			gdk_cairo_set_source_rgba (_tmp116_, &_tmp117_);
			_tmp118_ = cr;
			cairo_set_line_width (_tmp118_, (gdouble) 3);
			_tmp119_ = cr;
			_tmp120_ = center_x;
			_tmp121_ = center_y;
			_tmp122_ = ringsitem;
			_tmp123_ = _tmp122_->max_radius;
			_tmp124_ = ringsitem;
			_tmp125_ = _tmp124_->start_angle;
			_tmp126_ = final_angle;
			cairo_arc (_tmp119_, (gdouble) _tmp120_, (gdouble) _tmp121_, _tmp123_ + 4, _tmp125_ + BAOBAB_RINGSCHART_EDGE_ANGLE, _tmp126_ - BAOBAB_RINGSCHART_EDGE_ANGLE);
			_tmp127_ = cr;
			cairo_stroke (_tmp127_);
		}
	}
	_tmp128_ = context;
	gtk_style_context_restore (_tmp128_);
	_g_object_unref0 (toplevel_context);
	_g_object_unref0 (context);
	_baobab_chart_item_unref0 (ringsitem);
}


static void baobab_ringschart_real_calculate_item_geometry (BaobabChart* base, BaobabChartItem* item) {
	BaobabRingschart * self;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabChartItem* _tmp0_ = NULL;
	BaobabRingschartItem* _tmp1_ = NULL;
	BaobabRingschartItem* _tmp2_ = NULL;
	BaobabRingschartItem* _tmp3_ = NULL;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp4_ = {0};
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp5_ = NULL;
	GtkStyleContext* _tmp6_ = NULL;
	GtkStateFlags context_state = 0;
	GtkStyleContext* _tmp7_ = NULL;
	GtkStateFlags _tmp8_ = 0;
	GtkBorder padding = {0};
	GtkStyleContext* _tmp9_ = NULL;
	GtkStateFlags _tmp10_ = 0;
	GtkBorder _tmp11_ = {0};
	gint max_radius = 0;
	GtkAllocation _tmp12_ = {0};
	gint _tmp13_ = 0;
	GtkAllocation _tmp14_ = {0};
	gint _tmp15_ = 0;
	gint _tmp16_ = 0;
	GtkBorder _tmp17_ = {0};
	gint16 _tmp18_ = 0;
	guint thickness = 0U;
	gint _tmp19_ = 0;
	guint _tmp20_ = 0U;
	guint _tmp21_ = 0U;
	BaobabRingschartItem* _tmp22_ = NULL;
	GList* _tmp23_ = NULL;
	BaobabRingschartItem* _tmp69_ = NULL;
	BaobabChartItem* _tmp70_ = NULL;
	self = (BaobabRingschart*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	_tmp1_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp0_) : NULL);
	ringsitem = _tmp1_;
	_tmp2_ = ringsitem;
	_tmp2_->continued = FALSE;
	_tmp3_ = ringsitem;
	((BaobabChartItem*) _tmp3_)->visible = FALSE;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp4_);
	allocation = _tmp4_;
	_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp6_ = _g_object_ref0 (_tmp5_);
	context = _tmp6_;
	_tmp7_ = context;
	_tmp8_ = gtk_style_context_get_state (_tmp7_);
	context_state = _tmp8_;
	_tmp9_ = context;
	_tmp10_ = context_state;
	gtk_style_context_get_padding (_tmp9_, _tmp10_, &_tmp11_);
	padding = _tmp11_;
	_tmp12_ = allocation;
	_tmp13_ = _tmp12_.width;
	_tmp14_ = allocation;
	_tmp15_ = _tmp14_.height;
	_tmp16_ = MIN (_tmp13_ / 2, _tmp15_ / 2);
	_tmp17_ = padding;
	_tmp18_ = _tmp17_.left;
	max_radius = _tmp16_ - _tmp18_;
	_tmp19_ = max_radius;
	_tmp20_ = baobab_chart_get_max_depth ((BaobabChart*) self);
	_tmp21_ = _tmp20_;
	thickness = _tmp19_ / (_tmp21_ + 1);
	_tmp22_ = ringsitem;
	_tmp23_ = ((BaobabChartItem*) _tmp22_)->parent;
	if (_tmp23_ == NULL) {
		BaobabRingschartItem* _tmp24_ = NULL;
		BaobabRingschartItem* _tmp25_ = NULL;
		guint _tmp26_ = 0U;
		BaobabRingschartItem* _tmp27_ = NULL;
		BaobabRingschartItem* _tmp28_ = NULL;
		_tmp24_ = ringsitem;
		_tmp24_->min_radius = (gdouble) 0;
		_tmp25_ = ringsitem;
		_tmp26_ = thickness;
		_tmp25_->max_radius = (gdouble) _tmp26_;
		_tmp27_ = ringsitem;
		_tmp27_->start_angle = (gdouble) 0;
		_tmp28_ = ringsitem;
		_tmp28_->angle = 2 * G_PI;
	} else {
		BaobabRingschartItem* parent = NULL;
		BaobabChartItem* _tmp29_ = NULL;
		GList* _tmp30_ = NULL;
		gconstpointer _tmp31_ = NULL;
		BaobabChartItem* _tmp32_ = NULL;
		BaobabRingschartItem* _tmp33_ = NULL;
		BaobabRingschartItem* _tmp34_ = NULL;
		BaobabRingschartItem* _tmp35_ = NULL;
		guint _tmp36_ = 0U;
		guint _tmp37_ = 0U;
		BaobabRingschartItem* _tmp38_ = NULL;
		guint _tmp39_ = 0U;
		guint _tmp40_ = 0U;
		guint _tmp41_ = 0U;
		BaobabRingschartItem* _tmp46_ = NULL;
		BaobabRingschartItem* _tmp47_ = NULL;
		gdouble _tmp48_ = 0.0;
		BaobabRingschartItem* _tmp49_ = NULL;
		gdouble _tmp50_ = 0.0;
		BaobabRingschartItem* _tmp51_ = NULL;
		gdouble _tmp52_ = 0.0;
		BaobabRingschartItem* _tmp53_ = NULL;
		BaobabRingschartItem* _tmp54_ = NULL;
		gdouble _tmp55_ = 0.0;
		BaobabRingschartItem* _tmp56_ = NULL;
		gdouble _tmp57_ = 0.0;
		BaobabRingschartItem* _tmp58_ = NULL;
		gdouble _tmp59_ = 0.0;
		gboolean _tmp60_ = FALSE;
		BaobabRingschartItem* _tmp61_ = NULL;
		gboolean _tmp62_ = FALSE;
		BaobabRingschartItem* _tmp67_ = NULL;
		BaobabRingschartItem* _tmp68_ = NULL;
		_tmp29_ = item;
		_tmp30_ = _tmp29_->parent;
		_tmp31_ = _tmp30_->data;
		_tmp32_ = (BaobabChartItem*) _tmp31_;
		_tmp33_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp32_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp32_) : NULL);
		parent = _tmp33_;
		_tmp34_ = ringsitem;
		_tmp35_ = ringsitem;
		_tmp36_ = ((BaobabChartItem*) _tmp35_)->depth;
		_tmp37_ = thickness;
		_tmp34_->min_radius = (gdouble) (_tmp36_ * _tmp37_);
		_tmp38_ = ringsitem;
		_tmp39_ = ((BaobabChartItem*) _tmp38_)->depth;
		_tmp40_ = baobab_chart_get_max_depth ((BaobabChart*) self);
		_tmp41_ = _tmp40_;
		if (_tmp39_ > _tmp41_) {
			_baobab_chart_item_unref0 (parent);
			_g_object_unref0 (context);
			_baobab_chart_item_unref0 (ringsitem);
			return;
		} else {
			BaobabRingschartItem* _tmp42_ = NULL;
			BaobabRingschartItem* _tmp43_ = NULL;
			gdouble _tmp44_ = 0.0;
			guint _tmp45_ = 0U;
			_tmp42_ = ringsitem;
			_tmp43_ = ringsitem;
			_tmp44_ = _tmp43_->min_radius;
			_tmp45_ = thickness;
			_tmp42_->max_radius = _tmp44_ + _tmp45_;
		}
		_tmp46_ = ringsitem;
		_tmp47_ = parent;
		_tmp48_ = _tmp47_->angle;
		_tmp49_ = ringsitem;
		_tmp50_ = ((BaobabChartItem*) _tmp49_)->rel_size;
		_tmp46_->angle = (_tmp48_ * _tmp50_) / 100;
		_tmp51_ = ringsitem;
		_tmp52_ = _tmp51_->angle;
		if (_tmp52_ < BAOBAB_RINGSCHART_ITEM_MIN_ANGLE) {
			_baobab_chart_item_unref0 (parent);
			_g_object_unref0 (context);
			_baobab_chart_item_unref0 (ringsitem);
			return;
		}
		_tmp53_ = ringsitem;
		_tmp54_ = parent;
		_tmp55_ = _tmp54_->start_angle;
		_tmp56_ = parent;
		_tmp57_ = _tmp56_->angle;
		_tmp58_ = ringsitem;
		_tmp59_ = ((BaobabChartItem*) _tmp58_)->rel_start;
		_tmp53_->start_angle = _tmp55_ + ((_tmp57_ * _tmp59_) / 100);
		_tmp61_ = ringsitem;
		_tmp62_ = ((BaobabChartItem*) _tmp61_)->has_any_child;
		if (_tmp62_) {
			BaobabRingschartItem* _tmp63_ = NULL;
			guint _tmp64_ = 0U;
			guint _tmp65_ = 0U;
			guint _tmp66_ = 0U;
			_tmp63_ = ringsitem;
			_tmp64_ = ((BaobabChartItem*) _tmp63_)->depth;
			_tmp65_ = baobab_chart_get_max_depth ((BaobabChart*) self);
			_tmp66_ = _tmp65_;
			_tmp60_ = _tmp64_ == _tmp66_;
		} else {
			_tmp60_ = FALSE;
		}
		_tmp67_ = ringsitem;
		_tmp67_->continued = _tmp60_;
		_tmp68_ = parent;
		((BaobabChartItem*) _tmp68_)->has_visible_children = TRUE;
		_baobab_chart_item_unref0 (parent);
	}
	_tmp69_ = ringsitem;
	((BaobabChartItem*) _tmp69_)->visible = TRUE;
	_tmp70_ = item;
	baobab_chart_get_item_rectangle ((BaobabChart*) self, _tmp70_);
	_g_object_unref0 (context);
	_baobab_chart_item_unref0 (ringsitem);
}


static void baobab_ringschart_get_point_min_rect (BaobabRingschart* self, gdouble cx, gdouble cy, gdouble radius, gdouble angle, GdkRectangle* r) {
	gdouble x = 0.0;
	gdouble y = 0.0;
	gdouble _tmp0_ = 0.0;
	gdouble _tmp1_ = 0.0;
	gdouble _tmp2_ = 0.0;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_ = 0.0;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	gdouble _tmp7_ = 0.0;
	GdkRectangle _tmp8_ = {0};
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	GdkRectangle _tmp11_ = {0};
	gint _tmp12_ = 0;
	gint _tmp13_ = 0;
	GdkRectangle _tmp14_ = {0};
	gint _tmp15_ = 0;
	gint _tmp16_ = 0;
	GdkRectangle _tmp17_ = {0};
	gint _tmp18_ = 0;
	gint _tmp19_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (r != NULL);
	_tmp0_ = cx;
	_tmp1_ = angle;
	_tmp2_ = cos (_tmp1_);
	_tmp3_ = radius;
	x = _tmp0_ + (_tmp2_ * _tmp3_);
	_tmp4_ = cy;
	_tmp5_ = angle;
	_tmp6_ = sin (_tmp5_);
	_tmp7_ = radius;
	y = _tmp4_ + (_tmp6_ * _tmp7_);
	_tmp8_ = *r;
	_tmp9_ = _tmp8_.x;
	_tmp10_ = MIN (_tmp9_, (gint) x);
	(*r).x = _tmp10_;
	_tmp11_ = *r;
	_tmp12_ = _tmp11_.y;
	_tmp13_ = MIN (_tmp12_, (gint) y);
	(*r).y = _tmp13_;
	_tmp14_ = *r;
	_tmp15_ = _tmp14_.width;
	_tmp16_ = MAX (_tmp15_, (gint) x);
	(*r).width = _tmp16_;
	_tmp17_ = *r;
	_tmp18_ = _tmp17_.height;
	_tmp19_ = MAX (_tmp18_, (gint) y);
	(*r).height = _tmp19_;
}


static void baobab_ringschart_real_get_item_rectangle (BaobabChart* base, BaobabChartItem* item) {
	BaobabRingschart * self;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabChartItem* _tmp0_ = NULL;
	BaobabRingschartItem* _tmp1_ = NULL;
	GdkRectangle rect = {0};
	gdouble cx = 0.0;
	gdouble cy = 0.0;
	gdouble r1 = 0.0;
	gdouble r2 = 0.0;
	gdouble a1 = 0.0;
	gdouble a2 = 0.0;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp2_ = {0};
	GtkAllocation _tmp3_ = {0};
	gint _tmp4_ = 0;
	GtkAllocation _tmp5_ = {0};
	gint _tmp6_ = 0;
	BaobabRingschartItem* _tmp7_ = NULL;
	gdouble _tmp8_ = 0.0;
	BaobabRingschartItem* _tmp9_ = NULL;
	gdouble _tmp10_ = 0.0;
	BaobabRingschartItem* _tmp11_ = NULL;
	gdouble _tmp12_ = 0.0;
	BaobabRingschartItem* _tmp13_ = NULL;
	gdouble _tmp14_ = 0.0;
	BaobabRingschartItem* _tmp15_ = NULL;
	gdouble _tmp16_ = 0.0;
	GtkAllocation _tmp17_ = {0};
	gint _tmp18_ = 0;
	GtkAllocation _tmp19_ = {0};
	gint _tmp20_ = 0;
	gdouble _tmp21_ = 0.0;
	gdouble _tmp22_ = 0.0;
	gdouble _tmp23_ = 0.0;
	gdouble _tmp24_ = 0.0;
	gdouble _tmp25_ = 0.0;
	gdouble _tmp26_ = 0.0;
	gdouble _tmp27_ = 0.0;
	gdouble _tmp28_ = 0.0;
	gdouble _tmp29_ = 0.0;
	gdouble _tmp30_ = 0.0;
	gdouble _tmp31_ = 0.0;
	gdouble _tmp32_ = 0.0;
	gdouble _tmp33_ = 0.0;
	gdouble _tmp34_ = 0.0;
	gdouble _tmp35_ = 0.0;
	gdouble _tmp36_ = 0.0;
	gboolean _tmp37_ = FALSE;
	gdouble _tmp38_ = 0.0;
	gboolean _tmp46_ = FALSE;
	gdouble _tmp47_ = 0.0;
	gboolean _tmp55_ = FALSE;
	gdouble _tmp56_ = 0.0;
	gboolean _tmp64_ = FALSE;
	gdouble _tmp65_ = 0.0;
	gint _tmp73_ = 0;
	GdkRectangle _tmp74_ = {0};
	gint _tmp75_ = 0;
	gint _tmp76_ = 0;
	GdkRectangle _tmp77_ = {0};
	gint _tmp78_ = 0;
	BaobabRingschartItem* _tmp79_ = NULL;
	GdkRectangle _tmp80_ = {0};
	self = (BaobabRingschart*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	_tmp1_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp0_) : NULL);
	ringsitem = _tmp1_;
	memset (&rect, 0, sizeof (GdkRectangle));
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp2_);
	allocation = _tmp2_;
	_tmp3_ = allocation;
	_tmp4_ = _tmp3_.width;
	cx = (gdouble) (_tmp4_ / 2);
	_tmp5_ = allocation;
	_tmp6_ = _tmp5_.height;
	cy = (gdouble) (_tmp6_ / 2);
	_tmp7_ = ringsitem;
	_tmp8_ = _tmp7_->min_radius;
	r1 = _tmp8_;
	_tmp9_ = ringsitem;
	_tmp10_ = _tmp9_->max_radius;
	r2 = _tmp10_;
	_tmp11_ = ringsitem;
	_tmp12_ = _tmp11_->start_angle;
	a1 = _tmp12_;
	_tmp13_ = ringsitem;
	_tmp14_ = _tmp13_->start_angle;
	_tmp15_ = ringsitem;
	_tmp16_ = _tmp15_->angle;
	a2 = _tmp14_ + _tmp16_;
	_tmp17_ = allocation;
	_tmp18_ = _tmp17_.width;
	rect.x = _tmp18_;
	_tmp19_ = allocation;
	_tmp20_ = _tmp19_.height;
	rect.y = _tmp20_;
	rect.width = 0;
	rect.height = 0;
	_tmp21_ = cx;
	_tmp22_ = cy;
	_tmp23_ = r1;
	_tmp24_ = a1;
	baobab_ringschart_get_point_min_rect (self, _tmp21_, _tmp22_, _tmp23_, _tmp24_, &rect);
	_tmp25_ = cx;
	_tmp26_ = cy;
	_tmp27_ = r2;
	_tmp28_ = a1;
	baobab_ringschart_get_point_min_rect (self, _tmp25_, _tmp26_, _tmp27_, _tmp28_, &rect);
	_tmp29_ = cx;
	_tmp30_ = cy;
	_tmp31_ = r1;
	_tmp32_ = a2;
	baobab_ringschart_get_point_min_rect (self, _tmp29_, _tmp30_, _tmp31_, _tmp32_, &rect);
	_tmp33_ = cx;
	_tmp34_ = cy;
	_tmp35_ = r2;
	_tmp36_ = a2;
	baobab_ringschart_get_point_min_rect (self, _tmp33_, _tmp34_, _tmp35_, _tmp36_, &rect);
	_tmp38_ = a1;
	if (_tmp38_ <= (G_PI / 2)) {
		gdouble _tmp39_ = 0.0;
		_tmp39_ = a2;
		_tmp37_ = _tmp39_ >= (G_PI / 2);
	} else {
		_tmp37_ = FALSE;
	}
	if (_tmp37_) {
		GdkRectangle _tmp40_ = {0};
		gint _tmp41_ = 0;
		gdouble _tmp42_ = 0.0;
		gdouble _tmp43_ = 0.0;
		gdouble _tmp44_ = 0.0;
		gdouble _tmp45_ = 0.0;
		_tmp40_ = rect;
		_tmp41_ = _tmp40_.height;
		_tmp42_ = cy;
		_tmp43_ = sin (G_PI / 2);
		_tmp44_ = r2;
		_tmp45_ = MAX ((gdouble) _tmp41_, _tmp42_ + (_tmp43_ * _tmp44_));
		rect.height = (gint) _tmp45_;
	}
	_tmp47_ = a1;
	if (_tmp47_ <= G_PI) {
		gdouble _tmp48_ = 0.0;
		_tmp48_ = a2;
		_tmp46_ = _tmp48_ >= G_PI;
	} else {
		_tmp46_ = FALSE;
	}
	if (_tmp46_) {
		GdkRectangle _tmp49_ = {0};
		gint _tmp50_ = 0;
		gdouble _tmp51_ = 0.0;
		gdouble _tmp52_ = 0.0;
		gdouble _tmp53_ = 0.0;
		gdouble _tmp54_ = 0.0;
		_tmp49_ = rect;
		_tmp50_ = _tmp49_.x;
		_tmp51_ = cx;
		_tmp52_ = cos (G_PI);
		_tmp53_ = r2;
		_tmp54_ = MIN ((gdouble) _tmp50_, _tmp51_ + (_tmp52_ * _tmp53_));
		rect.x = (gint) _tmp54_;
	}
	_tmp56_ = a1;
	if (_tmp56_ <= (G_PI * 1.5)) {
		gdouble _tmp57_ = 0.0;
		_tmp57_ = a2;
		_tmp55_ = _tmp57_ >= (G_PI * 1.5);
	} else {
		_tmp55_ = FALSE;
	}
	if (_tmp55_) {
		GdkRectangle _tmp58_ = {0};
		gint _tmp59_ = 0;
		gdouble _tmp60_ = 0.0;
		gdouble _tmp61_ = 0.0;
		gdouble _tmp62_ = 0.0;
		gdouble _tmp63_ = 0.0;
		_tmp58_ = rect;
		_tmp59_ = _tmp58_.y;
		_tmp60_ = cy;
		_tmp61_ = sin (G_PI * 1.5);
		_tmp62_ = r2;
		_tmp63_ = MIN ((gdouble) _tmp59_, _tmp60_ + (_tmp61_ * _tmp62_));
		rect.y = (gint) _tmp63_;
	}
	_tmp65_ = a1;
	if (_tmp65_ <= (G_PI * 2)) {
		gdouble _tmp66_ = 0.0;
		_tmp66_ = a2;
		_tmp64_ = _tmp66_ >= (G_PI * 2);
	} else {
		_tmp64_ = FALSE;
	}
	if (_tmp64_) {
		GdkRectangle _tmp67_ = {0};
		gint _tmp68_ = 0;
		gdouble _tmp69_ = 0.0;
		gdouble _tmp70_ = 0.0;
		gdouble _tmp71_ = 0.0;
		gdouble _tmp72_ = 0.0;
		_tmp67_ = rect;
		_tmp68_ = _tmp67_.width;
		_tmp69_ = cx;
		_tmp70_ = cos (G_PI * 2);
		_tmp71_ = r2;
		_tmp72_ = MAX ((gdouble) _tmp68_, _tmp69_ + (_tmp70_ * _tmp71_));
		rect.width = (gint) _tmp72_;
	}
	_tmp73_ = rect.width;
	_tmp74_ = rect;
	_tmp75_ = _tmp74_.x;
	rect.width = _tmp73_ - _tmp75_;
	_tmp76_ = rect.height;
	_tmp77_ = rect;
	_tmp78_ = _tmp77_.y;
	rect.height = _tmp76_ - _tmp78_;
	_tmp79_ = ringsitem;
	_tmp80_ = rect;
	((BaobabChartItem*) _tmp79_)->rect = _tmp80_;
	_baobab_chart_item_unref0 (ringsitem);
}


static gboolean baobab_ringschart_real_is_point_over_item (BaobabChart* base, BaobabChartItem* item, gdouble x, gdouble y) {
	BaobabRingschart * self;
	gboolean result = FALSE;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabChartItem* _tmp0_ = NULL;
	BaobabRingschartItem* _tmp1_ = NULL;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp2_ = {0};
	gdouble _tmp3_ = 0.0;
	GtkAllocation _tmp4_ = {0};
	gint _tmp5_ = 0;
	gdouble _tmp6_ = 0.0;
	GtkAllocation _tmp7_ = {0};
	gint _tmp8_ = 0;
	gdouble radius = 0.0;
	gdouble _tmp9_ = 0.0;
	gdouble _tmp10_ = 0.0;
	gdouble _tmp11_ = 0.0;
	gdouble _tmp12_ = 0.0;
	gdouble _tmp13_ = 0.0;
	gdouble angle = 0.0;
	gdouble _tmp14_ = 0.0;
	gdouble _tmp15_ = 0.0;
	gdouble _tmp16_ = 0.0;
	gdouble _tmp17_ = 0.0;
	gdouble _tmp18_ = 0.0;
	gboolean _tmp21_ = FALSE;
	gboolean _tmp22_ = FALSE;
	gboolean _tmp23_ = FALSE;
	gdouble _tmp24_ = 0.0;
	BaobabRingschartItem* _tmp25_ = NULL;
	gdouble _tmp26_ = 0.0;
	self = (BaobabRingschart*) base;
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = item;
	_tmp1_ = _baobab_chart_item_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_RINGSCHART_ITEM) ? ((BaobabRingschartItem*) _tmp0_) : NULL);
	ringsitem = _tmp1_;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp2_);
	allocation = _tmp2_;
	_tmp3_ = x;
	_tmp4_ = allocation;
	_tmp5_ = _tmp4_.width;
	x = _tmp3_ - (_tmp5_ / 2);
	_tmp6_ = y;
	_tmp7_ = allocation;
	_tmp8_ = _tmp7_.height;
	y = _tmp6_ - (_tmp8_ / 2);
	_tmp9_ = x;
	_tmp10_ = x;
	_tmp11_ = y;
	_tmp12_ = y;
	_tmp13_ = sqrt ((_tmp9_ * _tmp10_) + (_tmp11_ * _tmp12_));
	radius = _tmp13_;
	_tmp14_ = y;
	_tmp15_ = x;
	_tmp16_ = atan2 (_tmp14_, _tmp15_);
	angle = _tmp16_;
	_tmp18_ = angle;
	if (_tmp18_ > ((gdouble) 0)) {
		gdouble _tmp19_ = 0.0;
		_tmp19_ = angle;
		_tmp17_ = _tmp19_;
	} else {
		gdouble _tmp20_ = 0.0;
		_tmp20_ = angle;
		_tmp17_ = _tmp20_ + (2 * G_PI);
	}
	angle = _tmp17_;
	_tmp24_ = radius;
	_tmp25_ = ringsitem;
	_tmp26_ = _tmp25_->min_radius;
	if (_tmp24_ >= _tmp26_) {
		gdouble _tmp27_ = 0.0;
		BaobabRingschartItem* _tmp28_ = NULL;
		gdouble _tmp29_ = 0.0;
		_tmp27_ = radius;
		_tmp28_ = ringsitem;
		_tmp29_ = _tmp28_->max_radius;
		_tmp23_ = _tmp27_ <= _tmp29_;
	} else {
		_tmp23_ = FALSE;
	}
	if (_tmp23_) {
		gdouble _tmp30_ = 0.0;
		BaobabRingschartItem* _tmp31_ = NULL;
		gdouble _tmp32_ = 0.0;
		_tmp30_ = angle;
		_tmp31_ = ringsitem;
		_tmp32_ = _tmp31_->start_angle;
		_tmp22_ = _tmp30_ >= _tmp32_;
	} else {
		_tmp22_ = FALSE;
	}
	if (_tmp22_) {
		gdouble _tmp33_ = 0.0;
		BaobabRingschartItem* _tmp34_ = NULL;
		gdouble _tmp35_ = 0.0;
		BaobabRingschartItem* _tmp36_ = NULL;
		gdouble _tmp37_ = 0.0;
		_tmp33_ = angle;
		_tmp34_ = ringsitem;
		_tmp35_ = _tmp34_->start_angle;
		_tmp36_ = ringsitem;
		_tmp37_ = _tmp36_->angle;
		_tmp21_ = _tmp33_ <= (_tmp35_ + _tmp37_);
	} else {
		_tmp21_ = FALSE;
	}
	result = _tmp21_;
	_baobab_chart_item_unref0 (ringsitem);
	return result;
}


static gboolean baobab_ringschart_real_can_zoom_out (BaobabChart* base) {
	BaobabRingschart * self;
	gboolean result = FALSE;
	guint _tmp0_ = 0U;
	guint _tmp1_ = 0U;
	self = (BaobabRingschart*) base;
	_tmp0_ = baobab_chart_get_max_depth ((BaobabChart*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_ < BAOBAB_CHART_MAX_DEPTH;
	return result;
}


static gboolean baobab_ringschart_real_can_zoom_in (BaobabChart* base) {
	BaobabRingschart * self;
	gboolean result = FALSE;
	guint _tmp0_ = 0U;
	guint _tmp1_ = 0U;
	self = (BaobabRingschart*) base;
	_tmp0_ = baobab_chart_get_max_depth ((BaobabChart*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_ > BAOBAB_CHART_MIN_DEPTH;
	return result;
}


BaobabRingschart* baobab_ringschart_construct (GType object_type) {
	BaobabRingschart * self = NULL;
	self = (BaobabRingschart*) baobab_chart_construct (object_type);
	return self;
}


BaobabRingschart* baobab_ringschart_new (void) {
	return baobab_ringschart_construct (BAOBAB_TYPE_RINGSCHART);
}


static void _baobab_ringschart_subtips_update_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	baobab_ringschart_subtips_update ((BaobabRingschart*) self);
}


static GObject * baobab_ringschart_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	BaobabRingschart * self;
	parent_class = G_OBJECT_CLASS (baobab_ringschart_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_RINGSCHART, BaobabRingschart);
	g_signal_connect_object ((GObject*) self, "notify::max-depth", (GCallback) _baobab_ringschart_subtips_update_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::highlighted-item", (GCallback) _baobab_ringschart_subtips_update_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::root", (GCallback) _baobab_ringschart_subtips_update_g_object_notify, self, 0);
	return obj;
}


static void baobab_ringschart_class_init (BaobabRingschartClass * klass) {
	baobab_ringschart_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BaobabRingschartPrivate));
	((BaobabChartClass *) klass)->create_new_chartitem = baobab_ringschart_real_create_new_chartitem;
	((BaobabChartClass *) klass)->post_draw = baobab_ringschart_real_post_draw;
	((BaobabChartClass *) klass)->draw_item = baobab_ringschart_real_draw_item;
	((BaobabChartClass *) klass)->calculate_item_geometry = baobab_ringschart_real_calculate_item_geometry;
	((BaobabChartClass *) klass)->get_item_rectangle = baobab_ringschart_real_get_item_rectangle;
	((BaobabChartClass *) klass)->is_point_over_item = baobab_ringschart_real_is_point_over_item;
	((BaobabChartClass *) klass)->can_zoom_out = baobab_ringschart_real_can_zoom_out;
	((BaobabChartClass *) klass)->can_zoom_in = baobab_ringschart_real_can_zoom_in;
	G_OBJECT_CLASS (klass)->constructor = baobab_ringschart_constructor;
	G_OBJECT_CLASS (klass)->finalize = baobab_ringschart_finalize;
}


static void baobab_ringschart_instance_init (BaobabRingschart * self) {
	self->priv = BAOBAB_RINGSCHART_GET_PRIVATE (self);
	self->priv->tips_timeout_id = (guint) 0;
	self->priv->drawing_subtips = FALSE;
}


static void baobab_ringschart_finalize (GObject* obj) {
	BaobabRingschart * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_RINGSCHART, BaobabRingschart);
	__g_list_free__baobab_chart_item_unref0_0 (self->priv->subtip_items);
	G_OBJECT_CLASS (baobab_ringschart_parent_class)->finalize (obj);
}


GType baobab_ringschart_get_type (void) {
	static volatile gsize baobab_ringschart_type_id__volatile = 0;
	if (g_once_init_enter (&baobab_ringschart_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BaobabRingschartClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) baobab_ringschart_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BaobabRingschart), 0, (GInstanceInitFunc) baobab_ringschart_instance_init, NULL };
		GType baobab_ringschart_type_id;
		baobab_ringschart_type_id = g_type_register_static (BAOBAB_TYPE_CHART, "BaobabRingschart", &g_define_type_info, 0);
		g_once_init_leave (&baobab_ringschart_type_id__volatile, baobab_ringschart_type_id);
	}
	return baobab_ringschart_type_id__volatile;
}



