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

/*
Copyright (C) 2014 2015 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 <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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

#define BIRD_FONT_TYPE_SETTINGS_DISPLAY (bird_font_settings_display_get_type ())
#define BIRD_FONT_SETTINGS_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_SETTINGS_DISPLAY, BirdFontSettingsDisplay))
#define BIRD_FONT_SETTINGS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_SETTINGS_DISPLAY, BirdFontSettingsDisplayClass))
#define BIRD_FONT_IS_SETTINGS_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_SETTINGS_DISPLAY))
#define BIRD_FONT_IS_SETTINGS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_SETTINGS_DISPLAY))
#define BIRD_FONT_SETTINGS_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_SETTINGS_DISPLAY, BirdFontSettingsDisplayClass))

typedef struct _BirdFontSettingsDisplay BirdFontSettingsDisplay;
typedef struct _BirdFontSettingsDisplayClass BirdFontSettingsDisplayClass;
typedef struct _BirdFontSettingsDisplayPrivate BirdFontSettingsDisplayPrivate;

#define BIRD_FONT_TYPE_THEME_TAB (bird_font_theme_tab_get_type ())
#define BIRD_FONT_THEME_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_THEME_TAB, BirdFontThemeTab))
#define BIRD_FONT_THEME_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_THEME_TAB, BirdFontThemeTabClass))
#define BIRD_FONT_IS_THEME_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_THEME_TAB))
#define BIRD_FONT_IS_THEME_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_THEME_TAB))
#define BIRD_FONT_THEME_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_THEME_TAB, BirdFontThemeTabClass))

typedef struct _BirdFontThemeTab BirdFontThemeTab;
typedef struct _BirdFontThemeTabClass BirdFontThemeTabClass;
typedef struct _BirdFontThemeTabPrivate BirdFontThemeTabPrivate;
enum  {
	BIRD_FONT_THEME_TAB_0_PROPERTY,
	BIRD_FONT_THEME_TAB_NUM_PROPERTIES
};
static GParamSpec* bird_font_theme_tab_properties[BIRD_FONT_THEME_TAB_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block69Data Block69Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _BirdFontSettingsDisplay {
	BirdFontFontDisplay parent_instance;
	BirdFontSettingsDisplayPrivate * priv;
	GeeArrayList* tools;
};

struct _BirdFontSettingsDisplayClass {
	BirdFontFontDisplayClass parent_class;
	void (*create_setting_items) (BirdFontSettingsDisplay* self);
};

struct _BirdFontThemeTab {
	BirdFontSettingsDisplay parent_instance;
	BirdFontThemeTabPrivate * priv;
};

struct _BirdFontThemeTabClass {
	BirdFontSettingsDisplayClass parent_class;
};

struct _BirdFontThemeTabPrivate {
	BirdFontColorTool* color_tool;
};

struct _Block69Data {
	int _ref_count_;
	BirdFontThemeTab* self;
	GeeArrayList* theme_buttons;
};

static gint BirdFontThemeTab_private_offset;
static gpointer bird_font_theme_tab_parent_class = NULL;
static BirdFontThemeTab* bird_font_theme_tab_singleton;
static BirdFontThemeTab* bird_font_theme_tab_singleton = NULL;

VALA_EXTERN GType bird_font_settings_display_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType bird_font_theme_tab_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void bird_font_settings_display_create_setting_items (BirdFontSettingsDisplay* self);
VALA_EXTERN BirdFontThemeTab* bird_font_theme_tab_new (void);
VALA_EXTERN BirdFontThemeTab* bird_font_theme_tab_construct (GType object_type);
VALA_EXTERN BirdFontSettingsDisplay* bird_font_settings_display_construct (GType object_type);
VALA_EXTERN BirdFontThemeTab* bird_font_theme_tab_get_instance (void);
VALA_EXTERN void bird_font_theme_tab_color_updated (BirdFontThemeTab* self,
                                        BirdFontColor* c);
static void bird_font_theme_tab_real_create_setting_items (BirdFontSettingsDisplay* base);
static Block69Data* block69_data_ref (Block69Data* _data69_);
static void block69_data_unref (void * _userdata_);
static void ____lambda272_ (BirdFontThemeTab* self,
                     BirdFontTool* _self_);
static void _____lambda272__bird_font_tool_deselect_action (BirdFontTool* _sender,
                                                     BirdFontTool* selected,
                                                     gpointer self);
static void ____lambda273_ (Block69Data* _data69_,
                     BirdFontTool* _self_);
VALA_EXTERN void bird_font_theme_tab_redraw_ui (void);
static void _____lambda273__bird_font_tool_select_action (BirdFontTool* _sender,
                                                   BirdFontTool* selected,
                                                   gpointer self);
VALA_EXTERN gchar* bird_font_theme_tab_get_label_from_file_name (const gchar* theme);
static void __lambda274_ (Block69Data* _data69_,
                   BirdFontTool* _self_);
VALA_EXTERN void bird_font_theme_add_new_theme (BirdFontSettingsDisplay* d);
static void ___lambda274__bird_font_tool_select_action (BirdFontTool* _sender,
                                                 BirdFontTool* selected,
                                                 gpointer self);
static void ____lambda276_ (BirdFontThemeTab* self,
                     BirdFontTool* _self_);
static void _____lambda276__bird_font_tool_select_action (BirdFontTool* _sender,
                                                   BirdFontTool* selected,
                                                   gpointer self);
static void ____lambda277_ (BirdFontThemeTab* self,
                     BirdFontTool* _self_);
static void _____lambda277__bird_font_tool_deselect_action (BirdFontTool* _sender,
                                                     BirdFontTool* selected,
                                                     gpointer self);
static void ____lambda278_ (BirdFontThemeTab* self);
static void _____lambda278__bird_font_color_tool_color_updated (BirdFontColorTool* _sender,
                                                         gpointer self);
static gchar* bird_font_theme_tab_real_get_label (BirdFontFontDisplay* base);
static gchar* bird_font_theme_tab_real_get_name (BirdFontFontDisplay* base);
static void bird_font_theme_tab_finalize (GObject * obj);
static GType bird_font_theme_tab_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_theme_tab_get_instance_private (BirdFontThemeTab* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontThemeTab_private_offset);
}

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

BirdFontThemeTab*
bird_font_theme_tab_construct (GType object_type)
{
	BirdFontThemeTab * self = NULL;
	BirdFontColorTool* _tmp0_;
	BirdFontThemeTab* _tmp1_;
	self = (BirdFontThemeTab*) bird_font_settings_display_construct (object_type);
	_tmp0_ = bird_font_color_tool_new ("");
	_g_object_unref0 (self->priv->color_tool);
	self->priv->color_tool = _tmp0_;
	_tmp1_ = _g_object_ref0 (self);
	_g_object_unref0 (bird_font_theme_tab_singleton);
	bird_font_theme_tab_singleton = _tmp1_;
	bird_font_settings_display_create_setting_items ((BirdFontSettingsDisplay*) self);
	return self;
}

BirdFontThemeTab*
bird_font_theme_tab_new (void)
{
	return bird_font_theme_tab_construct (BIRD_FONT_TYPE_THEME_TAB);
}

BirdFontThemeTab*
bird_font_theme_tab_get_instance (void)
{
	BirdFontThemeTab* _tmp0_;
	BirdFontThemeTab* _tmp1_;
	BirdFontThemeTab* result;
	_tmp0_ = bird_font_theme_tab_singleton;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
bird_font_theme_tab_color_updated (BirdFontThemeTab* self,
                                   BirdFontColor* c)
{
	BirdFontColorTool* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (c != NULL);
	_tmp0_ = self->priv->color_tool;
	bird_font_color_tool_set_color (_tmp0_, c);
}

static Block69Data*
block69_data_ref (Block69Data* _data69_)
{
	g_atomic_int_inc (&_data69_->_ref_count_);
	return _data69_;
}

static void
block69_data_unref (void * _userdata_)
{
	Block69Data* _data69_;
	_data69_ = (Block69Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data69_->_ref_count_)) {
		BirdFontThemeTab* self;
		self = _data69_->self;
		_g_object_unref0 (_data69_->theme_buttons);
		_g_object_unref0 (self);
		g_slice_free (Block69Data, _data69_);
	}
}

static void
____lambda272_ (BirdFontThemeTab* self,
                BirdFontTool* _self_)
{
	g_return_if_fail (_self_ != NULL);
	bird_font_tool_set_active (_self_, FALSE);
}

static void
_____lambda272__bird_font_tool_deselect_action (BirdFontTool* _sender,
                                                BirdFontTool* selected,
                                                gpointer self)
{
	____lambda272_ ((BirdFontThemeTab*) self, selected);
}

static void
____lambda273_ (Block69Data* _data69_,
                BirdFontTool* _self_)
{
	BirdFontThemeTab* self;
	gchar* theme_file = NULL;
	gchar* _tmp0_;
	BirdFontToolbox* toolbox = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	BirdFontToolbox* _tmp13_;
	self = _data69_->self;
	g_return_if_fail (_self_ != NULL);
	_tmp0_ = bird_font_tool_get_name (_self_);
	theme_file = _tmp0_;
	_tmp1_ = theme_file;
	bird_font_preferences_set ("theme", _tmp1_);
	_tmp2_ = theme_file;
	bird_font_theme_load_theme (_tmp2_);
	{
		GeeArrayList* _t_list = NULL;
		GeeArrayList* _tmp3_;
		gint _t_size = 0;
		GeeArrayList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _t_index = 0;
		_tmp3_ = _data69_->theme_buttons;
		_t_list = _tmp3_;
		_tmp4_ = _t_list;
		_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_t_size = _tmp6_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			BirdFontTool* t = NULL;
			GeeArrayList* _tmp9_;
			gpointer _tmp10_;
			BirdFontTool* _tmp11_;
			BirdFontTool* _tmp12_;
			_t_index = _t_index + 1;
			_tmp7_ = _t_index;
			_tmp8_ = _t_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _t_list;
			_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _t_index);
			t = (BirdFontTool*) _tmp10_;
			_tmp11_ = t;
			bird_font_tool_set_selected (_tmp11_, FALSE);
			_tmp12_ = t;
			bird_font_tool_set_active (_tmp12_, FALSE);
			_g_object_unref0 (t);
		}
	}
	bird_font_tool_set_selected (_self_, TRUE);
	bird_font_settings_display_create_setting_items ((BirdFontSettingsDisplay*) self);
	_tmp13_ = bird_font_main_window_get_toolbox ();
	_g_object_unref0 (toolbox);
	toolbox = _tmp13_;
	{
		GeeArrayList* _tc_list = NULL;
		BirdFontToolbox* _tmp14_;
		GeeArrayList* _tmp15_;
		gint _tc_size = 0;
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gint _tc_index = 0;
		_tmp14_ = toolbox;
		_tmp15_ = _tmp14_->tool_sets;
		_tc_list = _tmp15_;
		_tmp16_ = _tc_list;
		_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_tc_size = _tmp18_;
		_tc_index = -1;
		while (TRUE) {
			gint _tmp19_;
			gint _tmp20_;
			BirdFontToolCollection* tc = NULL;
			GeeArrayList* _tmp21_;
			gpointer _tmp22_;
			BirdFontToolCollection* _tmp23_;
			_tc_index = _tc_index + 1;
			_tmp19_ = _tc_index;
			_tmp20_ = _tc_size;
			if (!(_tmp19_ < _tmp20_)) {
				break;
			}
			_tmp21_ = _tc_list;
			_tmp22_ = gee_abstract_list_get ((GeeAbstractList*) _tmp21_, _tc_index);
			tc = (BirdFontToolCollection*) _tmp22_;
			_tmp23_ = tc;
			bird_font_tool_collection_redraw (_tmp23_);
			_g_object_unref0 (tc);
		}
	}
	{
		GeeArrayList* _e_list = NULL;
		BirdFontToolCollection* _tmp24_;
		GeeArrayList* _tmp25_;
		gint _e_size = 0;
		GeeArrayList* _tmp26_;
		gint _tmp27_;
		gint _tmp28_;
		gint _e_index = 0;
		_tmp24_ = bird_font_toolbox_current_set;
		_tmp25_ = bird_font_tool_collection_get_expanders (_tmp24_);
		_e_list = _tmp25_;
		_tmp26_ = _e_list;
		_tmp27_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp26_);
		_tmp28_ = _tmp27_;
		_e_size = _tmp28_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp29_;
			gint _tmp30_;
			BirdFontExpander* e = NULL;
			GeeArrayList* _tmp31_;
			gpointer _tmp32_;
			BirdFontExpander* _tmp33_;
			_e_index = _e_index + 1;
			_tmp29_ = _e_index;
			_tmp30_ = _e_size;
			if (!(_tmp29_ < _tmp30_)) {
				break;
			}
			_tmp31_ = _e_list;
			_tmp32_ = gee_abstract_list_get ((GeeAbstractList*) _tmp31_, _e_index);
			e = (BirdFontExpander*) _tmp32_;
			_tmp33_ = e;
			bird_font_expander_redraw (_tmp33_);
			_g_object_unref0 (e);
		}
		_g_object_unref0 (_e_list);
	}
	bird_font_theme_tab_redraw_ui ();
	_g_object_unref0 (toolbox);
	_g_free0 (theme_file);
}

static void
_____lambda273__bird_font_tool_select_action (BirdFontTool* _sender,
                                              BirdFontTool* selected,
                                              gpointer self)
{
	____lambda273_ (self, selected);
}

static void
__lambda274_ (Block69Data* _data69_,
              BirdFontTool* _self_)
{
	BirdFontThemeTab* self;
	self = _data69_->self;
	g_return_if_fail (_self_ != NULL);
	{
		GeeArrayList* _t_list = NULL;
		GeeArrayList* _tmp0_;
		gint _t_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _t_index = 0;
		_tmp0_ = _data69_->theme_buttons;
		_t_list = _tmp0_;
		_tmp1_ = _t_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_t_size = _tmp3_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontTool* t = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontTool* _tmp8_;
			_t_index = _t_index + 1;
			_tmp4_ = _t_index;
			_tmp5_ = _t_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _t_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _t_index);
			t = (BirdFontTool*) _tmp7_;
			_tmp8_ = t;
			bird_font_tool_set_selected (_tmp8_, FALSE);
			_g_object_unref0 (t);
		}
	}
	bird_font_tool_set_selected (_self_, FALSE);
	bird_font_theme_add_new_theme ((BirdFontSettingsDisplay*) self);
	bird_font_glyph_canvas_redraw ();
}

static void
___lambda274__bird_font_tool_select_action (BirdFontTool* _sender,
                                            BirdFontTool* selected,
                                            gpointer self)
{
	__lambda274_ (self, selected);
}

static void
____lambda276_ (BirdFontThemeTab* self,
                BirdFontTool* _self_)
{
	BirdFontColorTool* _tmp0_;
	g_return_if_fail (_self_ != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_self_, BIRD_FONT_TYPE_COLOR_TOOL, BirdFontColorTool));
	_g_object_unref0 (self->priv->color_tool);
	self->priv->color_tool = _tmp0_;
}

static void
_____lambda276__bird_font_tool_select_action (BirdFontTool* _sender,
                                              BirdFontTool* selected,
                                              gpointer self)
{
	____lambda276_ ((BirdFontThemeTab*) self, selected);
}

static void
____lambda277_ (BirdFontThemeTab* self,
                BirdFontTool* _self_)
{
	BirdFontColorTool* _tmp0_;
	g_return_if_fail (_self_ != NULL);
	_tmp0_ = bird_font_color_tool_new ("");
	_g_object_unref0 (self->priv->color_tool);
	self->priv->color_tool = _tmp0_;
}

static void
_____lambda277__bird_font_tool_deselect_action (BirdFontTool* _sender,
                                                BirdFontTool* selected,
                                                gpointer self)
{
	____lambda277_ ((BirdFontThemeTab*) self, selected);
}

static void
____lambda278_ (BirdFontThemeTab* self)
{
	bird_font_settings_display_create_setting_items ((BirdFontSettingsDisplay*) self);
	bird_font_glyph_canvas_redraw ();
}

static void
_____lambda278__bird_font_color_tool_color_updated (BirdFontColorTool* _sender,
                                                    gpointer self)
{
	____lambda278_ ((BirdFontThemeTab*) self);
}

static void
bird_font_theme_tab_real_create_setting_items (BirdFontSettingsDisplay* base)
{
	BirdFontThemeTab * self;
	Block69Data* _data69_;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	BirdFontSettingsItem* _tmp4_;
	BirdFontSettingsItem* _tmp5_;
	GeeArrayList* _tmp6_;
	BirdFontTool* add_theme = NULL;
	BirdFontTool* _tmp47_;
	BirdFontTool* _tmp48_;
	GeeArrayList* _tmp49_;
	BirdFontTool* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	BirdFontSettingsItem* _tmp53_;
	BirdFontSettingsItem* _tmp54_;
	GeeArrayList* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	BirdFontSettingsItem* _tmp58_;
	BirdFontSettingsItem* _tmp59_;
	self = (BirdFontThemeTab*) base;
	_data69_ = g_slice_new0 (Block69Data);
	_data69_->_ref_count_ = 1;
	_data69_->self = g_object_ref (self);
	_tmp0_ = ((BirdFontSettingsDisplay*) self)->tools;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
	_tmp1_ = ((BirdFontSettingsDisplay*) self)->tools;
	_tmp2_ = bird_font_t_ ("Themes");
	_tmp3_ = _tmp2_;
	_tmp4_ = bird_font_settings_item_new_head_line (_tmp3_);
	_tmp5_ = _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_free0 (_tmp3_);
	_tmp6_ = gee_array_list_new (BIRD_FONT_TYPE_TOOL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data69_->theme_buttons = _tmp6_;
	{
		GeeArrayList* _theme_list = NULL;
		GeeArrayList* _tmp7_;
		gint _theme_size = 0;
		GeeArrayList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		gint _theme_index = 0;
		_tmp7_ = bird_font_theme_themes;
		_theme_list = _tmp7_;
		_tmp8_ = _theme_list;
		_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		_theme_size = _tmp10_;
		_theme_index = -1;
		while (TRUE) {
			gint _tmp11_;
			gint _tmp12_;
			gchar* theme = NULL;
			GeeArrayList* _tmp13_;
			gpointer _tmp14_;
			gchar* label = NULL;
			BirdFontTool* select_theme = NULL;
			const gchar* _tmp15_;
			BirdFontTool* _tmp16_;
			BirdFontTool* _tmp17_;
			BirdFontTool* _tmp18_;
			BirdFontTool* _tmp19_;
			const gchar* _tmp20_;
			gchar* _tmp21_;
			GeeArrayList* _tmp22_;
			BirdFontTool* _tmp23_;
			const gchar* _tmp24_;
			BirdFontSettingsItem* _tmp25_;
			BirdFontSettingsItem* _tmp26_;
			GeeArrayList* _tmp27_;
			BirdFontTool* _tmp28_;
			BirdFontTool* _tmp29_;
			gchar* _tmp30_;
			gchar* _tmp31_;
			const gchar* _tmp32_;
			gboolean _tmp33_;
			_theme_index = _theme_index + 1;
			_tmp11_ = _theme_index;
			_tmp12_ = _theme_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _theme_list;
			_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, _theme_index);
			theme = (gchar*) _tmp14_;
			_tmp15_ = theme;
			_tmp16_ = bird_font_tool_new (_tmp15_, "");
			select_theme = _tmp16_;
			_tmp17_ = select_theme;
			g_signal_connect_object (_tmp17_, "deselect-action", (GCallback) _____lambda272__bird_font_tool_deselect_action, self, 0);
			_tmp18_ = select_theme;
			g_signal_connect_data (_tmp18_, "select-action", (GCallback) _____lambda273__bird_font_tool_select_action, block69_data_ref (_data69_), (GClosureNotify) block69_data_unref, 0);
			_tmp19_ = select_theme;
			bird_font_tool_set_icon (_tmp19_, "theme");
			_tmp20_ = theme;
			_tmp21_ = bird_font_theme_tab_get_label_from_file_name (_tmp20_);
			_g_free0 (label);
			label = _tmp21_;
			_tmp22_ = ((BirdFontSettingsDisplay*) self)->tools;
			_tmp23_ = select_theme;
			_tmp24_ = label;
			_tmp25_ = bird_font_settings_item_new (_tmp23_, _tmp24_);
			_tmp26_ = _tmp25_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp22_, _tmp26_);
			_g_object_unref0 (_tmp26_);
			_tmp27_ = _data69_->theme_buttons;
			_tmp28_ = select_theme;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp27_, _tmp28_);
			_tmp29_ = select_theme;
			_tmp30_ = bird_font_tool_get_name (_tmp29_);
			_tmp31_ = _tmp30_;
			_tmp32_ = bird_font_theme_current_theme;
			_tmp33_ = g_strcmp0 (_tmp31_, _tmp32_) == 0;
			_g_free0 (_tmp31_);
			if (_tmp33_) {
				BirdFontTool* _tmp34_;
				_tmp34_ = select_theme;
				bird_font_tool_set_selected (_tmp34_, TRUE);
			}
			_g_object_unref0 (select_theme);
			_g_free0 (label);
			_g_free0 (theme);
		}
	}
	{
		GeeArrayList* _t_list = NULL;
		GeeArrayList* _tmp35_;
		gint _t_size = 0;
		GeeArrayList* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gint _t_index = 0;
		_tmp35_ = _data69_->theme_buttons;
		_t_list = _tmp35_;
		_tmp36_ = _t_list;
		_tmp37_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp36_);
		_tmp38_ = _tmp37_;
		_t_size = _tmp38_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp39_;
			gint _tmp40_;
			BirdFontTool* t = NULL;
			GeeArrayList* _tmp41_;
			gpointer _tmp42_;
			BirdFontTool* _tmp43_;
			BirdFontTool* _tmp44_;
			const gchar* _tmp45_;
			const gchar* _tmp46_;
			_t_index = _t_index + 1;
			_tmp39_ = _t_index;
			_tmp40_ = _t_size;
			if (!(_tmp39_ < _tmp40_)) {
				break;
			}
			_tmp41_ = _t_list;
			_tmp42_ = gee_abstract_list_get ((GeeAbstractList*) _tmp41_, _t_index);
			t = (BirdFontTool*) _tmp42_;
			_tmp43_ = t;
			_tmp44_ = t;
			_tmp45_ = _tmp44_->name;
			_tmp46_ = bird_font_theme_current_theme;
			bird_font_tool_set_selected (_tmp43_, g_strcmp0 (_tmp45_, _tmp46_) == 0);
			_g_object_unref0 (t);
		}
	}
	_tmp47_ = bird_font_tool_new ("add_new_theme", "");
	add_theme = _tmp47_;
	_tmp48_ = add_theme;
	g_signal_connect_data (_tmp48_, "select-action", (GCallback) ___lambda274__bird_font_tool_select_action, block69_data_ref (_data69_), (GClosureNotify) block69_data_unref, 0);
	_tmp49_ = ((BirdFontSettingsDisplay*) self)->tools;
	_tmp50_ = add_theme;
	_tmp51_ = bird_font_t_ ("Add new theme");
	_tmp52_ = _tmp51_;
	_tmp53_ = bird_font_settings_item_new (_tmp50_, _tmp52_);
	_tmp54_ = _tmp53_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp49_, _tmp54_);
	_g_object_unref0 (_tmp54_);
	_g_free0 (_tmp52_);
	_tmp55_ = ((BirdFontSettingsDisplay*) self)->tools;
	_tmp56_ = bird_font_t_ ("Colors");
	_tmp57_ = _tmp56_;
	_tmp58_ = bird_font_settings_item_new_head_line (_tmp57_);
	_tmp59_ = _tmp58_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp55_, _tmp59_);
	_g_object_unref0 (_tmp59_);
	_g_free0 (_tmp57_);
	{
		GeeArrayList* _color_list = NULL;
		GeeArrayList* _tmp60_;
		gint _color_size = 0;
		GeeArrayList* _tmp61_;
		gint _tmp62_;
		gint _tmp63_;
		gint _color_index = 0;
		_tmp60_ = bird_font_theme_color_list;
		_color_list = _tmp60_;
		_tmp61_ = _color_list;
		_tmp62_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp61_);
		_tmp63_ = _tmp62_;
		_color_size = _tmp63_;
		_color_index = -1;
		while (TRUE) {
			gint _tmp64_;
			gint _tmp65_;
			gchar* color = NULL;
			GeeArrayList* _tmp66_;
			gpointer _tmp67_;
			BirdFontSettingsItem* s = NULL;
			const gchar* _tmp68_;
			BirdFontSettingsItem* _tmp69_;
			BirdFontColorTool* c = NULL;
			BirdFontSettingsItem* _tmp70_;
			BirdFontTool* _tmp71_;
			BirdFontColorTool* _tmp72_;
			GeeArrayList* _tmp73_;
			BirdFontSettingsItem* _tmp74_;
			BirdFontColorTool* _tmp75_;
			BirdFontColorTool* _tmp76_;
			BirdFontColorTool* _tmp77_;
			_color_index = _color_index + 1;
			_tmp64_ = _color_index;
			_tmp65_ = _color_size;
			if (!(_tmp64_ < _tmp65_)) {
				break;
			}
			_tmp66_ = _color_list;
			_tmp67_ = gee_abstract_list_get ((GeeAbstractList*) _tmp66_, _color_index);
			color = (gchar*) _tmp67_;
			_tmp68_ = color;
			_tmp69_ = bird_font_settings_item_new_color (_tmp68_);
			s = _tmp69_;
			_tmp70_ = s;
			_tmp71_ = _tmp70_->button;
			_tmp72_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (_tmp71_, BIRD_FONT_TYPE_TOOL, BirdFontTool), BIRD_FONT_TYPE_COLOR_TOOL, BirdFontColorTool));
			c = _tmp72_;
			_tmp73_ = ((BirdFontSettingsDisplay*) self)->tools;
			_tmp74_ = s;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp73_, _tmp74_);
			_tmp75_ = c;
			g_signal_connect_object ((BirdFontTool*) _tmp75_, "select-action", (GCallback) _____lambda276__bird_font_tool_select_action, self, 0);
			_tmp76_ = c;
			g_signal_connect_object ((BirdFontTool*) _tmp76_, "deselect-action", (GCallback) _____lambda277__bird_font_tool_deselect_action, self, 0);
			_tmp77_ = c;
			g_signal_connect_object (_tmp77_, "color-updated", (GCallback) _____lambda278__bird_font_color_tool_color_updated, self, 0);
			_g_object_unref0 (c);
			_g_object_unref0 (s);
			_g_free0 (color);
		}
	}
	_g_object_unref0 (add_theme);
	block69_data_unref (_data69_);
	_data69_ = NULL;
}

void
bird_font_theme_tab_redraw_ui (void)
{
	BirdFontTabBar* tb = NULL;
	BirdFontTabBar* _tmp0_;
	bird_font_toolbox_redraw_tool_box ();
	bird_font_glyph_canvas_redraw ();
	_tmp0_ = bird_font_main_window_get_tab_bar ();
	_g_object_unref0 (tb);
	tb = _tmp0_;
	bird_font_tab_bar_redraw (tb, 0, 0, tb->width, tb->height);
	_cairo_surface_destroy0 (bird_font_overview_item_label_background);
	bird_font_overview_item_label_background = NULL;
	_cairo_surface_destroy0 (bird_font_overview_item_selected_label_background);
	bird_font_overview_item_selected_label_background = NULL;
	_cairo_surface_destroy0 (bird_font_overview_item_label_background_no_menu);
	bird_font_overview_item_label_background_no_menu = NULL;
	_cairo_surface_destroy0 (bird_font_overview_item_selected_label_background_no_menu);
	bird_font_overview_item_selected_label_background_no_menu = NULL;
	_g_object_unref0 (tb);
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

gchar*
bird_font_theme_tab_get_label_from_file_name (const gchar* theme)
{
	gchar* label = NULL;
	gchar* result;
	g_return_val_if_fail (theme != NULL, NULL);
	if (g_strcmp0 (theme, "dark.theme") == 0) {
		gchar* _tmp0_;
		_tmp0_ = bird_font_t_ ("Dark");
		_g_free0 (label);
		label = _tmp0_;
	} else {
		if (g_strcmp0 (theme, "bright.theme") == 0) {
			gchar* _tmp1_;
			_tmp1_ = bird_font_t_ ("Bright");
			_g_free0 (label);
			label = _tmp1_;
		} else {
			if (g_strcmp0 (theme, "high_contrast.theme") == 0) {
				gchar* _tmp2_;
				_tmp2_ = bird_font_t_ ("High contrast");
				_g_free0 (label);
				label = _tmp2_;
			} else {
				if (g_strcmp0 (theme, "custom.theme") == 0) {
					gchar* _tmp3_;
					_tmp3_ = bird_font_t_ ("Custom");
					_g_free0 (label);
					label = _tmp3_;
				} else {
					gchar* _tmp4_;
					_tmp4_ = string_replace (theme, ".theme", "");
					_g_free0 (label);
					label = _tmp4_;
				}
			}
		}
	}
	result = label;
	return result;
}

static gchar*
bird_font_theme_tab_real_get_label (BirdFontFontDisplay* base)
{
	BirdFontThemeTab * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontThemeTab*) base;
	_tmp0_ = bird_font_t_ ("Themes");
	result = _tmp0_;
	return result;
}

static gchar*
bird_font_theme_tab_real_get_name (BirdFontFontDisplay* base)
{
	BirdFontThemeTab * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontThemeTab*) base;
	_tmp0_ = g_strdup ("Themes");
	result = _tmp0_;
	return result;
}

static void
bird_font_theme_tab_class_init (BirdFontThemeTabClass * klass,
                                gpointer klass_data)
{
	bird_font_theme_tab_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontThemeTab_private_offset);
	((BirdFontSettingsDisplayClass *) klass)->create_setting_items = (void (*) (BirdFontSettingsDisplay*)) bird_font_theme_tab_real_create_setting_items;
	((BirdFontFontDisplayClass *) klass)->get_label = (gchar* (*) (BirdFontFontDisplay*)) bird_font_theme_tab_real_get_label;
	((BirdFontFontDisplayClass *) klass)->get_name = (gchar* (*) (BirdFontFontDisplay*)) bird_font_theme_tab_real_get_name;
	G_OBJECT_CLASS (klass)->finalize = bird_font_theme_tab_finalize;
}

static void
bird_font_theme_tab_instance_init (BirdFontThemeTab * self,
                                   gpointer klass)
{
	self->priv = bird_font_theme_tab_get_instance_private (self);
}

static void
bird_font_theme_tab_finalize (GObject * obj)
{
	BirdFontThemeTab * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_THEME_TAB, BirdFontThemeTab);
	_g_object_unref0 (self->priv->color_tool);
	G_OBJECT_CLASS (bird_font_theme_tab_parent_class)->finalize (obj);
}

static GType
bird_font_theme_tab_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontThemeTabClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_theme_tab_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontThemeTab), 0, (GInstanceInitFunc) bird_font_theme_tab_instance_init, NULL };
	GType bird_font_theme_tab_type_id;
	bird_font_theme_tab_type_id = g_type_register_static (BIRD_FONT_TYPE_SETTINGS_DISPLAY, "BirdFontThemeTab", &g_define_type_info, 0);
	BirdFontThemeTab_private_offset = g_type_add_instance_private (bird_font_theme_tab_type_id, sizeof (BirdFontThemeTabPrivate));
	return bird_font_theme_tab_type_id;
}

GType
bird_font_theme_tab_get_type (void)
{
	static volatile gsize bird_font_theme_tab_type_id__once = 0;
	if (g_once_init_enter (&bird_font_theme_tab_type_id__once)) {
		GType bird_font_theme_tab_type_id;
		bird_font_theme_tab_type_id = bird_font_theme_tab_get_type_once ();
		g_once_init_leave (&bird_font_theme_tab_type_id__once, bird_font_theme_tab_type_id);
	}
	return bird_font_theme_tab_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

