/* gitg-tag-show-info-dialog.c generated by valac 0.56.19, the Vala compiler
 * generated from gitg-tag-show-info-dialog.vala, do not modify */

/*
 * This file is part of gitg
 *
 * Copyright (C) 2023 - Alberto Fanjul
 *
 * gitg 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 2 of the License, or
 * (at your option) any later version.
 *
 * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "config.h"
#include "libgitg.h"
#include <libgit2-glib/ggit.h>

#define GITG_TAG_SHOW_INFO_DIALOG_version VERSION
#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 GITG_TYPE_TAG_SHOW_INFO_DIALOG (gitg_tag_show_info_dialog_get_type ())
#define GITG_TAG_SHOW_INFO_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_TAG_SHOW_INFO_DIALOG, GitgTagShowInfoDialog))
#define GITG_TAG_SHOW_INFO_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_TAG_SHOW_INFO_DIALOG, GitgTagShowInfoDialogClass))
#define GITG_IS_TAG_SHOW_INFO_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_TAG_SHOW_INFO_DIALOG))
#define GITG_IS_TAG_SHOW_INFO_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_TAG_SHOW_INFO_DIALOG))
#define GITG_TAG_SHOW_INFO_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_TAG_SHOW_INFO_DIALOG, GitgTagShowInfoDialogClass))

typedef struct _GitgTagShowInfoDialog GitgTagShowInfoDialog;
typedef struct _GitgTagShowInfoDialogClass GitgTagShowInfoDialogClass;
typedef struct _GitgTagShowInfoDialogPrivate GitgTagShowInfoDialogPrivate;
enum  {
	GITG_TAG_SHOW_INFO_DIALOG_0_PROPERTY,
	GITG_TAG_SHOW_INFO_DIALOG_NUM_PROPERTIES
};
static GParamSpec* gitg_tag_show_info_dialog_properties[GITG_TAG_SHOW_INFO_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))

struct _GitgTagShowInfoDialog {
	GtkDialog parent_instance;
	GitgTagShowInfoDialogPrivate * priv;
};

struct _GitgTagShowInfoDialogClass {
	GtkDialogClass parent_class;
};

struct _GitgTagShowInfoDialogPrivate {
	GtkLabel* d_name;
	GtkLabel* d_message;
};

static gint GitgTagShowInfoDialog_private_offset;
static gpointer gitg_tag_show_info_dialog_parent_class = NULL;

VALA_EXTERN GType gitg_tag_show_info_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgTagShowInfoDialog, g_object_unref)
VALA_EXTERN GitgTagShowInfoDialog* gitg_tag_show_info_dialog_new (GtkWindow* parent,
                                                      GitgRef* reference);
VALA_EXTERN GitgTagShowInfoDialog* gitg_tag_show_info_dialog_construct (GType object_type,
                                                            GtkWindow* parent,
                                                            GitgRef* reference);
static GObject * gitg_tag_show_info_dialog_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void gitg_tag_show_info_dialog_finalize (GObject * obj);
static GType gitg_tag_show_info_dialog_get_type_once (void);

static inline gpointer
gitg_tag_show_info_dialog_get_instance_private (GitgTagShowInfoDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GitgTagShowInfoDialog_private_offset);
}

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

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

GitgTagShowInfoDialog*
gitg_tag_show_info_dialog_construct (GType object_type,
                                     GtkWindow* parent,
                                     GitgRef* reference)
{
	GitgTagShowInfoDialog * self = NULL;
	GgitRef* _tmp0_ = NULL;
	GgitRef* _tmp1_;
	GgitObject* _tmp2_ = NULL;
	GgitObject* _tmp3_;
	GgitTag* tag = NULL;
	GgitTag* _tmp4_;
	gchar* name = NULL;
	GgitTag* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	GtkLabel* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GtkLabel* _tmp13_;
	GgitTag* _tmp14_;
	const gchar* _tmp15_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (reference != NULL, NULL);
	self = (GitgTagShowInfoDialog*) g_object_new (object_type, "use-header-bar", 1, NULL);
	if (parent != NULL) {
		gtk_window_set_transient_for ((GtkWindow*) self, parent);
	}
	_tmp1_ = ggit_ref_resolve ((GgitRef*) reference, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp3_ = ggit_ref_lookup (_tmp0_, &_inner_error0_);
	_tmp2_ = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (_tmp0_);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, ggit_tag_get_type (), GgitTag));
	tag = _tmp4_;
	_tmp5_ = tag;
	_tmp6_ = ggit_tag_get_name (_tmp5_);
	_tmp7_ = g_strdup (_tmp6_);
	name = _tmp7_;
	_tmp8_ = self->priv->d_name;
	_tmp9_ = name;
	_tmp10_ = string_to_string (_tmp9_);
	_tmp11_ = g_strconcat ("<b>", _tmp10_, "</b>", NULL);
	_tmp12_ = _tmp11_;
	gtk_label_set_markup (_tmp8_, _tmp12_);
	_g_free0 (_tmp12_);
	_tmp13_ = self->priv->d_message;
	_tmp14_ = tag;
	_tmp15_ = ggit_tag_get_message (_tmp14_);
	gtk_label_set_text (_tmp13_, _tmp15_);
	_g_free0 (name);
	_g_object_unref0 (tag);
	_g_object_unref0 (_tmp2_);
	_g_object_unref0 (_tmp0_);
	return self;
}

GitgTagShowInfoDialog*
gitg_tag_show_info_dialog_new (GtkWindow* parent,
                               GitgRef* reference)
{
	return gitg_tag_show_info_dialog_construct (GITG_TYPE_TAG_SHOW_INFO_DIALOG, parent, reference);
}

static GObject *
gitg_tag_show_info_dialog_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgTagShowInfoDialog * self;
	parent_class = G_OBJECT_CLASS (gitg_tag_show_info_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_TAG_SHOW_INFO_DIALOG, GitgTagShowInfoDialog);
	gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_OK);
	return obj;
}

static void
gitg_tag_show_info_dialog_class_init (GitgTagShowInfoDialogClass * klass,
                                      gpointer klass_data)
{
	gitg_tag_show_info_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgTagShowInfoDialog_private_offset);
	G_OBJECT_CLASS (klass)->constructor = gitg_tag_show_info_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = gitg_tag_show_info_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/gitg/ui/gitg-tag-show-info-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_name", FALSE, GitgTagShowInfoDialog_private_offset + G_STRUCT_OFFSET (GitgTagShowInfoDialogPrivate, d_name));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_message", FALSE, GitgTagShowInfoDialog_private_offset + G_STRUCT_OFFSET (GitgTagShowInfoDialogPrivate, d_message));
}

static void
gitg_tag_show_info_dialog_instance_init (GitgTagShowInfoDialog * self,
                                         gpointer klass)
{
	self->priv = gitg_tag_show_info_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
gitg_tag_show_info_dialog_finalize (GObject * obj)
{
	GitgTagShowInfoDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_TAG_SHOW_INFO_DIALOG, GitgTagShowInfoDialog);
	G_OBJECT_CLASS (gitg_tag_show_info_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_tag_show_info_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgTagShowInfoDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_tag_show_info_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgTagShowInfoDialog), 0, (GInstanceInitFunc) gitg_tag_show_info_dialog_instance_init, NULL };
	GType gitg_tag_show_info_dialog_type_id;
	gitg_tag_show_info_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "GitgTagShowInfoDialog", &g_define_type_info, 0);
	GitgTagShowInfoDialog_private_offset = g_type_add_instance_private (gitg_tag_show_info_dialog_type_id, sizeof (GitgTagShowInfoDialogPrivate));
	return gitg_tag_show_info_dialog_type_id;
}

GType
gitg_tag_show_info_dialog_get_type (void)
{
	static gsize gitg_tag_show_info_dialog_type_id__once = 0;
	if (g_once_init_enter (&gitg_tag_show_info_dialog_type_id__once)) {
		GType gitg_tag_show_info_dialog_type_id;
		gitg_tag_show_info_dialog_type_id = gitg_tag_show_info_dialog_get_type_once ();
		g_once_init_leave (&gitg_tag_show_info_dialog_type_id__once, gitg_tag_show_info_dialog_type_id);
	}
	return gitg_tag_show_info_dialog_type_id__once;
}

