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

/* This file is part of Elastic. License: GPL-3.0+.*/

#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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 ELASTIC_TYPE_APPLICATION (elastic_application_get_type ())
#define ELASTIC_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ELASTIC_TYPE_APPLICATION, ElasticApplication))
#define ELASTIC_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ELASTIC_TYPE_APPLICATION, ElasticApplicationClass))
#define ELASTIC_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ELASTIC_TYPE_APPLICATION))
#define ELASTIC_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ELASTIC_TYPE_APPLICATION))
#define ELASTIC_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ELASTIC_TYPE_APPLICATION, ElasticApplicationClass))

typedef struct _ElasticApplication ElasticApplication;
typedef struct _ElasticApplicationClass ElasticApplicationClass;
typedef struct _ElasticApplicationPrivate ElasticApplicationPrivate;
enum  {
	ELASTIC_APPLICATION_0_PROPERTY,
	ELASTIC_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* elastic_application_properties[ELASTIC_APPLICATION_NUM_PROPERTIES];

#define ELASTIC_TYPE_WINDOW (elastic_window_get_type ())
#define ELASTIC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ELASTIC_TYPE_WINDOW, ElasticWindow))
#define ELASTIC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ELASTIC_TYPE_WINDOW, ElasticWindowClass))
#define ELASTIC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ELASTIC_TYPE_WINDOW))
#define ELASTIC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ELASTIC_TYPE_WINDOW))
#define ELASTIC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ELASTIC_TYPE_WINDOW, ElasticWindowClass))

typedef struct _ElasticWindow ElasticWindow;
typedef struct _ElasticWindowClass ElasticWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define ELASTIC_TYPE_PREFERENCES_DIALOG (elastic_preferences_dialog_get_type ())
#define ELASTIC_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ELASTIC_TYPE_PREFERENCES_DIALOG, ElasticPreferencesDialog))
#define ELASTIC_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ELASTIC_TYPE_PREFERENCES_DIALOG, ElasticPreferencesDialogClass))
#define ELASTIC_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ELASTIC_TYPE_PREFERENCES_DIALOG))
#define ELASTIC_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ELASTIC_TYPE_PREFERENCES_DIALOG))
#define ELASTIC_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ELASTIC_TYPE_PREFERENCES_DIALOG, ElasticPreferencesDialogClass))

typedef struct _ElasticPreferencesDialog ElasticPreferencesDialog;
typedef struct _ElasticPreferencesDialogClass ElasticPreferencesDialogClass;
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);

struct _ElasticApplication {
	AdwApplication parent_instance;
	ElasticApplicationPrivate * priv;
};

struct _ElasticApplicationClass {
	AdwApplicationClass parent_class;
};

static gpointer elastic_application_parent_class = NULL;

VALA_EXTERN GType elastic_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ElasticApplication, g_object_unref)
VALA_EXTERN ElasticApplication* elastic_application_new (void);
VALA_EXTERN ElasticApplication* elastic_application_construct (GType object_type);
static void elastic_application_real_activate (GApplication* base);
VALA_EXTERN ElasticWindow* elastic_window_new (GtkApplication* app);
VALA_EXTERN ElasticWindow* elastic_window_construct (GType object_type,
                                         GtkApplication* app);
VALA_EXTERN GType elastic_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ElasticWindow, g_object_unref)
static void elastic_application_on_about_action (ElasticApplication* self);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup2 (gchar** self,
                          gssize length);
static void elastic_application_on_preferences_action (ElasticApplication* self);
VALA_EXTERN GType elastic_preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ElasticPreferencesDialog, g_object_unref)
VALA_EXTERN ElasticPreferencesDialog* elastic_preferences_dialog_new (void);
VALA_EXTERN ElasticPreferencesDialog* elastic_preferences_dialog_construct (GType object_type);
static GObject * elastic_application_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static void _elastic_application_on_about_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                            GVariant* parameter,
                                                                            gpointer self);
static void _elastic_application_on_preferences_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                  GVariant* parameter,
                                                                                  gpointer self);
static void _g_application_quit_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self);
static GType elastic_application_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);

ElasticApplication*
elastic_application_construct (GType object_type)
{
	ElasticApplication * self = NULL;
	self = (ElasticApplication*) g_object_new (object_type, "application-id", "app.drey.Elastic", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	return self;
}

ElasticApplication*
elastic_application_new (void)
{
	return elastic_application_construct (ELASTIC_TYPE_APPLICATION);
}

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

static void
elastic_application_real_activate (GApplication* base)
{
	ElasticApplication * self;
	GtkWindow* _tmp0_ = NULL;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* win = NULL;
	GtkWindow* _tmp5_;
	self = (ElasticApplication*) base;
	G_APPLICATION_CLASS (elastic_application_parent_class)->activate ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp1_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp0_ = _tmp3_;
	if (_tmp0_ == NULL) {
		ElasticWindow* _tmp4_;
		_tmp4_ = elastic_window_new ((GtkApplication*) self);
		g_object_ref_sink (_tmp4_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = (GtkWindow*) _tmp4_;
	}
	_tmp5_ = _tmp0_;
	_tmp0_ = NULL;
	win = _tmp5_;
	gtk_window_present (win);
	_g_object_unref0 (win);
	_g_object_unref0 (_tmp0_);
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
_vala_array_dup2 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
elastic_application_on_about_action (ElasticApplication* self)
{
	gchar** developers = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gint developers_length1;
	gint _developers_size_;
	gchar** designers = NULL;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint designers_length1;
	gint _designers_size_;
	gchar* appdata = NULL;
	gchar* _tmp4_;
	AdwAboutDialog* about = NULL;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	AdwAboutDialog* _tmp9_ = NULL;
	GtkWindow* _tmp10_;
	GtkWindow* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("Alice Mikhaylenko https://nyaa.place/");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	developers = _tmp1_;
	developers_length1 = 1;
	_developers_size_ = developers_length1;
	_tmp2_ = g_strdup ("Tobias Bernard");
	_tmp3_ = g_new0 (gchar*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	designers = _tmp3_;
	designers_length1 = 1;
	_designers_size_ = designers_length1;
	_tmp4_ = g_strdup ("/app/drey/Elastic/app.drey.Elastic.metainfo.xml");
	appdata = _tmp4_;
	_tmp5_ = (developers != NULL) ? _vala_array_dup1 (developers, developers_length1) : developers;
	_tmp5__length1 = developers_length1;
	_tmp6_ = (designers != NULL) ? _vala_array_dup2 (designers, designers_length1) : designers;
	_tmp6__length1 = designers_length1;
	_tmp7_ = g_strdup (_ ("translator-credits"));
	_tmp8_ = g_strdup ("© 2021, 2023-2026 Alice Mikhaylenko");
	_tmp9_ = (AdwAboutDialog*) adw_about_dialog_new_from_appdata (appdata, NULL);
	adw_about_dialog_set_developers (_tmp9_, _tmp5_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_designers (_tmp9_, _tmp6_);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_translator_credits (_tmp9_, _tmp7_);
	_g_free0 (_tmp7_);
	adw_about_dialog_set_copyright (_tmp9_, _tmp8_);
	_g_free0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	about = _tmp9_;
	_tmp10_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp11_ = _tmp10_;
	adw_dialog_present ((AdwDialog*) about, (GtkWidget*) _tmp11_);
	_g_object_unref0 (about);
	_g_free0 (appdata);
	designers = (_vala_array_free (designers, designers_length1, (GDestroyNotify) g_free), NULL);
	developers = (_vala_array_free (developers, developers_length1, (GDestroyNotify) g_free), NULL);
}

static void
elastic_application_on_preferences_action (ElasticApplication* self)
{
	ElasticPreferencesDialog* win = NULL;
	ElasticPreferencesDialog* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = elastic_preferences_dialog_new ();
	g_object_ref_sink (_tmp0_);
	win = _tmp0_;
	_tmp1_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp2_ = _tmp1_;
	adw_dialog_present ((AdwDialog*) win, (GtkWidget*) _tmp2_);
	_g_object_unref0 (win);
}

static void
_elastic_application_on_about_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                       GVariant* parameter,
                                                                       gpointer self)
{
	elastic_application_on_about_action ((ElasticApplication*) self);
}

static void
_elastic_application_on_preferences_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                             GVariant* parameter,
                                                                             gpointer self)
{
	elastic_application_on_preferences_action ((ElasticApplication*) self);
}

static void
_g_application_quit_gsimple_action_activate_callback (GSimpleAction* action,
                                                      GVariant* parameter,
                                                      gpointer self)
{
	g_application_quit ((GApplication*) self);
}

static GObject *
elastic_application_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ElasticApplication * self;
	GActionEntry* action_entries = NULL;
	GActionEntry _tmp0_ = {0};
	GActionEntry _tmp1_ = {0};
	GActionEntry _tmp2_ = {0};
	GActionEntry* _tmp3_;
	gint action_entries_length1;
	gint _action_entries_size_;
	GActionEntry* _tmp4_;
	gint _tmp4__length1;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar* _tmp17_;
	gchar** _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* _tmp23_;
	gchar** _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	gchar* _tmp26_;
	gchar** _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	parent_class = G_OBJECT_CLASS (elastic_application_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ELASTIC_TYPE_APPLICATION, ElasticApplication);
	memset (&_tmp0_, 0, sizeof (GActionEntry));
	_tmp0_.name = "about";
	_tmp0_.activate = _elastic_application_on_about_action_gsimple_action_activate_callback;
	memset (&_tmp1_, 0, sizeof (GActionEntry));
	_tmp1_.name = "preferences";
	_tmp1_.activate = _elastic_application_on_preferences_action_gsimple_action_activate_callback;
	memset (&_tmp2_, 0, sizeof (GActionEntry));
	_tmp2_.name = "quit";
	_tmp2_.activate = _g_application_quit_gsimple_action_activate_callback;
	_tmp3_ = g_new0 (GActionEntry, 3);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	action_entries = _tmp3_;
	action_entries_length1 = 3;
	_action_entries_size_ = action_entries_length1;
	_tmp4_ = action_entries;
	_tmp4__length1 = action_entries_length1;
	g_action_map_add_action_entries ((GActionMap*) self, _tmp4_, (gint) _tmp4__length1, self);
	_tmp5_ = g_strdup ("<primary>q");
	_tmp6_ = g_new0 (gchar*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = g_strdup ("<primary>comma");
	_tmp9_ = g_new0 (gchar*, 1 + 1);
	_tmp9_[0] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.preferences", _tmp10_);
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	_tmp11_ = g_strdup ("<alt>1");
	_tmp12_ = g_new0 (gchar*, 1 + 1);
	_tmp12_[0] = _tmp11_;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.basic-view", _tmp13_);
	_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) g_free), NULL);
	_tmp14_ = g_strdup ("<alt>2");
	_tmp15_ = g_new0 (gchar*, 1 + 1);
	_tmp15_[0] = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.interactive-view", _tmp16_);
	_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
	_tmp17_ = g_strdup ("<primary>r");
	_tmp18_ = g_new0 (gchar*, 1 + 1);
	_tmp18_[0] = _tmp17_;
	_tmp19_ = _tmp18_;
	_tmp19__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.run-animation", _tmp19_);
	_tmp19_ = (_vala_array_free (_tmp19_, _tmp19__length1, (GDestroyNotify) g_free), NULL);
	_tmp20_ = g_strdup ("<primary>g");
	_tmp21_ = g_new0 (gchar*, 1 + 1);
	_tmp21_[0] = _tmp20_;
	_tmp22_ = _tmp21_;
	_tmp22__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.toggle-graph", _tmp22_);
	_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_free), NULL);
	_tmp23_ = g_strdup ("<shift><primary>c");
	_tmp24_ = g_new0 (gchar*, 1 + 1);
	_tmp24_[0] = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp25__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.copy-snippet", _tmp25_);
	_tmp25_ = (_vala_array_free (_tmp25_, _tmp25__length1, (GDestroyNotify) g_free), NULL);
	_tmp26_ = g_strdup ("<primary>t");
	_tmp27_ = g_new0 (gchar*, 1 + 1);
	_tmp27_[0] = _tmp26_;
	_tmp28_ = _tmp27_;
	_tmp28__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "editor.reset", _tmp28_);
	_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
	action_entries = (g_free (action_entries), NULL);
	return obj;
}

static void
elastic_application_class_init (ElasticApplicationClass * klass,
                                gpointer klass_data)
{
	elastic_application_parent_class = g_type_class_peek_parent (klass);
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) elastic_application_real_activate;
	G_OBJECT_CLASS (klass)->constructor = elastic_application_constructor;
}

static void
elastic_application_instance_init (ElasticApplication * self,
                                   gpointer klass)
{
}

static GType
elastic_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ElasticApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) elastic_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ElasticApplication), 0, (GInstanceInitFunc) elastic_application_instance_init, NULL };
	GType elastic_application_type_id;
	elastic_application_type_id = g_type_register_static (adw_application_get_type (), "ElasticApplication", &g_define_type_info, 0);
	return elastic_application_type_id;
}

GType
elastic_application_get_type (void)
{
	static volatile gsize elastic_application_type_id__once = 0;
	if (g_once_init_enter (&elastic_application_type_id__once)) {
		GType elastic_application_type_id;
		elastic_application_type_id = elastic_application_get_type_once ();
		g_once_init_leave (&elastic_application_type_id__once, elastic_application_type_id);
	}
	return elastic_application_type_id__once;
}

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);
}

