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

/* application.vala
 *
 * Copyright 2023 Diego Iván
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <adwaita.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <locale.h>
#include <glib/gi18n-lib.h>
#include "config.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include <exempi/xmp.h>
#include <glib/gstdio.h>
#include <poppler.h>
#include <gdk-pixbuf/gdk-pixbuf.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 PAPER_CLIP_TYPE_APPLICATION (paper_clip_application_get_type ())
#define PAPER_CLIP_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_APPLICATION, PaperClipApplication))
#define PAPER_CLIP_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_APPLICATION, PaperClipApplicationClass))
#define PAPER_CLIP_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_APPLICATION))
#define PAPER_CLIP_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_APPLICATION))
#define PAPER_CLIP_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_APPLICATION, PaperClipApplicationClass))

typedef struct _PaperClipApplication PaperClipApplication;
typedef struct _PaperClipApplicationClass PaperClipApplicationClass;
typedef struct _PaperClipApplicationPrivate PaperClipApplicationPrivate;
enum  {
	PAPER_CLIP_APPLICATION_0_PROPERTY,
	PAPER_CLIP_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* paper_clip_application_properties[PAPER_CLIP_APPLICATION_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define PAPER_CLIP_TYPE_WINDOW (paper_clip_window_get_type ())
#define PAPER_CLIP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_WINDOW, PaperClipWindow))
#define PAPER_CLIP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_WINDOW, PaperClipWindowClass))
#define PAPER_CLIP_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_WINDOW))
#define PAPER_CLIP_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_WINDOW))
#define PAPER_CLIP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_WINDOW, PaperClipWindowClass))

typedef struct _PaperClipWindow PaperClipWindow;
typedef struct _PaperClipWindowClass PaperClipWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER (paper_clip_services_document_manager_get_type ())
#define PAPER_CLIP_SERVICES_DOCUMENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER, PaperClipServicesDocumentManager))
#define PAPER_CLIP_SERVICES_DOCUMENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER, PaperClipServicesDocumentManagerClass))
#define PAPER_CLIP_SERVICES_IS_DOCUMENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER))
#define PAPER_CLIP_SERVICES_IS_DOCUMENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER))
#define PAPER_CLIP_SERVICES_DOCUMENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER, PaperClipServicesDocumentManagerClass))

typedef struct _PaperClipServicesDocumentManager PaperClipServicesDocumentManager;
typedef struct _PaperClipServicesDocumentManagerClass PaperClipServicesDocumentManagerClass;

#define PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG (paper_clip_save_changes_dialog_get_type ())
#define PAPER_CLIP_SAVE_CHANGES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG, PaperClipSaveChangesDialog))
#define PAPER_CLIP_SAVE_CHANGES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG, PaperClipSaveChangesDialogClass))
#define PAPER_CLIP_IS_SAVE_CHANGES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG))
#define PAPER_CLIP_IS_SAVE_CHANGES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG))
#define PAPER_CLIP_SAVE_CHANGES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG, PaperClipSaveChangesDialogClass))

typedef struct _PaperClipSaveChangesDialog PaperClipSaveChangesDialog;
typedef struct _PaperClipSaveChangesDialogClass PaperClipSaveChangesDialogClass;
typedef enum  {
	PAPER_CLIP_SAVE_CHANGES_RESPONSE_CANCEL,
	PAPER_CLIP_SAVE_CHANGES_RESPONSE_DISCARD,
	PAPER_CLIP_SAVE_CHANGES_RESPONSE_SAVE
} PaperClipSaveChangesResponse;

#define PAPER_CLIP_TYPE_SAVE_CHANGES_RESPONSE (paper_clip_save_changes_response_get_type ())
typedef struct _PaperClipApplicationOnQueryQuitActionAsyncData PaperClipApplicationOnQueryQuitActionAsyncData;
typedef struct _PaperClipApplicationSaveUnsavedManagersData PaperClipApplicationSaveUnsavedManagersData;
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);

struct _PaperClipApplication {
	AdwApplication parent_instance;
	PaperClipApplicationPrivate * priv;
};

struct _PaperClipApplicationClass {
	AdwApplicationClass parent_class;
};

struct _PaperClipApplicationPrivate {
	gchar* debug_information;
};

struct _PaperClipApplicationOnQueryQuitActionAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PaperClipApplication* self;
	PaperClipServicesDocumentManager** managers;
	PaperClipServicesDocumentManager** _tmp0_;
	gint managers_length1;
	gint _managers_size_;
	GList* _tmp1_;
	GList* toplevel_collection;
	GList* toplevel_it;
	GtkWindow* toplevel;
	PaperClipWindow* window;
	GtkWindow* _tmp2_;
	PaperClipWindow* _tmp3_;
	gboolean _tmp4_;
	PaperClipWindow* _tmp5_;
	PaperClipWindow* _tmp6_;
	PaperClipServicesDocumentManager* _tmp7_;
	PaperClipServicesDocumentManager* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	PaperClipWindow* _tmp11_;
	PaperClipServicesDocumentManager* _tmp12_;
	PaperClipServicesDocumentManager* _tmp13_;
	PaperClipServicesDocumentManager* _tmp14_;
	PaperClipServicesDocumentManager** _tmp15_;
	gint _tmp15__length1;
	PaperClipSaveChangesDialog* changes_dialog;
	GtkWindow* _tmp16_;
	GtkWindow* _tmp17_;
	GtkWindow* _tmp18_;
	PaperClipSaveChangesDialog* _tmp19_;
	PaperClipSaveChangesResponse response;
	PaperClipSaveChangesDialog* _tmp20_;
	PaperClipServicesDocumentManager** _tmp21_;
	gint _tmp21__length1;
	PaperClipSaveChangesDialog* _tmp22_;
};

struct _PaperClipApplicationSaveUnsavedManagersData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PaperClipApplication* self;
	PaperClipSaveChangesDialog* changes_dialog;
	GListModel* unsaved_documents;
	GListModel* _tmp0_;
	GListModel* _tmp1_;
	gint i;
	gboolean _tmp2_;
	gint _tmp3_;
	GListModel* _tmp4_;
	PaperClipServicesDocumentManager* unsaved_manager;
	GListModel* _tmp5_;
	GObject* _tmp6_;
	PaperClipServicesDocumentManager* _tmp7_;
};

static gint PaperClipApplication_private_offset;
static gpointer paper_clip_application_parent_class = NULL;

VALA_EXTERN GType paper_clip_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipApplication, g_object_unref)
VALA_EXTERN PaperClipApplication* paper_clip_application_new (void);
VALA_EXTERN PaperClipApplication* paper_clip_application_construct (GType object_type);
static gint paper_clip_application_real_handle_local_options (GApplication* base,
                                                       GVariantDict* options);
static void paper_clip_application_real_activate (GApplication* base);
VALA_EXTERN PaperClipWindow* paper_clip_window_new (GtkApplication* app);
VALA_EXTERN PaperClipWindow* paper_clip_window_construct (GType object_type,
                                              GtkApplication* app);
VALA_EXTERN GType paper_clip_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipWindow, g_object_unref)
static void paper_clip_application_real_startup (GApplication* base);
static void paper_clip_application_real_shutdown (GApplication* base);
static void paper_clip_application_real_open (GApplication* base,
                                       GFile** files,
                                       gint files_length1,
                                       const gchar* hint);
VALA_EXTERN void paper_clip_window_open_command_line_file (PaperClipWindow* self,
                                               GFile* file);
static void paper_clip_application_shortcuts_action (PaperClipApplication* self);
VALA_EXTERN void paper_clip_window_shortcuts (PaperClipWindow* self);
static void paper_clip_application_on_new_window_action (PaperClipApplication* self);
static void paper_clip_application_on_query_quit_action (PaperClipApplication* self);
static void paper_clip_application_on_query_quit_action_async (PaperClipApplication* self,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static void paper_clip_application_on_query_quit_action_finish (PaperClipApplication* self,
                                                         GAsyncResult* _res_);
static void paper_clip_application_on_query_quit_action_async_data_free (gpointer _data);
static gboolean paper_clip_application_on_query_quit_action_async_co (PaperClipApplicationOnQueryQuitActionAsyncData* _data_);
VALA_EXTERN GType paper_clip_services_document_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipServicesDocumentManager, g_object_unref)
VALA_EXTERN PaperClipServicesDocumentManager* paper_clip_window_get_document_manager (PaperClipWindow* self);
VALA_EXTERN gboolean paper_clip_services_document_manager_get_changed (PaperClipServicesDocumentManager* self);
static void _vala_array_add1 (PaperClipServicesDocumentManager** * array,
                       gint* length,
                       gint* size,
                       PaperClipServicesDocumentManager* value);
VALA_EXTERN GType paper_clip_save_changes_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipSaveChangesDialog, g_object_unref)
VALA_EXTERN PaperClipSaveChangesDialog* paper_clip_save_changes_dialog_new (void);
VALA_EXTERN PaperClipSaveChangesDialog* paper_clip_save_changes_dialog_construct (GType object_type);
VALA_EXTERN GType paper_clip_save_changes_response_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void paper_clip_save_changes_dialog_ask (PaperClipSaveChangesDialog* self,
                                         PaperClipServicesDocumentManager** document_managers,
                                         gint document_managers_length1,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN PaperClipSaveChangesResponse paper_clip_save_changes_dialog_ask_finish (PaperClipSaveChangesDialog* self,
                                                                        GAsyncResult* _res_);
static void paper_clip_application_on_query_quit_action_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
static void paper_clip_application_save_unsaved_managers (PaperClipApplication* self,
                                                   PaperClipSaveChangesDialog* changes_dialog,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void paper_clip_application_save_unsaved_managers_finish (PaperClipApplication* self,
                                                          GAsyncResult* _res_);
static void paper_clip_application_save_unsaved_managers_data_free (gpointer _data);
static gboolean paper_clip_application_save_unsaved_managers_co (PaperClipApplicationSaveUnsavedManagersData* _data_);
VALA_EXTERN GListModel* paper_clip_save_changes_dialog_get_selected_documents (PaperClipSaveChangesDialog* self);
VALA_EXTERN void paper_clip_services_document_manager_save (PaperClipServicesDocumentManager* self,
                                                const gchar* uri,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void paper_clip_services_document_manager_save_finish (PaperClipServicesDocumentManager* self,
                                                       GAsyncResult* _res_);
static void paper_clip_application_save_unsaved_managers_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void paper_clip_application_on_about_action (PaperClipApplication* self);
static gchar* paper_clip_application_generate_debug_info (PaperClipApplication* self);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup2 (gchar** self,
                          gssize length);
static GObject * paper_clip_application_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void _paper_clip_application_on_about_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self);
static void _paper_clip_application_shortcuts_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self);
static void _paper_clip_application_on_query_quit_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                    GVariant* parameter,
                                                                                    gpointer self);
static void _paper_clip_application_on_new_window_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                    GVariant* parameter,
                                                                                    gpointer self);
static void paper_clip_application_finalize (GObject * obj);
static GType paper_clip_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);

static inline gpointer
paper_clip_application_get_instance_private (PaperClipApplication* self)
{
	return G_STRUCT_MEMBER_P (self, PaperClipApplication_private_offset);
}

PaperClipApplication*
paper_clip_application_construct (GType object_type)
{
	PaperClipApplication * self = NULL;
	self = (PaperClipApplication*) g_object_new (object_type, "application-id", "io.github.diegoivan.pdf_metadata_editor", "flags", G_APPLICATION_HANDLES_OPEN, NULL);
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	textdomain (GETTEXT_PACKAGE);
	return self;
}

PaperClipApplication*
paper_clip_application_new (void)
{
	return paper_clip_application_construct (PAPER_CLIP_TYPE_APPLICATION);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static gint
paper_clip_application_real_handle_local_options (GApplication* base,
                                                  GVariantDict* options)
{
	PaperClipApplication * self;
	GError* _inner_error0_ = NULL;
	gint result;
	self = (PaperClipApplication*) base;
	g_return_val_if_fail (options != NULL, 0);
	if (g_variant_dict_contains (options, "new-window")) {
		{
			g_application_register ((GApplication*) self, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp0_;
			const gchar* _tmp1_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp0_ = e;
			_tmp1_ = _tmp0_->message;
			g_critical ("application.vala:59: %s", _tmp1_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp2_ = -1;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp2_;
		}
		if (g_application_get_is_remote ((GApplication*) self)) {
			g_action_group_activate_action ((GActionGroup*) self, "new-window", NULL);
			result = 0;
			return result;
		}
	}
	if (g_variant_dict_contains (options, "version")) {
		FILE* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = stderr;
		_tmp4_ = string_to_string (VERSION);
		_tmp5_ = g_strconcat ("Paper Clip ", _tmp4_, "\n", NULL);
		_tmp6_ = _tmp5_;
		fprintf (_tmp3_, "%s", _tmp6_);
		_g_free0 (_tmp6_);
		result = 0;
		return result;
	}
	result = -1;
	return result;
}

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

static void
paper_clip_application_real_activate (GApplication* base)
{
	PaperClipApplication * self;
	GtkWindow* win = NULL;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* _tmp5_;
	self = (PaperClipApplication*) base;
	G_APPLICATION_CLASS (paper_clip_application_parent_class)->activate ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	win = _tmp2_;
	_tmp3_ = win;
	if (_tmp3_ == NULL) {
		PaperClipWindow* _tmp4_;
		_tmp4_ = paper_clip_window_new ((GtkApplication*) self);
		g_object_ref_sink (_tmp4_);
		_g_object_unref0 (win);
		win = (GtkWindow*) _tmp4_;
	}
	_tmp5_ = win;
	gtk_window_present (_tmp5_);
	_g_object_unref0 (win);
}

static void
paper_clip_application_real_startup (GApplication* base)
{
	PaperClipApplication * self;
	self = (PaperClipApplication*) base;
	G_APPLICATION_CLASS (paper_clip_application_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	xmp_init ();
}

static void
paper_clip_application_real_shutdown (GApplication* base)
{
	PaperClipApplication * self;
	self = (PaperClipApplication*) base;
	G_APPLICATION_CLASS (paper_clip_application_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	xmp_terminate ();
}

static void
paper_clip_application_real_open (GApplication* base,
                                  GFile** files,
                                  gint files_length1,
                                  const gchar* hint)
{
	PaperClipApplication * self;
	GError* _inner_error0_ = NULL;
	self = (PaperClipApplication*) base;
	g_return_if_fail (hint != NULL);
	if (files_length1 < 1) {
		return;
	}
	{
		GFile** file_collection = NULL;
		gint file_collection_length1 = 0;
		gint _file_collection_size_ = 0;
		gint file_it = 0;
		file_collection = files;
		file_collection_length1 = files_length1;
		for (file_it = 0; file_it < file_collection_length1; file_it = file_it + 1) {
			GFile* _tmp0_;
			GFile* file = NULL;
			_tmp0_ = _g_object_ref0 (file_collection[file_it]);
			file = _tmp0_;
			{
				{
					GFileInfo* info = NULL;
					GFile* _tmp1_;
					GFileInfo* _tmp2_;
					gchar* content_type = NULL;
					GFileInfo* _tmp3_;
					const gchar* _tmp4_;
					gchar* _tmp5_;
					const gchar* _tmp6_;
					PaperClipWindow* window = NULL;
					PaperClipWindow* _tmp13_;
					PaperClipWindow* _tmp14_;
					GFile* _tmp15_;
					PaperClipWindow* _tmp16_;
					_tmp1_ = file;
					_tmp2_ = g_file_query_info (_tmp1_, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error0_);
					info = _tmp2_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp3_ = info;
					_tmp4_ = g_file_info_get_content_type (_tmp3_);
					_tmp5_ = g_strdup (_tmp4_);
					content_type = _tmp5_;
					_tmp6_ = content_type;
					if (g_strcmp0 (_tmp6_, "application/pdf") != 0) {
						GFile* _tmp7_;
						gchar* _tmp8_;
						gchar* _tmp9_;
						const gchar* _tmp10_;
						gchar* _tmp11_;
						gchar* _tmp12_;
						_tmp7_ = file;
						_tmp8_ = g_file_get_path (_tmp7_);
						_tmp9_ = _tmp8_;
						_tmp10_ = string_to_string (_tmp9_);
						_tmp11_ = g_strconcat ("File ", _tmp10_, " is not a PDF", NULL);
						_tmp12_ = _tmp11_;
						g_critical ("application.vala:105: %s", _tmp12_);
						_g_free0 (_tmp12_);
						_g_free0 (_tmp9_);
						_g_free0 (content_type);
						_g_object_unref0 (info);
						_g_object_unref0 (file);
						continue;
					}
					_tmp13_ = paper_clip_window_new ((GtkApplication*) self);
					g_object_ref_sink (_tmp13_);
					window = _tmp13_;
					_tmp14_ = window;
					_tmp15_ = file;
					paper_clip_window_open_command_line_file (_tmp14_, _tmp15_);
					_tmp16_ = window;
					gtk_window_present ((GtkWindow*) _tmp16_);
					_g_object_unref0 (window);
					_g_free0 (content_type);
					_g_object_unref0 (info);
				}
				goto __finally0;
				__catch0_g_error:
				{
					GError* e = NULL;
					GError* _tmp17_;
					const gchar* _tmp18_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp17_ = e;
					_tmp18_ = _tmp17_->message;
					g_critical ("application.vala:113: %s", _tmp18_);
					_g_error_free0 (e);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (file);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
				_g_object_unref0 (file);
			}
		}
	}
	g_application_activate ((GApplication*) self);
}

static void
paper_clip_application_shortcuts_action (PaperClipApplication* self)
{
	PaperClipWindow* window = NULL;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	PaperClipWindow* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, PAPER_CLIP_TYPE_WINDOW, PaperClipWindow));
	window = _tmp2_;
	paper_clip_window_shortcuts (window);
	_g_object_unref0 (window);
}

static void
paper_clip_application_on_new_window_action (PaperClipApplication* self)
{
	PaperClipWindow* window = NULL;
	PaperClipWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = paper_clip_window_new ((GtkApplication*) self);
	g_object_ref_sink (_tmp0_);
	window = _tmp0_;
	gtk_window_present ((GtkWindow*) window);
	_g_object_unref0 (window);
}

static void
paper_clip_application_on_query_quit_action (PaperClipApplication* self)
{
	g_return_if_fail (self != NULL);
	paper_clip_application_on_query_quit_action_async (self, NULL, NULL);
}

static void
paper_clip_application_on_query_quit_action_async_data_free (gpointer _data)
{
	PaperClipApplicationOnQueryQuitActionAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PaperClipApplicationOnQueryQuitActionAsyncData, _data_);
}

static void
paper_clip_application_on_query_quit_action_async (PaperClipApplication* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	PaperClipApplicationOnQueryQuitActionAsyncData* _data_;
	PaperClipApplication* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (PaperClipApplicationOnQueryQuitActionAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, paper_clip_application_on_query_quit_action_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	paper_clip_application_on_query_quit_action_async_co (_data_);
}

static void
paper_clip_application_on_query_quit_action_finish (PaperClipApplication* self,
                                                    GAsyncResult* _res_)
{
	PaperClipApplicationOnQueryQuitActionAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_vala_array_add1 (PaperClipServicesDocumentManager** * array,
                  gint* length,
                  gint* size,
                  PaperClipServicesDocumentManager* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (PaperClipServicesDocumentManager*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
paper_clip_application_on_query_quit_action_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	PaperClipApplicationOnQueryQuitActionAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	paper_clip_application_on_query_quit_action_async_co (_data_);
}

static gboolean
paper_clip_application_on_query_quit_action_async_co (PaperClipApplicationOnQueryQuitActionAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_new0 (PaperClipServicesDocumentManager*, 0 + 1);
	_data_->managers = _data_->_tmp0_;
	_data_->managers_length1 = 0;
	_data_->_managers_size_ = _data_->managers_length1;
	_data_->_tmp1_ = gtk_window_list_toplevels ();
	{
		_data_->toplevel_collection = _data_->_tmp1_;
		for (_data_->toplevel_it = _data_->toplevel_collection; _data_->toplevel_it != NULL; _data_->toplevel_it = _data_->toplevel_it->next) {
			_data_->toplevel = (GtkWindow*) _data_->toplevel_it->data;
			{
				_data_->_tmp2_ = _data_->toplevel;
				_data_->_tmp3_ = _g_object_ref0 (PAPER_CLIP_IS_WINDOW (_data_->_tmp2_) ? ((PaperClipWindow*) _data_->_tmp2_) : NULL);
				_data_->window = _data_->_tmp3_;
				_data_->_tmp5_ = _data_->window;
				if (_data_->_tmp5_ == NULL) {
					_data_->_tmp4_ = TRUE;
				} else {
					_data_->_tmp6_ = _data_->window;
					_data_->_tmp7_ = paper_clip_window_get_document_manager (_data_->_tmp6_);
					_data_->_tmp8_ = _data_->_tmp7_;
					_data_->_tmp9_ = paper_clip_services_document_manager_get_changed (_data_->_tmp8_);
					_data_->_tmp10_ = _data_->_tmp9_;
					_data_->_tmp4_ = !_data_->_tmp10_;
				}
				if (_data_->_tmp4_) {
					_g_object_unref0 (_data_->window);
					continue;
				}
				_data_->_tmp11_ = _data_->window;
				_data_->_tmp12_ = paper_clip_window_get_document_manager (_data_->_tmp11_);
				_data_->_tmp13_ = _data_->_tmp12_;
				_data_->_tmp14_ = _g_object_ref0 (_data_->_tmp13_);
				_vala_array_add1 (&_data_->managers, &_data_->managers_length1, &_data_->_managers_size_, _data_->_tmp14_);
				_g_object_unref0 (_data_->window);
			}
		}
		(_data_->toplevel_collection == NULL) ? NULL : (_data_->toplevel_collection = (g_list_free (_data_->toplevel_collection), NULL));
	}
	_data_->_tmp15_ = _data_->managers;
	_data_->_tmp15__length1 = _data_->managers_length1;
	if (_data_->_tmp15__length1 < 1) {
		g_application_quit ((GApplication*) _data_->self);
		_data_->managers = (_vala_array_free (_data_->managers, _data_->managers_length1, (GDestroyNotify) g_object_unref), NULL);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp16_ = gtk_application_get_active_window ((GtkApplication*) _data_->self);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = _g_object_ref0 (_data_->_tmp17_);
	_data_->_tmp19_ = NULL;
	_data_->_tmp19_ = paper_clip_save_changes_dialog_new ();
	gtk_window_set_transient_for ((GtkWindow*) _data_->_tmp19_, _data_->_tmp18_);
	_g_object_unref0 (_data_->_tmp18_);
	gtk_window_set_modal ((GtkWindow*) _data_->_tmp19_, TRUE);
	g_object_ref_sink (_data_->_tmp19_);
	_data_->changes_dialog = _data_->_tmp19_;
	_data_->_tmp20_ = _data_->changes_dialog;
	_data_->_tmp21_ = _data_->managers;
	_data_->_tmp21__length1 = _data_->managers_length1;
	_data_->_state_ = 1;
	paper_clip_save_changes_dialog_ask (_data_->_tmp20_, _data_->_tmp21_, (gint) _data_->_tmp21__length1, NULL, paper_clip_application_on_query_quit_action_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->response = paper_clip_save_changes_dialog_ask_finish (_data_->_tmp20_, _data_->_res_);
	switch (_data_->response) {
		case PAPER_CLIP_SAVE_CHANGES_RESPONSE_SAVE:
		{
			_data_->_tmp22_ = _data_->changes_dialog;
			_data_->_state_ = 2;
			paper_clip_application_save_unsaved_managers (_data_->self, _data_->_tmp22_, paper_clip_application_on_query_quit_action_async_ready, _data_);
			return FALSE;
			_state_2:
			paper_clip_application_save_unsaved_managers_finish (_data_->self, _data_->_res_);
			break;
		}
		case PAPER_CLIP_SAVE_CHANGES_RESPONSE_DISCARD:
		{
			g_application_quit ((GApplication*) _data_->self);
			break;
		}
		default:
		case PAPER_CLIP_SAVE_CHANGES_RESPONSE_CANCEL:
		{
			_g_object_unref0 (_data_->changes_dialog);
			_data_->managers = (_vala_array_free (_data_->managers, _data_->managers_length1, (GDestroyNotify) g_object_unref), NULL);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->changes_dialog);
	_data_->managers = (_vala_array_free (_data_->managers, _data_->managers_length1, (GDestroyNotify) g_object_unref), NULL);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
paper_clip_application_save_unsaved_managers_data_free (gpointer _data)
{
	PaperClipApplicationSaveUnsavedManagersData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->changes_dialog);
	_g_object_unref0 (_data_->self);
	g_slice_free (PaperClipApplicationSaveUnsavedManagersData, _data_);
}

static void
paper_clip_application_save_unsaved_managers (PaperClipApplication* self,
                                              PaperClipSaveChangesDialog* changes_dialog,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	PaperClipApplicationSaveUnsavedManagersData* _data_;
	PaperClipApplication* _tmp0_;
	PaperClipSaveChangesDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (changes_dialog != NULL);
	_data_ = g_slice_new0 (PaperClipApplicationSaveUnsavedManagersData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, paper_clip_application_save_unsaved_managers_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (changes_dialog);
	_g_object_unref0 (_data_->changes_dialog);
	_data_->changes_dialog = _tmp1_;
	paper_clip_application_save_unsaved_managers_co (_data_);
}

static void
paper_clip_application_save_unsaved_managers_finish (PaperClipApplication* self,
                                                     GAsyncResult* _res_)
{
	PaperClipApplicationSaveUnsavedManagersData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
paper_clip_application_save_unsaved_managers_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	PaperClipApplicationSaveUnsavedManagersData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	paper_clip_application_save_unsaved_managers_co (_data_);
}

static gboolean
paper_clip_application_save_unsaved_managers_co (PaperClipApplicationSaveUnsavedManagersData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = paper_clip_save_changes_dialog_get_selected_documents (_data_->changes_dialog);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->unsaved_documents = _data_->_tmp1_;
	{
		_data_->i = 0;
		{
			_data_->_tmp2_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp2_) {
					_data_->_tmp3_ = _data_->i;
					_data_->i = _data_->_tmp3_ + 1;
				}
				_data_->_tmp2_ = FALSE;
				_data_->_tmp4_ = _data_->unsaved_documents;
				if (!(((guint) _data_->i) < g_list_model_get_n_items (_data_->_tmp4_))) {
					break;
				}
				_data_->_tmp5_ = _data_->unsaved_documents;
				_data_->_tmp6_ = g_list_model_get_item (_data_->_tmp5_, (guint) _data_->i);
				_data_->unsaved_manager = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER, PaperClipServicesDocumentManager);
				_data_->_tmp7_ = _data_->unsaved_manager;
				_data_->_state_ = 1;
				paper_clip_services_document_manager_save (_data_->_tmp7_, NULL, paper_clip_application_save_unsaved_managers_ready, _data_);
				return FALSE;
				_state_1:
				paper_clip_services_document_manager_save_finish (_data_->_tmp7_, _data_->_res_);
				_g_object_unref0 (_data_->unsaved_manager);
			}
		}
	}
	g_application_quit ((GApplication*) _data_->self);
	_g_object_unref0 (_data_->unsaved_documents);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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
paper_clip_application_on_about_action (PaperClipApplication* self)
{
	gchar** developers = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gint developers_length1;
	gint _developers_size_;
	gchar** artists = NULL;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint artists_length1;
	gint _artists_size_;
	AdwAboutDialog* about = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	AdwAboutDialog* _tmp15_ = NULL;
	GtkWindow* _tmp16_;
	GtkWindow* _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("Diego Iván M.E");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	developers = _tmp1_;
	developers_length1 = 1;
	_developers_size_ = developers_length1;
	_tmp2_ = g_strdup ("Brage Fuglseth");
	_tmp3_ = g_new0 (gchar*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	artists = _tmp3_;
	artists_length1 = 1;
	_artists_size_ = artists_length1;
	_tmp4_ = g_strdup (APP_ID);
	_tmp5_ = g_strdup ("Paper Clip");
	_tmp6_ = g_strdup ("© 2023-2024 Diego Iván M.E");
	_tmp7_ = g_strdup ("Diego Iván M.E");
	_tmp8_ = paper_clip_application_generate_debug_info (self);
	_tmp9_ = (developers != NULL) ? _vala_array_dup1 (developers, developers_length1) : developers;
	_tmp9__length1 = developers_length1;
	_tmp10_ = (artists != NULL) ? _vala_array_dup2 (artists, artists_length1) : artists;
	_tmp10__length1 = artists_length1;
	_tmp11_ = g_strdup ("https://github.com/Diego-Ivan/Paper-Clip/issues");
	_tmp12_ = g_strdup (_ ("translator_credits"));
	_tmp13_ = g_strdup (VERSION);
	_tmp14_ = g_strdup ("https://github.com/Diego-Ivan/Paper-Clip");
	_tmp15_ = (AdwAboutDialog*) adw_about_dialog_new ();
	adw_about_dialog_set_application_icon (_tmp15_, _tmp4_);
	_g_free0 (_tmp4_);
	adw_about_dialog_set_application_name (_tmp15_, _tmp5_);
	_g_free0 (_tmp5_);
	adw_about_dialog_set_copyright (_tmp15_, _tmp6_);
	_g_free0 (_tmp6_);
	adw_about_dialog_set_developer_name (_tmp15_, _tmp7_);
	_g_free0 (_tmp7_);
	adw_about_dialog_set_debug_info (_tmp15_, _tmp8_);
	_g_free0 (_tmp8_);
	adw_about_dialog_set_developers (_tmp15_, _tmp9_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_artists (_tmp15_, _tmp10_);
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_issue_url (_tmp15_, _tmp11_);
	_g_free0 (_tmp11_);
	adw_about_dialog_set_license_type (_tmp15_, GTK_LICENSE_GPL_3_0);
	adw_about_dialog_set_translator_credits (_tmp15_, _tmp12_);
	_g_free0 (_tmp12_);
	adw_about_dialog_set_version (_tmp15_, _tmp13_);
	_g_free0 (_tmp13_);
	adw_about_dialog_set_website (_tmp15_, _tmp14_);
	_g_free0 (_tmp14_);
	g_object_ref_sink (_tmp15_);
	about = _tmp15_;
	_tmp16_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp17_ = _tmp16_;
	adw_dialog_present ((AdwDialog*) about, (GtkWidget*) _tmp17_);
	_g_object_unref0 (about);
	artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
	developers = (_vala_array_free (developers, developers_length1, (GDestroyNotify) g_free), NULL);
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static gchar*
paper_clip_application_generate_debug_info (PaperClipApplication* self)
{
	const gchar* _tmp0_;
	gboolean under_flatpak = FALSE;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->debug_information;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = self->priv->debug_information;
		_tmp2_ = g_strdup (_tmp1_);
		result = _tmp2_;
		return result;
	}
	under_flatpak = g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
	_tmp3_ = string_to_string (VERSION);
	_tmp4_ = g_strdup_printf ("%u", gtk_get_major_version ());
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup_printf ("%u", gtk_get_minor_version ());
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strdup_printf ("%u", gtk_get_micro_version ());
	_tmp9_ = _tmp8_;
	_tmp10_ = string_to_string (ADW_VERSION_S);
	_tmp11_ = poppler_get_version ();
	_tmp12_ = string_to_string (_tmp11_);
	_tmp13_ = string_to_string (EXEMPI_VERSION);
	_tmp14_ = string_to_string (GDK_PIXBUF_VERSION);
	_tmp15_ = bool_to_string (under_flatpak);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_get_os_info (G_OS_INFO_KEY_PRETTY_NAME);
	_tmp18_ = _tmp17_;
	_tmp19_ = string_to_string (_tmp18_);
	_tmp20_ = g_strconcat ("Paper Clip ", _tmp3_, "\nLibraries:\nGtk ", _tmp5_, ".", _tmp7_, ".", _tmp9_, " (Runtime)\nLibadwaita: ", _tmp10_, " (Compile Time)\nPoppler: ", _tmp12_, " (Compile Time)\nExempi: ", _tmp13_, "\nGdkPixbuf ", _tmp14_, " (Compile Time)\n\nRunning under Flatpak? ", _tmp16_, "\nOS Information? ", _tmp19_, NULL);
	_g_free0 (self->priv->debug_information);
	self->priv->debug_information = _tmp20_;
	_g_free0 (_tmp18_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_tmp21_ = self->priv->debug_information;
	_tmp22_ = g_strdup (_tmp21_);
	result = _tmp22_;
	return result;
}

static void
_paper_clip_application_on_about_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                          GVariant* parameter,
                                                                          gpointer self)
{
	paper_clip_application_on_about_action ((PaperClipApplication*) self);
}

static void
_paper_clip_application_shortcuts_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                           GVariant* parameter,
                                                                           gpointer self)
{
	paper_clip_application_shortcuts_action ((PaperClipApplication*) self);
}

static void
_paper_clip_application_on_query_quit_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self)
{
	paper_clip_application_on_query_quit_action ((PaperClipApplication*) self);
}

static void
_paper_clip_application_on_new_window_action_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self)
{
	paper_clip_application_on_new_window_action ((PaperClipApplication*) self);
}

static GObject *
paper_clip_application_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PaperClipApplication * self;
	GActionEntry* action_entries = NULL;
	GActionEntry _tmp0_ = {0};
	GActionEntry _tmp1_ = {0};
	GActionEntry _tmp2_ = {0};
	GActionEntry _tmp3_ = {0};
	GActionEntry* _tmp4_;
	gint action_entries_length1;
	gint _action_entries_size_;
	GActionEntry* _tmp5_;
	gint _tmp5__length1;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar* _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	GOptionEntry* option_entries = NULL;
	GOptionEntry _tmp15_ = {0};
	GOptionEntry _tmp16_ = {0};
	GOptionEntry _tmp17_ = {0};
	GOptionEntry* _tmp18_;
	gint option_entries_length1;
	gint _option_entries_size_;
	GOptionEntry* _tmp19_;
	gint _tmp19__length1;
	parent_class = G_OBJECT_CLASS (paper_clip_application_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_APPLICATION, PaperClipApplication);
	memset (&_tmp0_, 0, sizeof (GActionEntry));
	_tmp0_.name = "about";
	_tmp0_.activate = _paper_clip_application_on_about_action_gsimple_action_activate_callback;
	memset (&_tmp1_, 0, sizeof (GActionEntry));
	_tmp1_.name = "shortcuts";
	_tmp1_.activate = _paper_clip_application_shortcuts_action_gsimple_action_activate_callback;
	memset (&_tmp2_, 0, sizeof (GActionEntry));
	_tmp2_.name = "query-quit";
	_tmp2_.activate = _paper_clip_application_on_query_quit_action_gsimple_action_activate_callback;
	memset (&_tmp3_, 0, sizeof (GActionEntry));
	_tmp3_.name = "new-window";
	_tmp3_.activate = _paper_clip_application_on_new_window_action_gsimple_action_activate_callback;
	_tmp4_ = g_new0 (GActionEntry, 4);
	_tmp4_[0] = _tmp0_;
	_tmp4_[1] = _tmp1_;
	_tmp4_[2] = _tmp2_;
	_tmp4_[3] = _tmp3_;
	action_entries = _tmp4_;
	action_entries_length1 = 4;
	_action_entries_size_ = action_entries_length1;
	_tmp5_ = action_entries;
	_tmp5__length1 = action_entries_length1;
	g_action_map_add_action_entries ((GActionMap*) self, _tmp5_, (gint) _tmp5__length1, self);
	_tmp6_ = g_strdup ("<Ctrl>question");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.shortcuts", _tmp8_);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = g_strdup ("<Ctrl>q");
	_tmp10_ = g_new0 (gchar*, 1 + 1);
	_tmp10_[0] = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp11__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.query-quit", _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	_tmp12_ = g_strdup ("<Ctrl>n");
	_tmp13_ = g_new0 (gchar*, 1 + 1);
	_tmp13_[0] = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.new-window", _tmp14_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	memset (&_tmp15_, 0, sizeof (GOptionEntry));
	_tmp15_.long_name = "new-window";
	_tmp15_.short_name = 'w';
	_tmp15_.flags = (gint) G_OPTION_FLAG_NONE;
	_tmp15_.arg = G_OPTION_ARG_NONE;
	_tmp15_.arg_data = NULL;
	_tmp15_.description = N_ ("Open a new window");
	_tmp15_.arg_description = NULL;
	memset (&_tmp16_, 0, sizeof (GOptionEntry));
	_tmp16_.long_name = "version";
	_tmp16_.short_name = 'v';
	_tmp16_.flags = (gint) G_OPTION_FLAG_NONE;
	_tmp16_.arg = G_OPTION_ARG_NONE;
	_tmp16_.arg_data = NULL;
	_tmp16_.description = N_ ("Print version information and exit");
	_tmp16_.arg_description = NULL;
	memset (&_tmp17_, 0, sizeof (GOptionEntry));
	_tmp18_ = g_new0 (GOptionEntry, 3);
	_tmp18_[0] = _tmp15_;
	_tmp18_[1] = _tmp16_;
	_tmp18_[2] = _tmp17_;
	option_entries = _tmp18_;
	option_entries_length1 = 3;
	_option_entries_size_ = option_entries_length1;
	_tmp19_ = option_entries;
	_tmp19__length1 = option_entries_length1;
	g_application_add_main_option_entries ((GApplication*) self, _tmp19_);
	option_entries = (g_free (option_entries), NULL);
	action_entries = (g_free (action_entries), NULL);
	return obj;
}

static void
paper_clip_application_class_init (PaperClipApplicationClass * klass,
                                   gpointer klass_data)
{
	paper_clip_application_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PaperClipApplication_private_offset);
	((GApplicationClass *) klass)->handle_local_options = (gint (*) (GApplication*, GVariantDict*)) paper_clip_application_real_handle_local_options;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) paper_clip_application_real_activate;
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) paper_clip_application_real_startup;
	((GApplicationClass *) klass)->shutdown = (void (*) (GApplication*)) paper_clip_application_real_shutdown;
	((GApplicationClass *) klass)->open = (void (*) (GApplication*, GFile**, gint, const gchar*)) paper_clip_application_real_open;
	G_OBJECT_CLASS (klass)->constructor = paper_clip_application_constructor;
	G_OBJECT_CLASS (klass)->finalize = paper_clip_application_finalize;
}

static void
paper_clip_application_instance_init (PaperClipApplication * self,
                                      gpointer klass)
{
	self->priv = paper_clip_application_get_instance_private (self);
	self->priv->debug_information = NULL;
}

static void
paper_clip_application_finalize (GObject * obj)
{
	PaperClipApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_APPLICATION, PaperClipApplication);
	_g_free0 (self->priv->debug_information);
	G_OBJECT_CLASS (paper_clip_application_parent_class)->finalize (obj);
}

static GType
paper_clip_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PaperClipApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) paper_clip_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PaperClipApplication), 0, (GInstanceInitFunc) paper_clip_application_instance_init, NULL };
	GType paper_clip_application_type_id;
	paper_clip_application_type_id = g_type_register_static (adw_application_get_type (), "PaperClipApplication", &g_define_type_info, 0);
	PaperClipApplication_private_offset = g_type_add_instance_private (paper_clip_application_type_id, sizeof (PaperClipApplicationPrivate));
	return paper_clip_application_type_id;
}

GType
paper_clip_application_get_type (void)
{
	static volatile gsize paper_clip_application_type_id__once = 0;
	if (g_once_init_enter (&paper_clip_application_type_id__once)) {
		GType paper_clip_application_type_id;
		paper_clip_application_type_id = paper_clip_application_get_type_once ();
		g_once_init_leave (&paper_clip_application_type_id__once, paper_clip_application_type_id);
	}
	return paper_clip_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);
}

