/* baobab-ringschart.c generated by valac 0.56.18-dirty, 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 "baobab.h"
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <string.h>
#include <pango/pango.h>
#include <stdlib.h>

#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
#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 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;
enum  {
	BAOBAB_RINGSCHART_0_PROPERTY,
	BAOBAB_RINGSCHART_NUM_PROPERTIES
};
static GParamSpec* baobab_ringschart_properties[BAOBAB_RINGSCHART_NUM_PROPERTIES];
#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 _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 _BaobabRingschartPrivate {
	guint tips_timeout_id;
	gboolean drawing_subtips;
	GList* subtip_items;
};

static gpointer baobab_ringschart_item_parent_class = NULL;
static gint BaobabRingschart_private_offset;
static gpointer baobab_ringschart_parent_class = NULL;

VALA_EXTERN GType baobab_ringschart_item_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BaobabRingschartItem* baobab_ringschart_item_new (void);
VALA_EXTERN BaobabRingschartItem* baobab_ringschart_item_construct (GType object_type);
static void baobab_ringschart_item_finalize (BaobabChartItem * obj);
static GType baobab_ringschart_item_get_type_once (void);
static void _baobab_chart_item_unref0_ (gpointer var);
static inline void _g_list_free__baobab_chart_item_unref0_ (GList* self);
static void baobab_ringschart_subtips_update (BaobabRingschart* self);
static gboolean ___lambda27_ (BaobabRingschart* self);
static gboolean ____lambda27__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);
static void baobab_ringschart_real_calculate_item_geometry (BaobabChart* base,
                                                     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);
static gboolean baobab_ringschart_real_can_zoom_in (BaobabChart* base);
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);
static GType baobab_ringschart_get_type_once (void);

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,
                                   gpointer klass_data)
{
	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,
                                      gpointer klass)
{
}

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);
}

static GType
baobab_ringschart_item_get_type_once (void)
{
	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);
	return baobab_ringschart_item_type_id;
}

GType
baobab_ringschart_item_get_type (void)
{
	static volatile gsize baobab_ringschart_item_type_id__once = 0;
	if (g_once_init_enter (&baobab_ringschart_item_type_id__once)) {
		GType baobab_ringschart_item_type_id;
		baobab_ringschart_item_type_id = baobab_ringschart_item_get_type_once ();
		g_once_init_leave (&baobab_ringschart_item_type_id__once, baobab_ringschart_item_type_id);
	}
	return baobab_ringschart_item_type_id__once;
}

static inline gpointer
baobab_ringschart_get_instance_private (BaobabRingschart* self)
{
	return G_STRUCT_MEMBER_P (self, BaobabRingschart_private_offset);
}

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

static inline void
_g_list_free__baobab_chart_item_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _baobab_chart_item_unref0_);
}

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

static gboolean
____lambda27__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda27_ ((BaobabRingschart*) self);
	return result;
}

static void
baobab_ringschart_subtips_update (BaobabRingschart* self)
{
	BaobabChartItem* _tmp0_;
	BaobabChartItem* _tmp1_;
	g_return_if_fail (self != NULL);
	if (self->priv->drawing_subtips) {
		gtk_widget_queue_draw ((GtkWidget*) self);
	}
	self->priv->drawing_subtips = FALSE;
	if (self->priv->tips_timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->tips_timeout_id);
		self->priv->tips_timeout_id = (guint) 0;
	}
	(self->priv->subtip_items == NULL) ? NULL : (self->priv->subtip_items = (_g_list_free__baobab_chart_item_unref0_ (self->priv->subtip_items), NULL));
	self->priv->subtip_items = NULL;
	_tmp0_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		self->priv->tips_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) BAOBAB_RINGSCHART_SUBTIP_TIMEOUT, ____lambda27__gsource_func, g_object_ref (self), g_object_unref);
	}
}

static BaobabChartItem*
baobab_ringschart_real_create_new_chartitem (BaobabChart* base)
{
	BaobabRingschart * self;
	BaobabRingschartItem* _tmp0_;
	BaobabChartItem* _tmp1_;
	BaobabChartItem* result;
	self = (BaobabRingschart*) base;
	_tmp0_ = baobab_ringschart_item_new ();
	_tmp1_ = BAOBAB_IS_CHART_ITEM (_tmp0_) ? ((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;
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp0_;
	GtkStyleContext* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkStyleContext* _tmp3_;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp4_ = {0};
	gint q_width = 0;
	GtkAllocation _tmp5_;
	gint q_height = 0;
	GtkAllocation _tmp6_;
	gdouble q_angle = 0.0;
	GdkRectangle last_rect = {0};
	GtkBorder padding = {0};
	GtkStyleContext* _tmp7_;
	GtkBorder _tmp8_ = {0};
	gint16 vpadding = 0;
	GtkBorder _tmp9_;
	GtkBorder _tmp10_;
	gint16 hpadding = 0;
	GtkBorder _tmp11_;
	GtkBorder _tmp12_;
	GList* _tmp13_;
	GtkStyleContext* _tmp93_;
	self = (BaobabRingschart*) base;
	g_return_if_fail (cr != NULL);
	if (!self->priv->drawing_subtips) {
		return;
	}
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	context = _tmp1_;
	_tmp2_ = context;
	gtk_style_context_save (_tmp2_);
	_tmp3_ = context;
	gtk_style_context_add_class (_tmp3_, "subfolder-tip");
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp4_);
	allocation = _tmp4_;
	_tmp5_ = allocation;
	q_width = _tmp5_.width / 2;
	_tmp6_ = allocation;
	q_height = _tmp6_.height / 2;
	q_angle = atan2 ((gdouble) q_height, (gdouble) q_width);
	memset (&last_rect, 0, sizeof (GdkRectangle));
	_tmp7_ = context;
	gtk_style_context_get_padding (_tmp7_, &_tmp8_);
	padding = _tmp8_;
	_tmp9_ = padding;
	_tmp10_ = padding;
	vpadding = _tmp9_.top + _tmp10_.bottom;
	_tmp11_ = padding;
	_tmp12_ = padding;
	hpadding = _tmp11_.left + _tmp12_.right;
	_tmp13_ = self->priv->subtip_items;
	{
		GList* item_collection = NULL;
		GList* item_it = NULL;
		item_collection = _tmp13_;
		for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
			BaobabChartItem* _tmp14_;
			BaobabChartItem* item = NULL;
			_tmp14_ = _baobab_chart_item_ref0 ((BaobabChartItem*) item_it->data);
			item = _tmp14_;
			{
				BaobabRingschartItem* ringsitem = NULL;
				BaobabChartItem* _tmp15_;
				BaobabRingschartItem* _tmp16_;
				gdouble middle_angle = 0.0;
				BaobabRingschartItem* _tmp17_;
				BaobabRingschartItem* _tmp18_;
				gdouble middle_angle_n = 0.0;
				PangoLayout* layout = NULL;
				PangoLayout* _tmp19_;
				gchar* markup = NULL;
				BaobabChartItem* _tmp20_;
				BaobabScannerResults* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				gchar* _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				gchar* _tmp29_;
				PangoLayout* _tmp30_;
				const gchar* _tmp31_;
				PangoLayout* _tmp32_;
				PangoLayout* _tmp33_;
				PangoLayout* _tmp34_;
				PangoLayout* _tmp35_;
				PangoRectangle layout_rect = {0};
				PangoLayout* _tmp36_;
				PangoRectangle _tmp37_ = {0};
				gdouble tip_x = 0.0;
				gdouble tip_y = 0.0;
				cairo_rectangle_t tooltip_rect = {0};
				PangoRectangle _tmp40_;
				GtkBorder _tmp41_;
				PangoRectangle _tmp42_;
				GtkBorder _tmp43_;
				PangoRectangle _tmp44_;
				PangoRectangle _tmp45_;
				gdouble a = 0.0;
				gint i = 0;
				GdkRectangle _rect = {0};
				cairo_rectangle_t _tmp53_;
				cairo_rectangle_t _tmp54_;
				cairo_rectangle_t _tmp55_;
				cairo_rectangle_t _tmp56_;
				GdkRectangle _tmp57_;
				_tmp15_ = item;
				_tmp16_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (_tmp15_) ? ((BaobabRingschartItem*) _tmp15_) : NULL);
				ringsitem = _tmp16_;
				_tmp17_ = ringsitem;
				_tmp18_ = ringsitem;
				middle_angle = _tmp17_->start_angle + (_tmp18_->angle / 2);
				middle_angle_n = middle_angle;
				while (TRUE) {
					if (!(middle_angle_n > (G_PI / 2))) {
						break;
					}
					middle_angle_n -= G_PI;
				}
				middle_angle_n = fabs (middle_angle_n);
				_tmp19_ = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
				layout = _tmp19_;
				_tmp20_ = item;
				_tmp21_ = _tmp20_->results;
				_tmp22_ = baobab_scanner_results_get_display_name (_tmp21_);
				_tmp23_ = _tmp22_;
				_tmp24_ = g_markup_escape_text (_tmp23_, (gssize) -1);
				_tmp25_ = _tmp24_;
				_tmp26_ = g_strconcat ("<span size=\"small\">", _tmp25_, NULL);
				_tmp27_ = _tmp26_;
				_tmp28_ = g_strconcat (_tmp27_, "</span>", NULL);
				_tmp29_ = _tmp28_;
				_g_free0 (_tmp27_);
				_g_free0 (_tmp25_);
				markup = _tmp29_;
				_tmp30_ = layout;
				_tmp31_ = markup;
				pango_layout_set_markup (_tmp30_, _tmp31_, -1);
				_tmp32_ = layout;
				pango_layout_set_indent (_tmp32_, 0);
				_tmp33_ = layout;
				pango_layout_set_spacing (_tmp33_, 0);
				_tmp34_ = layout;
				pango_layout_set_width (_tmp34_, (PANGO_SCALE * q_width) / 2);
				_tmp35_ = layout;
				pango_layout_set_ellipsize (_tmp35_, PANGO_ELLIPSIZE_END);
				_tmp36_ = layout;
				pango_layout_get_pixel_extents (_tmp36_, NULL, &_tmp37_);
				layout_rect = _tmp37_;
				if (middle_angle_n < q_angle) {
					PangoRectangle _tmp38_;
					_tmp38_ = layout_rect;
					tip_x = (gdouble) ((q_width - (_tmp38_.width / 2)) - hpadding);
					tip_y = tan (middle_angle_n) * tip_x;
				} else {
					PangoRectangle _tmp39_;
					_tmp39_ = layout_rect;
					tip_y = (gdouble) ((q_height - (_tmp39_.height / 2)) - vpadding);
					tip_x = tip_y / tan (middle_angle_n);
				}
				memset (&tooltip_rect, 0, sizeof (cairo_rectangle_t));
				_tmp40_ = layout_rect;
				_tmp41_ = padding;
				tooltip_rect.x = ((q_width + tip_x) - (_tmp40_.width / 2)) - _tmp41_.left;
				_tmp42_ = layout_rect;
				_tmp43_ = padding;
				tooltip_rect.y = ((q_height + tip_y) - (_tmp42_.height / 2)) - _tmp43_.top;
				_tmp44_ = layout_rect;
				tooltip_rect.width = (gdouble) (_tmp44_.width + hpadding);
				_tmp45_ = layout_rect;
				tooltip_rect.height = (gdouble) (_tmp45_.height + vpadding);
				a = middle_angle;
				i = 0;
				while (TRUE) {
					gint _tmp52_;
					if (!(a > (G_PI / 2))) {
						break;
					}
					if ((i % 2) == 0) {
						GtkAllocation _tmp46_;
						cairo_rectangle_t _tmp47_;
						cairo_rectangle_t _tmp48_;
						_tmp46_ = allocation;
						_tmp47_ = tooltip_rect;
						_tmp48_ = tooltip_rect;
						tooltip_rect.x = (_tmp46_.width - _tmp47_.x) - _tmp48_.width;
					} else {
						GtkAllocation _tmp49_;
						cairo_rectangle_t _tmp50_;
						cairo_rectangle_t _tmp51_;
						_tmp49_ = allocation;
						_tmp50_ = tooltip_rect;
						_tmp51_ = tooltip_rect;
						tooltip_rect.y = (_tmp49_.height - _tmp50_.y) - _tmp51_.height;
					}
					_tmp52_ = i;
					i = _tmp52_ + 1;
					a -= G_PI / 2;
				}
				memset (&_rect, 0, sizeof (GdkRectangle));
				_tmp53_ = tooltip_rect;
				_rect.x = (gint) (_tmp53_.x - 1);
				_tmp54_ = tooltip_rect;
				_rect.y = (gint) (_tmp54_.y - 1);
				_tmp55_ = tooltip_rect;
				_rect.width = (gint) (_tmp55_.width + 2);
				_tmp56_ = tooltip_rect;
				_rect.height = (gint) (_tmp56_.height + 2);
				_tmp57_ = last_rect;
				if (!gdk_rectangle_intersect (&_rect, &_tmp57_, NULL)) {
					GdkRectangle _tmp58_;
					cairo_rectangle_t _tmp59_;
					cairo_rectangle_t _tmp60_;
					gdouble middle_radius = 0.0;
					BaobabRingschartItem* _tmp61_;
					BaobabRingschartItem* _tmp62_;
					BaobabRingschartItem* _tmp63_;
					gdouble sector_center_x = 0.0;
					gdouble sector_center_y = 0.0;
					GtkAllocation _tmp64_;
					GtkAllocation _tmp65_;
					cairo_rectangle_t _tmp66_;
					cairo_rectangle_t _tmp67_;
					cairo_rectangle_t _tmp68_;
					cairo_rectangle_t _tmp69_;
					cairo_rectangle_t _tmp70_;
					GdkRGBA bg_color = {0};
					GdkRGBA _tmp71_ = {0};
					GdkRGBA _tmp72_;
					cairo_rectangle_t _tmp73_;
					cairo_rectangle_t _tmp74_;
					cairo_rectangle_t _tmp75_;
					cairo_rectangle_t _tmp76_;
					GtkStyleContext* _tmp77_;
					cairo_rectangle_t _tmp78_;
					cairo_rectangle_t _tmp79_;
					cairo_rectangle_t _tmp80_;
					cairo_rectangle_t _tmp81_;
					GtkStyleContext* _tmp82_;
					cairo_rectangle_t _tmp83_;
					cairo_rectangle_t _tmp84_;
					cairo_rectangle_t _tmp85_;
					cairo_rectangle_t _tmp86_;
					GtkStyleContext* _tmp87_;
					cairo_rectangle_t _tmp88_;
					GtkBorder _tmp89_;
					cairo_rectangle_t _tmp90_;
					GtkBorder _tmp91_;
					PangoLayout* _tmp92_;
					_tmp58_ = _rect;
					last_rect = _tmp58_;
					_tmp59_ = tooltip_rect;
					tooltip_rect.x = floor (_tmp59_.x);
					_tmp60_ = tooltip_rect;
					tooltip_rect.y = floor (_tmp60_.y);
					_tmp61_ = ringsitem;
					_tmp62_ = ringsitem;
					_tmp63_ = ringsitem;
					middle_radius = _tmp61_->min_radius + ((_tmp62_->max_radius - _tmp63_->min_radius) / 2);
					sector_center_x = q_width + (middle_radius * cos (middle_angle));
					sector_center_y = q_height + (middle_radius * sin (middle_angle));
					cairo_save (cr);
					_tmp64_ = allocation;
					_tmp65_ = allocation;
					cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp64_.width, (gdouble) _tmp65_.height);
					_tmp66_ = tooltip_rect;
					_tmp67_ = tooltip_rect;
					_tmp68_ = tooltip_rect;
					_tmp69_ = tooltip_rect;
					_tmp70_ = tooltip_rect;
					cairo_rectangle (cr, _tmp66_.x + _tmp67_.width, _tmp68_.y, -_tmp69_.width, _tmp70_.height);
					cairo_clip (cr);
					_tmp71_.red = (gfloat) 0;
					_tmp71_.green = (gfloat) 0;
					_tmp71_.blue = (gfloat) 0;
					_tmp71_.alpha = (gfloat) 0.8;
					bg_color = _tmp71_;
					cairo_set_line_width (cr, (gdouble) 1);
					cairo_move_to (cr, sector_center_x, sector_center_y);
					_tmp72_ = bg_color;
					gdk_cairo_set_source_rgba (cr, &_tmp72_);
					_tmp73_ = tooltip_rect;
					_tmp74_ = tooltip_rect;
					_tmp75_ = tooltip_rect;
					_tmp76_ = tooltip_rect;
					cairo_line_to (cr, _tmp73_.x + (_tmp74_.width / 2), _tmp75_.y + (_tmp76_.height / 2));
					cairo_stroke (cr);
					cairo_restore (cr);
					cairo_arc (cr, sector_center_x, sector_center_y, 1.0, (gdouble) 0, 2 * G_PI);
					cairo_stroke (cr);
					_tmp77_ = context;
					_tmp78_ = tooltip_rect;
					_tmp79_ = tooltip_rect;
					_tmp80_ = tooltip_rect;
					_tmp81_ = tooltip_rect;
					gtk_render_background (_tmp77_, cr, _tmp78_.x, _tmp79_.y, _tmp80_.width, _tmp81_.height);
					_tmp82_ = context;
					_tmp83_ = tooltip_rect;
					_tmp84_ = tooltip_rect;
					_tmp85_ = tooltip_rect;
					_tmp86_ = tooltip_rect;
					gtk_render_frame (_tmp82_, cr, _tmp83_.x, _tmp84_.y, _tmp85_.width, _tmp86_.height);
					_tmp87_ = context;
					_tmp88_ = tooltip_rect;
					_tmp89_ = padding;
					_tmp90_ = tooltip_rect;
					_tmp91_ = padding;
					_tmp92_ = layout;
					gtk_render_layout (_tmp87_, cr, _tmp88_.x + _tmp89_.left, _tmp90_.y + _tmp91_.top, _tmp92_);
				}
				_g_free0 (markup);
				_g_object_unref0 (layout);
				_baobab_chart_item_unref0 (ringsitem);
				_baobab_chart_item_unref0 (item);
			}
		}
	}
	_tmp93_ = context;
	gtk_style_context_restore (_tmp93_);
	_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;
	BaobabRingschartItem* _tmp0_;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp11_ = {0};
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp12_;
	GtkStyleContext* _tmp13_;
	GdkRGBA border_color = {0};
	GdkRGBA bg_color = {0};
	GtkStyleContext* _tmp14_;
	GdkRGBA _tmp15_ = {0};
	GtkStyleContext* _tmp16_;
	GdkRGBA _tmp17_ = {0};
	gint center_x = 0;
	GtkAllocation _tmp18_;
	gint center_y = 0;
	GtkAllocation _tmp19_;
	gdouble final_angle = 0.0;
	BaobabRingschartItem* _tmp20_;
	BaobabRingschartItem* _tmp21_;
	self = (BaobabRingschart*) base;
	g_return_if_fail (cr != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (item) ? ((BaobabRingschartItem*) item) : NULL);
	ringsitem = _tmp0_;
	if (self->priv->drawing_subtips) {
		gboolean _tmp1_ = FALSE;
		gboolean _tmp2_ = FALSE;
		BaobabChartItem* _tmp3_;
		BaobabChartItem* _tmp4_;
		_tmp3_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
		_tmp4_ = _tmp3_;
		if (_tmp4_ != NULL) {
			GList* _tmp5_;
			_tmp5_ = item->parent;
			_tmp2_ = _tmp5_ != NULL;
		} else {
			_tmp2_ = FALSE;
		}
		if (_tmp2_) {
			GList* _tmp6_;
			gconstpointer _tmp7_;
			BaobabChartItem* _tmp8_;
			BaobabChartItem* _tmp9_;
			_tmp6_ = item->parent;
			_tmp7_ = _tmp6_->data;
			_tmp8_ = baobab_chart_get_highlighted_item ((BaobabChart*) self);
			_tmp9_ = _tmp8_;
			_tmp1_ = ((BaobabChartItem*) _tmp7_) == _tmp9_;
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			BaobabChartItem* _tmp10_;
			_tmp10_ = _baobab_chart_item_ref0 (item);
			self->priv->subtip_items = g_list_append (self->priv->subtip_items, _tmp10_);
		}
	}
	cairo_set_line_width (cr, (gdouble) BAOBAB_RINGSCHART_ITEM_BORDER_WIDTH);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp11_);
	allocation = _tmp11_;
	_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp13_ = _g_object_ref0 (_tmp12_);
	context = _tmp13_;
	_tmp14_ = context;
	gtk_style_context_lookup_color (_tmp14_, "chart_borders", &_tmp15_);
	border_color = _tmp15_;
	_tmp16_ = context;
	gtk_style_context_lookup_color (_tmp16_, "theme_bg_color", &_tmp17_);
	bg_color = _tmp17_;
	_tmp18_ = allocation;
	center_x = _tmp18_.width / 2;
	_tmp19_ = allocation;
	center_y = _tmp19_.height / 2;
	_tmp20_ = ringsitem;
	_tmp21_ = ringsitem;
	final_angle = _tmp20_->start_angle + _tmp21_->angle;
	if (item->depth == ((guint) 0)) {
		PangoLayout* layout = NULL;
		PangoLayout* _tmp22_;
		gchar* size = NULL;
		BaobabScannerResults* _tmp23_;
		guint64 _tmp24_;
		guint64 _tmp25_;
		gchar* _tmp26_;
		gchar* markup = NULL;
		const gchar* _tmp27_;
		gchar* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		PangoLayout* _tmp34_;
		const gchar* _tmp35_;
		PangoLayout* _tmp36_;
		PangoLayout* _tmp37_;
		PangoRectangle layout_rect = {0};
		PangoLayout* _tmp38_;
		PangoRectangle _tmp39_ = {0};
		PangoRectangle _tmp40_;
		BaobabRingschartItem* _tmp41_;
		BaobabRingschartItem* _tmp47_;
		GdkRGBA _tmp48_;
		_tmp22_ = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
		layout = _tmp22_;
		_tmp23_ = item->results;
		_tmp24_ = baobab_scanner_results_get_size (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_format_size_full (_tmp25_, G_FORMAT_SIZE_DEFAULT);
		size = _tmp26_;
		_tmp27_ = size;
		_tmp28_ = g_markup_escape_text (_tmp27_, (gssize) -1);
		_tmp29_ = _tmp28_;
		_tmp30_ = g_strconcat ("<span size=\"small\">", _tmp29_, NULL);
		_tmp31_ = _tmp30_;
		_tmp32_ = g_strconcat (_tmp31_, "</span>", NULL);
		_tmp33_ = _tmp32_;
		_g_free0 (_tmp31_);
		_g_free0 (_tmp29_);
		markup = _tmp33_;
		_tmp34_ = layout;
		_tmp35_ = markup;
		pango_layout_set_markup (_tmp34_, _tmp35_, -1);
		_tmp36_ = layout;
		pango_layout_set_indent (_tmp36_, 0);
		_tmp37_ = layout;
		pango_layout_set_spacing (_tmp37_, 0);
		_tmp38_ = layout;
		pango_layout_get_pixel_extents (_tmp38_, NULL, &_tmp39_);
		layout_rect = _tmp39_;
		_tmp40_ = layout_rect;
		_tmp41_ = ringsitem;
		if (((gdouble) _tmp40_.width) < (2 * _tmp41_->max_radius)) {
			GtkStyleContext* _tmp42_;
			PangoRectangle _tmp43_;
			PangoRectangle _tmp44_;
			PangoLayout* _tmp45_;
			BaobabRingschartItem* _tmp46_;
			_tmp42_ = context;
			_tmp43_ = layout_rect;
			_tmp44_ = layout_rect;
			_tmp45_ = layout;
			gtk_render_layout (_tmp42_, cr, (gdouble) (center_x - (_tmp43_.width / 2)), (gdouble) (center_y - (_tmp44_.height / 2)), _tmp45_);
			_tmp46_ = ringsitem;
			cairo_move_to (cr, (center_x + _tmp46_->max_radius) + 1, (gdouble) center_y);
		}
		_tmp47_ = ringsitem;
		cairo_arc (cr, (gdouble) center_x, (gdouble) center_y, _tmp47_->max_radius + 1, (gdouble) 0, 2 * G_PI);
		_tmp48_ = border_color;
		gdk_cairo_set_source_rgba (cr, &_tmp48_);
		cairo_stroke (cr);
		_g_free0 (markup);
		_g_free0 (size);
		_g_object_unref0 (layout);
	} else {
		GdkRGBA fill_color = {0};
		BaobabRingschartItem* _tmp49_;
		GdkRGBA _tmp50_ = {0};
		BaobabRingschartItem* _tmp51_;
		BaobabRingschartItem* _tmp52_;
		BaobabRingschartItem* _tmp53_;
		BaobabRingschartItem* _tmp54_;
		GdkRGBA _tmp55_;
		GdkRGBA _tmp56_;
		BaobabRingschartItem* _tmp57_;
		_tmp49_ = ringsitem;
		baobab_chart_get_item_color ((BaobabChart*) self, (_tmp49_->start_angle / G_PI) * 99, item->depth, highlighted, &_tmp50_);
		fill_color = _tmp50_;
		_tmp51_ = ringsitem;
		_tmp52_ = ringsitem;
		cairo_arc (cr, (gdouble) center_x, (gdouble) center_y, _tmp51_->min_radius, _tmp52_->start_angle, final_angle);
		_tmp53_ = ringsitem;
		_tmp54_ = ringsitem;
		cairo_arc_negative (cr, (gdouble) center_x, (gdouble) center_y, _tmp53_->max_radius, final_angle, _tmp54_->start_angle);
		cairo_close_path (cr);
		_tmp55_ = fill_color;
		gdk_cairo_set_source_rgba (cr, &_tmp55_);
		cairo_fill_preserve (cr);
		_tmp56_ = bg_color;
		gdk_cairo_set_source_rgba (cr, &_tmp56_);
		cairo_stroke (cr);
		_tmp57_ = ringsitem;
		if (_tmp57_->continued) {
			GdkRGBA _tmp58_;
			BaobabRingschartItem* _tmp59_;
			BaobabRingschartItem* _tmp60_;
			_tmp58_ = border_color;
			gdk_cairo_set_source_rgba (cr, &_tmp58_);
			cairo_set_line_width (cr, (gdouble) 3);
			_tmp59_ = ringsitem;
			_tmp60_ = ringsitem;
			cairo_arc (cr, (gdouble) center_x, (gdouble) center_y, _tmp59_->max_radius + 4, _tmp60_->start_angle + BAOBAB_RINGSCHART_EDGE_ANGLE, final_angle - BAOBAB_RINGSCHART_EDGE_ANGLE);
			cairo_stroke (cr);
		}
	}
	_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;
	BaobabRingschartItem* _tmp0_;
	BaobabRingschartItem* _tmp1_;
	BaobabRingschartItem* _tmp2_;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp3_ = {0};
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp4_;
	GtkStyleContext* _tmp5_;
	GtkBorder padding = {0};
	GtkStyleContext* _tmp6_;
	GtkBorder _tmp7_ = {0};
	gint max_radius = 0;
	GtkAllocation _tmp8_;
	GtkAllocation _tmp9_;
	GtkBorder _tmp10_;
	guint thickness = 0U;
	guint _tmp11_;
	guint _tmp12_;
	BaobabRingschartItem* _tmp13_;
	GList* _tmp14_;
	BaobabRingschartItem* _tmp48_;
	self = (BaobabRingschart*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (item) ? ((BaobabRingschartItem*) item) : NULL);
	ringsitem = _tmp0_;
	_tmp1_ = ringsitem;
	_tmp1_->continued = FALSE;
	_tmp2_ = ringsitem;
	((BaobabChartItem*) _tmp2_)->visible = FALSE;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp3_);
	allocation = _tmp3_;
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	context = _tmp5_;
	_tmp6_ = context;
	gtk_style_context_get_padding (_tmp6_, &_tmp7_);
	padding = _tmp7_;
	_tmp8_ = allocation;
	_tmp9_ = allocation;
	_tmp10_ = padding;
	max_radius = MIN (_tmp8_.width / 2, _tmp9_.height / 2) - _tmp10_.left;
	_tmp11_ = baobab_chart_get_max_depth ((BaobabChart*) self);
	_tmp12_ = _tmp11_;
	thickness = max_radius / (_tmp12_ + 1);
	_tmp13_ = ringsitem;
	_tmp14_ = ((BaobabChartItem*) _tmp13_)->parent;
	if (_tmp14_ == NULL) {
		BaobabRingschartItem* _tmp15_;
		BaobabRingschartItem* _tmp16_;
		BaobabRingschartItem* _tmp17_;
		BaobabRingschartItem* _tmp18_;
		_tmp15_ = ringsitem;
		_tmp15_->min_radius = (gdouble) 0;
		_tmp16_ = ringsitem;
		_tmp16_->max_radius = (gdouble) thickness;
		_tmp17_ = ringsitem;
		_tmp17_->start_angle = (gdouble) 0;
		_tmp18_ = ringsitem;
		_tmp18_->angle = 2 * G_PI;
	} else {
		BaobabRingschartItem* parent = NULL;
		GList* _tmp19_;
		gconstpointer _tmp20_;
		BaobabChartItem* _tmp21_;
		BaobabRingschartItem* _tmp22_;
		BaobabRingschartItem* _tmp23_;
		BaobabRingschartItem* _tmp24_;
		BaobabRingschartItem* _tmp25_;
		guint _tmp26_;
		guint _tmp27_;
		BaobabRingschartItem* _tmp30_;
		BaobabRingschartItem* _tmp31_;
		BaobabRingschartItem* _tmp32_;
		BaobabRingschartItem* _tmp33_;
		BaobabRingschartItem* _tmp34_;
		BaobabRingschartItem* _tmp35_;
		BaobabRingschartItem* _tmp36_;
		BaobabRingschartItem* _tmp37_;
		gboolean _tmp38_ = FALSE;
		BaobabRingschartItem* _tmp39_;
		BaobabScannerResults* _tmp40_;
		gboolean _tmp41_;
		gboolean _tmp42_;
		BaobabRingschartItem* _tmp46_;
		BaobabRingschartItem* _tmp47_;
		_tmp19_ = item->parent;
		_tmp20_ = _tmp19_->data;
		_tmp21_ = (BaobabChartItem*) _tmp20_;
		_tmp22_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (_tmp21_) ? ((BaobabRingschartItem*) _tmp21_) : NULL);
		parent = _tmp22_;
		_tmp23_ = ringsitem;
		_tmp24_ = ringsitem;
		_tmp23_->min_radius = (gdouble) (((BaobabChartItem*) _tmp24_)->depth * thickness);
		_tmp25_ = ringsitem;
		_tmp26_ = baobab_chart_get_max_depth ((BaobabChart*) self);
		_tmp27_ = _tmp26_;
		if (((BaobabChartItem*) _tmp25_)->depth > _tmp27_) {
			_baobab_chart_item_unref0 (parent);
			_g_object_unref0 (context);
			_baobab_chart_item_unref0 (ringsitem);
			return;
		} else {
			BaobabRingschartItem* _tmp28_;
			BaobabRingschartItem* _tmp29_;
			_tmp28_ = ringsitem;
			_tmp29_ = ringsitem;
			_tmp28_->max_radius = _tmp29_->min_radius + thickness;
		}
		_tmp30_ = ringsitem;
		_tmp31_ = parent;
		_tmp32_ = ringsitem;
		_tmp30_->angle = (_tmp31_->angle * ((BaobabChartItem*) _tmp32_)->rel_size) / 100;
		_tmp33_ = ringsitem;
		if (_tmp33_->angle < BAOBAB_RINGSCHART_ITEM_MIN_ANGLE) {
			_baobab_chart_item_unref0 (parent);
			_g_object_unref0 (context);
			_baobab_chart_item_unref0 (ringsitem);
			return;
		}
		_tmp34_ = ringsitem;
		_tmp35_ = parent;
		_tmp36_ = parent;
		_tmp37_ = ringsitem;
		_tmp34_->start_angle = _tmp35_->start_angle + ((_tmp36_->angle * ((BaobabChartItem*) _tmp37_)->rel_start) / 100);
		_tmp39_ = ringsitem;
		_tmp40_ = ((BaobabChartItem*) _tmp39_)->results;
		_tmp41_ = baobab_scanner_results_get_is_empty (_tmp40_);
		_tmp42_ = _tmp41_;
		if (!_tmp42_) {
			BaobabRingschartItem* _tmp43_;
			guint _tmp44_;
			guint _tmp45_;
			_tmp43_ = ringsitem;
			_tmp44_ = baobab_chart_get_max_depth ((BaobabChart*) self);
			_tmp45_ = _tmp44_;
			_tmp38_ = ((BaobabChartItem*) _tmp43_)->depth == _tmp45_;
		} else {
			_tmp38_ = FALSE;
		}
		_tmp46_ = ringsitem;
		_tmp46_->continued = _tmp38_;
		_tmp47_ = parent;
		((BaobabChartItem*) _tmp47_)->has_visible_children = TRUE;
		_baobab_chart_item_unref0 (parent);
	}
	_tmp48_ = ringsitem;
	((BaobabChartItem*) _tmp48_)->visible = TRUE;
	baobab_chart_get_item_rectangle ((BaobabChart*) self, item);
	_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;
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (r != NULL);
	x = cx + (cos (angle) * radius);
	y = cy + (sin (angle) * radius);
	_tmp0_ = *r;
	(*r).x = MIN (_tmp0_.x, (gint) x);
	_tmp1_ = *r;
	(*r).y = MIN (_tmp1_.y, (gint) y);
	_tmp2_ = *r;
	(*r).width = MAX (_tmp2_.width, (gint) x);
	_tmp3_ = *r;
	(*r).height = MAX (_tmp3_.height, (gint) y);
}

static void
baobab_ringschart_real_get_item_rectangle (BaobabChart* base,
                                           BaobabChartItem* item)
{
	BaobabRingschart * self;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabRingschartItem* _tmp0_;
	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 _tmp1_ = {0};
	GtkAllocation _tmp2_;
	GtkAllocation _tmp3_;
	BaobabRingschartItem* _tmp4_;
	BaobabRingschartItem* _tmp5_;
	BaobabRingschartItem* _tmp6_;
	BaobabRingschartItem* _tmp7_;
	BaobabRingschartItem* _tmp8_;
	GtkAllocation _tmp9_;
	GtkAllocation _tmp10_;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp13_ = FALSE;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp17_ = FALSE;
	GdkRectangle _tmp19_;
	GdkRectangle _tmp20_;
	BaobabRingschartItem* _tmp21_;
	GdkRectangle _tmp22_;
	self = (BaobabRingschart*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (item) ? ((BaobabRingschartItem*) item) : NULL);
	ringsitem = _tmp0_;
	memset (&rect, 0, sizeof (GdkRectangle));
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp1_);
	allocation = _tmp1_;
	_tmp2_ = allocation;
	cx = (gdouble) (_tmp2_.width / 2);
	_tmp3_ = allocation;
	cy = (gdouble) (_tmp3_.height / 2);
	_tmp4_ = ringsitem;
	r1 = _tmp4_->min_radius;
	_tmp5_ = ringsitem;
	r2 = _tmp5_->max_radius;
	_tmp6_ = ringsitem;
	a1 = _tmp6_->start_angle;
	_tmp7_ = ringsitem;
	_tmp8_ = ringsitem;
	a2 = _tmp7_->start_angle + _tmp8_->angle;
	_tmp9_ = allocation;
	rect.x = _tmp9_.width;
	_tmp10_ = allocation;
	rect.y = _tmp10_.height;
	rect.width = 0;
	rect.height = 0;
	baobab_ringschart_get_point_min_rect (self, cx, cy, r1, a1, &rect);
	baobab_ringschart_get_point_min_rect (self, cx, cy, r2, a1, &rect);
	baobab_ringschart_get_point_min_rect (self, cx, cy, r1, a2, &rect);
	baobab_ringschart_get_point_min_rect (self, cx, cy, r2, a2, &rect);
	if (a1 <= (G_PI / 2)) {
		_tmp11_ = a2 >= (G_PI / 2);
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		GdkRectangle _tmp12_;
		_tmp12_ = rect;
		rect.height = (gint) MAX ((gdouble) _tmp12_.height, cy + (sin (G_PI / 2) * r2));
	}
	if (a1 <= G_PI) {
		_tmp13_ = a2 >= G_PI;
	} else {
		_tmp13_ = FALSE;
	}
	if (_tmp13_) {
		GdkRectangle _tmp14_;
		_tmp14_ = rect;
		rect.x = (gint) MIN ((gdouble) _tmp14_.x, cx + (cos (G_PI) * r2));
	}
	if (a1 <= (G_PI * 1.5)) {
		_tmp15_ = a2 >= (G_PI * 1.5);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		GdkRectangle _tmp16_;
		_tmp16_ = rect;
		rect.y = (gint) MIN ((gdouble) _tmp16_.y, cy + (sin (G_PI * 1.5) * r2));
	}
	if (a1 <= (G_PI * 2)) {
		_tmp17_ = a2 >= (G_PI * 2);
	} else {
		_tmp17_ = FALSE;
	}
	if (_tmp17_) {
		GdkRectangle _tmp18_;
		_tmp18_ = rect;
		rect.width = (gint) MAX ((gdouble) _tmp18_.width, cx + (cos (G_PI * 2) * r2));
	}
	_tmp19_ = rect;
	rect.width = rect.width - _tmp19_.x;
	_tmp20_ = rect;
	rect.height = rect.height - _tmp20_.y;
	_tmp21_ = ringsitem;
	_tmp22_ = rect;
	((BaobabChartItem*) _tmp21_)->rect = _tmp22_;
	_baobab_chart_item_unref0 (ringsitem);
}

static gboolean
baobab_ringschart_real_is_point_over_item (BaobabChart* base,
                                           BaobabChartItem* item,
                                           gdouble x,
                                           gdouble y)
{
	BaobabRingschart * self;
	BaobabRingschartItem* ringsitem = NULL;
	BaobabRingschartItem* _tmp0_;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp1_ = {0};
	GtkAllocation _tmp2_;
	GtkAllocation _tmp3_;
	gdouble radius = 0.0;
	gdouble angle = 0.0;
	gdouble _tmp4_ = 0.0;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	BaobabRingschartItem* _tmp8_;
	gboolean result;
	self = (BaobabRingschart*) base;
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = _baobab_chart_item_ref0 (BAOBAB_IS_RINGSCHART_ITEM (item) ? ((BaobabRingschartItem*) item) : NULL);
	ringsitem = _tmp0_;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp1_);
	allocation = _tmp1_;
	_tmp2_ = allocation;
	x = x - (_tmp2_.width / 2);
	_tmp3_ = allocation;
	y = y - (_tmp3_.height / 2);
	radius = sqrt ((x * x) + (y * y));
	angle = atan2 (y, x);
	if (angle > ((gdouble) 0)) {
		_tmp4_ = angle;
	} else {
		_tmp4_ = angle + (2 * G_PI);
	}
	angle = _tmp4_;
	_tmp8_ = ringsitem;
	if (radius >= _tmp8_->min_radius) {
		BaobabRingschartItem* _tmp9_;
		_tmp9_ = ringsitem;
		_tmp7_ = radius <= _tmp9_->max_radius;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		BaobabRingschartItem* _tmp10_;
		_tmp10_ = ringsitem;
		_tmp6_ = angle >= _tmp10_->start_angle;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		BaobabRingschartItem* _tmp11_;
		BaobabRingschartItem* _tmp12_;
		_tmp11_ = ringsitem;
		_tmp12_ = ringsitem;
		_tmp5_ = angle <= (_tmp11_->start_angle + _tmp12_->angle);
	} else {
		_tmp5_ = FALSE;
	}
	result = _tmp5_;
	_baobab_chart_item_unref0 (ringsitem);
	return result;
}

static gboolean
baobab_ringschart_real_can_zoom_out (BaobabChart* base)
{
	BaobabRingschart * self;
	guint _tmp0_;
	guint _tmp1_;
	gboolean result;
	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;
	guint _tmp0_;
	guint _tmp1_;
	gboolean result;
	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,
                              gpointer klass_data)
{
	baobab_ringschart_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BaobabRingschart_private_offset);
	((BaobabChartClass *) klass)->create_new_chartitem = (BaobabChartItem* (*) (BaobabChart*)) baobab_ringschart_real_create_new_chartitem;
	((BaobabChartClass *) klass)->post_draw = (void (*) (BaobabChart*, cairo_t*)) baobab_ringschart_real_post_draw;
	((BaobabChartClass *) klass)->draw_item = (void (*) (BaobabChart*, cairo_t*, BaobabChartItem*, gboolean)) baobab_ringschart_real_draw_item;
	((BaobabChartClass *) klass)->calculate_item_geometry = (void (*) (BaobabChart*, BaobabChartItem*)) baobab_ringschart_real_calculate_item_geometry;
	((BaobabChartClass *) klass)->get_item_rectangle = (void (*) (BaobabChart*, BaobabChartItem*)) baobab_ringschart_real_get_item_rectangle;
	((BaobabChartClass *) klass)->is_point_over_item = (gboolean (*) (BaobabChart*, BaobabChartItem*, gdouble, gdouble)) baobab_ringschart_real_is_point_over_item;
	((BaobabChartClass *) klass)->can_zoom_out = (gboolean (*) (BaobabChart*)) baobab_ringschart_real_can_zoom_out;
	((BaobabChartClass *) klass)->can_zoom_in = (gboolean (*) (BaobabChart*)) baobab_ringschart_real_can_zoom_in;
	G_OBJECT_CLASS (klass)->constructor = baobab_ringschart_constructor;
	G_OBJECT_CLASS (klass)->finalize = baobab_ringschart_finalize;
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "ringschart");
}

static void
baobab_ringschart_instance_init (BaobabRingschart * self,
                                 gpointer klass)
{
	self->priv = baobab_ringschart_get_instance_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);
	(self->priv->subtip_items == NULL) ? NULL : (self->priv->subtip_items = (_g_list_free__baobab_chart_item_unref0_ (self->priv->subtip_items), NULL));
	G_OBJECT_CLASS (baobab_ringschart_parent_class)->finalize (obj);
}

static GType
baobab_ringschart_get_type_once (void)
{
	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);
	BaobabRingschart_private_offset = g_type_add_instance_private (baobab_ringschart_type_id, sizeof (BaobabRingschartPrivate));
	return baobab_ringschart_type_id;
}

GType
baobab_ringschart_get_type (void)
{
	static volatile gsize baobab_ringschart_type_id__once = 0;
	if (g_once_init_enter (&baobab_ringschart_type_id__once)) {
		GType baobab_ringschart_type_id;
		baobab_ringschart_type_id = baobab_ringschart_get_type_once ();
		g_once_init_leave (&baobab_ringschart_type_id__once, baobab_ringschart_type_id);
	}
	return baobab_ringschart_type_id__once;
}

