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

/*
Copyright (C) 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 <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>

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

enum  {
	BIRD_FONT_OVERWRITE_BF_FILE_0_PROPERTY,
	BIRD_FONT_OVERWRITE_BF_FILE_NUM_PROPERTIES
};
static GParamSpec* bird_font_overwrite_bf_file_properties[BIRD_FONT_OVERWRITE_BF_FILE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block41Data Block41Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BirdFontOverwriteBfFilePrivate {
	BirdFontButton* replace;
	BirdFontButton* cancel;
};

struct _Block41Data {
	int _ref_count_;
	BirdFontOverwriteBfFile* self;
	BirdFontSaveCallback* save_callback;
};

static gint BirdFontOverwriteBfFile_private_offset;
static gpointer bird_font_overwrite_bf_file_parent_class = NULL;

static Block41Data* block41_data_ref (Block41Data* _data41_);
static void block41_data_unref (void * _userdata_);
static void __lambda382_ (Block41Data* _data41_);
static void ___lambda382__bird_font_button_action (BirdFontButton* _sender,
                                            gpointer self);
static void __lambda383_ (Block41Data* _data41_);
static void ___lambda383__bird_font_button_action (BirdFontButton* _sender,
                                            gpointer self);
static void bird_font_overwrite_bf_file_finalize (GObject * obj);
static GType bird_font_overwrite_bf_file_get_type_once (void);

static inline gpointer
bird_font_overwrite_bf_file_get_instance_private (BirdFontOverwriteBfFile* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontOverwriteBfFile_private_offset);
}

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

static Block41Data*
block41_data_ref (Block41Data* _data41_)
{
	g_atomic_int_inc (&_data41_->_ref_count_);
	return _data41_;
}

static void
block41_data_unref (void * _userdata_)
{
	Block41Data* _data41_;
	_data41_ = (Block41Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data41_->_ref_count_)) {
		BirdFontOverwriteBfFile* self;
		self = _data41_->self;
		_g_object_unref0 (_data41_->save_callback);
		_g_object_unref0 (self);
		g_slice_free (Block41Data, _data41_);
	}
}

static void
__lambda382_ (Block41Data* _data41_)
{
	BirdFontOverwriteBfFile* self;
	self = _data41_->self;
	bird_font_main_window_hide_dialog ();
	bird_font_save_callback_save (_data41_->save_callback);
}

static void
___lambda382__bird_font_button_action (BirdFontButton* _sender,
                                       gpointer self)
{
	__lambda382_ (self);
}

static void
__lambda383_ (Block41Data* _data41_)
{
	BirdFontOverwriteBfFile* self;
	self = _data41_->self;
	_data41_->save_callback->is_done = TRUE;
	bird_font_main_window_hide_dialog ();
}

static void
___lambda383__bird_font_button_action (BirdFontButton* _sender,
                                       gpointer self)
{
	__lambda383_ (self);
}

BirdFontOverwriteBfFile*
bird_font_overwrite_bf_file_construct (GType object_type,
                                       BirdFontSaveCallback* save_callback)
{
	BirdFontOverwriteBfFile * self = NULL;
	Block41Data* _data41_;
	BirdFontSaveCallback* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	BirdFontButton* _tmp5_;
	BirdFontButton* _tmp6_;
	BirdFontButton* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	BirdFontButton* _tmp10_;
	BirdFontButton* _tmp11_;
	BirdFontButton* _tmp12_;
	g_return_val_if_fail (save_callback != NULL, NULL);
	_data41_ = g_slice_new0 (Block41Data);
	_data41_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (save_callback);
	_g_object_unref0 (_data41_->save_callback);
	_data41_->save_callback = _tmp0_;
	_tmp1_ = bird_font_t_ ("This file already exists. Do you want to replace it?");
	_tmp2_ = _tmp1_;
	self = (BirdFontOverwriteBfFile*) bird_font_question_dialog_construct (object_type, _tmp2_);
	_data41_->self = g_object_ref (self);
	_g_free0 (_tmp2_);
	_tmp3_ = bird_font_t_ ("Replace");
	_tmp4_ = _tmp3_;
	_tmp5_ = bird_font_button_new (_tmp4_, (gdouble) 0);
	_g_object_unref0 (self->priv->replace);
	self->priv->replace = _tmp5_;
	_g_free0 (_tmp4_);
	_tmp6_ = self->priv->replace;
	g_signal_connect_data (_tmp6_, "action", (GCallback) ___lambda382__bird_font_button_action, block41_data_ref (_data41_), (GClosureNotify) block41_data_unref, 0);
	_tmp7_ = self->priv->replace;
	bird_font_question_dialog_add_button ((BirdFontQuestionDialog*) self, _tmp7_);
	_tmp8_ = bird_font_t_ ("Cancel");
	_tmp9_ = _tmp8_;
	_tmp10_ = bird_font_button_new (_tmp9_, (gdouble) 0);
	_g_object_unref0 (self->priv->cancel);
	self->priv->cancel = _tmp10_;
	_g_free0 (_tmp9_);
	_tmp11_ = self->priv->cancel;
	g_signal_connect_data (_tmp11_, "action", (GCallback) ___lambda383__bird_font_button_action, block41_data_ref (_data41_), (GClosureNotify) block41_data_unref, 0);
	_tmp12_ = self->priv->cancel;
	bird_font_question_dialog_add_button ((BirdFontQuestionDialog*) self, _tmp12_);
	block41_data_unref (_data41_);
	_data41_ = NULL;
	return self;
}

BirdFontOverwriteBfFile*
bird_font_overwrite_bf_file_new (BirdFontSaveCallback* save_callback)
{
	return bird_font_overwrite_bf_file_construct (BIRD_FONT_TYPE_OVERWRITE_BF_FILE, save_callback);
}

static void
bird_font_overwrite_bf_file_class_init (BirdFontOverwriteBfFileClass * klass,
                                        gpointer klass_data)
{
	bird_font_overwrite_bf_file_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontOverwriteBfFile_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_overwrite_bf_file_finalize;
}

static void
bird_font_overwrite_bf_file_instance_init (BirdFontOverwriteBfFile * self,
                                           gpointer klass)
{
	self->priv = bird_font_overwrite_bf_file_get_instance_private (self);
}

static void
bird_font_overwrite_bf_file_finalize (GObject * obj)
{
	BirdFontOverwriteBfFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_OVERWRITE_BF_FILE, BirdFontOverwriteBfFile);
	_g_object_unref0 (self->priv->replace);
	_g_object_unref0 (self->priv->cancel);
	G_OBJECT_CLASS (bird_font_overwrite_bf_file_parent_class)->finalize (obj);
}

static GType
bird_font_overwrite_bf_file_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontOverwriteBfFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_overwrite_bf_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontOverwriteBfFile), 0, (GInstanceInitFunc) bird_font_overwrite_bf_file_instance_init, NULL };
	GType bird_font_overwrite_bf_file_type_id;
	bird_font_overwrite_bf_file_type_id = g_type_register_static (BIRD_FONT_TYPE_QUESTION_DIALOG, "BirdFontOverwriteBfFile", &g_define_type_info, 0);
	BirdFontOverwriteBfFile_private_offset = g_type_add_instance_private (bird_font_overwrite_bf_file_type_id, sizeof (BirdFontOverwriteBfFilePrivate));
	return bird_font_overwrite_bf_file_type_id;
}

GType
bird_font_overwrite_bf_file_get_type (void)
{
	static volatile gsize bird_font_overwrite_bf_file_type_id__once = 0;
	if (g_once_init_enter (&bird_font_overwrite_bf_file_type_id__once)) {
		GType bird_font_overwrite_bf_file_type_id;
		bird_font_overwrite_bf_file_type_id = bird_font_overwrite_bf_file_get_type_once ();
		g_once_init_leave (&bird_font_overwrite_bf_file_type_id__once, bird_font_overwrite_bf_file_type_id);
	}
	return bird_font_overwrite_bf_file_type_id__once;
}

