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

/* SaveChangesDialog.vala
 *
 * Copyright 2023 Diego Iván <diegoivan.mae@gmail.com>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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_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 struct _PaperClipSaveChangesDialogPrivate PaperClipSaveChangesDialogPrivate;
enum  {
	PAPER_CLIP_SAVE_CHANGES_DIALOG_0_PROPERTY,
	PAPER_CLIP_SAVE_CHANGES_DIALOG_SELECTED_DOCUMENTS_PROPERTY,
	PAPER_CLIP_SAVE_CHANGES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* paper_clip_save_changes_dialog_properties[PAPER_CLIP_SAVE_CHANGES_DIALOG_NUM_PROPERTIES];
#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;
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 ())

#define PAPER_CLIP_TYPE_DOCUMENT_ROW (paper_clip_document_row_get_type ())
#define PAPER_CLIP_DOCUMENT_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow))
#define PAPER_CLIP_DOCUMENT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRowClass))
#define PAPER_CLIP_IS_DOCUMENT_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DOCUMENT_ROW))
#define PAPER_CLIP_IS_DOCUMENT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DOCUMENT_ROW))
#define PAPER_CLIP_DOCUMENT_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRowClass))

typedef struct _PaperClipDocumentRow PaperClipDocumentRow;
typedef struct _PaperClipDocumentRowClass PaperClipDocumentRowClass;
typedef struct _PaperClipSaveChangesDialogAskData PaperClipSaveChangesDialogAskData;
typedef struct _PaperClipDocumentRowPrivate PaperClipDocumentRowPrivate;
enum  {
	PAPER_CLIP_DOCUMENT_ROW_0_PROPERTY,
	PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY,
	PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY,
	PAPER_CLIP_DOCUMENT_ROW_NUM_PROPERTIES
};
static GParamSpec* paper_clip_document_row_properties[PAPER_CLIP_DOCUMENT_ROW_NUM_PROPERTIES];

#define PAPER_CLIP_TYPE_DOCUMENT (paper_clip_document_get_type ())
#define PAPER_CLIP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DOCUMENT, PaperClipDocument))
#define PAPER_CLIP_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DOCUMENT, PaperClipDocumentClass))
#define PAPER_CLIP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DOCUMENT))
#define PAPER_CLIP_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DOCUMENT))
#define PAPER_CLIP_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DOCUMENT, PaperClipDocumentClass))

typedef struct _PaperClipDocument PaperClipDocument;
typedef struct _PaperClipDocumentClass PaperClipDocumentClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _PaperClipSaveChangesDialog {
	AdwMessageDialog parent_instance;
	PaperClipSaveChangesDialogPrivate * priv;
};

struct _PaperClipSaveChangesDialogClass {
	AdwMessageDialogClass parent_class;
};

struct _PaperClipSaveChangesDialogPrivate {
	GtkListBox* documents_listbox;
};

struct _PaperClipSaveChangesDialogAskData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PaperClipSaveChangesDialog* self;
	PaperClipServicesDocumentManager** document_managers;
	gint document_managers_length1;
	GCancellable* cancellable;
	PaperClipSaveChangesResponse result;
	PaperClipServicesDocumentManager** manager_collection;
	gint manager_collection_length1;
	gint _manager_collection_size_;
	gint manager_it;
	PaperClipServicesDocumentManager* _tmp0_;
	PaperClipServicesDocumentManager* manager;
	PaperClipServicesDocumentManager* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	PaperClipDocumentRow* document_row;
	PaperClipServicesDocumentManager* _tmp4_;
	PaperClipServicesDocumentManager* _tmp5_;
	PaperClipDocumentRow* _tmp6_;
	GtkListBox* _tmp7_;
	PaperClipDocumentRow* _tmp8_;
	const gchar* dialog_response;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GQuark _tmp13_;
};

struct _PaperClipDocumentRow {
	AdwActionRow parent_instance;
	PaperClipDocumentRowPrivate * priv;
};

struct _PaperClipDocumentRowClass {
	AdwActionRowClass parent_class;
};

struct _PaperClipDocumentRowPrivate {
	PaperClipServicesDocumentManager* _document;
	gboolean _selected;
	GtkCheckButton* check_button;
};

static gint PaperClipSaveChangesDialog_private_offset;
static gpointer paper_clip_save_changes_dialog_parent_class = NULL;
static gint PaperClipDocumentRow_private_offset;
static gpointer paper_clip_document_row_parent_class = NULL;

VALA_EXTERN GType paper_clip_save_changes_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipSaveChangesDialog, g_object_unref)
static void paper_clip_save_changes_dialog_ask_data_free (gpointer _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 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 gboolean paper_clip_save_changes_dialog_ask_co (PaperClipSaveChangesDialogAskData* _data_);
VALA_EXTERN gboolean paper_clip_services_document_manager_get_changed (PaperClipServicesDocumentManager* self);
VALA_EXTERN GType paper_clip_document_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDocumentRow, g_object_unref)
VALA_EXTERN PaperClipDocumentRow* paper_clip_document_row_new (void);
VALA_EXTERN PaperClipDocumentRow* paper_clip_document_row_construct (GType object_type);
VALA_EXTERN void paper_clip_document_row_set_document_manager (PaperClipDocumentRow* self,
                                                   PaperClipServicesDocumentManager* value);
static void paper_clip_save_changes_dialog_ask_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
VALA_EXTERN PaperClipSaveChangesDialog* paper_clip_save_changes_dialog_new (void);
VALA_EXTERN PaperClipSaveChangesDialog* paper_clip_save_changes_dialog_construct (GType object_type);
VALA_EXTERN GListModel* paper_clip_save_changes_dialog_get_selected_documents (PaperClipSaveChangesDialog* self);
VALA_EXTERN gboolean paper_clip_document_row_get_selected (PaperClipDocumentRow* self);
VALA_EXTERN PaperClipServicesDocumentManager* paper_clip_document_row_get_document_manager (PaperClipDocumentRow* self);
static void paper_clip_save_changes_dialog_finalize (GObject * obj);
static GType paper_clip_save_changes_dialog_get_type_once (void);
static void _vala_paper_clip_save_changes_dialog_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
VALA_EXTERN GType paper_clip_document_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDocument, g_object_unref)
VALA_EXTERN PaperClipDocument* paper_clip_services_document_manager_get_document (PaperClipServicesDocumentManager* self);
VALA_EXTERN gchar* paper_clip_document_get_title (PaperClipDocument* self);
VALA_EXTERN GFile* paper_clip_document_get_original_file (PaperClipDocument* self);
VALA_EXTERN void paper_clip_document_row_set_selected (PaperClipDocumentRow* self,
                                           gboolean value);
static GObject * paper_clip_document_row_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static void paper_clip_document_row_finalize (GObject * obj);
static GType paper_clip_document_row_get_type_once (void);
static void _vala_paper_clip_document_row_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_paper_clip_document_row_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);

static inline gpointer
paper_clip_save_changes_dialog_get_instance_private (PaperClipSaveChangesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, PaperClipSaveChangesDialog_private_offset);
}

static void
paper_clip_save_changes_dialog_ask_data_free (gpointer _data)
{
	PaperClipSaveChangesDialogAskData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (PaperClipSaveChangesDialogAskData, _data_);
}

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

void
paper_clip_save_changes_dialog_ask (PaperClipSaveChangesDialog* self,
                                    PaperClipServicesDocumentManager** document_managers,
                                    gint document_managers_length1,
                                    GCancellable* cancellable,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	PaperClipSaveChangesDialogAskData* _data_;
	PaperClipSaveChangesDialog* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (PaperClipSaveChangesDialogAskData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, paper_clip_save_changes_dialog_ask_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->document_managers = document_managers;
	_data_->document_managers_length1 = document_managers_length1;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	paper_clip_save_changes_dialog_ask_co (_data_);
}

PaperClipSaveChangesResponse
paper_clip_save_changes_dialog_ask_finish (PaperClipSaveChangesDialog* self,
                                           GAsyncResult* _res_)
{
	PaperClipSaveChangesResponse result;
	PaperClipSaveChangesDialogAskData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		return 0;
	}
	result = _data_->result;
	return result;
}

static void
paper_clip_save_changes_dialog_ask_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	PaperClipSaveChangesDialogAskData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	paper_clip_save_changes_dialog_ask_co (_data_);
}

static gboolean
paper_clip_save_changes_dialog_ask_co (PaperClipSaveChangesDialogAskData* _data_)
{
	static GQuark _tmp12_label0 = 0;
	static GQuark _tmp12_label1 = 0;
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->manager_collection_length1 = 0;
		_data_->_manager_collection_size_ = 0;
		_data_->manager_collection = _data_->document_managers;
		_data_->manager_collection_length1 = _data_->document_managers_length1;
		for (_data_->manager_it = 0; _data_->manager_it < _data_->manager_collection_length1; _data_->manager_it = _data_->manager_it + 1) {
			_data_->_tmp0_ = _g_object_ref0 (_data_->manager_collection[_data_->manager_it]);
			_data_->manager = _data_->_tmp0_;
			{
				_data_->_tmp1_ = _data_->manager;
				_data_->_tmp2_ = paper_clip_services_document_manager_get_changed (_data_->_tmp1_);
				_data_->_tmp3_ = _data_->_tmp2_;
				if (!_data_->_tmp3_) {
					_g_object_unref0 (_data_->manager);
					continue;
				}
				_data_->_tmp4_ = _data_->manager;
				_data_->_tmp5_ = _g_object_ref0 (_data_->_tmp4_);
				_data_->_tmp6_ = NULL;
				_data_->_tmp6_ = paper_clip_document_row_new ();
				paper_clip_document_row_set_document_manager (_data_->_tmp6_, _data_->_tmp5_);
				_g_object_unref0 (_data_->_tmp5_);
				g_object_ref_sink (_data_->_tmp6_);
				_data_->document_row = _data_->_tmp6_;
				_data_->_tmp7_ = _data_->self->priv->documents_listbox;
				_data_->_tmp8_ = _data_->document_row;
				gtk_list_box_append (_data_->_tmp7_, (GtkWidget*) _data_->_tmp8_);
				_g_object_unref0 (_data_->document_row);
				_g_object_unref0 (_data_->manager);
			}
		}
	}
	_data_->_state_ = 1;
	adw_message_dialog_choose ((AdwMessageDialog*) _data_->self, _data_->cancellable, paper_clip_save_changes_dialog_ask_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp9_ = adw_message_dialog_choose_finish ((AdwMessageDialog*) _data_->self, _data_->_res_);
	_data_->dialog_response = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->dialog_response;
	_data_->_tmp13_ = 0U;
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp13_ = (NULL == _data_->_tmp11_) ? 0 : g_quark_from_string (_data_->_tmp11_);
	if (_data_->_tmp13_ == ((0 != _tmp12_label0) ? _tmp12_label0 : (_tmp12_label0 = g_quark_from_static_string ("save")))) {
		switch (0) {
			default:
			{
				_data_->result = PAPER_CLIP_SAVE_CHANGES_RESPONSE_SAVE;
				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;
			}
		}
	} else if (_data_->_tmp13_ == ((0 != _tmp12_label1) ? _tmp12_label1 : (_tmp12_label1 = g_quark_from_static_string ("discard")))) {
		switch (0) {
			default:
			{
				_data_->result = PAPER_CLIP_SAVE_CHANGES_RESPONSE_DISCARD;
				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;
			}
		}
	} else {
		switch (0) {
			default:
			{
				_data_->result = PAPER_CLIP_SAVE_CHANGES_RESPONSE_CANCEL;
				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;
			}
		}
	}
}

PaperClipSaveChangesDialog*
paper_clip_save_changes_dialog_construct (GType object_type)
{
	PaperClipSaveChangesDialog * self = NULL;
	self = (PaperClipSaveChangesDialog*) g_object_new (object_type, NULL);
	return self;
}

PaperClipSaveChangesDialog*
paper_clip_save_changes_dialog_new (void)
{
	return paper_clip_save_changes_dialog_construct (PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG);
}

GListModel*
paper_clip_save_changes_dialog_get_selected_documents (PaperClipSaveChangesDialog* self)
{
	GListModel* result;
	GListStore* list_store = NULL;
	GListStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_list_store_new (PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER);
	list_store = _tmp0_;
	{
		GtkWidget* row = NULL;
		GtkListBox* _tmp1_;
		GtkWidget* _tmp2_;
		_tmp1_ = self->priv->documents_listbox;
		_tmp2_ = gtk_widget_get_first_child ((GtkWidget*) _tmp1_);
		row = _tmp2_;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				GtkWidget* _tmp6_;
				PaperClipDocumentRow* document_row = NULL;
				GtkWidget* _tmp7_;
				PaperClipDocumentRow* _tmp8_;
				PaperClipDocumentRow* _tmp9_;
				gboolean _tmp10_;
				gboolean _tmp11_;
				if (!_tmp3_) {
					GtkWidget* _tmp4_;
					GtkWidget* _tmp5_;
					_tmp4_ = row;
					_tmp5_ = gtk_widget_get_next_sibling (_tmp4_);
					row = _tmp5_;
				}
				_tmp3_ = FALSE;
				_tmp6_ = row;
				if (!(_tmp6_ != NULL)) {
					break;
				}
				_tmp7_ = row;
				_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow));
				document_row = _tmp8_;
				_tmp9_ = document_row;
				_tmp10_ = paper_clip_document_row_get_selected (_tmp9_);
				_tmp11_ = _tmp10_;
				if (_tmp11_) {
					GListStore* _tmp12_;
					PaperClipDocumentRow* _tmp13_;
					PaperClipServicesDocumentManager* _tmp14_;
					PaperClipServicesDocumentManager* _tmp15_;
					_tmp12_ = list_store;
					_tmp13_ = document_row;
					_tmp14_ = paper_clip_document_row_get_document_manager (_tmp13_);
					_tmp15_ = _tmp14_;
					g_list_store_append (_tmp12_, (GObject*) _tmp15_);
				}
				_g_object_unref0 (document_row);
			}
		}
	}
	result = (GListModel*) list_store;
	return result;
}

static void
paper_clip_save_changes_dialog_class_init (PaperClipSaveChangesDialogClass * klass,
                                           gpointer klass_data)
{
	paper_clip_save_changes_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PaperClipSaveChangesDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_paper_clip_save_changes_dialog_get_property;
	G_OBJECT_CLASS (klass)->finalize = paper_clip_save_changes_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PAPER_CLIP_SAVE_CHANGES_DIALOG_SELECTED_DOCUMENTS_PROPERTY, paper_clip_save_changes_dialog_properties[PAPER_CLIP_SAVE_CHANGES_DIALOG_SELECTED_DOCUMENTS_PROPERTY] = g_param_spec_object ("selected-documents", "selected-documents", "selected-documents", g_list_model_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/diegoivan/pdf_metadata_editor/gtk/save-changes-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "documents_listbox", FALSE, PaperClipSaveChangesDialog_private_offset + G_STRUCT_OFFSET (PaperClipSaveChangesDialogPrivate, documents_listbox));
}

static void
paper_clip_save_changes_dialog_instance_init (PaperClipSaveChangesDialog * self,
                                              gpointer klass)
{
	self->priv = paper_clip_save_changes_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
paper_clip_save_changes_dialog_finalize (GObject * obj)
{
	PaperClipSaveChangesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG, PaperClipSaveChangesDialog);
	G_OBJECT_CLASS (paper_clip_save_changes_dialog_parent_class)->finalize (obj);
}

static GType
paper_clip_save_changes_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PaperClipSaveChangesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) paper_clip_save_changes_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PaperClipSaveChangesDialog), 0, (GInstanceInitFunc) paper_clip_save_changes_dialog_instance_init, NULL };
	GType paper_clip_save_changes_dialog_type_id;
	paper_clip_save_changes_dialog_type_id = g_type_register_static (adw_message_dialog_get_type (), "PaperClipSaveChangesDialog", &g_define_type_info, 0);
	PaperClipSaveChangesDialog_private_offset = g_type_add_instance_private (paper_clip_save_changes_dialog_type_id, sizeof (PaperClipSaveChangesDialogPrivate));
	return paper_clip_save_changes_dialog_type_id;
}

GType
paper_clip_save_changes_dialog_get_type (void)
{
	static volatile gsize paper_clip_save_changes_dialog_type_id__once = 0;
	if (g_once_init_enter (&paper_clip_save_changes_dialog_type_id__once)) {
		GType paper_clip_save_changes_dialog_type_id;
		paper_clip_save_changes_dialog_type_id = paper_clip_save_changes_dialog_get_type_once ();
		g_once_init_leave (&paper_clip_save_changes_dialog_type_id__once, paper_clip_save_changes_dialog_type_id);
	}
	return paper_clip_save_changes_dialog_type_id__once;
}

static void
_vala_paper_clip_save_changes_dialog_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	PaperClipSaveChangesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAPER_CLIP_TYPE_SAVE_CHANGES_DIALOG, PaperClipSaveChangesDialog);
	switch (property_id) {
		case PAPER_CLIP_SAVE_CHANGES_DIALOG_SELECTED_DOCUMENTS_PROPERTY:
		g_value_take_object (value, paper_clip_save_changes_dialog_get_selected_documents (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
paper_clip_document_row_get_instance_private (PaperClipDocumentRow* self)
{
	return G_STRUCT_MEMBER_P (self, PaperClipDocumentRow_private_offset);
}

PaperClipDocumentRow*
paper_clip_document_row_construct (GType object_type)
{
	PaperClipDocumentRow * self = NULL;
	self = (PaperClipDocumentRow*) g_object_new (object_type, NULL);
	return self;
}

PaperClipDocumentRow*
paper_clip_document_row_new (void)
{
	return paper_clip_document_row_construct (PAPER_CLIP_TYPE_DOCUMENT_ROW);
}

PaperClipServicesDocumentManager*
paper_clip_document_row_get_document_manager (PaperClipDocumentRow* self)
{
	PaperClipServicesDocumentManager* result;
	PaperClipServicesDocumentManager* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_document;
	result = _tmp0_;
	return result;
}

void
paper_clip_document_row_set_document_manager (PaperClipDocumentRow* self,
                                              PaperClipServicesDocumentManager* value)
{
	PaperClipServicesDocumentManager* _tmp0_;
	PaperClipServicesDocumentManager* _tmp1_;
	PaperClipServicesDocumentManager* _tmp2_;
	PaperClipDocument* _tmp3_;
	PaperClipDocument* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	PaperClipServicesDocumentManager* _tmp9_;
	PaperClipServicesDocumentManager* _tmp10_;
	PaperClipDocument* _tmp11_;
	PaperClipDocument* _tmp12_;
	GFile* _tmp13_;
	GFile* _tmp14_;
	gchar* _tmp15_;
	GtkCheckButton* _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_document);
	self->priv->_document = _tmp0_;
	_tmp1_ = paper_clip_document_row_get_document_manager (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = paper_clip_services_document_manager_get_document (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = paper_clip_document_get_title (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp9_ = paper_clip_document_row_get_document_manager (self);
	_tmp10_ = _tmp9_;
	_tmp11_ = paper_clip_services_document_manager_get_document (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = paper_clip_document_get_original_file (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_file_get_basename (_tmp14_);
	_tmp8_ = _tmp15_;
	if (_tmp8_ == NULL) {
		gchar* _tmp16_;
		_tmp16_ = g_strdup ("");
		_g_free0 (_tmp8_);
		_tmp8_ = _tmp16_;
	}
	adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp8_);
	_tmp17_ = self->priv->check_button;
	gtk_check_button_set_active (_tmp17_, TRUE);
	_g_free0 (_tmp8_);
	g_object_notify_by_pspec ((GObject *) self, paper_clip_document_row_properties[PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY]);
}

gboolean
paper_clip_document_row_get_selected (PaperClipDocumentRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selected;
	return result;
}

void
paper_clip_document_row_set_selected (PaperClipDocumentRow* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = paper_clip_document_row_get_selected (self);
	if (old_value != value) {
		self->priv->_selected = value;
		g_object_notify_by_pspec ((GObject *) self, paper_clip_document_row_properties[PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY]);
	}
}

static GObject *
paper_clip_document_row_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PaperClipDocumentRow * self;
	GtkCheckButton* _tmp0_;
	GtkCheckButton* _tmp1_;
	GtkCheckButton* _tmp2_;
	parent_class = G_OBJECT_CLASS (paper_clip_document_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow);
	_tmp0_ = self->priv->check_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp0_, GTK_ALIGN_CENTER);
	_tmp1_ = self->priv->check_button;
	g_object_bind_property_with_closures ((GObject*) _tmp1_, "active", (GObject*) self, "selected", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp2_ = self->priv->check_button;
	adw_action_row_add_prefix ((AdwActionRow*) self, (GtkWidget*) _tmp2_);
	return obj;
}

static void
paper_clip_document_row_class_init (PaperClipDocumentRowClass * klass,
                                    gpointer klass_data)
{
	paper_clip_document_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PaperClipDocumentRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_paper_clip_document_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_paper_clip_document_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = paper_clip_document_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = paper_clip_document_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY, paper_clip_document_row_properties[PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY] = g_param_spec_object ("document-manager", "document-manager", "document-manager", PAPER_CLIP_SERVICES_TYPE_DOCUMENT_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY, paper_clip_document_row_properties[PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
paper_clip_document_row_instance_init (PaperClipDocumentRow * self,
                                       gpointer klass)
{
	GtkCheckButton* _tmp0_;
	self->priv = paper_clip_document_row_get_instance_private (self);
	_tmp0_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp0_);
	self->priv->check_button = _tmp0_;
}

static void
paper_clip_document_row_finalize (GObject * obj)
{
	PaperClipDocumentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow);
	_g_object_unref0 (self->priv->_document);
	_g_object_unref0 (self->priv->check_button);
	G_OBJECT_CLASS (paper_clip_document_row_parent_class)->finalize (obj);
}

static GType
paper_clip_document_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PaperClipDocumentRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) paper_clip_document_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PaperClipDocumentRow), 0, (GInstanceInitFunc) paper_clip_document_row_instance_init, NULL };
	GType paper_clip_document_row_type_id;
	paper_clip_document_row_type_id = g_type_register_static (adw_action_row_get_type (), "PaperClipDocumentRow", &g_define_type_info, 0);
	PaperClipDocumentRow_private_offset = g_type_add_instance_private (paper_clip_document_row_type_id, sizeof (PaperClipDocumentRowPrivate));
	return paper_clip_document_row_type_id;
}

GType
paper_clip_document_row_get_type (void)
{
	static volatile gsize paper_clip_document_row_type_id__once = 0;
	if (g_once_init_enter (&paper_clip_document_row_type_id__once)) {
		GType paper_clip_document_row_type_id;
		paper_clip_document_row_type_id = paper_clip_document_row_get_type_once ();
		g_once_init_leave (&paper_clip_document_row_type_id__once, paper_clip_document_row_type_id);
	}
	return paper_clip_document_row_type_id__once;
}

static void
_vala_paper_clip_document_row_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	PaperClipDocumentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow);
	switch (property_id) {
		case PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY:
		g_value_set_object (value, paper_clip_document_row_get_document_manager (self));
		break;
		case PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY:
		g_value_set_boolean (value, paper_clip_document_row_get_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_paper_clip_document_row_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	PaperClipDocumentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAPER_CLIP_TYPE_DOCUMENT_ROW, PaperClipDocumentRow);
	switch (property_id) {
		case PAPER_CLIP_DOCUMENT_ROW_DOCUMENT_MANAGER_PROPERTY:
		paper_clip_document_row_set_document_manager (self, g_value_get_object (value));
		break;
		case PAPER_CLIP_DOCUMENT_ROW_SELECTED_PROPERTY:
		paper_clip_document_row_set_selected (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static GType
paper_clip_save_changes_response_get_type_once (void)
{
	static const GEnumValue values[] = {{PAPER_CLIP_SAVE_CHANGES_RESPONSE_CANCEL, "PAPER_CLIP_SAVE_CHANGES_RESPONSE_CANCEL", "cancel"}, {PAPER_CLIP_SAVE_CHANGES_RESPONSE_DISCARD, "PAPER_CLIP_SAVE_CHANGES_RESPONSE_DISCARD", "discard"}, {PAPER_CLIP_SAVE_CHANGES_RESPONSE_SAVE, "PAPER_CLIP_SAVE_CHANGES_RESPONSE_SAVE", "save"}, {0, NULL, NULL}};
	GType paper_clip_save_changes_response_type_id;
	paper_clip_save_changes_response_type_id = g_enum_register_static ("PaperClipSaveChangesResponse", values);
	return paper_clip_save_changes_response_type_id;
}

GType
paper_clip_save_changes_response_get_type (void)
{
	static volatile gsize paper_clip_save_changes_response_type_id__once = 0;
	if (g_once_init_enter (&paper_clip_save_changes_response_type_id__once)) {
		GType paper_clip_save_changes_response_type_id;
		paper_clip_save_changes_response_type_id = paper_clip_save_changes_response_get_type_once ();
		g_once_init_leave (&paper_clip_save_changes_response_type_id__once, paper_clip_save_changes_response_type_id);
	}
	return paper_clip_save_changes_response_type_id__once;
}

