/* tools-release-changelog-dialog.c generated by valac 0.56.19, the Vala compiler
 * generated from tools-release-changelog-dialog.vala, do not modify */

#include "protonplus_core.h"
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <adwaita.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

enum  {
	PROTON_PLUS_WIDGETS_TOOLS_RELEASE_CHANGELOG_DIALOG_0_PROPERTY,
	PROTON_PLUS_WIDGETS_TOOLS_RELEASE_CHANGELOG_DIALOG_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_tools_release_changelog_dialog_properties[PROTON_PLUS_WIDGETS_TOOLS_RELEASE_CHANGELOG_DIALOG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer proton_plus_widgets_tools_release_changelog_dialog_parent_class = NULL;

static GType proton_plus_widgets_tools_release_changelog_dialog_get_type_once (void);

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

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

ProtonPlusWidgetsToolsReleaseChangelogDialog*
proton_plus_widgets_tools_release_changelog_dialog_construct (GType object_type,
                                                              ProtonPlusServicesInstallJob* job)
{
	ProtonPlusWidgetsToolsReleaseChangelogDialog * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	AdwWindowTitle* window_title = NULL;
	gchar* _tmp5_;
	gchar* _tmp6_;
	AdwWindowTitle* _tmp7_;
	AdwWindowTitle* _tmp8_;
	AdwHeaderBar* header_bar = NULL;
	AdwHeaderBar* _tmp9_;
	AdwHeaderBar* _tmp10_;
	AdwWindowTitle* _tmp11_;
	GtkWidget* content = NULL;
	gboolean _tmp12_ = FALSE;
	ProtonPlusModelsRelease* _tmp13_;
	ProtonPlusModelsRelease* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp34_;
	AdwHeaderBar* _tmp35_;
	GtkWidget* _tmp36_;
	g_return_val_if_fail (job != NULL, NULL);
	_tmp0_ = proton_plus_services_install_job_get_title (job);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf (_ ("Changelog for %s"), _tmp2_);
	_tmp4_ = _tmp3_;
	self = (ProtonPlusWidgetsToolsReleaseChangelogDialog*) g_object_new (object_type, "title", _tmp4_, NULL);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = proton_plus_widgets_tools_release_row_release_display_title (job);
	_tmp6_ = _tmp5_;
	_tmp7_ = (AdwWindowTitle*) adw_window_title_new (_ ("Changelog"), _tmp6_);
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	window_title = _tmp8_;
	_tmp9_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp9_);
	header_bar = _tmp9_;
	_tmp10_ = header_bar;
	_tmp11_ = window_title;
	adw_header_bar_set_title_widget (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp13_ = proton_plus_services_install_job_get_release (job);
	_tmp14_ = _tmp13_;
	_tmp15_ = proton_plus_models_release_get_description (_tmp14_);
	_tmp16_ = _tmp15_;
	if (_tmp16_ == NULL) {
		_tmp12_ = TRUE;
	} else {
		ProtonPlusModelsRelease* _tmp17_;
		ProtonPlusModelsRelease* _tmp18_;
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp17_ = proton_plus_services_install_job_get_release (job);
		_tmp18_ = _tmp17_;
		_tmp19_ = proton_plus_models_release_get_description (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = string_strip (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp12_ = g_strcmp0 (_tmp22_, "") == 0;
		_g_free0 (_tmp22_);
	}
	if (_tmp12_) {
		gchar* _tmp23_;
		gchar* _tmp24_;
		AdwStatusPage* _tmp25_ = NULL;
		_tmp23_ = g_strdup (_ ("No Changelog Available"));
		_tmp24_ = g_strdup ("book-open-symbolic");
		_tmp25_ = (AdwStatusPage*) adw_status_page_new ();
		adw_status_page_set_title (_tmp25_, _tmp23_);
		_g_free0 (_tmp23_);
		adw_status_page_set_icon_name (_tmp25_, _tmp24_);
		_g_free0 (_tmp24_);
		gtk_widget_set_vexpand ((GtkWidget*) _tmp25_, TRUE);
		g_object_ref_sink (_tmp25_);
		_g_object_unref0 (content);
		content = (GtkWidget*) _tmp25_;
	} else {
		ProtonPlusWidgetsToolsReleaseChangelog* changelog = NULL;
		ProtonPlusWidgetsToolsReleaseChangelog* _tmp26_;
		ProtonPlusWidgetsToolsReleaseChangelog* _tmp27_;
		ProtonPlusModelsRelease* _tmp28_;
		ProtonPlusModelsRelease* _tmp29_;
		const gchar* _tmp30_;
		const gchar* _tmp31_;
		ProtonPlusWidgetsToolsReleaseChangelog* _tmp32_;
		GtkWidget* _tmp33_;
		_tmp26_ = proton_plus_widgets_tools_release_changelog_new ();
		g_object_ref_sink (_tmp26_);
		changelog = _tmp26_;
		_tmp27_ = changelog;
		_tmp28_ = proton_plus_services_install_job_get_release (job);
		_tmp29_ = _tmp28_;
		_tmp30_ = proton_plus_models_release_get_description (_tmp29_);
		_tmp31_ = _tmp30_;
		proton_plus_widgets_tools_release_changelog_set_markdown (_tmp27_, _tmp31_);
		_tmp32_ = changelog;
		_tmp33_ = _g_object_ref0 ((GtkWidget*) _tmp32_);
		_g_object_unref0 (content);
		content = _tmp33_;
		_g_object_unref0 (changelog);
	}
	_tmp34_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp34_);
	toolbar_view = _tmp34_;
	_tmp35_ = header_bar;
	adw_toolbar_view_add_top_bar (toolbar_view, (GtkWidget*) _tmp35_);
	_tmp36_ = content;
	adw_toolbar_view_set_content (toolbar_view, _tmp36_);
	adw_dialog_set_content_width ((AdwDialog*) self, 720);
	adw_dialog_set_content_height ((AdwDialog*) self, 600);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) toolbar_view);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (content);
	_g_object_unref0 (header_bar);
	_g_object_unref0 (window_title);
	return self;
}

ProtonPlusWidgetsToolsReleaseChangelogDialog*
proton_plus_widgets_tools_release_changelog_dialog_new (ProtonPlusServicesInstallJob* job)
{
	return proton_plus_widgets_tools_release_changelog_dialog_construct (PROTON_PLUS_WIDGETS_TOOLS_TYPE_RELEASE_CHANGELOG_DIALOG, job);
}

static void
proton_plus_widgets_tools_release_changelog_dialog_class_init (ProtonPlusWidgetsToolsReleaseChangelogDialogClass * klass,
                                                               gpointer klass_data)
{
	proton_plus_widgets_tools_release_changelog_dialog_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_widgets_tools_release_changelog_dialog_instance_init (ProtonPlusWidgetsToolsReleaseChangelogDialog * self,
                                                                  gpointer klass)
{
}

static GType
proton_plus_widgets_tools_release_changelog_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsToolsReleaseChangelogDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_tools_release_changelog_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsToolsReleaseChangelogDialog), 0, (GInstanceInitFunc) proton_plus_widgets_tools_release_changelog_dialog_instance_init, NULL };
	GType proton_plus_widgets_tools_release_changelog_dialog_type_id;
	proton_plus_widgets_tools_release_changelog_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "ProtonPlusWidgetsToolsReleaseChangelogDialog", &g_define_type_info, 0);
	return proton_plus_widgets_tools_release_changelog_dialog_type_id;
}

GType
proton_plus_widgets_tools_release_changelog_dialog_get_type (void)
{
	static volatile gsize proton_plus_widgets_tools_release_changelog_dialog_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_tools_release_changelog_dialog_type_id__once)) {
		GType proton_plus_widgets_tools_release_changelog_dialog_type_id;
		proton_plus_widgets_tools_release_changelog_dialog_type_id = proton_plus_widgets_tools_release_changelog_dialog_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_tools_release_changelog_dialog_type_id__once, proton_plus_widgets_tools_release_changelog_dialog_type_id);
	}
	return proton_plus_widgets_tools_release_changelog_dialog_type_id__once;
}

