/* CompressPDF.c generated by valac 0.56.19, the Vala compiler
 * generated from CompressPDF.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 <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_COMPRESS_PDF (pdftricks_compress_pdf_get_type ())
#define PDFTRICKS_COMPRESS_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDF))
#define PDFTRICKS_COMPRESS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDFClass))
#define PDFTRICKS_IS_COMPRESS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFTRICKS_TYPE_COMPRESS_PDF))
#define PDFTRICKS_IS_COMPRESS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFTRICKS_TYPE_COMPRESS_PDF))
#define PDFTRICKS_COMPRESS_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDFClass))

typedef struct _pdftricksCompressPDF pdftricksCompressPDF;
typedef struct _pdftricksCompressPDFClass pdftricksCompressPDFClass;
typedef struct _pdftricksCompressPDFPrivate pdftricksCompressPDFPrivate;
enum  {
	PDFTRICKS_COMPRESS_PDF_0_PROPERTY,
	PDFTRICKS_COMPRESS_PDF_WINDOW_PROPERTY,
	PDFTRICKS_COMPRESS_PDF_NUM_PROPERTIES
};
static GParamSpec* pdftricks_compress_pdf_properties[PDFTRICKS_COMPRESS_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))
typedef struct _Block1Data Block1Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
typedef struct _PdftricksCompressPdfCompressFileData PdftricksCompressPdfCompressFileData;
typedef struct _Block2Data Block2Data;
enum  {
	PDFTRICKS_COMPRESS_PDF_PROCCESS_BEGIN_SIGNAL,
	PDFTRICKS_COMPRESS_PDF_PROCCESS_FINISHED_SIGNAL,
	PDFTRICKS_COMPRESS_PDF_NUM_SIGNALS
};
static guint pdftricks_compress_pdf_signals[PDFTRICKS_COMPRESS_PDF_NUM_SIGNALS] = {0};

struct _pdftricksCompressPDF {
	GtkBox parent_instance;
	pdftricksCompressPDFPrivate * priv;
};

struct _pdftricksCompressPDFClass {
	GtkBoxClass parent_class;
};

struct _pdftricksCompressPDFPrivate {
	GtkFileChooserButton* filechooser;
	GtkListStore* resolution_store;
	GtkTreeIter iter;
	GtkComboBox* resolution_box;
	GtkWindow* _window;
	GtkGrid* grid;
	GtkSpinner* spinner;
	GtkLabel* level_description;
};

struct _Block1Data {
	int _ref_count_;
	pdftricksCompressPDF* self;
	gboolean ret;
	GSourceFunc callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
	gchar* input;
	gchar* output_file;
	gchar* resolution;
	gpointer _async_data_;
};

struct _PdftricksCompressPdfCompressFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	pdftricksCompressPDF* self;
	gchar* input;
	gchar* output_file;
	gchar* resolution;
	gboolean result;
	Block1Data* _data1_;
	GThreadFunc run;
	gpointer run_target;
	GThread* _tmp0_;
	GThread* _tmp1_;
	GError* e;
	GError* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_;
};

struct _Block2Data {
	int _ref_count_;
	pdftricksCompressPDF* self;
	GtkButton* compress_button;
};

static gint pdftricksCompressPDF_private_offset;
static gpointer pdftricks_compress_pdf_parent_class = NULL;

VALA_EXTERN GType pdftricks_compress_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdftricksCompressPDF, g_object_unref)
VALA_EXTERN pdftricksCompressPDF* pdftricks_compress_pdf_new (GtkWindow* window);
VALA_EXTERN pdftricksCompressPDF* pdftricks_compress_pdf_construct (GType object_type,
                                                        GtkWindow* window);
static void pdftricks_compress_pdf_confirm_compress (pdftricksCompressPDF* self);
VALA_EXTERN GtkWindow* pdftricks_compress_pdf_get_window (pdftricksCompressPDF* self);
static void pdftricks_compress_pdf_compress_file (pdftricksCompressPDF* self,
                                           const gchar* input,
                                           const gchar* output_file,
                                           const gchar* resolution,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static gboolean pdftricks_compress_pdf_compress_file_finish (pdftricksCompressPDF* self,
                                                      GAsyncResult* _res_);
static void ___lambda5_ (pdftricksCompressPDF* self,
                  GObject* obj,
                  GAsyncResult* res);
static void ____lambda5__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void pdftricks_compress_pdf_compress_file_data_free (gpointer _data);
static gboolean pdftricks_compress_pdf_compress_file_co (PdftricksCompressPdfCompressFileData* _data_);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static gboolean _pdftricks_compress_pdf_compress_file_co_gsource_func (gpointer self);
static void* __lambda4_ (Block1Data* _data1_);
static gpointer ___lambda4__gthread_func (gpointer self);
static void pdftricks_compress_pdf_set_window (pdftricksCompressPDF* self,
                                        GtkWindow* value);
static GObject * pdftricks_compress_pdf_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void _pdftricks_compress_pdf___lambda6_ (pdftricksCompressPDF* self);
static void __pdftricks_compress_pdf___lambda6__gtk_combo_box_changed (GtkComboBox* _sender,
                                                                gpointer self);
static void _pdftricks_compress_pdf_confirm_compress_gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self);
static void _pdftricks_compress_pdf___lambda7_ (Block2Data* _data2_);
static void __pdftricks_compress_pdf___lambda7__gtk_file_chooser_button_file_set (GtkFileChooserButton* _sender,
                                                                           gpointer self);
static void _pdftricks_compress_pdf___lambda8_ (Block2Data* _data2_);
static void __pdftricks_compress_pdf___lambda8__pdftricks_compress_pdf_proccess_begin (pdftricksCompressPDF* _sender,
                                                                                gpointer self);
static void _pdftricks_compress_pdf___lambda9_ (Block2Data* _data2_,
                                         gboolean _result_);
static void __pdftricks_compress_pdf___lambda9__pdftricks_compress_pdf_proccess_finished (pdftricksCompressPDF* _sender,
                                                                                   gboolean _result_,
                                                                                   gpointer self);
static void pdftricks_compress_pdf_finalize (GObject * obj);
static GType pdftricks_compress_pdf_get_type_once (void);
static void _vala_pdftricks_compress_pdf_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_pdftricks_compress_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 inline gpointer
pdftricks_compress_pdf_get_instance_private (pdftricksCompressPDF* self)
{
	return G_STRUCT_MEMBER_P (self, pdftricksCompressPDF_private_offset);
}

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

pdftricksCompressPDF*
pdftricks_compress_pdf_new (GtkWindow* window)
{
	return pdftricks_compress_pdf_construct (PDFTRICKS_TYPE_COMPRESS_PDF, window);
}

static void
___lambda5_ (pdftricksCompressPDF* self,
             GObject* obj,
             GAsyncResult* res)
{
	g_return_if_fail (res != NULL);
	g_signal_emit (self, pdftricks_compress_pdf_signals[PDFTRICKS_COMPRESS_PDF_PROCCESS_FINISHED_SIGNAL], 0, pdftricks_compress_pdf_compress_file_finish (self, res));
}

static void
____lambda5__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	___lambda5_ ((pdftricksCompressPDF*) self, source_object, res);
	g_object_unref (self);
}

static void
pdftricks_compress_pdf_confirm_compress (pdftricksCompressPDF* self)
{
	GValue resolution = {0};
	gboolean compress = FALSE;
	GtkComboBox* _tmp0_;
	GtkTreeIter _tmp1_ = {0};
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_;
	GValue _tmp4_ = {0};
	gchar* file_pdf = NULL;
	GtkFileChooserButton* _tmp5_;
	gchar* _tmp6_;
	gchar* str_resolution = NULL;
	gchar* _tmp7_;
	gchar* output_file = NULL;
	gchar* _tmp8_;
	GtkFileChooserNative* chooser_output = NULL;
	GtkWindow* _tmp9_;
	GtkFileChooserNative* _tmp10_;
	gchar** split_filename = NULL;
	const gchar* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	gint split_filename_length1;
	gint _split_filename_size_;
	gchar* filename = NULL;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar** _tmp15_;
	gint _tmp15__length1;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	GtkFileChooserNative* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	GtkFileChooserNative* _tmp22_;
	const gchar* _tmp23_;
	gchar** _tmp24_;
	gchar** _tmp25_;
	gchar** _tmp26_;
	gint _tmp26__length1;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	GtkFileChooserNative* _tmp30_;
	GtkFileChooserNative* _tmp31_;
	GtkFileChooserNative* _tmp34_;
	gboolean _tmp35_ = FALSE;
	g_return_if_fail (self != NULL);
	compress = FALSE;
	_tmp0_ = self->priv->resolution_box;
	gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
	self->priv->iter = _tmp1_;
	_tmp2_ = self->priv->resolution_store;
	_tmp3_ = self->priv->iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp2_, &_tmp3_, 0, &_tmp4_);
	G_IS_VALUE (&resolution) ? (g_value_unset (&resolution), NULL) : NULL;
	resolution = _tmp4_;
	_tmp5_ = self->priv->filechooser;
	_tmp6_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp5_);
	file_pdf = _tmp6_;
	_tmp7_ = g_value_dup_string (&resolution);
	str_resolution = _tmp7_;
	_tmp8_ = g_strdup ("");
	output_file = _tmp8_;
	_tmp9_ = self->priv->_window;
	_tmp10_ = gtk_file_chooser_native_new (_ ("Select the file to save"), _tmp9_, GTK_FILE_CHOOSER_ACTION_SAVE, _ ("Save"), _ ("Cancel"));
	chooser_output = _tmp10_;
	_tmp11_ = file_pdf;
	_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, "/", 0);
	split_filename = _tmp13_;
	split_filename_length1 = _vala_array_length (_tmp12_);
	_split_filename_size_ = split_filename_length1;
	_tmp14_ = split_filename;
	_tmp14__length1 = split_filename_length1;
	_tmp15_ = split_filename;
	_tmp15__length1 = split_filename_length1;
	_tmp16_ = _tmp14_[_tmp15__length1 - 1];
	_tmp17_ = g_strdup (_tmp16_);
	filename = _tmp17_;
	_tmp18_ = chooser_output;
	_tmp19_ = file_pdf;
	_tmp20_ = g_path_get_dirname (_tmp19_);
	_tmp21_ = _tmp20_;
	gtk_file_chooser_set_current_folder ((GtkFileChooser*) _tmp18_, _tmp21_);
	_g_free0 (_tmp21_);
	_tmp22_ = chooser_output;
	_tmp23_ = filename;
	_tmp25_ = _tmp24_ = g_strsplit (_tmp23_, ".", 0);
	_tmp26_ = _tmp25_;
	_tmp26__length1 = _vala_array_length (_tmp24_);
	_tmp27_ = _tmp26_[0];
	_tmp28_ = g_strconcat (_tmp27_, "_compressed.pdf", NULL);
	_tmp29_ = _tmp28_;
	gtk_file_chooser_set_current_name ((GtkFileChooser*) _tmp22_, _tmp29_);
	_g_free0 (_tmp29_);
	_tmp26_ = (_vala_array_free (_tmp26_, _tmp26__length1, (GDestroyNotify) g_free), NULL);
	_tmp30_ = chooser_output;
	gtk_file_chooser_set_do_overwrite_confirmation ((GtkFileChooser*) _tmp30_, TRUE);
	_tmp31_ = chooser_output;
	if (gtk_native_dialog_run ((GtkNativeDialog*) _tmp31_) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserNative* _tmp32_;
		gchar* _tmp33_;
		_tmp32_ = chooser_output;
		_tmp33_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp32_);
		_g_free0 (output_file);
		output_file = _tmp33_;
		compress = TRUE;
	}
	_tmp34_ = chooser_output;
	gtk_native_dialog_destroy ((GtkNativeDialog*) _tmp34_);
	if (compress == TRUE) {
		const gchar* _tmp36_;
		_tmp36_ = output_file;
		_tmp35_ = g_strcmp0 (_tmp36_, "") != 0;
	} else {
		_tmp35_ = FALSE;
	}
	if (_tmp35_) {
		const gchar* _tmp37_;
		const gchar* _tmp38_;
		const gchar* _tmp39_;
		g_signal_emit (self, pdftricks_compress_pdf_signals[PDFTRICKS_COMPRESS_PDF_PROCCESS_BEGIN_SIGNAL], 0);
		_tmp37_ = file_pdf;
		_tmp38_ = output_file;
		_tmp39_ = str_resolution;
		pdftricks_compress_pdf_compress_file (self, _tmp37_, _tmp38_, _tmp39_, ____lambda5__gasync_ready_callback, g_object_ref (self));
	}
	_g_free0 (filename);
	split_filename = (_vala_array_free (split_filename, split_filename_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (chooser_output);
	_g_free0 (output_file);
	_g_free0 (str_resolution);
	_g_free0 (file_pdf);
	G_IS_VALUE (&resolution) ? (g_value_unset (&resolution), NULL) : NULL;
}

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

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

static void
pdftricks_compress_pdf_compress_file (pdftricksCompressPDF* self,
                                      const gchar* input,
                                      const gchar* output_file,
                                      const gchar* resolution,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	PdftricksCompressPdfCompressFileData* _data_;
	pdftricksCompressPDF* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (input != NULL);
	g_return_if_fail (output_file != NULL);
	g_return_if_fail (resolution != NULL);
	_data_ = g_slice_new0 (PdftricksCompressPdfCompressFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, pdftricks_compress_pdf_compress_file_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (input);
	_g_free0 (_data_->input);
	_data_->input = _tmp1_;
	_tmp2_ = g_strdup (output_file);
	_g_free0 (_data_->output_file);
	_data_->output_file = _tmp2_;
	_tmp3_ = g_strdup (resolution);
	_g_free0 (_data_->resolution);
	_data_->resolution = _tmp3_;
	pdftricks_compress_pdf_compress_file_co (_data_);
}

static gboolean
pdftricks_compress_pdf_compress_file_finish (pdftricksCompressPDF* self,
                                             GAsyncResult* _res_)
{
	gboolean result;
	PdftricksCompressPdfCompressFileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		pdftricksCompressPDF* self;
		self = _data1_->self;
		(_data1_->callback_target_destroy_notify == NULL) ? NULL : (_data1_->callback_target_destroy_notify (_data1_->callback_target), NULL);
		_data1_->callback = NULL;
		_data1_->callback_target = NULL;
		_data1_->callback_target_destroy_notify = NULL;
		_g_free0 (_data1_->input);
		_g_free0 (_data1_->output_file);
		_g_free0 (_data1_->resolution);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static gboolean
_pdftricks_compress_pdf_compress_file_co_gsource_func (gpointer self)
{
	gboolean result;
	result = pdftricks_compress_pdf_compress_file_co (self);
	return result;
}

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*
__lambda4_ (Block1Data* _data1_)
{
	pdftricksCompressPDF* self;
	gchar* output = NULL;
	gchar* stderr = NULL;
	gchar* _tmp0_;
	gint exit_status = 0;
	GSourceFunc _tmp18_;
	gpointer _tmp18__target;
	GDestroyNotify _tmp18__target_destroy_notify;
	GError* _inner_error0_ = NULL;
	void* result;
	self = _data1_->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_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gint _tmp15_ = 0;
		_tmp1_ = g_strconcat ("gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/", _data1_->resolution, NULL);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strconcat (_tmp2_, " -dNOPAUSE -dQUIET -dBATCH -sOutputFile=\"", NULL);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strconcat (_tmp4_, _data1_->output_file, NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat (_tmp6_, "\" \"", NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat (_tmp8_, _data1_->input, NULL);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_strconcat (_tmp10_, "\"", NULL);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		_g_free0 (_tmp8_);
		_g_free0 (_tmp6_);
		_g_free0 (_tmp4_);
		_g_free0 (_tmp2_);
		cmd = _tmp12_;
		g_spawn_command_line_sync (cmd, &_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;
		}
		_g_free0 (cmd);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp16_;
		const gchar* _tmp17_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		g_critical ("CompressPDF.vala:190: %s", _tmp17_);
		_data1_->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) {
		if (string_contains (output, "Error")) {
			_data1_->ret = FALSE;
		}
	}
	_tmp18_ = _data1_->callback;
	_tmp18__target = _data1_->callback_target;
	_tmp18__target_destroy_notify = _data1_->callback_target_destroy_notify;
	_data1_->callback = NULL;
	_data1_->callback_target = NULL;
	_data1_->callback_target_destroy_notify = NULL;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp18_, _tmp18__target, _tmp18__target_destroy_notify);
	result = NULL;
	_g_free0 (stderr);
	_g_free0 (output);
	return result;
}

static gpointer
___lambda4__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda4_ (self);
	block1_data_unref (self);
	return result;
}

static gboolean
pdftricks_compress_pdf_compress_file_co (PdftricksCompressPdfCompressFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data1_ = g_slice_new0 (Block1Data);
	_data_->_data1_->_ref_count_ = 1;
	_data_->_data1_->self = g_object_ref (_data_->self);
	_g_free0 (_data_->_data1_->input);
	_data_->_data1_->input = _data_->input;
	_g_free0 (_data_->_data1_->output_file);
	_data_->_data1_->output_file = _data_->output_file;
	_g_free0 (_data_->_data1_->resolution);
	_data_->_data1_->resolution = _data_->resolution;
	_data_->_data1_->_async_data_ = _data_;
	_data_->_data1_->ret = TRUE;
	_data_->_data1_->callback = _pdftricks_compress_pdf_compress_file_co_gsource_func;
	_data_->_data1_->callback_target = _data_;
	_data_->_data1_->callback_target_destroy_notify = NULL;
	_data_->run = ___lambda4__gthread_func;
	_data_->run_target = block1_data_ref (_data_->_data1_);
	{
		_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 ("CompressPDF.vala:204: %s", _data_->_tmp3_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		block1_data_unref (_data_->_data1_);
		_data_->_data1_ = 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_->_data1_->ret;
	block1_data_unref (_data_->_data1_);
	_data_->_data1_ = 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_compress_pdf_get_window (pdftricksCompressPDF* self)
{
	GtkWindow* result;
	GtkWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
pdftricks_compress_pdf_set_window (pdftricksCompressPDF* self,
                                   GtkWindow* value)
{
	GtkWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdftricks_compress_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_compress_pdf_properties[PDFTRICKS_COMPRESS_PDF_WINDOW_PROPERTY]);
	}
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		pdftricksCompressPDF* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->compress_button);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
_pdftricks_compress_pdf___lambda6_ (pdftricksCompressPDF* self)
{
	GValue resolution = {0};
	gboolean compress = FALSE;
	GtkComboBox* _tmp0_;
	GtkTreeIter _tmp1_ = {0};
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_;
	GValue _tmp4_ = {0};
	gchar* str_resolution = NULL;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	compress = FALSE;
	_tmp0_ = self->priv->resolution_box;
	gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
	self->priv->iter = _tmp1_;
	_tmp2_ = self->priv->resolution_store;
	_tmp3_ = self->priv->iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp2_, &_tmp3_, 0, &_tmp4_);
	G_IS_VALUE (&resolution) ? (g_value_unset (&resolution), NULL) : NULL;
	resolution = _tmp4_;
	_tmp5_ = g_value_dup_string (&resolution);
	str_resolution = _tmp5_;
	_tmp6_ = str_resolution;
	if (g_strcmp0 (_tmp6_, "screen") == 0) {
		GtkLabel* _tmp7_;
		_tmp7_ = self->priv->level_description;
		gtk_label_set_label (_tmp7_, _ ("Less quality, high compression"));
	} else {
		const gchar* _tmp8_;
		_tmp8_ = str_resolution;
		if (g_strcmp0 (_tmp8_, "printer") == 0) {
			GtkLabel* _tmp9_;
			_tmp9_ = self->priv->level_description;
			gtk_label_set_label (_tmp9_, _ ("Good quality, optimized for printing"));
		} else {
			const gchar* _tmp10_;
			_tmp10_ = str_resolution;
			if (g_strcmp0 (_tmp10_, "ebook") == 0) {
				GtkLabel* _tmp11_;
				_tmp11_ = self->priv->level_description;
				gtk_label_set_label (_tmp11_, _ ("Good quality, good compression"));
			} else {
				const gchar* _tmp12_;
				_tmp12_ = str_resolution;
				if (g_strcmp0 (_tmp12_, "prepress") == 0) {
					GtkLabel* _tmp13_;
					_tmp13_ = self->priv->level_description;
					gtk_label_set_label (_tmp13_, _ ("High quality, less compression"));
				}
			}
		}
	}
	_g_free0 (str_resolution);
	G_IS_VALUE (&resolution) ? (g_value_unset (&resolution), NULL) : NULL;
}

static void
__pdftricks_compress_pdf___lambda6__gtk_combo_box_changed (GtkComboBox* _sender,
                                                           gpointer self)
{
	_pdftricks_compress_pdf___lambda6_ ((pdftricksCompressPDF*) self);
}

static void
_pdftricks_compress_pdf_confirm_compress_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self)
{
	pdftricks_compress_pdf_confirm_compress ((pdftricksCompressPDF*) self);
}

static void
_pdftricks_compress_pdf___lambda7_ (Block2Data* _data2_)
{
	pdftricksCompressPDF* self;
	GtkButton* _tmp0_;
	GtkComboBox* _tmp1_;
	self = _data2_->self;
	_tmp0_ = _data2_->compress_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, TRUE);
	_tmp1_ = self->priv->resolution_box;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
}

static void
__pdftricks_compress_pdf___lambda7__gtk_file_chooser_button_file_set (GtkFileChooserButton* _sender,
                                                                      gpointer self)
{
	_pdftricks_compress_pdf___lambda7_ (self);
}

static void
_pdftricks_compress_pdf___lambda8_ (Block2Data* _data2_)
{
	pdftricksCompressPDF* self;
	GtkSpinner* _tmp0_;
	GtkButton* _tmp1_;
	self = _data2_->self;
	_tmp0_ = self->priv->spinner;
	g_object_set (_tmp0_, "active", TRUE, NULL);
	_tmp1_ = _data2_->compress_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, FALSE);
}

static void
__pdftricks_compress_pdf___lambda8__pdftricks_compress_pdf_proccess_begin (pdftricksCompressPDF* _sender,
                                                                           gpointer self)
{
	_pdftricks_compress_pdf___lambda8_ (self);
}

static void
_pdftricks_compress_pdf___lambda9_ (Block2Data* _data2_,
                                    gboolean _result_)
{
	pdftricksCompressPDF* self;
	GtkSpinner* _tmp0_;
	GtkButton* _tmp1_;
	self = _data2_->self;
	_tmp0_ = self->priv->spinner;
	g_object_set (_tmp0_, "active", FALSE, NULL);
	_tmp1_ = _data2_->compress_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 compressed."), "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 compressing 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_compress_pdf___lambda9__pdftricks_compress_pdf_proccess_finished (pdftricksCompressPDF* _sender,
                                                                              gboolean _result_,
                                                                              gpointer self)
{
	_pdftricks_compress_pdf___lambda9_ (self, _result_);
}

static GObject *
pdftricks_compress_pdf_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	pdftricksCompressPDF * self;
	Block2Data* _data2_;
	GtkFileChooserButton* _tmp0_;
	GtkLabel* _tmp1_;
	GtkFileFilter* filter = NULL;
	GtkFileFilter* _tmp2_;
	GtkFileFilter* _tmp3_;
	GtkFileChooserButton* _tmp4_;
	GtkFileFilter* _tmp5_;
	GtkListStore* _tmp6_;
	GtkListStore* _tmp7_;
	GtkTreeIter _tmp8_ = {0};
	GtkListStore* _tmp9_;
	GtkTreeIter _tmp10_;
	GtkListStore* _tmp11_;
	GtkTreeIter _tmp12_ = {0};
	GtkListStore* _tmp13_;
	GtkTreeIter _tmp14_;
	GtkListStore* _tmp15_;
	GtkTreeIter _tmp16_ = {0};
	GtkListStore* _tmp17_;
	GtkTreeIter _tmp18_;
	GtkListStore* _tmp19_;
	GtkTreeIter _tmp20_ = {0};
	GtkListStore* _tmp21_;
	GtkTreeIter _tmp22_;
	GtkListStore* _tmp23_;
	GtkComboBox* _tmp24_;
	GtkComboBox* _tmp25_;
	GtkComboBox* _tmp26_;
	GtkCellRendererText* renderer = NULL;
	GtkCellRendererText* _tmp27_;
	GtkComboBox* _tmp28_;
	GtkCellRendererText* _tmp29_;
	GtkComboBox* _tmp30_;
	GtkCellRendererText* _tmp31_;
	GtkComboBox* _tmp32_;
	GtkButton* _tmp33_;
	GtkButton* _tmp34_;
	GtkStyleContext* _tmp35_;
	GtkButton* _tmp36_;
	GtkButton* _tmp37_;
	GtkButton* _tmp38_;
	GtkButton* _tmp39_;
	GtkFileChooserButton* _tmp40_;
	GtkGrid* _tmp41_;
	GtkGrid* _tmp42_;
	GtkGrid* _tmp43_;
	GtkGrid* _tmp44_;
	GtkGrid* _tmp45_;
	GtkGrid* _tmp46_;
	GtkGrid* _tmp47_;
	GtkGrid* _tmp48_;
	GraniteHeaderLabel* _tmp49_;
	GraniteHeaderLabel* _tmp50_;
	GtkGrid* _tmp51_;
	GtkFileChooserButton* _tmp52_;
	GtkGrid* _tmp53_;
	GraniteHeaderLabel* _tmp54_;
	GraniteHeaderLabel* _tmp55_;
	GtkGrid* _tmp56_;
	GtkComboBox* _tmp57_;
	GtkGrid* _tmp58_;
	GtkLabel* _tmp59_;
	GtkGrid* _tmp60_;
	GtkButton* _tmp61_;
	GtkSpinner* _tmp62_;
	GtkSpinner* _tmp63_;
	GtkGrid* _tmp64_;
	GtkSpinner* _tmp65_;
	GtkGrid* _tmp66_;
	parent_class = G_OBJECT_CLASS (pdftricks_compress_pdf_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDF);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = (GtkFileChooserButton*) gtk_file_chooser_button_new (_ ("Select the file to compress"), GTK_FILE_CHOOSER_ACTION_OPEN);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->filechooser);
	self->priv->filechooser = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (_ ("Good quality, good compression"));
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->level_description);
	self->priv->level_description = _tmp1_;
	_tmp2_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp2_);
	filter = _tmp2_;
	_tmp3_ = filter;
	gtk_file_filter_add_mime_type (_tmp3_, "application/pdf");
	_tmp4_ = self->priv->filechooser;
	_tmp5_ = filter;
	gtk_file_chooser_set_filter ((GtkFileChooser*) _tmp4_, _tmp5_);
	_tmp6_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING, -1);
	_g_object_unref0 (self->priv->resolution_store);
	self->priv->resolution_store = _tmp6_;
	_tmp7_ = self->priv->resolution_store;
	gtk_list_store_append (_tmp7_, &_tmp8_);
	self->priv->iter = _tmp8_;
	_tmp9_ = self->priv->resolution_store;
	_tmp10_ = self->priv->iter;
	gtk_list_store_set (_tmp9_, &_tmp10_, 0, "screen", 1, _ ("Extreme Compression"), -1);
	_tmp11_ = self->priv->resolution_store;
	gtk_list_store_append (_tmp11_, &_tmp12_);
	self->priv->iter = _tmp12_;
	_tmp13_ = self->priv->resolution_store;
	_tmp14_ = self->priv->iter;
	gtk_list_store_set (_tmp13_, &_tmp14_, 0, "ebook", 1, _ ("Medium Compression"), -1);
	_tmp15_ = self->priv->resolution_store;
	gtk_list_store_append (_tmp15_, &_tmp16_);
	self->priv->iter = _tmp16_;
	_tmp17_ = self->priv->resolution_store;
	_tmp18_ = self->priv->iter;
	gtk_list_store_set (_tmp17_, &_tmp18_, 0, "printer", 1, _ ("Recommended Compression"), -1);
	_tmp19_ = self->priv->resolution_store;
	gtk_list_store_append (_tmp19_, &_tmp20_);
	self->priv->iter = _tmp20_;
	_tmp21_ = self->priv->resolution_store;
	_tmp22_ = self->priv->iter;
	gtk_list_store_set (_tmp21_, &_tmp22_, 0, "prepress", 1, _ ("Less Compression"), -1);
	_tmp23_ = self->priv->resolution_store;
	_tmp24_ = (GtkComboBox*) gtk_combo_box_new_with_model ((GtkTreeModel*) _tmp23_);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->resolution_box);
	self->priv->resolution_box = _tmp24_;
	_tmp25_ = self->priv->resolution_box;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp25_, FALSE);
	_tmp26_ = self->priv->resolution_box;
	g_signal_connect_object (_tmp26_, "changed", (GCallback) __pdftricks_compress_pdf___lambda6__gtk_combo_box_changed, self, 0);
	_tmp27_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp27_);
	renderer = _tmp27_;
	_tmp28_ = self->priv->resolution_box;
	_tmp29_ = renderer;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp28_, (GtkCellRenderer*) _tmp29_, TRUE);
	_tmp30_ = self->priv->resolution_box;
	_tmp31_ = renderer;
	gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp30_, (GtkCellRenderer*) _tmp31_, "text", 1);
	_tmp32_ = self->priv->resolution_box;
	gtk_combo_box_set_active (_tmp32_, 2);
	_tmp33_ = (GtkButton*) gtk_button_new_with_label (_ ("Compress"));
	g_object_ref_sink (_tmp33_);
	_data2_->compress_button = _tmp33_;
	_tmp34_ = _data2_->compress_button;
	_tmp35_ = gtk_widget_get_style_context ((GtkWidget*) _tmp34_);
	gtk_style_context_add_class (_tmp35_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp36_ = _data2_->compress_button;
	gtk_widget_set_can_default ((GtkWidget*) _tmp36_, TRUE);
	_tmp37_ = _data2_->compress_button;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp37_, TRUE);
	_tmp38_ = _data2_->compress_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp38_, FALSE);
	_tmp39_ = _data2_->compress_button;
	g_signal_connect_object (_tmp39_, "clicked", (GCallback) _pdftricks_compress_pdf_confirm_compress_gtk_button_clicked, self, 0);
	_tmp40_ = self->priv->filechooser;
	g_signal_connect_data (_tmp40_, "file-set", (GCallback) __pdftricks_compress_pdf___lambda7__gtk_file_chooser_button_file_set, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp41_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp41_);
	_g_object_unref0 (self->priv->grid);
	self->priv->grid = _tmp41_;
	_tmp42_ = self->priv->grid;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp42_, GTK_ORIENTATION_VERTICAL);
	_tmp43_ = self->priv->grid;
	gtk_widget_set_halign ((GtkWidget*) _tmp43_, GTK_ALIGN_CENTER);
	_tmp44_ = self->priv->grid;
	gtk_widget_set_valign ((GtkWidget*) _tmp44_, GTK_ALIGN_CENTER);
	_tmp45_ = self->priv->grid;
	gtk_grid_set_column_spacing (_tmp45_, 16);
	_tmp46_ = self->priv->grid;
	gtk_grid_set_row_spacing (_tmp46_, 8);
	_tmp47_ = self->priv->grid;
	gtk_grid_set_column_homogeneous (_tmp47_, TRUE);
	_tmp48_ = self->priv->grid;
	_tmp49_ = granite_header_label_new (_ ("File to Compress:"));
	g_object_ref_sink (_tmp49_);
	_tmp50_ = _tmp49_;
	gtk_grid_attach (_tmp48_, (GtkWidget*) _tmp50_, 0, 0, 1, 1);
	_g_object_unref0 (_tmp50_);
	_tmp51_ = self->priv->grid;
	_tmp52_ = self->priv->filechooser;
	gtk_grid_attach (_tmp51_, (GtkWidget*) _tmp52_, 1, 0, 1, 1);
	_tmp53_ = self->priv->grid;
	_tmp54_ = granite_header_label_new (_ ("Compression Level:"));
	g_object_ref_sink (_tmp54_);
	_tmp55_ = _tmp54_;
	gtk_grid_attach (_tmp53_, (GtkWidget*) _tmp55_, 0, 1, 1, 1);
	_g_object_unref0 (_tmp55_);
	_tmp56_ = self->priv->grid;
	_tmp57_ = self->priv->resolution_box;
	gtk_grid_attach (_tmp56_, (GtkWidget*) _tmp57_, 1, 1, 1, 1);
	_tmp58_ = self->priv->grid;
	_tmp59_ = self->priv->level_description;
	gtk_grid_attach (_tmp58_, (GtkWidget*) _tmp59_, 0, 2, 2, 1);
	_tmp60_ = self->priv->grid;
	_tmp61_ = _data2_->compress_button;
	gtk_grid_attach (_tmp60_, (GtkWidget*) _tmp61_, 0, 3, 2, 2);
	_tmp62_ = (GtkSpinner*) gtk_spinner_new ();
	g_object_ref_sink (_tmp62_);
	_g_object_unref0 (self->priv->spinner);
	self->priv->spinner = _tmp62_;
	_tmp63_ = self->priv->spinner;
	g_object_set (_tmp63_, "active", FALSE, NULL);
	_tmp64_ = self->priv->grid;
	_tmp65_ = self->priv->spinner;
	gtk_grid_attach (_tmp64_, (GtkWidget*) _tmp65_, 0, 5, 2, 2);
	_tmp66_ = self->priv->grid;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp66_);
	g_signal_connect_data (self, "proccess-begin", (GCallback) __pdftricks_compress_pdf___lambda8__pdftricks_compress_pdf_proccess_begin, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	g_signal_connect_data (self, "proccess-finished", (GCallback) __pdftricks_compress_pdf___lambda9__pdftricks_compress_pdf_proccess_finished, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_g_object_unref0 (renderer);
	_g_object_unref0 (filter);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return obj;
}

static void
pdftricks_compress_pdf_class_init (pdftricksCompressPDFClass * klass,
                                   gpointer klass_data)
{
	pdftricks_compress_pdf_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdftricksCompressPDF_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pdftricks_compress_pdf_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pdftricks_compress_pdf_set_property;
	G_OBJECT_CLASS (klass)->constructor = pdftricks_compress_pdf_constructor;
	G_OBJECT_CLASS (klass)->finalize = pdftricks_compress_pdf_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFTRICKS_COMPRESS_PDF_WINDOW_PROPERTY, pdftricks_compress_pdf_properties[PDFTRICKS_COMPRESS_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_compress_pdf_signals[PDFTRICKS_COMPRESS_PDF_PROCCESS_BEGIN_SIGNAL] = g_signal_new ("proccess-begin", PDFTRICKS_TYPE_COMPRESS_PDF, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	pdftricks_compress_pdf_signals[PDFTRICKS_COMPRESS_PDF_PROCCESS_FINISHED_SIGNAL] = g_signal_new ("proccess-finished", PDFTRICKS_TYPE_COMPRESS_PDF, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
pdftricks_compress_pdf_instance_init (pdftricksCompressPDF * self,
                                      gpointer klass)
{
	self->priv = pdftricks_compress_pdf_get_instance_private (self);
}

static void
pdftricks_compress_pdf_finalize (GObject * obj)
{
	pdftricksCompressPDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDF);
	_g_object_unref0 (self->priv->filechooser);
	_g_object_unref0 (self->priv->resolution_store);
	_g_object_unref0 (self->priv->resolution_box);
	_g_object_unref0 (self->priv->_window);
	_g_object_unref0 (self->priv->grid);
	_g_object_unref0 (self->priv->spinner);
	_g_object_unref0 (self->priv->level_description);
	G_OBJECT_CLASS (pdftricks_compress_pdf_parent_class)->finalize (obj);
}

static GType
pdftricks_compress_pdf_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdftricksCompressPDFClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdftricks_compress_pdf_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdftricksCompressPDF), 0, (GInstanceInitFunc) pdftricks_compress_pdf_instance_init, NULL };
	GType pdftricks_compress_pdf_type_id;
	pdftricks_compress_pdf_type_id = g_type_register_static (gtk_box_get_type (), "pdftricksCompressPDF", &g_define_type_info, 0);
	pdftricksCompressPDF_private_offset = g_type_add_instance_private (pdftricks_compress_pdf_type_id, sizeof (pdftricksCompressPDFPrivate));
	return pdftricks_compress_pdf_type_id;
}

GType
pdftricks_compress_pdf_get_type (void)
{
	static volatile gsize pdftricks_compress_pdf_type_id__once = 0;
	if (g_once_init_enter (&pdftricks_compress_pdf_type_id__once)) {
		GType pdftricks_compress_pdf_type_id;
		pdftricks_compress_pdf_type_id = pdftricks_compress_pdf_get_type_once ();
		g_once_init_leave (&pdftricks_compress_pdf_type_id__once, pdftricks_compress_pdf_type_id);
	}
	return pdftricks_compress_pdf_type_id__once;
}

static void
_vala_pdftricks_compress_pdf_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	pdftricksCompressPDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDF);
	switch (property_id) {
		case PDFTRICKS_COMPRESS_PDF_WINDOW_PROPERTY:
		g_value_set_object (value, pdftricks_compress_pdf_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pdftricks_compress_pdf_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	pdftricksCompressPDF * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFTRICKS_TYPE_COMPRESS_PDF, pdftricksCompressPDF);
	switch (property_id) {
		case PDFTRICKS_COMPRESS_PDF_WINDOW_PROPERTY:
		pdftricks_compress_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;
}

