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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <granite-7.h>
#include <gdk/gdk.h>

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

#define TYPE_THEME_EDITOR (theme_editor_get_type ())
#define THEME_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME_EDITOR, ThemeEditor))
#define THEME_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME_EDITOR, ThemeEditorClass))
#define IS_THEME_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME_EDITOR))
#define IS_THEME_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME_EDITOR))
#define THEME_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME_EDITOR, ThemeEditorClass))

typedef struct _ThemeEditor ThemeEditor;
typedef struct _ThemeEditorClass ThemeEditorClass;
typedef struct _ThemeEditorPrivate ThemeEditorPrivate;

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;

#define TYPE_THEME (theme_get_type ())
#define THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME, Theme))
#define THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME, ThemeClass))
#define IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME))
#define IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME))
#define THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME, ThemeClass))

typedef struct _Theme Theme;
typedef struct _ThemeClass ThemeClass;
enum  {
	THEME_EDITOR_0_PROPERTY,
	THEME_EDITOR_NUM_PROPERTIES
};
static GParamSpec* theme_editor_properties[THEME_EDITOR_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 TYPE_THEMES (themes_get_type ())
#define THEMES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEMES, Themes))
#define THEMES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEMES, ThemesClass))
#define IS_THEMES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEMES))
#define IS_THEMES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEMES))
#define THEMES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEMES, ThemesClass))

typedef struct _Themes Themes;
typedef struct _ThemesClass ThemesClass;
typedef struct _Block80Data Block80Data;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;

#define TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;
#define _mind_map_unref0(var) ((var == NULL) ? NULL : (var = (mind_map_unref (var), NULL)))
#define __vala_GdkRGBA_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkRGBA_free (var), NULL)))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
typedef struct _Block81Data Block81Data;

struct _ThemeEditor {
	GtkBox parent_instance;
	ThemeEditorPrivate * priv;
};

struct _ThemeEditorClass {
	GtkBoxClass parent_class;
};

struct _ThemeEditorPrivate {
	MainWindow* _win;
	Theme* _theme;
	Theme* _orig_theme;
	gboolean _edit;
	GtkEntry* _name;
	GeeHashMap* _btns;
	GtkButton* _del;
	gboolean _ignore;
};

struct _Block80Data {
	int _ref_count_;
	ThemeEditor* self;
	GtkColorButton* btn;
	gchar* name;
};

struct _Block81Data {
	int _ref_count_;
	ThemeEditor* self;
	GraniteMessageDialog* dialog;
};

static gint ThemeEditor_private_offset;
static gpointer theme_editor_parent_class = NULL;

VALA_EXTERN GType theme_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ThemeEditor, g_object_unref)
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
VALA_EXTERN GType theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Theme, g_object_unref)
VALA_EXTERN ThemeEditor* theme_editor_new (MainWindow* win);
VALA_EXTERN ThemeEditor* theme_editor_construct (GType object_type,
                                     MainWindow* win);
static void __lambda163_ (ThemeEditor* self);
VALA_EXTERN const gchar* theme_get_name (Theme* self);
VALA_EXTERN GType themes_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Themes, g_object_unref)
VALA_EXTERN Themes* main_window_get_themes (MainWindow* self);
VALA_EXTERN gchar* themes_uniquify_name (Themes* self,
                             const gchar* name);
static void ___lambda163__gtk_event_controller_focus_leave (GtkEventControllerFocus* _sender,
                                                     gpointer self);
static void theme_editor_add_color (ThemeEditor* self,
                             const gchar* lbl_str,
                             const gchar* name,
                             GtkGrid* grid,
                             gint* row);
VALA_EXTERN gint theme_num_link_colors (void);
static void theme_editor_confirm_deletion (ThemeEditor* self);
static void _theme_editor_confirm_deletion_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self);
static void theme_editor_close_window (ThemeEditor* self);
static void _theme_editor_close_window_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self);
static void theme_editor_save_theme (ThemeEditor* self);
static void _theme_editor_save_theme_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self);
static Block80Data* block80_data_ref (Block80Data* _data80_);
static void block80_data_unref (void * _userdata_);
static void __lambda164_ (Block80Data* _data80_);
VALA_EXTERN gboolean theme_set_color (Theme* self,
                          const gchar* name,
                          GdkRGBA* color);
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN MindMap* main_window_get_current_map (MainWindow* self,
                                      const gchar* caller);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN void map_model_set_theme (MapModel* self,
                          Theme* theme,
                          gboolean save);
static void ___lambda164__gtk_color_button_color_set (GtkColorButton* _sender,
                                               gpointer self);
VALA_EXTERN void theme_editor_initialize (ThemeEditor* self,
                              Theme* theme,
                              gboolean edit);
VALA_EXTERN Theme* theme_new_customized (Theme* theme);
VALA_EXTERN Theme* theme_construct_customized (GType object_type,
                                   Theme* theme);
VALA_EXTERN void theme_set_label (Theme* self,
                      const gchar* value);
VALA_EXTERN void theme_set_name (Theme* self,
                     const gchar* value);
VALA_EXTERN GArray* theme_colors (Theme* self);
VALA_EXTERN GdkRGBA* theme_get_color (Theme* self,
                          const gchar* name);
static void _vala_GdkRGBA_free (GdkRGBA* self);
static Block81Data* block81_data_ref (Block81Data* _data81_);
static void block81_data_unref (void * _userdata_);
static void __lambda165_ (Block81Data* _data81_,
                   gint id);
static void theme_editor_delete_theme (ThemeEditor* self);
static void ___lambda165__gtk_dialog_response (GtkDialog* _sender,
                                        gint response_id,
                                        gpointer self);
VALA_EXTERN Theme* themes_get_theme (Themes* self,
                         const gchar* name);
VALA_EXTERN void themes_delete_theme (Themes* self,
                          const gchar* name);
VALA_EXTERN void main_window_hide_theme_editor (MainWindow* self);
VALA_EXTERN void theme_copy (Theme* self,
                 Theme* theme);
VALA_EXTERN void themes_add_theme (Themes* self,
                       Theme* theme);
static void theme_editor_finalize (GObject * obj);
static GType theme_editor_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
theme_editor_get_instance_private (ThemeEditor* self)
{
	return G_STRUCT_MEMBER_P (self, ThemeEditor_private_offset);
}

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

static void
__lambda163_ (ThemeEditor* self)
{
	gboolean _tmp0_ = FALSE;
	if (!self->priv->_edit) {
		_tmp0_ = TRUE;
	} else {
		GtkEntry* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		Theme* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp1_ = self->priv->_name;
		_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = self->priv->_orig_theme;
		_tmp5_ = theme_get_name (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = g_strcmp0 (_tmp3_, _tmp6_) != 0;
	}
	if (_tmp0_) {
		GtkEntry* _tmp7_;
		MainWindow* _tmp8_;
		Themes* _tmp9_;
		Themes* _tmp10_;
		GtkEntry* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp7_ = self->priv->_name;
		_tmp8_ = self->priv->_win;
		_tmp9_ = main_window_get_themes (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->_name;
		_tmp12_ = gtk_editable_get_text ((GtkEditable*) _tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = themes_uniquify_name (_tmp10_, _tmp13_);
		_tmp15_ = _tmp14_;
		gtk_editable_set_text ((GtkEditable*) _tmp7_, _tmp15_);
		_g_free0 (_tmp15_);
	}
}

static void
___lambda163__gtk_event_controller_focus_leave (GtkEventControllerFocus* _sender,
                                                gpointer self)
{
	__lambda163_ ((ThemeEditor*) self);
}

static void
_theme_editor_confirm_deletion_gtk_button_clicked (GtkButton* _sender,
                                                   gpointer self)
{
	theme_editor_confirm_deletion ((ThemeEditor*) self);
}

static void
_theme_editor_close_window_gtk_button_clicked (GtkButton* _sender,
                                               gpointer self)
{
	theme_editor_close_window ((ThemeEditor*) self);
}

static void
_theme_editor_save_theme_gtk_button_clicked (GtkButton* _sender,
                                             gpointer self)
{
	theme_editor_save_theme ((ThemeEditor*) self);
}

ThemeEditor*
theme_editor_construct (GType object_type,
                        MainWindow* win)
{
	ThemeEditor * self = NULL;
	MainWindow* _tmp0_;
	GeeHashMap* _tmp1_;
	GtkLabel* title = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* nlbl = NULL;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GtkLabel* _tmp10_ = NULL;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkEntry* _tmp13_;
	GtkEventControllerFocus* entry_focus = NULL;
	GtkEventControllerFocus* _tmp14_;
	GtkEntry* _tmp15_;
	GtkEventControllerFocus* _tmp16_;
	GtkEventController* _tmp17_;
	GtkEventControllerFocus* _tmp18_;
	GtkBox* nbox = NULL;
	GtkBox* _tmp19_ = NULL;
	GtkBox* _tmp20_;
	GtkLabel* _tmp21_;
	GtkBox* _tmp22_;
	GtkEntry* _tmp23_;
	GtkBox* _tmp24_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp25_ = NULL;
	GtkScrolledWindow* sw = NULL;
	GtkGrid* _tmp26_;
	GtkWidget* _tmp27_;
	GtkScrolledWindow* _tmp28_ = NULL;
	GtkScrolledWindow* _tmp29_;
	GtkWidget* _tmp30_;
	GtkWidget* _tmp31_;
	GtkScrolledWindow* _tmp32_;
	gint row = 0;
	GtkLabel* color_lbl = NULL;
	gchar* _tmp33_;
	gchar* _tmp34_;
	GtkLabel* _tmp35_ = NULL;
	GtkLabel* _tmp36_;
	GtkLabel* _tmp37_;
	GtkGrid* _tmp38_;
	GtkLabel* _tmp39_;
	gint _tmp40_;
	GtkGrid* _tmp41_;
	GtkGrid* _tmp42_;
	GtkGrid* _tmp43_;
	GtkGrid* _tmp44_;
	GtkGrid* _tmp45_;
	GtkGrid* _tmp46_;
	GtkGrid* _tmp47_;
	GtkGrid* _tmp48_;
	GtkGrid* _tmp49_;
	GtkGrid* _tmp50_;
	GtkGrid* _tmp51_;
	GtkGrid* _tmp52_;
	GtkGrid* _tmp53_;
	GtkGrid* _tmp54_;
	GtkGrid* _tmp55_;
	GtkGrid* _tmp56_;
	GtkGrid* _tmp57_;
	GtkGrid* _tmp58_;
	GtkGrid* _tmp59_;
	GtkGrid* _tmp60_;
	GtkGrid* _tmp61_;
	GtkGrid* _tmp62_;
	GtkLabel* _tmp63_;
	GtkLabel* _tmp64_;
	gint _tmp65_;
	GtkLabel* link_lbl = NULL;
	gchar* _tmp66_;
	gchar* _tmp67_;
	GtkLabel* _tmp68_ = NULL;
	GtkLabel* _tmp69_;
	GtkLabel* _tmp70_;
	GtkGrid* _tmp71_;
	GtkLabel* _tmp72_;
	gint _tmp73_;
	GtkButton* _tmp83_ = NULL;
	GtkButton* _tmp84_;
	GtkButton* _tmp85_;
	GtkLabel* l = NULL;
	GtkLabel* _tmp86_ = NULL;
	GtkButton* cancel = NULL;
	GtkButton* _tmp87_ = NULL;
	GtkButton* save = NULL;
	GtkButton* _tmp88_ = NULL;
	GtkBox* bbox = NULL;
	GtkBox* _tmp89_ = NULL;
	GtkButton* _tmp90_;
	g_return_val_if_fail (win != NULL, NULL);
	self = (ThemeEditor*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 10, "margin-start", 10, "margin-end", 10, "margin-top", 10, "margin-bottom", 10, NULL);
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (self->priv->_win);
	self->priv->_win = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, gtk_color_button_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->_btns);
	self->priv->_btns = _tmp1_;
	_tmp2_ = g_strconcat (_ ("Customize Theme"), "\n", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	title = _tmp5_;
	_tmp6_ = title;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "titled");
	_tmp7_ = title;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp7_);
	_tmp8_ = g_strconcat (_ ("Name"), ":", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = (GtkLabel*) gtk_label_new (_tmp9_);
	gtk_label_set_xalign (_tmp10_, (gfloat) 0);
	g_object_ref_sink (_tmp10_);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp9_);
	nlbl = _tmp11_;
	_tmp12_ = nlbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "titled");
	_tmp13_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->_name);
	self->priv->_name = _tmp13_;
	_tmp14_ = (GtkEventControllerFocus*) gtk_event_controller_focus_new ();
	entry_focus = _tmp14_;
	_tmp15_ = self->priv->_name;
	_tmp16_ = entry_focus;
	_tmp17_ = _g_object_ref0 ((GtkEventController*) _tmp16_);
	gtk_widget_add_controller ((GtkWidget*) _tmp15_, _tmp17_);
	_tmp18_ = entry_focus;
	g_signal_connect_object (_tmp18_, "leave", (GCallback) ___lambda163__gtk_event_controller_focus_leave, self, 0);
	_tmp19_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
	gtk_widget_set_halign ((GtkWidget*) _tmp19_, GTK_ALIGN_FILL);
	g_object_ref_sink (_tmp19_);
	nbox = _tmp19_;
	_tmp20_ = nbox;
	_tmp21_ = nlbl;
	gtk_box_append (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = nbox;
	_tmp23_ = self->priv->_name;
	gtk_box_append (_tmp22_, (GtkWidget*) _tmp23_);
	_tmp24_ = nbox;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp24_);
	_tmp25_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_row_spacing (_tmp25_, 5);
	gtk_grid_set_column_spacing (_tmp25_, 30);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp25_, 5);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp25_, 5);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp25_, 5);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp25_, 5);
	g_object_ref_sink (_tmp25_);
	grid = _tmp25_;
	_tmp26_ = grid;
	_tmp27_ = _g_object_ref0 ((GtkWidget*) _tmp26_);
	_tmp28_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_widget_set_vexpand ((GtkWidget*) _tmp28_, TRUE);
	gtk_scrolled_window_set_child (_tmp28_, _tmp27_);
	_g_object_unref0 (_tmp27_);
	g_object_ref_sink (_tmp28_);
	sw = _tmp28_;
	_tmp29_ = sw;
	_tmp30_ = gtk_scrolled_window_get_child (_tmp29_);
	_tmp31_ = _tmp30_;
	gtk_widget_set_size_request (_tmp31_, 180, 600);
	_tmp32_ = sw;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp32_);
	row = 0;
	_tmp33_ = g_strconcat (_ ("Base Colors"), "\n", NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = (GtkLabel*) gtk_label_new (_tmp34_);
	gtk_label_set_xalign (_tmp35_, (gfloat) 0);
	g_object_ref_sink (_tmp35_);
	_tmp36_ = _tmp35_;
	_g_free0 (_tmp34_);
	color_lbl = _tmp36_;
	_tmp37_ = color_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp37_, "titled");
	_tmp38_ = grid;
	_tmp39_ = color_lbl;
	gtk_grid_attach (_tmp38_, (GtkWidget*) _tmp39_, 0, row, 2, 1);
	_tmp40_ = row;
	row = _tmp40_ + 1;
	_tmp41_ = grid;
	theme_editor_add_color (self, _ ("Background"), "background", _tmp41_, &row);
	_tmp42_ = grid;
	theme_editor_add_color (self, _ ("Foreground"), "foreground", _tmp42_, &row);
	_tmp43_ = grid;
	theme_editor_add_color (self, _ ("Root Node Background"), "root_background", _tmp43_, &row);
	_tmp44_ = grid;
	theme_editor_add_color (self, _ ("Root Node Foreground"), "root_foreground", _tmp44_, &row);
	_tmp45_ = grid;
	theme_editor_add_color (self, _ ("Node Select Background"), "nodesel_background", _tmp45_, &row);
	_tmp46_ = grid;
	theme_editor_add_color (self, _ ("Node Select Foreground"), "nodesel_foreground", _tmp46_, &row);
	_tmp47_ = grid;
	theme_editor_add_color (self, _ ("Text Select Background"), "textsel_background", _tmp47_, &row);
	_tmp48_ = grid;
	theme_editor_add_color (self, _ ("Text Select Foreground"), "textsel_foreground", _tmp48_, &row);
	_tmp49_ = grid;
	theme_editor_add_color (self, _ ("Text Cursor"), "text_cursor", _tmp49_, &row);
	_tmp50_ = grid;
	theme_editor_add_color (self, _ ("Attachable Highlight"), "attachable", _tmp50_, &row);
	_tmp51_ = grid;
	theme_editor_add_color (self, _ ("Connection Color"), "connection_background", _tmp51_, &row);
	_tmp52_ = grid;
	theme_editor_add_color (self, _ ("Connection Title Color"), "connection_foreground", _tmp52_, &row);
	_tmp53_ = grid;
	theme_editor_add_color (self, _ ("Callout Background"), "callout_background", _tmp53_, &row);
	_tmp54_ = grid;
	theme_editor_add_color (self, _ ("URL Link Background"), "url_background", _tmp54_, &row);
	_tmp55_ = grid;
	theme_editor_add_color (self, _ ("URL Link Foreground"), "url_foreground", _tmp55_, &row);
	_tmp56_ = grid;
	theme_editor_add_color (self, _ ("Highlighter"), "highlighter", _tmp56_, &row);
	_tmp57_ = grid;
	theme_editor_add_color (self, _ ("Tag"), "tag", _tmp57_, &row);
	_tmp58_ = grid;
	theme_editor_add_color (self, _ ("Markdown Syntax Chars"), "syntax", _tmp58_, &row);
	_tmp59_ = grid;
	theme_editor_add_color (self, _ ("Match Background"), "match_background", _tmp59_, &row);
	_tmp60_ = grid;
	theme_editor_add_color (self, _ ("Match Foreground"), "match_foreground", _tmp60_, &row);
	_tmp61_ = grid;
	theme_editor_add_color (self, _ ("Markdown List Item"), "markdown_listitem", _tmp61_, &row);
	_tmp62_ = grid;
	_tmp63_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp63_);
	_tmp64_ = _tmp63_;
	gtk_grid_attach (_tmp62_, (GtkWidget*) _tmp64_, 0, row, 1, 1);
	_g_object_unref0 (_tmp64_);
	_tmp65_ = row;
	row = _tmp65_ + 1;
	_tmp66_ = g_strconcat (_ ("Link Colors"), "\n", NULL);
	_tmp67_ = _tmp66_;
	_tmp68_ = (GtkLabel*) gtk_label_new (_tmp67_);
	gtk_label_set_xalign (_tmp68_, (gfloat) 0);
	g_object_ref_sink (_tmp68_);
	_tmp69_ = _tmp68_;
	_g_free0 (_tmp67_);
	link_lbl = _tmp69_;
	_tmp70_ = link_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp70_, "titled");
	_tmp71_ = grid;
	_tmp72_ = link_lbl;
	gtk_grid_attach (_tmp71_, (GtkWidget*) _tmp72_, 0, row, 2, 1);
	_tmp73_ = row;
	row = _tmp73_ + 1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp74_ = FALSE;
			_tmp74_ = TRUE;
			while (TRUE) {
				gchar* _tmp76_;
				gchar* _tmp77_;
				gchar* _tmp78_;
				gchar* _tmp79_;
				gchar* _tmp80_;
				gchar* _tmp81_;
				GtkGrid* _tmp82_;
				if (!_tmp74_) {
					gint _tmp75_;
					_tmp75_ = i;
					i = _tmp75_ + 1;
				}
				_tmp74_ = FALSE;
				if (!(i < theme_num_link_colors ())) {
					break;
				}
				_tmp76_ = g_strdup_printf (" #%d", i + 1);
				_tmp77_ = _tmp76_;
				_tmp78_ = g_strconcat (_ ("Link Color"), _tmp77_, NULL);
				_tmp79_ = _tmp78_;
				_tmp80_ = g_strdup_printf ("link_color%d", i);
				_tmp81_ = _tmp80_;
				_tmp82_ = grid;
				theme_editor_add_color (self, _tmp79_, _tmp81_, _tmp82_, &row);
				_g_free0 (_tmp81_);
				_g_free0 (_tmp79_);
				_g_free0 (_tmp77_);
			}
		}
	}
	_tmp83_ = (GtkButton*) gtk_button_new_with_label (_ ("Delete"));
	gtk_widget_set_halign ((GtkWidget*) _tmp83_, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp83_, TRUE);
	gtk_widget_set_visible ((GtkWidget*) _tmp83_, FALSE);
	g_object_ref_sink (_tmp83_);
	_g_object_unref0 (self->priv->_del);
	self->priv->_del = _tmp83_;
	_tmp84_ = self->priv->_del;
	gtk_widget_add_css_class ((GtkWidget*) _tmp84_, "destructive-action");
	_tmp85_ = self->priv->_del;
	g_signal_connect_object (_tmp85_, "clicked", (GCallback) _theme_editor_confirm_deletion_gtk_button_clicked, self, 0);
	_tmp86_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_hexpand ((GtkWidget*) _tmp86_, TRUE);
	g_object_ref_sink (_tmp86_);
	l = _tmp86_;
	_tmp87_ = (GtkButton*) gtk_button_new_with_label (_ ("Cancel"));
	gtk_widget_set_halign ((GtkWidget*) _tmp87_, GTK_ALIGN_END);
	g_object_ref_sink (_tmp87_);
	cancel = _tmp87_;
	g_signal_connect_object (cancel, "clicked", (GCallback) _theme_editor_close_window_gtk_button_clicked, self, 0);
	_tmp88_ = (GtkButton*) gtk_button_new_with_label (_ ("Save"));
	gtk_widget_set_halign ((GtkWidget*) _tmp88_, GTK_ALIGN_END);
	g_object_ref_sink (_tmp88_);
	save = _tmp88_;
	gtk_widget_add_css_class ((GtkWidget*) save, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	g_signal_connect_object (save, "clicked", (GCallback) _theme_editor_save_theme_gtk_button_clicked, self, 0);
	_tmp89_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	gtk_widget_set_valign ((GtkWidget*) _tmp89_, GTK_ALIGN_FILL);
	g_object_ref_sink (_tmp89_);
	bbox = _tmp89_;
	_tmp90_ = self->priv->_del;
	gtk_box_append (bbox, (GtkWidget*) _tmp90_);
	gtk_box_append (bbox, (GtkWidget*) l);
	gtk_box_append (bbox, (GtkWidget*) cancel);
	gtk_box_append (bbox, (GtkWidget*) save);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) bbox);
	_g_object_unref0 (bbox);
	_g_object_unref0 (save);
	_g_object_unref0 (cancel);
	_g_object_unref0 (l);
	_g_object_unref0 (link_lbl);
	_g_object_unref0 (color_lbl);
	_g_object_unref0 (sw);
	_g_object_unref0 (grid);
	_g_object_unref0 (nbox);
	_g_object_unref0 (entry_focus);
	_g_object_unref0 (nlbl);
	_g_object_unref0 (title);
	return self;
}

ThemeEditor*
theme_editor_new (MainWindow* win)
{
	return theme_editor_construct (TYPE_THEME_EDITOR, win);
}

static Block80Data*
block80_data_ref (Block80Data* _data80_)
{
	g_atomic_int_inc (&_data80_->_ref_count_);
	return _data80_;
}

static void
block80_data_unref (void * _userdata_)
{
	Block80Data* _data80_;
	_data80_ = (Block80Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data80_->_ref_count_)) {
		ThemeEditor* self;
		self = _data80_->self;
		_g_object_unref0 (_data80_->btn);
		_g_free0 (_data80_->name);
		_g_object_unref0 (self);
		g_slice_free (Block80Data, _data80_);
	}
}

static void
__lambda164_ (Block80Data* _data80_)
{
	ThemeEditor* self;
	Theme* _tmp0_;
	GdkRGBA _tmp1_ = {0};
	GdkRGBA _tmp2_;
	MainWindow* _tmp3_;
	MindMap* _tmp4_;
	MindMap* _tmp5_;
	MapModel* _tmp6_;
	MapModel* _tmp7_;
	Theme* _tmp8_;
	self = _data80_->self;
	_tmp0_ = self->priv->_theme;
	gtk_color_chooser_get_rgba ((GtkColorChooser*) _data80_->btn, &_tmp1_);
	_tmp2_ = _tmp1_;
	theme_set_color (_tmp0_, _data80_->name, &_tmp2_);
	_tmp3_ = self->priv->_win;
	_tmp4_ = main_window_get_current_map (_tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = mind_map_get_model (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->_theme;
	map_model_set_theme (_tmp7_, _tmp8_, TRUE);
	_mind_map_unref0 (_tmp5_);
}

static void
___lambda164__gtk_color_button_color_set (GtkColorButton* _sender,
                                          gpointer self)
{
	__lambda164_ (self);
}

static void
theme_editor_add_color (ThemeEditor* self,
                        const gchar* lbl_str,
                        const gchar* name,
                        GtkGrid* grid,
                        gint* row)
{
	Block80Data* _data80_;
	gchar* _tmp0_;
	GtkLabel* lbl = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkLabel* _tmp3_ = NULL;
	GtkLabel* _tmp4_;
	GtkColorButton* _tmp5_ = NULL;
	GeeHashMap* _tmp6_;
	gint _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (lbl_str != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (grid != NULL);
	_data80_ = g_slice_new0 (Block80Data);
	_data80_->_ref_count_ = 1;
	_data80_->self = g_object_ref (self);
	_tmp0_ = g_strdup (name);
	_g_free0 (_data80_->name);
	_data80_->name = _tmp0_;
	_tmp1_ = g_strconcat ("  ", lbl_str, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new (_tmp2_);
	gtk_label_set_xalign (_tmp3_, (gfloat) 0);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	lbl = _tmp4_;
	_tmp5_ = (GtkColorButton*) gtk_color_button_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp5_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp5_);
	_data80_->btn = _tmp5_;
	g_signal_connect_data (_data80_->btn, "color-set", (GCallback) ___lambda164__gtk_color_button_color_set, block80_data_ref (_data80_), (GClosureNotify) block80_data_unref, 0);
	_tmp6_ = self->priv->_btns;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, _data80_->name, _data80_->btn);
	gtk_grid_attach (grid, (GtkWidget*) lbl, 0, *row, 1, 1);
	gtk_grid_attach (grid, (GtkWidget*) _data80_->btn, 1, *row, 2, 1);
	_tmp7_ = *row;
	*row = _tmp7_ + 1;
	_g_object_unref0 (lbl);
	block80_data_unref (_data80_);
	_data80_ = NULL;
}

static void
_vala_GdkRGBA_free (GdkRGBA* self)
{
	g_boxed_free (gdk_rgba_get_type (), self);
}

void
theme_editor_initialize (ThemeEditor* self,
                         Theme* theme,
                         gboolean edit)
{
	Theme* _tmp0_;
	Theme* _tmp1_;
	GArray* colors = NULL;
	Theme* _tmp11_;
	GArray* _tmp12_;
	GtkEntry* _tmp27_;
	Theme* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	GtkButton* _tmp31_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (theme != NULL);
	_tmp0_ = _g_object_ref0 (theme);
	_g_object_unref0 (self->priv->_orig_theme);
	self->priv->_orig_theme = _tmp0_;
	self->priv->_edit = edit;
	_tmp1_ = theme_new_customized (theme);
	_g_object_unref0 (self->priv->_theme);
	self->priv->_theme = _tmp1_;
	if (!edit) {
		Theme* _tmp2_;
		Theme* _tmp3_;
		MainWindow* _tmp4_;
		Themes* _tmp5_;
		Themes* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp2_ = self->priv->_theme;
		_tmp3_ = self->priv->_theme;
		_tmp4_ = self->priv->_win;
		_tmp5_ = main_window_get_themes (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat (_ ("Custom"), " #1", NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = themes_uniquify_name (_tmp6_, _tmp8_);
		_tmp10_ = _tmp9_;
		theme_set_label (_tmp3_, _tmp10_);
		theme_set_name (_tmp2_, _tmp10_);
		_g_free0 (_tmp10_);
		_g_free0 (_tmp8_);
	}
	self->priv->_ignore = TRUE;
	_tmp11_ = self->priv->_theme;
	_tmp12_ = theme_colors (_tmp11_);
	colors = _tmp12_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp13_ = FALSE;
			_tmp13_ = TRUE;
			while (TRUE) {
				GArray* _tmp15_;
				GeeHashMap* _tmp16_;
				GArray* _tmp17_;
				const gchar* _tmp18_;
				gpointer _tmp19_;
				GtkColorButton* _tmp20_;
				Theme* _tmp21_;
				GArray* _tmp22_;
				const gchar* _tmp23_;
				GdkRGBA* _tmp24_;
				GdkRGBA* _tmp25_;
				GdkRGBA _tmp26_;
				if (!_tmp13_) {
					gint _tmp14_;
					_tmp14_ = i;
					i = _tmp14_ + 1;
				}
				_tmp13_ = FALSE;
				_tmp15_ = colors;
				if (!(((guint) i) < _tmp15_->len)) {
					break;
				}
				_tmp16_ = self->priv->_btns;
				_tmp17_ = colors;
				_tmp18_ = g_array_index (_tmp17_, gchar*, (guint) i);
				_tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp16_, _tmp18_);
				_tmp20_ = (GtkColorButton*) _tmp19_;
				_tmp21_ = self->priv->_theme;
				_tmp22_ = colors;
				_tmp23_ = g_array_index (_tmp22_, gchar*, (guint) i);
				_tmp24_ = theme_get_color (_tmp21_, _tmp23_);
				_tmp25_ = _tmp24_;
				_tmp26_ = *_tmp25_;
				gtk_color_chooser_set_rgba ((GtkColorChooser*) _tmp20_, &_tmp26_);
				__vala_GdkRGBA_free0 (_tmp25_);
				_g_object_unref0 (_tmp20_);
			}
		}
	}
	_tmp27_ = self->priv->_name;
	_tmp28_ = self->priv->_theme;
	_tmp29_ = theme_get_name (_tmp28_);
	_tmp30_ = _tmp29_;
	gtk_editable_set_text ((GtkEditable*) _tmp27_, _tmp30_);
	_tmp31_ = self->priv->_del;
	gtk_widget_set_visible ((GtkWidget*) _tmp31_, edit);
	self->priv->_ignore = FALSE;
	_g_array_unref0 (colors);
}

static Block81Data*
block81_data_ref (Block81Data* _data81_)
{
	g_atomic_int_inc (&_data81_->_ref_count_);
	return _data81_;
}

static void
block81_data_unref (void * _userdata_)
{
	Block81Data* _data81_;
	_data81_ = (Block81Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data81_->_ref_count_)) {
		ThemeEditor* self;
		self = _data81_->self;
		_g_object_unref0 (_data81_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block81Data, _data81_);
	}
}

static void
__lambda165_ (Block81Data* _data81_,
              gint id)
{
	ThemeEditor* self;
	self = _data81_->self;
	if (id == ((gint) GTK_RESPONSE_ACCEPT)) {
		theme_editor_delete_theme (self);
	}
	g_signal_emit_by_name ((GtkDialog*) _data81_->dialog, "close");
}

static void
___lambda165__gtk_dialog_response (GtkDialog* _sender,
                                   gint response_id,
                                   gpointer self)
{
	__lambda165_ (self, response_id);
}

static void
theme_editor_confirm_deletion (ThemeEditor* self)
{
	Block81Data* _data81_;
	GraniteMessageDialog* _tmp0_;
	GtkButton* no = NULL;
	GtkButton* _tmp1_;
	GtkButton* yes = NULL;
	GtkButton* _tmp2_;
	MainWindow* _tmp3_;
	g_return_if_fail (self != NULL);
	_data81_ = g_slice_new0 (Block81Data);
	_data81_->_ref_count_ = 1;
	_data81_->self = g_object_ref (self);
	_tmp0_ = granite_message_dialog_new_with_image_from_icon_name (_ ("Delete theme?"), _ ("This operation cannot be undone."), "dialog-warning", GTK_BUTTONS_NONE);
	g_object_ref_sink (_tmp0_);
	_data81_->dialog = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new_with_label (_ ("No"));
	g_object_ref_sink (_tmp1_);
	no = _tmp1_;
	gtk_dialog_add_action_widget ((GtkDialog*) _data81_->dialog, (GtkWidget*) no, (gint) GTK_RESPONSE_CANCEL);
	_tmp2_ = (GtkButton*) gtk_button_new_with_label (_ ("Yes"));
	g_object_ref_sink (_tmp2_);
	yes = _tmp2_;
	gtk_widget_add_css_class ((GtkWidget*) yes, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	gtk_dialog_add_action_widget ((GtkDialog*) _data81_->dialog, (GtkWidget*) yes, (gint) GTK_RESPONSE_ACCEPT);
	_tmp3_ = self->priv->_win;
	gtk_window_set_transient_for ((GtkWindow*) _data81_->dialog, (GtkWindow*) _tmp3_);
	gtk_dialog_set_default_response ((GtkDialog*) _data81_->dialog, (gint) GTK_RESPONSE_ACCEPT);
	gtk_window_set_title ((GtkWindow*) _data81_->dialog, "");
	g_signal_connect_data ((GtkDialog*) _data81_->dialog, "response", (GCallback) ___lambda165__gtk_dialog_response, block81_data_ref (_data81_), (GClosureNotify) block81_data_unref, 0);
	gtk_window_present ((GtkWindow*) _data81_->dialog);
	_g_object_unref0 (yes);
	_g_object_unref0 (no);
	block81_data_unref (_data81_);
	_data81_ = NULL;
}

static void
theme_editor_delete_theme (ThemeEditor* self)
{
	MainWindow* _tmp0_;
	MindMap* _tmp1_;
	MindMap* _tmp2_;
	MapModel* _tmp3_;
	MapModel* _tmp4_;
	MainWindow* _tmp5_;
	Themes* _tmp6_;
	Themes* _tmp7_;
	Theme* _tmp8_;
	Theme* _tmp9_;
	MainWindow* _tmp10_;
	Themes* _tmp11_;
	Themes* _tmp12_;
	Theme* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	MainWindow* _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_win;
	_tmp1_ = main_window_get_current_map (_tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = mind_map_get_model (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_win;
	_tmp6_ = main_window_get_themes (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = themes_get_theme (_tmp7_, _ ("Default"));
	_tmp9_ = _tmp8_;
	map_model_set_theme (_tmp4_, _tmp9_, TRUE);
	_g_object_unref0 (_tmp9_);
	_mind_map_unref0 (_tmp2_);
	_tmp10_ = self->priv->_win;
	_tmp11_ = main_window_get_themes (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = self->priv->_orig_theme;
	_tmp14_ = theme_get_name (_tmp13_);
	_tmp15_ = _tmp14_;
	themes_delete_theme (_tmp12_, _tmp15_);
	_tmp16_ = self->priv->_win;
	main_window_hide_theme_editor (_tmp16_);
}

static void
theme_editor_close_window (ThemeEditor* self)
{
	MainWindow* _tmp0_;
	MindMap* _tmp1_;
	MindMap* _tmp2_;
	MapModel* _tmp3_;
	MapModel* _tmp4_;
	Theme* _tmp5_;
	MainWindow* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_win;
	_tmp1_ = main_window_get_current_map (_tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = mind_map_get_model (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_orig_theme;
	map_model_set_theme (_tmp4_, _tmp5_, TRUE);
	_mind_map_unref0 (_tmp2_);
	_tmp6_ = self->priv->_win;
	main_window_hide_theme_editor (_tmp6_);
}

static void
theme_editor_save_theme (ThemeEditor* self)
{
	Theme* _tmp0_;
	Theme* _tmp1_;
	GtkEntry* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	MainWindow* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_theme;
	_tmp1_ = self->priv->_theme;
	_tmp2_ = self->priv->_name;
	_tmp3_ = gtk_editable_get_text ((GtkEditable*) _tmp2_);
	_tmp4_ = _tmp3_;
	theme_set_label (_tmp1_, _tmp4_);
	theme_set_name (_tmp0_, _tmp4_);
	if (self->priv->_edit) {
		Theme* _tmp5_;
		Theme* _tmp6_;
		MainWindow* _tmp7_;
		Themes* _tmp8_;
		Themes* _tmp9_;
		_tmp5_ = self->priv->_orig_theme;
		_tmp6_ = self->priv->_theme;
		theme_copy (_tmp5_, _tmp6_);
		_tmp7_ = self->priv->_win;
		_tmp8_ = main_window_get_themes (_tmp7_);
		_tmp9_ = _tmp8_;
		g_signal_emit_by_name (_tmp9_, "themes-changed");
	} else {
		MainWindow* _tmp10_;
		Themes* _tmp11_;
		Themes* _tmp12_;
		Theme* _tmp13_;
		_tmp10_ = self->priv->_win;
		_tmp11_ = main_window_get_themes (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = self->priv->_theme;
		themes_add_theme (_tmp12_, _tmp13_);
	}
	_tmp14_ = self->priv->_win;
	main_window_hide_theme_editor (_tmp14_);
}

static void
theme_editor_class_init (ThemeEditorClass * klass,
                         gpointer klass_data)
{
	theme_editor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ThemeEditor_private_offset);
	G_OBJECT_CLASS (klass)->finalize = theme_editor_finalize;
}

static void
theme_editor_instance_init (ThemeEditor * self,
                            gpointer klass)
{
	self->priv = theme_editor_get_instance_private (self);
	self->priv->_ignore = FALSE;
}

static void
theme_editor_finalize (GObject * obj)
{
	ThemeEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_THEME_EDITOR, ThemeEditor);
	_g_object_unref0 (self->priv->_win);
	_g_object_unref0 (self->priv->_theme);
	_g_object_unref0 (self->priv->_orig_theme);
	_g_object_unref0 (self->priv->_name);
	_g_object_unref0 (self->priv->_btns);
	_g_object_unref0 (self->priv->_del);
	G_OBJECT_CLASS (theme_editor_parent_class)->finalize (obj);
}

static GType
theme_editor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ThemeEditorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) theme_editor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ThemeEditor), 0, (GInstanceInitFunc) theme_editor_instance_init, NULL };
	GType theme_editor_type_id;
	theme_editor_type_id = g_type_register_static (gtk_box_get_type (), "ThemeEditor", &g_define_type_info, 0);
	ThemeEditor_private_offset = g_type_add_instance_private (theme_editor_type_id, sizeof (ThemeEditorPrivate));
	return theme_editor_type_id;
}

GType
theme_editor_get_type (void)
{
	static volatile gsize theme_editor_type_id__once = 0;
	if (g_once_init_enter (&theme_editor_type_id__once)) {
		GType theme_editor_type_id;
		theme_editor_type_id = theme_editor_get_type_once ();
		g_once_init_leave (&theme_editor_type_id__once, theme_editor_type_id);
	}
	return theme_editor_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;
}

