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

/*
* Copyright (c) 2018 Murilo Venturoso
*
* 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Murilo Venturoso <muriloventuroso@gmail.com>
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <granite.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 PDFTRICKS_TYPE_MERGE_PDF (pdftricks_merge_pdf_get_type ())
#define PDFTRICKS_MERGE_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDF))
#define PDFTRICKS_MERGE_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDFClass))
#define PDFTRICKS_IS_MERGE_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFTRICKS_TYPE_MERGE_PDF))
#define PDFTRICKS_IS_MERGE_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFTRICKS_TYPE_MERGE_PDF))
#define PDFTRICKS_MERGE_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDFClass))

typedef struct _pdftricksMergePDF pdftricksMergePDF;
typedef struct _pdftricksMergePDFClass pdftricksMergePDFClass;
typedef struct _pdftricksMergePDFPrivate pdftricksMergePDFPrivate;
enum  {
	PDFTRICKS_MERGE_PDF_0_PROPERTY,
	PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY,
	PDFTRICKS_MERGE_PDF_NUM_PROPERTIES
};
static GParamSpec* pdftricks_merge_pdf_properties[PDFTRICKS_MERGE_PDF_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)))
#define __vala_GtkTreePath_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreePath_free (var), NULL)))
typedef struct _Block7Data Block7Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _Block8Data Block8Data;
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
typedef struct _PdftricksMergePdfMergeFileData PdftricksMergePdfMergeFileData;
typedef struct _Block9Data Block9Data;
enum  {
	PDFTRICKS_MERGE_PDF_PROCCESS_BEGIN_SIGNAL,
	PDFTRICKS_MERGE_PDF_PROCCESS_FINISHED_SIGNAL,
	PDFTRICKS_MERGE_PDF_NUM_SIGNALS
};
static guint pdftricks_merge_pdf_signals[PDFTRICKS_MERGE_PDF_NUM_SIGNALS] = {0};

struct _pdftricksMergePDF {
	GtkBox parent_instance;
	pdftricksMergePDFPrivate * priv;
};

struct _pdftricksMergePDFClass {
	GtkBoxClass parent_class;
};

struct _pdftricksMergePDFPrivate {
	GtkWindow* _window;
	GtkTreeView* view;
	GtkListStore* list_store;
	GtkSpinner* spinner;
};

struct _Block7Data {
	int _ref_count_;
	pdftricksMergePDF* self;
	gchar* files_pdf;
};

struct _Block8Data {
	int _ref_count_;
	pdftricksMergePDF* self;
	gboolean ret;
	GSourceFunc callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
	gchar* inputs;
	gchar* output_file;
	gpointer _async_data_;
};

struct _PdftricksMergePdfMergeFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	pdftricksMergePDF* self;
	gchar* inputs;
	gchar* output_file;
	gboolean result;
	Block8Data* _data8_;
	GThreadFunc run;
	gpointer run_target;
	GThread* _tmp0_;
	GThread* _tmp1_;
	GError* e;
	GError* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_;
};

struct _Block9Data {
	int _ref_count_;
	pdftricksMergePDF* self;
	gchar** input_formats;
	gint input_formats_length1;
	gint _input_formats_size_;
	GtkTreeIter iter;
	GtkFileFilter* filter;
	GtkButton* merge_button;
};

static gint pdftricksMergePDF_private_offset;
static gpointer pdftricks_merge_pdf_parent_class = NULL;

VALA_EXTERN GType pdftricks_merge_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdftricksMergePDF, g_object_unref)
VALA_EXTERN pdftricksMergePDF* pdftricks_merge_pdf_new (GtkWindow* window);
VALA_EXTERN pdftricksMergePDF* pdftricks_merge_pdf_construct (GType object_type,
                                                  GtkWindow* window);
static gint pdftricks_merge_pdf_get_page_count (pdftricksMergePDF* self,
                                         const gchar* input_file);
static void pdftricks_merge_pdf_on_drag_data_get (pdftricksMergePDF* self,
                                           GtkWidget* widget,
                                           GdkDragContext* context,
                                           GtkSelectionData* selection_data,
                                           guint target_type,
                                           guint time);
static void pdftricks_merge_pdf_on_drag_data_received (pdftricksMergePDF* self,
                                                GtkWidget* widget,
                                                GdkDragContext* context,
                                                gint x,
                                                gint y,
                                                GtkSelectionData* selection_data,
                                                guint target_type,
                                                guint time);
static void _vala_GtkTreePath_free (GtkTreePath* self);
static void pdftricks_merge_pdf_confirm_merge (pdftricksMergePDF* self);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static gboolean __lambda25_ (Block7Data* _data7_,
                      GtkTreeModel* model,
                      GtkTreePath* path,
                      GtkTreeIter* iter);
static gchar* pdftricks_merge_pdf_convert_to_pdf (pdftricksMergePDF* self,
                                           const gchar* input_file);
static gboolean ___lambda25__gtk_tree_model_foreach_func (GtkTreeModel* model,
                                                   GtkTreePath* path,
                                                   GtkTreeIter* iter,
                                                   gpointer self);
VALA_EXTERN GtkWindow* pdftricks_merge_pdf_get_window (pdftricksMergePDF* self);
static void pdftricks_merge_pdf_merge_file (pdftricksMergePDF* self,
                                     const gchar* inputs,
                                     const gchar* output_file,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static gboolean pdftricks_merge_pdf_merge_file_finish (pdftricksMergePDF* self,
                                                GAsyncResult* _res_);
static void ___lambda27_ (pdftricksMergePDF* self,
                   GObject* obj,
                   GAsyncResult* res);
static void ____lambda27__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void pdftricks_merge_pdf_merge_file_data_free (gpointer _data);
static gboolean pdftricks_merge_pdf_merge_file_co (PdftricksMergePdfMergeFileData* _data_);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static gboolean _pdftricks_merge_pdf_merge_file_co_gsource_func (gpointer self);
static void* __lambda26_ (Block8Data* _data8_);
static gpointer ___lambda26__gthread_func (gpointer self);
static void pdftricks_merge_pdf_set_window (pdftricksMergePDF* self,
                                     GtkWindow* value);
static GObject * pdftricks_merge_pdf_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void _pdftricks_merge_pdf_on_drag_data_get_gtk_widget_drag_data_get (GtkWidget* _sender,
                                                                     GdkDragContext* context,
                                                                     GtkSelectionData* selection_data,
                                                                     guint info,
                                                                     guint time_,
                                                                     gpointer self);
static void _pdftricks_merge_pdf_on_drag_data_received_gtk_widget_drag_data_received (GtkWidget* _sender,
                                                                               GdkDragContext* context,
                                                                               gint x,
                                                                               gint y,
                                                                               GtkSelectionData* selection_data,
                                                                               guint info,
                                                                               guint time_,
                                                                               gpointer self);
static void _pdftricks_merge_pdf___lambda28_ (Block9Data* _data9_);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static void _g_free0_ (gpointer var);
static inline void _g_slist_free__g_free0_ (GSList* self);
static void __pdftricks_merge_pdf___lambda28__gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self);
static void _pdftricks_merge_pdf___lambda29_ (pdftricksMergePDF* self);
static GtkTreePath* _vala_GtkTreePath_copy (GtkTreePath* self);
static void __vala_GtkTreePath_free0_ (gpointer var);
static inline void _g_list_free___vala_GtkTreePath_free0_ (GList* self);
static void __pdftricks_merge_pdf___lambda29__gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self);
static void _pdftricks_merge_pdf___lambda30_ (pdftricksMergePDF* self);
static void __pdftricks_merge_pdf___lambda30__gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self);
static void _pdftricks_merge_pdf_confirm_merge_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self);
static void _pdftricks_merge_pdf___lambda31_ (Block9Data* _data9_);
static void __pdftricks_merge_pdf___lambda31__pdftricks_merge_pdf_proccess_begin (pdftricksMergePDF* _sender,
                                                                           gpointer self);
static void _pdftricks_merge_pdf___lambda32_ (Block9Data* _data9_,
                                       gboolean _result_);
static void __pdftricks_merge_pdf___lambda32__pdftricks_merge_pdf_proccess_finished (pdftricksMergePDF* _sender,
                                                                              gboolean _result_,
                                                                              gpointer self);
static void pdftricks_merge_pdf_finalize (GObject * obj);
static GType pdftricks_merge_pdf_get_type_once (void);
static void _vala_pdftricks_merge_pdf_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_pdftricks_merge_pdf_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static const GtkTargetEntry PDFTRICKS_MERGE_PDF_targets[1] = {{"STRING", (guint) 0, (guint) 0}};

static inline gpointer
pdftricks_merge_pdf_get_instance_private (pdftricksMergePDF* self)
{
	return G_STRUCT_MEMBER_P (self, pdftricksMergePDF_private_offset);
}

pdftricksMergePDF*
pdftricks_merge_pdf_construct (GType object_type,
                               GtkWindow* window)
{
	pdftricksMergePDF * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (pdftricksMergePDF*) g_object_new (object_type, "margin-start", 20, "margin-end", 20, "window", window, "hexpand", TRUE, "homogeneous", TRUE, NULL);
	return self;
}

pdftricksMergePDF*
pdftricks_merge_pdf_new (GtkWindow* window)
{
	return pdftricks_merge_pdf_construct (PDFTRICKS_TYPE_MERGE_PDF, window);
}

static gint
pdftricks_merge_pdf_get_page_count (pdftricksMergePDF* self,
                                    const gchar* input_file)
{
	gchar* output = NULL;
	gchar* stderr = NULL;
	gchar* _tmp0_;
	gint exit_status = 0;
	gint _result_ = 0;
	gchar** file_name_split = NULL;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint file_name_split_length1;
	gint _file_name_split_size_;
	gchar* input_format = NULL;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (input_file != NULL, -1);
	_tmp0_ = g_strdup ("");
	stderr = _tmp0_;
	exit_status = 0;
	_result_ = 0;
	_tmp2_ = _tmp1_ = g_strsplit (input_file, ".", 0);
	file_name_split = _tmp2_;
	file_name_split_length1 = _vala_array_length (_tmp1_);
	_file_name_split_size_ = file_name_split_length1;
	_tmp3_ = file_name_split;
	_tmp3__length1 = file_name_split_length1;
	_tmp4_ = file_name_split;
	_tmp4__length1 = file_name_split_length1;
	_tmp5_ = _tmp3_[_tmp4__length1 - 1];
	_tmp6_ = g_strdup (_tmp5_);
	input_format = _tmp6_;
	_tmp7_ = input_format;
	if (g_strcmp0 (_tmp7_, "pdf") != 0) {
		result = 1;
		_g_free0 (input_format);
		file_name_split = (_vala_array_free (file_name_split, file_name_split_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (stderr);
		_g_free0 (output);
		return result;
	}
	{
		gchar* cmd = NULL;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gint _tmp15_ = 0;
		const gchar* _tmp16_;
		_tmp8_ = g_strconcat ("gs -q -dNODISPLAY -c \"(\"", input_file, NULL);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_strconcat (_tmp9_, "\") (r) file runpdfbegin pdfpagecount = quit\"", NULL);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		cmd = _tmp11_;
		_tmp12_ = cmd;
		g_spawn_command_line_sync (_tmp12_, &_tmp13_, &_tmp14_, &_tmp15_, &_inner_error0_);
		_g_free0 (output);
		output = _tmp13_;
		_g_free0 (stderr);
		stderr = _tmp14_;
		exit_status = _tmp15_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (cmd);
			goto __catch0_g_error;
		}
		_tmp16_ = output;
		_result_ = atoi (_tmp16_);
		_g_free0 (cmd);
	}
	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 ("MergePDF.vala:181: %s", _tmp18_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp19_ = -1;
		_g_free0 (input_format);
		file_name_split = (_vala_array_free (file_name_split, file_name_split_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (stderr);
		_g_free0 (output);
		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 _tmp19_;
	}
	result = _result_;
	_g_free0 (input_format);
	file_name_split = (_vala_array_free (file_name_split, file_name_split_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (stderr);
	_g_free0 (output);
	return result;
}

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

static gchar*
string_to_utf8 (const gchar* self,
                gint* result_length1)
{
	gint string_length = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _result_ = NULL;
	gchar* _tmp2_;
	gint _result__length1;
	gint __result__size_;
	gint _tmp3_;
	gchar* _tmp4_;
	gint _tmp4__length1;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = _tmp1_;
	_tmp2_ = g_new0 (gchar, string_length + 1);
	_result_ = _tmp2_;
	_result__length1 = string_length + 1;
	__result__size_ = _result__length1;
	_tmp3_ = _result__length1;
	_result__length1 = _tmp3_ - 1;
	memcpy (_result_, self, (gsize) string_length);
	_tmp4_ = _result_;
	_tmp4__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}

static void
pdftricks_merge_pdf_on_drag_data_get (pdftricksMergePDF* self,
                                      GtkWidget* widget,
                                      GdkDragContext* context,
                                      GtkSelectionData* selection_data,
                                      guint target_type,
                                      guint time)
{
	GtkTreeSelection* treeselection = NULL;
	GtkTreeView* _tmp0_;
	GtkTreeSelection* _tmp1_;
	GtkTreeSelection* _tmp2_;
	GtkTreeModel* model = NULL;
	GtkTreeIter iter = {0};
	GValue data_value = {0};
	GtkTreeModel* _tmp3_ = NULL;
	GtkTreeIter _tmp4_ = {0};
	GtkTreeModel* _tmp5_;
	GtkTreeIter _tmp6_;
	GValue _tmp7_ = {0};
	gchar* data = NULL;
	gchar* _tmp8_;
	gint _tmp9_ = 0;
	gchar* _tmp10_;
	guchar* _tmp11_;
	gint _tmp11__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	g_return_if_fail (context != NULL);
	g_return_if_fail (selection_data != NULL);
	_tmp0_ = self->priv->view;
	_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	treeselection = _tmp2_;
	gtk_tree_selection_get_selected (treeselection, &_tmp3_, &_tmp4_);
	_g_object_unref0 (model);
	_tmp5_ = _g_object_ref0 (_tmp3_);
	model = _tmp5_;
	iter = _tmp4_;
	_tmp6_ = iter;
	gtk_tree_model_get_value (model, &_tmp6_, 0, &_tmp7_);
	G_IS_VALUE (&data_value) ? (g_value_unset (&data_value), NULL) : NULL;
	data_value = _tmp7_;
	_tmp8_ = g_value_dup_string (&data_value);
	data = _tmp8_;
	_tmp10_ = string_to_utf8 (data, &_tmp9_);
	_tmp11_ = (guchar*) _tmp10_;
	_tmp11__length1 = (_tmp9_ * sizeof (gchar)) / sizeof (guchar);
	gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, _tmp11_, (gint) ((_tmp9_ * sizeof (gchar)) / sizeof (guchar)));
	_tmp11_ = (g_free (_tmp11_), NULL);
	_g_free0 (data);
	G_IS_VALUE (&data_value) ? (g_value_unset (&data_value), NULL) : NULL;
	_g_object_unref0 (model);
	_g_object_unref0 (treeselection);
}

static void
_vala_GtkTreePath_free (GtkTreePath* self)
{
	g_boxed_free (gtk_tree_path_get_type (), self);
}

static void
pdftricks_merge_pdf_on_drag_data_received (pdftricksMergePDF* self,
                                           GtkWidget* widget,
                                           GdkDragContext* context,
                                           gint x,
                                           gint y,
                                           GtkSelectionData* selection_data,
                                           guint target_type,
                                           guint time)
{
	GtkTreeModel* model = NULL;
	GtkTreeView* _tmp0_;
	GtkTreeModel* _tmp1_;
	GtkTreeModel* _tmp2_;
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	g_return_if_fail (context != NULL);
	g_return_if_fail (selection_data != NULL);
	_tmp0_ = self->priv->view;
	_tmp1_ = gtk_tree_view_get_model (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	model = _tmp2_;
	if (selection_data != NULL) {
		_tmp3_ = gtk_selection_data_get_length (selection_data) >= 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		gchar* data = NULL;
		guint8* _tmp4_;
		gchar* _tmp5_;
		gchar* page_size = NULL;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		GtkTreePath* path = NULL;
		GtkTreeViewDropPosition position = 0;
		gboolean drop_info = FALSE;
		GtkTreeView* _tmp8_;
		GtkTreePath* _tmp9_ = NULL;
		GtkTreeViewDropPosition _tmp10_ = 0;
		gboolean _tmp11_;
		GtkTreeIter new_iter = {0};
		GtkTreeIter sibling = {0};
		GtkTreeIter iter = {0};
		GtkTreeModel* _tmp12_;
		GtkTreePath* _tmp13_;
		GtkTreeIter _tmp14_ = {0};
		_tmp4_ = gtk_selection_data_get_data (selection_data);
		_tmp5_ = g_strdup ((const gchar*) _tmp4_);
		data = _tmp5_;
		_tmp6_ = data;
		_tmp7_ = g_strdup_printf ("%i", pdftricks_merge_pdf_get_page_count (self, _tmp6_));
		page_size = _tmp7_;
		_tmp8_ = self->priv->view;
		_tmp11_ = gtk_tree_view_get_dest_row_at_pos (_tmp8_, x, y, &_tmp9_, &_tmp10_);
		__vala_GtkTreePath_free0 (path);
		path = _tmp9_;
		position = _tmp10_;
		drop_info = _tmp11_;
		_tmp12_ = model;
		_tmp13_ = path;
		gtk_tree_model_get_iter (_tmp12_, &_tmp14_, _tmp13_);
		sibling = _tmp14_;
		drop_info = TRUE;
		if (drop_info) {
			GtkTreeModel* _tmp15_;
			GtkTreePath* _tmp16_;
			GtkTreeIter _tmp17_ = {0};
			gboolean _tmp18_ = FALSE;
			GtkListStore* _tmp25_;
			GtkTreeIter _tmp26_;
			const gchar* _tmp27_;
			const gchar* _tmp28_;
			_tmp15_ = model;
			_tmp16_ = path;
			gtk_tree_model_get_iter (_tmp15_, &_tmp17_, _tmp16_);
			iter = _tmp17_;
			if (position == GTK_TREE_VIEW_DROP_BEFORE) {
				_tmp18_ = TRUE;
			} else {
				_tmp18_ = position == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
			}
			if (_tmp18_) {
				GtkListStore* _tmp19_;
				GtkTreeIter _tmp20_;
				GtkTreeIter _tmp21_ = {0};
				_tmp19_ = self->priv->list_store;
				_tmp20_ = sibling;
				gtk_list_store_insert_before (_tmp19_, &_tmp21_, &_tmp20_);
				new_iter = _tmp21_;
			} else {
				GtkListStore* _tmp22_;
				GtkTreeIter _tmp23_;
				GtkTreeIter _tmp24_ = {0};
				_tmp22_ = self->priv->list_store;
				_tmp23_ = sibling;
				gtk_list_store_insert_after (_tmp22_, &_tmp24_, &_tmp23_);
				new_iter = _tmp24_;
			}
			_tmp25_ = self->priv->list_store;
			_tmp26_ = new_iter;
			_tmp27_ = data;
			_tmp28_ = page_size;
			gtk_list_store_set (_tmp25_, &_tmp26_, 0, _tmp27_, 1, _tmp28_, -1);
		} else {
			GtkListStore* _tmp29_;
			GtkTreeIter _tmp30_ = {0};
			GtkListStore* _tmp31_;
			GtkTreeIter _tmp32_;
			const gchar* _tmp33_;
			const gchar* _tmp34_;
			_tmp29_ = self->priv->list_store;
			gtk_list_store_append (_tmp29_, &_tmp30_);
			new_iter = _tmp30_;
			_tmp31_ = self->priv->list_store;
			_tmp32_ = new_iter;
			_tmp33_ = data;
			_tmp34_ = page_size;
			gtk_list_store_set (_tmp31_, &_tmp32_, 0, _tmp33_, 1, _tmp34_, -1);
		}
		if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE) {
			gtk_drag_finish (context, TRUE, TRUE, (guint32) time);
		}
		__vala_GtkTreePath_free0 (path);
		_g_free0 (page_size);
		_g_free0 (data);
	}
	_g_object_unref0 (model);
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		pdftricksMergePDF* self;
		self = _data7_->self;
		_g_free0 (_data7_->files_pdf);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

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 gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 NULL;
}

static gboolean
__lambda25_ (Block7Data* _data7_,
             GtkTreeModel* model,
             GtkTreePath* path,
             GtkTreeIter* iter)
{
	pdftricksMergePDF* self;
	GValue cell1 = {0};
	GtkListStore* _tmp0_;
	GtkTreeIter _tmp1_;
	GValue _tmp2_ = {0};
	gchar* file_pdf = NULL;
	GValue _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gboolean result;
	self = _data7_->self;
	g_return_val_if_fail (model != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = self->priv->list_store;
	_tmp1_ = *iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp0_, &_tmp1_, 0, &_tmp2_);
	G_IS_VALUE (&cell1) ? (g_value_unset (&cell1), NULL) : NULL;
	cell1 = _tmp2_;
	_tmp3_ = cell1;
	_tmp4_ = g_strdup (g_value_get_string (&_tmp3_));
	file_pdf = _tmp4_;
	_tmp5_ = file_pdf;
	if (!string_contains (_tmp5_, ".pdf")) {
		const gchar* _tmp6_;
		gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = file_pdf;
		_tmp7_ = pdftricks_merge_pdf_convert_to_pdf (self, _tmp6_);
		_g_free0 (file_pdf);
		file_pdf = _tmp7_;
		_tmp8_ = file_pdf;
		if (g_strcmp0 (_tmp8_, "") == 0) {
			gchar* _tmp9_;
			_tmp9_ = g_strdup ("");
			_g_free0 (_data7_->files_pdf);
			_data7_->files_pdf = _tmp9_;
			result = TRUE;
			_g_free0 (file_pdf);
			G_IS_VALUE (&cell1) ? (g_value_unset (&cell1), NULL) : NULL;
			return result;
		}
	}
	_tmp10_ = _data7_->files_pdf;
	_tmp11_ = g_strconcat (_tmp10_, " ", NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = file_pdf;
	_tmp14_ = string_replace (_tmp13_, " ", "\\ ");
	_tmp15_ = _tmp14_;
	_tmp16_ = string_replace (_tmp15_, "'", "\\'");
	_tmp17_ = _tmp16_;
	_tmp18_ = g_strconcat (_tmp12_, _tmp17_, NULL);
	_g_free0 (_data7_->files_pdf);
	_data7_->files_pdf = _tmp18_;
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp12_);
	result = FALSE;
	_g_free0 (file_pdf);
	G_IS_VALUE (&cell1) ? (g_value_unset (&cell1), NULL) : NULL;
	return result;
}

static gboolean
___lambda25__gtk_tree_model_foreach_func (GtkTreeModel* model,
                                          GtkTreePath* path,
                                          GtkTreeIter* iter,
                                          gpointer self)
{
	gboolean result;
	result = __lambda25_ (self, model, path, iter);
	return result;
}

static void
___lambda27_ (pdftricksMergePDF* self,
              GObject* obj,
              GAsyncResult* res)
{
	g_return_if_fail (res != NULL);
	g_signal_emit (self, pdftricks_merge_pdf_signals[PDFTRICKS_MERGE_PDF_PROCCESS_FINISHED_SIGNAL], 0, pdftricks_merge_pdf_merge_file_finish (self, res));
}

static void
____lambda27__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	___lambda27_ ((pdftricksMergePDF*) self, source_object, res);
	g_object_unref (self);
}

static void
pdftricks_merge_pdf_confirm_merge (pdftricksMergePDF* self)
{
	Block7Data* _data7_;
	gboolean merge = FALSE;
	gchar* _tmp0_;
	GtkListStore* _tmp1_;
	const gchar* _tmp2_;
	gchar* output_file = NULL;
	gchar* _tmp3_;
	GtkFileChooserNative* chooser_output = NULL;
	GtkWindow* _tmp4_;
	GtkFileChooserNative* _tmp5_;
	GtkFileChooserNative* _tmp6_;
	GtkFileChooserNative* _tmp7_;
	GtkFileChooserNative* _tmp12_;
	g_return_if_fail (self != NULL);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	merge = FALSE;
	_tmp0_ = g_strdup ("");
	_data7_->files_pdf = _tmp0_;
	_tmp1_ = self->priv->list_store;
	gtk_tree_model_foreach ((GtkTreeModel*) _tmp1_, ___lambda25__gtk_tree_model_foreach_func, _data7_);
	_tmp2_ = _data7_->files_pdf;
	if (g_strcmp0 (_tmp2_, "") == 0) {
		block7_data_unref (_data7_);
		_data7_ = NULL;
		return;
	}
	_tmp3_ = g_strdup ("");
	output_file = _tmp3_;
	_tmp4_ = self->priv->_window;
	_tmp5_ = gtk_file_chooser_native_new (_ ("Select the file to compress"), _tmp4_, GTK_FILE_CHOOSER_ACTION_SAVE, _ ("Save"), _ ("Cancel"));
	chooser_output = _tmp5_;
	_tmp6_ = chooser_output;
	gtk_file_chooser_set_do_overwrite_confirmation ((GtkFileChooser*) _tmp6_, TRUE);
	_tmp7_ = chooser_output;
	if (gtk_native_dialog_run ((GtkNativeDialog*) _tmp7_) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserNative* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp8_ = chooser_output;
		_tmp9_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = string_replace (_tmp10_, " ", "\\ ");
		_g_free0 (output_file);
		output_file = _tmp11_;
		_g_free0 (_tmp10_);
		merge = TRUE;
	}
	_tmp12_ = chooser_output;
	gtk_native_dialog_destroy ((GtkNativeDialog*) _tmp12_);
	if (merge == TRUE) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		g_signal_emit (self, pdftricks_merge_pdf_signals[PDFTRICKS_MERGE_PDF_PROCCESS_BEGIN_SIGNAL], 0);
		_tmp13_ = _data7_->files_pdf;
		_tmp14_ = output_file;
		pdftricks_merge_pdf_merge_file (self, _tmp13_, _tmp14_, ____lambda27__gasync_ready_callback, g_object_ref (self));
	}
	_g_object_unref0 (chooser_output);
	_g_free0 (output_file);
	block7_data_unref (_data7_);
	_data7_ = NULL;
}

static gchar*
pdftricks_merge_pdf_convert_to_pdf (pdftricksMergePDF* self,
                                    const gchar* input_file)
{
	gchar* output = NULL;
	gchar* stderr = NULL;
	gchar* cmd = NULL;
	gchar* result_file = NULL;
	gchar* _tmp0_;
	gint exit_status = 0;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gboolean _tmp21_ = FALSE;
	gboolean _tmp22_ = FALSE;
	const gchar* _tmp23_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (input_file != NULL, NULL);
	_tmp0_ = g_strdup ("");
	result_file = _tmp0_;
	exit_status = 0;
	_tmp1_ = g_uuid_string_random ();
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat ("/tmp/c_", _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat (_tmp4_, ".pdf", NULL);
	_g_free0 (result_file);
	result_file = _tmp5_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp6_ = g_strconcat ("convert \"", input_file, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "\" \"", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = result_file;
	_tmp11_ = g_strconcat (_tmp9_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, "\"", NULL);
	_g_free0 (cmd);
	cmd = _tmp13_;
	_g_free0 (_tmp12_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	{
		const gchar* _tmp14_;
		gchar* _tmp15_ = NULL;
		gchar* _tmp16_ = NULL;
		gint _tmp17_ = 0;
		_tmp14_ = cmd;
		g_spawn_command_line_sync (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_, &_inner_error0_);
		_g_free0 (output);
		output = _tmp15_;
		_g_free0 (stderr);
		stderr = _tmp16_;
		exit_status = _tmp17_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp18_ = e;
		_tmp19_ = _tmp18_->message;
		g_critical ("MergePDF.vala:284: %s", _tmp19_);
		_tmp20_ = g_strdup ("");
		result = _tmp20_;
		_g_error_free0 (e);
		_g_free0 (result_file);
		_g_free0 (cmd);
		_g_free0 (stderr);
		_g_free0 (output);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (result_file);
		_g_free0 (cmd);
		_g_free0 (stderr);
		_g_free0 (output);
		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 NULL;
	}
	_tmp23_ = output;
	if (g_strcmp0 (_tmp23_, "") != 0) {
		_tmp22_ = TRUE;
	} else {
		_tmp22_ = exit_status != 0;
	}
	if (_tmp22_) {
		_tmp21_ = TRUE;
	} else {
		const gchar* _tmp24_;
		_tmp24_ = stderr;
		_tmp21_ = g_strcmp0 (_tmp24_, "") != 0;
	}
	if (_tmp21_) {
		const gchar* _tmp25_;
		const gchar* _tmp27_;
		_tmp25_ = output;
		if (string_contains (_tmp25_, "Error")) {
			gchar* _tmp26_;
			_tmp26_ = g_strdup ("");
			result = _tmp26_;
			_g_free0 (result_file);
			_g_free0 (cmd);
			_g_free0 (stderr);
			_g_free0 (output);
			return result;
		}
		_tmp27_ = stderr;
		if (string_contains (_tmp27_, "not allowed")) {
			GraniteMessageDialog* message_dialog = NULL;
			GraniteMessageDialog* _tmp28_;
			GraniteMessageDialog* _tmp29_;
			GtkWindow* _tmp30_;
			GraniteMessageDialog* _tmp31_;
			GraniteMessageDialog* _tmp32_;
			GraniteMessageDialog* _tmp33_;
			gchar* _tmp34_;
			_tmp28_ = granite_message_dialog_new_with_image_from_icon_name (_ ("ImageMagick Policies"), _ ("Change the ImageMagick security policies that prevent this operation a" \
"nd try again."), "process-stop", GTK_BUTTONS_CLOSE);
			g_object_ref_sink (_tmp28_);
			message_dialog = _tmp28_;
			_tmp29_ = message_dialog;
			_tmp30_ = self->priv->_window;
			gtk_window_set_transient_for ((GtkWindow*) _tmp29_, _tmp30_);
			_tmp31_ = message_dialog;
			gtk_widget_show_all ((GtkWidget*) _tmp31_);
			_tmp32_ = message_dialog;
			gtk_dialog_run ((GtkDialog*) _tmp32_);
			_tmp33_ = message_dialog;
			gtk_widget_destroy ((GtkWidget*) _tmp33_);
			_tmp34_ = g_strdup ("");
			result = _tmp34_;
			_g_object_unref0 (message_dialog);
			_g_free0 (result_file);
			_g_free0 (cmd);
			_g_free0 (stderr);
			_g_free0 (output);
			return result;
		}
		if (exit_status != 0) {
			gchar* _tmp35_;
			_tmp35_ = g_strdup ("");
			result = _tmp35_;
			_g_free0 (result_file);
			_g_free0 (cmd);
			_g_free0 (stderr);
			_g_free0 (output);
			return result;
		}
	}
	result = result_file;
	_g_free0 (cmd);
	_g_free0 (stderr);
	_g_free0 (output);
	return result;
}

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

static void
pdftricks_merge_pdf_merge_file (pdftricksMergePDF* self,
                                const gchar* inputs,
                                const gchar* output_file,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	PdftricksMergePdfMergeFileData* _data_;
	pdftricksMergePDF* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (inputs != NULL);
	g_return_if_fail (output_file != NULL);
	_data_ = g_slice_new0 (PdftricksMergePdfMergeFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, pdftricks_merge_pdf_merge_file_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (inputs);
	_g_free0 (_data_->inputs);
	_data_->inputs = _tmp1_;
	_tmp2_ = g_strdup (output_file);
	_g_free0 (_data_->output_file);
	_data_->output_file = _tmp2_;
	pdftricks_merge_pdf_merge_file_co (_data_);
}

static gboolean
pdftricks_merge_pdf_merge_file_finish (pdftricksMergePDF* self,
                                       GAsyncResult* _res_)
{
	gboolean result;
	PdftricksMergePdfMergeFileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		pdftricksMergePDF* self;
		self = _data8_->self;
		(_data8_->callback_target_destroy_notify == NULL) ? NULL : (_data8_->callback_target_destroy_notify (_data8_->callback_target), NULL);
		_data8_->callback = NULL;
		_data8_->callback_target = NULL;
		_data8_->callback_target_destroy_notify = NULL;
		_g_free0 (_data8_->inputs);
		_g_free0 (_data8_->output_file);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static gboolean
_pdftricks_merge_pdf_merge_file_co_gsource_func (gpointer self)
{
	gboolean result;
	result = pdftricks_merge_pdf_merge_file_co (self);
	return result;
}

static void*
__lambda26_ (Block8Data* _data8_)
{
	pdftricksMergePDF* self;
	gchar* output = NULL;
	gchar* stderr = NULL;
	gchar* _tmp0_;
	gint exit_status = 0;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	GSourceFunc _tmp15_;
	gpointer _tmp15__target;
	GDestroyNotify _tmp15__target_destroy_notify;
	GError* _inner_error0_ = NULL;
	void* result;
	self = _data8_->self;
	_tmp0_ = g_strdup ("");
	stderr = _tmp0_;
	exit_status = 0;
	{
		gchar* cmd = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gint _tmp9_ = 0;
		_tmp1_ = g_strconcat ("gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=", _data8_->output_file, NULL);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strconcat (_tmp2_, " -dBATCH ", NULL);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strconcat (_tmp4_, _data8_->inputs, NULL);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		_g_free0 (_tmp2_);
		cmd = _tmp6_;
		g_spawn_command_line_sync (cmd, &_tmp7_, &_tmp8_, &_tmp9_, &_inner_error0_);
		_g_free0 (output);
		output = _tmp7_;
		_g_free0 (stderr);
		stderr = _tmp8_;
		exit_status = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (cmd);
			goto __catch0_g_error;
		}
		_g_free0 (cmd);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		g_critical ("MergePDF.vala:316: %s", _tmp11_);
		_data8_->ret = FALSE;
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (stderr);
		_g_free0 (output);
		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 NULL;
	}
	if (g_strcmp0 (output, "") != 0) {
		_tmp13_ = TRUE;
	} else {
		_tmp13_ = exit_status != 0;
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		const gchar* _tmp14_;
		_tmp14_ = stderr;
		_tmp12_ = g_strcmp0 (_tmp14_, "") != 0;
	}
	if (_tmp12_) {
		if (string_contains (output, "Error")) {
			_data8_->ret = FALSE;
		}
		if (exit_status != 0) {
			_data8_->ret = FALSE;
		}
	}
	_tmp15_ = _data8_->callback;
	_tmp15__target = _data8_->callback_target;
	_tmp15__target_destroy_notify = _data8_->callback_target_destroy_notify;
	_data8_->callback = NULL;
	_data8_->callback_target = NULL;
	_data8_->callback_target_destroy_notify = NULL;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp15_, _tmp15__target, _tmp15__target_destroy_notify);
	result = NULL;
	_g_free0 (stderr);
	_g_free0 (output);
	return result;
}

static gpointer
___lambda26__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda26_ (self);
	block8_data_unref (self);
	return result;
}

static gboolean
pdftricks_merge_pdf_merge_file_co (PdftricksMergePdfMergeFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data8_ = g_slice_new0 (Block8Data);
	_data_->_data8_->_ref_count_ = 1;
	_data_->_data8_->self = g_object_ref (_data_->self);
	_g_free0 (_data_->_data8_->inputs);
	_data_->_data8_->inputs = _data_->inputs;
	_g_free0 (_data_->_data8_->output_file);
	_data_->_data8_->output_file = _data_->output_file;
	_data_->_data8_->_async_data_ = _data_;
	_data_->_data8_->ret = TRUE;
	_data_->_data8_->callback = _pdftricks_merge_pdf_merge_file_co_gsource_func;
	_data_->_data8_->callback_target = _data_;
	_data_->_data8_->callback_target_destroy_notify = NULL;
	_data_->run = ___lambda26__gthread_func;
	_data_->run_target = block8_data_ref (_data_->_data8_);
	{
		_data_->_tmp0_ = g_thread_try_new (NULL, _data_->run, _data_->run_target, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp0_;
		_g_thread_unref0 (_data_->_tmp1_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp2_ = _data_->e;
		_data_->_tmp3_ = _data_->_tmp2_->message;
		g_warning ("MergePDF.vala:333: %s", _data_->_tmp3_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		block8_data_unref (_data_->_data8_);
		_data_->_data8_ = 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;
	}
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	_data_->result = _data_->_data8_->ret;
	block8_data_unref (_data_->_data8_);
	_data_->_data8_ = 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;
}

GtkWindow*
pdftricks_merge_pdf_get_window (pdftricksMergePDF* self)
{
	GtkWindow* result;
	GtkWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
pdftricks_merge_pdf_set_window (pdftricksMergePDF* self,
                                GtkWindow* value)
{
	GtkWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdftricks_merge_pdf_get_window (self);
	if (old_value != value) {
		GtkWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdftricks_merge_pdf_properties[PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY]);
	}
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		pdftricksMergePDF* self;
		self = _data9_->self;
		_g_object_unref0 (_data9_->merge_button);
		_g_object_unref0 (_data9_->filter);
		_data9_->input_formats = (_vala_array_free (_data9_->input_formats, _data9_->input_formats_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
_pdftricks_merge_pdf_on_drag_data_get_gtk_widget_drag_data_get (GtkWidget* _sender,
                                                                GdkDragContext* context,
                                                                GtkSelectionData* selection_data,
                                                                guint info,
                                                                guint time_,
                                                                gpointer self)
{
	pdftricks_merge_pdf_on_drag_data_get ((pdftricksMergePDF*) self, _sender, context, selection_data, info, time_);
}

static void
_pdftricks_merge_pdf_on_drag_data_received_gtk_widget_drag_data_received (GtkWidget* _sender,
                                                                          GdkDragContext* context,
                                                                          gint x,
                                                                          gint y,
                                                                          GtkSelectionData* selection_data,
                                                                          guint info,
                                                                          guint time_,
                                                                          gpointer self)
{
	pdftricks_merge_pdf_on_drag_data_received ((pdftricksMergePDF*) self, _sender, context, x, y, selection_data, info, time_);
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_slist_free__g_free0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _g_free0_);
}

static void
_pdftricks_merge_pdf___lambda28_ (Block9Data* _data9_)
{
	pdftricksMergePDF* self;
	GtkFileChooserNative* chooser_file = NULL;
	GtkWindow* _tmp0_;
	GtkFileChooserNative* _tmp1_;
	GtkFileChooserNative* _tmp2_;
	GtkFileFilter* _tmp3_;
	GtkFileChooserNative* _tmp4_;
	GtkFileChooserNative* _tmp5_;
	GtkFileChooserNative* _tmp28_;
	self = _data9_->self;
	_tmp0_ = self->priv->_window;
	_tmp1_ = gtk_file_chooser_native_new (_ ("Select the file to compress"), _tmp0_, GTK_FILE_CHOOSER_ACTION_OPEN, _ ("Open"), _ ("Cancel"));
	chooser_file = _tmp1_;
	_tmp2_ = chooser_file;
	_tmp3_ = _data9_->filter;
	gtk_file_chooser_set_filter ((GtkFileChooser*) _tmp2_, _tmp3_);
	_tmp4_ = chooser_file;
	gtk_file_chooser_set_select_multiple ((GtkFileChooser*) _tmp4_, TRUE);
	_tmp5_ = chooser_file;
	if (gtk_native_dialog_run ((GtkNativeDialog*) _tmp5_) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserNative* _tmp6_;
		GSList* _tmp7_;
		_tmp6_ = chooser_file;
		_tmp7_ = gtk_file_chooser_get_filenames ((GtkFileChooser*) _tmp6_);
		{
			GSList* pdf_file_collection = NULL;
			GSList* pdf_file_it = NULL;
			pdf_file_collection = _tmp7_;
			for (pdf_file_it = pdf_file_collection; pdf_file_it != NULL; pdf_file_it = pdf_file_it->next) {
				gchar* _tmp8_;
				gchar* pdf_file = NULL;
				_tmp8_ = g_strdup ((const gchar*) pdf_file_it->data);
				pdf_file = _tmp8_;
				{
					const gchar* _tmp9_;
					gchar* _tmp10_;
					gchar** file_name_split = NULL;
					const gchar* _tmp11_;
					gchar** _tmp12_;
					gchar** _tmp13_;
					gint file_name_split_length1;
					gint _file_name_split_size_;
					gchar* input_format = NULL;
					gchar** _tmp14_;
					gint _tmp14__length1;
					gchar** _tmp15_;
					gint _tmp15__length1;
					const gchar* _tmp16_;
					gchar* _tmp17_;
					const gchar* _tmp18_;
					gchar** _tmp19_;
					gint _tmp19__length1;
					_tmp9_ = pdf_file;
					_tmp10_ = string_replace (_tmp9_, "%20", " ");
					_g_free0 (pdf_file);
					pdf_file = _tmp10_;
					_tmp11_ = pdf_file;
					_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, ".", 0);
					file_name_split = _tmp13_;
					file_name_split_length1 = _vala_array_length (_tmp12_);
					_file_name_split_size_ = file_name_split_length1;
					_tmp14_ = file_name_split;
					_tmp14__length1 = file_name_split_length1;
					_tmp15_ = file_name_split;
					_tmp15__length1 = file_name_split_length1;
					_tmp16_ = _tmp14_[_tmp15__length1 - 1];
					_tmp17_ = g_strdup (_tmp16_);
					input_format = _tmp17_;
					_tmp18_ = input_format;
					_tmp19_ = _data9_->input_formats;
					_tmp19__length1 = _data9_->input_formats_length1;
					if (_vala_string_array_contains (_tmp19_, _tmp19__length1, _tmp18_)) {
						gint page_size = 0;
						const gchar* _tmp20_;
						GtkListStore* _tmp21_;
						GtkTreeIter _tmp22_ = {0};
						GtkListStore* _tmp23_;
						GtkTreeIter _tmp24_;
						const gchar* _tmp25_;
						gchar* _tmp26_;
						gchar* _tmp27_;
						_tmp20_ = pdf_file;
						page_size = pdftricks_merge_pdf_get_page_count (self, _tmp20_);
						_tmp21_ = self->priv->list_store;
						gtk_list_store_append (_tmp21_, &_tmp22_);
						_data9_->iter = _tmp22_;
						_tmp23_ = self->priv->list_store;
						_tmp24_ = _data9_->iter;
						_tmp25_ = pdf_file;
						_tmp26_ = g_strdup_printf ("%i", page_size);
						_tmp27_ = _tmp26_;
						gtk_list_store_set (_tmp23_, &_tmp24_, 0, _tmp25_, 1, _tmp27_, -1);
						_g_free0 (_tmp27_);
					}
					_g_free0 (input_format);
					file_name_split = (_vala_array_free (file_name_split, file_name_split_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (pdf_file);
				}
			}
			(pdf_file_collection == NULL) ? NULL : (pdf_file_collection = (_g_slist_free__g_free0_ (pdf_file_collection), NULL));
		}
	}
	_tmp28_ = chooser_file;
	gtk_native_dialog_destroy ((GtkNativeDialog*) _tmp28_);
	_g_object_unref0 (chooser_file);
}

static void
__pdftricks_merge_pdf___lambda28__gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self)
{
	_pdftricks_merge_pdf___lambda28_ (self);
}

static GtkTreePath*
_vala_GtkTreePath_copy (GtkTreePath* self)
{
	return g_boxed_copy (gtk_tree_path_get_type (), self);
}

static gpointer
__vala_GtkTreePath_copy0 (gpointer self)
{
	return self ? _vala_GtkTreePath_copy (self) : NULL;
}

static void
__vala_GtkTreePath_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (_vala_GtkTreePath_free (var), NULL));
}

static inline void
_g_list_free___vala_GtkTreePath_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) __vala_GtkTreePath_free0_);
}

static void
_pdftricks_merge_pdf___lambda29_ (pdftricksMergePDF* self)
{
	GtkTreeModel* model = NULL;
	GtkTreeSelection* selection = NULL;
	GtkTreeView* _tmp0_;
	GtkTreeSelection* _tmp1_;
	GtkTreeSelection* _tmp2_;
	GtkTreeSelection* _tmp3_;
	GtkTreeModel* _tmp4_ = NULL;
	GList* _tmp5_;
	GtkTreeModel* _tmp6_;
	_tmp0_ = self->priv->view;
	_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	selection = _tmp2_;
	_tmp3_ = selection;
	_tmp5_ = gtk_tree_selection_get_selected_rows (_tmp3_, &_tmp4_);
	_g_object_unref0 (model);
	_tmp6_ = _g_object_ref0 (_tmp4_);
	model = _tmp6_;
	{
		GList* path_collection = NULL;
		GList* path_it = NULL;
		path_collection = _tmp5_;
		for (path_it = path_collection; path_it != NULL; path_it = path_it->next) {
			GtkTreePath* _tmp7_;
			GtkTreePath* path = NULL;
			_tmp7_ = __vala_GtkTreePath_copy0 ((GtkTreePath*) path_it->data);
			path = _tmp7_;
			{
				GtkTreeIter r_iter = {0};
				GtkTreeModel* _tmp8_;
				GtkTreePath* _tmp9_;
				GtkTreeIter _tmp10_ = {0};
				GtkListStore* _tmp11_;
				_tmp8_ = model;
				_tmp9_ = path;
				gtk_tree_model_get_iter (_tmp8_, &_tmp10_, _tmp9_);
				r_iter = _tmp10_;
				_tmp11_ = self->priv->list_store;
				gtk_list_store_remove (_tmp11_, &r_iter);
				__vala_GtkTreePath_free0 (path);
			}
		}
		(path_collection == NULL) ? NULL : (path_collection = (_g_list_free___vala_GtkTreePath_free0_ (path_collection), NULL));
	}
	_g_object_unref0 (selection);
	_g_object_unref0 (model);
}

static void
__pdftricks_merge_pdf___lambda29__gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self)
{
	_pdftricks_merge_pdf___lambda29_ ((pdftricksMergePDF*) self);
}

static void
_pdftricks_merge_pdf___lambda30_ (pdftricksMergePDF* self)
{
	GtkListStore* _tmp0_;
	_tmp0_ = self->priv->list_store;
	gtk_list_store_clear (_tmp0_);
}

static void
__pdftricks_merge_pdf___lambda30__gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self)
{
	_pdftricks_merge_pdf___lambda30_ ((pdftricksMergePDF*) self);
}

static void
_pdftricks_merge_pdf_confirm_merge_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self)
{
	pdftricks_merge_pdf_confirm_merge ((pdftricksMergePDF*) self);
}

static void
_pdftricks_merge_pdf___lambda31_ (Block9Data* _data9_)
{
	pdftricksMergePDF* self;
	GtkSpinner* _tmp0_;
	GtkButton* _tmp1_;
	self = _data9_->self;
	_tmp0_ = self->priv->spinner;
	g_object_set (_tmp0_, "active", TRUE, NULL);
	_tmp1_ = _data9_->merge_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, FALSE);
}

static void
__pdftricks_merge_pdf___lambda31__pdftricks_merge_pdf_proccess_begin (pdftricksMergePDF* _sender,
                                                                      gpointer self)
{
	_pdftricks_merge_pdf___lambda31_ (self);
}

static void
_pdftricks_merge_pdf___lambda32_ (Block9Data* _data9_,
                                  gboolean _result_)
{
	pdftricksMergePDF* self;
	GtkSpinner* _tmp0_;
	GtkButton* _tmp1_;
	self = _data9_->self;
	_tmp0_ = self->priv->spinner;
	g_object_set (_tmp0_, "active", FALSE, NULL);
	_tmp1_ = _data9_->merge_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	if (_result_) {
		GraniteMessageDialog* message_dialog = NULL;
		GraniteMessageDialog* _tmp2_;
		GraniteMessageDialog* _tmp3_;
		GtkWindow* _tmp4_;
		GraniteMessageDialog* _tmp5_;
		GraniteMessageDialog* _tmp6_;
		GraniteMessageDialog* _tmp7_;
		_tmp2_ = granite_message_dialog_new_with_image_from_icon_name (_ ("Success."), _ ("Your file was succefully merged."), "gtk-apply", GTK_BUTTONS_CLOSE);
		g_object_ref_sink (_tmp2_);
		message_dialog = _tmp2_;
		_tmp3_ = message_dialog;
		_tmp4_ = self->priv->_window;
		gtk_window_set_transient_for ((GtkWindow*) _tmp3_, _tmp4_);
		_tmp5_ = message_dialog;
		gtk_widget_show_all ((GtkWidget*) _tmp5_);
		_tmp6_ = message_dialog;
		gtk_dialog_run ((GtkDialog*) _tmp6_);
		_tmp7_ = message_dialog;
		gtk_widget_destroy ((GtkWidget*) _tmp7_);
		_g_object_unref0 (message_dialog);
	} else {
		GraniteMessageDialog* message_dialog = NULL;
		GraniteMessageDialog* _tmp8_;
		GraniteMessageDialog* _tmp9_;
		GtkWindow* _tmp10_;
		GraniteMessageDialog* _tmp11_;
		GraniteMessageDialog* _tmp12_;
		GraniteMessageDialog* _tmp13_;
		_tmp8_ = granite_message_dialog_new_with_image_from_icon_name (_ ("Failure."), _ ("There was a problem merging your file."), "process-stop", GTK_BUTTONS_CLOSE);
		g_object_ref_sink (_tmp8_);
		message_dialog = _tmp8_;
		_tmp9_ = message_dialog;
		_tmp10_ = self->priv->_window;
		gtk_window_set_transient_for ((GtkWindow*) _tmp9_, _tmp10_);
		_tmp11_ = message_dialog;
		gtk_widget_show_all ((GtkWidget*) _tmp11_);
		_tmp12_ = message_dialog;
		gtk_dialog_run ((GtkDialog*) _tmp12_);
		_tmp13_ = message_dialog;
		gtk_widget_destroy ((GtkWidget*) _tmp13_);
		_g_object_unref0 (message_dialog);
	}
}

static void
__pdftricks_merge_pdf___lambda32__pdftricks_merge_pdf_proccess_finished (pdftricksMergePDF* _sender,
                                                                         gboolean _result_,
                                                                         gpointer self)
{
	_pdftricks_merge_pdf___lambda32_ (self, _result_);
}

static GObject *
pdftricks_merge_pdf_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	pdftricksMergePDF * self;
	Block9Data* _data9_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	GtkButton* add_button = NULL;
	GtkButton* _tmp7_;
	GtkButton* del_button = NULL;
	GtkButton* _tmp8_;
	GtkButton* clear_button = NULL;
	GtkButton* _tmp9_;
	GtkListStore* _tmp10_;
	GtkFileFilter* _tmp11_;
	GtkFileFilter* _tmp12_;
	GtkFileFilter* _tmp13_;
	GtkFileFilter* _tmp14_;
	GtkFileFilter* _tmp15_;
	GtkFileFilter* _tmp16_;
	GtkListStore* _tmp17_;
	GtkTreeView* _tmp18_;
	GtkTreeView* _tmp19_;
	GtkTreeView* _tmp20_;
	GtkTreeView* _tmp21_;
	GtkTreeView* _tmp22_;
	GtkTreeView* _tmp23_;
	GtkTreeView* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GtkCellRendererText* cell = NULL;
	GtkCellRendererText* _tmp28_;
	GtkTreeView* _tmp29_;
	GtkCellRendererText* _tmp30_;
	GtkTreeView* _tmp31_;
	GtkCellRendererText* _tmp32_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp33_;
	GtkGrid* _tmp34_;
	GtkGrid* _tmp35_;
	GtkGrid* _tmp36_;
	GtkGrid* _tmp37_;
	GtkGrid* _tmp38_;
	GtkGrid* _tmp39_;
	GtkGrid* _tmp40_;
	GtkGrid* _tmp41_;
	GtkGrid* _tmp42_;
	GtkButton* _tmp43_;
	GtkButton* _tmp44_;
	GtkStyleContext* _tmp45_;
	GtkButton* _tmp46_;
	GtkButton* _tmp47_;
	GtkButton* _tmp48_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp49_;
	GtkScrolledWindow* _tmp50_;
	GtkScrolledWindow* _tmp51_;
	GtkScrolledWindow* _tmp52_;
	GtkTreeView* _tmp53_;
	GtkGrid* _tmp54_;
	GtkButton* _tmp55_;
	GtkGrid* _tmp56_;
	GtkButton* _tmp57_;
	GtkGrid* _tmp58_;
	GtkButton* _tmp59_;
	GtkGrid* _tmp60_;
	GtkScrolledWindow* _tmp61_;
	GtkGrid* _tmp62_;
	GtkButton* _tmp63_;
	GtkSpinner* _tmp64_;
	GtkSpinner* _tmp65_;
	GtkGrid* _tmp66_;
	GtkSpinner* _tmp67_;
	GtkGrid* _tmp68_;
	parent_class = G_OBJECT_CLASS (pdftricks_merge_pdf_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDF);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_tmp0_ = g_strdup ("pdf");
	_tmp1_ = g_strdup ("png");
	_tmp2_ = g_strdup ("jpg");
	_tmp3_ = g_strdup ("jpeg");
	_tmp4_ = g_strdup ("svg");
	_tmp5_ = g_strdup ("bmp");
	_tmp6_ = g_new0 (gchar*, 6 + 1);
	_tmp6_[0] = _tmp0_;
	_tmp6_[1] = _tmp1_;
	_tmp6_[2] = _tmp2_;
	_tmp6_[3] = _tmp3_;
	_tmp6_[4] = _tmp4_;
	_tmp6_[5] = _tmp5_;
	_data9_->input_formats = _tmp6_;
	_data9_->input_formats_length1 = 6;
	_data9_->_input_formats_size_ = _data9_->input_formats_length1;
	_tmp7_ = (GtkButton*) gtk_button_new_with_label (_ ("Add File"));
	g_object_ref_sink (_tmp7_);
	add_button = _tmp7_;
	_tmp8_ = (GtkButton*) gtk_button_new_with_label (_ ("Remove Selected"));
	g_object_ref_sink (_tmp8_);
	del_button = _tmp8_;
	_tmp9_ = (GtkButton*) gtk_button_new_with_label (_ ("Clear All"));
	g_object_ref_sink (_tmp9_);
	clear_button = _tmp9_;
	_tmp10_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING, -1);
	_g_object_unref0 (self->priv->list_store);
	self->priv->list_store = _tmp10_;
	_tmp11_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp11_);
	_data9_->filter = _tmp11_;
	_tmp12_ = _data9_->filter;
	gtk_file_filter_add_mime_type (_tmp12_, "application/pdf");
	_tmp13_ = _data9_->filter;
	gtk_file_filter_add_mime_type (_tmp13_, "image/jpeg");
	_tmp14_ = _data9_->filter;
	gtk_file_filter_add_mime_type (_tmp14_, "image/png");
	_tmp15_ = _data9_->filter;
	gtk_file_filter_add_mime_type (_tmp15_, "image/bmp");
	_tmp16_ = _data9_->filter;
	gtk_file_filter_add_mime_type (_tmp16_, "image/svg+xml");
	_tmp17_ = self->priv->list_store;
	_tmp18_ = (GtkTreeView*) gtk_tree_view_new_with_model ((GtkTreeModel*) _tmp17_);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp18_;
	_tmp19_ = self->priv->view;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp19_, TRUE);
	_tmp20_ = self->priv->view;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp20_, TRUE);
	_tmp21_ = self->priv->view;
	gtk_tree_view_enable_model_drag_source (_tmp21_, GDK_BUTTON1_MASK, PDFTRICKS_MERGE_PDF_targets, (gint) G_N_ELEMENTS (PDFTRICKS_MERGE_PDF_targets), GDK_ACTION_MOVE);
	_tmp22_ = self->priv->view;
	gtk_tree_view_enable_model_drag_dest (_tmp22_, PDFTRICKS_MERGE_PDF_targets, (gint) G_N_ELEMENTS (PDFTRICKS_MERGE_PDF_targets), GDK_ACTION_DEFAULT);
	_tmp23_ = self->priv->view;
	g_signal_connect_object ((GtkWidget*) _tmp23_, "drag-data-get", (GCallback) _pdftricks_merge_pdf_on_drag_data_get_gtk_widget_drag_data_get, self, 0);
	_tmp24_ = self->priv->view;
	g_signal_connect_object ((GtkWidget*) _tmp24_, "drag-data-received", (GCallback) _pdftricks_merge_pdf_on_drag_data_received_gtk_widget_drag_data_received, self, 0);
	_tmp25_ = add_button;
	g_signal_connect_data (_tmp25_, "clicked", (GCallback) __pdftricks_merge_pdf___lambda28__gtk_button_clicked, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	_tmp26_ = del_button;
	g_signal_connect_object (_tmp26_, "clicked", (GCallback) __pdftricks_merge_pdf___lambda29__gtk_button_clicked, self, 0);
	_tmp27_ = clear_button;
	g_signal_connect_object (_tmp27_, "clicked", (GCallback) __pdftricks_merge_pdf___lambda30__gtk_button_clicked, self, 0);
	_tmp28_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp28_);
	cell = _tmp28_;
	_tmp29_ = self->priv->view;
	_tmp30_ = cell;
	gtk_tree_view_insert_column_with_attributes (_tmp29_, -1, _ ("Files"), (GtkCellRenderer*) _tmp30_, "text", 0, NULL);
	_tmp31_ = self->priv->view;
	_tmp32_ = cell;
	gtk_tree_view_insert_column_with_attributes (_tmp31_, -1, _ ("Pages"), (GtkCellRenderer*) _tmp32_, "text", 1, NULL);
	_tmp33_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp33_);
	grid = _tmp33_;
	_tmp34_ = grid;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp34_, GTK_ORIENTATION_VERTICAL);
	_tmp35_ = grid;
	gtk_widget_set_halign ((GtkWidget*) _tmp35_, GTK_ALIGN_CENTER);
	_tmp36_ = grid;
	gtk_widget_set_valign ((GtkWidget*) _tmp36_, GTK_ALIGN_CENTER);
	_tmp37_ = grid;
	gtk_grid_set_column_spacing (_tmp37_, 16);
	_tmp38_ = grid;
	gtk_grid_set_row_spacing (_tmp38_, 8);
	_tmp39_ = grid;
	gtk_grid_set_column_homogeneous (_tmp39_, TRUE);
	_tmp40_ = grid;
	gtk_grid_set_row_homogeneous (_tmp40_, TRUE);
	_tmp41_ = grid;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp41_, TRUE);
	_tmp42_ = grid;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp42_, TRUE);
	_tmp43_ = (GtkButton*) gtk_button_new_with_label (_ ("Merge"));
	g_object_ref_sink (_tmp43_);
	_data9_->merge_button = _tmp43_;
	_tmp44_ = _data9_->merge_button;
	_tmp45_ = gtk_widget_get_style_context ((GtkWidget*) _tmp44_);
	gtk_style_context_add_class (_tmp45_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp46_ = _data9_->merge_button;
	gtk_widget_set_can_default ((GtkWidget*) _tmp46_, TRUE);
	_tmp47_ = _data9_->merge_button;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp47_, TRUE);
	_tmp48_ = _data9_->merge_button;
	g_signal_connect_object (_tmp48_, "clicked", (GCallback) _pdftricks_merge_pdf_confirm_merge_gtk_button_clicked, self, 0);
	_tmp49_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp49_);
	scroll = _tmp49_;
	_tmp50_ = scroll;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp50_, TRUE);
	_tmp51_ = scroll;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp51_, TRUE);
	_tmp52_ = scroll;
	_tmp53_ = self->priv->view;
	gtk_container_add ((GtkContainer*) _tmp52_, (GtkWidget*) _tmp53_);
	_tmp54_ = grid;
	_tmp55_ = add_button;
	gtk_grid_attach (_tmp54_, (GtkWidget*) _tmp55_, 1, 0, 1, 1);
	_tmp56_ = grid;
	_tmp57_ = del_button;
	gtk_grid_attach (_tmp56_, (GtkWidget*) _tmp57_, 2, 0, 1, 1);
	_tmp58_ = grid;
	_tmp59_ = clear_button;
	gtk_grid_attach (_tmp58_, (GtkWidget*) _tmp59_, 3, 0, 1, 1);
	_tmp60_ = grid;
	_tmp61_ = scroll;
	gtk_grid_attach (_tmp60_, (GtkWidget*) _tmp61_, 0, 1, 5, 6);
	_tmp62_ = grid;
	_tmp63_ = _data9_->merge_button;
	gtk_grid_attach (_tmp62_, (GtkWidget*) _tmp63_, 1, 7, 3, 1);
	_tmp64_ = (GtkSpinner*) gtk_spinner_new ();
	g_object_ref_sink (_tmp64_);
	_g_object_unref0 (self->priv->spinner);
	self->priv->spinner = _tmp64_;
	_tmp65_ = self->priv->spinner;
	g_object_set (_tmp65_, "active", FALSE, NULL);
	_tmp66_ = grid;
	_tmp67_ = self->priv->spinner;
	gtk_grid_attach (_tmp66_, (GtkWidget*) _tmp67_, 2, 9, 1, 1);
	_tmp68_ = grid;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp68_, TRUE, TRUE, (guint) 0);
	g_signal_connect_data (self, "proccess-begin", (GCallback) __pdftricks_merge_pdf___lambda31__pdftricks_merge_pdf_proccess_begin, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	g_signal_connect_data (self, "proccess-finished", (GCallback) __pdftricks_merge_pdf___lambda32__pdftricks_merge_pdf_proccess_finished, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	_g_object_unref0 (scroll);
	_g_object_unref0 (grid);
	_g_object_unref0 (cell);
	_g_object_unref0 (clear_button);
	_g_object_unref0 (del_button);
	_g_object_unref0 (add_button);
	block9_data_unref (_data9_);
	_data9_ = NULL;
	return obj;
}

static void
pdftricks_merge_pdf_class_init (pdftricksMergePDFClass * klass,
                                gpointer klass_data)
{
	pdftricks_merge_pdf_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdftricksMergePDF_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pdftricks_merge_pdf_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pdftricks_merge_pdf_set_property;
	G_OBJECT_CLASS (klass)->constructor = pdftricks_merge_pdf_constructor;
	G_OBJECT_CLASS (klass)->finalize = pdftricks_merge_pdf_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY, pdftricks_merge_pdf_properties[PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", gtk_window_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	pdftricks_merge_pdf_signals[PDFTRICKS_MERGE_PDF_PROCCESS_BEGIN_SIGNAL] = g_signal_new ("proccess-begin", PDFTRICKS_TYPE_MERGE_PDF, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	pdftricks_merge_pdf_signals[PDFTRICKS_MERGE_PDF_PROCCESS_FINISHED_SIGNAL] = g_signal_new ("proccess-finished", PDFTRICKS_TYPE_MERGE_PDF, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
pdftricks_merge_pdf_instance_init (pdftricksMergePDF * self,
                                   gpointer klass)
{
	self->priv = pdftricks_merge_pdf_get_instance_private (self);
}

static void
pdftricks_merge_pdf_finalize (GObject * obj)
{
	pdftricksMergePDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDF);
	_g_object_unref0 (self->priv->_window);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->list_store);
	_g_object_unref0 (self->priv->spinner);
	G_OBJECT_CLASS (pdftricks_merge_pdf_parent_class)->finalize (obj);
}

static GType
pdftricks_merge_pdf_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdftricksMergePDFClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdftricks_merge_pdf_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdftricksMergePDF), 0, (GInstanceInitFunc) pdftricks_merge_pdf_instance_init, NULL };
	GType pdftricks_merge_pdf_type_id;
	pdftricks_merge_pdf_type_id = g_type_register_static (gtk_box_get_type (), "pdftricksMergePDF", &g_define_type_info, 0);
	pdftricksMergePDF_private_offset = g_type_add_instance_private (pdftricks_merge_pdf_type_id, sizeof (pdftricksMergePDFPrivate));
	return pdftricks_merge_pdf_type_id;
}

GType
pdftricks_merge_pdf_get_type (void)
{
	static volatile gsize pdftricks_merge_pdf_type_id__once = 0;
	if (g_once_init_enter (&pdftricks_merge_pdf_type_id__once)) {
		GType pdftricks_merge_pdf_type_id;
		pdftricks_merge_pdf_type_id = pdftricks_merge_pdf_get_type_once ();
		g_once_init_leave (&pdftricks_merge_pdf_type_id__once, pdftricks_merge_pdf_type_id);
	}
	return pdftricks_merge_pdf_type_id__once;
}

static void
_vala_pdftricks_merge_pdf_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	pdftricksMergePDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDF);
	switch (property_id) {
		case PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY:
		g_value_set_object (value, pdftricks_merge_pdf_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pdftricks_merge_pdf_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	pdftricksMergePDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFTRICKS_TYPE_MERGE_PDF, pdftricksMergePDF);
	switch (property_id) {
		case PDFTRICKS_MERGE_PDF_WINDOW_PROPERTY:
		pdftricks_merge_pdf_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

