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

/*
Copyright (C) 2014 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library 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 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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

enum  {
	BIRD_FONT_BACKGROUND_TOOLS_0_PROPERTY,
	BIRD_FONT_BACKGROUND_TOOLS_NUM_PROPERTIES
};
static GParamSpec* bird_font_background_tools_properties[BIRD_FONT_BACKGROUND_TOOLS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL (bird_font_background_tools_background_selection_label_get_type ())
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel))
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabelClass))
#define BIRD_FONT_BACKGROUND_TOOLS_IS_BACKGROUND_SELECTION_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL))
#define BIRD_FONT_BACKGROUND_TOOLS_IS_BACKGROUND_SELECTION_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL))
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabelClass))

typedef struct _BirdFontBackgroundToolsBackgroundSelectionLabel BirdFontBackgroundToolsBackgroundSelectionLabel;
typedef struct _BirdFontBackgroundToolsBackgroundSelectionLabelClass BirdFontBackgroundToolsBackgroundSelectionLabelClass;
typedef struct _BirdFontBackgroundToolsBackgroundSelectionLabelPrivate BirdFontBackgroundToolsBackgroundSelectionLabelPrivate;
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))

#define BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL (bird_font_background_tools_background_part_label_get_type ())
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabel))
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabelClass))
#define BIRD_FONT_BACKGROUND_TOOLS_IS_BACKGROUND_PART_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL))
#define BIRD_FONT_BACKGROUND_TOOLS_IS_BACKGROUND_PART_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL))
#define BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabelClass))

typedef struct _BirdFontBackgroundToolsBackgroundPartLabel BirdFontBackgroundToolsBackgroundPartLabel;
typedef struct _BirdFontBackgroundToolsBackgroundPartLabelClass BirdFontBackgroundToolsBackgroundPartLabelClass;
typedef struct _Block1Data Block1Data;
typedef struct _BirdFontBackgroundToolsBackgroundPartLabelPrivate BirdFontBackgroundToolsBackgroundPartLabelPrivate;
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;
typedef struct _Block4Data Block4Data;
enum  {
	BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL_0_PROPERTY,
	BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL_NUM_PROPERTIES
};
static GParamSpec* bird_font_background_tools_background_selection_label_properties[BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_SELECTION_LABEL_NUM_PROPERTIES];
enum  {
	BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL_0_PROPERTY,
	BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL_NUM_PROPERTIES
};
static GParamSpec* bird_font_background_tools_background_part_label_properties[BIRD_FONT_BACKGROUND_TOOLS_BACKGROUND_PART_LABEL_NUM_PROPERTIES];

struct _BirdFontBackgroundToolsPrivate {
	BirdFontExpander* files;
	BirdFontExpander* parts;
};

struct _BirdFontBackgroundToolsBackgroundSelectionLabel {
	BirdFontLabelTool parent_instance;
	BirdFontBackgroundToolsBackgroundSelectionLabelPrivate * priv;
	BirdFontBackgroundImage* img;
	gboolean deleted;
};

struct _BirdFontBackgroundToolsBackgroundSelectionLabelClass {
	BirdFontLabelToolClass parent_class;
};

struct _Block1Data {
	int _ref_count_;
	BirdFontBackgroundTools* self;
	BirdFontBackgroundToolsBackgroundPartLabel* bpl;
	BirdFontGlyphSelection* gs;
};

struct _BirdFontBackgroundToolsBackgroundPartLabel {
	BirdFontLabelTool parent_instance;
	BirdFontBackgroundToolsBackgroundPartLabelPrivate * priv;
	gboolean deleted;
	BirdFontBackgroundSelection* selection;
};

struct _BirdFontBackgroundToolsBackgroundPartLabelClass {
	BirdFontLabelToolClass parent_class;
};

struct _Block2Data {
	int _ref_count_;
	BirdFontBackgroundTools* self;
	BirdFontLabelTool* t;
};

struct _Block3Data {
	int _ref_count_;
	BirdFontBackgroundTools* self;
	BirdFontLabelTool* image_selection;
};

struct _Block4Data {
	int _ref_count_;
	Block3Data * _data3_;
	BirdFontLabelTool* t;
};

static gint BirdFontBackgroundTools_private_offset;
static gpointer bird_font_background_tools_parent_class = NULL;
static gpointer bird_font_background_tools_background_selection_label_parent_class = NULL;
static gpointer bird_font_background_tools_background_part_label_parent_class = NULL;

static void _bird_font_background_tools_update_tool_selection_bird_font_tool_select_action (BirdFontTool* _sender,
                                                                                     BirdFontTool* selected,
                                                                                     gpointer self);
static void __lambda258_ (BirdFontBackgroundTools* self,
                   BirdFontTool* t);
static void bird_font_background_tools_load_image (BirdFontBackgroundTools* self);
static void ___lambda258__bird_font_tool_select_action (BirdFontTool* _sender,
                                                 BirdFontTool* selected,
                                                 gpointer self);
static void bird_font_background_tools_real_reset_selection (BirdFontToolCollection* base,
                                                      BirdFontTool* selected);
static void bird_font_background_tools_set_default_canvas (BirdFontBackgroundTools* self);
static void bird_font_background_tools_real_selected (BirdFontToolCollection* base);
static gboolean __lambda263_ (BirdFontBackgroundTools* self);
static GType bird_font_background_tools_background_selection_label_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gboolean ___lambda263__gsource_func (gpointer self);
static GType bird_font_background_tools_background_part_label_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static BirdFontBackgroundToolsBackgroundPartLabel* bird_font_background_tools_background_part_label_new (BirdFontBackgroundSelection* selection,
                                                                                                  const gchar* base_name);
static BirdFontBackgroundToolsBackgroundPartLabel* bird_font_background_tools_background_part_label_construct (GType object_type,
                                                                                                        BirdFontBackgroundSelection* selection,
                                                                                                        const gchar* base_name);
static void __lambda249_ (BirdFontBackgroundTools* self,
                   BirdFontTool* t);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda250_ (Block1Data* _data1_,
                   BirdFontGlyphCollection* gc);
static void bird_font_background_tools_set_new_background_image (BirdFontBackgroundTools* self,
                                                          BirdFontGlyphCollection* gc,
                                                          BirdFontBackgroundToolsBackgroundPartLabel* bpl);
static void ___lambda250__bird_font_glyph_selection_selected_glyph (BirdFontGlyphSelection* _sender,
                                                             BirdFontGlyphCollection* gc,
                                                             gpointer self);
static void __lambda251_ (Block1Data* _data1_,
                   gunichar character);
static void ___lambda251__bird_font_overview_open_new_glyph_signal (BirdFontOverview* _sender,
                                                             gunichar c,
                                                             gpointer self);
static void ___lambda249__bird_font_tool_select_action (BirdFontTool* _sender,
                                                 BirdFontTool* selected,
                                                 gpointer self);
static void __lambda252_ (BirdFontBackgroundTools* self,
                   BirdFontLabelTool* t);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static gboolean __lambda253_ (Block2Data* _data2_);
static gboolean ___lambda253__gsource_func (gpointer self);
static void ___lambda252__bird_font_label_tool_delete_action (BirdFontLabelTool* _sender,
                                                       BirdFontLabelTool* _self_,
                                                       gpointer self);
static GeeArrayList* bird_font_background_tools_real_get_expanders (BirdFontToolCollection* base);
static void __lambda259_ (BirdFontBackgroundTools* self,
                   const gchar* fn);
static void bird_font_background_tools_add_image_file (BirdFontBackgroundTools* self,
                                                const gchar* file_path);
static void ___lambda259__bird_font_file_chooser_file_selected (BirdFontFileChooser* _sender,
                                                         const gchar* path,
                                                         gpointer self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static BirdFontBackgroundToolsBackgroundSelectionLabel* bird_font_background_tools_background_selection_label_new (BirdFontBackgroundImage* img,
                                                                                                            const gchar* base_name);
static BirdFontBackgroundToolsBackgroundSelectionLabel* bird_font_background_tools_background_selection_label_construct (GType object_type,
                                                                                                                  BirdFontBackgroundImage* img,
                                                                                                                  const gchar* base_name);
static void __lambda260_ (BirdFontBackgroundTools* self,
                   BirdFontTool* t);
static void ___lambda260__bird_font_tool_select_action (BirdFontTool* _sender,
                                                 BirdFontTool* selected,
                                                 gpointer self);
static void __lambda261_ (Block3Data* _data3_,
                   BirdFontLabelTool* t);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static gboolean __lambda262_ (Block4Data* _data4_);
static gboolean ___lambda262__gsource_func (gpointer self);
static void ___lambda261__bird_font_label_tool_delete_action (BirdFontLabelTool* _sender,
                                                       BirdFontLabelTool* _self_,
                                                       gpointer self);
static GeeArrayList* bird_font_background_tools_real_get_displays (BirdFontToolCollection* base);
static void bird_font_background_tools_background_selection_label_finalize (GObject * obj);
static GType bird_font_background_tools_background_selection_label_get_type_once (void);
static void bird_font_background_tools_background_part_label_finalize (GObject * obj);
static GType bird_font_background_tools_background_part_label_get_type_once (void);
static void bird_font_background_tools_finalize (GObject * obj);
static GType bird_font_background_tools_get_type_once (void);

static inline gpointer
bird_font_background_tools_get_instance_private (BirdFontBackgroundTools* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontBackgroundTools_private_offset);
}

static void
_bird_font_background_tools_update_tool_selection_bird_font_tool_select_action (BirdFontTool* _sender,
                                                                                BirdFontTool* selected,
                                                                                gpointer self)
{
	bird_font_background_tools_update_tool_selection ((BirdFontBackgroundTools*) self, selected);
}

static void
__lambda258_ (BirdFontBackgroundTools* self,
              BirdFontTool* t)
{
	g_return_if_fail (t != NULL);
	bird_font_background_tools_load_image (self);
}

static void
___lambda258__bird_font_tool_select_action (BirdFontTool* _sender,
                                            BirdFontTool* selected,
                                            gpointer self)
{
	__lambda258_ ((BirdFontBackgroundTools*) self, selected);
}

BirdFontBackgroundTools*
bird_font_background_tools_construct (GType object_type)
{
	BirdFontBackgroundTools * self = NULL;
	BirdFontExpander* background_tools = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	BirdFontExpander* _tmp2_;
	BirdFontExpander* _tmp3_;
	BirdFontExpander* background_selection = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	BirdFontExpander* _tmp6_;
	BirdFontExpander* _tmp7_;
	BirdFontExpander* font_name = NULL;
	BirdFontExpander* _tmp8_;
	BirdFontFontName* _tmp9_;
	BirdFontFontName* _tmp10_;
	BirdFontBackgroundSelectionTool* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	BirdFontExpander* _tmp14_;
	BirdFontExpander* _tmp15_;
	BirdFontExpander* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	BirdFontExpander* _tmp19_;
	BirdFontExpander* _tmp20_;
	BirdFontExpander* _tmp21_;
	BirdFontBackgroundSelectionTool* _tmp22_;
	BirdFontBackgroundSelectionTool* _tmp23_;
	BirdFontBackgroundTool* _tmp24_;
	BirdFontBackgroundTool* _tmp25_;
	BirdFontTool* _tmp26_;
	BirdFontTool* _tmp27_;
	BirdFontSpinButton* _tmp28_;
	BirdFontLabelTool* add_new_image = NULL;
	gchar* _tmp29_;
	gchar* _tmp30_;
	BirdFontLabelTool* _tmp31_;
	BirdFontLabelTool* _tmp32_;
	GeeArrayList* _tmp33_;
	GeeArrayList* _tmp34_;
	GeeArrayList* _tmp35_;
	BirdFontExpander* _tmp36_;
	BirdFontExpander* _tmp37_;
	GeeArrayList* _tmp38_;
	BirdFontExpander* _tmp39_;
	BirdFontExpander* _tmp40_;
	GeeArrayList* _tmp41_;
	GeeArrayList* _tmp42_;
	BirdFontExpander* _tmp43_;
	GeeArrayList* _tmp44_;
	BirdFontExpander* _tmp45_;
	self = (BirdFontBackgroundTools*) bird_font_tool_collection_construct (object_type);
	_tmp0_ = bird_font_t_ ("Background Image");
	_tmp1_ = _tmp0_;
	_tmp2_ = bird_font_expander_new (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	background_tools = _tmp3_;
	_tmp4_ = bird_font_t_ ("Images");
	_tmp5_ = _tmp4_;
	_tmp6_ = bird_font_expander_new (_tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	background_selection = _tmp7_;
	_tmp8_ = bird_font_expander_new (NULL);
	font_name = _tmp8_;
	_tmp9_ = bird_font_font_name_new (NULL, "");
	_tmp10_ = _tmp9_;
	bird_font_expander_add_tool (font_name, (BirdFontTool*) _tmp10_, -1);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = bird_font_background_selection_tool_new ();
	_g_object_unref0 (self->select_background);
	self->select_background = _tmp11_;
	_tmp12_ = bird_font_t_ ("Files");
	_tmp13_ = _tmp12_;
	_tmp14_ = bird_font_expander_new (_tmp13_);
	_g_object_unref0 (self->priv->files);
	self->priv->files = _tmp14_;
	_g_free0 (_tmp13_);
	_tmp15_ = self->priv->files;
	bird_font_expander_set_persistent (_tmp15_, TRUE);
	_tmp16_ = self->priv->files;
	bird_font_expander_set_unique (_tmp16_, TRUE);
	_tmp17_ = bird_font_t_ ("Parts");
	_tmp18_ = _tmp17_;
	_tmp19_ = bird_font_expander_new (_tmp18_);
	_g_object_unref0 (self->priv->parts);
	self->priv->parts = _tmp19_;
	_g_free0 (_tmp18_);
	_tmp20_ = self->priv->parts;
	bird_font_expander_set_persistent (_tmp20_, TRUE);
	_tmp21_ = self->priv->parts;
	bird_font_expander_set_unique (_tmp21_, TRUE);
	_tmp22_ = self->select_background;
	bird_font_expander_add_tool (background_tools, (BirdFontTool*) _tmp22_, -1);
	_tmp23_ = self->select_background;
	g_signal_connect_object ((BirdFontTool*) _tmp23_, "select-action", (GCallback) _bird_font_background_tools_update_tool_selection_bird_font_tool_select_action, self, 0);
	_tmp24_ = bird_font_drawing_tools_move_background;
	bird_font_expander_add_tool (background_tools, (BirdFontTool*) _tmp24_, -1);
	_tmp25_ = bird_font_drawing_tools_move_background;
	g_signal_connect_object ((BirdFontTool*) _tmp25_, "select-action", (GCallback) _bird_font_background_tools_update_tool_selection_bird_font_tool_select_action, self, 0);
	_tmp26_ = bird_font_drawing_tools_move_canvas;
	bird_font_expander_add_tool (background_tools, _tmp26_, -1);
	_tmp27_ = bird_font_drawing_tools_move_canvas;
	g_signal_connect_object (_tmp27_, "select-action", (GCallback) _bird_font_background_tools_update_tool_selection_bird_font_tool_select_action, self, 0);
	_tmp28_ = bird_font_drawing_tools_background_scale;
	bird_font_expander_add_tool (background_tools, (BirdFontTool*) _tmp28_, -1);
	_tmp29_ = bird_font_t_ ("Add");
	_tmp30_ = _tmp29_;
	_tmp31_ = bird_font_label_tool_new (_tmp30_);
	_tmp32_ = _tmp31_;
	_g_free0 (_tmp30_);
	add_new_image = _tmp32_;
	g_signal_connect_object ((BirdFontTool*) add_new_image, "select-action", (GCallback) ___lambda258__bird_font_tool_select_action, self, 0);
	bird_font_expander_add_tool (background_selection, (BirdFontTool*) add_new_image, -1);
	_tmp33_ = self->expanders;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp33_, font_name);
	_tmp34_ = self->expanders;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp34_, background_tools);
	_tmp35_ = self->expanders;
	_tmp36_ = bird_font_drawing_tools_get_zoombar_tool ();
	_tmp37_ = _tmp36_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp35_, _tmp37_);
	_tmp38_ = self->expanders;
	_tmp39_ = bird_font_drawing_tools_get_guideline_tools ();
	_tmp40_ = _tmp39_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp38_, _tmp40_);
	_tmp41_ = self->expanders;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp41_, background_selection);
	_tmp42_ = self->expanders;
	_tmp43_ = self->priv->files;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp42_, _tmp43_);
	_tmp44_ = self->expanders;
	_tmp45_ = self->priv->parts;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp45_);
	_g_object_unref0 (add_new_image);
	_g_object_unref0 (font_name);
	_g_object_unref0 (background_selection);
	_g_object_unref0 (background_tools);
	return self;
}

BirdFontBackgroundTools*
bird_font_background_tools_new (void)
{
	return bird_font_background_tools_construct (BIRD_FONT_TYPE_BACKGROUND_TOOLS);
}

static void
bird_font_background_tools_real_reset_selection (BirdFontToolCollection* base,
                                                 BirdFontTool* selected)
{
	BirdFontBackgroundTools * self;
	BirdFontBackgroundSelectionTool* _tmp0_;
	BirdFontBackgroundTool* _tmp1_;
	BirdFontTool* _tmp2_;
	BirdFontSpinButton* _tmp3_;
	self = (BirdFontBackgroundTools*) base;
	g_return_if_fail (selected != NULL);
	_tmp0_ = self->select_background;
	bird_font_tool_set_selected ((BirdFontTool*) _tmp0_, FALSE);
	_tmp1_ = bird_font_drawing_tools_move_background;
	bird_font_tool_set_selected ((BirdFontTool*) _tmp1_, FALSE);
	_tmp2_ = bird_font_drawing_tools_move_canvas;
	bird_font_tool_set_selected (_tmp2_, FALSE);
	_tmp3_ = bird_font_drawing_tools_background_scale;
	bird_font_tool_set_selected ((BirdFontTool*) _tmp3_, FALSE);
}

void
bird_font_background_tools_update_tool_selection (BirdFontBackgroundTools* self,
                                                  BirdFontTool* selected)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (selected != NULL);
	bird_font_tool_collection_reset_selection ((BirdFontToolCollection*) self, selected);
	bird_font_tool_set_selected (selected, TRUE);
}

void
bird_font_background_tools_remove_images (BirdFontBackgroundTools* self)
{
	BirdFontExpander* _tmp0_;
	GeeArrayList* _tmp1_;
	BirdFontExpander* _tmp2_;
	GeeArrayList* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->files;
	_tmp1_ = _tmp0_->tool;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp1_);
	_tmp2_ = self->priv->parts;
	_tmp3_ = _tmp2_->tool;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp3_);
}

static void
bird_font_background_tools_set_default_canvas (BirdFontBackgroundTools* self)
{
	BirdFontTabBar* _tmp0_;
	BirdFontTabBar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_main_window_get_tab_bar ();
	_tmp1_ = _tmp0_;
	bird_font_tab_bar_select_tab_name (_tmp1_, "Backgrounds");
	_g_object_unref0 (_tmp1_);
}

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

static gboolean
__lambda263_ (BirdFontBackgroundTools* self)
{
	gboolean result;
	{
		GeeArrayList* _t_list = NULL;
		BirdFontExpander* _tmp0_;
		GeeArrayList* _tmp1_;
		gint _t_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _t_index = 0;
		_tmp0_ = self->priv->files;
		_tmp1_ = _tmp0_->tool;
		_t_list = _tmp1_;
		_tmp2_ = _t_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_t_size = _tmp4_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			BirdFontTool* t = NULL;
			GeeArrayList* _tmp7_;
			gpointer _tmp8_;
			BirdFontBackgroundToolsBackgroundSelectionLabel* bg = NULL;
			BirdFontTool* _tmp9_;
			BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp10_;
			BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp11_;
			_t_index = _t_index + 1;
			_tmp5_ = _t_index;
			_tmp6_ = _t_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _t_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _t_index);
			t = (BirdFontTool*) _tmp8_;
			_tmp9_ = t;
			_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel));
			bg = _tmp10_;
			_tmp11_ = bg;
			if (bird_font_tool_is_selected ((BirdFontTool*) _tmp11_)) {
				BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp12_;
				BirdFontBackgroundImage* _tmp13_;
				_tmp12_ = bg;
				_tmp13_ = _tmp12_->img;
				bird_font_background_tools_update_parts_list (self, _tmp13_);
			}
			_g_object_unref0 (bg);
			_g_object_unref0 (t);
		}
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda263__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda263_ ((BirdFontBackgroundTools*) self);
	return result;
}

static void
bird_font_background_tools_real_selected (BirdFontToolCollection* base)
{
	BirdFontBackgroundTools * self;
	GSource* idle = NULL;
	GSource* _tmp0_;
	self = (BirdFontBackgroundTools*) base;
	_tmp0_ = g_idle_source_new ();
	idle = _tmp0_;
	g_source_set_callback (idle, ___lambda263__gsource_func, g_object_ref (self), g_object_unref);
	g_source_attach (idle, NULL);
	BIRD_FONT_TOOL_COLLECTION_CLASS (bird_font_background_tools_parent_class)->selected (G_TYPE_CHECK_INSTANCE_CAST (self, BIRD_FONT_TYPE_TOOL_COLLECTION, BirdFontToolCollection));
	_g_source_unref0 (idle);
}

void
bird_font_background_tools_update_parts_list (BirdFontBackgroundTools* self,
                                              BirdFontBackgroundImage* current_image)
{
	BirdFontExpander* _tmp0_;
	GeeArrayList* _tmp1_;
	BirdFontExpander* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_image != NULL);
	_tmp0_ = self->priv->parts;
	_tmp1_ = _tmp0_->tool;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp1_);
	{
		GeeArrayList* _selection_list = NULL;
		GeeArrayList* _tmp2_;
		gint _selection_size = 0;
		GeeArrayList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _selection_index = 0;
		_tmp2_ = current_image->selections;
		_selection_list = _tmp2_;
		_tmp3_ = _selection_list;
		_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_selection_size = _tmp5_;
		_selection_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			BirdFontBackgroundSelection* selection = NULL;
			GeeArrayList* _tmp8_;
			gpointer _tmp9_;
			BirdFontBackgroundSelection* _tmp10_;
			_selection_index = _selection_index + 1;
			_tmp6_ = _selection_index;
			_tmp7_ = _selection_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _selection_list;
			_tmp9_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _selection_index);
			selection = (BirdFontBackgroundSelection*) _tmp9_;
			_tmp10_ = selection;
			bird_font_background_tools_add_part (self, _tmp10_);
			_g_object_unref0 (selection);
		}
	}
	_tmp11_ = self->priv->parts;
	bird_font_expander_redraw (_tmp11_);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		BirdFontBackgroundTools* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->gs);
		_g_object_unref0 (_data1_->bpl);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda250_ (Block1Data* _data1_,
              BirdFontGlyphCollection* gc)
{
	BirdFontBackgroundTools* self;
	BirdFontGlyphCollection* pgc = NULL;
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	BirdFontFont* _tmp1_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp2_;
	BirdFontBackgroundSelection* _tmp3_;
	const gchar* _tmp4_;
	BirdFontGlyphCollection* _tmp5_;
	BirdFontGlyphCollection* _tmp6_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp10_;
	self = _data1_->self;
	g_return_if_fail (gc != NULL);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = font;
	_tmp2_ = _data1_->bpl;
	_tmp3_ = _tmp2_->selection;
	_tmp4_ = _tmp3_->assigned_glyph;
	_tmp5_ = bird_font_font_get_glyph_collection_by_name (_tmp1_, _tmp4_);
	_g_object_unref0 (pgc);
	pgc = _tmp5_;
	_tmp6_ = pgc;
	if (_tmp6_ != NULL) {
		BirdFontGlyphCollection* _tmp7_;
		BirdFontGlyph* _tmp8_;
		BirdFontGlyph* _tmp9_;
		_tmp7_ = pgc;
		_tmp8_ = bird_font_glyph_collection_get_current (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, BIRD_FONT_TYPE_GLYPH_COLLECTION, BirdFontGlyphCollection));
		_tmp9_ = _tmp8_;
		bird_font_glyph_set_background_image (_tmp9_, NULL);
		_g_object_unref0 (_tmp9_);
	}
	_tmp10_ = _data1_->bpl;
	bird_font_background_tools_set_new_background_image (self, gc, _tmp10_);
	_g_object_unref0 (font);
	_g_object_unref0 (pgc);
}

static void
___lambda250__bird_font_glyph_selection_selected_glyph (BirdFontGlyphSelection* _sender,
                                                        BirdFontGlyphCollection* gc,
                                                        gpointer self)
{
	__lambda250_ (self, gc);
}

static void
__lambda251_ (Block1Data* _data1_,
              gunichar character)
{
	BirdFontBackgroundTools* self;
	BirdFontGlyphCollection* gc = NULL;
	BirdFontGlyphSelection* _tmp0_;
	BirdFontGlyphCollection* _tmp1_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp2_;
	self = _data1_->self;
	_tmp0_ = _data1_->gs;
	_tmp1_ = bird_font_overview_create_new_glyph ((BirdFontOverview*) _tmp0_, character);
	gc = _tmp1_;
	_tmp2_ = _data1_->bpl;
	bird_font_background_tools_set_new_background_image (self, gc, _tmp2_);
	_g_object_unref0 (gc);
}

static void
___lambda251__bird_font_overview_open_new_glyph_signal (BirdFontOverview* _sender,
                                                        gunichar c,
                                                        gpointer self)
{
	__lambda251_ (self, c);
}

static void
__lambda249_ (BirdFontBackgroundTools* self,
              BirdFontTool* t)
{
	Block1Data* _data1_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp0_;
	BirdFontGlyphSelection* _tmp1_;
	BirdFontGlyphSelection* _tmp2_;
	BirdFontGlyphSelection* _tmp3_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp4_;
	g_return_if_fail (t != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (t, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabel));
	_data1_->bpl = _tmp0_;
	_tmp1_ = bird_font_glyph_selection_new ();
	_data1_->gs = _tmp1_;
	_tmp2_ = _data1_->gs;
	g_signal_connect_data (_tmp2_, "selected-glyph", (GCallback) ___lambda250__bird_font_glyph_selection_selected_glyph, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp3_ = _data1_->gs;
	g_signal_connect_data ((BirdFontOverview*) _tmp3_, "open-new-glyph-signal", (GCallback) ___lambda251__bird_font_overview_open_new_glyph_signal, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp4_ = _data1_->bpl;
	if (!_tmp4_->deleted) {
		BirdFontGlyphSelection* _tmp5_;
		_tmp5_ = _data1_->gs;
		bird_font_glyph_canvas_set_display ((BirdFontFontDisplay*) _tmp5_);
		bird_font_toolbox_set_toolbox_from_tab ("Overview", NULL);
	}
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
___lambda249__bird_font_tool_select_action (BirdFontTool* _sender,
                                            BirdFontTool* selected,
                                            gpointer self)
{
	__lambda249_ ((BirdFontBackgroundTools*) self, selected);
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		BirdFontBackgroundTools* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->t);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static gboolean
__lambda253_ (Block2Data* _data2_)
{
	BirdFontBackgroundTools* self;
	BirdFontGlyphCollection* gc = NULL;
	BirdFontBackgroundToolsBackgroundPartLabel* bpl = NULL;
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp1_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp2_;
	BirdFontFont* _tmp3_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp4_;
	BirdFontBackgroundSelection* _tmp5_;
	const gchar* _tmp6_;
	BirdFontGlyphCollection* _tmp7_;
	BirdFontGlyphCollection* _tmp8_;
	BirdFontExpander* _tmp12_;
	GeeArrayList* _tmp13_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp14_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp15_;
	BirdFontBackgroundSelection* _tmp16_;
	BirdFontBackgroundImage* _tmp17_;
	GeeArrayList* _tmp18_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp19_;
	BirdFontBackgroundSelection* _tmp20_;
	BirdFontToolbox* _tmp21_;
	BirdFontToolbox* _tmp22_;
	BirdFontExpander* _tmp23_;
	gboolean result;
	self = _data2_->self;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data2_->t, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabel));
	_g_object_unref0 (bpl);
	bpl = _tmp1_;
	_tmp2_ = bpl;
	_tmp2_->deleted = TRUE;
	_tmp3_ = font;
	_tmp4_ = bpl;
	_tmp5_ = _tmp4_->selection;
	_tmp6_ = _tmp5_->assigned_glyph;
	_tmp7_ = bird_font_font_get_glyph_collection_by_name (_tmp3_, _tmp6_);
	_g_object_unref0 (gc);
	gc = _tmp7_;
	_tmp8_ = gc;
	if (_tmp8_ != NULL) {
		BirdFontGlyphCollection* _tmp9_;
		BirdFontGlyph* _tmp10_;
		BirdFontGlyph* _tmp11_;
		_tmp9_ = gc;
		_tmp10_ = bird_font_glyph_collection_get_current (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, BIRD_FONT_TYPE_GLYPH_COLLECTION, BirdFontGlyphCollection));
		_tmp11_ = _tmp10_;
		bird_font_glyph_set_background_image (_tmp11_, NULL);
		_g_object_unref0 (_tmp11_);
	}
	_tmp12_ = self->priv->parts;
	_tmp13_ = _tmp12_->tool;
	_tmp14_ = bpl;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp13_, (BirdFontTool*) _tmp14_);
	_tmp15_ = bpl;
	_tmp16_ = _tmp15_->selection;
	_tmp17_ = _tmp16_->parent_image;
	_tmp18_ = _tmp17_->selections;
	_tmp19_ = bpl;
	_tmp20_ = _tmp19_->selection;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp18_, _tmp20_);
	_tmp21_ = bird_font_main_window_get_toolbox ();
	_tmp22_ = _tmp21_;
	bird_font_toolbox_update_expanders (_tmp22_);
	_g_object_unref0 (_tmp22_);
	_tmp23_ = self->priv->parts;
	bird_font_expander_clear_cache (_tmp23_);
	bird_font_background_tools_set_default_canvas (self);
	bird_font_toolbox_redraw_tool_box ();
	bird_font_glyph_canvas_redraw ();
	result = FALSE;
	_g_object_unref0 (font);
	_g_object_unref0 (bpl);
	_g_object_unref0 (gc);
	return result;
}

static gboolean
___lambda253__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda253_ (self);
	return result;
}

static void
__lambda252_ (BirdFontBackgroundTools* self,
              BirdFontLabelTool* t)
{
	Block2Data* _data2_;
	BirdFontLabelTool* _tmp0_;
	GSource* idle = NULL;
	GSource* _tmp1_;
	g_return_if_fail (t != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (t);
	_g_object_unref0 (_data2_->t);
	_data2_->t = _tmp0_;
	_tmp1_ = g_idle_source_new ();
	idle = _tmp1_;
	g_source_set_callback (idle, ___lambda253__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	g_source_attach (idle, NULL);
	_g_source_unref0 (idle);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}

static void
___lambda252__bird_font_label_tool_delete_action (BirdFontLabelTool* _sender,
                                                  BirdFontLabelTool* _self_,
                                                  gpointer self)
{
	__lambda252_ ((BirdFontBackgroundTools*) self, _self_);
}

void
bird_font_background_tools_add_part (BirdFontBackgroundTools* self,
                                     BirdFontBackgroundSelection* selection)
{
	BirdFontBackgroundToolsBackgroundPartLabel* label = NULL;
	const gchar* _tmp0_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp6_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp7_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp8_;
	BirdFontExpander* _tmp9_;
	BirdFontBackgroundToolsBackgroundPartLabel* _tmp10_;
	BirdFontExpander* _tmp11_;
	BirdFontToolbox* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (selection != NULL);
	_tmp0_ = selection->assigned_glyph;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		gchar* _tmp2_;
		BirdFontBackgroundToolsBackgroundPartLabel* _tmp3_;
		_tmp1_ = bird_font_t_ ("Select Glyph");
		_tmp2_ = _tmp1_;
		_tmp3_ = bird_font_background_tools_background_part_label_new (selection, _tmp2_);
		_g_object_unref0 (label);
		label = _tmp3_;
		_g_free0 (_tmp2_);
	} else {
		const gchar* _tmp4_;
		BirdFontBackgroundToolsBackgroundPartLabel* _tmp5_;
		_tmp4_ = selection->assigned_glyph;
		_tmp5_ = bird_font_background_tools_background_part_label_new (selection, (const gchar*) _tmp4_);
		_g_object_unref0 (label);
		label = _tmp5_;
	}
	_tmp6_ = label;
	g_signal_connect_object ((BirdFontTool*) _tmp6_, "select-action", (GCallback) ___lambda249__bird_font_tool_select_action, self, 0);
	_tmp7_ = label;
	g_signal_connect_object ((BirdFontLabelTool*) _tmp7_, "delete-action", (GCallback) ___lambda252__bird_font_label_tool_delete_action, self, 0);
	_tmp8_ = label;
	bird_font_label_tool_set_has_delete_button ((BirdFontLabelTool*) _tmp8_, TRUE);
	_tmp9_ = self->priv->parts;
	_tmp10_ = label;
	bird_font_expander_add_tool (_tmp9_, (BirdFontTool*) _tmp10_, 0);
	_tmp11_ = self->priv->parts;
	bird_font_expander_redraw (_tmp11_);
	_tmp12_ = bird_font_main_window_get_toolbox ();
	if (!bird_font_is_null (_tmp12_)) {
		BirdFontToolbox* _tmp13_;
		BirdFontToolbox* _tmp14_;
		BirdFontExpander* _tmp15_;
		_tmp13_ = bird_font_main_window_get_toolbox ();
		_tmp14_ = _tmp13_;
		bird_font_toolbox_update_expanders (_tmp14_);
		_g_object_unref0 (_tmp14_);
		_tmp15_ = self->priv->parts;
		bird_font_expander_clear_cache (_tmp15_);
		bird_font_toolbox_redraw_tool_box ();
		bird_font_glyph_canvas_redraw ();
	}
	_g_object_unref0 (label);
}

static void
bird_font_background_tools_set_new_background_image (BirdFontBackgroundTools* self,
                                                     BirdFontGlyphCollection* gc,
                                                     BirdFontBackgroundToolsBackgroundPartLabel* bpl)
{
	BirdFontGlyph* g = NULL;
	BirdFontGlyph* _tmp0_;
	BirdFontBackgroundSelection* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	BirdFontGlyph* _tmp5_;
	BirdFontBackgroundSelection* _tmp6_;
	BirdFontBackgroundImage* _tmp7_;
	BirdFontGlyph* _tmp8_;
	BirdFontBackgroundSelection* _tmp9_;
	BirdFontBackgroundImage* _tmp10_;
	BirdFontToolbox* _tmp15_;
	BirdFontToolbox* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gc != NULL);
	g_return_if_fail (bpl != NULL);
	_tmp0_ = bird_font_glyph_collection_get_current (gc);
	_g_object_unref0 (g);
	g = _tmp0_;
	_tmp1_ = bpl->selection;
	_tmp2_ = bird_font_glyph_collection_get_name (gc);
	_g_free0 (_tmp1_->assigned_glyph);
	_tmp1_->assigned_glyph = _tmp2_;
	_tmp3_ = bird_font_glyph_collection_get_name (gc);
	_tmp4_ = _tmp3_;
	bird_font_label_tool_set_label ((BirdFontLabelTool*) bpl, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = g;
	_tmp6_ = bpl->selection;
	_tmp7_ = _tmp6_->image;
	bird_font_glyph_set_background_image (_tmp5_, _tmp7_);
	_tmp8_ = g;
	bird_font_glyph_set_background_visible (_tmp8_, TRUE);
	_tmp9_ = bpl->selection;
	_tmp10_ = _tmp9_->image;
	if (_tmp10_ != NULL) {
		BirdFontBackgroundSelection* _tmp11_;
		BirdFontBackgroundImage* _tmp12_;
		BirdFontGlyph* _tmp13_;
		BirdFontGlyph* _tmp14_;
		_tmp11_ = bpl->selection;
		_tmp12_ = _tmp11_->image;
		_tmp13_ = bird_font_glyph_collection_get_current (gc);
		_tmp14_ = _tmp13_;
		bird_font_background_image_center_in_glyph (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, BIRD_FONT_TYPE_BACKGROUND_IMAGE, BirdFontBackgroundImage), _tmp14_);
		_g_object_unref0 (_tmp14_);
	}
	bird_font_background_tools_set_default_canvas (self);
	bird_font_zoom_tool_zoom_full_background_image ();
	_tmp15_ = bird_font_main_window_get_toolbox ();
	_tmp16_ = _tmp15_;
	bird_font_toolbox_update_expanders (_tmp16_);
	_g_object_unref0 (_tmp16_);
	_g_object_unref0 (g);
}

static GeeArrayList*
bird_font_background_tools_real_get_expanders (BirdFontToolCollection* base)
{
	BirdFontBackgroundTools * self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* result;
	self = (BirdFontBackgroundTools*) base;
	_tmp0_ = self->expanders;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
__lambda259_ (BirdFontBackgroundTools* self,
              const gchar* fn)
{
	if (fn != NULL) {
		bird_font_background_tools_add_image_file (self, (const gchar*) fn);
	}
}

static void
___lambda259__bird_font_file_chooser_file_selected (BirdFontFileChooser* _sender,
                                                    const gchar* path,
                                                    gpointer self)
{
	__lambda259_ ((BirdFontBackgroundTools*) self, path);
}

static void
bird_font_background_tools_load_image (BirdFontBackgroundTools* self)
{
	BirdFontFileChooser* fc = NULL;
	BirdFontFileChooser* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_file_chooser_new ();
	fc = _tmp0_;
	g_signal_connect_object (fc, "file-selected", (GCallback) ___lambda259__bird_font_file_chooser_file_selected, self, 0);
	bird_font_file_chooser_add_extension (fc, "png");
	bird_font_file_chooser_add_extension (fc, "jpeg");
	bird_font_file_chooser_add_extension (fc, "jpg");
	bird_font_file_chooser_add_extension (fc, "gif");
	bird_font_file_chooser_add_extension (fc, "tiff");
	bird_font_file_chooser_add_extension (fc, "bmp");
	bird_font_file_chooser_add_extension (fc, "svg");
	_tmp1_ = bird_font_t_ ("Open");
	_tmp2_ = _tmp1_;
	bird_font_main_window_file_chooser (_tmp2_, fc, BIRD_FONT_FILE_CHOOSER_LOAD);
	_g_free0 (_tmp2_);
	_g_object_unref0 (fc);
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (needle != NULL, 0);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

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
bird_font_background_tools_add_image_file (BirdFontBackgroundTools* self,
                                           const gchar* file_path)
{
	GFile* f = NULL;
	GFile* _tmp0_;
	gchar* fn = NULL;
	GFile* _tmp1_;
	gchar* _tmp2_;
	BirdFontBackgroundImage* image = NULL;
	BirdFontBackgroundImage* _tmp3_;
	gint i = 0;
	const gchar* _tmp4_;
	BirdFontBackgroundImage* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	BirdFontBackgroundImage* _tmp10_;
	BirdFontToolbox* _tmp11_;
	BirdFontToolbox* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_path != NULL);
	_tmp0_ = g_file_new_for_path (file_path);
	f = _tmp0_;
	_tmp1_ = f;
	_tmp2_ = g_file_get_basename (_tmp1_);
	fn = (gchar*) _tmp2_;
	_tmp3_ = bird_font_background_image_new (file_path);
	image = _tmp3_;
	_tmp4_ = fn;
	i = string_index_of (_tmp4_, ".", 0);
	if (i > -1) {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = fn;
		_tmp6_ = string_substring (_tmp5_, (glong) 0, (glong) i);
		_g_free0 (fn);
		fn = _tmp6_;
	}
	_tmp7_ = image;
	_tmp8_ = fn;
	_tmp9_ = g_strdup (_tmp8_);
	_g_free0 (_tmp7_->name);
	_tmp7_->name = _tmp9_;
	_tmp10_ = image;
	bird_font_background_tools_add_image (self, _tmp10_);
	bird_font_glyph_canvas_redraw ();
	_tmp11_ = bird_font_main_window_get_toolbox ();
	_tmp12_ = _tmp11_;
	bird_font_toolbox_update_expanders (_tmp12_);
	_g_object_unref0 (_tmp12_);
	bird_font_toolbox_redraw_tool_box ();
	_g_object_unref0 (image);
	_g_free0 (fn);
	_g_object_unref0 (f);
}

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

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

static void
__lambda260_ (BirdFontBackgroundTools* self,
              BirdFontTool* t)
{
	BirdFontBackgroundTab* background_tab = NULL;
	BirdFontBackgroundTab* _tmp0_;
	BirdFontBackgroundToolsBackgroundSelectionLabel* bg = NULL;
	BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp1_;
	BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp2_;
	g_return_if_fail (t != NULL);
	_tmp0_ = bird_font_background_tab_get_instance ();
	background_tab = _tmp0_;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (t, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel));
	bg = _tmp1_;
	_tmp2_ = bg;
	if (!_tmp2_->deleted) {
		BirdFontBackgroundTab* _tmp3_;
		BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp4_;
		BirdFontBackgroundImage* _tmp5_;
		BirdFontBackgroundTab* _tmp6_;
		BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp7_;
		BirdFontBackgroundImage* _tmp8_;
		_tmp3_ = background_tab;
		_tmp4_ = bg;
		_tmp5_ = _tmp4_->img;
		bird_font_glyph_set_background_image ((BirdFontGlyph*) _tmp3_, _tmp5_);
		_tmp6_ = background_tab;
		bird_font_glyph_set_background_visible ((BirdFontGlyph*) _tmp6_, TRUE);
		bird_font_zoom_tool_zoom_full_background_image ();
		_tmp7_ = bg;
		_tmp8_ = _tmp7_->img;
		bird_font_background_tools_update_parts_list (self, _tmp8_);
		bird_font_glyph_canvas_redraw ();
		bird_font_toolbox_redraw_tool_box ();
	}
	bird_font_background_tools_set_default_canvas (self);
	_g_object_unref0 (bg);
	_g_object_unref0 (background_tab);
}

static void
___lambda260__bird_font_tool_select_action (BirdFontTool* _sender,
                                            BirdFontTool* selected,
                                            gpointer self)
{
	__lambda260_ ((BirdFontBackgroundTools*) self, selected);
}

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

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		BirdFontBackgroundTools* self;
		self = _data4_->_data3_->self;
		_g_object_unref0 (_data4_->t);
		block3_data_unref (_data4_->_data3_);
		_data4_->_data3_ = NULL;
		g_slice_free (Block4Data, _data4_);
	}
}

static gboolean
__lambda262_ (Block4Data* _data4_)
{
	Block3Data* _data3_;
	BirdFontBackgroundTools* self;
	BirdFontBackgroundToolsBackgroundSelectionLabel* bsl = NULL;
	BirdFontFont* f = NULL;
	BirdFontFont* _tmp0_;
	BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp1_;
	BirdFontExpander* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	BirdFontBackgroundImage* _tmp5_;
	BirdFontGlyph* _tmp6_;
	BirdFontGlyph* _tmp7_;
	BirdFontToolbox* _tmp8_;
	BirdFontToolbox* _tmp9_;
	BirdFontLabelTool* _tmp10_;
	gboolean result;
	_data3_ = _data4_->_data3_;
	self = _data3_->self;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	f = _tmp0_;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data4_->t, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel));
	_g_object_unref0 (bsl);
	bsl = _tmp1_;
	bsl->deleted = TRUE;
	_tmp2_ = self->priv->files;
	_tmp3_ = _tmp2_->tool;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp3_, (BirdFontTool*) bsl);
	_tmp4_ = f->background_images;
	_tmp5_ = bsl->img;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp4_, _tmp5_);
	_tmp6_ = bird_font_main_window_get_current_glyph ();
	_tmp7_ = _tmp6_;
	bird_font_glyph_set_background_image (_tmp7_, NULL);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = bird_font_main_window_get_toolbox ();
	_tmp9_ = _tmp8_;
	bird_font_toolbox_update_expanders (_tmp9_);
	_g_object_unref0 (_tmp9_);
	bird_font_background_tools_set_default_canvas (self);
	_tmp10_ = _data3_->image_selection;
	bird_font_tool_redraw ((BirdFontTool*) _tmp10_);
	bird_font_glyph_canvas_redraw ();
	result = FALSE;
	_g_object_unref0 (f);
	_g_object_unref0 (bsl);
	return result;
}

static gboolean
___lambda262__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda262_ (self);
	return result;
}

static void
__lambda261_ (Block3Data* _data3_,
              BirdFontLabelTool* t)
{
	BirdFontBackgroundTools* self;
	Block4Data* _data4_;
	BirdFontLabelTool* _tmp0_;
	GSource* idle = NULL;
	GSource* _tmp1_;
	self = _data3_->self;
	g_return_if_fail (t != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->_data3_ = block3_data_ref (_data3_);
	_tmp0_ = _g_object_ref0 (t);
	_g_object_unref0 (_data4_->t);
	_data4_->t = _tmp0_;
	_tmp1_ = g_idle_source_new ();
	idle = _tmp1_;
	g_source_set_callback (idle, ___lambda262__gsource_func, block4_data_ref (_data4_), block4_data_unref);
	g_source_attach (idle, NULL);
	_g_source_unref0 (idle);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

static void
___lambda261__bird_font_label_tool_delete_action (BirdFontLabelTool* _sender,
                                                  BirdFontLabelTool* _self_,
                                                  gpointer self)
{
	__lambda261_ (self, _self_);
}

void
bird_font_background_tools_add_image (BirdFontBackgroundTools* self,
                                      BirdFontBackgroundImage* image)
{
	Block3Data* _data3_;
	gdouble xc = 0.0;
	gdouble yc = 0.0;
	BirdFontBackgroundTab* bt = NULL;
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	const gchar* _tmp1_;
	BirdFontBackgroundToolsBackgroundSelectionLabel* _tmp2_;
	BirdFontLabelTool* _tmp3_;
	BirdFontLabelTool* _tmp4_;
	BirdFontLabelTool* _tmp5_;
	BirdFontLabelTool* _tmp6_;
	BirdFontLabelTool* _tmp7_;
	BirdFontExpander* _tmp8_;
	BirdFontLabelTool* _tmp9_;
	BirdFontBackgroundTab* _tmp10_;
	BirdFontBackgroundTab* _tmp11_;
	BirdFontBackgroundTab* _tmp12_;
	BirdFontLabelTool* _tmp23_;
	BirdFontBackgroundTab* _tmp24_;
	BirdFontBackgroundTab* _tmp25_;
	gdouble _tmp26_;
	gdouble _tmp27_;
	gdouble _tmp28_;
	gdouble _tmp29_;
	BirdFontFont* _tmp30_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (image != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	_g_object_unref0 (font);
	font = _tmp0_;
	_tmp1_ = image->name;
	_tmp2_ = bird_font_background_tools_background_selection_label_new (image, _tmp1_);
	_g_object_unref0 (_data3_->image_selection);
	_data3_->image_selection = (BirdFontLabelTool*) _tmp2_;
	_tmp3_ = _data3_->image_selection;
	g_signal_connect_object ((BirdFontTool*) _tmp3_, "select-action", (GCallback) ___lambda260__bird_font_tool_select_action, self, 0);
	_tmp4_ = _data3_->image_selection;
	_tmp5_ = _data3_->image_selection;
	g_signal_emit_by_name ((BirdFontTool*) _tmp4_, "select-action", (BirdFontTool*) G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel));
	_tmp6_ = _data3_->image_selection;
	g_signal_connect_data (_tmp6_, "delete-action", (GCallback) ___lambda261__bird_font_label_tool_delete_action, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	_tmp7_ = _data3_->image_selection;
	bird_font_label_tool_set_has_delete_button (_tmp7_, TRUE);
	_tmp8_ = self->priv->files;
	_tmp9_ = _data3_->image_selection;
	bird_font_expander_add_tool (_tmp8_, (BirdFontTool*) _tmp9_, -1);
	_tmp10_ = bird_font_background_tab_get_instance ();
	_g_object_unref0 (bt);
	bt = _tmp10_;
	_tmp11_ = bt;
	bird_font_glyph_set_background_image ((BirdFontGlyph*) _tmp11_, image);
	_tmp12_ = bt;
	bird_font_glyph_set_background_visible ((BirdFontGlyph*) _tmp12_, TRUE);
	bird_font_zoom_tool_zoom_full_background_image ();
	{
		GeeArrayList* _t_list = NULL;
		BirdFontExpander* _tmp13_;
		GeeArrayList* _tmp14_;
		gint _t_size = 0;
		GeeArrayList* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		gint _t_index = 0;
		_tmp13_ = self->priv->files;
		_tmp14_ = _tmp13_->tool;
		_t_list = _tmp14_;
		_tmp15_ = _t_list;
		_tmp16_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp15_);
		_tmp17_ = _tmp16_;
		_t_size = _tmp17_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp18_;
			gint _tmp19_;
			BirdFontTool* t = NULL;
			GeeArrayList* _tmp20_;
			gpointer _tmp21_;
			BirdFontTool* _tmp22_;
			_t_index = _t_index + 1;
			_tmp18_ = _t_index;
			_tmp19_ = _t_size;
			if (!(_tmp18_ < _tmp19_)) {
				break;
			}
			_tmp20_ = _t_list;
			_tmp21_ = gee_abstract_list_get ((GeeAbstractList*) _tmp20_, _t_index);
			t = (BirdFontTool*) _tmp21_;
			_tmp22_ = t;
			bird_font_tool_set_selected (_tmp22_, FALSE);
			_g_object_unref0 (t);
		}
	}
	_tmp23_ = _data3_->image_selection;
	bird_font_tool_set_selected ((BirdFontTool*) _tmp23_, TRUE);
	_tmp24_ = bt;
	bird_font_glyph_set_background_image ((BirdFontGlyph*) _tmp24_, image);
	_tmp25_ = bt;
	bird_font_glyph_set_background_visible ((BirdFontGlyph*) _tmp25_, TRUE);
	_tmp26_ = bird_font_background_image_get_img_middle_x (image);
	_tmp27_ = _tmp26_;
	xc = _tmp27_;
	_tmp28_ = bird_font_background_image_get_img_middle_y (image);
	_tmp29_ = _tmp28_;
	yc = _tmp29_;
	bird_font_background_image_set_img_scale (image, 0.2, 0.2);
	bird_font_background_image_set_img_middle_x (image, xc);
	bird_font_background_image_set_img_middle_y (image, yc);
	bird_font_background_image_center_in_glyph (image, NULL);
	bird_font_zoom_tool_zoom_full_background_image ();
	_tmp30_ = font;
	bird_font_font_add_background_image (_tmp30_, image);
	_g_object_unref0 (font);
	_g_object_unref0 (bt);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

static GeeArrayList*
bird_font_background_tools_real_get_displays (BirdFontToolCollection* base)
{
	BirdFontBackgroundTools * self;
	GeeArrayList* d = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* result;
	self = (BirdFontBackgroundTools*) base;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	d = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) d, "Backgrounds");
	result = d;
	return result;
}

static BirdFontBackgroundToolsBackgroundSelectionLabel*
bird_font_background_tools_background_selection_label_construct (GType object_type,
                                                                 BirdFontBackgroundImage* img,
                                                                 const gchar* base_name)
{
	BirdFontBackgroundToolsBackgroundSelectionLabel * self = NULL;
	BirdFontBackgroundImage* _tmp0_;
	g_return_val_if_fail (img != NULL, NULL);
	g_return_val_if_fail (base_name != NULL, NULL);
	self = (BirdFontBackgroundToolsBackgroundSelectionLabel*) bird_font_label_tool_construct (object_type, base_name);
	_tmp0_ = _g_object_ref0 (img);
	_g_object_unref0 (self->img);
	self->img = _tmp0_;
	self->deleted = FALSE;
	return self;
}

static BirdFontBackgroundToolsBackgroundSelectionLabel*
bird_font_background_tools_background_selection_label_new (BirdFontBackgroundImage* img,
                                                           const gchar* base_name)
{
	return bird_font_background_tools_background_selection_label_construct (BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, img, base_name);
}

static void
bird_font_background_tools_background_selection_label_class_init (BirdFontBackgroundToolsBackgroundSelectionLabelClass * klass,
                                                                  gpointer klass_data)
{
	bird_font_background_tools_background_selection_label_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_background_tools_background_selection_label_finalize;
}

static void
bird_font_background_tools_background_selection_label_instance_init (BirdFontBackgroundToolsBackgroundSelectionLabel * self,
                                                                     gpointer klass)
{
}

static void
bird_font_background_tools_background_selection_label_finalize (GObject * obj)
{
	BirdFontBackgroundToolsBackgroundSelectionLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_SELECTION_LABEL, BirdFontBackgroundToolsBackgroundSelectionLabel);
	_g_object_unref0 (self->img);
	G_OBJECT_CLASS (bird_font_background_tools_background_selection_label_parent_class)->finalize (obj);
}

static GType
bird_font_background_tools_background_selection_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBackgroundToolsBackgroundSelectionLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_background_tools_background_selection_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBackgroundToolsBackgroundSelectionLabel), 0, (GInstanceInitFunc) bird_font_background_tools_background_selection_label_instance_init, NULL };
	GType bird_font_background_tools_background_selection_label_type_id;
	bird_font_background_tools_background_selection_label_type_id = g_type_register_static (BIRD_FONT_TYPE_LABEL_TOOL, "BirdFontBackgroundToolsBackgroundSelectionLabel", &g_define_type_info, 0);
	return bird_font_background_tools_background_selection_label_type_id;
}

static GType
bird_font_background_tools_background_selection_label_get_type (void)
{
	static volatile gsize bird_font_background_tools_background_selection_label_type_id__once = 0;
	if (g_once_init_enter (&bird_font_background_tools_background_selection_label_type_id__once)) {
		GType bird_font_background_tools_background_selection_label_type_id;
		bird_font_background_tools_background_selection_label_type_id = bird_font_background_tools_background_selection_label_get_type_once ();
		g_once_init_leave (&bird_font_background_tools_background_selection_label_type_id__once, bird_font_background_tools_background_selection_label_type_id);
	}
	return bird_font_background_tools_background_selection_label_type_id__once;
}

static BirdFontBackgroundToolsBackgroundPartLabel*
bird_font_background_tools_background_part_label_construct (GType object_type,
                                                            BirdFontBackgroundSelection* selection,
                                                            const gchar* base_name)
{
	BirdFontBackgroundToolsBackgroundPartLabel * self = NULL;
	BirdFontBackgroundSelection* _tmp0_;
	g_return_val_if_fail (selection != NULL, NULL);
	g_return_val_if_fail (base_name != NULL, NULL);
	self = (BirdFontBackgroundToolsBackgroundPartLabel*) bird_font_label_tool_construct (object_type, base_name);
	_tmp0_ = _g_object_ref0 (selection);
	_g_object_unref0 (self->selection);
	self->selection = _tmp0_;
	self->deleted = FALSE;
	return self;
}

static BirdFontBackgroundToolsBackgroundPartLabel*
bird_font_background_tools_background_part_label_new (BirdFontBackgroundSelection* selection,
                                                      const gchar* base_name)
{
	return bird_font_background_tools_background_part_label_construct (BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, selection, base_name);
}

static void
bird_font_background_tools_background_part_label_class_init (BirdFontBackgroundToolsBackgroundPartLabelClass * klass,
                                                             gpointer klass_data)
{
	bird_font_background_tools_background_part_label_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_background_tools_background_part_label_finalize;
}

static void
bird_font_background_tools_background_part_label_instance_init (BirdFontBackgroundToolsBackgroundPartLabel * self,
                                                                gpointer klass)
{
}

static void
bird_font_background_tools_background_part_label_finalize (GObject * obj)
{
	BirdFontBackgroundToolsBackgroundPartLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_BACKGROUND_TOOLS_TYPE_BACKGROUND_PART_LABEL, BirdFontBackgroundToolsBackgroundPartLabel);
	_g_object_unref0 (self->selection);
	G_OBJECT_CLASS (bird_font_background_tools_background_part_label_parent_class)->finalize (obj);
}

static GType
bird_font_background_tools_background_part_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBackgroundToolsBackgroundPartLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_background_tools_background_part_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBackgroundToolsBackgroundPartLabel), 0, (GInstanceInitFunc) bird_font_background_tools_background_part_label_instance_init, NULL };
	GType bird_font_background_tools_background_part_label_type_id;
	bird_font_background_tools_background_part_label_type_id = g_type_register_static (BIRD_FONT_TYPE_LABEL_TOOL, "BirdFontBackgroundToolsBackgroundPartLabel", &g_define_type_info, 0);
	return bird_font_background_tools_background_part_label_type_id;
}

static GType
bird_font_background_tools_background_part_label_get_type (void)
{
	static volatile gsize bird_font_background_tools_background_part_label_type_id__once = 0;
	if (g_once_init_enter (&bird_font_background_tools_background_part_label_type_id__once)) {
		GType bird_font_background_tools_background_part_label_type_id;
		bird_font_background_tools_background_part_label_type_id = bird_font_background_tools_background_part_label_get_type_once ();
		g_once_init_leave (&bird_font_background_tools_background_part_label_type_id__once, bird_font_background_tools_background_part_label_type_id);
	}
	return bird_font_background_tools_background_part_label_type_id__once;
}

static void
bird_font_background_tools_class_init (BirdFontBackgroundToolsClass * klass,
                                       gpointer klass_data)
{
	bird_font_background_tools_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontBackgroundTools_private_offset);
	((BirdFontToolCollectionClass *) klass)->reset_selection = (void (*) (BirdFontToolCollection*, BirdFontTool*)) bird_font_background_tools_real_reset_selection;
	((BirdFontToolCollectionClass *) klass)->selected = (void (*) (BirdFontToolCollection*)) bird_font_background_tools_real_selected;
	((BirdFontToolCollectionClass *) klass)->get_expanders = (GeeArrayList* (*) (BirdFontToolCollection*)) bird_font_background_tools_real_get_expanders;
	((BirdFontToolCollectionClass *) klass)->get_displays = (GeeArrayList* (*) (BirdFontToolCollection*)) bird_font_background_tools_real_get_displays;
	G_OBJECT_CLASS (klass)->finalize = bird_font_background_tools_finalize;
}

static void
bird_font_background_tools_instance_init (BirdFontBackgroundTools * self,
                                          gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = bird_font_background_tools_get_instance_private (self);
	_tmp0_ = gee_array_list_new (BIRD_FONT_TYPE_EXPANDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->expanders = _tmp0_;
}

static void
bird_font_background_tools_finalize (GObject * obj)
{
	BirdFontBackgroundTools * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_BACKGROUND_TOOLS, BirdFontBackgroundTools);
	_g_object_unref0 (self->select_background);
	_g_object_unref0 (self->priv->files);
	_g_object_unref0 (self->priv->parts);
	_g_object_unref0 (self->expanders);
	G_OBJECT_CLASS (bird_font_background_tools_parent_class)->finalize (obj);
}

static GType
bird_font_background_tools_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBackgroundToolsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_background_tools_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBackgroundTools), 0, (GInstanceInitFunc) bird_font_background_tools_instance_init, NULL };
	GType bird_font_background_tools_type_id;
	bird_font_background_tools_type_id = g_type_register_static (BIRD_FONT_TYPE_TOOL_COLLECTION, "BirdFontBackgroundTools", &g_define_type_info, 0);
	BirdFontBackgroundTools_private_offset = g_type_add_instance_private (bird_font_background_tools_type_id, sizeof (BirdFontBackgroundToolsPrivate));
	return bird_font_background_tools_type_id;
}

GType
bird_font_background_tools_get_type (void)
{
	static volatile gsize bird_font_background_tools_type_id__once = 0;
	if (g_once_init_enter (&bird_font_background_tools_type_id__once)) {
		GType bird_font_background_tools_type_id;
		bird_font_background_tools_type_id = bird_font_background_tools_get_type_once ();
		g_once_init_leave (&bird_font_background_tools_type_id__once, bird_font_background_tools_type_id);
	}
	return bird_font_background_tools_type_id__once;
}

