/* themedIcon.c generated by valac 0.56.19, the Vala compiler
 * generated from themedIcon.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 <gee.h>
#include <cairo-gobject.h>
#include <float.h>
#include <math.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_THEMED_ICON (gnome_pie_themed_icon_get_type ())
#define GNOME_PIE_THEMED_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_THEMED_ICON, GnomePieThemedIcon))
#define GNOME_PIE_THEMED_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_THEMED_ICON, GnomePieThemedIconClass))
#define GNOME_PIE_IS_THEMED_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_THEMED_ICON))
#define GNOME_PIE_IS_THEMED_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_THEMED_ICON))
#define GNOME_PIE_THEMED_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_THEMED_ICON, GnomePieThemedIconClass))

typedef struct _GnomePieThemedIcon GnomePieThemedIcon;
typedef struct _GnomePieThemedIconClass GnomePieThemedIconClass;
typedef struct _GnomePieThemedIconPrivate GnomePieThemedIconPrivate;
enum  {
	GNOME_PIE_THEMED_ICON_0_PROPERTY,
	GNOME_PIE_THEMED_ICON_NUM_PROPERTIES
};
static GParamSpec* gnome_pie_themed_icon_properties[GNOME_PIE_THEMED_ICON_NUM_PROPERTIES];

#define GNOME_PIE_TYPE_SLICE_LAYER (gnome_pie_slice_layer_get_type ())
#define GNOME_PIE_SLICE_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_SLICE_LAYER, GnomePieSliceLayer))
#define GNOME_PIE_SLICE_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_SLICE_LAYER, GnomePieSliceLayerClass))
#define GNOME_PIE_IS_SLICE_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_SLICE_LAYER))
#define GNOME_PIE_IS_SLICE_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_SLICE_LAYER))
#define GNOME_PIE_SLICE_LAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_SLICE_LAYER, GnomePieSliceLayerClass))

typedef struct _GnomePieSliceLayer GnomePieSliceLayer;
typedef struct _GnomePieSliceLayerClass GnomePieSliceLayerClass;

#define GNOME_PIE_TYPE_CONFIG (gnome_pie_config_get_type ())
#define GNOME_PIE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_CONFIG, GnomePieConfig))
#define GNOME_PIE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_CONFIG, GnomePieConfigClass))
#define GNOME_PIE_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_CONFIG))
#define GNOME_PIE_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_CONFIG))
#define GNOME_PIE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_CONFIG, GnomePieConfigClass))

typedef struct _GnomePieConfig GnomePieConfig;
typedef struct _GnomePieConfigClass GnomePieConfigClass;

#define GNOME_PIE_TYPE_THEME (gnome_pie_theme_get_type ())
#define GNOME_PIE_THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_THEME, GnomePieTheme))
#define GNOME_PIE_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_THEME, GnomePieThemeClass))
#define GNOME_PIE_IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_THEME))
#define GNOME_PIE_IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_THEME))
#define GNOME_PIE_THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_THEME, GnomePieThemeClass))

typedef struct _GnomePieTheme GnomePieTheme;
typedef struct _GnomePieThemeClass GnomePieThemeClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
typedef enum  {
	GNOME_PIE_SLICE_LAYER_TYPE_FILE,
	GNOME_PIE_SLICE_LAYER_TYPE_ICON,
	GNOME_PIE_SLICE_LAYER_TYPE_CAPTION
} GnomePieSliceLayerType;

#define GNOME_PIE_SLICE_LAYER_TYPE_TYPE (gnome_pie_slice_layer_type_get_type ())

#define GNOME_PIE_TYPE_ICON (gnome_pie_icon_get_type ())
#define GNOME_PIE_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_ICON, GnomePieIcon))
#define GNOME_PIE_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_ICON, GnomePieIconClass))
#define GNOME_PIE_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_ICON))
#define GNOME_PIE_IS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_ICON))
#define GNOME_PIE_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_ICON, GnomePieIconClass))

typedef struct _GnomePieIcon GnomePieIcon;
typedef struct _GnomePieIconClass GnomePieIconClass;

#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;
typedef enum  {
	GNOME_PIE_SLICE_LAYER_VISIBILITY_ANY,
	GNOME_PIE_SLICE_LAYER_VISIBILITY_WITH_CAPTION,
	GNOME_PIE_SLICE_LAYER_VISIBILITY_WITHOUT_CAPTION
} GnomePieSliceLayerVisibility;

#define GNOME_PIE_SLICE_LAYER_TYPE_VISIBILITY (gnome_pie_slice_layer_visibility_get_type ())

#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;
#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 _GnomePieThemedIcon {
	GnomePieImage parent_instance;
	GnomePieThemedIconPrivate * priv;
};

struct _GnomePieThemedIconClass {
	GnomePieImageClass parent_class;
};

static gpointer gnome_pie_themed_icon_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_themed_icon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieThemedIcon, g_object_unref)
VALA_EXTERN GnomePieThemedIcon* gnome_pie_themed_icon_new (const gchar* caption,
                                               const gchar* icon_name,
                                               gboolean active);
VALA_EXTERN GnomePieThemedIcon* gnome_pie_themed_icon_construct (GType object_type,
                                                     const gchar* caption,
                                                     const gchar* icon_name,
                                                     gboolean active);
VALA_EXTERN GnomePieImage* gnome_pie_image_new (void);
VALA_EXTERN GnomePieImage* gnome_pie_image_construct (GType object_type);
VALA_EXTERN GType gnome_pie_slice_layer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieSliceLayer, g_object_unref)
VALA_EXTERN GType gnome_pie_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieConfig, g_object_unref)
VALA_EXTERN GnomePieConfig* gnome_pie_config_get_global (void);
VALA_EXTERN GType gnome_pie_theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieTheme, g_object_unref)
VALA_EXTERN GnomePieTheme* gnome_pie_config_get_theme (GnomePieConfig* self);
VALA_EXTERN GeeArrayList* gnome_pie_theme_get_active_slice_layers (GnomePieTheme* self);
VALA_EXTERN GeeArrayList* gnome_pie_theme_get_inactive_slice_layers (GnomePieTheme* self);
VALA_EXTERN GnomePieImage* gnome_pie_slice_layer_get_image (GnomePieSliceLayer* self);
VALA_EXTERN gint gnome_pie_image_width (GnomePieImage* self);
VALA_EXTERN void gnome_pie_image_set_surface (GnomePieImage* self,
                                  cairo_surface_t* value);
VALA_EXTERN GType gnome_pie_slice_layer_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GnomePieSliceLayerType gnome_pie_slice_layer_get_layer_type (GnomePieSliceLayer* self);
VALA_EXTERN GnomePieImage* gnome_pie_image_new_from_file_at_size (const gchar* filename,
                                                      gint width,
                                                      gint height);
VALA_EXTERN GnomePieImage* gnome_pie_image_construct_from_file_at_size (GType object_type,
                                                            const gchar* filename,
                                                            gint width,
                                                            gint height);
VALA_EXTERN GnomePieIcon* gnome_pie_icon_new (const gchar* icon_name,
                                  gint size);
VALA_EXTERN GnomePieIcon* gnome_pie_icon_construct (GType object_type,
                                        const gchar* icon_name,
                                        gint size);
VALA_EXTERN GType gnome_pie_icon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieIcon, 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 GnomePieColor* gnome_pie_color_new_from_icon (GnomePieImage* icon);
VALA_EXTERN GnomePieColor* gnome_pie_color_construct_from_icon (GType object_type,
                                                    GnomePieImage* icon);
VALA_EXTERN cairo_t* gnome_pie_image_context (GnomePieImage* self);
VALA_EXTERN GType gnome_pie_slice_layer_visibility_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GnomePieSliceLayerVisibility gnome_pie_slice_layer_get_visibility (GnomePieSliceLayer* self);
VALA_EXTERN gboolean gnome_pie_config_get_show_captions (GnomePieConfig* self);
VALA_EXTERN gboolean gnome_pie_slice_layer_get_colorize (GnomePieSliceLayer* self);
VALA_EXTERN gint gnome_pie_slice_layer_get_x (GnomePieSliceLayer* self);
VALA_EXTERN gint gnome_pie_slice_layer_get_y (GnomePieSliceLayer* self);
VALA_EXTERN void gnome_pie_image_paint_on (GnomePieImage* self,
                               cairo_t* ctx,
                               gdouble alpha);
VALA_EXTERN gint gnome_pie_slice_layer_get_width (GnomePieSliceLayer* self);
VALA_EXTERN gint gnome_pie_slice_layer_get_height (GnomePieSliceLayer* self);
VALA_EXTERN const gchar* gnome_pie_slice_layer_get_font (GnomePieSliceLayer* self);
VALA_EXTERN GnomePieColor* gnome_pie_slice_layer_get_color (GnomePieSliceLayer* self);
VALA_EXTERN gdouble gnome_pie_config_get_global_scale (GnomePieConfig* self);
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 GType gnome_pie_rendered_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieRenderedText, g_object_unref)
VALA_EXTERN gfloat gnome_pie_color_get_r (GnomePieColor* self);
VALA_EXTERN gfloat gnome_pie_color_get_g (GnomePieColor* self);
VALA_EXTERN gfloat gnome_pie_color_get_b (GnomePieColor* self);
VALA_EXTERN gint gnome_pie_themed_icon_size (GnomePieThemedIcon* self);
static GType gnome_pie_themed_icon_get_type_once (void);

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

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

GnomePieThemedIcon*
gnome_pie_themed_icon_construct (GType object_type,
                                 const gchar* caption,
                                 const gchar* icon_name,
                                 gboolean active)
{
	GnomePieThemedIcon * self = NULL;
	GeeArrayList* _tmp0_ = NULL;
	GeeArrayList* layers = NULL;
	GeeArrayList* _tmp13_;
	gint size = 0;
	cairo_surface_t* _tmp32_;
	cairo_surface_t* _tmp33_;
	gint icon_size = 0;
	GnomePieImage* icon = NULL;
	GnomePieColor* color = NULL;
	GnomePieImage* _tmp54_;
	GnomePieColor* _tmp55_;
	cairo_t* ctx = NULL;
	cairo_t* _tmp56_;
	cairo_t* _tmp57_;
	cairo_t* _tmp58_;
	g_return_val_if_fail (caption != NULL, NULL);
	g_return_val_if_fail (icon_name != NULL, NULL);
	self = (GnomePieThemedIcon*) gnome_pie_image_construct (object_type);
	if (active) {
		GnomePieConfig* _tmp1_;
		GnomePieConfig* _tmp2_;
		GnomePieTheme* _tmp3_;
		GnomePieTheme* _tmp4_;
		GeeArrayList* _tmp5_;
		GeeArrayList* _tmp6_;
		_tmp1_ = gnome_pie_config_get_global ();
		_tmp2_ = _tmp1_;
		_tmp3_ = gnome_pie_config_get_theme (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = gnome_pie_theme_get_active_slice_layers (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		GnomePieConfig* _tmp7_;
		GnomePieConfig* _tmp8_;
		GnomePieTheme* _tmp9_;
		GnomePieTheme* _tmp10_;
		GeeArrayList* _tmp11_;
		GeeArrayList* _tmp12_;
		_tmp7_ = gnome_pie_config_get_global ();
		_tmp8_ = _tmp7_;
		_tmp9_ = gnome_pie_config_get_theme (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gnome_pie_theme_get_inactive_slice_layers (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp0_ = _tmp12_;
	}
	_tmp13_ = _g_object_ref0 (_tmp0_);
	layers = _tmp13_;
	size = 1;
	{
		GeeArrayList* _layer_list = NULL;
		GeeArrayList* _tmp14_;
		gint _layer_size = 0;
		GeeArrayList* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		gint _layer_index = 0;
		_tmp14_ = layers;
		_layer_list = _tmp14_;
		_tmp15_ = _layer_list;
		_tmp16_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp15_);
		_tmp17_ = _tmp16_;
		_layer_size = _tmp17_;
		_layer_index = -1;
		while (TRUE) {
			gint _tmp18_;
			gint _tmp19_;
			GnomePieSliceLayer* layer = NULL;
			GeeArrayList* _tmp20_;
			gpointer _tmp21_;
			gboolean _tmp22_ = FALSE;
			GnomePieSliceLayer* _tmp23_;
			GnomePieImage* _tmp24_;
			GnomePieImage* _tmp25_;
			_layer_index = _layer_index + 1;
			_tmp18_ = _layer_index;
			_tmp19_ = _layer_size;
			if (!(_tmp18_ < _tmp19_)) {
				break;
			}
			_tmp20_ = _layer_list;
			_tmp21_ = gee_abstract_list_get ((GeeAbstractList*) _tmp20_, _layer_index);
			layer = (GnomePieSliceLayer*) _tmp21_;
			_tmp23_ = layer;
			_tmp24_ = gnome_pie_slice_layer_get_image (_tmp23_);
			_tmp25_ = _tmp24_;
			if (_tmp25_ != NULL) {
				GnomePieSliceLayer* _tmp26_;
				GnomePieImage* _tmp27_;
				GnomePieImage* _tmp28_;
				_tmp26_ = layer;
				_tmp27_ = gnome_pie_slice_layer_get_image (_tmp26_);
				_tmp28_ = _tmp27_;
				_tmp22_ = gnome_pie_image_width (_tmp28_) > size;
			} else {
				_tmp22_ = FALSE;
			}
			if (_tmp22_) {
				GnomePieSliceLayer* _tmp29_;
				GnomePieImage* _tmp30_;
				GnomePieImage* _tmp31_;
				_tmp29_ = layer;
				_tmp30_ = gnome_pie_slice_layer_get_image (_tmp29_);
				_tmp31_ = _tmp30_;
				size = gnome_pie_image_width (_tmp31_);
			}
			_g_object_unref0 (layer);
		}
	}
	_tmp32_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
	_tmp33_ = _tmp32_;
	gnome_pie_image_set_surface ((GnomePieImage*) self, _tmp33_);
	_cairo_surface_destroy0 (_tmp33_);
	icon_size = size;
	{
		GeeArrayList* _layer_list = NULL;
		GeeArrayList* _tmp34_;
		gint _layer_size = 0;
		GeeArrayList* _tmp35_;
		gint _tmp36_;
		gint _tmp37_;
		gint _layer_index = 0;
		_tmp34_ = layers;
		_layer_list = _tmp34_;
		_tmp35_ = _layer_list;
		_tmp36_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp35_);
		_tmp37_ = _tmp36_;
		_layer_size = _tmp37_;
		_layer_index = -1;
		while (TRUE) {
			gint _tmp38_;
			gint _tmp39_;
			GnomePieSliceLayer* layer = NULL;
			GeeArrayList* _tmp40_;
			gpointer _tmp41_;
			gboolean _tmp42_ = FALSE;
			GnomePieSliceLayer* _tmp43_;
			GnomePieImage* _tmp44_;
			GnomePieImage* _tmp45_;
			_layer_index = _layer_index + 1;
			_tmp38_ = _layer_index;
			_tmp39_ = _layer_size;
			if (!(_tmp38_ < _tmp39_)) {
				break;
			}
			_tmp40_ = _layer_list;
			_tmp41_ = gee_abstract_list_get ((GeeAbstractList*) _tmp40_, _layer_index);
			layer = (GnomePieSliceLayer*) _tmp41_;
			_tmp43_ = layer;
			_tmp44_ = gnome_pie_slice_layer_get_image (_tmp43_);
			_tmp45_ = _tmp44_;
			if (_tmp45_ != NULL) {
				GnomePieSliceLayer* _tmp46_;
				GnomePieSliceLayerType _tmp47_;
				GnomePieSliceLayerType _tmp48_;
				_tmp46_ = layer;
				_tmp47_ = gnome_pie_slice_layer_get_layer_type (_tmp46_);
				_tmp48_ = _tmp47_;
				_tmp42_ = _tmp48_ == GNOME_PIE_SLICE_LAYER_TYPE_ICON;
			} else {
				_tmp42_ = FALSE;
			}
			if (_tmp42_) {
				GnomePieSliceLayer* _tmp49_;
				GnomePieImage* _tmp50_;
				GnomePieImage* _tmp51_;
				_tmp49_ = layer;
				_tmp50_ = gnome_pie_slice_layer_get_image (_tmp49_);
				_tmp51_ = _tmp50_;
				icon_size = gnome_pie_image_width (_tmp51_);
			}
			_g_object_unref0 (layer);
		}
	}
	if (string_contains (icon_name, "/")) {
		GnomePieImage* _tmp52_;
		_tmp52_ = gnome_pie_image_new_from_file_at_size (icon_name, icon_size, icon_size);
		_g_object_unref0 (icon);
		icon = _tmp52_;
	} else {
		GnomePieIcon* _tmp53_;
		_tmp53_ = gnome_pie_icon_new (icon_name, icon_size);
		_g_object_unref0 (icon);
		icon = (GnomePieImage*) _tmp53_;
	}
	_tmp54_ = icon;
	_tmp55_ = gnome_pie_color_new_from_icon (_tmp54_);
	color = _tmp55_;
	_tmp56_ = gnome_pie_image_context ((GnomePieImage*) self);
	ctx = _tmp56_;
	_tmp57_ = ctx;
	cairo_translate (_tmp57_, (gdouble) (size / 2), (gdouble) (size / 2));
	_tmp58_ = ctx;
	cairo_set_operator (_tmp58_, CAIRO_OPERATOR_OVER);
	{
		GeeArrayList* _layer_list = NULL;
		GeeArrayList* _tmp59_;
		gint _layer_size = 0;
		GeeArrayList* _tmp60_;
		gint _tmp61_;
		gint _tmp62_;
		gint _layer_index = 0;
		_tmp59_ = layers;
		_layer_list = _tmp59_;
		_tmp60_ = _layer_list;
		_tmp61_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp60_);
		_tmp62_ = _tmp61_;
		_layer_size = _tmp62_;
		_layer_index = -1;
		while (TRUE) {
			gint _tmp63_;
			gint _tmp64_;
			GnomePieSliceLayer* layer = NULL;
			GeeArrayList* _tmp65_;
			gpointer _tmp66_;
			gboolean _tmp67_ = FALSE;
			GnomePieSliceLayer* _tmp68_;
			GnomePieSliceLayerVisibility _tmp69_;
			GnomePieSliceLayerVisibility _tmp70_;
			_layer_index = _layer_index + 1;
			_tmp63_ = _layer_index;
			_tmp64_ = _layer_size;
			if (!(_tmp63_ < _tmp64_)) {
				break;
			}
			_tmp65_ = _layer_list;
			_tmp66_ = gee_abstract_list_get ((GeeAbstractList*) _tmp65_, _layer_index);
			layer = (GnomePieSliceLayer*) _tmp66_;
			_tmp68_ = layer;
			_tmp69_ = gnome_pie_slice_layer_get_visibility (_tmp68_);
			_tmp70_ = _tmp69_;
			if (_tmp70_ == GNOME_PIE_SLICE_LAYER_VISIBILITY_ANY) {
				_tmp67_ = TRUE;
			} else {
				GnomePieConfig* _tmp71_;
				GnomePieConfig* _tmp72_;
				gboolean _tmp73_;
				gboolean _tmp74_;
				GnomePieSliceLayer* _tmp75_;
				GnomePieSliceLayerVisibility _tmp76_;
				GnomePieSliceLayerVisibility _tmp77_;
				_tmp71_ = gnome_pie_config_get_global ();
				_tmp72_ = _tmp71_;
				_tmp73_ = gnome_pie_config_get_show_captions (_tmp72_);
				_tmp74_ = _tmp73_;
				_tmp75_ = layer;
				_tmp76_ = gnome_pie_slice_layer_get_visibility (_tmp75_);
				_tmp77_ = _tmp76_;
				_tmp67_ = _tmp74_ == (_tmp77_ == GNOME_PIE_SLICE_LAYER_VISIBILITY_WITH_CAPTION);
			}
			if (_tmp67_) {
				GnomePieSliceLayer* _tmp78_;
				gboolean _tmp79_;
				gboolean _tmp80_;
				GnomePieSliceLayer* _tmp82_;
				GnomePieSliceLayerType _tmp83_;
				GnomePieSliceLayerType _tmp84_;
				GnomePieSliceLayer* _tmp181_;
				gboolean _tmp182_;
				gboolean _tmp183_;
				_tmp78_ = layer;
				_tmp79_ = gnome_pie_slice_layer_get_colorize (_tmp78_);
				_tmp80_ = _tmp79_;
				if (_tmp80_) {
					cairo_t* _tmp81_;
					_tmp81_ = ctx;
					cairo_push_group (_tmp81_);
				}
				_tmp82_ = layer;
				_tmp83_ = gnome_pie_slice_layer_get_layer_type (_tmp82_);
				_tmp84_ = _tmp83_;
				if (_tmp84_ == GNOME_PIE_SLICE_LAYER_TYPE_ICON) {
					cairo_t* _tmp85_;
					cairo_t* _tmp86_;
					GnomePieSliceLayer* _tmp87_;
					gint _tmp88_;
					gint _tmp89_;
					GnomePieSliceLayer* _tmp90_;
					gint _tmp91_;
					gint _tmp92_;
					GnomePieSliceLayer* _tmp93_;
					GnomePieImage* _tmp94_;
					GnomePieImage* _tmp95_;
					cairo_t* _tmp96_;
					cairo_t* _tmp97_;
					GnomePieSliceLayer* _tmp98_;
					GnomePieImage* _tmp99_;
					GnomePieImage* _tmp100_;
					GnomePieImage* _tmp112_;
					cairo_t* _tmp113_;
					cairo_t* _tmp114_;
					GnomePieSliceLayer* _tmp115_;
					gint _tmp116_;
					gint _tmp117_;
					GnomePieSliceLayer* _tmp118_;
					gint _tmp119_;
					gint _tmp120_;
					cairo_t* _tmp121_;
					cairo_t* _tmp122_;
					cairo_t* _tmp123_;
					_tmp85_ = ctx;
					cairo_push_group (_tmp85_);
					_tmp86_ = ctx;
					_tmp87_ = layer;
					_tmp88_ = gnome_pie_slice_layer_get_x (_tmp87_);
					_tmp89_ = _tmp88_;
					_tmp90_ = layer;
					_tmp91_ = gnome_pie_slice_layer_get_y (_tmp90_);
					_tmp92_ = _tmp91_;
					cairo_translate (_tmp86_, (gdouble) _tmp89_, (gdouble) _tmp92_);
					_tmp93_ = layer;
					_tmp94_ = gnome_pie_slice_layer_get_image (_tmp93_);
					_tmp95_ = _tmp94_;
					_tmp96_ = ctx;
					gnome_pie_image_paint_on (_tmp95_, _tmp96_, 1.0);
					_tmp97_ = ctx;
					cairo_set_operator (_tmp97_, CAIRO_OPERATOR_IN);
					_tmp98_ = layer;
					_tmp99_ = gnome_pie_slice_layer_get_image (_tmp98_);
					_tmp100_ = _tmp99_;
					if (gnome_pie_image_width (_tmp100_) != icon_size) {
						if (string_contains (icon_name, "/")) {
							GnomePieSliceLayer* _tmp101_;
							GnomePieImage* _tmp102_;
							GnomePieImage* _tmp103_;
							GnomePieSliceLayer* _tmp104_;
							GnomePieImage* _tmp105_;
							GnomePieImage* _tmp106_;
							GnomePieImage* _tmp107_;
							_tmp101_ = layer;
							_tmp102_ = gnome_pie_slice_layer_get_image (_tmp101_);
							_tmp103_ = _tmp102_;
							_tmp104_ = layer;
							_tmp105_ = gnome_pie_slice_layer_get_image (_tmp104_);
							_tmp106_ = _tmp105_;
							_tmp107_ = gnome_pie_image_new_from_file_at_size (icon_name, gnome_pie_image_width (_tmp103_), gnome_pie_image_width (_tmp106_));
							_g_object_unref0 (icon);
							icon = _tmp107_;
						} else {
							GnomePieSliceLayer* _tmp108_;
							GnomePieImage* _tmp109_;
							GnomePieImage* _tmp110_;
							GnomePieIcon* _tmp111_;
							_tmp108_ = layer;
							_tmp109_ = gnome_pie_slice_layer_get_image (_tmp108_);
							_tmp110_ = _tmp109_;
							_tmp111_ = gnome_pie_icon_new (icon_name, gnome_pie_image_width (_tmp110_));
							_g_object_unref0 (icon);
							icon = (GnomePieImage*) _tmp111_;
						}
					}
					_tmp112_ = icon;
					_tmp113_ = ctx;
					gnome_pie_image_paint_on (_tmp112_, _tmp113_, 1.0);
					_tmp114_ = ctx;
					_tmp115_ = layer;
					_tmp116_ = gnome_pie_slice_layer_get_x (_tmp115_);
					_tmp117_ = _tmp116_;
					_tmp118_ = layer;
					_tmp119_ = gnome_pie_slice_layer_get_y (_tmp118_);
					_tmp120_ = _tmp119_;
					cairo_translate (_tmp114_, (gdouble) (-_tmp117_), (gdouble) (-_tmp120_));
					_tmp121_ = ctx;
					cairo_pop_group_to_source (_tmp121_);
					_tmp122_ = ctx;
					cairo_paint (_tmp122_);
					_tmp123_ = ctx;
					cairo_set_operator (_tmp123_, CAIRO_OPERATOR_OVER);
				} else {
					GnomePieSliceLayer* _tmp124_;
					GnomePieSliceLayerType _tmp125_;
					GnomePieSliceLayerType _tmp126_;
					_tmp124_ = layer;
					_tmp125_ = gnome_pie_slice_layer_get_layer_type (_tmp124_);
					_tmp126_ = _tmp125_;
					if (_tmp126_ == GNOME_PIE_SLICE_LAYER_TYPE_CAPTION) {
						GnomePieImage* text = NULL;
						GnomePieSliceLayer* _tmp127_;
						gint _tmp128_;
						gint _tmp129_;
						GnomePieSliceLayer* _tmp130_;
						gint _tmp131_;
						gint _tmp132_;
						GnomePieSliceLayer* _tmp133_;
						const gchar* _tmp134_;
						const gchar* _tmp135_;
						GnomePieSliceLayer* _tmp136_;
						GnomePieColor* _tmp137_;
						GnomePieColor* _tmp138_;
						GnomePieConfig* _tmp139_;
						GnomePieConfig* _tmp140_;
						gdouble _tmp141_;
						gdouble _tmp142_;
						GnomePieRenderedText* _tmp143_;
						cairo_t* _tmp144_;
						GnomePieSliceLayer* _tmp145_;
						gint _tmp146_;
						gint _tmp147_;
						GnomePieSliceLayer* _tmp148_;
						gint _tmp149_;
						gint _tmp150_;
						GnomePieImage* _tmp151_;
						cairo_t* _tmp152_;
						cairo_t* _tmp153_;
						GnomePieSliceLayer* _tmp154_;
						gint _tmp155_;
						gint _tmp156_;
						GnomePieSliceLayer* _tmp157_;
						gint _tmp158_;
						gint _tmp159_;
						_tmp127_ = layer;
						_tmp128_ = gnome_pie_slice_layer_get_width (_tmp127_);
						_tmp129_ = _tmp128_;
						_tmp130_ = layer;
						_tmp131_ = gnome_pie_slice_layer_get_height (_tmp130_);
						_tmp132_ = _tmp131_;
						_tmp133_ = layer;
						_tmp134_ = gnome_pie_slice_layer_get_font (_tmp133_);
						_tmp135_ = _tmp134_;
						_tmp136_ = layer;
						_tmp137_ = gnome_pie_slice_layer_get_color (_tmp136_);
						_tmp138_ = _tmp137_;
						_tmp139_ = gnome_pie_config_get_global ();
						_tmp140_ = _tmp139_;
						_tmp141_ = gnome_pie_config_get_global_scale (_tmp140_);
						_tmp142_ = _tmp141_;
						_tmp143_ = gnome_pie_rendered_text_new (caption, _tmp129_, _tmp132_, _tmp135_, _tmp138_, _tmp142_);
						text = (GnomePieImage*) _tmp143_;
						_tmp144_ = ctx;
						_tmp145_ = layer;
						_tmp146_ = gnome_pie_slice_layer_get_x (_tmp145_);
						_tmp147_ = _tmp146_;
						_tmp148_ = layer;
						_tmp149_ = gnome_pie_slice_layer_get_y (_tmp148_);
						_tmp150_ = _tmp149_;
						cairo_translate (_tmp144_, (gdouble) _tmp147_, (gdouble) _tmp150_);
						_tmp151_ = text;
						_tmp152_ = ctx;
						gnome_pie_image_paint_on (_tmp151_, _tmp152_, 1.0);
						_tmp153_ = ctx;
						_tmp154_ = layer;
						_tmp155_ = gnome_pie_slice_layer_get_x (_tmp154_);
						_tmp156_ = _tmp155_;
						_tmp157_ = layer;
						_tmp158_ = gnome_pie_slice_layer_get_y (_tmp157_);
						_tmp159_ = _tmp158_;
						cairo_translate (_tmp153_, (gdouble) (-_tmp156_), (gdouble) (-_tmp159_));
						_g_object_unref0 (text);
					} else {
						GnomePieSliceLayer* _tmp160_;
						GnomePieSliceLayerType _tmp161_;
						GnomePieSliceLayerType _tmp162_;
						_tmp160_ = layer;
						_tmp161_ = gnome_pie_slice_layer_get_layer_type (_tmp160_);
						_tmp162_ = _tmp161_;
						if (_tmp162_ == GNOME_PIE_SLICE_LAYER_TYPE_FILE) {
							cairo_t* _tmp163_;
							GnomePieSliceLayer* _tmp164_;
							gint _tmp165_;
							gint _tmp166_;
							GnomePieSliceLayer* _tmp167_;
							gint _tmp168_;
							gint _tmp169_;
							GnomePieSliceLayer* _tmp170_;
							GnomePieImage* _tmp171_;
							GnomePieImage* _tmp172_;
							cairo_t* _tmp173_;
							cairo_t* _tmp174_;
							GnomePieSliceLayer* _tmp175_;
							gint _tmp176_;
							gint _tmp177_;
							GnomePieSliceLayer* _tmp178_;
							gint _tmp179_;
							gint _tmp180_;
							_tmp163_ = ctx;
							_tmp164_ = layer;
							_tmp165_ = gnome_pie_slice_layer_get_x (_tmp164_);
							_tmp166_ = _tmp165_;
							_tmp167_ = layer;
							_tmp168_ = gnome_pie_slice_layer_get_y (_tmp167_);
							_tmp169_ = _tmp168_;
							cairo_translate (_tmp163_, (gdouble) _tmp166_, (gdouble) _tmp169_);
							_tmp170_ = layer;
							_tmp171_ = gnome_pie_slice_layer_get_image (_tmp170_);
							_tmp172_ = _tmp171_;
							_tmp173_ = ctx;
							gnome_pie_image_paint_on (_tmp172_, _tmp173_, 1.0);
							_tmp174_ = ctx;
							_tmp175_ = layer;
							_tmp176_ = gnome_pie_slice_layer_get_x (_tmp175_);
							_tmp177_ = _tmp176_;
							_tmp178_ = layer;
							_tmp179_ = gnome_pie_slice_layer_get_y (_tmp178_);
							_tmp180_ = _tmp179_;
							cairo_translate (_tmp174_, (gdouble) (-_tmp177_), (gdouble) (-_tmp180_));
						}
					}
				}
				_tmp181_ = layer;
				_tmp182_ = gnome_pie_slice_layer_get_colorize (_tmp181_);
				_tmp183_ = _tmp182_;
				if (_tmp183_) {
					cairo_t* _tmp184_;
					cairo_t* _tmp185_;
					GnomePieColor* _tmp186_;
					gfloat _tmp187_;
					gfloat _tmp188_;
					GnomePieColor* _tmp189_;
					gfloat _tmp190_;
					gfloat _tmp191_;
					GnomePieColor* _tmp192_;
					gfloat _tmp193_;
					gfloat _tmp194_;
					cairo_t* _tmp195_;
					cairo_t* _tmp196_;
					cairo_t* _tmp197_;
					cairo_t* _tmp198_;
					_tmp184_ = ctx;
					cairo_set_operator (_tmp184_, CAIRO_OPERATOR_ATOP);
					_tmp185_ = ctx;
					_tmp186_ = color;
					_tmp187_ = gnome_pie_color_get_r (_tmp186_);
					_tmp188_ = _tmp187_;
					_tmp189_ = color;
					_tmp190_ = gnome_pie_color_get_g (_tmp189_);
					_tmp191_ = _tmp190_;
					_tmp192_ = color;
					_tmp193_ = gnome_pie_color_get_b (_tmp192_);
					_tmp194_ = _tmp193_;
					cairo_set_source_rgb (_tmp185_, (gdouble) _tmp188_, (gdouble) _tmp191_, (gdouble) _tmp194_);
					_tmp195_ = ctx;
					cairo_paint (_tmp195_);
					_tmp196_ = ctx;
					cairo_set_operator (_tmp196_, CAIRO_OPERATOR_OVER);
					_tmp197_ = ctx;
					cairo_pop_group_to_source (_tmp197_);
					_tmp198_ = ctx;
					cairo_paint (_tmp198_);
				}
			}
			_g_object_unref0 (layer);
		}
	}
	_cairo_destroy0 (ctx);
	_g_object_unref0 (color);
	_g_object_unref0 (icon);
	_g_object_unref0 (layers);
	return self;
}

GnomePieThemedIcon*
gnome_pie_themed_icon_new (const gchar* caption,
                           const gchar* icon_name,
                           gboolean active)
{
	return gnome_pie_themed_icon_construct (GNOME_PIE_TYPE_THEMED_ICON, caption, icon_name, active);
}

gint
gnome_pie_themed_icon_size (GnomePieThemedIcon* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = gnome_pie_image_width (G_TYPE_CHECK_INSTANCE_CAST (self, GNOME_PIE_TYPE_IMAGE, GnomePieImage));
	return result;
}

static void
gnome_pie_themed_icon_class_init (GnomePieThemedIconClass * klass,
                                  gpointer klass_data)
{
	gnome_pie_themed_icon_parent_class = g_type_class_peek_parent (klass);
}

static void
gnome_pie_themed_icon_instance_init (GnomePieThemedIcon * self,
                                     gpointer klass)
{
}

static GType
gnome_pie_themed_icon_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GnomePieThemedIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gnome_pie_themed_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GnomePieThemedIcon), 0, (GInstanceInitFunc) gnome_pie_themed_icon_instance_init, NULL };
	GType gnome_pie_themed_icon_type_id;
	gnome_pie_themed_icon_type_id = g_type_register_static (GNOME_PIE_TYPE_IMAGE, "GnomePieThemedIcon", &g_define_type_info, 0);
	return gnome_pie_themed_icon_type_id;
}

GType
gnome_pie_themed_icon_get_type (void)
{
	static volatile gsize gnome_pie_themed_icon_type_id__once = 0;
	if (g_once_init_enter (&gnome_pie_themed_icon_type_id__once)) {
		GType gnome_pie_themed_icon_type_id;
		gnome_pie_themed_icon_type_id = gnome_pie_themed_icon_get_type_once ();
		g_once_init_leave (&gnome_pie_themed_icon_type_id__once, gnome_pie_themed_icon_type_id);
	}
	return gnome_pie_themed_icon_type_id__once;
}

