/* SaveDialog.c generated by valac 0.56.17, the Vala compiler
 * generated from SaveDialog.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.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

#define BIRD_FONT_SAVE_DIALOG_question_font_size ((gdouble) 23)
#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_SAVE_DIALOG_0_PROPERTY,
	BIRD_FONT_SAVE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* bird_font_save_dialog_properties[BIRD_FONT_SAVE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block56Data Block56Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BirdFontSaveDialogPrivate {
	BirdFontSaveDialogListener* listener;
	BirdFontText* save_question;
	BirdFontButton* save_button;
	BirdFontButton* discard_button;
	BirdFontButton* cancel_button;
	gdouble width;
	gdouble height;
};

struct _Block56Data {
	int _ref_count_;
	BirdFontSaveDialog* self;
	BirdFontSaveDialogListener* callbacks;
};

static gint BirdFontSaveDialog_private_offset;
static gpointer bird_font_save_dialog_parent_class = NULL;

static Block56Data* block56_data_ref (Block56Data* _data56_);
static void block56_data_unref (void * _userdata_);
static void __lambda287_ (Block56Data* _data56_);
static void ___lambda287__bird_font_button_action (BirdFontButton* _sender,
                                            gpointer self);
static void __lambda288_ (Block56Data* _data56_);
static void ___lambda288__bird_font_button_action (BirdFontButton* _sender,
                                            gpointer self);
static void __lambda289_ (Block56Data* _data56_);
static void ___lambda289__bird_font_button_action (BirdFontButton* _sender,
                                            gpointer self);
static void bird_font_save_dialog_real_layout (BirdFontWidget* base);
static void bird_font_save_dialog_real_draw (BirdFontWidget* base,
                                      cairo_t* cr);
static void bird_font_save_dialog_real_button_press (BirdFontWidget* base,
                                              guint button,
                                              gdouble x,
                                              gdouble y);
static void bird_font_save_dialog_real_button_release (BirdFontWidget* base,
                                                guint button,
                                                gdouble x,
                                                gdouble y);
static void bird_font_save_dialog_finalize (GObject * obj);
static GType bird_font_save_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_save_dialog_get_instance_private (BirdFontSaveDialog* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontSaveDialog_private_offset);
}

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

static Block56Data*
block56_data_ref (Block56Data* _data56_)
{
	g_atomic_int_inc (&_data56_->_ref_count_);
	return _data56_;
}

static void
block56_data_unref (void * _userdata_)
{
	Block56Data* _data56_;
	_data56_ = (Block56Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data56_->_ref_count_)) {
		BirdFontSaveDialog* self;
		self = _data56_->self;
		_g_object_unref0 (_data56_->callbacks);
		_g_object_unref0 (self);
		g_slice_free (Block56Data, _data56_);
	}
}

static void
__lambda287_ (Block56Data* _data56_)
{
	BirdFontSaveDialog* self;
	self = _data56_->self;
	bird_font_main_window_hide_dialog ();
	g_signal_emit_by_name (_data56_->callbacks, "signal-save");
}

static void
___lambda287__bird_font_button_action (BirdFontButton* _sender,
                                       gpointer self)
{
	__lambda287_ (self);
}

static void
__lambda288_ (Block56Data* _data56_)
{
	BirdFontSaveDialog* self;
	self = _data56_->self;
	bird_font_main_window_hide_dialog ();
	g_signal_emit_by_name (_data56_->callbacks, "signal-discard");
}

static void
___lambda288__bird_font_button_action (BirdFontButton* _sender,
                                       gpointer self)
{
	__lambda288_ (self);
}

static void
__lambda289_ (Block56Data* _data56_)
{
	BirdFontSaveDialog* self;
	self = _data56_->self;
	bird_font_main_window_hide_dialog ();
	g_signal_emit_by_name (_data56_->callbacks, "signal-cancel");
}

static void
___lambda289__bird_font_button_action (BirdFontButton* _sender,
                                       gpointer self)
{
	__lambda289_ (self);
}

BirdFontSaveDialog*
bird_font_save_dialog_construct (GType object_type,
                                 BirdFontSaveDialogListener* callbacks)
{
	BirdFontSaveDialog * self = NULL;
	Block56Data* _data56_;
	BirdFontSaveDialogListener* _tmp0_;
	BirdFontSaveDialogListener* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	BirdFontText* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	BirdFontButton* _tmp7_;
	BirdFontButton* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	BirdFontButton* _tmp11_;
	BirdFontButton* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	BirdFontButton* _tmp15_;
	BirdFontButton* _tmp16_;
	g_return_val_if_fail (callbacks != NULL, NULL);
	_data56_ = g_slice_new0 (Block56Data);
	_data56_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (callbacks);
	_g_object_unref0 (_data56_->callbacks);
	_data56_->callbacks = _tmp0_;
	self = (BirdFontSaveDialog*) bird_font_dialog_construct (object_type);
	_data56_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data56_->callbacks);
	_g_object_unref0 (self->priv->listener);
	self->priv->listener = _tmp1_;
	_tmp2_ = bird_font_t_ ("Save changes?");
	_tmp3_ = _tmp2_;
	_tmp4_ = bird_font_text_new (_tmp3_, BIRD_FONT_SAVE_DIALOG_question_font_size, (gdouble) 0);
	_g_object_unref0 (self->priv->save_question);
	self->priv->save_question = _tmp4_;
	_g_free0 (_tmp3_);
	_tmp5_ = bird_font_t_ ("Save");
	_tmp6_ = _tmp5_;
	_tmp7_ = bird_font_button_new (_tmp6_, (gdouble) 0);
	_g_object_unref0 (self->priv->save_button);
	self->priv->save_button = _tmp7_;
	_g_free0 (_tmp6_);
	_tmp8_ = self->priv->save_button;
	g_signal_connect_data (_tmp8_, "action", (GCallback) ___lambda287__bird_font_button_action, block56_data_ref (_data56_), (GClosureNotify) block56_data_unref, 0);
	_tmp9_ = bird_font_t_ ("Discard");
	_tmp10_ = _tmp9_;
	_tmp11_ = bird_font_button_new (_tmp10_, (gdouble) 0);
	_g_object_unref0 (self->priv->discard_button);
	self->priv->discard_button = _tmp11_;
	_g_free0 (_tmp10_);
	_tmp12_ = self->priv->discard_button;
	g_signal_connect_data (_tmp12_, "action", (GCallback) ___lambda288__bird_font_button_action, block56_data_ref (_data56_), (GClosureNotify) block56_data_unref, 0);
	_tmp13_ = bird_font_t_ ("Cancel");
	_tmp14_ = _tmp13_;
	_tmp15_ = bird_font_button_new (_tmp14_, (gdouble) 0);
	_g_object_unref0 (self->priv->cancel_button);
	self->priv->cancel_button = _tmp15_;
	_g_free0 (_tmp14_);
	_tmp16_ = self->priv->cancel_button;
	g_signal_connect_data (_tmp16_, "action", (GCallback) ___lambda289__bird_font_button_action, block56_data_ref (_data56_), (GClosureNotify) block56_data_unref, 0);
	self->priv->height = (gdouble) 90;
	block56_data_unref (_data56_);
	_data56_ = NULL;
	return self;
}

BirdFontSaveDialog*
bird_font_save_dialog_new (BirdFontSaveDialogListener* callbacks)
{
	return bird_font_save_dialog_construct (BIRD_FONT_TYPE_SAVE_DIALOG, callbacks);
}

static void
bird_font_save_dialog_real_layout (BirdFontWidget* base)
{
	BirdFontSaveDialog * self;
	gdouble cx = 0.0;
	gdouble cy = 0.0;
	BirdFontWidgetAllocation* _tmp0_;
	gdouble center = 0.0;
	gdouble qh = 0.0;
	BirdFontButton* _tmp1_;
	BirdFontButton* _tmp2_;
	BirdFontButton* _tmp3_;
	BirdFontButton* _tmp4_;
	BirdFontButton* _tmp5_;
	BirdFontButton* _tmp6_;
	BirdFontWidgetAllocation* _tmp7_;
	BirdFontText* _tmp8_;
	BirdFontButton* _tmp9_;
	BirdFontText* _tmp10_;
	BirdFontText* _tmp11_;
	BirdFontButton* _tmp12_;
	BirdFontButton* _tmp13_;
	BirdFontButton* _tmp14_;
	BirdFontButton* _tmp15_;
	BirdFontButton* _tmp16_;
	BirdFontButton* _tmp17_;
	BirdFontButton* _tmp18_;
	BirdFontButton* _tmp19_;
	BirdFontButton* _tmp20_;
	self = (BirdFontSaveDialog*) base;
	cx = (gdouble) 0;
	_tmp0_ = ((BirdFontWidget*) self)->allocation;
	cy = (_tmp0_->height - self->priv->height) / 2.0;
	cx = (gdouble) 20;
	_tmp1_ = self->priv->save_button;
	((BirdFontWidget*) _tmp1_)->widget_x = cx;
	_tmp2_ = self->priv->save_button;
	cx += 10 + bird_font_widget_get_width ((BirdFontWidget*) _tmp2_);
	_tmp3_ = self->priv->discard_button;
	((BirdFontWidget*) _tmp3_)->widget_x = cx;
	_tmp4_ = self->priv->discard_button;
	cx += 10 + bird_font_widget_get_width ((BirdFontWidget*) _tmp4_);
	_tmp5_ = self->priv->cancel_button;
	((BirdFontWidget*) _tmp5_)->widget_x = cx;
	_tmp6_ = self->priv->cancel_button;
	self->priv->width = (cx + 20) + bird_font_widget_get_width ((BirdFontWidget*) _tmp6_);
	_tmp7_ = ((BirdFontWidget*) self)->allocation;
	center = (_tmp7_->width - self->priv->width) / 2.0;
	_tmp8_ = self->priv->save_question;
	_tmp9_ = self->priv->save_button;
	((BirdFontWidget*) _tmp8_)->widget_x = ((BirdFontWidget*) _tmp9_)->widget_x + center;
	_tmp10_ = self->priv->save_question;
	((BirdFontWidget*) _tmp10_)->widget_y = cy + 15;
	_tmp11_ = self->priv->save_question;
	bird_font_theme_text_color (_tmp11_, "Text Tool Box");
	qh = BIRD_FONT_SAVE_DIALOG_question_font_size + 1;
	_tmp12_ = self->priv->save_button;
	_tmp13_ = self->priv->save_button;
	((BirdFontWidget*) _tmp13_)->widget_x = ((BirdFontWidget*) _tmp13_)->widget_x + center;
	_tmp14_ = self->priv->save_button;
	((BirdFontWidget*) _tmp14_)->widget_y = (cy + qh) + 25;
	_tmp15_ = self->priv->discard_button;
	_tmp16_ = self->priv->discard_button;
	((BirdFontWidget*) _tmp16_)->widget_x = ((BirdFontWidget*) _tmp16_)->widget_x + center;
	_tmp17_ = self->priv->discard_button;
	((BirdFontWidget*) _tmp17_)->widget_y = (cy + qh) + 25;
	_tmp18_ = self->priv->cancel_button;
	_tmp19_ = self->priv->cancel_button;
	((BirdFontWidget*) _tmp19_)->widget_x = ((BirdFontWidget*) _tmp19_)->widget_x + center;
	_tmp20_ = self->priv->cancel_button;
	((BirdFontWidget*) _tmp20_)->widget_y = (cy + qh) + 25;
}

static void
bird_font_save_dialog_real_draw (BirdFontWidget* base,
                                 cairo_t* cr)
{
	BirdFontSaveDialog * self;
	gdouble cx = 0.0;
	gdouble cy = 0.0;
	BirdFontWidgetAllocation* _tmp0_;
	BirdFontWidgetAllocation* _tmp1_;
	BirdFontWidgetAllocation* _tmp2_;
	BirdFontWidgetAllocation* _tmp3_;
	BirdFontText* _tmp4_;
	BirdFontButton* _tmp5_;
	BirdFontButton* _tmp6_;
	BirdFontButton* _tmp7_;
	self = (BirdFontSaveDialog*) base;
	g_return_if_fail (cr != NULL);
	bird_font_widget_layout ((BirdFontWidget*) self);
	_tmp0_ = ((BirdFontWidget*) self)->allocation;
	cx = (_tmp0_->width - self->priv->width) / 2.0;
	_tmp1_ = ((BirdFontWidget*) self)->allocation;
	cy = (_tmp1_->height - self->priv->height) / 2.0;
	cairo_save (cr);
	bird_font_theme_color (cr, "Dialog Shadow");
	_tmp2_ = ((BirdFontWidget*) self)->allocation;
	_tmp3_ = ((BirdFontWidget*) self)->allocation;
	cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp2_->width, (gdouble) _tmp3_->height);
	cairo_fill (cr);
	cairo_restore (cr);
	cairo_save (cr);
	bird_font_theme_color (cr, "Dialog Background");
	bird_font_widget_draw_rounded_rectangle (cr, cx, cy, self->priv->width, self->priv->height, (gdouble) 10);
	cairo_fill (cr);
	cairo_restore (cr);
	cairo_save (cr);
	bird_font_theme_color (cr, "Button Border 4");
	cairo_set_line_width (cr, (gdouble) 1);
	bird_font_widget_draw_rounded_rectangle (cr, cx, cy, self->priv->width, self->priv->height, (gdouble) 10);
	cairo_stroke (cr);
	cairo_restore (cr);
	_tmp4_ = self->priv->save_question;
	bird_font_widget_draw ((BirdFontWidget*) _tmp4_, cr);
	_tmp5_ = self->priv->save_button;
	bird_font_widget_draw ((BirdFontWidget*) _tmp5_, cr);
	_tmp6_ = self->priv->discard_button;
	bird_font_widget_draw ((BirdFontWidget*) _tmp6_, cr);
	_tmp7_ = self->priv->cancel_button;
	bird_font_widget_draw ((BirdFontWidget*) _tmp7_, cr);
}

static void
bird_font_save_dialog_real_button_press (BirdFontWidget* base,
                                         guint button,
                                         gdouble x,
                                         gdouble y)
{
	BirdFontSaveDialog * self;
	BirdFontButton* _tmp0_;
	BirdFontButton* _tmp1_;
	BirdFontButton* _tmp2_;
	self = (BirdFontSaveDialog*) base;
	_tmp0_ = self->priv->save_button;
	bird_font_widget_button_press ((BirdFontWidget*) _tmp0_, button, x, y);
	_tmp1_ = self->priv->discard_button;
	bird_font_widget_button_press ((BirdFontWidget*) _tmp1_, button, x, y);
	_tmp2_ = self->priv->cancel_button;
	bird_font_widget_button_press ((BirdFontWidget*) _tmp2_, button, x, y);
}

static void
bird_font_save_dialog_real_button_release (BirdFontWidget* base,
                                           guint button,
                                           gdouble x,
                                           gdouble y)
{
	BirdFontSaveDialog * self;
	BirdFontButton* _tmp0_;
	BirdFontButton* _tmp1_;
	BirdFontButton* _tmp2_;
	self = (BirdFontSaveDialog*) base;
	_tmp0_ = self->priv->save_button;
	bird_font_widget_button_release ((BirdFontWidget*) _tmp0_, button, x, y);
	_tmp1_ = self->priv->discard_button;
	bird_font_widget_button_release ((BirdFontWidget*) _tmp1_, button, x, y);
	_tmp2_ = self->priv->cancel_button;
	bird_font_widget_button_release ((BirdFontWidget*) _tmp2_, button, x, y);
}

static void
bird_font_save_dialog_class_init (BirdFontSaveDialogClass * klass,
                                  gpointer klass_data)
{
	bird_font_save_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontSaveDialog_private_offset);
	((BirdFontWidgetClass *) klass)->layout = (void (*) (BirdFontWidget*)) bird_font_save_dialog_real_layout;
	((BirdFontWidgetClass *) klass)->draw = (void (*) (BirdFontWidget*, cairo_t*)) bird_font_save_dialog_real_draw;
	((BirdFontWidgetClass *) klass)->button_press = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_save_dialog_real_button_press;
	((BirdFontWidgetClass *) klass)->button_release = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_save_dialog_real_button_release;
	G_OBJECT_CLASS (klass)->finalize = bird_font_save_dialog_finalize;
}

static void
bird_font_save_dialog_instance_init (BirdFontSaveDialog * self,
                                     gpointer klass)
{
	self->priv = bird_font_save_dialog_get_instance_private (self);
	self->priv->width = (gdouble) 0;
}

static void
bird_font_save_dialog_finalize (GObject * obj)
{
	BirdFontSaveDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_SAVE_DIALOG, BirdFontSaveDialog);
	_g_object_unref0 (self->priv->listener);
	_g_object_unref0 (self->priv->save_question);
	_g_object_unref0 (self->priv->save_button);
	_g_object_unref0 (self->priv->discard_button);
	_g_object_unref0 (self->priv->cancel_button);
	G_OBJECT_CLASS (bird_font_save_dialog_parent_class)->finalize (obj);
}

static GType
bird_font_save_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontSaveDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_save_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontSaveDialog), 0, (GInstanceInitFunc) bird_font_save_dialog_instance_init, NULL };
	GType bird_font_save_dialog_type_id;
	bird_font_save_dialog_type_id = g_type_register_static (BIRD_FONT_TYPE_DIALOG, "BirdFontSaveDialog", &g_define_type_info, 0);
	BirdFontSaveDialog_private_offset = g_type_add_instance_private (bird_font_save_dialog_type_id, sizeof (BirdFontSaveDialogPrivate));
	return bird_font_save_dialog_type_id;
}

GType
bird_font_save_dialog_get_type (void)
{
	static volatile gsize bird_font_save_dialog_type_id__once = 0;
	if (g_once_init_enter (&bird_font_save_dialog_type_id__once)) {
		GType bird_font_save_dialog_type_id;
		bird_font_save_dialog_type_id = bird_font_save_dialog_get_type_once ();
		g_once_init_leave (&bird_font_save_dialog_type_id__once, bird_font_save_dialog_type_id);
	}
	return bird_font_save_dialog_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;
}

