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

/* DocumentView.vala
 *
 * Copyright 2023 Diego Iván <diegoivan.mae@gmail.com>
 *
 * 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 <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <pango/pango.h>
#include <float.h>
#include <math.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_DOCUMENT_VIEW (paper_clip_document_view_get_type ())
#define PAPER_CLIP_DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentView))
#define PAPER_CLIP_DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentViewClass))
#define PAPER_CLIP_IS_DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DOCUMENT_VIEW))
#define PAPER_CLIP_IS_DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DOCUMENT_VIEW))
#define PAPER_CLIP_DOCUMENT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentViewClass))

typedef struct _PaperClipDocumentView PaperClipDocumentView;
typedef struct _PaperClipDocumentViewClass PaperClipDocumentViewClass;
typedef struct _PaperClipDocumentViewPrivate PaperClipDocumentViewPrivate;

#define PAPER_CLIP_TYPE_DATE_ROW (paper_clip_date_row_get_type ())
#define PAPER_CLIP_DATE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DATE_ROW, PaperClipDateRow))
#define PAPER_CLIP_DATE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DATE_ROW, PaperClipDateRowClass))
#define PAPER_CLIP_IS_DATE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DATE_ROW))
#define PAPER_CLIP_IS_DATE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DATE_ROW))
#define PAPER_CLIP_DATE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DATE_ROW, PaperClipDateRowClass))

typedef struct _PaperClipDateRow PaperClipDateRow;
typedef struct _PaperClipDateRowClass PaperClipDateRowClass;

#define PAPER_CLIP_TYPE_KEYWORD_LIST (paper_clip_keyword_list_get_type ())
#define PAPER_CLIP_KEYWORD_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_KEYWORD_LIST, PaperClipKeywordList))
#define PAPER_CLIP_KEYWORD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_KEYWORD_LIST, PaperClipKeywordListClass))
#define PAPER_CLIP_IS_KEYWORD_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_KEYWORD_LIST))
#define PAPER_CLIP_IS_KEYWORD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_KEYWORD_LIST))
#define PAPER_CLIP_KEYWORD_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_KEYWORD_LIST, PaperClipKeywordListClass))

typedef struct _PaperClipKeywordList PaperClipKeywordList;
typedef struct _PaperClipKeywordListClass PaperClipKeywordListClass;

#define PAPER_CLIP_TYPE_DETAILS_LIST (paper_clip_details_list_get_type ())
#define PAPER_CLIP_DETAILS_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DETAILS_LIST, PaperClipDetailsList))
#define PAPER_CLIP_DETAILS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DETAILS_LIST, PaperClipDetailsListClass))
#define PAPER_CLIP_IS_DETAILS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DETAILS_LIST))
#define PAPER_CLIP_IS_DETAILS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DETAILS_LIST))
#define PAPER_CLIP_DETAILS_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DETAILS_LIST, PaperClipDetailsListClass))

typedef struct _PaperClipDetailsList PaperClipDetailsList;
typedef struct _PaperClipDetailsListClass PaperClipDetailsListClass;

#define PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL (paper_clip_document_thumbnail_get_type ())
#define PAPER_CLIP_DOCUMENT_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL, PaperClipDocumentThumbnail))
#define PAPER_CLIP_DOCUMENT_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL, PaperClipDocumentThumbnailClass))
#define PAPER_CLIP_IS_DOCUMENT_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL))
#define PAPER_CLIP_IS_DOCUMENT_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL))
#define PAPER_CLIP_DOCUMENT_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL, PaperClipDocumentThumbnailClass))

typedef struct _PaperClipDocumentThumbnail PaperClipDocumentThumbnail;
typedef struct _PaperClipDocumentThumbnailClass PaperClipDocumentThumbnailClass;

#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;
enum  {
	PAPER_CLIP_DOCUMENT_VIEW_0_PROPERTY,
	PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY,
	PAPER_CLIP_DOCUMENT_VIEW_NUM_PROPERTIES
};
static GParamSpec* paper_clip_document_view_properties[PAPER_CLIP_DOCUMENT_VIEW_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))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PaperClipDocumentViewOpenOnAppData PaperClipDocumentViewOpenOnAppData;

struct _PaperClipDocumentView {
	AdwBin parent_instance;
	PaperClipDocumentViewPrivate * priv;
};

struct _PaperClipDocumentViewClass {
	AdwBinClass parent_class;
};

struct _PaperClipDocumentViewPrivate {
	AdwEntryRow* title_row;
	AdwEntryRow* author_row;
	AdwEntryRow* creator_row;
	AdwEntryRow* subject_row;
	AdwEntryRow* producer_row;
	PaperClipDateRow* creation_row;
	PaperClipDateRow* modification_row;
	PaperClipKeywordList* keyword_list;
	GtkLabel* title_label;
	PaperClipDetailsList* details_list;
	PaperClipDocumentThumbnail* document_thumbnail;
	GtkScrolledWindow* scrolled_window;
	GBindingGroup* document_bindings;
	GtkFileLauncher* file_launcher;
	PaperClipDocument* _document;
};

struct _PaperClipDocumentViewOpenOnAppData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PaperClipDocumentView* self;
	gboolean _result_;
	GtkFileLauncher* _tmp0_;
	GtkRoot* _tmp1_;
	GtkRoot* _tmp2_;
	GError* e;
	GError* _tmp3_;
	const gchar* _tmp4_;
	GError* _inner_error0_;
};

static gint PaperClipDocumentView_private_offset;
static gpointer paper_clip_document_view_parent_class = NULL;

VALA_EXTERN GType paper_clip_document_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDocumentView, g_object_unref)
VALA_EXTERN GType paper_clip_date_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDateRow, g_object_unref)
VALA_EXTERN GType paper_clip_keyword_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipKeywordList, g_object_unref)
VALA_EXTERN GType paper_clip_details_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDetailsList, g_object_unref)
VALA_EXTERN GType paper_clip_document_thumbnail_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDocumentThumbnail, g_object_unref)
VALA_EXTERN GType paper_clip_document_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperClipDocument, g_object_unref)
static void paper_clip_document_view_setup_bindings (PaperClipDocumentView* self);
static void paper_clip_document_view_measure_filename (PaperClipDocumentView* self);
VALA_EXTERN PaperClipDocument* paper_clip_document_view_get_document (PaperClipDocumentView* self);
VALA_EXTERN GFile* paper_clip_document_get_original_file (PaperClipDocument* self);
static void paper_clip_document_view_open_on_app_data_free (gpointer _data);
VALA_EXTERN void paper_clip_document_view_open_on_app (PaperClipDocumentView* self,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
VALA_EXTERN void paper_clip_document_view_open_on_app_finish (PaperClipDocumentView* self,
                                                  GAsyncResult* _res_);
static gboolean paper_clip_document_view_open_on_app_co (PaperClipDocumentViewOpenOnAppData* _data_);
static void paper_clip_document_view_open_on_app_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
VALA_EXTERN PaperClipDocumentView* paper_clip_document_view_new (void);
VALA_EXTERN PaperClipDocumentView* paper_clip_document_view_construct (GType object_type);
VALA_EXTERN void paper_clip_document_view_set_document (PaperClipDocumentView* self,
                                            PaperClipDocument* value);
VALA_EXTERN void paper_clip_details_list_set_document (PaperClipDetailsList* self,
                                           PaperClipDocument* value);
VALA_EXTERN void paper_clip_document_thumbnail_set_document (PaperClipDocumentThumbnail* self,
                                                 PaperClipDocument* value);
VALA_EXTERN void paper_clip_keyword_list_set_document (PaperClipKeywordList* self,
                                           PaperClipDocument* value);
static GObject * paper_clip_document_view_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void paper_clip_document_view_finalize (GObject * obj);
static GType paper_clip_document_view_get_type_once (void);
static void _vala_paper_clip_document_view_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_paper_clip_document_view_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
paper_clip_document_view_get_instance_private (PaperClipDocumentView* self)
{
	return G_STRUCT_MEMBER_P (self, PaperClipDocumentView_private_offset);
}

static void
paper_clip_document_view_setup_bindings (PaperClipDocumentView* self)
{
	GBindingGroup* _tmp0_;
	AdwEntryRow* _tmp1_;
	GBindingGroup* _tmp2_;
	AdwEntryRow* _tmp3_;
	GBindingGroup* _tmp4_;
	AdwEntryRow* _tmp5_;
	GBindingGroup* _tmp6_;
	AdwEntryRow* _tmp7_;
	GBindingGroup* _tmp8_;
	AdwEntryRow* _tmp9_;
	GBindingGroup* _tmp10_;
	PaperClipDateRow* _tmp11_;
	GBindingGroup* _tmp12_;
	PaperClipDateRow* _tmp13_;
	GBindingGroup* _tmp14_;
	GtkFileLauncher* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->document_bindings;
	_tmp1_ = self->priv->title_row;
	g_binding_group_bind (_tmp0_, "title", (GObject*) _tmp1_, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp2_ = self->priv->document_bindings;
	_tmp3_ = self->priv->author_row;
	g_binding_group_bind (_tmp2_, "author", (GObject*) _tmp3_, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp4_ = self->priv->document_bindings;
	_tmp5_ = self->priv->creator_row;
	g_binding_group_bind (_tmp4_, "creator", (GObject*) _tmp5_, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp6_ = self->priv->document_bindings;
	_tmp7_ = self->priv->subject_row;
	g_binding_group_bind (_tmp6_, "subject", (GObject*) _tmp7_, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp8_ = self->priv->document_bindings;
	_tmp9_ = self->priv->producer_row;
	g_binding_group_bind (_tmp8_, "producer", (GObject*) _tmp9_, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp10_ = self->priv->document_bindings;
	_tmp11_ = self->priv->creation_row;
	g_binding_group_bind (_tmp10_, "creation-date", (GObject*) _tmp11_, "date", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp12_ = self->priv->document_bindings;
	_tmp13_ = self->priv->modification_row;
	g_binding_group_bind (_tmp12_, "modification-date", (GObject*) _tmp13_, "date", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	_tmp14_ = self->priv->document_bindings;
	_tmp15_ = self->priv->file_launcher;
	g_binding_group_bind (_tmp14_, "original-file", (GObject*) _tmp15_, "file", G_BINDING_SYNC_CREATE);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static void
paper_clip_document_view_measure_filename (PaperClipDocumentView* self)
{
	gchar* basename = NULL;
	PaperClipDocument* _tmp0_;
	PaperClipDocument* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gboolean _tmp14_ = FALSE;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = paper_clip_document_view_get_document (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = paper_clip_document_get_original_file (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_file_get_basename (_tmp3_);
	basename = _tmp4_;
	_tmp5_ = basename;
	if (_tmp5_ == NULL) {
		_g_free0 (basename);
		return;
	}
	_tmp6_ = self->priv->title_label;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp6_, "long-filename");
	_tmp7_ = self->priv->title_label;
	gtk_label_set_ellipsize (_tmp7_, PANGO_ELLIPSIZE_NONE);
	_tmp9_ = basename;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ > 45) {
		const gchar* _tmp12_;
		_tmp12_ = basename;
		_tmp8_ = string_contains (_tmp12_, " ");
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		GtkLabel* _tmp13_;
		_tmp13_ = self->priv->title_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp13_, "long-filename");
		_g_free0 (basename);
		return;
	}
	_tmp15_ = basename;
	_tmp16_ = strlen (_tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ > 21) {
		const gchar* _tmp18_;
		_tmp18_ = basename;
		_tmp14_ = !string_contains (_tmp18_, " ");
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		GtkLabel* _tmp19_;
		_tmp19_ = self->priv->title_label;
		gtk_label_set_ellipsize (_tmp19_, PANGO_ELLIPSIZE_END);
	}
	_g_free0 (basename);
}

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

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

void
paper_clip_document_view_open_on_app (PaperClipDocumentView* self,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	PaperClipDocumentViewOpenOnAppData* _data_;
	PaperClipDocumentView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (PaperClipDocumentViewOpenOnAppData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, paper_clip_document_view_open_on_app_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	paper_clip_document_view_open_on_app_co (_data_);
}

void
paper_clip_document_view_open_on_app_finish (PaperClipDocumentView* self,
                                             GAsyncResult* _res_)
{
	PaperClipDocumentViewOpenOnAppData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
paper_clip_document_view_open_on_app_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	PaperClipDocumentViewOpenOnAppData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	paper_clip_document_view_open_on_app_co (_data_);
}

static gboolean
paper_clip_document_view_open_on_app_co (PaperClipDocumentViewOpenOnAppData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->file_launcher;
		_data_->_tmp1_ = gtk_widget_get_root ((GtkWidget*) _data_->self);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_state_ = 1;
		gtk_file_launcher_launch (_data_->_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, gtk_window_get_type (), GtkWindow), NULL, paper_clip_document_view_open_on_app_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_result_ = gtk_file_launcher_launch_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (!_data_->_result_) {
			g_debug ("DocumentView.vala:129: File was not opened by the user");
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp3_ = _data_->e;
		_data_->_tmp4_ = _data_->_tmp3_->message;
		g_critical ("DocumentView.vala:133: %s", _data_->_tmp4_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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;
}

PaperClipDocumentView*
paper_clip_document_view_construct (GType object_type)
{
	PaperClipDocumentView * self = NULL;
	self = (PaperClipDocumentView*) g_object_new (object_type, NULL);
	return self;
}

PaperClipDocumentView*
paper_clip_document_view_new (void)
{
	return paper_clip_document_view_construct (PAPER_CLIP_TYPE_DOCUMENT_VIEW);
}

PaperClipDocument*
paper_clip_document_view_get_document (PaperClipDocumentView* self)
{
	PaperClipDocument* result;
	PaperClipDocument* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_document;
	result = _tmp0_;
	return result;
}

void
paper_clip_document_view_set_document (PaperClipDocumentView* self,
                                       PaperClipDocument* value)
{
	PaperClipDocument* _tmp0_;
	GBindingGroup* _tmp1_;
	PaperClipDocument* _tmp2_;
	PaperClipDocument* _tmp3_;
	PaperClipDetailsList* _tmp4_;
	PaperClipDocument* _tmp5_;
	PaperClipDocument* _tmp6_;
	PaperClipDocumentThumbnail* _tmp7_;
	PaperClipDocument* _tmp8_;
	PaperClipDocument* _tmp9_;
	PaperClipKeywordList* _tmp10_;
	PaperClipDocument* _tmp11_;
	PaperClipDocument* _tmp12_;
	PaperClipDocument* _tmp13_;
	PaperClipDocument* _tmp14_;
	GtkRoot* _tmp15_;
	GtkRoot* _tmp16_;
	GtkLabel* _tmp17_;
	PaperClipDocument* _tmp18_;
	PaperClipDocument* _tmp19_;
	GFile* _tmp20_;
	GFile* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	AdwEntryRow* _tmp24_;
	GtkScrolledWindow* _tmp25_;
	GtkAdjustment* _tmp26_;
	GtkAdjustment* _tmp27_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_document);
	self->priv->_document = _tmp0_;
	_tmp1_ = self->priv->document_bindings;
	_tmp2_ = paper_clip_document_view_get_document (self);
	_tmp3_ = _tmp2_;
	g_object_set (_tmp1_, "source", (GObject*) _tmp3_, NULL);
	_tmp4_ = self->priv->details_list;
	_tmp5_ = paper_clip_document_view_get_document (self);
	_tmp6_ = _tmp5_;
	paper_clip_details_list_set_document (_tmp4_, _tmp6_);
	_tmp7_ = self->priv->document_thumbnail;
	_tmp8_ = paper_clip_document_view_get_document (self);
	_tmp9_ = _tmp8_;
	paper_clip_document_thumbnail_set_document (_tmp7_, _tmp9_);
	_tmp10_ = self->priv->keyword_list;
	_tmp11_ = paper_clip_document_view_get_document (self);
	_tmp12_ = _tmp11_;
	paper_clip_keyword_list_set_document (_tmp10_, _tmp12_);
	_tmp13_ = paper_clip_document_view_get_document (self);
	_tmp14_ = _tmp13_;
	_tmp15_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp16_ = _tmp15_;
	g_object_bind_property_with_closures ((GObject*) _tmp14_, "title", (GObject*) _tmp16_, "title", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	paper_clip_document_view_measure_filename (self);
	_tmp17_ = self->priv->title_label;
	_tmp18_ = paper_clip_document_view_get_document (self);
	_tmp19_ = _tmp18_;
	_tmp20_ = paper_clip_document_get_original_file (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_file_get_basename (_tmp21_);
	_tmp23_ = _tmp22_;
	gtk_label_set_label (_tmp17_, _tmp23_);
	_g_free0 (_tmp23_);
	_tmp24_ = self->priv->title_row;
	adw_entry_row_grab_focus_without_selecting (_tmp24_);
	_tmp25_ = self->priv->scrolled_window;
	_tmp26_ = gtk_scrolled_window_get_vadjustment (_tmp25_);
	_tmp27_ = _tmp26_;
	gtk_adjustment_set_value (_tmp27_, (gdouble) 0);
	g_object_notify_by_pspec ((GObject *) self, paper_clip_document_view_properties[PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY]);
}

static GObject *
paper_clip_document_view_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PaperClipDocumentView * self;
	GtkFileLauncher* _tmp0_ = NULL;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp1_;
	GSimpleActionGroup* _tmp2_;
	parent_class = G_OBJECT_CLASS (paper_clip_document_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentView);
	_tmp0_ = gtk_file_launcher_new (NULL);
	gtk_file_launcher_set_always_ask (_tmp0_, TRUE);
	_g_object_unref0 (self->priv->file_launcher);
	self->priv->file_launcher = _tmp0_;
	_tmp1_ = g_simple_action_group_new ();
	action_group = _tmp1_;
	_tmp2_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "editor", (GActionGroup*) _tmp2_);
	paper_clip_document_view_setup_bindings (self);
	_g_object_unref0 (action_group);
	return obj;
}

static void
paper_clip_document_view_class_init (PaperClipDocumentViewClass * klass,
                                     gpointer klass_data)
{
	paper_clip_document_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PaperClipDocumentView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_paper_clip_document_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_paper_clip_document_view_set_property;
	G_OBJECT_CLASS (klass)->constructor = paper_clip_document_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = paper_clip_document_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY, paper_clip_document_view_properties[PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY] = g_param_spec_object ("document", "document", "document", PAPER_CLIP_TYPE_DOCUMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/diegoivan/pdf_metadata_editor/gtk/document-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, title_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "author_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, author_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "creator_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, creator_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "subject_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, subject_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "producer_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, producer_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "creation_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, creation_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "modification_row", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, modification_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "keyword_list", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, keyword_list));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title_label", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, title_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "details_list", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, details_list));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "document_thumbnail", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, document_thumbnail));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "scrolled_window", FALSE, PaperClipDocumentView_private_offset + G_STRUCT_OFFSET (PaperClipDocumentViewPrivate, scrolled_window));
}

static void
paper_clip_document_view_instance_init (PaperClipDocumentView * self,
                                        gpointer klass)
{
	GBindingGroup* _tmp0_;
	self->priv = paper_clip_document_view_get_instance_private (self);
	_tmp0_ = g_binding_group_new ();
	self->priv->document_bindings = _tmp0_;
	g_type_ensure (PAPER_CLIP_TYPE_DATE_ROW);
	g_type_ensure (PAPER_CLIP_TYPE_DATE_ROW);
	g_type_ensure (PAPER_CLIP_TYPE_KEYWORD_LIST);
	g_type_ensure (PAPER_CLIP_TYPE_DETAILS_LIST);
	g_type_ensure (PAPER_CLIP_TYPE_DOCUMENT_THUMBNAIL);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
paper_clip_document_view_finalize (GObject * obj)
{
	PaperClipDocumentView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentView);
	_g_object_unref0 (self->priv->document_bindings);
	_g_object_unref0 (self->priv->file_launcher);
	_g_object_unref0 (self->priv->_document);
	G_OBJECT_CLASS (paper_clip_document_view_parent_class)->finalize (obj);
}

static GType
paper_clip_document_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PaperClipDocumentViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) paper_clip_document_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PaperClipDocumentView), 0, (GInstanceInitFunc) paper_clip_document_view_instance_init, NULL };
	GType paper_clip_document_view_type_id;
	paper_clip_document_view_type_id = g_type_register_static (adw_bin_get_type (), "PaperClipDocumentView", &g_define_type_info, 0);
	PaperClipDocumentView_private_offset = g_type_add_instance_private (paper_clip_document_view_type_id, sizeof (PaperClipDocumentViewPrivate));
	return paper_clip_document_view_type_id;
}

GType
paper_clip_document_view_get_type (void)
{
	static volatile gsize paper_clip_document_view_type_id__once = 0;
	if (g_once_init_enter (&paper_clip_document_view_type_id__once)) {
		GType paper_clip_document_view_type_id;
		paper_clip_document_view_type_id = paper_clip_document_view_get_type_once ();
		g_once_init_leave (&paper_clip_document_view_type_id__once, paper_clip_document_view_type_id);
	}
	return paper_clip_document_view_type_id__once;
}

static void
_vala_paper_clip_document_view_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	PaperClipDocumentView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentView);
	switch (property_id) {
		case PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY:
		g_value_set_object (value, paper_clip_document_view_get_document (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_paper_clip_document_view_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	PaperClipDocumentView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAPER_CLIP_TYPE_DOCUMENT_VIEW, PaperClipDocumentView);
	switch (property_id) {
		case PAPER_CLIP_DOCUMENT_VIEW_DOCUMENT_PROPERTY:
		paper_clip_document_view_set_document (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

