/* renderedText.c generated by valac 0.56.18, the Vala compiler
 * generated from renderedText.vala, do not modify */

/*///////////////////////////////////////////////////////////////////////*/
/* Copyright 2011-2021 Simon Schneegans*/
/**/
/* Permission is hereby granted, free of charge, to any person obtaining*/
/* a copy of this software and associated documentation files (the*/
/* "Software"), to deal in the Software without restriction, including*/
/* without limitation the rights to use, copy, modify, merge, publish,*/
/* distribute, sublicense, and/or sell copies of the Software, and to*/
/* permit persons to whom the Software is furnished to do so, subject to*/
/* the following conditions:*/
/* */
/* The above copyright notice and this permission notice shall be*/
/* included in all copies or substantial portions of the Software.*/
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,*/
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF*/
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY*/
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,*/
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE*/
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
/*///////////////////////////////////////////////////////////////////////*/

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GNOME_PIE_TYPE_IMAGE (gnome_pie_image_get_type ())
#define GNOME_PIE_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_IMAGE, GnomePieImage))
#define GNOME_PIE_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_IMAGE, GnomePieImageClass))
#define GNOME_PIE_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_IMAGE))
#define GNOME_PIE_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_IMAGE))
#define GNOME_PIE_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_IMAGE, GnomePieImageClass))

typedef struct _GnomePieImage GnomePieImage;
typedef struct _GnomePieImageClass GnomePieImageClass;
typedef struct _GnomePieImagePrivate GnomePieImagePrivate;

#define GNOME_PIE_TYPE_RENDERED_TEXT (gnome_pie_rendered_text_get_type ())
#define GNOME_PIE_RENDERED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_RENDERED_TEXT, GnomePieRenderedText))
#define GNOME_PIE_RENDERED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_RENDERED_TEXT, GnomePieRenderedTextClass))
#define GNOME_PIE_IS_RENDERED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_RENDERED_TEXT))
#define GNOME_PIE_IS_RENDERED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_RENDERED_TEXT))
#define GNOME_PIE_RENDERED_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_RENDERED_TEXT, GnomePieRenderedTextClass))

typedef struct _GnomePieRenderedText GnomePieRenderedText;
typedef struct _GnomePieRenderedTextClass GnomePieRenderedTextClass;
typedef struct _GnomePieRenderedTextPrivate GnomePieRenderedTextPrivate;
enum  {
	GNOME_PIE_RENDERED_TEXT_0_PROPERTY,
	GNOME_PIE_RENDERED_TEXT_NUM_PROPERTIES
};
static GParamSpec* gnome_pie_rendered_text_properties[GNOME_PIE_RENDERED_TEXT_NUM_PROPERTIES];

#define GNOME_PIE_TYPE_COLOR (gnome_pie_color_get_type ())
#define GNOME_PIE_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_COLOR, GnomePieColor))
#define GNOME_PIE_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_COLOR, GnomePieColorClass))
#define GNOME_PIE_IS_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_COLOR))
#define GNOME_PIE_IS_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_COLOR))
#define GNOME_PIE_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_COLOR, GnomePieColorClass))

typedef struct _GnomePieColor GnomePieColor;
typedef struct _GnomePieColorClass GnomePieColorClass;
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (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)))
#define __vala_PangoFontDescription_free0(var) ((var == NULL) ? NULL : (var = (_vala_PangoFontDescription_free (var), NULL)))
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))

struct _GnomePieImage {
	GObject parent_instance;
	GnomePieImagePrivate * priv;
};

struct _GnomePieImageClass {
	GObjectClass parent_class;
};

struct _GnomePieRenderedText {
	GnomePieImage parent_instance;
	GnomePieRenderedTextPrivate * priv;
};

struct _GnomePieRenderedTextClass {
	GnomePieImageClass parent_class;
};

static gpointer gnome_pie_rendered_text_parent_class = NULL;

VALA_EXTERN GType gnome_pie_image_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieImage, g_object_unref)
VALA_EXTERN GType gnome_pie_rendered_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieRenderedText, g_object_unref)
VALA_EXTERN GType gnome_pie_color_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieColor, g_object_unref)
VALA_EXTERN GnomePieRenderedText* gnome_pie_rendered_text_new (const gchar* text,
                                                   gint width,
                                                   gint height,
                                                   const gchar* font,
                                                   GnomePieColor* color,
                                                   gdouble scale);
VALA_EXTERN GnomePieRenderedText* gnome_pie_rendered_text_construct (GType object_type,
                                                         const gchar* text,
                                                         gint width,
                                                         gint height,
                                                         const gchar* font,
                                                         GnomePieColor* color,
                                                         gdouble scale);
VALA_EXTERN GnomePieImage* gnome_pie_image_new (void);
VALA_EXTERN GnomePieImage* gnome_pie_image_construct (GType object_type);
VALA_EXTERN void gnome_pie_rendered_text_render_text (GnomePieRenderedText* self,
                                          const gchar* text,
                                          gint width,
                                          gint height,
                                          const gchar* font,
                                          GnomePieColor* color,
                                          gdouble scale);
VALA_EXTERN GnomePieRenderedText* gnome_pie_rendered_text_new_with_markup (const gchar* text,
                                                               gint width,
                                                               gint height,
                                                               const gchar* font,
                                                               GnomePieColor* color,
                                                               gdouble scale);
VALA_EXTERN GnomePieRenderedText* gnome_pie_rendered_text_construct_with_markup (GType object_type,
                                                                     const gchar* text,
                                                                     gint width,
                                                                     gint height,
                                                                     const gchar* font,
                                                                     GnomePieColor* color,
                                                                     gdouble scale);
VALA_EXTERN void gnome_pie_rendered_text_render_markup (GnomePieRenderedText* self,
                                            const gchar* text,
                                            gint width,
                                            gint height,
                                            const gchar* font,
                                            GnomePieColor* color,
                                            gdouble scale);
VALA_EXTERN void gnome_pie_image_set_surface (GnomePieImage* self,
                                  cairo_surface_t* value);
VALA_EXTERN cairo_t* gnome_pie_image_context (GnomePieImage* self);
VALA_EXTERN gfloat gnome_pie_color_get_r (GnomePieColor* self);
VALA_EXTERN gfloat gnome_pie_color_get_g (GnomePieColor* self);
static void _vala_PangoFontDescription_free (PangoFontDescription* self);
static GType gnome_pie_rendered_text_get_type_once (void);

GnomePieRenderedText*
gnome_pie_rendered_text_construct (GType object_type,
                                   const gchar* text,
                                   gint width,
                                   gint height,
                                   const gchar* font,
                                   GnomePieColor* color,
                                   gdouble scale)
{
	GnomePieRenderedText * self = NULL;
	g_return_val_if_fail (text != NULL, NULL);
	g_return_val_if_fail (font != NULL, NULL);
	g_return_val_if_fail (color != NULL, NULL);
	self = (GnomePieRenderedText*) gnome_pie_image_construct (object_type);
	gnome_pie_rendered_text_render_text (self, text, width, height, font, color, scale);
	return self;
}

GnomePieRenderedText*
gnome_pie_rendered_text_new (const gchar* text,
                             gint width,
                             gint height,
                             const gchar* font,
                             GnomePieColor* color,
                             gdouble scale)
{
	return gnome_pie_rendered_text_construct (GNOME_PIE_TYPE_RENDERED_TEXT, text, width, height, font, color, scale);
}

GnomePieRenderedText*
gnome_pie_rendered_text_construct_with_markup (GType object_type,
                                               const gchar* text,
                                               gint width,
                                               gint height,
                                               const gchar* font,
                                               GnomePieColor* color,
                                               gdouble scale)
{
	GnomePieRenderedText * self = NULL;
	g_return_val_if_fail (text != NULL, NULL);
	g_return_val_if_fail (font != NULL, NULL);
	g_return_val_if_fail (color != NULL, NULL);
	self = (GnomePieRenderedText*) gnome_pie_image_construct (object_type);
	gnome_pie_rendered_text_render_markup (self, text, width, height, font, color, scale);
	return self;
}

GnomePieRenderedText*
gnome_pie_rendered_text_new_with_markup (const gchar* text,
                                         gint width,
                                         gint height,
                                         const gchar* font,
                                         GnomePieColor* color,
                                         gdouble scale)
{
	return gnome_pie_rendered_text_construct_with_markup (GNOME_PIE_TYPE_RENDERED_TEXT, text, width, height, font, color, scale);
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static void
_vala_PangoFontDescription_free (PangoFontDescription* self)
{
	g_boxed_free (pango_font_description_get_type (), self);
}

void
gnome_pie_rendered_text_render_text (GnomePieRenderedText* self,
                                     const gchar* text,
                                     gint width,
                                     gint height,
                                     const gchar* font,
                                     GnomePieColor* color,
                                     gdouble scale)
{
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (font != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
	_tmp1_ = _tmp0_;
	gnome_pie_image_set_surface ((GnomePieImage*) self, _tmp1_);
	_cairo_surface_destroy0 (_tmp1_);
	if (g_strcmp0 (text, "") != 0) {
		cairo_t* ctx = NULL;
		cairo_t* _tmp2_;
		cairo_t* _tmp3_;
		gfloat _tmp4_;
		gfloat _tmp5_;
		gfloat _tmp6_;
		gfloat _tmp7_;
		gfloat _tmp8_;
		gfloat _tmp9_;
		PangoLayout* layout = NULL;
		cairo_t* _tmp10_;
		PangoLayout* _tmp11_;
		PangoLayout* _tmp12_;
		PangoFontDescription* font_description = NULL;
		PangoFontDescription* _tmp13_;
		PangoFontDescription* _tmp14_;
		PangoFontDescription* _tmp15_;
		PangoLayout* _tmp16_;
		PangoFontDescription* _tmp17_;
		PangoLayout* _tmp18_;
		gchar* broken_string = NULL;
		gchar* _tmp19_;
		PangoLayout* _tmp58_;
		const gchar* _tmp59_;
		PangoLayout* _tmp60_;
		PangoLayout* _tmp61_;
		PangoRectangle extents = {0};
		PangoLayout* _tmp62_;
		PangoRectangle _tmp63_ = {0};
		cairo_t* _tmp64_;
		PangoRectangle _tmp65_;
		cairo_t* _tmp66_;
		PangoLayout* _tmp67_;
		cairo_t* _tmp68_;
		PangoLayout* _tmp69_;
		_tmp2_ = gnome_pie_image_context ((GnomePieImage*) self);
		ctx = _tmp2_;
		_tmp3_ = ctx;
		_tmp4_ = gnome_pie_color_get_r (color);
		_tmp5_ = _tmp4_;
		_tmp6_ = gnome_pie_color_get_g (color);
		_tmp7_ = _tmp6_;
		_tmp8_ = gnome_pie_color_get_g (color);
		_tmp9_ = _tmp8_;
		cairo_set_source_rgb (_tmp3_, (gdouble) _tmp5_, (gdouble) _tmp7_, (gdouble) _tmp9_);
		_tmp10_ = ctx;
		_tmp11_ = pango_cairo_create_layout (_tmp10_);
		layout = _tmp11_;
		_tmp12_ = layout;
		pango_layout_set_width (_tmp12_, pango_units_from_double ((gdouble) width));
		_tmp13_ = pango_font_description_from_string (font);
		font_description = _tmp13_;
		_tmp14_ = font_description;
		_tmp15_ = font_description;
		pango_font_description_set_size (_tmp14_, (gint) (pango_font_description_get_size (_tmp15_) * scale));
		_tmp16_ = layout;
		_tmp17_ = font_description;
		pango_layout_set_font_description (_tmp16_, _tmp17_);
		_tmp18_ = layout;
		pango_layout_set_text (_tmp18_, text, -1);
		_tmp19_ = g_strdup ("");
		broken_string = _tmp19_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp20_ = FALSE;
				_tmp20_ = TRUE;
				while (TRUE) {
					PangoLayout* _tmp22_;
					gchar* next_line = NULL;
					gchar* _tmp23_;
					PangoLayout* _tmp24_;
					const gchar* _tmp33_;
					if (!_tmp20_) {
						gint _tmp21_;
						i = i + 1;
						_tmp21_ = i;
					}
					_tmp20_ = FALSE;
					_tmp22_ = layout;
					if (!(i < pango_layout_get_line_count (_tmp22_))) {
						break;
					}
					_tmp23_ = g_strdup ("");
					next_line = _tmp23_;
					_tmp24_ = layout;
					if (i == (pango_layout_get_line_count (_tmp24_) - 1)) {
						PangoLayout* _tmp25_;
						PangoLayoutLine* _tmp26_;
						gchar* _tmp27_;
						_tmp25_ = layout;
						_tmp26_ = pango_layout_get_line (_tmp25_, i);
						_tmp27_ = string_substring (text, (glong) _tmp26_->start_index, (glong) -1);
						_g_free0 (next_line);
						next_line = _tmp27_;
					} else {
						PangoLayout* _tmp28_;
						PangoLayoutLine* _tmp29_;
						PangoLayout* _tmp30_;
						PangoLayoutLine* _tmp31_;
						gchar* _tmp32_;
						_tmp28_ = layout;
						_tmp29_ = pango_layout_get_line (_tmp28_, i);
						_tmp30_ = layout;
						_tmp31_ = pango_layout_get_line (_tmp30_, i);
						_tmp32_ = string_substring (text, (glong) _tmp29_->start_index, (glong) _tmp31_->length);
						_g_free0 (next_line);
						next_line = _tmp32_;
					}
					_tmp33_ = broken_string;
					if (g_strcmp0 (_tmp33_, "") == 0) {
						const gchar* _tmp34_;
						gchar* _tmp35_;
						_tmp34_ = next_line;
						_tmp35_ = g_strdup (_tmp34_);
						_g_free0 (broken_string);
						broken_string = _tmp35_;
					} else {
						const gchar* _tmp36_;
						_tmp36_ = next_line;
						if (g_strcmp0 (_tmp36_, "") != 0) {
							gchar* broken_string_tmp = NULL;
							const gchar* _tmp37_;
							gchar* _tmp38_;
							gchar* _tmp39_;
							const gchar* _tmp40_;
							gchar* _tmp41_;
							gchar* _tmp42_;
							PangoLayout* layout_tmp = NULL;
							cairo_t* _tmp43_;
							PangoLayout* _tmp44_;
							PangoLayout* _tmp45_;
							PangoLayout* _tmp46_;
							PangoFontDescription* _tmp47_;
							PangoLayout* _tmp48_;
							const gchar* _tmp49_;
							PangoRectangle extents = {0};
							PangoLayout* _tmp50_;
							PangoRectangle _tmp51_ = {0};
							PangoRectangle _tmp52_;
							_tmp37_ = broken_string;
							_tmp38_ = g_strconcat (_tmp37_, "\n", NULL);
							_tmp39_ = _tmp38_;
							_tmp40_ = next_line;
							_tmp41_ = g_strconcat (_tmp39_, _tmp40_, NULL);
							_tmp42_ = _tmp41_;
							_g_free0 (_tmp39_);
							broken_string_tmp = _tmp42_;
							_tmp43_ = ctx;
							_tmp44_ = pango_cairo_create_layout (_tmp43_);
							layout_tmp = _tmp44_;
							_tmp45_ = layout_tmp;
							pango_layout_set_width (_tmp45_, pango_units_from_double ((gdouble) width));
							_tmp46_ = layout_tmp;
							_tmp47_ = font_description;
							pango_layout_set_font_description (_tmp46_, _tmp47_);
							_tmp48_ = layout_tmp;
							_tmp49_ = broken_string_tmp;
							pango_layout_set_text (_tmp48_, _tmp49_, -1);
							_tmp50_ = layout_tmp;
							pango_layout_get_pixel_extents (_tmp50_, NULL, &_tmp51_);
							extents = _tmp51_;
							_tmp52_ = extents;
							if (_tmp52_.height > height) {
								const gchar* _tmp53_;
								const gchar* _tmp54_;
								gchar* _tmp55_;
								_tmp53_ = broken_string;
								_tmp54_ = next_line;
								_tmp55_ = g_strconcat (_tmp53_, _tmp54_, NULL);
								_g_free0 (broken_string);
								broken_string = _tmp55_;
							} else {
								const gchar* _tmp56_;
								gchar* _tmp57_;
								_tmp56_ = broken_string_tmp;
								_tmp57_ = g_strdup (_tmp56_);
								_g_free0 (broken_string);
								broken_string = _tmp57_;
							}
							_g_object_unref0 (layout_tmp);
							_g_free0 (broken_string_tmp);
						}
					}
					_g_free0 (next_line);
				}
			}
		}
		_tmp58_ = layout;
		_tmp59_ = broken_string;
		pango_layout_set_text (_tmp58_, _tmp59_, -1);
		_tmp60_ = layout;
		pango_layout_set_ellipsize (_tmp60_, PANGO_ELLIPSIZE_END);
		_tmp61_ = layout;
		pango_layout_set_alignment (_tmp61_, PANGO_ALIGN_CENTER);
		_tmp62_ = layout;
		pango_layout_get_pixel_extents (_tmp62_, NULL, &_tmp63_);
		extents = _tmp63_;
		_tmp64_ = ctx;
		_tmp65_ = extents;
		cairo_move_to (_tmp64_, (gdouble) 0, (gdouble) ((gint) (0.5 * (height - _tmp65_.height))));
		_tmp66_ = ctx;
		_tmp67_ = layout;
		pango_cairo_update_layout (_tmp66_, _tmp67_);
		_tmp68_ = ctx;
		_tmp69_ = layout;
		pango_cairo_show_layout (_tmp68_, _tmp69_);
		_g_free0 (broken_string);
		__vala_PangoFontDescription_free0 (font_description);
		_g_object_unref0 (layout);
		_cairo_destroy0 (ctx);
	}
}

void
gnome_pie_rendered_text_render_markup (GnomePieRenderedText* self,
                                       const gchar* text,
                                       gint width,
                                       gint height,
                                       const gchar* font,
                                       GnomePieColor* color,
                                       gdouble scale)
{
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	cairo_t* ctx = NULL;
	cairo_t* _tmp2_;
	gfloat _tmp3_;
	gfloat _tmp4_;
	gfloat _tmp5_;
	gfloat _tmp6_;
	gfloat _tmp7_;
	gfloat _tmp8_;
	PangoLayout* layout = NULL;
	PangoLayout* _tmp9_;
	PangoFontDescription* font_description = NULL;
	PangoFontDescription* _tmp10_;
	PangoRectangle extents = {0};
	PangoRectangle _tmp11_ = {0};
	PangoRectangle _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (font != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
	_tmp1_ = _tmp0_;
	gnome_pie_image_set_surface ((GnomePieImage*) self, _tmp1_);
	_cairo_surface_destroy0 (_tmp1_);
	_tmp2_ = gnome_pie_image_context ((GnomePieImage*) self);
	ctx = _tmp2_;
	_tmp3_ = gnome_pie_color_get_r (color);
	_tmp4_ = _tmp3_;
	_tmp5_ = gnome_pie_color_get_g (color);
	_tmp6_ = _tmp5_;
	_tmp7_ = gnome_pie_color_get_g (color);
	_tmp8_ = _tmp7_;
	cairo_set_source_rgb (ctx, (gdouble) _tmp4_, (gdouble) _tmp6_, (gdouble) _tmp8_);
	_tmp9_ = pango_cairo_create_layout (ctx);
	layout = _tmp9_;
	pango_layout_set_width (layout, pango_units_from_double ((gdouble) width));
	_tmp10_ = pango_font_description_from_string (font);
	font_description = _tmp10_;
	pango_font_description_set_size (font_description, (gint) (pango_font_description_get_size (font_description) * scale));
	pango_layout_set_font_description (layout, font_description);
	pango_layout_set_markup (layout, text, -1);
	pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
	pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
	pango_layout_get_pixel_extents (layout, NULL, &_tmp11_);
	extents = _tmp11_;
	_tmp12_ = extents;
	cairo_move_to (ctx, (gdouble) 0, (gdouble) ((gint) (0.5 * (height - _tmp12_.height))));
	pango_cairo_update_layout (ctx, layout);
	pango_cairo_show_layout (ctx, layout);
	__vala_PangoFontDescription_free0 (font_description);
	_g_object_unref0 (layout);
	_cairo_destroy0 (ctx);
}

static void
gnome_pie_rendered_text_class_init (GnomePieRenderedTextClass * klass,
                                    gpointer klass_data)
{
	gnome_pie_rendered_text_parent_class = g_type_class_peek_parent (klass);
}

static void
gnome_pie_rendered_text_instance_init (GnomePieRenderedText * self,
                                       gpointer klass)
{
}

static GType
gnome_pie_rendered_text_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GnomePieRenderedTextClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gnome_pie_rendered_text_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GnomePieRenderedText), 0, (GInstanceInitFunc) gnome_pie_rendered_text_instance_init, NULL };
	GType gnome_pie_rendered_text_type_id;
	gnome_pie_rendered_text_type_id = g_type_register_static (GNOME_PIE_TYPE_IMAGE, "GnomePieRenderedText", &g_define_type_info, 0);
	return gnome_pie_rendered_text_type_id;
}

GType
gnome_pie_rendered_text_get_type (void)
{
	static volatile gsize gnome_pie_rendered_text_type_id__once = 0;
	if (g_once_init_enter (&gnome_pie_rendered_text_type_id__once)) {
		GType gnome_pie_rendered_text_type_id;
		gnome_pie_rendered_text_type_id = gnome_pie_rendered_text_get_type_once ();
		g_once_init_leave (&gnome_pie_rendered_text_type_id__once, gnome_pie_rendered_text_type_id);
	}
	return gnome_pie_rendered_text_type_id__once;
}

