/* Application.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from Application.vala, do not modify */

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2018–2025 Cassidy James Blaede <c@ssidyjam.es>
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "config.h"

#define APP_ID "com.cassidyjames.clairvoyant"
#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_CLAIRVOYANT (clairvoyant_get_type ())
#define CLAIRVOYANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CLAIRVOYANT, Clairvoyant))
#define CLAIRVOYANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CLAIRVOYANT, ClairvoyantClass))
#define IS_CLAIRVOYANT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CLAIRVOYANT))
#define IS_CLAIRVOYANT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CLAIRVOYANT))
#define CLAIRVOYANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CLAIRVOYANT, ClairvoyantClass))

typedef struct _Clairvoyant Clairvoyant;
typedef struct _ClairvoyantClass ClairvoyantClass;
typedef struct _ClairvoyantPrivate ClairvoyantPrivate;
enum  {
	CLAIRVOYANT_0_PROPERTY,
	CLAIRVOYANT_NUM_PROPERTIES
};
static GParamSpec* clairvoyant_properties[CLAIRVOYANT_NUM_PROPERTIES];

#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;
typedef struct _Block1Data Block1Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _Clairvoyant {
	AdwApplication parent_instance;
	ClairvoyantPrivate * priv;
};

struct _ClairvoyantClass {
	AdwApplicationClass parent_class;
};

struct _Block1Data {
	int _ref_count_;
	Clairvoyant* self;
	MainWindow* main_window;
};

static gpointer clairvoyant_parent_class = NULL;

VALA_EXTERN GType clairvoyant_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Clairvoyant, g_object_unref)
VALA_EXTERN Clairvoyant* clairvoyant_new (void);
VALA_EXTERN Clairvoyant* clairvoyant_construct (GType object_type);
static void clairvoyant_real_activate (GApplication* base);
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
VALA_EXTERN MainWindow* main_window_new (GtkApplication* application);
VALA_EXTERN MainWindow* main_window_construct (GType object_type,
                                   GtkApplication* application);
static void __lambda7_ (Block1Data* _data1_);
static void ___lambda7__g_simple_action_activate (GSimpleAction* _sender,
                                           GVariant* parameter,
                                           gpointer self);
static gint clairvoyant_main (gchar** args,
                       gint args_length1);
static GType clairvoyant_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);

Clairvoyant*
clairvoyant_construct (GType object_type)
{
	Clairvoyant * self = NULL;
	self = (Clairvoyant*) g_object_new (object_type, "application-id", APP_ID, "flags", G_APPLICATION_FLAGS_NONE, NULL);
	return self;
}

Clairvoyant*
clairvoyant_new (void)
{
	return clairvoyant_construct (TYPE_CLAIRVOYANT);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		Clairvoyant* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->main_window);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda7_ (Block1Data* _data1_)
{
	Clairvoyant* self;
	MainWindow* _tmp0_;
	self = _data1_->self;
	_tmp0_ = _data1_->main_window;
	if (_tmp0_ != NULL) {
		MainWindow* _tmp1_;
		_tmp1_ = _data1_->main_window;
		gtk_window_destroy ((GtkWindow*) _tmp1_);
	}
}

static void
___lambda7__g_simple_action_activate (GSimpleAction* _sender,
                                      GVariant* parameter,
                                      gpointer self)
{
	__lambda7_ (self);
}

static void
clairvoyant_real_activate (GApplication* base)
{
	Clairvoyant * self;
	Block1Data* _data1_;
	GList* _tmp0_;
	MainWindow* _tmp3_;
	MainWindow* _tmp4_;
	GSimpleAction* quit_action = NULL;
	GSimpleAction* _tmp5_;
	GSimpleAction* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	GSimpleAction* _tmp12_;
	self = (Clairvoyant*) base;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = gtk_application_get_windows ((GtkApplication*) self);
	if (g_list_length (_tmp0_) > ((guint) 0)) {
		GList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp1_ = gtk_application_get_windows ((GtkApplication*) self);
		_tmp2_ = _tmp1_->data;
		gtk_window_present ((GtkWindow*) _tmp2_);
		block1_data_unref (_data1_);
		_data1_ = NULL;
		return;
	}
	_tmp3_ = main_window_new ((GtkApplication*) self);
	g_object_ref_sink (_tmp3_);
	_data1_->main_window = _tmp3_;
	_tmp4_ = _data1_->main_window;
	gtk_widget_show ((GtkWidget*) _tmp4_);
	_tmp5_ = g_simple_action_new ("quit", NULL);
	quit_action = _tmp5_;
	_tmp6_ = quit_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp6_);
	_tmp7_ = g_strdup ("Escape");
	_tmp8_ = g_strdup ("<Ctrl>Q");
	_tmp9_ = g_strdup ("<Ctrl>W");
	_tmp10_ = g_new0 (gchar*, 3 + 1);
	_tmp10_[0] = _tmp7_;
	_tmp10_[1] = _tmp8_;
	_tmp10_[2] = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp11__length1 = 3;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	_tmp12_ = quit_action;
	g_signal_connect_data (_tmp12_, "activate", (GCallback) ___lambda7__g_simple_action_activate, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_g_object_unref0 (quit_action);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static gint
clairvoyant_main (gchar** args,
                  gint args_length1)
{
	Clairvoyant* app = NULL;
	Clairvoyant* _tmp0_;
	gint result;
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = clairvoyant_new ();
	app = _tmp0_;
	result = g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
	return result;
}

int
main (int argc,
      char ** argv)
{
	return clairvoyant_main (argv, argc);
}

static void
clairvoyant_class_init (ClairvoyantClass * klass,
                        gpointer klass_data)
{
	clairvoyant_parent_class = g_type_class_peek_parent (klass);
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) clairvoyant_real_activate;
}

static void
clairvoyant_instance_init (Clairvoyant * self,
                           gpointer klass)
{
}

static GType
clairvoyant_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ClairvoyantClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) clairvoyant_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Clairvoyant), 0, (GInstanceInitFunc) clairvoyant_instance_init, NULL };
	GType clairvoyant_type_id;
	clairvoyant_type_id = g_type_register_static (adw_application_get_type (), "Clairvoyant", &g_define_type_info, 0);
	return clairvoyant_type_id;
}

GType
clairvoyant_get_type (void)
{
	static volatile gsize clairvoyant_type_id__once = 0;
	if (g_once_init_enter (&clairvoyant_type_id__once)) {
		GType clairvoyant_type_id;
		clairvoyant_type_id = clairvoyant_get_type_once ();
		g_once_init_leave (&clairvoyant_type_id__once, clairvoyant_type_id);
	}
	return clairvoyant_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);
}

