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

/*
* Copyright (c) 2019-2026 (https://github.com/phase1geo/Minder)
*
* 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 2 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: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <gobject/gvaluecollector.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 TYPE_ABOUT (about_get_type ())
#define ABOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ABOUT, About))
#define ABOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ABOUT, AboutClass))
#define IS_ABOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ABOUT))
#define IS_ABOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ABOUT))
#define ABOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ABOUT, AboutClass))

typedef struct _About About;
typedef struct _AboutClass AboutClass;
typedef struct _AboutPrivate AboutPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ParamSpecAbout ParamSpecAbout;

struct _About {
	GTypeInstance parent_instance;
	volatile int ref_count;
	AboutPrivate * priv;
};

struct _AboutClass {
	GTypeClass parent_class;
	void (*finalize) (About *self);
};

struct _AboutPrivate {
	GtkAboutDialog* _about;
};

struct _ParamSpecAbout {
	GParamSpec parent_instance;
};

static gint About_private_offset;
static gpointer about_parent_class = NULL;
VALA_EXTERN gchar* minder_version;

VALA_EXTERN gpointer about_ref (gpointer instance);
VALA_EXTERN void about_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_about (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags);
VALA_EXTERN void value_set_about (GValue* value,
                      gpointer v_object);
VALA_EXTERN void value_take_about (GValue* value,
                       gpointer v_object);
VALA_EXTERN gpointer value_get_about (const GValue* value);
VALA_EXTERN GType about_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (About, about_unref)
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
VALA_EXTERN About* about_new (MainWindow* win);
VALA_EXTERN About* about_construct (GType object_type,
                        MainWindow* win);
static gchar* about_get_system_info (About* self);
VALA_EXTERN gchar* utils_get_flatpak_runtime (void);
VALA_EXTERN void about_show (About* self);
static void about_finalize (About * obj);
static GType about_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
about_get_instance_private (About* self)
{
	return G_STRUCT_MEMBER_P (self, About_private_offset);
}

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

About*
about_construct (GType object_type,
                 MainWindow* win)
{
	About* self = NULL;
	GtkImage* image = NULL;
	GtkImage* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GdkPaintable* _tmp11_;
	GdkPaintable* _tmp12_;
	GtkAboutDialog* _tmp13_ = NULL;
	GtkAboutDialog* _tmp14_;
	GtkAboutDialog* _tmp15_;
	GtkAboutDialog* _tmp16_;
	g_return_val_if_fail (win != NULL, NULL);
	self = (About*) g_type_create_instance (object_type);
	_tmp0_ = (GtkImage*) gtk_image_new_from_resource ("/com/github/phase1geo/minder/minder-logo.svg");
	g_object_ref_sink (_tmp0_);
	image = _tmp0_;
	_tmp1_ = g_strdup ("Trevor Williams");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = g_strdup ("Minder");
	_tmp4_ = g_strdup (_ ("Mind-mapping application"));
	_tmp5_ = g_strconcat (_ ("Copyright"), " © 2018-2026 Trevor Williams", NULL);
	_tmp6_ = minder_version;
	_tmp7_ = g_strdup (_tmp6_);
	_tmp8_ = g_strdup ("https://appcenter.elementary.io/com.github.phase1geo.minder/");
	_tmp9_ = g_strdup (_ ("Minder in AppCenter"));
	_tmp10_ = about_get_system_info (self);
	_tmp11_ = gtk_image_get_paintable (image);
	_tmp12_ = _g_object_ref0 (_tmp11_);
	_tmp13_ = (GtkAboutDialog*) gtk_about_dialog_new ();
	gtk_about_dialog_set_authors (_tmp13_, _tmp2_);
	_tmp2_ = (_vala_array_free (_tmp2_, 1, (GDestroyNotify) g_free), NULL);
	gtk_about_dialog_set_program_name (_tmp13_, _tmp3_);
	_g_free0 (_tmp3_);
	gtk_about_dialog_set_comments (_tmp13_, _tmp4_);
	_g_free0 (_tmp4_);
	gtk_about_dialog_set_copyright (_tmp13_, _tmp5_);
	_g_free0 (_tmp5_);
	gtk_about_dialog_set_version (_tmp13_, _tmp7_);
	_g_free0 (_tmp7_);
	gtk_about_dialog_set_license_type (_tmp13_, GTK_LICENSE_GPL_3_0);
	gtk_about_dialog_set_website (_tmp13_, _tmp8_);
	_g_free0 (_tmp8_);
	gtk_about_dialog_set_website_label (_tmp13_, _tmp9_);
	_g_free0 (_tmp9_);
	gtk_about_dialog_set_system_information (_tmp13_, _tmp10_);
	_g_free0 (_tmp10_);
	gtk_about_dialog_set_logo (_tmp13_, _tmp12_);
	_g_object_unref0 (_tmp12_);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->_about);
	self->priv->_about = _tmp13_;
	_tmp14_ = self->priv->_about;
	gtk_window_set_destroy_with_parent ((GtkWindow*) _tmp14_, TRUE);
	_tmp15_ = self->priv->_about;
	gtk_window_set_transient_for ((GtkWindow*) _tmp15_, (GtkWindow*) win);
	_tmp16_ = self->priv->_about;
	gtk_window_set_modal ((GtkWindow*) _tmp16_, TRUE);
	_g_object_unref0 (image);
	return self;
}

About*
about_new (MainWindow* win)
{
	return about_construct (TYPE_ABOUT, win);
}

static gchar*
about_get_system_info (About* self)
{
	gchar* runtime = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = utils_get_flatpak_runtime ();
	runtime = _tmp0_;
	_tmp1_ = runtime;
	if (g_strcmp0 (_tmp1_, "") != 0) {
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp2_ = runtime;
		_tmp3_ = g_strdup_printf ("Flatpak Runtime: %s", _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strdup (_ (_tmp4_));
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		result = _tmp6_;
		_g_free0 (runtime);
		return result;
	}
	_tmp7_ = g_strdup ("");
	result = _tmp7_;
	_g_free0 (runtime);
	return result;
}

void
about_show (About* self)
{
	GtkAboutDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_about;
	gtk_window_present ((GtkWindow*) _tmp0_);
}

static void
value_about_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
value_about_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		about_unref (value->data[0].v_pointer);
	}
}

static void
value_about_copy_value (const GValue* src_value,
                        GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = about_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
value_about_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
value_about_collect_value (GValue* value,
                           guint n_collect_values,
                           GTypeCValue* collect_values,
                           guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		About * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = about_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_about_lcopy_value (const GValue* value,
                         guint n_collect_values,
                         GTypeCValue* collect_values,
                         guint collect_flags)
{
	About ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = about_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_about (const gchar* name,
                  const gchar* nick,
                  const gchar* blurb,
                  GType object_type,
                  GParamFlags flags)
{
	ParamSpecAbout* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_ABOUT), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
value_get_about (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_ABOUT), NULL);
	return value->data[0].v_pointer;
}

void
value_set_about (GValue* value,
                 gpointer v_object)
{
	About * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_ABOUT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_ABOUT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		about_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		about_unref (old);
	}
}

void
value_take_about (GValue* value,
                  gpointer v_object)
{
	About * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_ABOUT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_ABOUT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		about_unref (old);
	}
}

static void
about_class_init (AboutClass * klass,
                  gpointer klass_data)
{
	about_parent_class = g_type_class_peek_parent (klass);
	((AboutClass *) klass)->finalize = about_finalize;
	g_type_class_adjust_private_offset (klass, &About_private_offset);
}

static void
about_instance_init (About * self,
                     gpointer klass)
{
	self->priv = about_get_instance_private (self);
	self->ref_count = 1;
}

static void
about_finalize (About * obj)
{
	About * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ABOUT, About);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_about);
}

static GType
about_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_about_init, value_about_free_value, value_about_copy_value, value_about_peek_pointer, "p", value_about_collect_value, "p", value_about_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (AboutClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) about_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (About), 0, (GInstanceInitFunc) about_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType about_type_id;
	about_type_id = g_type_register_fundamental (g_type_fundamental_next (), "About", &g_define_type_info, &g_define_type_fundamental_info, 0);
	About_private_offset = g_type_add_instance_private (about_type_id, sizeof (AboutPrivate));
	return about_type_id;
}

GType
about_get_type (void)
{
	static volatile gsize about_type_id__once = 0;
	if (g_once_init_enter (&about_type_id__once)) {
		GType about_type_id;
		about_type_id = about_get_type_once ();
		g_once_init_leave (&about_type_id__once, about_type_id);
	}
	return about_type_id__once;
}

gpointer
about_ref (gpointer instance)
{
	About * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
about_unref (gpointer instance)
{
	About * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		ABOUT_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

