/* MessageDialog.c generated by valac 0.56.17, the Vala compiler
 * generated from MessageDialog.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 <cairo-gobject.h>
#include <glib.h>
#include <float.h>
#include <math.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_MESSAGE_DIALOG_0_PROPERTY,
	BIRD_FONT_MESSAGE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* bird_font_message_dialog_properties[BIRD_FONT_MESSAGE_DIALOG_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 _bird_font_color_unref0(var) ((var == NULL) ? NULL : (var = (bird_font_color_unref (var), NULL)))
enum  {
	BIRD_FONT_MESSAGE_DIALOG_CLOSE_SIGNAL,
	BIRD_FONT_MESSAGE_DIALOG_NUM_SIGNALS
};
static guint bird_font_message_dialog_signals[BIRD_FONT_MESSAGE_DIALOG_NUM_SIGNALS] = {0};

struct _BirdFontMessageDialogPrivate {
	BirdFontTextArea* message;
};

static gint BirdFontMessageDialog_private_offset;
static gpointer bird_font_message_dialog_parent_class = NULL;

static void _bird_font_message_dialog_close_action_bird_font_button_action (BirdFontButton* _sender,
                                                                     gpointer self);
static void bird_font_message_dialog_real_draw (BirdFontWidget* base,
                                         cairo_t* cr);
static void bird_font_message_dialog_real_button_press (BirdFontWidget* base,
                                                 guint button,
                                                 gdouble x,
                                                 gdouble y);
static void bird_font_message_dialog_real_button_release (BirdFontWidget* base,
                                                   guint button,
                                                   gdouble x,
                                                   gdouble y);
static void bird_font_message_dialog_finalize (GObject * obj);
static GType bird_font_message_dialog_get_type_once (void);

static inline gpointer
bird_font_message_dialog_get_instance_private (BirdFontMessageDialog* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontMessageDialog_private_offset);
}

static void
_bird_font_message_dialog_close_action_bird_font_button_action (BirdFontButton* _sender,
                                                                gpointer self)
{
	bird_font_message_dialog_close_action ((BirdFontMessageDialog*) self);
}

BirdFontMessageDialog*
bird_font_message_dialog_construct (GType object_type,
                                    const gchar* message)
{
	BirdFontMessageDialog * self = NULL;
	BirdFontColor* c = NULL;
	BirdFontColor* _tmp0_;
	BirdFontTextArea* _tmp1_;
	BirdFontTextArea* _tmp2_;
	BirdFontTextArea* _tmp3_;
	BirdFontTextArea* _tmp4_;
	BirdFontTextArea* _tmp5_;
	BirdFontTextArea* _tmp6_;
	BirdFontTextArea* _tmp7_;
	BirdFontTextArea* _tmp8_;
	BirdFontTextArea* _tmp9_;
	BirdFontTextArea* _tmp10_;
	BirdFontTextArea* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	BirdFontButton* _tmp14_;
	BirdFontButton* _tmp15_;
	g_return_val_if_fail (message != NULL, NULL);
	self = (BirdFontMessageDialog*) bird_font_dialog_construct (object_type);
	_tmp0_ = bird_font_theme_get_color ("Text Tool Box");
	c = _tmp0_;
	_tmp1_ = bird_font_text_area_new ((gdouble) 20, c);
	_g_object_unref0 (self->priv->message);
	self->priv->message = _tmp1_;
	_tmp2_ = self->priv->message;
	bird_font_text_area_set_text (_tmp2_, message);
	_tmp3_ = self->priv->message;
	_tmp3_->draw_border = FALSE;
	_tmp4_ = self->priv->message;
	_tmp4_->editable = FALSE;
	_tmp5_ = self->priv->message;
	_tmp5_->carret_is_visible = FALSE;
	_tmp6_ = self->priv->message;
	_tmp6_->min_width = (gdouble) 300;
	_tmp7_ = self->priv->message;
	_tmp8_ = self->priv->message;
	_tmp7_->width = _tmp8_->min_width;
	_tmp9_ = self->priv->message;
	_tmp9_->min_height = (gdouble) 20;
	_tmp10_ = self->priv->message;
	_tmp11_ = self->priv->message;
	_tmp10_->height = _tmp11_->min_height;
	_tmp12_ = bird_font_t_ ("Close");
	_tmp13_ = _tmp12_;
	_tmp14_ = bird_font_button_new (_tmp13_, (gdouble) 0);
	_g_object_unref0 (self->ok_button);
	self->ok_button = _tmp14_;
	_g_free0 (_tmp13_);
	_tmp15_ = self->ok_button;
	g_signal_connect_object (_tmp15_, "action", (GCallback) _bird_font_message_dialog_close_action_bird_font_button_action, self, 0);
	_bird_font_color_unref0 (c);
	return self;
}

BirdFontMessageDialog*
bird_font_message_dialog_new (const gchar* message)
{
	return bird_font_message_dialog_construct (BIRD_FONT_TYPE_MESSAGE_DIALOG, message);
}

void
bird_font_message_dialog_close_action (BirdFontMessageDialog* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, bird_font_message_dialog_signals[BIRD_FONT_MESSAGE_DIALOG_CLOSE_SIGNAL], 0);
	bird_font_main_window_hide_dialog ();
}

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

static void
bird_font_message_dialog_real_draw (BirdFontWidget* base,
                                    cairo_t* cr)
{
	BirdFontMessageDialog * self;
	gdouble cx = 0.0;
	gdouble cy = 0.0;
	gdouble width = 0.0;
	gdouble height = 0.0;
	BirdFontTextArea* _tmp0_;
	BirdFontTextArea* _tmp1_;
	BirdFontTextArea* _tmp2_;
	BirdFontButton* _tmp3_;
	BirdFontWidgetAllocation* _tmp4_;
	BirdFontWidgetAllocation* _tmp5_;
	BirdFontWidgetAllocation* _tmp6_;
	BirdFontWidgetAllocation* _tmp7_;
	BirdFontTextArea* _tmp8_;
	BirdFontTextArea* _tmp9_;
	BirdFontTextArea* _tmp10_;
	BirdFontWidgetAllocation* _tmp11_;
	BirdFontWidgetAllocation* _tmp12_;
	BirdFontTextArea* _tmp13_;
	BirdFontTextArea* _tmp14_;
	BirdFontButton* _tmp15_;
	BirdFontButton* _tmp16_;
	BirdFontTextArea* _tmp17_;
	BirdFontButton* _tmp18_;
	self = (BirdFontMessageDialog*) base;
	g_return_if_fail (cr != NULL);
	_tmp0_ = self->priv->message;
	bird_font_widget_layout ((BirdFontWidget*) _tmp0_);
	_tmp1_ = self->priv->message;
	width = bird_font_widget_get_width ((BirdFontWidget*) _tmp1_);
	width += (gdouble) 10;
	_tmp2_ = self->priv->message;
	height = bird_font_widget_get_height ((BirdFontWidget*) _tmp2_);
	_tmp3_ = self->ok_button;
	height += bird_font_widget_get_height ((BirdFontWidget*) _tmp3_);
	height += (gdouble) 5;
	_tmp4_ = ((BirdFontWidget*) self)->allocation;
	cx = (_tmp4_->width - width) / 2.0;
	_tmp5_ = ((BirdFontWidget*) self)->allocation;
	cy = (_tmp5_->height - height) / 2.0;
	cairo_save (cr);
	bird_font_theme_color_opacity (cr, "Foreground 1", 0.3);
	_tmp6_ = ((BirdFontWidget*) self)->allocation;
	_tmp7_ = ((BirdFontWidget*) self)->allocation;
	cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) _tmp6_->width, (gdouble) _tmp7_->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, width, height, (gdouble) 10);
	cairo_fill (cr);
	cairo_restore (cr);
	cairo_save (cr);
	bird_font_theme_color (cr, "Foreground 1");
	cairo_set_line_width (cr, (gdouble) 1);
	bird_font_widget_draw_rounded_rectangle (cr, cx, cy, width, height, (gdouble) 10);
	cairo_stroke (cr);
	cairo_restore (cr);
	cy += (gdouble) 5;
	_tmp8_ = self->priv->message;
	((BirdFontWidget*) _tmp8_)->widget_x = cx + 10;
	_tmp9_ = self->priv->message;
	((BirdFontWidget*) _tmp9_)->widget_y = cy;
	_tmp10_ = self->priv->message;
	_tmp11_ = ((BirdFontWidget*) self)->allocation;
	_tmp12_ = _g_object_ref0 (_tmp11_);
	_g_object_unref0 (((BirdFontWidget*) _tmp10_)->allocation);
	((BirdFontWidget*) _tmp10_)->allocation = _tmp12_;
	_tmp13_ = self->priv->message;
	bird_font_widget_layout ((BirdFontWidget*) _tmp13_);
	_tmp14_ = self->priv->message;
	bird_font_widget_draw ((BirdFontWidget*) _tmp14_, cr);
	_tmp15_ = self->ok_button;
	((BirdFontWidget*) _tmp15_)->widget_x = cx + 10;
	_tmp16_ = self->ok_button;
	_tmp17_ = self->priv->message;
	((BirdFontWidget*) _tmp16_)->widget_y = cy + bird_font_widget_get_height ((BirdFontWidget*) _tmp17_);
	_tmp18_ = self->ok_button;
	bird_font_widget_draw ((BirdFontWidget*) _tmp18_, cr);
}

static void
bird_font_message_dialog_real_button_press (BirdFontWidget* base,
                                            guint button,
                                            gdouble x,
                                            gdouble y)
{
	BirdFontMessageDialog * self;
	BirdFontButton* _tmp0_;
	self = (BirdFontMessageDialog*) base;
	_tmp0_ = self->ok_button;
	bird_font_widget_button_press ((BirdFontWidget*) _tmp0_, button, x, y);
}

static void
bird_font_message_dialog_real_button_release (BirdFontWidget* base,
                                              guint button,
                                              gdouble x,
                                              gdouble y)
{
	BirdFontMessageDialog * self;
	BirdFontButton* _tmp0_;
	self = (BirdFontMessageDialog*) base;
	_tmp0_ = self->ok_button;
	bird_font_widget_button_release ((BirdFontWidget*) _tmp0_, button, x, y);
}

static void
bird_font_message_dialog_class_init (BirdFontMessageDialogClass * klass,
                                     gpointer klass_data)
{
	bird_font_message_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontMessageDialog_private_offset);
	((BirdFontWidgetClass *) klass)->draw = (void (*) (BirdFontWidget*, cairo_t*)) bird_font_message_dialog_real_draw;
	((BirdFontWidgetClass *) klass)->button_press = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_message_dialog_real_button_press;
	((BirdFontWidgetClass *) klass)->button_release = (void (*) (BirdFontWidget*, guint, gdouble, gdouble)) bird_font_message_dialog_real_button_release;
	G_OBJECT_CLASS (klass)->finalize = bird_font_message_dialog_finalize;
	bird_font_message_dialog_signals[BIRD_FONT_MESSAGE_DIALOG_CLOSE_SIGNAL] = g_signal_new ("close", BIRD_FONT_TYPE_MESSAGE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
bird_font_message_dialog_instance_init (BirdFontMessageDialog * self,
                                        gpointer klass)
{
	self->priv = bird_font_message_dialog_get_instance_private (self);
}

static void
bird_font_message_dialog_finalize (GObject * obj)
{
	BirdFontMessageDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_MESSAGE_DIALOG, BirdFontMessageDialog);
	_g_object_unref0 (self->ok_button);
	_g_object_unref0 (self->priv->message);
	G_OBJECT_CLASS (bird_font_message_dialog_parent_class)->finalize (obj);
}

static GType
bird_font_message_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontMessageDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_message_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontMessageDialog), 0, (GInstanceInitFunc) bird_font_message_dialog_instance_init, NULL };
	GType bird_font_message_dialog_type_id;
	bird_font_message_dialog_type_id = g_type_register_static (BIRD_FONT_TYPE_DIALOG, "BirdFontMessageDialog", &g_define_type_info, 0);
	BirdFontMessageDialog_private_offset = g_type_add_instance_private (bird_font_message_dialog_type_id, sizeof (BirdFontMessageDialogPrivate));
	return bird_font_message_dialog_type_id;
}

GType
bird_font_message_dialog_get_type (void)
{
	static volatile gsize bird_font_message_dialog_type_id__once = 0;
	if (g_once_init_enter (&bird_font_message_dialog_type_id__once)) {
		GType bird_font_message_dialog_type_id;
		bird_font_message_dialog_type_id = bird_font_message_dialog_get_type_once ();
		g_once_init_leave (&bird_font_message_dialog_type_id__once, bird_font_message_dialog_type_id);
	}
	return bird_font_message_dialog_type_id__once;
}

