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

/*
* Copyright (c) 2020-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 <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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
#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_EXPORTER (exporter_get_type ())
#define EXPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORTER, Exporter))
#define EXPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORTER, ExporterClass))
#define IS_EXPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORTER))
#define IS_EXPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORTER))
#define EXPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORTER, ExporterClass))

typedef struct _Exporter Exporter;
typedef struct _ExporterClass ExporterClass;
typedef struct _ExporterPrivate ExporterPrivate;
enum  {
	EXPORTER_0_PROPERTY,
	EXPORTER_NUM_PROPERTIES
};
static GParamSpec* exporter_properties[EXPORTER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#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;
typedef struct _Block21Data Block21Data;

#define TYPE_EXPORTS (exports_get_type ())
#define EXPORTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORTS, Exports))
#define EXPORTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORTS, ExportsClass))
#define IS_EXPORTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORTS))
#define IS_EXPORTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORTS))
#define EXPORTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORTS, ExportsClass))

typedef struct _Exports Exports;
typedef struct _ExportsClass ExportsClass;

#define TYPE_EXPORT (export_get_type ())
#define EXPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT, Export))
#define EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT, ExportClass))
#define IS_EXPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT))
#define IS_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT))
#define EXPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT, ExportClass))

typedef struct _Export Export;
typedef struct _ExportClass ExportClass;
#define _export_unref0(var) ((var == NULL) ? NULL : (var = (export_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block22Data Block22Data;

#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_DOCUMENT (document_get_type ())
#define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
#define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
#define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
#define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
#define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))

typedef struct _Document Document;
typedef struct _DocumentClass DocumentClass;
#define _mind_map_unref0(var) ((var == NULL) ? NULL : (var = (mind_map_unref (var), NULL)))
enum  {
	EXPORTER_EXPORT_DONE_SIGNAL,
	EXPORTER_NUM_SIGNALS
};
static guint exporter_signals[EXPORTER_NUM_SIGNALS] = {0};

struct _Exporter {
	GtkBox parent_instance;
	ExporterPrivate * priv;
};

struct _ExporterClass {
	GtkBoxClass parent_class;
};

struct _ExporterPrivate {
	GtkRevealer* _stack_reveal;
	GtkStack* _stack;
};

struct _Block21Data {
	int _ref_count_;
	Exporter* self;
	GtkDropDown* mb;
	MainWindow* win;
};

struct _Block22Data {
	int _ref_count_;
	Exporter* self;
	GtkFileDialog* dialog;
	MainWindow* win;
	Export* export;
};

static gint Exporter_private_offset;
static gpointer exporter_parent_class = NULL;
VALA_EXTERN GSettings* minder_settings;

VALA_EXTERN GType exporter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Exporter, 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 Exporter* exporter_new (MainWindow* win);
VALA_EXTERN Exporter* exporter_construct (GType object_type,
                              MainWindow* win);
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
VALA_EXTERN gpointer exports_ref (gpointer instance);
VALA_EXTERN void exports_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_exports (const gchar* name,
                                const gchar* nick,
                                const gchar* blurb,
                                GType object_type,
                                GParamFlags flags);
VALA_EXTERN void value_set_exports (GValue* value,
                        gpointer v_object);
VALA_EXTERN void value_take_exports (GValue* value,
                         gpointer v_object);
VALA_EXTERN gpointer value_get_exports (const GValue* value);
VALA_EXTERN GType exports_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Exports, exports_unref)
VALA_EXTERN Exports* main_window_get_exports (MainWindow* self);
VALA_EXTERN gint exports_length (Exports* self);
VALA_EXTERN gpointer export_ref (gpointer instance);
VALA_EXTERN void export_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_export (const gchar* name,
                               const gchar* nick,
                               const gchar* blurb,
                               GType object_type,
                               GParamFlags flags);
VALA_EXTERN void value_set_export (GValue* value,
                       gpointer v_object);
VALA_EXTERN void value_take_export (GValue* value,
                        gpointer v_object);
VALA_EXTERN gpointer value_get_export (const GValue* value);
VALA_EXTERN GType export_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Export, export_unref)
VALA_EXTERN Export* exports_index (Exports* self,
                       gint idx);
VALA_EXTERN gboolean export_get_exportable (Export* self);
VALA_EXTERN const gchar* export_get_label (Export* self);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void exporter_add_export (Exporter* self,
                          MainWindow* win,
                          Export* export);
static void __lambda244_ (Block21Data* _data21_);
static void exporter_handle_mb_change (Exporter* self,
                                Export* export);
static void ___lambda244__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
VALA_EXTERN gchar* utils_tooltip_with_accel (const gchar* tooltip,
                                 const gchar* accel);
static void __lambda245_ (Block21Data* _data21_);
VALA_EXTERN void exporter_do_export (Exporter* self,
                         MainWindow* win);
static void ___lambda245__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN GSettings* main_window_get_settings (MainWindow* self);
VALA_EXTERN gint exports_get_index_by_name (Exports* self,
                                const gchar* name);
VALA_EXTERN const gchar* export_get_name (Export* self);
VALA_EXTERN gboolean export_settings_available (Export* self);
VALA_EXTERN void export_add_all_settings (Export* self,
                              GtkGrid* grid);
VALA_EXTERN void exporter_do_export_to_file (Exporter* self,
                                 MainWindow* win,
                                 Export* export);
static Block22Data* block22_data_ref (Block22Data* _data22_);
static void block22_data_unref (void * _userdata_);
VALA_EXTERN GtkFileDialog* utils_make_file_chooser (const gchar* user_title,
                                        const gchar* user_accept_label);
VALA_EXTERN gchar* utils_rootname (const gchar* filename);
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 GType document_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Document, g_object_unref)
VALA_EXTERN Document* mind_map_get_doc (MindMap* self);
VALA_EXTERN const gchar* document_get_filename (Document* self);
VALA_EXTERN gchar* main_window_repair_filename (MainWindow* self,
                                    const gchar* fname,
                                    gchar** extensions,
                                    gint extensions_length1);
VALA_EXTERN gchar** export_get_extensions (Export* self,
                               gint* result_length1);
static void __lambda246_ (Block22Data* _data22_,
                   GObject* obj,
                   GAsyncResult* res);
VALA_EXTERN gboolean export_export (Export* self,
                        const gchar* fname,
                        MindMap* map);
VALA_EXTERN void main_window_notification (MainWindow* self,
                               const gchar* title,
                               const gchar* msg,
                               GNotificationPriority priority);
static void ___lambda246__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
VALA_EXTERN void exporter_do_export_to_clipboard (Exporter* self,
                                      MainWindow* win,
                                      Export* export);
VALA_EXTERN Export* exports_get_by_name (Exports* self,
                             const gchar* name);
VALA_EXTERN void mind_map_unedit_text (MindMap* self);
VALA_EXTERN gboolean export_send_to_clipboard (Export* self);
static void exporter_finalize (GObject * obj);
static GType exporter_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
exporter_get_instance_private (Exporter* self)
{
	return G_STRUCT_MEMBER_P (self, Exporter_private_offset);
}

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

static Block21Data*
block21_data_ref (Block21Data* _data21_)
{
	g_atomic_int_inc (&_data21_->_ref_count_);
	return _data21_;
}

static void
block21_data_unref (void * _userdata_)
{
	Block21Data* _data21_;
	_data21_ = (Block21Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data21_->_ref_count_)) {
		Exporter* self;
		self = _data21_->self;
		_g_object_unref0 (_data21_->mb);
		_g_object_unref0 (_data21_->win);
		_g_object_unref0 (self);
		g_slice_free (Block21Data, _data21_);
	}
}

static void
_vala_array_add3 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda244_ (Block21Data* _data21_)
{
	Exporter* self;
	Exports* _tmp0_;
	Exports* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	Export* _tmp4_;
	Export* _tmp5_;
	self = _data21_->self;
	_tmp0_ = main_window_get_exports (_data21_->win);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_drop_down_get_selected (_data21_->mb);
	_tmp3_ = _tmp2_;
	_tmp4_ = exports_index (_tmp1_, (gint) _tmp3_);
	_tmp5_ = _tmp4_;
	exporter_handle_mb_change (self, _tmp5_);
	_export_unref0 (_tmp5_);
}

static void
___lambda244__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda244_ (self);
}

static void
__lambda245_ (Block21Data* _data21_)
{
	Exporter* self;
	self = _data21_->self;
	exporter_do_export (self, _data21_->win);
	g_signal_emit (self, exporter_signals[EXPORTER_EXPORT_DONE_SIGNAL], 0);
}

static void
___lambda245__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda245_ (self);
}

Exporter*
exporter_construct (GType object_type,
                    MainWindow* win)
{
	Exporter * self = NULL;
	Block21Data* _data21_;
	MainWindow* _tmp0_;
	GtkStack* _tmp1_ = NULL;
	gchar** export_types = NULL;
	gchar** _tmp2_;
	gint export_types_length1;
	gint _export_types_size_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	GtkDropDown* _tmp26_ = NULL;
	GtkButton* export = NULL;
	gchar* _tmp27_;
	GtkButton* _tmp28_ = NULL;
	GtkBox* bbox = NULL;
	GtkBox* _tmp29_;
	GtkStack* _tmp30_;
	GtkWidget* _tmp31_;
	GtkRevealer* _tmp32_ = NULL;
	GtkRevealer* _tmp33_;
	gchar* last = NULL;
	GSettings* _tmp34_;
	GSettings* _tmp35_;
	gchar* _tmp36_;
	Exports* _tmp37_;
	Exports* _tmp38_;
	g_return_val_if_fail (win != NULL, NULL);
	_data21_ = g_slice_new0 (Block21Data);
	_data21_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (_data21_->win);
	_data21_->win = _tmp0_;
	self = (Exporter*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	_data21_->self = g_object_ref (self);
	_tmp1_ = (GtkStack*) gtk_stack_new ();
	gtk_stack_set_transition_type (_tmp1_, GTK_STACK_TRANSITION_TYPE_NONE);
	gtk_stack_set_hhomogeneous (_tmp1_, TRUE);
	gtk_stack_set_vhomogeneous (_tmp1_, FALSE);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->_stack);
	self->priv->_stack = _tmp1_;
	_tmp2_ = g_new0 (gchar*, 0 + 1);
	export_types = _tmp2_;
	export_types_length1 = 0;
	_export_types_size_ = export_types_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				Exports* _tmp5_;
				Exports* _tmp6_;
				Exports* _tmp7_;
				Exports* _tmp8_;
				Export* _tmp9_;
				Export* _tmp10_;
				gboolean _tmp11_;
				gboolean _tmp12_;
				gboolean _tmp13_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = main_window_get_exports (_data21_->win);
				_tmp6_ = _tmp5_;
				if (!(i < exports_length (_tmp6_))) {
					break;
				}
				_tmp7_ = main_window_get_exports (_data21_->win);
				_tmp8_ = _tmp7_;
				_tmp9_ = exports_index (_tmp8_, i);
				_tmp10_ = _tmp9_;
				_tmp11_ = export_get_exportable (_tmp10_);
				_tmp12_ = _tmp11_;
				_tmp13_ = _tmp12_;
				_export_unref0 (_tmp10_);
				if (_tmp13_) {
					Exports* _tmp14_;
					Exports* _tmp15_;
					Export* _tmp16_;
					Export* _tmp17_;
					const gchar* _tmp18_;
					const gchar* _tmp19_;
					gchar* _tmp20_;
					Exports* _tmp21_;
					Exports* _tmp22_;
					Export* _tmp23_;
					Export* _tmp24_;
					_tmp14_ = main_window_get_exports (_data21_->win);
					_tmp15_ = _tmp14_;
					_tmp16_ = exports_index (_tmp15_, i);
					_tmp17_ = _tmp16_;
					_tmp18_ = export_get_label (_tmp17_);
					_tmp19_ = _tmp18_;
					_tmp20_ = g_strdup (_tmp19_);
					_vala_array_add3 (&export_types, &export_types_length1, &_export_types_size_, _tmp20_);
					_export_unref0 (_tmp17_);
					_tmp21_ = main_window_get_exports (_data21_->win);
					_tmp22_ = _tmp21_;
					_tmp23_ = exports_index (_tmp22_, i);
					_tmp24_ = _tmp23_;
					exporter_add_export (self, _data21_->win, _tmp24_);
					_export_unref0 (_tmp24_);
				}
			}
		}
	}
	_tmp25_ = export_types;
	_tmp25__length1 = export_types_length1;
	_tmp26_ = (GtkDropDown*) gtk_drop_down_new_from_strings (_tmp25_);
	gtk_widget_set_halign ((GtkWidget*) _tmp26_, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp26_, TRUE);
	g_object_ref_sink (_tmp26_);
	_data21_->mb = _tmp26_;
	g_signal_connect_data ((GObject*) _data21_->mb, "notify::selected", (GCallback) ___lambda244__g_object_notify, block21_data_ref (_data21_), (GClosureNotify) block21_data_unref, 0);
	_tmp27_ = utils_tooltip_with_accel (_ ("Export With Current Settings"), "<Control>e");
	_tmp28_ = (GtkButton*) gtk_button_new_with_label (_ ("Export…"));
	gtk_widget_set_halign ((GtkWidget*) _tmp28_, GTK_ALIGN_END);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp28_, _tmp27_);
	_g_free0 (_tmp27_);
	g_object_ref_sink (_tmp28_);
	export = _tmp28_;
	g_signal_connect_data (export, "clicked", (GCallback) ___lambda245__gtk_button_clicked, block21_data_ref (_data21_), (GClosureNotify) block21_data_unref, 0);
	_tmp29_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	g_object_ref_sink (_tmp29_);
	bbox = _tmp29_;
	gtk_box_append (bbox, (GtkWidget*) _data21_->mb);
	gtk_box_append (bbox, (GtkWidget*) export);
	_tmp30_ = self->priv->_stack;
	_tmp31_ = _g_object_ref0 ((GtkWidget*) _tmp30_);
	_tmp32_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_child (_tmp32_, _tmp31_);
	_g_object_unref0 (_tmp31_);
	g_object_ref_sink (_tmp32_);
	_g_object_unref0 (self->priv->_stack_reveal);
	self->priv->_stack_reveal = _tmp32_;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) bbox);
	_tmp33_ = self->priv->_stack_reveal;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp33_);
	_tmp34_ = main_window_get_settings (_data21_->win);
	_tmp35_ = _tmp34_;
	_tmp36_ = g_settings_get_string (_tmp35_, "last-export");
	last = _tmp36_;
	_tmp37_ = main_window_get_exports (_data21_->win);
	_tmp38_ = _tmp37_;
	gtk_drop_down_set_selected (_data21_->mb, (guint) exports_get_index_by_name (_tmp38_, last));
	_g_free0 (last);
	_g_object_unref0 (bbox);
	_g_object_unref0 (export);
	export_types = (_vala_array_free (export_types, export_types_length1, (GDestroyNotify) g_free), NULL);
	block21_data_unref (_data21_);
	_data21_ = NULL;
	return self;
}

Exporter*
exporter_new (MainWindow* win)
{
	return exporter_construct (TYPE_EXPORTER, win);
}

static void
exporter_handle_mb_change (Exporter* self,
                           Export* export)
{
	GtkStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkRevealer* _tmp3_;
	GSettings* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (export != NULL);
	_tmp0_ = self->priv->_stack;
	_tmp1_ = export_get_name (export);
	_tmp2_ = _tmp1_;
	gtk_stack_set_visible_child_name (_tmp0_, _tmp2_);
	_tmp3_ = self->priv->_stack_reveal;
	gtk_revealer_set_reveal_child (_tmp3_, export_settings_available (export));
	_tmp4_ = minder_settings;
	_tmp5_ = export_get_name (export);
	_tmp6_ = _tmp5_;
	g_settings_set_string (_tmp4_, "last-export", _tmp6_);
}

static void
exporter_add_export (Exporter* self,
                     MainWindow* win,
                     Export* export)
{
	GtkGrid* opts = NULL;
	GtkGrid* _tmp0_ = NULL;
	GtkLabel* label = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GtkLabel* _tmp5_ = NULL;
	GtkLabel* _tmp6_;
	GtkFrame* frame = NULL;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	GtkFrame* _tmp9_ = NULL;
	GtkStack* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	g_return_if_fail (export != NULL);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 5);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 5);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 5);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 5);
	gtk_grid_set_column_homogeneous (_tmp0_, TRUE);
	gtk_grid_set_row_spacing (_tmp0_, 5);
	gtk_grid_set_column_spacing (_tmp0_, 5);
	g_object_ref_sink (_tmp0_);
	opts = _tmp0_;
	export_add_all_settings (export, opts);
	_tmp1_ = g_strconcat ("<i>", _ ("Export Options"), NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "</i>", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = (GtkLabel*) gtk_label_new (_tmp4_);
	gtk_label_set_use_markup (_tmp5_, TRUE);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	label = _tmp6_;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) label);
	_tmp8_ = _g_object_ref0 ((GtkWidget*) opts);
	_tmp9_ = (GtkFrame*) gtk_frame_new (NULL);
	gtk_frame_set_label_widget (_tmp9_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	g_object_set (_tmp9_, "label-xalign", (gfloat) 0.5, NULL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 5);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp9_, 5);
	gtk_frame_set_child (_tmp9_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	frame = _tmp9_;
	_tmp10_ = self->priv->_stack;
	_tmp11_ = export_get_name (export);
	_tmp12_ = _tmp11_;
	gtk_stack_add_named (_tmp10_, (GtkWidget*) frame, _tmp12_);
	_g_object_unref0 (frame);
	_g_object_unref0 (label);
	_g_object_unref0 (opts);
}

static gpointer
_export_ref0 (gpointer self)
{
	return self ? export_ref (self) : NULL;
}

static Block22Data*
block22_data_ref (Block22Data* _data22_)
{
	g_atomic_int_inc (&_data22_->_ref_count_);
	return _data22_;
}

static void
block22_data_unref (void * _userdata_)
{
	Block22Data* _data22_;
	_data22_ = (Block22Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data22_->_ref_count_)) {
		Exporter* self;
		self = _data22_->self;
		_g_object_unref0 (_data22_->dialog);
		_g_object_unref0 (_data22_->win);
		_export_unref0 (_data22_->export);
		_g_object_unref0 (self);
		g_slice_free (Block22Data, _data22_);
	}
}

static void
__lambda246_ (Block22Data* _data22_,
              GObject* obj,
              GAsyncResult* res)
{
	Exporter* self;
	GError* _inner_error0_ = NULL;
	self = _data22_->self;
	g_return_if_fail (res != NULL);
	{
		GFile* file = NULL;
		GtkFileDialog* _tmp0_;
		GFile* _tmp1_;
		_tmp0_ = _data22_->dialog;
		_tmp1_ = gtk_file_dialog_save_finish (_tmp0_, res, &_inner_error0_);
		file = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (file != NULL) {
			gchar* fname = NULL;
			gchar* _tmp2_;
			const gchar* _tmp3_;
			gchar** _tmp4_;
			gint _tmp4__length1;
			gint _tmp5_ = 0;
			gchar** _tmp6_;
			gint _tmp6__length1;
			gchar* _tmp7_;
			const gchar* _tmp8_;
			MindMap* _tmp9_;
			MindMap* _tmp10_;
			const gchar* _tmp11_;
			_tmp2_ = g_file_get_path (file);
			fname = _tmp2_;
			_tmp3_ = fname;
			_tmp4_ = export_get_extensions (_data22_->export, &_tmp5_);
			_tmp4__length1 = _tmp5_;
			_tmp6_ = _tmp4_;
			_tmp6__length1 = _tmp4__length1;
			_tmp7_ = main_window_repair_filename (_data22_->win, _tmp3_, _tmp6_, (gint) _tmp6__length1);
			_g_free0 (fname);
			fname = _tmp7_;
			_tmp8_ = fname;
			_tmp9_ = main_window_get_current_map (_data22_->win, NULL);
			_tmp10_ = _tmp9_;
			export_export (_data22_->export, _tmp8_, _tmp10_);
			_mind_map_unref0 (_tmp10_);
			_tmp11_ = fname;
			main_window_notification (_data22_->win, _ ("Minder Export Completed"), _tmp11_, G_NOTIFICATION_PRIORITY_NORMAL);
			_g_free0 (fname);
		}
		_g_object_unref0 (file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static void
___lambda246__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda246_ (self, source_object, res);
	block22_data_unref (self);
}

void
exporter_do_export_to_file (Exporter* self,
                            MainWindow* win,
                            Export* export)
{
	Block22Data* _data22_;
	MainWindow* _tmp0_;
	Export* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GtkFileDialog* _tmp6_;
	GtkFileDialog* _tmp7_;
	gchar* default_fname = NULL;
	MindMap* _tmp8_;
	MindMap* _tmp9_;
	Document* _tmp10_;
	Document* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GtkFileDialog* _tmp16_;
	const gchar* _tmp17_;
	gchar** _tmp18_;
	gint _tmp18__length1;
	gint _tmp19_ = 0;
	gchar** _tmp20_;
	gint _tmp20__length1;
	gchar* _tmp21_;
	gchar* _tmp22_;
	GListStore* filters = NULL;
	GListStore* _tmp23_;
	GtkFileFilter* filter = NULL;
	GtkFileFilter* _tmp24_;
	GtkFileFilter* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	gint _tmp29_ = 0;
	gchar** _tmp30_;
	gint _tmp30__length1;
	GtkFileDialog* _tmp36_;
	GListStore* _tmp37_;
	GtkFileDialog* _tmp38_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	g_return_if_fail (export != NULL);
	_data22_ = g_slice_new0 (Block22Data);
	_data22_->_ref_count_ = 1;
	_data22_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (_data22_->win);
	_data22_->win = _tmp0_;
	_tmp1_ = _export_ref0 (export);
	_export_unref0 (_data22_->export);
	_data22_->export = _tmp1_;
	_tmp2_ = export_get_label (_data22_->export);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup_printf (_ ("Export As %s"), _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = utils_make_file_chooser (_tmp5_, _ ("Export"));
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_data22_->dialog = _tmp7_;
	_tmp8_ = main_window_get_current_map (_data22_->win, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = mind_map_get_doc (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = document_get_filename (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = utils_rootname (_tmp13_);
	_tmp15_ = _tmp14_;
	_mind_map_unref0 (_tmp9_);
	default_fname = _tmp15_;
	_tmp16_ = _data22_->dialog;
	_tmp17_ = default_fname;
	_tmp18_ = export_get_extensions (_data22_->export, &_tmp19_);
	_tmp18__length1 = _tmp19_;
	_tmp20_ = _tmp18_;
	_tmp20__length1 = _tmp18__length1;
	_tmp21_ = main_window_repair_filename (_data22_->win, _tmp17_, _tmp20_, (gint) _tmp20__length1);
	_tmp22_ = _tmp21_;
	gtk_file_dialog_set_initial_name (_tmp16_, _tmp22_);
	_g_free0 (_tmp22_);
	_tmp23_ = g_list_store_new (gtk_file_filter_get_type ());
	filters = _tmp23_;
	_tmp24_ = gtk_file_filter_new ();
	filter = _tmp24_;
	_tmp25_ = filter;
	_tmp26_ = export_get_label (_data22_->export);
	_tmp27_ = _tmp26_;
	gtk_file_filter_set_name (_tmp25_, _tmp27_);
	_tmp28_ = export_get_extensions (_data22_->export, &_tmp29_);
	_tmp28__length1 = _tmp29_;
	_tmp30_ = _tmp28_;
	_tmp30__length1 = _tmp28__length1;
	{
		gchar** extension_collection = NULL;
		gint extension_collection_length1 = 0;
		gint _extension_collection_size_ = 0;
		gint extension_it = 0;
		extension_collection = _tmp30_;
		extension_collection_length1 = _tmp30__length1;
		for (extension_it = 0; extension_it < extension_collection_length1; extension_it = extension_it + 1) {
			gchar* _tmp31_;
			gchar* extension = NULL;
			_tmp31_ = g_strdup (extension_collection[extension_it]);
			extension = _tmp31_;
			{
				GtkFileFilter* _tmp32_;
				const gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				_tmp32_ = filter;
				_tmp33_ = extension;
				_tmp34_ = g_strconcat ("*", _tmp33_, NULL);
				_tmp35_ = _tmp34_;
				gtk_file_filter_add_pattern (_tmp32_, _tmp35_);
				_g_free0 (_tmp35_);
				_g_free0 (extension);
			}
		}
	}
	_tmp36_ = _data22_->dialog;
	_tmp37_ = filters;
	gtk_file_dialog_set_filters (_tmp36_, (GListModel*) _tmp37_);
	_tmp38_ = _data22_->dialog;
	gtk_file_dialog_save (_tmp38_, (GtkWindow*) _data22_->win, NULL, ___lambda246__gasync_ready_callback, block22_data_ref (_data22_));
	_g_object_unref0 (filter);
	_g_object_unref0 (filters);
	_g_free0 (default_fname);
	block22_data_unref (_data22_);
	_data22_ = NULL;
}

void
exporter_do_export_to_clipboard (Exporter* self,
                                 MainWindow* win,
                                 Export* export)
{
	MindMap* _tmp0_;
	MindMap* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	g_return_if_fail (export != NULL);
	_tmp0_ = main_window_get_current_map (win, NULL);
	_tmp1_ = _tmp0_;
	export_export (export, "", _tmp1_);
	_mind_map_unref0 (_tmp1_);
	main_window_notification (win, _ ("Minder Export Completed"), _ ("Copied to clipboard"), G_NOTIFICATION_PRIORITY_NORMAL);
}

void
exporter_do_export (Exporter* self,
                    MainWindow* win)
{
	gchar* name = NULL;
	GtkStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	Export* export = NULL;
	Exports* _tmp4_;
	Exports* _tmp5_;
	const gchar* _tmp6_;
	Export* _tmp7_;
	MindMap* map = NULL;
	MindMap* _tmp8_;
	MindMap* _tmp9_;
	Export* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_stack_get_visible_child_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	name = _tmp3_;
	_tmp4_ = main_window_get_exports (win);
	_tmp5_ = _tmp4_;
	_tmp6_ = name;
	_tmp7_ = exports_get_by_name (_tmp5_, _tmp6_);
	export = _tmp7_;
	_tmp8_ = main_window_get_current_map (win, NULL);
	map = _tmp8_;
	_tmp9_ = map;
	mind_map_unedit_text (_tmp9_);
	_tmp10_ = export;
	if (export_send_to_clipboard (_tmp10_)) {
		Export* _tmp11_;
		_tmp11_ = export;
		exporter_do_export_to_clipboard (self, win, _tmp11_);
	} else {
		Export* _tmp12_;
		_tmp12_ = export;
		exporter_do_export_to_file (self, win, _tmp12_);
	}
	_mind_map_unref0 (map);
	_export_unref0 (export);
	_g_free0 (name);
}

static void
exporter_class_init (ExporterClass * klass,
                     gpointer klass_data)
{
	exporter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Exporter_private_offset);
	G_OBJECT_CLASS (klass)->finalize = exporter_finalize;
	exporter_signals[EXPORTER_EXPORT_DONE_SIGNAL] = g_signal_new ("export-done", TYPE_EXPORTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
exporter_instance_init (Exporter * self,
                        gpointer klass)
{
	self->priv = exporter_get_instance_private (self);
}

static void
exporter_finalize (GObject * obj)
{
	Exporter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EXPORTER, Exporter);
	_g_object_unref0 (self->priv->_stack_reveal);
	_g_object_unref0 (self->priv->_stack);
	G_OBJECT_CLASS (exporter_parent_class)->finalize (obj);
}

static GType
exporter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ExporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) exporter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Exporter), 0, (GInstanceInitFunc) exporter_instance_init, NULL };
	GType exporter_type_id;
	exporter_type_id = g_type_register_static (gtk_box_get_type (), "Exporter", &g_define_type_info, 0);
	Exporter_private_offset = g_type_add_instance_private (exporter_type_id, sizeof (ExporterPrivate));
	return exporter_type_id;
}

GType
exporter_get_type (void)
{
	static volatile gsize exporter_type_id__once = 0;
	if (g_once_init_enter (&exporter_type_id__once)) {
		GType exporter_type_id;
		exporter_type_id = exporter_get_type_once ();
		g_once_init_leave (&exporter_type_id__once, exporter_type_id);
	}
	return exporter_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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;
}

