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

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

#define BUILD_INSTALL_PREFIX "/usr"
#define BUILD_GETTEXT_PACKAGE "io.github.alainm23.planify"
#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_QUICK_ADD (quick_add_get_type ())
#define QUICK_ADD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_QUICK_ADD, QuickAdd))
#define QUICK_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_QUICK_ADD, QuickAddClass))
#define IS_QUICK_ADD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_QUICK_ADD))
#define IS_QUICK_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_QUICK_ADD))
#define QUICK_ADD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_QUICK_ADD, QuickAddClass))

typedef struct _QuickAdd QuickAdd;
typedef struct _QuickAddClass QuickAddClass;
typedef struct _QuickAddPrivate QuickAddPrivate;

#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;
enum  {
	QUICK_ADD_0_PROPERTY,
	QUICK_ADD_NUM_PROPERTIES
};
static GParamSpec* quick_add_properties[QUICK_ADD_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 _QuickAdd {
	AdwApplication parent_instance;
	QuickAddPrivate * priv;
	MainWindow* main_window;
};

struct _QuickAddClass {
	AdwApplicationClass parent_class;
};

static gpointer quick_add_parent_class = NULL;
VALA_EXTERN QuickAdd* quick_add__instance;
QuickAdd* quick_add__instance = NULL;

VALA_EXTERN GType quick_add_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (QuickAdd, g_object_unref)
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
static void quick_add_real_activate (GApplication* base);
VALA_EXTERN MainWindow* main_window_new (QuickAdd* application);
VALA_EXTERN MainWindow* main_window_construct (GType object_type,
                                   QuickAdd* application);
static void __lambda8_ (QuickAdd* self);
VALA_EXTERN gboolean main_window_get_can_close (MainWindow* self);
static gboolean ___lambda9_ (QuickAdd* self);
static gboolean ____lambda9__gsource_func (gpointer self);
static void ___lambda8__g_simple_action_activate (GSimpleAction* _sender,
                                           GVariant* parameter,
                                           gpointer self);
static gint quick_add_main (gchar** args,
                     gint args_length1);
VALA_EXTERN QuickAdd* quick_add_get_instance (void);
VALA_EXTERN QuickAdd* quick_add_new (void);
VALA_EXTERN QuickAdd* quick_add_construct (GType object_type);
static GObject * quick_add_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void quick_add_finalize (GObject * obj);
static GType quick_add_get_type_once (void);
static void _vala_quick_add_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
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 gboolean
___lambda9_ (QuickAdd* self)
{
	MainWindow* _tmp0_;
	gboolean result;
	_tmp0_ = self->main_window;
	gtk_window_destroy ((GtkWindow*) _tmp0_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda9__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda9_ ((QuickAdd*) self);
	return result;
}

static void
__lambda8_ (QuickAdd* self)
{
	gboolean _tmp0_ = FALSE;
	MainWindow* _tmp1_;
	_tmp1_ = self->main_window;
	if (_tmp1_ != NULL) {
		MainWindow* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->main_window;
		_tmp3_ = main_window_get_can_close (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		MainWindow* _tmp5_;
		_tmp5_ = self->main_window;
		gtk_widget_hide ((GtkWidget*) _tmp5_);
		g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 500, ____lambda9__gsource_func, g_object_ref (self), g_object_unref);
	}
}

static void
___lambda8__g_simple_action_activate (GSimpleAction* _sender,
                                      GVariant* parameter,
                                      gpointer self)
{
	__lambda8_ ((QuickAdd*) self);
}

static void
quick_add_real_activate (GApplication* base)
{
	QuickAdd * self;
	MainWindow* _tmp0_;
	MainWindow* _tmp1_;
	GSimpleAction* quit_action = NULL;
	GSimpleAction* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	GtkCssProvider* provider = NULL;
	GtkCssProvider* _tmp6_;
	GdkDisplay* _tmp7_;
	Util* _tmp8_;
	Util* _tmp9_;
	Util* _tmp10_;
	Util* _tmp11_;
	self = (QuickAdd*) base;
	_tmp0_ = main_window_new (self);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->main_window);
	self->main_window = _tmp0_;
	_tmp1_ = self->main_window;
	gtk_widget_show ((GtkWidget*) _tmp1_);
	_tmp2_ = g_simple_action_new ("quit", NULL);
	quit_action = _tmp2_;
	g_action_map_add_action ((GActionMap*) self, (GAction*) quit_action);
	_tmp3_ = g_strdup ("Escape");
	_tmp4_ = g_new0 (gchar*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp5_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	g_signal_connect_object (quit_action, "activate", (GCallback) ___lambda8__g_simple_action_activate, self, 0);
	_tmp6_ = gtk_css_provider_new ();
	provider = _tmp6_;
	gtk_css_provider_load_from_resource (provider, "/io/github/alainm23/planify/index.css");
	_tmp7_ = gdk_display_get_default ();
	gtk_style_context_add_provider_for_display (_tmp7_, (GtkStyleProvider*) provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp8_ = util_get_default ();
	_tmp9_ = _tmp8_;
	util_update_theme (_tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = util_get_default ();
	_tmp11_ = _tmp10_;
	util_update_font_scale (_tmp11_);
	_g_object_unref0 (_tmp11_);
	_g_object_unref0 (provider);
	_g_object_unref0 (quit_action);
}

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

static gint
quick_add_main (gchar** args,
                gint args_length1)
{
	QuickAdd* app = NULL;
	QuickAdd* _tmp0_;
	QuickAdd* _tmp1_;
	QuickAdd* _tmp2_;
	gint result;
	_tmp0_ = quick_add_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	app = _tmp2_;
	result = g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
	return result;
}

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

QuickAdd*
quick_add_construct (GType object_type)
{
	QuickAdd * self = NULL;
	self = (QuickAdd*) g_object_new (object_type, NULL);
	return self;
}

QuickAdd*
quick_add_new (void)
{
	return quick_add_construct (TYPE_QUICK_ADD);
}

QuickAdd*
quick_add_get_instance (void)
{
	QuickAdd* result;
	QuickAdd* _tmp0_;
	QuickAdd* _tmp2_;
	_tmp0_ = quick_add__instance;
	if (_tmp0_ == NULL) {
		QuickAdd* _tmp1_;
		_tmp1_ = quick_add_new ();
		_g_object_unref0 (quick_add__instance);
		quick_add__instance = _tmp1_;
	}
	_tmp2_ = quick_add__instance;
	result = _tmp2_;
	return result;
}

static GObject *
quick_add_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	QuickAdd * self;
	GApplicationFlags _tmp0_;
	GApplicationFlags _tmp1_;
	gchar* langpack_dir = NULL;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	parent_class = G_OBJECT_CLASS (quick_add_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_QUICK_ADD, QuickAdd);
	g_application_set_application_id ((GApplication*) self, "io.github.alainm23.planify.quick-add");
	_tmp0_ = g_application_get_flags ((GApplication*) self);
	_tmp1_ = _tmp0_;
	g_application_set_flags ((GApplication*) self, _tmp1_ | G_APPLICATION_FLAGS_NONE);
	setlocale (LC_ALL, "");
	_tmp2_ = g_build_filename (BUILD_INSTALL_PREFIX, "share", "locale", NULL);
	langpack_dir = _tmp2_;
	_tmp3_ = langpack_dir;
	bindtextdomain (BUILD_GETTEXT_PACKAGE, _tmp3_);
	bind_textdomain_codeset (BUILD_GETTEXT_PACKAGE, "UTF-8");
	textdomain (BUILD_GETTEXT_PACKAGE);
	_g_free0 (langpack_dir);
	return obj;
}

static void
quick_add_class_init (QuickAddClass * klass,
                      gpointer klass_data)
{
	quick_add_parent_class = g_type_class_peek_parent (klass);
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) quick_add_real_activate;
	G_OBJECT_CLASS (klass)->get_property = _vala_quick_add_get_property;
	G_OBJECT_CLASS (klass)->constructor = quick_add_constructor;
	G_OBJECT_CLASS (klass)->finalize = quick_add_finalize;
}

static void
quick_add_instance_init (QuickAdd * self,
                         gpointer klass)
{
}

static void
quick_add_finalize (GObject * obj)
{
	QuickAdd * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_QUICK_ADD, QuickAdd);
	_g_object_unref0 (self->main_window);
	G_OBJECT_CLASS (quick_add_parent_class)->finalize (obj);
}

static GType
quick_add_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QuickAddClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) quick_add_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QuickAdd), 0, (GInstanceInitFunc) quick_add_instance_init, NULL };
	GType quick_add_type_id;
	quick_add_type_id = g_type_register_static (adw_application_get_type (), "QuickAdd", &g_define_type_info, 0);
	return quick_add_type_id;
}

GType
quick_add_get_type (void)
{
	static volatile gsize quick_add_type_id__once = 0;
	if (g_once_init_enter (&quick_add_type_id__once)) {
		GType quick_add_type_id;
		quick_add_type_id = quick_add_get_type_once ();
		g_once_init_leave (&quick_add_type_id__once, quick_add_type_id);
	}
	return quick_add_type_id__once;
}

static void
_vala_quick_add_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	QuickAdd * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_QUICK_ADD, QuickAdd);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

