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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * 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 3 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: Alain M. <alainmh23@gmail.com>
 */

#include <adwaita.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.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 DIALOGS_TYPE_ERROR_DIALOG (dialogs_error_dialog_get_type ())
#define DIALOGS_ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialog))
#define DIALOGS_ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialogClass))
#define DIALOGS_IS_ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_TYPE_ERROR_DIALOG))
#define DIALOGS_IS_ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_TYPE_ERROR_DIALOG))
#define DIALOGS_ERROR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialogClass))

typedef struct _DialogsErrorDialog DialogsErrorDialog;
typedef struct _DialogsErrorDialogClass DialogsErrorDialogClass;
typedef struct _DialogsErrorDialogPrivate DialogsErrorDialogPrivate;
enum  {
	DIALOGS_ERROR_DIALOG_0_PROPERTY,
	DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY,
	DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY,
	DIALOGS_ERROR_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dialogs_error_dialog_properties[DIALOGS_ERROR_DIALOG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define WIDGETS_TYPE_ERROR_VIEW (widgets_error_view_get_type ())
#define WIDGETS_ERROR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_ERROR_VIEW, WidgetsErrorView))
#define WIDGETS_ERROR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_ERROR_VIEW, WidgetsErrorViewClass))
#define WIDGETS_IS_ERROR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_ERROR_VIEW))
#define WIDGETS_IS_ERROR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_ERROR_VIEW))
#define WIDGETS_ERROR_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_ERROR_VIEW, WidgetsErrorViewClass))

typedef struct _WidgetsErrorView WidgetsErrorView;
typedef struct _WidgetsErrorViewClass WidgetsErrorViewClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DialogsErrorDialog {
	AdwDialog parent_instance;
	DialogsErrorDialogPrivate * priv;
};

struct _DialogsErrorDialogClass {
	AdwDialogClass parent_class;
};

struct _DialogsErrorDialogPrivate {
	gint _error_code;
	gchar* _error_message;
};

static gint DialogsErrorDialog_private_offset;
static gpointer dialogs_error_dialog_parent_class = NULL;

VALA_EXTERN GType dialogs_error_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsErrorDialog, g_object_unref)
VALA_EXTERN DialogsErrorDialog* dialogs_error_dialog_new (gint error_code,
                                              const gchar* error_message);
VALA_EXTERN DialogsErrorDialog* dialogs_error_dialog_construct (GType object_type,
                                                    gint error_code,
                                                    const gchar* error_message);
VALA_EXTERN gint dialogs_error_dialog_get_error_code (DialogsErrorDialog* self);
static void dialogs_error_dialog_set_error_code (DialogsErrorDialog* self,
                                          gint value);
VALA_EXTERN const gchar* dialogs_error_dialog_get_error_message (DialogsErrorDialog* self);
static void dialogs_error_dialog_set_error_message (DialogsErrorDialog* self,
                                             const gchar* value);
static GObject * dialogs_error_dialog_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
VALA_EXTERN GType widgets_error_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsErrorView, g_object_unref)
VALA_EXTERN WidgetsErrorView* widgets_error_view_new (void);
VALA_EXTERN WidgetsErrorView* widgets_error_view_construct (GType object_type);
VALA_EXTERN void widgets_error_view_set_error_code (WidgetsErrorView* self,
                                        gint value);
VALA_EXTERN void widgets_error_view_set_error_message (WidgetsErrorView* self,
                                           const gchar* value);
static void dialogs_error_dialog_finalize (GObject * obj);
static GType dialogs_error_dialog_get_type_once (void);
static void _vala_dialogs_error_dialog_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_dialogs_error_dialog_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);

static inline gpointer
dialogs_error_dialog_get_instance_private (DialogsErrorDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsErrorDialog_private_offset);
}

DialogsErrorDialog*
dialogs_error_dialog_construct (GType object_type,
                                gint error_code,
                                const gchar* error_message)
{
	DialogsErrorDialog * self = NULL;
	g_return_val_if_fail (error_message != NULL, NULL);
	self = (DialogsErrorDialog*) g_object_new (object_type, "error-code", error_code, "error-message", error_message, "content-width", 375, "content-height", 450, NULL);
	return self;
}

DialogsErrorDialog*
dialogs_error_dialog_new (gint error_code,
                          const gchar* error_message)
{
	return dialogs_error_dialog_construct (DIALOGS_TYPE_ERROR_DIALOG, error_code, error_message);
}

gint
dialogs_error_dialog_get_error_code (DialogsErrorDialog* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_error_code;
	return result;
}

static void
dialogs_error_dialog_set_error_code (DialogsErrorDialog* self,
                                     gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dialogs_error_dialog_get_error_code (self);
	if (old_value != value) {
		self->priv->_error_code = value;
		g_object_notify_by_pspec ((GObject *) self, dialogs_error_dialog_properties[DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY]);
	}
}

const gchar*
dialogs_error_dialog_get_error_message (DialogsErrorDialog* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_error_message;
	result = _tmp0_;
	return result;
}

static void
dialogs_error_dialog_set_error_message (DialogsErrorDialog* self,
                                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dialogs_error_dialog_get_error_message (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_error_message);
		self->priv->_error_message = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dialogs_error_dialog_properties[DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY]);
	}
}

static GObject *
dialogs_error_dialog_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsErrorDialog * self;
	WidgetsErrorView* error_view = NULL;
	gint _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	WidgetsErrorView* _tmp3_ = NULL;
	WidgetsErrorView* _tmp4_;
	parent_class = G_OBJECT_CLASS (dialogs_error_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialog);
	_tmp0_ = self->priv->_error_code;
	_tmp1_ = self->priv->_error_message;
	_tmp2_ = g_strdup (_tmp1_);
	_tmp3_ = widgets_error_view_new ();
	widgets_error_view_set_error_code (_tmp3_, _tmp0_);
	widgets_error_view_set_error_message (_tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	error_view = _tmp3_;
	_tmp4_ = error_view;
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) _tmp4_);
	_g_object_unref0 (error_view);
	return obj;
}

static void
dialogs_error_dialog_class_init (DialogsErrorDialogClass * klass,
                                 gpointer klass_data)
{
	dialogs_error_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsErrorDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dialogs_error_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dialogs_error_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = dialogs_error_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_error_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY, dialogs_error_dialog_properties[DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY] = g_param_spec_int ("error-code", "error-code", "error-code", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY, dialogs_error_dialog_properties[DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY] = g_param_spec_string ("error-message", "error-message", "error-message", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
dialogs_error_dialog_instance_init (DialogsErrorDialog * self,
                                    gpointer klass)
{
	self->priv = dialogs_error_dialog_get_instance_private (self);
}

static void
dialogs_error_dialog_finalize (GObject * obj)
{
	DialogsErrorDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialog);
	g_debug ("ErrorDialog.vala:36: Destroying - Dialogs.ErrorDialog\n");
	_g_free0 (self->priv->_error_message);
	G_OBJECT_CLASS (dialogs_error_dialog_parent_class)->finalize (obj);
}

static GType
dialogs_error_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsErrorDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_error_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsErrorDialog), 0, (GInstanceInitFunc) dialogs_error_dialog_instance_init, NULL };
	GType dialogs_error_dialog_type_id;
	dialogs_error_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DialogsErrorDialog", &g_define_type_info, 0);
	DialogsErrorDialog_private_offset = g_type_add_instance_private (dialogs_error_dialog_type_id, sizeof (DialogsErrorDialogPrivate));
	return dialogs_error_dialog_type_id;
}

GType
dialogs_error_dialog_get_type (void)
{
	static volatile gsize dialogs_error_dialog_type_id__once = 0;
	if (g_once_init_enter (&dialogs_error_dialog_type_id__once)) {
		GType dialogs_error_dialog_type_id;
		dialogs_error_dialog_type_id = dialogs_error_dialog_get_type_once ();
		g_once_init_leave (&dialogs_error_dialog_type_id__once, dialogs_error_dialog_type_id);
	}
	return dialogs_error_dialog_type_id__once;
}

static void
_vala_dialogs_error_dialog_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	DialogsErrorDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialog);
	switch (property_id) {
		case DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY:
		g_value_set_int (value, dialogs_error_dialog_get_error_code (self));
		break;
		case DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY:
		g_value_set_string (value, dialogs_error_dialog_get_error_message (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dialogs_error_dialog_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	DialogsErrorDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_ERROR_DIALOG, DialogsErrorDialog);
	switch (property_id) {
		case DIALOGS_ERROR_DIALOG_ERROR_CODE_PROPERTY:
		dialogs_error_dialog_set_error_code (self, g_value_get_int (value));
		break;
		case DIALOGS_ERROR_DIALOG_ERROR_MESSAGE_PROPERTY:
		dialogs_error_dialog_set_error_message (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

