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

/*
Copyright (C) 2014 Johan Mattsson

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

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	BIRD_FONT_EXPORT_CALLBACK_0_PROPERTY,
	BIRD_FONT_EXPORT_CALLBACK_NUM_PROPERTIES
};
static GParamSpec* bird_font_export_callback_properties[BIRD_FONT_EXPORT_CALLBACK_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	BIRD_FONT_EXPORT_CALLBACK_FILE_EXPORTED_SIGNAL,
	BIRD_FONT_EXPORT_CALLBACK_NUM_SIGNALS
};
static guint bird_font_export_callback_signals[BIRD_FONT_EXPORT_CALLBACK_NUM_SIGNALS] = {0};

static gpointer bird_font_export_callback_parent_class = NULL;

static void ___lambda210_ (BirdFontExportCallback* self);
static void ____lambda210__bird_font_save_callback_file_saved (BirdFontSaveCallback* _sender,
                                                        gpointer self);
static void bird_font_export_callback_finalize (GObject * obj);
static GType bird_font_export_callback_get_type_once (void);

BirdFontExportCallback*
bird_font_export_callback_construct (GType object_type)
{
	BirdFontExportCallback * self = NULL;
	self = (BirdFontExportCallback*) g_object_new (object_type, NULL);
	return self;
}

BirdFontExportCallback*
bird_font_export_callback_new (void)
{
	return bird_font_export_callback_construct (BIRD_FONT_TYPE_EXPORT_CALLBACK);
}

static void
___lambda210_ (BirdFontExportCallback* self)
{
	BirdFontNativeWindow* _tmp0_;
	_tmp0_ = bird_font_main_window_native_window;
	bird_font_native_window_export_font (_tmp0_);
}

static void
____lambda210__bird_font_save_callback_file_saved (BirdFontSaveCallback* _sender,
                                                   gpointer self)
{
	___lambda210_ ((BirdFontExportCallback*) self);
}

void
bird_font_export_callback_export_fonts_in_background (BirdFontExportCallback* self)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	BirdFontNativeWindow* _tmp1_;
	BirdFontFont* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_main_window_native_window;
	if (!bird_font_native_window_can_export (_tmp1_)) {
		_g_object_unref0 (font);
		return;
	}
	_tmp2_ = font;
	_tmp3_ = _tmp2_->font_file;
	if (_tmp3_ == NULL) {
		BirdFontSaveCallback* _tmp4_;
		BirdFontSaveCallback* _tmp5_;
		BirdFontSaveCallback* _tmp6_;
		BirdFontSaveCallback* _tmp7_;
		_tmp4_ = bird_font_save_callback_new ();
		_tmp5_ = _tmp4_;
		bird_font_menu_tab_set_save_callback (_tmp5_);
		_g_object_unref0 (_tmp5_);
		_tmp6_ = bird_font_menu_tab_save_callback;
		g_signal_connect_object (_tmp6_, "file-saved", (GCallback) ____lambda210__bird_font_save_callback_file_saved, self, 0);
		_tmp7_ = bird_font_menu_tab_save_callback;
		bird_font_save_callback_save (_tmp7_);
	} else {
		BirdFontNativeWindow* _tmp8_;
		_tmp8_ = bird_font_main_window_native_window;
		bird_font_native_window_export_font (_tmp8_);
	}
	_g_object_unref0 (font);
}

/** Export TTF, EOT and SVG fonts. */
void
bird_font_export_callback_export_fonts (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gboolean _tmp1_ = FALSE;
	BirdFontFont* _tmp2_;
	BirdFontFont* _tmp4_;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp2_ = font;
	if (bird_font_export_settings_export_ttf_setting (_tmp2_)) {
		_tmp1_ = TRUE;
	} else {
		BirdFontFont* _tmp3_;
		_tmp3_ = font;
		_tmp1_ = bird_font_export_settings_export_eot_setting (_tmp3_);
	}
	if (_tmp1_) {
		bird_font_export_tool_export_ttf_font ();
	}
	_tmp4_ = font;
	if (bird_font_export_settings_export_svg_setting (_tmp4_)) {
		bird_font_export_tool_export_svg_font ();
	}
	_g_object_unref0 (font);
}

static void
bird_font_export_callback_class_init (BirdFontExportCallbackClass * klass,
                                      gpointer klass_data)
{
	bird_font_export_callback_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_export_callback_finalize;
	bird_font_export_callback_signals[BIRD_FONT_EXPORT_CALLBACK_FILE_EXPORTED_SIGNAL] = g_signal_new ("file-exported", BIRD_FONT_TYPE_EXPORT_CALLBACK, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
bird_font_export_callback_instance_init (BirdFontExportCallback * self,
                                         gpointer klass)
{
	self->preview = FALSE;
}

static void
bird_font_export_callback_finalize (GObject * obj)
{
	BirdFontExportCallback * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_EXPORT_CALLBACK, BirdFontExportCallback);
	G_OBJECT_CLASS (bird_font_export_callback_parent_class)->finalize (obj);
}

static GType
bird_font_export_callback_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontExportCallbackClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_export_callback_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontExportCallback), 0, (GInstanceInitFunc) bird_font_export_callback_instance_init, NULL };
	GType bird_font_export_callback_type_id;
	bird_font_export_callback_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontExportCallback", &g_define_type_info, 0);
	return bird_font_export_callback_type_id;
}

GType
bird_font_export_callback_get_type (void)
{
	static volatile gsize bird_font_export_callback_type_id__once = 0;
	if (g_once_init_enter (&bird_font_export_callback_type_id__once)) {
		GType bird_font_export_callback_type_id;
		bird_font_export_callback_type_id = bird_font_export_callback_get_type_once ();
		g_once_init_leave (&bird_font_export_callback_type_id__once, bird_font_export_callback_type_id);
	}
	return bird_font_export_callback_type_id__once;
}

