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

/*
 * Copyright (C) 2009-2017 Canonical Ltd.
 * Author: Robert Ancell <robert.ancell@canonical.com>,
 *         Eduard Gotwig <g@ox.io>
 *
 * 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. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <adwaita.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>

#define SIDE_ID_FRONT "front"
#define SIDE_ID_BACK "back"
#define SIDE_ID_BOTH "both"
#define DEFAULT_TEXT_DPI 150
#define DEFAULT_PHOTO_DPI 300
#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 TYPE_DPI_ITEM (dpi_item_get_type ())
#define DPI_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DPI_ITEM, DpiItem))
#define DPI_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DPI_ITEM, DpiItemClass))
#define IS_DPI_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DPI_ITEM))
#define IS_DPI_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DPI_ITEM))
#define DPI_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DPI_ITEM, DpiItemClass))

typedef struct _DpiItem DpiItem;
typedef struct _DpiItemClass DpiItemClass;
typedef struct _DpiItemPrivate DpiItemPrivate;
enum  {
	DPI_ITEM_0_PROPERTY,
	DPI_ITEM_NUM_PROPERTIES
};
static GParamSpec* dpi_item_properties[DPI_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_PAPER_SIZE_ITEM (paper_size_item_get_type ())
#define PAPER_SIZE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PAPER_SIZE_ITEM, PaperSizeItem))
#define PAPER_SIZE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PAPER_SIZE_ITEM, PaperSizeItemClass))
#define IS_PAPER_SIZE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PAPER_SIZE_ITEM))
#define IS_PAPER_SIZE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PAPER_SIZE_ITEM))
#define PAPER_SIZE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PAPER_SIZE_ITEM, PaperSizeItemClass))

typedef struct _PaperSizeItem PaperSizeItem;
typedef struct _PaperSizeItemClass PaperSizeItemClass;
typedef struct _PaperSizeItemPrivate PaperSizeItemPrivate;
enum  {
	PAPER_SIZE_ITEM_0_PROPERTY,
	PAPER_SIZE_ITEM_NUM_PROPERTIES
};
static GParamSpec* paper_size_item_properties[PAPER_SIZE_ITEM_NUM_PROPERTIES];

#define TYPE_PREFERENCES_DIALOG (preferences_dialog_get_type ())
#define PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialog))
#define PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))
#define IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES_DIALOG))
#define IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES_DIALOG))
#define PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))

typedef struct _PreferencesDialog PreferencesDialog;
typedef struct _PreferencesDialogClass PreferencesDialogClass;
typedef struct _PreferencesDialogPrivate PreferencesDialogPrivate;
enum  {
	PREFERENCES_DIALOG_0_PROPERTY,
	PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* preferences_dialog_properties[PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block12Data Block12Data;
#define _gtk_expression_unref0(var) ((var == NULL) ? NULL : (var = (gtk_expression_unref (var), NULL)))
typedef enum  {
	SCAN_SIDE_FRONT,
	SCAN_SIDE_BACK,
	SCAN_SIDE_BOTH
} ScanSide;

#define TYPE_SCAN_SIDE (scan_side_get_type ())

struct _DpiItem {
	GObject parent_instance;
	DpiItemPrivate * priv;
	gint dpi;
	gchar* label;
};

struct _DpiItemClass {
	GObjectClass parent_class;
};

struct _PaperSizeItem {
	GObject parent_instance;
	PaperSizeItemPrivate * priv;
	gchar* label;
	gint width;
	gint height;
};

struct _PaperSizeItemClass {
	GObjectClass parent_class;
};

struct _PreferencesDialog {
	AdwPreferencesDialog parent_instance;
	PreferencesDialogPrivate * priv;
};

struct _PreferencesDialogClass {
	AdwPreferencesDialogClass parent_class;
};

struct _PreferencesDialogPrivate {
	GSettings* settings;
	AdwComboRow* text_dpi_row;
	AdwComboRow* photo_dpi_row;
	AdwComboRow* paper_size_row;
	GtkScale* brightness_scale;
	GtkScale* contrast_scale;
	GtkScale* compression_scale;
	AdwToggleGroup* page_delay_toggles;
	GListStore* text_dpi_model;
	GListStore* photo_dpi_model;
	AdwToggleGroup* scan_side_toggles;
	GListStore* paper_size_model;
	GtkAdjustment* brightness_adjustment;
	GtkAdjustment* contrast_adjustment;
	GtkAdjustment* compression_adjustment;
	GtkSwitch* postproc_enable_switch;
	GtkEntry* postproc_script_entry;
	GtkEntry* postproc_args_entry;
	GtkSwitch* postproc_keep_original_switch;
};

struct _Block12Data {
	int _ref_count_;
	PreferencesDialog* self;
	GSettings* settings;
};

static gpointer dpi_item_parent_class = NULL;
static gpointer paper_size_item_parent_class = NULL;
static gint PreferencesDialog_private_offset;
static gpointer preferences_dialog_parent_class = NULL;

VALA_EXTERN GType dpi_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DpiItem, g_object_unref)
VALA_EXTERN DpiItem* dpi_item_new (gint dpi,
                       const gchar* label);
VALA_EXTERN DpiItem* dpi_item_construct (GType object_type,
                             gint dpi,
                             const gchar* label);
static void dpi_item_finalize (GObject * obj);
static GType dpi_item_get_type_once (void);
VALA_EXTERN GType paper_size_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PaperSizeItem, g_object_unref)
VALA_EXTERN PaperSizeItem* paper_size_item_new (const gchar* label,
                                    gint width,
                                    gint height);
VALA_EXTERN PaperSizeItem* paper_size_item_construct (GType object_type,
                                          const gchar* label,
                                          gint width,
                                          gint height);
static void paper_size_item_finalize (GObject * obj);
static GType paper_size_item_get_type_once (void);
VALA_EXTERN GType preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PreferencesDialog, g_object_unref)
static gchar* preferences_dialog_get_dpi_label (DpiItem* device);
static gchar* preferences_dialog_get_page_size_label (PaperSizeItem* size);
VALA_EXTERN PreferencesDialog* preferences_dialog_new (GSettings* settings);
VALA_EXTERN PreferencesDialog* preferences_dialog_construct (GType object_type,
                                                 GSettings* settings);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static void preferences_dialog_set_dpi_combo (PreferencesDialog* self,
                                       AdwComboRow* combo,
                                       gint default_dpi,
                                       gint current_dpi);
static void __lambda10_ (Block12Data* _data12_);
VALA_EXTERN gint preferences_dialog_get_text_dpi (PreferencesDialog* self);
static void ___lambda10__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda11_ (Block12Data* _data12_);
VALA_EXTERN gint preferences_dialog_get_photo_dpi (PreferencesDialog* self);
static void ___lambda11__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN GType scan_side_get_type (void) G_GNUC_CONST ;
static void preferences_dialog_set_page_side (PreferencesDialog* self,
                                       ScanSide page_side);
static void __lambda12_ (Block12Data* _data12_);
static void ___lambda12__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda13_ (Block12Data* _data12_);
VALA_EXTERN gint preferences_dialog_get_brightness (PreferencesDialog* self);
static void ___lambda13__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                gpointer self);
static void __lambda14_ (Block12Data* _data12_);
VALA_EXTERN gint preferences_dialog_get_contrast (PreferencesDialog* self);
static void ___lambda14__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                gpointer self);
static void __lambda15_ (Block12Data* _data12_);
static void ___lambda15__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                gpointer self);
VALA_EXTERN void preferences_dialog_set_paper_size (PreferencesDialog* self,
                                        gint width,
                                        gint height);
static void __lambda16_ (Block12Data* _data12_);
VALA_EXTERN gboolean preferences_dialog_get_paper_size (PreferencesDialog* self,
                                            gint* width,
                                            gint* height);
static void ___lambda16__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN void preferences_dialog_set_page_delay (PreferencesDialog* self,
                                        gint page_delay);
static void __lambda17_ (Block12Data* _data12_);
static void ___lambda17__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void preferences_dialog_toggle_postproc_visibility (PreferencesDialog* self,
                                                    gboolean enabled);
static gboolean __lambda18_ (Block12Data* _data12_,
                      gboolean is_active);
static gboolean ___lambda18__gtk_switch_state_set (GtkSwitch* _sender,
                                            gboolean state,
                                            gpointer self);
static void __lambda19_ (Block12Data* _data12_);
static void ___lambda19__gtk_editable_changed (GtkEditable* _sender,
                                        gpointer self);
static void __lambda20_ (Block12Data* _data12_);
static void ___lambda20__gtk_editable_changed (GtkEditable* _sender,
                                        gpointer self);
static gboolean __lambda21_ (Block12Data* _data12_,
                      gboolean is_active);
static gboolean ___lambda21__gtk_switch_state_set (GtkSwitch* _sender,
                                            gboolean state,
                                            gpointer self);
VALA_EXTERN ScanSide preferences_dialog_get_page_side (PreferencesDialog* self);
VALA_EXTERN void preferences_dialog_set_brightness (PreferencesDialog* self,
                                        gint brightness);
VALA_EXTERN void preferences_dialog_set_contrast (PreferencesDialog* self,
                                      gint contrast);
VALA_EXTERN gint preferences_dialog_get_page_delay (PreferencesDialog* self);
static void preferences_dialog_finalize (GObject * obj);
static GType preferences_dialog_get_type_once (void);

DpiItem*
dpi_item_construct (GType object_type,
                    gint dpi,
                    const gchar* label)
{
	DpiItem * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (label != NULL, NULL);
	self = (DpiItem*) g_object_new (object_type, NULL);
	self->dpi = dpi;
	_tmp0_ = g_strdup (label);
	_g_free0 (self->label);
	self->label = _tmp0_;
	return self;
}

DpiItem*
dpi_item_new (gint dpi,
              const gchar* label)
{
	return dpi_item_construct (TYPE_DPI_ITEM, dpi, label);
}

static void
dpi_item_class_init (DpiItemClass * klass,
                     gpointer klass_data)
{
	dpi_item_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = dpi_item_finalize;
}

static void
dpi_item_instance_init (DpiItem * self,
                        gpointer klass)
{
}

static void
dpi_item_finalize (GObject * obj)
{
	DpiItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DPI_ITEM, DpiItem);
	_g_free0 (self->label);
	G_OBJECT_CLASS (dpi_item_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
dpi_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DpiItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dpi_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DpiItem), 0, (GInstanceInitFunc) dpi_item_instance_init, NULL };
	GType dpi_item_type_id;
	dpi_item_type_id = g_type_register_static (G_TYPE_OBJECT, "DpiItem", &g_define_type_info, G_TYPE_FLAG_NONE);
	return dpi_item_type_id;
}

GType
dpi_item_get_type (void)
{
	static gsize dpi_item_type_id__once = 0;
	if (g_once_init_enter (&dpi_item_type_id__once)) {
		GType dpi_item_type_id;
		dpi_item_type_id = dpi_item_get_type_once ();
		g_once_init_leave (&dpi_item_type_id__once, dpi_item_type_id);
	}
	return dpi_item_type_id__once;
}

PaperSizeItem*
paper_size_item_construct (GType object_type,
                           const gchar* label,
                           gint width,
                           gint height)
{
	PaperSizeItem * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (label != NULL, NULL);
	self = (PaperSizeItem*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (label);
	_g_free0 (self->label);
	self->label = _tmp0_;
	self->width = width;
	self->height = height;
	return self;
}

PaperSizeItem*
paper_size_item_new (const gchar* label,
                     gint width,
                     gint height)
{
	return paper_size_item_construct (TYPE_PAPER_SIZE_ITEM, label, width, height);
}

static void
paper_size_item_class_init (PaperSizeItemClass * klass,
                            gpointer klass_data)
{
	paper_size_item_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = paper_size_item_finalize;
}

static void
paper_size_item_instance_init (PaperSizeItem * self,
                               gpointer klass)
{
}

static void
paper_size_item_finalize (GObject * obj)
{
	PaperSizeItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PAPER_SIZE_ITEM, PaperSizeItem);
	_g_free0 (self->label);
	G_OBJECT_CLASS (paper_size_item_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
paper_size_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PaperSizeItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) paper_size_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PaperSizeItem), 0, (GInstanceInitFunc) paper_size_item_instance_init, NULL };
	GType paper_size_item_type_id;
	paper_size_item_type_id = g_type_register_static (G_TYPE_OBJECT, "PaperSizeItem", &g_define_type_info, G_TYPE_FLAG_NONE);
	return paper_size_item_type_id;
}

GType
paper_size_item_get_type (void)
{
	static gsize paper_size_item_type_id__once = 0;
	if (g_once_init_enter (&paper_size_item_type_id__once)) {
		GType paper_size_item_type_id;
		paper_size_item_type_id = paper_size_item_get_type_once ();
		g_once_init_leave (&paper_size_item_type_id__once, paper_size_item_type_id);
	}
	return paper_size_item_type_id__once;
}

static inline gpointer
preferences_dialog_get_instance_private (PreferencesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, PreferencesDialog_private_offset);
}

static gchar*
preferences_dialog_get_dpi_label (DpiItem* device)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (device != NULL, NULL);
	_tmp0_ = device->label;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
preferences_dialog_get_page_size_label (PaperSizeItem* size)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (size != NULL, NULL);
	_tmp0_ = size->label;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

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

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		PreferencesDialog* self;
		self = _data12_->self;
		_g_object_unref0 (_data12_->settings);
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static void
__lambda10_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	self = _data12_->self;
	g_settings_set_int (_data12_->settings, "text-dpi", preferences_dialog_get_text_dpi (self));
}

static void
___lambda10__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda10_ (self);
}

static void
__lambda11_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	self = _data12_->self;
	g_settings_set_int (_data12_->settings, "photo-dpi", preferences_dialog_get_photo_dpi (self));
}

static void
___lambda11__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda11_ (self);
}

static void
__lambda12_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	gchar* active_side_id = NULL;
	AdwToggleGroup* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	self = _data12_->self;
	_tmp0_ = self->priv->scan_side_toggles;
	_tmp1_ = adw_toggle_group_get_active_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	active_side_id = _tmp3_;
	_tmp4_ = active_side_id;
	if (g_strcmp0 (_tmp4_, SIDE_ID_FRONT) == 0) {
		g_settings_set_enum (_data12_->settings, "page-side", (gint) SCAN_SIDE_FRONT);
	} else {
		const gchar* _tmp5_;
		_tmp5_ = active_side_id;
		if (g_strcmp0 (_tmp5_, SIDE_ID_BACK) == 0) {
			g_settings_set_enum (_data12_->settings, "page-side", (gint) SCAN_SIDE_BACK);
		} else {
			g_settings_set_enum (_data12_->settings, "page-side", (gint) SCAN_SIDE_BOTH);
		}
	}
	_g_free0 (active_side_id);
}

static void
___lambda12__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda12_ (self);
}

static void
__lambda13_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	self = _data12_->self;
	g_settings_set_int (_data12_->settings, "brightness", preferences_dialog_get_brightness (self));
}

static void
___lambda13__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                           gpointer self)
{
	__lambda13_ (self);
}

static void
__lambda14_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	self = _data12_->self;
	g_settings_set_int (_data12_->settings, "contrast", preferences_dialog_get_contrast (self));
}

static void
___lambda14__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                           gpointer self)
{
	__lambda14_ (self);
}

static void
__lambda15_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	GtkAdjustment* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	self = _data12_->self;
	_tmp0_ = self->priv->compression_adjustment;
	_tmp1_ = gtk_adjustment_get_value (_tmp0_);
	_tmp2_ = _tmp1_;
	g_settings_set_int (_data12_->settings, "jpeg-quality", (gint) _tmp2_);
}

static void
___lambda15__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                           gpointer self)
{
	__lambda15_ (self);
}

static void
__lambda16_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	gint w = 0;
	gint h = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	self = _data12_->self;
	preferences_dialog_get_paper_size (self, &_tmp0_, &_tmp1_);
	w = _tmp0_;
	h = _tmp1_;
	g_settings_set_int (_data12_->settings, "paper-width", w);
	g_settings_set_int (_data12_->settings, "paper-height", h);
}

static void
___lambda16__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda16_ (self);
}

static void
__lambda17_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	AdwToggleGroup* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = _data12_->self;
	_tmp0_ = self->priv->page_delay_toggles;
	_tmp1_ = adw_toggle_group_get_active_name (_tmp0_);
	_tmp2_ = _tmp1_;
	g_settings_set_int (_data12_->settings, "page-delay", atoi (_tmp2_) * 1000);
}

static void
___lambda17__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda17_ (self);
}

static gboolean
__lambda18_ (Block12Data* _data12_,
             gboolean is_active)
{
	PreferencesDialog* self;
	gboolean result;
	self = _data12_->self;
	preferences_dialog_toggle_postproc_visibility (self, is_active);
	g_settings_set_boolean (_data12_->settings, "postproc-enabled", is_active);
	result = TRUE;
	return result;
}

static gboolean
___lambda18__gtk_switch_state_set (GtkSwitch* _sender,
                                   gboolean state,
                                   gpointer self)
{
	gboolean result;
	result = __lambda18_ (self, state);
	return result;
}

static void
__lambda19_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	self = _data12_->self;
	_tmp0_ = self->priv->postproc_script_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	g_settings_set_string (_data12_->settings, "postproc-script", _tmp1_);
}

static void
___lambda19__gtk_editable_changed (GtkEditable* _sender,
                                   gpointer self)
{
	__lambda19_ (self);
}

static void
__lambda20_ (Block12Data* _data12_)
{
	PreferencesDialog* self;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	self = _data12_->self;
	_tmp0_ = self->priv->postproc_args_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	g_settings_set_string (_data12_->settings, "postproc-arguments", _tmp1_);
}

static void
___lambda20__gtk_editable_changed (GtkEditable* _sender,
                                   gpointer self)
{
	__lambda20_ (self);
}

static gboolean
__lambda21_ (Block12Data* _data12_,
             gboolean is_active)
{
	PreferencesDialog* self;
	gboolean result;
	self = _data12_->self;
	g_settings_set_boolean (_data12_->settings, "postproc-keep-original", is_active);
	result = TRUE;
	return result;
}

static gboolean
___lambda21__gtk_switch_state_set (GtkSwitch* _sender,
                                   gboolean state,
                                   gpointer self)
{
	gboolean result;
	result = __lambda21_ (self, state);
	return result;
}

PreferencesDialog*
preferences_dialog_construct (GType object_type,
                              GSettings* settings)
{
	PreferencesDialog * self = NULL;
	Block12Data* _data12_;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	AdwComboRow* _tmp2_;
	GtkExpression** _tmp3_;
	GtkCClosureExpression* _tmp4_;
	GtkCClosureExpression* _tmp5_;
	GListStore* _tmp6_;
	GListStore* _tmp7_;
	PaperSizeItem* _tmp8_;
	PaperSizeItem* _tmp9_;
	GListStore* _tmp10_;
	PaperSizeItem* _tmp11_;
	PaperSizeItem* _tmp12_;
	GListStore* _tmp13_;
	PaperSizeItem* _tmp14_;
	PaperSizeItem* _tmp15_;
	GListStore* _tmp16_;
	PaperSizeItem* _tmp17_;
	PaperSizeItem* _tmp18_;
	GListStore* _tmp19_;
	PaperSizeItem* _tmp20_;
	PaperSizeItem* _tmp21_;
	GListStore* _tmp22_;
	PaperSizeItem* _tmp23_;
	PaperSizeItem* _tmp24_;
	GListStore* _tmp25_;
	PaperSizeItem* _tmp26_;
	PaperSizeItem* _tmp27_;
	GListStore* _tmp28_;
	PaperSizeItem* _tmp29_;
	PaperSizeItem* _tmp30_;
	AdwComboRow* _tmp31_;
	GListStore* _tmp32_;
	AdwComboRow* _tmp33_;
	GtkExpression** _tmp34_;
	GtkCClosureExpression* _tmp35_;
	GtkCClosureExpression* _tmp36_;
	GListStore* _tmp37_;
	AdwComboRow* _tmp38_;
	GListStore* _tmp39_;
	AdwComboRow* _tmp40_;
	GtkExpression** _tmp41_;
	GtkCClosureExpression* _tmp42_;
	GtkCClosureExpression* _tmp43_;
	GListStore* _tmp44_;
	AdwComboRow* _tmp45_;
	GListStore* _tmp46_;
	gint dpi = 0;
	AdwComboRow* _tmp47_;
	AdwComboRow* _tmp48_;
	AdwComboRow* _tmp49_;
	AdwComboRow* _tmp50_;
	AdwToggleGroup* _tmp51_;
	gdouble lower = 0.0;
	GtkAdjustment* _tmp52_;
	gdouble _tmp53_;
	gdouble _tmp54_;
	gchar* darker_label = NULL;
	gchar* _tmp55_;
	gdouble upper = 0.0;
	GtkAdjustment* _tmp56_;
	gdouble _tmp57_;
	gdouble _tmp58_;
	gchar* lighter_label = NULL;
	gchar* _tmp59_;
	GtkScale* _tmp60_;
	GtkScale* _tmp61_;
	GtkScale* _tmp62_;
	GtkAdjustment* _tmp63_;
	GtkAdjustment* _tmp64_;
	GtkAdjustment* _tmp65_;
	gdouble _tmp66_;
	gdouble _tmp67_;
	gchar* less_label = NULL;
	gchar* _tmp68_;
	GtkAdjustment* _tmp69_;
	gdouble _tmp70_;
	gdouble _tmp71_;
	gchar* more_label = NULL;
	gchar* _tmp72_;
	GtkScale* _tmp73_;
	GtkScale* _tmp74_;
	GtkScale* _tmp75_;
	GtkAdjustment* _tmp76_;
	GtkAdjustment* _tmp77_;
	gchar* minimum_size_label = NULL;
	gchar* _tmp78_;
	GtkScale* _tmp79_;
	GtkAdjustment* _tmp80_;
	gdouble _tmp81_;
	gdouble _tmp82_;
	GtkScale* _tmp83_;
	GtkScale* _tmp84_;
	gchar* full_detail_label = NULL;
	gchar* _tmp85_;
	GtkScale* _tmp86_;
	GtkAdjustment* _tmp87_;
	gdouble _tmp88_;
	gdouble _tmp89_;
	GtkAdjustment* _tmp90_;
	GtkAdjustment* _tmp91_;
	gint paper_width = 0;
	gint paper_height = 0;
	AdwComboRow* _tmp92_;
	AdwToggleGroup* _tmp93_;
	gboolean postproc_enabled = FALSE;
	GtkSwitch* _tmp94_;
	GtkSwitch* _tmp95_;
	gchar* postproc_script = NULL;
	gchar* _tmp96_;
	GtkEntry* _tmp97_;
	GtkEntry* _tmp98_;
	gchar* postproc_arguments = NULL;
	gchar* _tmp99_;
	GtkEntry* _tmp100_;
	GtkEntry* _tmp101_;
	gboolean postproc_keep_original = FALSE;
	GtkSwitch* _tmp102_;
	GtkSwitch* _tmp103_;
	g_return_val_if_fail (settings != NULL, NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (settings);
	_g_object_unref0 (_data12_->settings);
	_data12_->settings = _tmp0_;
	self = (PreferencesDialog*) g_object_new (object_type, NULL);
	_data12_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data12_->settings);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = self->priv->paper_size_row;
	_tmp3_ = g_new0 (GtkExpression*, 0 + 1);
	_tmp4_ = (GtkCClosureExpression*) gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, _tmp3_, (GCallback) preferences_dialog_get_page_size_label, NULL, NULL);
	_tmp5_ = _tmp4_;
	adw_combo_row_set_expression (_tmp2_, (GtkExpression*) _tmp5_);
	_gtk_expression_unref0 (_tmp5_);
	_tmp6_ = g_list_store_new (TYPE_PAPER_SIZE_ITEM);
	_g_object_unref0 (self->priv->paper_size_model);
	self->priv->paper_size_model = _tmp6_;
	_tmp7_ = self->priv->paper_size_model;
	_tmp8_ = paper_size_item_new (_ ("Automatic"), 0, 0);
	_tmp9_ = _tmp8_;
	g_list_store_append (_tmp7_, (GObject*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = self->priv->paper_size_model;
	_tmp11_ = paper_size_item_new ("A6", 1050, 1480);
	_tmp12_ = _tmp11_;
	g_list_store_append (_tmp10_, (GObject*) _tmp12_);
	_g_object_unref0 (_tmp12_);
	_tmp13_ = self->priv->paper_size_model;
	_tmp14_ = paper_size_item_new ("A5", 1480, 2100);
	_tmp15_ = _tmp14_;
	g_list_store_append (_tmp13_, (GObject*) _tmp15_);
	_g_object_unref0 (_tmp15_);
	_tmp16_ = self->priv->paper_size_model;
	_tmp17_ = paper_size_item_new ("A4", 2100, 2970);
	_tmp18_ = _tmp17_;
	g_list_store_append (_tmp16_, (GObject*) _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = self->priv->paper_size_model;
	_tmp20_ = paper_size_item_new ("A3", 2970, 4200);
	_tmp21_ = _tmp20_;
	g_list_store_append (_tmp19_, (GObject*) _tmp21_);
	_g_object_unref0 (_tmp21_);
	_tmp22_ = self->priv->paper_size_model;
	_tmp23_ = paper_size_item_new ("Letter", 2159, 2794);
	_tmp24_ = _tmp23_;
	g_list_store_append (_tmp22_, (GObject*) _tmp24_);
	_g_object_unref0 (_tmp24_);
	_tmp25_ = self->priv->paper_size_model;
	_tmp26_ = paper_size_item_new ("Legal", 2159, 3556);
	_tmp27_ = _tmp26_;
	g_list_store_append (_tmp25_, (GObject*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = self->priv->paper_size_model;
	_tmp29_ = paper_size_item_new ("4×6", 1016, 1524);
	_tmp30_ = _tmp29_;
	g_list_store_append (_tmp28_, (GObject*) _tmp30_);
	_g_object_unref0 (_tmp30_);
	_tmp31_ = self->priv->paper_size_row;
	_tmp32_ = self->priv->paper_size_model;
	adw_combo_row_set_model (_tmp31_, (GListModel*) _tmp32_);
	_tmp33_ = self->priv->text_dpi_row;
	_tmp34_ = g_new0 (GtkExpression*, 0 + 1);
	_tmp35_ = (GtkCClosureExpression*) gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, _tmp34_, (GCallback) preferences_dialog_get_dpi_label, NULL, NULL);
	_tmp36_ = _tmp35_;
	adw_combo_row_set_expression (_tmp33_, (GtkExpression*) _tmp36_);
	_gtk_expression_unref0 (_tmp36_);
	_tmp37_ = g_list_store_new (TYPE_DPI_ITEM);
	_g_object_unref0 (self->priv->text_dpi_model);
	self->priv->text_dpi_model = _tmp37_;
	_tmp38_ = self->priv->text_dpi_row;
	_tmp39_ = self->priv->text_dpi_model;
	adw_combo_row_set_model (_tmp38_, (GListModel*) _tmp39_);
	_tmp40_ = self->priv->photo_dpi_row;
	_tmp41_ = g_new0 (GtkExpression*, 0 + 1);
	_tmp42_ = (GtkCClosureExpression*) gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, _tmp41_, (GCallback) preferences_dialog_get_dpi_label, NULL, NULL);
	_tmp43_ = _tmp42_;
	adw_combo_row_set_expression (_tmp40_, (GtkExpression*) _tmp43_);
	_gtk_expression_unref0 (_tmp43_);
	_tmp44_ = g_list_store_new (TYPE_DPI_ITEM);
	_g_object_unref0 (self->priv->photo_dpi_model);
	self->priv->photo_dpi_model = _tmp44_;
	_tmp45_ = self->priv->photo_dpi_row;
	_tmp46_ = self->priv->photo_dpi_model;
	adw_combo_row_set_model (_tmp45_, (GListModel*) _tmp46_);
	dpi = g_settings_get_int (_data12_->settings, "text-dpi");
	if (dpi <= 0) {
		dpi = DEFAULT_TEXT_DPI;
	}
	_tmp47_ = self->priv->text_dpi_row;
	preferences_dialog_set_dpi_combo (self, _tmp47_, DEFAULT_TEXT_DPI, dpi);
	_tmp48_ = self->priv->text_dpi_row;
	g_signal_connect_data ((GObject*) _tmp48_, "notify::selected", (GCallback) ___lambda10__g_object_notify, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	dpi = g_settings_get_int (_data12_->settings, "photo-dpi");
	if (dpi <= 0) {
		dpi = DEFAULT_PHOTO_DPI;
	}
	_tmp49_ = self->priv->photo_dpi_row;
	preferences_dialog_set_dpi_combo (self, _tmp49_, DEFAULT_PHOTO_DPI, dpi);
	_tmp50_ = self->priv->photo_dpi_row;
	g_signal_connect_data ((GObject*) _tmp50_, "notify::selected", (GCallback) ___lambda11__g_object_notify, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	preferences_dialog_set_page_side (self, (ScanSide) g_settings_get_enum (_data12_->settings, "page-side"));
	_tmp51_ = self->priv->scan_side_toggles;
	g_signal_connect_data ((GObject*) _tmp51_, "notify::active-name", (GCallback) ___lambda12__g_object_notify, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp52_ = self->priv->brightness_adjustment;
	_tmp53_ = gtk_adjustment_get_lower (_tmp52_);
	_tmp54_ = _tmp53_;
	lower = _tmp54_;
	_tmp55_ = g_strdup_printf ("<small>%s</small>", _ ("Darker"));
	darker_label = _tmp55_;
	_tmp56_ = self->priv->brightness_adjustment;
	_tmp57_ = gtk_adjustment_get_upper (_tmp56_);
	_tmp58_ = _tmp57_;
	upper = _tmp58_;
	_tmp59_ = g_strdup_printf ("<small>%s</small>", _ ("Lighter"));
	lighter_label = _tmp59_;
	_tmp60_ = self->priv->brightness_scale;
	gtk_scale_add_mark (_tmp60_, lower, GTK_POS_BOTTOM, darker_label);
	_tmp61_ = self->priv->brightness_scale;
	gtk_scale_add_mark (_tmp61_, (gdouble) 0, GTK_POS_BOTTOM, NULL);
	_tmp62_ = self->priv->brightness_scale;
	gtk_scale_add_mark (_tmp62_, upper, GTK_POS_BOTTOM, lighter_label);
	_tmp63_ = self->priv->brightness_adjustment;
	gtk_adjustment_set_value (_tmp63_, (gdouble) g_settings_get_int (_data12_->settings, "brightness"));
	_tmp64_ = self->priv->brightness_adjustment;
	g_signal_connect_data (_tmp64_, "value-changed", (GCallback) ___lambda13__gtk_adjustment_value_changed, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp65_ = self->priv->contrast_adjustment;
	_tmp66_ = gtk_adjustment_get_lower (_tmp65_);
	_tmp67_ = _tmp66_;
	lower = _tmp67_;
	_tmp68_ = g_strdup_printf ("<small>%s</small>", _ ("Less"));
	less_label = _tmp68_;
	_tmp69_ = self->priv->contrast_adjustment;
	_tmp70_ = gtk_adjustment_get_upper (_tmp69_);
	_tmp71_ = _tmp70_;
	upper = _tmp71_;
	_tmp72_ = g_strdup_printf ("<small>%s</small>", _ ("More"));
	more_label = _tmp72_;
	_tmp73_ = self->priv->contrast_scale;
	gtk_scale_add_mark (_tmp73_, lower, GTK_POS_BOTTOM, less_label);
	_tmp74_ = self->priv->contrast_scale;
	gtk_scale_add_mark (_tmp74_, (gdouble) 0, GTK_POS_BOTTOM, NULL);
	_tmp75_ = self->priv->contrast_scale;
	gtk_scale_add_mark (_tmp75_, upper, GTK_POS_BOTTOM, more_label);
	_tmp76_ = self->priv->contrast_adjustment;
	gtk_adjustment_set_value (_tmp76_, (gdouble) g_settings_get_int (_data12_->settings, "contrast"));
	_tmp77_ = self->priv->contrast_adjustment;
	g_signal_connect_data (_tmp77_, "value-changed", (GCallback) ___lambda14__gtk_adjustment_value_changed, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp78_ = g_strdup_printf ("<small>%s</small>", _ ("Minimum size"));
	minimum_size_label = _tmp78_;
	_tmp79_ = self->priv->compression_scale;
	_tmp80_ = self->priv->compression_adjustment;
	_tmp81_ = gtk_adjustment_get_lower (_tmp80_);
	_tmp82_ = _tmp81_;
	gtk_scale_add_mark (_tmp79_, _tmp82_, GTK_POS_BOTTOM, minimum_size_label);
	_tmp83_ = self->priv->compression_scale;
	gtk_scale_add_mark (_tmp83_, (gdouble) 75, GTK_POS_BOTTOM, NULL);
	_tmp84_ = self->priv->compression_scale;
	gtk_scale_add_mark (_tmp84_, (gdouble) 90, GTK_POS_BOTTOM, NULL);
	_tmp85_ = g_strdup_printf ("<small>%s</small>", _ ("Full detail"));
	full_detail_label = _tmp85_;
	_tmp86_ = self->priv->compression_scale;
	_tmp87_ = self->priv->compression_adjustment;
	_tmp88_ = gtk_adjustment_get_upper (_tmp87_);
	_tmp89_ = _tmp88_;
	gtk_scale_add_mark (_tmp86_, _tmp89_, GTK_POS_BOTTOM, full_detail_label);
	_tmp90_ = self->priv->compression_adjustment;
	gtk_adjustment_set_value (_tmp90_, (gdouble) g_settings_get_int (_data12_->settings, "jpeg-quality"));
	_tmp91_ = self->priv->compression_adjustment;
	g_signal_connect_data (_tmp91_, "value-changed", (GCallback) ___lambda15__gtk_adjustment_value_changed, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	paper_width = g_settings_get_int (_data12_->settings, "paper-width");
	paper_height = g_settings_get_int (_data12_->settings, "paper-height");
	preferences_dialog_set_paper_size (self, paper_width, paper_height);
	_tmp92_ = self->priv->paper_size_row;
	g_signal_connect_data ((GObject*) _tmp92_, "notify::selected", (GCallback) ___lambda16__g_object_notify, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	preferences_dialog_set_page_delay (self, g_settings_get_int (_data12_->settings, "page-delay"));
	_tmp93_ = self->priv->page_delay_toggles;
	g_signal_connect_data ((GObject*) _tmp93_, "notify::active-name", (GCallback) ___lambda17__g_object_notify, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	postproc_enabled = g_settings_get_boolean (_data12_->settings, "postproc-enabled");
	_tmp94_ = self->priv->postproc_enable_switch;
	gtk_switch_set_state (_tmp94_, postproc_enabled);
	preferences_dialog_toggle_postproc_visibility (self, postproc_enabled);
	_tmp95_ = self->priv->postproc_enable_switch;
	g_signal_connect_data (_tmp95_, "state-set", (GCallback) ___lambda18__gtk_switch_state_set, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp96_ = g_settings_get_string (_data12_->settings, "postproc-script");
	postproc_script = _tmp96_;
	_tmp97_ = self->priv->postproc_script_entry;
	gtk_editable_set_text ((GtkEditable*) _tmp97_, postproc_script);
	_tmp98_ = self->priv->postproc_script_entry;
	g_signal_connect_data ((GtkEditable*) _tmp98_, "changed", (GCallback) ___lambda19__gtk_editable_changed, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp99_ = g_settings_get_string (_data12_->settings, "postproc-arguments");
	postproc_arguments = _tmp99_;
	_tmp100_ = self->priv->postproc_args_entry;
	gtk_editable_set_text ((GtkEditable*) _tmp100_, postproc_arguments);
	_tmp101_ = self->priv->postproc_args_entry;
	g_signal_connect_data ((GtkEditable*) _tmp101_, "changed", (GCallback) ___lambda20__gtk_editable_changed, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	postproc_keep_original = g_settings_get_boolean (_data12_->settings, "postproc-keep-original");
	_tmp102_ = self->priv->postproc_keep_original_switch;
	gtk_switch_set_state (_tmp102_, postproc_keep_original);
	_tmp103_ = self->priv->postproc_keep_original_switch;
	g_signal_connect_data (_tmp103_, "state-set", (GCallback) ___lambda21__gtk_switch_state_set, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_g_free0 (postproc_arguments);
	_g_free0 (postproc_script);
	_g_free0 (full_detail_label);
	_g_free0 (minimum_size_label);
	_g_free0 (more_label);
	_g_free0 (less_label);
	_g_free0 (lighter_label);
	_g_free0 (darker_label);
	block12_data_unref (_data12_);
	_data12_ = NULL;
	return self;
}

PreferencesDialog*
preferences_dialog_new (GSettings* settings)
{
	return preferences_dialog_construct (TYPE_PREFERENCES_DIALOG, settings);
}

static void
preferences_dialog_toggle_postproc_visibility (PreferencesDialog* self,
                                               gboolean enabled)
{
	GtkEntry* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkEntry* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	GtkSwitch* _tmp10_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	GtkWidget* _tmp13_;
	GtkWidget* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->postproc_script_entry;
	_tmp1_ = gtk_widget_get_parent ((GtkWidget*) _tmp0_);
	_tmp2_ = gtk_widget_get_parent (_tmp1_);
	_tmp3_ = gtk_widget_get_parent (_tmp2_);
	_tmp4_ = gtk_widget_get_parent (_tmp3_);
	gtk_widget_set_visible (_tmp4_, enabled);
	_tmp5_ = self->priv->postproc_args_entry;
	_tmp6_ = gtk_widget_get_parent ((GtkWidget*) _tmp5_);
	_tmp7_ = gtk_widget_get_parent (_tmp6_);
	_tmp8_ = gtk_widget_get_parent (_tmp7_);
	_tmp9_ = gtk_widget_get_parent (_tmp8_);
	gtk_widget_set_visible (_tmp9_, enabled);
	_tmp10_ = self->priv->postproc_keep_original_switch;
	_tmp11_ = gtk_widget_get_parent ((GtkWidget*) _tmp10_);
	_tmp12_ = gtk_widget_get_parent (_tmp11_);
	_tmp13_ = gtk_widget_get_parent (_tmp12_);
	_tmp14_ = gtk_widget_get_parent (_tmp13_);
	gtk_widget_set_visible (_tmp14_, enabled);
}

static void
preferences_dialog_set_page_side (PreferencesDialog* self,
                                  ScanSide page_side)
{
	gchar* active_side_id = NULL;
	AdwToggleGroup* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	switch (page_side) {
		case SCAN_SIDE_FRONT:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup (SIDE_ID_FRONT);
			_g_free0 (active_side_id);
			active_side_id = _tmp0_;
			break;
		}
		case SCAN_SIDE_BACK:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup (SIDE_ID_BACK);
			_g_free0 (active_side_id);
			active_side_id = _tmp1_;
			break;
		}
		default:
		case SCAN_SIDE_BOTH:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup (SIDE_ID_BOTH);
			_g_free0 (active_side_id);
			active_side_id = _tmp2_;
			break;
		}
	}
	_tmp3_ = self->priv->scan_side_toggles;
	_tmp4_ = active_side_id;
	adw_toggle_group_set_active_name (_tmp3_, _tmp4_);
	_g_free0 (active_side_id);
}

ScanSide
preferences_dialog_get_page_side (PreferencesDialog* self)
{
	gchar* active_side_id = NULL;
	AdwToggleGroup* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	ScanSide result;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->scan_side_toggles;
	_tmp1_ = adw_toggle_group_get_active_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	active_side_id = _tmp3_;
	_tmp4_ = active_side_id;
	if (g_strcmp0 (_tmp4_, SIDE_ID_FRONT) == 0) {
		result = SCAN_SIDE_FRONT;
		_g_free0 (active_side_id);
		return result;
	} else {
		const gchar* _tmp5_;
		_tmp5_ = active_side_id;
		if (g_strcmp0 (_tmp5_, SIDE_ID_BACK) == 0) {
			result = SCAN_SIDE_BACK;
			_g_free0 (active_side_id);
			return result;
		} else {
			result = SCAN_SIDE_BOTH;
			_g_free0 (active_side_id);
			return result;
		}
	}
}

void
preferences_dialog_set_paper_size (PreferencesDialog* self,
                                   gint width,
                                   gint height)
{
	g_return_if_fail (self != NULL);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GListStore* _tmp2_;
				guint _tmp3_;
				guint _tmp4_;
				PaperSizeItem* item = NULL;
				GListStore* _tmp5_;
				GObject* _tmp6_;
				PaperSizeItem* _tmp7_;
				gboolean _tmp8_ = FALSE;
				PaperSizeItem* _tmp9_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->paper_size_model;
				g_object_get (_tmp2_, "n-items", &_tmp3_, NULL);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->paper_size_model;
				_tmp6_ = g_list_model_get_item ((GListModel*) _tmp5_, i);
				_tmp7_ = IS_PAPER_SIZE_ITEM (_tmp6_) ? ((PaperSizeItem*) _tmp6_) : NULL;
				if (_tmp7_ == NULL) {
					_g_object_unref0 (_tmp6_);
				}
				item = _tmp7_;
				_tmp9_ = item;
				if (_tmp9_->width == width) {
					PaperSizeItem* _tmp10_;
					_tmp10_ = item;
					_tmp8_ = _tmp10_->height == height;
				} else {
					_tmp8_ = FALSE;
				}
				if (_tmp8_) {
					AdwComboRow* _tmp11_;
					_tmp11_ = self->priv->paper_size_row;
					adw_combo_row_set_selected (_tmp11_, i);
					_g_object_unref0 (item);
					break;
				}
				_g_object_unref0 (item);
			}
		}
	}
}

gint
preferences_dialog_get_text_dpi (PreferencesDialog* self)
{
	AdwComboRow* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->text_dpi_row;
	_tmp1_ = adw_combo_row_get_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != GTK_INVALID_LIST_POSITION) {
		DpiItem* item = NULL;
		GListStore* _tmp3_;
		AdwComboRow* _tmp4_;
		guint _tmp5_;
		guint _tmp6_;
		GObject* _tmp7_;
		DpiItem* _tmp8_;
		DpiItem* _tmp9_;
		_tmp3_ = self->priv->text_dpi_model;
		_tmp4_ = self->priv->text_dpi_row;
		_tmp5_ = adw_combo_row_get_selected (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_list_model_get_item ((GListModel*) _tmp3_, _tmp6_);
		_tmp8_ = IS_DPI_ITEM (_tmp7_) ? ((DpiItem*) _tmp7_) : NULL;
		if (_tmp8_ == NULL) {
			_g_object_unref0 (_tmp7_);
		}
		item = _tmp8_;
		_tmp9_ = item;
		result = _tmp9_->dpi;
		_g_object_unref0 (item);
		return result;
	}
	result = DEFAULT_TEXT_DPI;
	return result;
}

gint
preferences_dialog_get_photo_dpi (PreferencesDialog* self)
{
	AdwComboRow* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->photo_dpi_row;
	_tmp1_ = adw_combo_row_get_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != GTK_INVALID_LIST_POSITION) {
		DpiItem* item = NULL;
		GListStore* _tmp3_;
		AdwComboRow* _tmp4_;
		guint _tmp5_;
		guint _tmp6_;
		GObject* _tmp7_;
		DpiItem* _tmp8_;
		DpiItem* _tmp9_;
		_tmp3_ = self->priv->photo_dpi_model;
		_tmp4_ = self->priv->photo_dpi_row;
		_tmp5_ = adw_combo_row_get_selected (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_list_model_get_item ((GListModel*) _tmp3_, _tmp6_);
		_tmp8_ = IS_DPI_ITEM (_tmp7_) ? ((DpiItem*) _tmp7_) : NULL;
		if (_tmp8_ == NULL) {
			_g_object_unref0 (_tmp7_);
		}
		item = _tmp8_;
		_tmp9_ = item;
		result = _tmp9_->dpi;
		_g_object_unref0 (item);
		return result;
	}
	result = DEFAULT_PHOTO_DPI;
	return result;
}

gboolean
preferences_dialog_get_paper_size (PreferencesDialog* self,
                                   gint* width,
                                   gint* height)
{
	gint _vala_width = 0;
	gint _vala_height = 0;
	AdwComboRow* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_height = 0;
	_vala_width = _vala_height;
	_tmp0_ = self->priv->paper_size_row;
	_tmp1_ = adw_combo_row_get_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != GTK_INVALID_LIST_POSITION) {
		PaperSizeItem* item = NULL;
		GListStore* _tmp3_;
		AdwComboRow* _tmp4_;
		guint _tmp5_;
		guint _tmp6_;
		GObject* _tmp7_;
		PaperSizeItem* _tmp8_;
		PaperSizeItem* _tmp9_;
		PaperSizeItem* _tmp10_;
		_tmp3_ = self->priv->paper_size_model;
		_tmp4_ = self->priv->paper_size_row;
		_tmp5_ = adw_combo_row_get_selected (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_list_model_get_item ((GListModel*) _tmp3_, _tmp6_);
		_tmp8_ = IS_PAPER_SIZE_ITEM (_tmp7_) ? ((PaperSizeItem*) _tmp7_) : NULL;
		if (_tmp8_ == NULL) {
			_g_object_unref0 (_tmp7_);
		}
		item = _tmp8_;
		_tmp9_ = item;
		_vala_width = _tmp9_->width;
		_tmp10_ = item;
		_vala_height = _tmp10_->height;
		result = TRUE;
		_g_object_unref0 (item);
		if (width) {
			*width = _vala_width;
		}
		if (height) {
			*height = _vala_height;
		}
		return result;
	}
	result = FALSE;
	if (width) {
		*width = _vala_width;
	}
	if (height) {
		*height = _vala_height;
	}
	return result;
}

gint
preferences_dialog_get_brightness (PreferencesDialog* self)
{
	GtkAdjustment* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->brightness_adjustment;
	_tmp1_ = gtk_adjustment_get_value (_tmp0_);
	_tmp2_ = _tmp1_;
	result = (gint) _tmp2_;
	return result;
}

void
preferences_dialog_set_brightness (PreferencesDialog* self,
                                   gint brightness)
{
	GtkAdjustment* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->brightness_adjustment;
	gtk_adjustment_set_value (_tmp0_, (gdouble) brightness);
}

gint
preferences_dialog_get_contrast (PreferencesDialog* self)
{
	GtkAdjustment* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->contrast_adjustment;
	_tmp1_ = gtk_adjustment_get_value (_tmp0_);
	_tmp2_ = _tmp1_;
	result = (gint) _tmp2_;
	return result;
}

void
preferences_dialog_set_contrast (PreferencesDialog* self,
                                 gint contrast)
{
	GtkAdjustment* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->contrast_adjustment;
	gtk_adjustment_set_value (_tmp0_, (gdouble) contrast);
}

gint
preferences_dialog_get_page_delay (PreferencesDialog* self)
{
	AdwToggleGroup* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->page_delay_toggles;
	_tmp1_ = adw_toggle_group_get_active_name (_tmp0_);
	_tmp2_ = _tmp1_;
	result = atoi (_tmp2_) * 1000;
	return result;
}

void
preferences_dialog_set_page_delay (PreferencesDialog* self,
                                   gint page_delay)
{
	AdwToggleGroup* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->page_delay_toggles;
	_tmp1_ = g_strdup_printf ("%i", page_delay / 1000);
	_tmp2_ = _tmp1_;
	adw_toggle_group_set_active_name (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
}

static void
preferences_dialog_set_dpi_combo (PreferencesDialog* self,
                                  AdwComboRow* combo,
                                  gint default_dpi,
                                  gint current_dpi)
{
	GListStore* model = NULL;
	GListModel* _tmp0_;
	GListModel* _tmp1_;
	GListStore* _tmp2_;
	gint* scan_resolutions = NULL;
	gint* _tmp3_;
	gint scan_resolutions_length1;
	gint _scan_resolutions_size_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (combo != NULL);
	_tmp0_ = adw_combo_row_get_model (combo);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, g_list_store_get_type ()) ? ((GListStore*) _tmp1_) : NULL);
	model = _tmp2_;
	_tmp3_ = g_new0 (gint, 7);
	_tmp3_[0] = 75;
	_tmp3_[1] = 150;
	_tmp3_[2] = 200;
	_tmp3_[3] = 300;
	_tmp3_[4] = 600;
	_tmp3_[5] = 1200;
	_tmp3_[6] = 2400;
	scan_resolutions = _tmp3_;
	scan_resolutions_length1 = 7;
	_scan_resolutions_size_ = scan_resolutions_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gint* _tmp6_;
				gint _tmp6__length1;
				gint dpi = 0;
				gint* _tmp7_;
				gint _tmp7__length1;
				gint _tmp8_;
				gchar* label = NULL;
				GListStore* _tmp13_;
				const gchar* _tmp14_;
				DpiItem* _tmp15_;
				DpiItem* _tmp16_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = scan_resolutions;
				_tmp6__length1 = scan_resolutions_length1;
				if (!(i < _tmp6__length1)) {
					break;
				}
				_tmp7_ = scan_resolutions;
				_tmp7__length1 = scan_resolutions_length1;
				_tmp8_ = _tmp7_[i];
				dpi = _tmp8_;
				if (dpi == default_dpi) {
					gchar* _tmp9_;
					_tmp9_ = g_strdup_printf (_ ("%d dpi (default)"), dpi);
					_g_free0 (label);
					label = _tmp9_;
				} else {
					if (dpi == 75) {
						gchar* _tmp10_;
						_tmp10_ = g_strdup_printf (_ ("%d dpi (draft)"), dpi);
						_g_free0 (label);
						label = _tmp10_;
					} else {
						if (dpi == 1200) {
							gchar* _tmp11_;
							_tmp11_ = g_strdup_printf (_ ("%d dpi (high resolution)"), dpi);
							_g_free0 (label);
							label = _tmp11_;
						} else {
							gchar* _tmp12_;
							_tmp12_ = g_strdup_printf (_ ("%d dpi"), dpi);
							_g_free0 (label);
							label = _tmp12_;
						}
					}
				}
				_tmp13_ = model;
				_tmp14_ = label;
				_tmp15_ = dpi_item_new (dpi, _tmp14_);
				_tmp16_ = _tmp15_;
				g_list_store_append (_tmp13_, (GObject*) _tmp16_);
				_g_object_unref0 (_tmp16_);
				if (dpi == current_dpi) {
					adw_combo_row_set_selected (combo, (guint) i);
				}
				_g_free0 (label);
			}
		}
	}
	scan_resolutions = (g_free (scan_resolutions), NULL);
	_g_object_unref0 (model);
}

static void
preferences_dialog_class_init (PreferencesDialogClass * klass,
                               gpointer klass_data)
{
	preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PreferencesDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = preferences_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/SimpleScan/ui/preferences-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "text_dpi_row", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, text_dpi_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "photo_dpi_row", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, photo_dpi_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "paper_size_row", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, paper_size_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "brightness_scale", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, brightness_scale));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "contrast_scale", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, contrast_scale));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "compression_scale", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, compression_scale));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "page_delay_toggles", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, page_delay_toggles));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "scan_side_toggles", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, scan_side_toggles));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "brightness_adjustment", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, brightness_adjustment));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "contrast_adjustment", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, contrast_adjustment));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "compression_adjustment", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, compression_adjustment));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "postproc_enable_switch", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, postproc_enable_switch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "postproc_script_entry", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, postproc_script_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "postproc_args_entry", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, postproc_args_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "postproc_keep_original_switch", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, postproc_keep_original_switch));
}

static void
preferences_dialog_instance_init (PreferencesDialog * self,
                                  gpointer klass)
{
	self->priv = preferences_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
preferences_dialog_finalize (GObject * obj)
{
	PreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PREFERENCES_DIALOG, PreferencesDialog);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->text_dpi_model);
	_g_object_unref0 (self->priv->photo_dpi_model);
	_g_object_unref0 (self->priv->paper_size_model);
	G_OBJECT_CLASS (preferences_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
preferences_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesDialog), 0, (GInstanceInitFunc) preferences_dialog_instance_init, NULL };
	GType preferences_dialog_type_id;
	preferences_dialog_type_id = g_type_register_static (adw_preferences_dialog_get_type (), "PreferencesDialog", &g_define_type_info, G_TYPE_FLAG_NONE);
	PreferencesDialog_private_offset = g_type_add_instance_private (preferences_dialog_type_id, sizeof (PreferencesDialogPrivate));
	return preferences_dialog_type_id;
}

GType
preferences_dialog_get_type (void)
{
	static gsize preferences_dialog_type_id__once = 0;
	if (g_once_init_enter (&preferences_dialog_type_id__once)) {
		GType preferences_dialog_type_id;
		preferences_dialog_type_id = preferences_dialog_get_type_once ();
		g_once_init_leave (&preferences_dialog_type_id__once, preferences_dialog_type_id);
	}
	return preferences_dialog_type_id__once;
}

