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

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <adwaita.h>
#include <gtk/gtk.h>
#include <gio/gio.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

typedef void (*DcSettingWriter) (GKeyFile* kf, gpointer user_data);

#define DC_TYPE_SETTINGS_MANAGER (dc_settings_manager_get_type ())
#define DC_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManager))
#define DC_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))
#define DC_IS_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SETTINGS_MANAGER))
#define DC_IS_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SETTINGS_MANAGER))
#define DC_SETTINGS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))

typedef struct _DcSettingsManager DcSettingsManager;
typedef struct _DcSettingsManagerClass DcSettingsManagerClass;
typedef struct _DcSettingsManagerPrivate DcSettingsManagerPrivate;
enum  {
	DC_SETTINGS_MANAGER_0_PROPERTY,
	DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY,
	DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY,
	DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY,
	DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY,
	DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY,
	DC_SETTINGS_MANAGER_NUM_PROPERTIES
};
static GParamSpec* dc_settings_manager_properties[DC_SETTINGS_MANAGER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_key_file_unref0(var) ((var == NULL) ? NULL : (var = (g_key_file_unref (var), NULL)))
typedef struct _Block25Data Block25Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block26Data Block26Data;
typedef struct _Block27Data Block27Data;
typedef struct _Block28Data Block28Data;
typedef struct _Block29Data Block29Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define DC_TYPE_SETTINGS_DIALOG (dc_settings_dialog_get_type ())
#define DC_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialog))
#define DC_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialogClass))
#define DC_IS_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SETTINGS_DIALOG))
#define DC_IS_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SETTINGS_DIALOG))
#define DC_SETTINGS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialogClass))

typedef struct _DcSettingsDialog DcSettingsDialog;
typedef struct _DcSettingsDialogClass DcSettingsDialogClass;
typedef struct _DcSettingsDialogPrivate DcSettingsDialogPrivate;

#define DC_TYPE_WINDOW (dc_window_get_type ())
#define DC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_WINDOW, DcWindow))
#define DC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_WINDOW, DcWindowClass))
#define DC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_WINDOW))
#define DC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_WINDOW))
#define DC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_WINDOW, DcWindowClass))

typedef struct _DcWindow DcWindow;
typedef struct _DcWindowClass DcWindowClass;
enum  {
	DC_SETTINGS_DIALOG_0_PROPERTY,
	DC_SETTINGS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_settings_dialog_properties[DC_SETTINGS_DIALOG_NUM_PROPERTIES];
typedef struct _Block30Data Block30Data;
typedef struct _DcWindowPrivate DcWindowPrivate;
typedef struct _DcSettingsDialogOnBrowseRpcServerData DcSettingsDialogOnBrowseRpcServerData;
typedef void (*DcVoidFunc) (gpointer user_data);

struct _DcSettingsManager {
	GObject parent_instance;
	DcSettingsManagerPrivate * priv;
};

struct _DcSettingsManagerClass {
	GObjectClass parent_class;
};

struct _DcSettingsManagerPrivate {
	gint _double_click_action;
	gboolean _markdown_rendering;
	gboolean _shift_enter_sends;
	gboolean _notifications_enabled;
	gchar* _rpc_server_path;
};

struct _Block25Data {
	int _ref_count_;
	DcSettingsManager* self;
	gint v;
};

struct _Block26Data {
	int _ref_count_;
	DcSettingsManager* self;
	gboolean v;
};

struct _Block27Data {
	int _ref_count_;
	DcSettingsManager* self;
	gboolean v;
};

struct _Block28Data {
	int _ref_count_;
	DcSettingsManager* self;
	gboolean v;
};

struct _Block29Data {
	int _ref_count_;
	DcSettingsManager* self;
	gchar* v;
};

struct _DcSettingsDialog {
	AdwDialog parent_instance;
	DcSettingsDialogPrivate * priv;
};

struct _DcSettingsDialogClass {
	AdwDialogClass parent_class;
};

struct _DcSettingsDialogPrivate {
	GtkBox* content;
	DcWindow* app_window;
	AdwActionRow* rpc_row;
	GtkSwitch* rpc_custom_switch;
};

struct _Block30Data {
	int _ref_count_;
	DcSettingsDialog* self;
	GtkDropDown* dblclick_combo;
	GtkSwitch* md_switch;
	GtkSwitch* shift_switch;
	GtkSwitch* notif_switch;
};

struct _DcWindow {
	AdwApplicationWindow parent_instance;
	DcWindowPrivate * priv;
	DcSettingsManager* settings;
};

struct _DcWindowClass {
	AdwApplicationWindowClass parent_class;
};

struct _DcSettingsDialogOnBrowseRpcServerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcSettingsDialog* self;
	GtkFileDialog* dlg;
	GtkFileDialog* _tmp0_;
	GtkFileDialog* _tmp1_;
	GtkFileDialog* _tmp2_;
	gchar* start;
	DcWindow* _tmp3_;
	DcSettingsManager* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	GtkFileDialog* _tmp18_;
	const gchar* _tmp19_;
	GFile* _tmp20_;
	GFile* _tmp21_;
	GFile* file;
	GtkFileDialog* _tmp22_;
	DcWindow* _tmp23_;
	GFile* _tmp24_;
	gchar* path;
	gchar* _tmp25_;
	gboolean _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	DcWindow* _tmp29_;
	DcSettingsManager* _tmp30_;
	const gchar* _tmp31_;
	DcWindow* _tmp32_;
	DcWindow* _tmp33_;
	GError* e;
	gboolean _tmp34_;
	GError* _tmp35_;
	GError* _tmp36_;
	DcWindow* _tmp37_;
	GError* _tmp38_;
	const gchar* _tmp39_;
	GtkSwitch* _tmp40_;
	DcWindow* _tmp41_;
	DcSettingsManager* _tmp42_;
	const gchar* _tmp43_;
	const gchar* _tmp44_;
	gint _tmp45_;
	gint _tmp46_;
	GError* _inner_error0_;
};

static gint DcSettingsManager_private_offset;
static gpointer dc_settings_manager_parent_class = NULL;
VALA_EXTERN gboolean dc_markdown_enabled;
static gint DcSettingsDialog_private_offset;
static gpointer dc_settings_dialog_parent_class = NULL;

VALA_EXTERN GType dc_settings_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsManager, g_object_unref)
VALA_EXTERN gchar* dc_settings_manager_get_config_path (void);
VALA_EXTERN void dc_settings_manager_load (DcSettingsManager* self);
static gint dc_settings_manager_kf_int (GKeyFile* kf,
                                 const gchar* k,
                                 gint d);
VALA_EXTERN void dc_settings_manager_set_double_click_action (DcSettingsManager* self,
                                                  gint value);
static gboolean dc_settings_manager_kf_bool (GKeyFile* kf,
                                      const gchar* k,
                                      gboolean d);
VALA_EXTERN void dc_settings_manager_set_markdown_rendering (DcSettingsManager* self,
                                                 gboolean value);
VALA_EXTERN gboolean dc_settings_manager_get_markdown_rendering (DcSettingsManager* self);
VALA_EXTERN void dc_settings_manager_set_shift_enter_sends (DcSettingsManager* self,
                                                gboolean value);
VALA_EXTERN void dc_settings_manager_set_notifications_enabled (DcSettingsManager* self,
                                                    gboolean value);
static gchar* dc_settings_manager_kf_str (GKeyFile* kf,
                                   const gchar* k,
                                   const gchar* d);
VALA_EXTERN void dc_settings_manager_set_rpc_server_path (DcSettingsManager* self,
                                              const gchar* value);
VALA_EXTERN void dc_settings_manager_save_double_click_action (DcSettingsManager* self,
                                                   gint v);
static Block25Data* block25_data_ref (Block25Data* _data25_);
static void block25_data_unref (void * _userdata_);
VALA_EXTERN void dc_settings_manager_save_to_file (DcSettingsManager* self,
                                       DcSettingWriter writer,
                                       gpointer writer_target);
static void __lambda7_ (Block25Data* _data25_,
                 GKeyFile* kf);
static void ___lambda7__dc_setting_writer (GKeyFile* kf,
                                    gpointer self);
VALA_EXTERN void dc_settings_manager_save_markdown_rendering (DcSettingsManager* self,
                                                  gboolean v);
static Block26Data* block26_data_ref (Block26Data* _data26_);
static void block26_data_unref (void * _userdata_);
static void __lambda8_ (Block26Data* _data26_,
                 GKeyFile* kf);
static void ___lambda8__dc_setting_writer (GKeyFile* kf,
                                    gpointer self);
VALA_EXTERN void dc_settings_manager_save_shift_enter_sends (DcSettingsManager* self,
                                                 gboolean v);
static Block27Data* block27_data_ref (Block27Data* _data27_);
static void block27_data_unref (void * _userdata_);
static void __lambda9_ (Block27Data* _data27_,
                 GKeyFile* kf);
static void ___lambda9__dc_setting_writer (GKeyFile* kf,
                                    gpointer self);
VALA_EXTERN void dc_settings_manager_save_notifications_enabled (DcSettingsManager* self,
                                                     gboolean v);
static Block28Data* block28_data_ref (Block28Data* _data28_);
static void block28_data_unref (void * _userdata_);
static void __lambda10_ (Block28Data* _data28_,
                  GKeyFile* kf);
static void ___lambda10__dc_setting_writer (GKeyFile* kf,
                                     gpointer self);
VALA_EXTERN void dc_settings_manager_save_rpc_server_path (DcSettingsManager* self,
                                               const gchar* v);
static Block29Data* block29_data_ref (Block29Data* _data29_);
static void block29_data_unref (void * _userdata_);
static void __lambda11_ (Block29Data* _data29_,
                  GKeyFile* kf);
static void ___lambda11__dc_setting_writer (GKeyFile* kf,
                                     gpointer self);
VALA_EXTERN DcSettingsManager* dc_settings_manager_new (void);
VALA_EXTERN DcSettingsManager* dc_settings_manager_construct (GType object_type);
VALA_EXTERN gint dc_settings_manager_get_double_click_action (DcSettingsManager* self);
VALA_EXTERN gboolean dc_settings_manager_get_shift_enter_sends (DcSettingsManager* self);
VALA_EXTERN gboolean dc_settings_manager_get_notifications_enabled (DcSettingsManager* self);
VALA_EXTERN const gchar* dc_settings_manager_get_rpc_server_path (DcSettingsManager* self);
static void dc_settings_manager_finalize (GObject * obj);
static GType dc_settings_manager_get_type_once (void);
static void _vala_dc_settings_manager_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_dc_settings_manager_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);
VALA_EXTERN GType dc_settings_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsDialog, g_object_unref)
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN DcSettingsDialog* dc_settings_dialog_new (DcWindow* window);
VALA_EXTERN DcSettingsDialog* dc_settings_dialog_construct (GType object_type,
                                                DcWindow* window);
static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
static void __lambda145_ (Block30Data* _data30_);
static void ___lambda145__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda146_ (Block30Data* _data30_);
static void ___lambda146__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda147_ (Block30Data* _data30_);
static void ___lambda147__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda148_ (Block30Data* _data30_);
static void ___lambda148__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda149_ (DcSettingsDialog* self);
static void dc_settings_dialog_on_browse_rpc_server (DcSettingsDialog* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
static void dc_settings_dialog_on_browse_rpc_server_finish (DcSettingsDialog* self,
                                                     GAsyncResult* _res_);
static void ___lambda149__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_settings_dialog_on_rpc_switch_toggled (DcSettingsDialog* self);
static void _dc_settings_dialog_on_rpc_switch_toggled_g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self);
static void dc_settings_dialog_update_rpc_row (DcSettingsDialog* self);
static void dc_settings_dialog_on_reset_settings (DcSettingsDialog* self);
static void _dc_settings_dialog_on_reset_settings_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
VALA_EXTERN gchar* dc_account_finder_find_rpc_server (const gchar* override_path);
VALA_EXTERN void dc_window_show_toast (DcWindow* self,
                           const gchar* message);
static void dc_settings_dialog_on_browse_rpc_server_data_free (gpointer _data);
static gboolean dc_settings_dialog_on_browse_rpc_server_co (DcSettingsDialogOnBrowseRpcServerData* _data_);
static void dc_settings_dialog_on_browse_rpc_server_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        DcVoidFunc on_confirm,
                        gpointer on_confirm_target,
                        GDestroyNotify on_confirm_target_destroy_notify);
static void __lambda150_ (DcSettingsDialog* self);
static void dc_settings_dialog_delete_parla_config (void);
static void ___lambda150__dc_void_func (gpointer self);
static void dc_settings_dialog_finalize (GObject * obj);
static GType dc_settings_dialog_get_type_once (void);
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 inline gpointer
dc_settings_manager_get_instance_private (DcSettingsManager* self)
{
	return G_STRUCT_MEMBER_P (self, DcSettingsManager_private_offset);
}

gchar*
dc_settings_manager_get_config_path (void)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	_tmp0_ = g_get_user_config_dir ();
	_tmp1_ = g_build_filename (_tmp0_, "parla", "settings.ini", NULL);
	result = _tmp1_;
	return result;
}

void
dc_settings_manager_load (DcSettingsManager* self)
{
	GKeyFile* kf = NULL;
	GKeyFile* _tmp0_;
	gboolean _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_key_file_new ();
	kf = _tmp0_;
	{
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = dc_settings_manager_get_config_path ();
		_tmp2_ = _tmp1_;
		g_key_file_load_from_file (kf, _tmp2_, G_KEY_FILE_NONE, &_inner_error0_);
		_g_free0 (_tmp2_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_key_file_unref0 (kf);
		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;
	}
	dc_settings_manager_set_double_click_action (self, dc_settings_manager_kf_int (kf, "double_click_action", 0));
	dc_settings_manager_set_markdown_rendering (self, dc_settings_manager_kf_bool (kf, "markdown_rendering", FALSE));
	_tmp3_ = self->priv->_markdown_rendering;
	dc_markdown_enabled = _tmp3_;
	dc_settings_manager_set_shift_enter_sends (self, dc_settings_manager_kf_bool (kf, "shift_enter_sends", FALSE));
	dc_settings_manager_set_notifications_enabled (self, dc_settings_manager_kf_bool (kf, "notifications_enabled", TRUE));
	_tmp4_ = dc_settings_manager_kf_str (kf, "rpc_server_path", "");
	_tmp5_ = _tmp4_;
	dc_settings_manager_set_rpc_server_path (self, _tmp5_);
	_g_free0 (_tmp5_);
	_g_key_file_unref0 (kf);
}

static gint
dc_settings_manager_kf_int (GKeyFile* kf,
                            const gchar* k,
                            gint d)
{
	gint _tmp1_ = -1;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (kf != NULL, -1);
	g_return_val_if_fail (k != NULL, -1);
	{
		gint _tmp0_ = 0;
		_tmp0_ = g_key_file_get_integer (kf, "General", k, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		result = _tmp0_;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = d;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp1_;
}

static gboolean
dc_settings_manager_kf_bool (GKeyFile* kf,
                             const gchar* k,
                             gboolean d)
{
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (kf != NULL, FALSE);
	g_return_val_if_fail (k != NULL, FALSE);
	{
		gboolean _tmp0_ = FALSE;
		_tmp0_ = g_key_file_get_boolean (kf, "General", k, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		result = _tmp0_;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = d;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp1_;
}

static gchar*
dc_settings_manager_kf_str (GKeyFile* kf,
                            const gchar* k,
                            const gchar* d)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (kf != NULL, NULL);
	g_return_val_if_fail (k != NULL, NULL);
	g_return_val_if_fail (d != NULL, NULL);
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_key_file_get_string (kf, "General", k, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp2_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		gchar* _tmp3_;
		g_clear_error (&_inner_error0_);
		_tmp3_ = g_strdup (d);
		result = _tmp3_;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static Block25Data*
block25_data_ref (Block25Data* _data25_)
{
	g_atomic_int_inc (&_data25_->_ref_count_);
	return _data25_;
}

static void
block25_data_unref (void * _userdata_)
{
	Block25Data* _data25_;
	_data25_ = (Block25Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data25_->_ref_count_)) {
		DcSettingsManager* self;
		self = _data25_->self;
		_g_object_unref0 (self);
		g_slice_free (Block25Data, _data25_);
	}
}

static void
__lambda7_ (Block25Data* _data25_,
            GKeyFile* kf)
{
	DcSettingsManager* self;
	self = _data25_->self;
	g_return_if_fail (kf != NULL);
	g_key_file_set_integer (kf, "General", "double_click_action", _data25_->v);
}

static void
___lambda7__dc_setting_writer (GKeyFile* kf,
                               gpointer self)
{
	__lambda7_ (self, kf);
}

void
dc_settings_manager_save_double_click_action (DcSettingsManager* self,
                                              gint v)
{
	Block25Data* _data25_;
	g_return_if_fail (self != NULL);
	_data25_ = g_slice_new0 (Block25Data);
	_data25_->_ref_count_ = 1;
	_data25_->self = g_object_ref (self);
	_data25_->v = v;
	dc_settings_manager_set_double_click_action (self, _data25_->v);
	dc_settings_manager_save_to_file (self, ___lambda7__dc_setting_writer, _data25_);
	block25_data_unref (_data25_);
	_data25_ = NULL;
}

static Block26Data*
block26_data_ref (Block26Data* _data26_)
{
	g_atomic_int_inc (&_data26_->_ref_count_);
	return _data26_;
}

static void
block26_data_unref (void * _userdata_)
{
	Block26Data* _data26_;
	_data26_ = (Block26Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data26_->_ref_count_)) {
		DcSettingsManager* self;
		self = _data26_->self;
		_g_object_unref0 (self);
		g_slice_free (Block26Data, _data26_);
	}
}

static void
__lambda8_ (Block26Data* _data26_,
            GKeyFile* kf)
{
	DcSettingsManager* self;
	self = _data26_->self;
	g_return_if_fail (kf != NULL);
	g_key_file_set_boolean (kf, "General", "markdown_rendering", _data26_->v);
}

static void
___lambda8__dc_setting_writer (GKeyFile* kf,
                               gpointer self)
{
	__lambda8_ (self, kf);
}

void
dc_settings_manager_save_markdown_rendering (DcSettingsManager* self,
                                             gboolean v)
{
	Block26Data* _data26_;
	g_return_if_fail (self != NULL);
	_data26_ = g_slice_new0 (Block26Data);
	_data26_->_ref_count_ = 1;
	_data26_->self = g_object_ref (self);
	_data26_->v = v;
	dc_settings_manager_set_markdown_rendering (self, _data26_->v);
	dc_markdown_enabled = _data26_->v;
	dc_settings_manager_save_to_file (self, ___lambda8__dc_setting_writer, _data26_);
	block26_data_unref (_data26_);
	_data26_ = NULL;
}

static Block27Data*
block27_data_ref (Block27Data* _data27_)
{
	g_atomic_int_inc (&_data27_->_ref_count_);
	return _data27_;
}

static void
block27_data_unref (void * _userdata_)
{
	Block27Data* _data27_;
	_data27_ = (Block27Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data27_->_ref_count_)) {
		DcSettingsManager* self;
		self = _data27_->self;
		_g_object_unref0 (self);
		g_slice_free (Block27Data, _data27_);
	}
}

static void
__lambda9_ (Block27Data* _data27_,
            GKeyFile* kf)
{
	DcSettingsManager* self;
	self = _data27_->self;
	g_return_if_fail (kf != NULL);
	g_key_file_set_boolean (kf, "General", "shift_enter_sends", _data27_->v);
}

static void
___lambda9__dc_setting_writer (GKeyFile* kf,
                               gpointer self)
{
	__lambda9_ (self, kf);
}

void
dc_settings_manager_save_shift_enter_sends (DcSettingsManager* self,
                                            gboolean v)
{
	Block27Data* _data27_;
	g_return_if_fail (self != NULL);
	_data27_ = g_slice_new0 (Block27Data);
	_data27_->_ref_count_ = 1;
	_data27_->self = g_object_ref (self);
	_data27_->v = v;
	dc_settings_manager_set_shift_enter_sends (self, _data27_->v);
	dc_settings_manager_save_to_file (self, ___lambda9__dc_setting_writer, _data27_);
	block27_data_unref (_data27_);
	_data27_ = NULL;
}

static Block28Data*
block28_data_ref (Block28Data* _data28_)
{
	g_atomic_int_inc (&_data28_->_ref_count_);
	return _data28_;
}

static void
block28_data_unref (void * _userdata_)
{
	Block28Data* _data28_;
	_data28_ = (Block28Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data28_->_ref_count_)) {
		DcSettingsManager* self;
		self = _data28_->self;
		_g_object_unref0 (self);
		g_slice_free (Block28Data, _data28_);
	}
}

static void
__lambda10_ (Block28Data* _data28_,
             GKeyFile* kf)
{
	DcSettingsManager* self;
	self = _data28_->self;
	g_return_if_fail (kf != NULL);
	g_key_file_set_boolean (kf, "General", "notifications_enabled", _data28_->v);
}

static void
___lambda10__dc_setting_writer (GKeyFile* kf,
                                gpointer self)
{
	__lambda10_ (self, kf);
}

void
dc_settings_manager_save_notifications_enabled (DcSettingsManager* self,
                                                gboolean v)
{
	Block28Data* _data28_;
	g_return_if_fail (self != NULL);
	_data28_ = g_slice_new0 (Block28Data);
	_data28_->_ref_count_ = 1;
	_data28_->self = g_object_ref (self);
	_data28_->v = v;
	dc_settings_manager_set_notifications_enabled (self, _data28_->v);
	dc_settings_manager_save_to_file (self, ___lambda10__dc_setting_writer, _data28_);
	block28_data_unref (_data28_);
	_data28_ = NULL;
}

static Block29Data*
block29_data_ref (Block29Data* _data29_)
{
	g_atomic_int_inc (&_data29_->_ref_count_);
	return _data29_;
}

static void
block29_data_unref (void * _userdata_)
{
	Block29Data* _data29_;
	_data29_ = (Block29Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data29_->_ref_count_)) {
		DcSettingsManager* self;
		self = _data29_->self;
		_g_free0 (_data29_->v);
		_g_object_unref0 (self);
		g_slice_free (Block29Data, _data29_);
	}
}

static void
__lambda11_ (Block29Data* _data29_,
             GKeyFile* kf)
{
	DcSettingsManager* self;
	self = _data29_->self;
	g_return_if_fail (kf != NULL);
	g_key_file_set_string (kf, "General", "rpc_server_path", _data29_->v);
}

static void
___lambda11__dc_setting_writer (GKeyFile* kf,
                                gpointer self)
{
	__lambda11_ (self, kf);
}

void
dc_settings_manager_save_rpc_server_path (DcSettingsManager* self,
                                          const gchar* v)
{
	Block29Data* _data29_;
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (v != NULL);
	_data29_ = g_slice_new0 (Block29Data);
	_data29_->_ref_count_ = 1;
	_data29_->self = g_object_ref (self);
	_tmp0_ = g_strdup (v);
	_g_free0 (_data29_->v);
	_data29_->v = _tmp0_;
	dc_settings_manager_set_rpc_server_path (self, _data29_->v);
	dc_settings_manager_save_to_file (self, ___lambda11__dc_setting_writer, _data29_);
	block29_data_unref (_data29_);
	_data29_ = NULL;
}

void
dc_settings_manager_save_to_file (DcSettingsManager* self,
                                  DcSettingWriter writer,
                                  gpointer writer_target)
{
	GKeyFile* kf = NULL;
	GKeyFile* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_key_file_new ();
	kf = _tmp0_;
	{
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = dc_settings_manager_get_config_path ();
		_tmp2_ = _tmp1_;
		g_key_file_load_from_file (kf, _tmp2_, G_KEY_FILE_NONE, &_inner_error0_);
		_g_free0 (_tmp2_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_key_file_unref0 (kf);
		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;
	}
	writer (kf, writer_target);
	{
		gchar* dir = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp3_ = dc_settings_manager_get_config_path ();
		_tmp4_ = _tmp3_;
		_tmp5_ = g_path_get_dirname (_tmp4_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		dir = _tmp6_;
		g_mkdir_with_parents (dir, 0755);
		_tmp7_ = dc_settings_manager_get_config_path ();
		_tmp8_ = _tmp7_;
		g_key_file_save_to_file (kf, _tmp8_, &_inner_error0_);
		_g_free0 (_tmp8_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (dir);
			goto __catch1_g_error;
		}
		_g_free0 (dir);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_warning ("settings_dialog.vala:79: Failed to save settings: %s", _tmp10_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_key_file_unref0 (kf);
		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;
	}
	_g_key_file_unref0 (kf);
}

DcSettingsManager*
dc_settings_manager_construct (GType object_type)
{
	DcSettingsManager * self = NULL;
	self = (DcSettingsManager*) g_object_new (object_type, NULL);
	return self;
}

DcSettingsManager*
dc_settings_manager_new (void)
{
	return dc_settings_manager_construct (DC_TYPE_SETTINGS_MANAGER);
}

gint
dc_settings_manager_get_double_click_action (DcSettingsManager* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_double_click_action;
	return result;
}

void
dc_settings_manager_set_double_click_action (DcSettingsManager* self,
                                             gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_settings_manager_get_double_click_action (self);
	if (old_value != value) {
		self->priv->_double_click_action = value;
		g_object_notify_by_pspec ((GObject *) self, dc_settings_manager_properties[DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY]);
	}
}

gboolean
dc_settings_manager_get_markdown_rendering (DcSettingsManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_markdown_rendering;
	return result;
}

void
dc_settings_manager_set_markdown_rendering (DcSettingsManager* self,
                                            gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_settings_manager_get_markdown_rendering (self);
	if (old_value != value) {
		self->priv->_markdown_rendering = value;
		g_object_notify_by_pspec ((GObject *) self, dc_settings_manager_properties[DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY]);
	}
}

gboolean
dc_settings_manager_get_shift_enter_sends (DcSettingsManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_shift_enter_sends;
	return result;
}

void
dc_settings_manager_set_shift_enter_sends (DcSettingsManager* self,
                                           gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_settings_manager_get_shift_enter_sends (self);
	if (old_value != value) {
		self->priv->_shift_enter_sends = value;
		g_object_notify_by_pspec ((GObject *) self, dc_settings_manager_properties[DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY]);
	}
}

gboolean
dc_settings_manager_get_notifications_enabled (DcSettingsManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_notifications_enabled;
	return result;
}

void
dc_settings_manager_set_notifications_enabled (DcSettingsManager* self,
                                               gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_settings_manager_get_notifications_enabled (self);
	if (old_value != value) {
		self->priv->_notifications_enabled = value;
		g_object_notify_by_pspec ((GObject *) self, dc_settings_manager_properties[DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY]);
	}
}

const gchar*
dc_settings_manager_get_rpc_server_path (DcSettingsManager* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_rpc_server_path;
	result = _tmp0_;
	return result;
}

void
dc_settings_manager_set_rpc_server_path (DcSettingsManager* self,
                                         const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_settings_manager_get_rpc_server_path (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_rpc_server_path);
		self->priv->_rpc_server_path = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_settings_manager_properties[DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY]);
	}
}

static void
dc_settings_manager_class_init (DcSettingsManagerClass * klass,
                                gpointer klass_data)
{
	dc_settings_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcSettingsManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_settings_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_settings_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_settings_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY, dc_settings_manager_properties[DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY] = g_param_spec_int ("double-click-action", "double-click-action", "double-click-action", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY, dc_settings_manager_properties[DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY] = g_param_spec_boolean ("markdown-rendering", "markdown-rendering", "markdown-rendering", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY, dc_settings_manager_properties[DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY] = g_param_spec_boolean ("shift-enter-sends", "shift-enter-sends", "shift-enter-sends", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY, dc_settings_manager_properties[DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY] = g_param_spec_boolean ("notifications-enabled", "notifications-enabled", "notifications-enabled", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY, dc_settings_manager_properties[DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY] = g_param_spec_string ("rpc-server-path", "rpc-server-path", "rpc-server-path", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dc_settings_manager_instance_init (DcSettingsManager * self,
                                   gpointer klass)
{
	gchar* _tmp0_;
	self->priv = dc_settings_manager_get_instance_private (self);
	self->priv->_double_click_action = 0;
	self->priv->_markdown_rendering = FALSE;
	self->priv->_shift_enter_sends = FALSE;
	self->priv->_notifications_enabled = TRUE;
	_tmp0_ = g_strdup ("");
	self->priv->_rpc_server_path = _tmp0_;
}

static void
dc_settings_manager_finalize (GObject * obj)
{
	DcSettingsManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_SETTINGS_MANAGER, DcSettingsManager);
	_g_free0 (self->priv->_rpc_server_path);
	G_OBJECT_CLASS (dc_settings_manager_parent_class)->finalize (obj);
}

static GType
dc_settings_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcSettingsManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_settings_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcSettingsManager), 0, (GInstanceInitFunc) dc_settings_manager_instance_init, NULL };
	GType dc_settings_manager_type_id;
	dc_settings_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "DcSettingsManager", &g_define_type_info, 0);
	DcSettingsManager_private_offset = g_type_add_instance_private (dc_settings_manager_type_id, sizeof (DcSettingsManagerPrivate));
	return dc_settings_manager_type_id;
}

GType
dc_settings_manager_get_type (void)
{
	static volatile gsize dc_settings_manager_type_id__once = 0;
	if (g_once_init_enter (&dc_settings_manager_type_id__once)) {
		GType dc_settings_manager_type_id;
		dc_settings_manager_type_id = dc_settings_manager_get_type_once ();
		g_once_init_leave (&dc_settings_manager_type_id__once, dc_settings_manager_type_id);
	}
	return dc_settings_manager_type_id__once;
}

static void
_vala_dc_settings_manager_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	DcSettingsManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_SETTINGS_MANAGER, DcSettingsManager);
	switch (property_id) {
		case DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY:
		g_value_set_int (value, dc_settings_manager_get_double_click_action (self));
		break;
		case DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY:
		g_value_set_boolean (value, dc_settings_manager_get_markdown_rendering (self));
		break;
		case DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY:
		g_value_set_boolean (value, dc_settings_manager_get_shift_enter_sends (self));
		break;
		case DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY:
		g_value_set_boolean (value, dc_settings_manager_get_notifications_enabled (self));
		break;
		case DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY:
		g_value_set_string (value, dc_settings_manager_get_rpc_server_path (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_settings_manager_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	DcSettingsManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_SETTINGS_MANAGER, DcSettingsManager);
	switch (property_id) {
		case DC_SETTINGS_MANAGER_DOUBLE_CLICK_ACTION_PROPERTY:
		dc_settings_manager_set_double_click_action (self, g_value_get_int (value));
		break;
		case DC_SETTINGS_MANAGER_MARKDOWN_RENDERING_PROPERTY:
		dc_settings_manager_set_markdown_rendering (self, g_value_get_boolean (value));
		break;
		case DC_SETTINGS_MANAGER_SHIFT_ENTER_SENDS_PROPERTY:
		dc_settings_manager_set_shift_enter_sends (self, g_value_get_boolean (value));
		break;
		case DC_SETTINGS_MANAGER_NOTIFICATIONS_ENABLED_PROPERTY:
		dc_settings_manager_set_notifications_enabled (self, g_value_get_boolean (value));
		break;
		case DC_SETTINGS_MANAGER_RPC_SERVER_PATH_PROPERTY:
		dc_settings_manager_set_rpc_server_path (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dc_settings_dialog_get_instance_private (DcSettingsDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcSettingsDialog_private_offset);
}

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		DcSettingsDialog* self;
		self = _data30_->self;
		_g_object_unref0 (_data30_->notif_switch);
		_g_object_unref0 (_data30_->shift_switch);
		_g_object_unref0 (_data30_->md_switch);
		_g_object_unref0 (_data30_->dblclick_combo);
		_g_object_unref0 (self);
		g_slice_free (Block30Data, _data30_);
	}
}

static void
__lambda145_ (Block30Data* _data30_)
{
	DcSettingsDialog* self;
	DcWindow* _tmp0_;
	DcSettingsManager* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	self = _data30_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _tmp0_->settings;
	_tmp2_ = gtk_drop_down_get_selected (_data30_->dblclick_combo);
	_tmp3_ = _tmp2_;
	dc_settings_manager_save_double_click_action (_tmp1_, (gint) _tmp3_);
}

static void
___lambda145__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda145_ (self);
}

static void
__lambda146_ (Block30Data* _data30_)
{
	DcSettingsDialog* self;
	DcWindow* _tmp0_;
	DcSettingsManager* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	self = _data30_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _tmp0_->settings;
	_tmp2_ = gtk_switch_get_active (_data30_->md_switch);
	_tmp3_ = _tmp2_;
	dc_settings_manager_save_markdown_rendering (_tmp1_, _tmp3_);
}

static void
___lambda146__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda146_ (self);
}

static void
__lambda147_ (Block30Data* _data30_)
{
	DcSettingsDialog* self;
	DcWindow* _tmp0_;
	DcSettingsManager* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	self = _data30_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _tmp0_->settings;
	_tmp2_ = gtk_switch_get_active (_data30_->shift_switch);
	_tmp3_ = _tmp2_;
	dc_settings_manager_save_shift_enter_sends (_tmp1_, _tmp3_);
}

static void
___lambda147__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda147_ (self);
}

static void
__lambda148_ (Block30Data* _data30_)
{
	DcSettingsDialog* self;
	DcWindow* _tmp0_;
	DcSettingsManager* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	self = _data30_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _tmp0_->settings;
	_tmp2_ = gtk_switch_get_active (_data30_->notif_switch);
	_tmp3_ = _tmp2_;
	dc_settings_manager_save_notifications_enabled (_tmp1_, _tmp3_);
}

static void
___lambda148__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda148_ (self);
}

static void
__lambda149_ (DcSettingsDialog* self)
{
	dc_settings_dialog_on_browse_rpc_server (self, NULL, NULL);
}

static void
___lambda149__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda149_ ((DcSettingsDialog*) self);
}

static void
_dc_settings_dialog_on_rpc_switch_toggled_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self)
{
	dc_settings_dialog_on_rpc_switch_toggled ((DcSettingsDialog*) self);
}

static void
_dc_settings_dialog_on_reset_settings_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	dc_settings_dialog_on_reset_settings ((DcSettingsDialog*) self);
}

DcSettingsDialog*
dc_settings_dialog_construct (GType object_type,
                              DcWindow* window)
{
	DcSettingsDialog * self = NULL;
	Block30Data* _data30_;
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp1_;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkLabel* behavior_label = NULL;
	GtkLabel* _tmp7_;
	GtkBox* _tmp8_;
	GtkListBox* behavior_list = NULL;
	GtkListBox* _tmp9_;
	AdwActionRow* dblclick_row = NULL;
	AdwActionRow* _tmp10_;
	gchar** dblclick_labels = NULL;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar** _tmp16_;
	gint dblclick_labels_length1;
	gint _dblclick_labels_size_;
	GtkDropDown* _tmp17_;
	DcWindow* _tmp18_;
	DcSettingsManager* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	AdwActionRow* md_row = NULL;
	AdwActionRow* _tmp22_;
	GtkSwitch* _tmp23_;
	AdwActionRow* shift_row = NULL;
	AdwActionRow* _tmp24_;
	GtkSwitch* _tmp25_;
	DcWindow* _tmp26_;
	DcSettingsManager* _tmp27_;
	gboolean _tmp28_;
	gboolean _tmp29_;
	AdwActionRow* notif_row = NULL;
	AdwActionRow* _tmp30_;
	GtkSwitch* _tmp31_;
	DcWindow* _tmp32_;
	DcSettingsManager* _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp35_;
	GtkBox* _tmp36_;
	GtkLabel* advanced_label = NULL;
	GtkLabel* _tmp37_;
	GtkBox* _tmp38_;
	GtkListBox* advanced_list = NULL;
	GtkListBox* _tmp39_;
	AdwActionRow* _tmp40_;
	AdwActionRow* _tmp41_;
	GtkButton* rpc_choose_btn = NULL;
	GtkButton* _tmp42_;
	AdwActionRow* _tmp43_;
	GtkSwitch* _tmp44_;
	GtkSwitch* _tmp45_;
	GtkSwitch* _tmp46_;
	GtkSwitch* _tmp47_;
	DcWindow* _tmp48_;
	DcSettingsManager* _tmp49_;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	gint _tmp52_;
	gint _tmp53_;
	GtkSwitch* _tmp54_;
	GtkSwitch* _tmp55_;
	AdwActionRow* _tmp56_;
	GtkSwitch* _tmp57_;
	AdwActionRow* _tmp58_;
	GtkBox* _tmp59_;
	GtkBox* reset_box = NULL;
	GtkBox* _tmp60_;
	GtkButton* reset_btn = NULL;
	GtkButton* _tmp61_;
	GtkLabel* reset_label = NULL;
	GtkLabel* _tmp62_;
	GtkBox* _tmp63_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp64_;
	GtkBox* _tmp65_;
	g_return_val_if_fail (window != NULL, NULL);
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	self = (DcSettingsDialog*) g_object_new (object_type, NULL);
	_data30_->self = g_object_ref (self);
	self->priv->app_window = window;
	adw_dialog_set_title ((AdwDialog*) self, "Settings");
	adw_dialog_set_content_width ((AdwDialog*) self, 400);
	adw_dialog_set_content_height ((AdwDialog*) self, 480);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp1_);
	header = _tmp1_;
	adw_header_bar_set_show_end_title_buttons (header, TRUE);
	gtk_box_append (box, (GtkWidget*) header);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 16);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->content);
	self->priv->content = _tmp2_;
	_tmp3_ = self->priv->content;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp3_, 16);
	_tmp4_ = self->priv->content;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp4_, 16);
	_tmp5_ = self->priv->content;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp5_, 12);
	_tmp6_ = self->priv->content;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp6_, 16);
	_tmp7_ = (GtkLabel*) gtk_label_new ("Behavior");
	g_object_ref_sink (_tmp7_);
	behavior_label = _tmp7_;
	gtk_widget_add_css_class ((GtkWidget*) behavior_label, "title-3");
	gtk_widget_set_halign ((GtkWidget*) behavior_label, GTK_ALIGN_START);
	_tmp8_ = self->priv->content;
	gtk_box_append (_tmp8_, (GtkWidget*) behavior_label);
	_tmp9_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp9_);
	behavior_list = _tmp9_;
	gtk_list_box_set_selection_mode (behavior_list, GTK_SELECTION_NONE);
	gtk_widget_add_css_class ((GtkWidget*) behavior_list, "boxed-list");
	_tmp10_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp10_);
	dblclick_row = _tmp10_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) dblclick_row, "Double-click on message");
	adw_action_row_set_subtitle (dblclick_row, "Action when a message is double-clicked");
	_tmp11_ = g_strdup ("Reply to message");
	_tmp12_ = g_strdup ("React with ❤️");
	_tmp13_ = g_strdup ("React with 👍");
	_tmp14_ = g_strdup ("Open user profile");
	_tmp15_ = g_strdup ("Do nothing");
	_tmp16_ = g_new0 (gchar*, 5 + 1);
	_tmp16_[0] = _tmp11_;
	_tmp16_[1] = _tmp12_;
	_tmp16_[2] = _tmp13_;
	_tmp16_[3] = _tmp14_;
	_tmp16_[4] = _tmp15_;
	dblclick_labels = _tmp16_;
	dblclick_labels_length1 = 5;
	_dblclick_labels_size_ = dblclick_labels_length1;
	_tmp17_ = (GtkDropDown*) gtk_drop_down_new_from_strings (dblclick_labels);
	g_object_ref_sink (_tmp17_);
	_data30_->dblclick_combo = _tmp17_;
	_tmp18_ = self->priv->app_window;
	_tmp19_ = _tmp18_->settings;
	_tmp20_ = dc_settings_manager_get_double_click_action (_tmp19_);
	_tmp21_ = _tmp20_;
	gtk_drop_down_set_selected (_data30_->dblclick_combo, (guint) _tmp21_);
	gtk_widget_set_valign ((GtkWidget*) _data30_->dblclick_combo, GTK_ALIGN_CENTER);
	g_signal_connect_data ((GObject*) _data30_->dblclick_combo, "notify::selected", (GCallback) ___lambda145__g_object_notify, block30_data_ref (_data30_), (GClosureNotify) block30_data_unref, 0);
	adw_action_row_add_suffix (dblclick_row, (GtkWidget*) _data30_->dblclick_combo);
	adw_action_row_set_activatable_widget (dblclick_row, (GtkWidget*) _data30_->dblclick_combo);
	gtk_list_box_append (behavior_list, (GtkWidget*) dblclick_row);
	_tmp22_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp22_);
	md_row = _tmp22_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) md_row, "Markdown rendering");
	adw_action_row_set_subtitle (md_row, "Format bold, italic, code and headings");
	_tmp23_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp23_);
	_data30_->md_switch = _tmp23_;
	gtk_switch_set_active (_data30_->md_switch, dc_markdown_enabled);
	gtk_widget_set_valign ((GtkWidget*) _data30_->md_switch, GTK_ALIGN_CENTER);
	g_signal_connect_data ((GObject*) _data30_->md_switch, "notify::active", (GCallback) ___lambda146__g_object_notify, block30_data_ref (_data30_), (GClosureNotify) block30_data_unref, 0);
	adw_action_row_add_suffix (md_row, (GtkWidget*) _data30_->md_switch);
	adw_action_row_set_activatable_widget (md_row, (GtkWidget*) _data30_->md_switch);
	gtk_list_box_append (behavior_list, (GtkWidget*) md_row);
	_tmp24_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp24_);
	shift_row = _tmp24_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) shift_row, "Shift+Return sends message");
	adw_action_row_set_subtitle (shift_row, "When on, Return inserts a newline and Shift+Return sends");
	_tmp25_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp25_);
	_data30_->shift_switch = _tmp25_;
	_tmp26_ = self->priv->app_window;
	_tmp27_ = _tmp26_->settings;
	_tmp28_ = dc_settings_manager_get_shift_enter_sends (_tmp27_);
	_tmp29_ = _tmp28_;
	gtk_switch_set_active (_data30_->shift_switch, _tmp29_);
	gtk_widget_set_valign ((GtkWidget*) _data30_->shift_switch, GTK_ALIGN_CENTER);
	g_signal_connect_data ((GObject*) _data30_->shift_switch, "notify::active", (GCallback) ___lambda147__g_object_notify, block30_data_ref (_data30_), (GClosureNotify) block30_data_unref, 0);
	adw_action_row_add_suffix (shift_row, (GtkWidget*) _data30_->shift_switch);
	adw_action_row_set_activatable_widget (shift_row, (GtkWidget*) _data30_->shift_switch);
	gtk_list_box_append (behavior_list, (GtkWidget*) shift_row);
	_tmp30_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp30_);
	notif_row = _tmp30_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) notif_row, "Desktop notifications");
	adw_action_row_set_subtitle (notif_row, "Notify on incoming messages when the window is not focused");
	_tmp31_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp31_);
	_data30_->notif_switch = _tmp31_;
	_tmp32_ = self->priv->app_window;
	_tmp33_ = _tmp32_->settings;
	_tmp34_ = dc_settings_manager_get_notifications_enabled (_tmp33_);
	_tmp35_ = _tmp34_;
	gtk_switch_set_active (_data30_->notif_switch, _tmp35_);
	gtk_widget_set_valign ((GtkWidget*) _data30_->notif_switch, GTK_ALIGN_CENTER);
	g_signal_connect_data ((GObject*) _data30_->notif_switch, "notify::active", (GCallback) ___lambda148__g_object_notify, block30_data_ref (_data30_), (GClosureNotify) block30_data_unref, 0);
	adw_action_row_add_suffix (notif_row, (GtkWidget*) _data30_->notif_switch);
	adw_action_row_set_activatable_widget (notif_row, (GtkWidget*) _data30_->notif_switch);
	gtk_list_box_append (behavior_list, (GtkWidget*) notif_row);
	_tmp36_ = self->priv->content;
	gtk_box_append (_tmp36_, (GtkWidget*) behavior_list);
	_tmp37_ = (GtkLabel*) gtk_label_new ("Advanced");
	g_object_ref_sink (_tmp37_);
	advanced_label = _tmp37_;
	gtk_widget_add_css_class ((GtkWidget*) advanced_label, "title-3");
	gtk_widget_set_halign ((GtkWidget*) advanced_label, GTK_ALIGN_START);
	_tmp38_ = self->priv->content;
	gtk_box_append (_tmp38_, (GtkWidget*) advanced_label);
	_tmp39_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp39_);
	advanced_list = _tmp39_;
	gtk_list_box_set_selection_mode (advanced_list, GTK_SELECTION_NONE);
	gtk_widget_add_css_class ((GtkWidget*) advanced_list, "boxed-list");
	_tmp40_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp40_);
	_g_object_unref0 (self->priv->rpc_row);
	self->priv->rpc_row = _tmp40_;
	_tmp41_ = self->priv->rpc_row;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp41_, "deltachat-rpc-server");
	_tmp42_ = (GtkButton*) gtk_button_new_with_label ("Choose…");
	g_object_ref_sink (_tmp42_);
	rpc_choose_btn = _tmp42_;
	gtk_widget_set_valign ((GtkWidget*) rpc_choose_btn, GTK_ALIGN_CENTER);
	gtk_widget_add_css_class ((GtkWidget*) rpc_choose_btn, "flat");
	gtk_widget_set_tooltip_text ((GtkWidget*) rpc_choose_btn, "Pick a deltachat-rpc-server binary");
	g_signal_connect_object (rpc_choose_btn, "clicked", (GCallback) ___lambda149__gtk_button_clicked, self, 0);
	_tmp43_ = self->priv->rpc_row;
	adw_action_row_add_suffix (_tmp43_, (GtkWidget*) rpc_choose_btn);
	_tmp44_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp44_);
	_g_object_unref0 (self->priv->rpc_custom_switch);
	self->priv->rpc_custom_switch = _tmp44_;
	_tmp45_ = self->priv->rpc_custom_switch;
	gtk_widget_set_valign ((GtkWidget*) _tmp45_, GTK_ALIGN_CENTER);
	_tmp46_ = self->priv->rpc_custom_switch;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp46_, "Use a custom deltachat-rpc-server binary");
	_tmp47_ = self->priv->rpc_custom_switch;
	_tmp48_ = self->priv->app_window;
	_tmp49_ = _tmp48_->settings;
	_tmp50_ = dc_settings_manager_get_rpc_server_path (_tmp49_);
	_tmp51_ = _tmp50_;
	_tmp52_ = strlen (_tmp51_);
	_tmp53_ = _tmp52_;
	gtk_switch_set_active (_tmp47_, _tmp53_ > 0);
	_tmp54_ = self->priv->rpc_custom_switch;
	g_signal_connect_object ((GObject*) _tmp54_, "notify::active", (GCallback) _dc_settings_dialog_on_rpc_switch_toggled_g_object_notify, self, 0);
	_tmp55_ = self->priv->rpc_custom_switch;
	g_object_bind_property_with_closures ((GObject*) _tmp55_, "active", (GObject*) rpc_choose_btn, "sensitive", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp56_ = self->priv->rpc_row;
	_tmp57_ = self->priv->rpc_custom_switch;
	adw_action_row_add_suffix (_tmp56_, (GtkWidget*) _tmp57_);
	_tmp58_ = self->priv->rpc_row;
	gtk_list_box_append (advanced_list, (GtkWidget*) _tmp58_);
	_tmp59_ = self->priv->content;
	gtk_box_append (_tmp59_, (GtkWidget*) advanced_list);
	dc_settings_dialog_update_rpc_row (self);
	_tmp60_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp60_);
	reset_box = _tmp60_;
	gtk_widget_set_margin_top ((GtkWidget*) reset_box, 8);
	_tmp61_ = (GtkButton*) gtk_button_new_with_label ("Factory Reset");
	g_object_ref_sink (_tmp61_);
	reset_btn = _tmp61_;
	gtk_widget_add_css_class ((GtkWidget*) reset_btn, "destructive-action");
	gtk_widget_set_tooltip_text ((GtkWidget*) reset_btn, "Delete all Parla configuration and start fresh");
	g_signal_connect_object (reset_btn, "clicked", (GCallback) _dc_settings_dialog_on_reset_settings_gtk_button_clicked, self, 0);
	gtk_box_append (reset_box, (GtkWidget*) reset_btn);
	_tmp62_ = (GtkLabel*) gtk_label_new ("Remove all settings and close the app");
	g_object_ref_sink (_tmp62_);
	reset_label = _tmp62_;
	gtk_widget_add_css_class ((GtkWidget*) reset_label, "dim-label");
	gtk_widget_set_valign ((GtkWidget*) reset_label, GTK_ALIGN_CENTER);
	gtk_box_append (reset_box, (GtkWidget*) reset_label);
	_tmp63_ = self->priv->content;
	gtk_box_append (_tmp63_, (GtkWidget*) reset_box);
	_tmp64_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp64_);
	scroll = _tmp64_;
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp65_ = self->priv->content;
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) _tmp65_);
	gtk_box_append (box, (GtkWidget*) scroll);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	_g_object_unref0 (scroll);
	_g_object_unref0 (reset_label);
	_g_object_unref0 (reset_btn);
	_g_object_unref0 (reset_box);
	_g_object_unref0 (rpc_choose_btn);
	_g_object_unref0 (advanced_list);
	_g_object_unref0 (advanced_label);
	_g_object_unref0 (notif_row);
	_g_object_unref0 (shift_row);
	_g_object_unref0 (md_row);
	dblclick_labels = (_vala_array_free (dblclick_labels, dblclick_labels_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (dblclick_row);
	_g_object_unref0 (behavior_list);
	_g_object_unref0 (behavior_label);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	block30_data_unref (_data30_);
	_data30_ = NULL;
	return self;
}

DcSettingsDialog*
dc_settings_dialog_new (DcWindow* window)
{
	return dc_settings_dialog_construct (DC_TYPE_SETTINGS_DIALOG, window);
}

static void
dc_settings_dialog_update_rpc_row (DcSettingsDialog* self)
{
	gchar* custom = NULL;
	DcWindow* _tmp0_;
	DcSettingsManager* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _tmp0_->settings;
	_tmp2_ = dc_settings_manager_get_rpc_server_path (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup (_tmp3_);
	custom = _tmp4_;
	_tmp5_ = custom;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ > 0) {
		gboolean ok = FALSE;
		const gchar* _tmp8_;
		const gchar* _tmp9_ = NULL;
		AdwActionRow* _tmp10_;
		AdwActionRow* _tmp11_;
		const gchar* _tmp12_;
		_tmp8_ = custom;
		ok = g_file_test (_tmp8_, G_FILE_TEST_IS_EXECUTABLE);
		if (ok) {
			_tmp9_ = "Custom";
		} else {
			_tmp9_ = "❌ Custom path is not executable";
		}
		_tmp10_ = self->priv->rpc_row;
		adw_action_row_set_subtitle (_tmp10_, _tmp9_);
		_tmp11_ = self->priv->rpc_row;
		_tmp12_ = custom;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp11_, _tmp12_);
	} else {
		gchar* found = NULL;
		gchar* _tmp13_;
		const gchar* _tmp14_ = NULL;
		const gchar* _tmp15_;
		AdwActionRow* _tmp16_;
		const gchar* _tmp17_ = NULL;
		const gchar* _tmp18_;
		AdwActionRow* _tmp19_;
		_tmp13_ = dc_account_finder_find_rpc_server (NULL);
		found = _tmp13_;
		_tmp15_ = found;
		if (_tmp15_ != NULL) {
			_tmp14_ = "Auto-detected";
		} else {
			_tmp14_ = "❌ Not found";
		}
		_tmp16_ = self->priv->rpc_row;
		adw_action_row_set_subtitle (_tmp16_, _tmp14_);
		_tmp18_ = found;
		_tmp17_ = _tmp18_;
		if (_tmp17_ == NULL) {
			_tmp17_ = "No deltachat-rpc-server binary in the default locations";
		}
		_tmp19_ = self->priv->rpc_row;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp19_, _tmp17_);
		_g_free0 (found);
	}
	_g_free0 (custom);
}

static void
dc_settings_dialog_on_rpc_switch_toggled (DcSettingsDialog* self)
{
	GtkSwitch* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc_custom_switch;
	_tmp1_ = gtk_switch_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		dc_settings_dialog_on_browse_rpc_server (self, NULL, NULL);
	} else {
		DcWindow* _tmp3_;
		DcSettingsManager* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp3_ = self->priv->app_window;
		_tmp4_ = _tmp3_->settings;
		_tmp5_ = dc_settings_manager_get_rpc_server_path (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		if (_tmp8_ > 0) {
			DcWindow* _tmp9_;
			DcSettingsManager* _tmp10_;
			DcWindow* _tmp11_;
			_tmp9_ = self->priv->app_window;
			_tmp10_ = _tmp9_->settings;
			dc_settings_manager_save_rpc_server_path (_tmp10_, "");
			_tmp11_ = self->priv->app_window;
			dc_window_show_toast (_tmp11_, "Using auto-detected RPC server. Restart to apply.");
			dc_settings_dialog_update_rpc_row (self);
		}
	}
}

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

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

static void
dc_settings_dialog_on_browse_rpc_server (DcSettingsDialog* self,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	DcSettingsDialogOnBrowseRpcServerData* _data_;
	DcSettingsDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcSettingsDialogOnBrowseRpcServerData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_settings_dialog_on_browse_rpc_server_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_settings_dialog_on_browse_rpc_server_co (_data_);
}

static void
dc_settings_dialog_on_browse_rpc_server_finish (DcSettingsDialog* self,
                                                GAsyncResult* _res_)
{
	DcSettingsDialogOnBrowseRpcServerData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_settings_dialog_on_browse_rpc_server_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	DcSettingsDialogOnBrowseRpcServerData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_settings_dialog_on_browse_rpc_server_co (_data_);
}

static gboolean
dc_settings_dialog_on_browse_rpc_server_co (DcSettingsDialogOnBrowseRpcServerData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_file_dialog_new ();
	_data_->dlg = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->dlg;
	gtk_file_dialog_set_title (_data_->_tmp1_, "Locate deltachat-rpc-server");
	_data_->_tmp2_ = _data_->dlg;
	gtk_file_dialog_set_modal (_data_->_tmp2_, TRUE);
	_data_->_tmp3_ = _data_->self->priv->app_window;
	_data_->_tmp4_ = _data_->_tmp3_->settings;
	_data_->_tmp5_ = dc_settings_manager_get_rpc_server_path (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = g_strdup (_data_->_tmp6_);
	_data_->start = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->start;
	_data_->_tmp9_ = strlen (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	if (_data_->_tmp10_ == 0) {
		_data_->_tmp12_ = dc_account_finder_find_rpc_server (NULL);
		_data_->_tmp11_ = _data_->_tmp12_;
		if (_data_->_tmp11_ == NULL) {
			_data_->_tmp13_ = g_strdup ("");
			_g_free0 (_data_->_tmp11_);
			_data_->_tmp11_ = _data_->_tmp13_;
		}
		_data_->_tmp14_ = _data_->_tmp11_;
		_data_->_tmp11_ = NULL;
		_g_free0 (_data_->start);
		_data_->start = _data_->_tmp14_;
		_g_free0 (_data_->_tmp11_);
	}
	_data_->_tmp15_ = _data_->start;
	_data_->_tmp16_ = strlen (_data_->_tmp15_);
	_data_->_tmp17_ = _data_->_tmp16_;
	if (_data_->_tmp17_ > 0) {
		_data_->_tmp18_ = _data_->dlg;
		_data_->_tmp19_ = _data_->start;
		_data_->_tmp20_ = g_file_new_for_path (_data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		gtk_file_dialog_set_initial_file (_data_->_tmp18_, _data_->_tmp21_);
		_g_object_unref0 (_data_->_tmp21_);
	}
	{
		_data_->_tmp22_ = _data_->dlg;
		_data_->_tmp23_ = _data_->self->priv->app_window;
		_data_->_state_ = 1;
		gtk_file_dialog_open (_data_->_tmp22_, (GtkWindow*) _data_->_tmp23_, NULL, dc_settings_dialog_on_browse_rpc_server_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp24_ = gtk_file_dialog_open_finish (_data_->_tmp22_, _data_->_res_, &_data_->_inner_error0_);
		_data_->file = _data_->_tmp24_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_data_->file != NULL) {
			_data_->_tmp25_ = g_file_get_path (_data_->file);
			_data_->path = _data_->_tmp25_;
			_data_->_tmp27_ = _data_->path;
			if (_data_->_tmp27_ != NULL) {
				_data_->_tmp28_ = _data_->path;
				_data_->_tmp26_ = g_file_test (_data_->_tmp28_, G_FILE_TEST_IS_EXECUTABLE);
			} else {
				_data_->_tmp26_ = FALSE;
			}
			if (_data_->_tmp26_) {
				_data_->_tmp29_ = _data_->self->priv->app_window;
				_data_->_tmp30_ = _data_->_tmp29_->settings;
				_data_->_tmp31_ = _data_->path;
				dc_settings_manager_save_rpc_server_path (_data_->_tmp30_, _data_->_tmp31_);
				_data_->_tmp32_ = _data_->self->priv->app_window;
				dc_window_show_toast (_data_->_tmp32_, "RPC server path saved. Restart to apply.");
			} else {
				_data_->_tmp33_ = _data_->self->priv->app_window;
				dc_show_error ((GtkWidget*) _data_->_tmp33_, "Selected file is not an executable binary.");
			}
			_g_free0 (_data_->path);
		}
		_g_object_unref0 (_data_->file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp35_ = _data_->e;
		if (!(_data_->_tmp35_->domain == GTK_DIALOG_ERROR)) {
			_data_->_tmp36_ = _data_->e;
			_data_->_tmp34_ = !g_error_matches (_data_->_tmp36_, G_IO_ERROR, G_IO_ERROR_CANCELLED);
		} else {
			_data_->_tmp34_ = FALSE;
		}
		if (_data_->_tmp34_) {
			_data_->_tmp37_ = _data_->self->priv->app_window;
			_data_->_tmp38_ = _data_->e;
			_data_->_tmp39_ = _data_->_tmp38_->message;
			dc_show_error ((GtkWidget*) _data_->_tmp37_, _data_->_tmp39_);
		}
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->start);
		_g_object_unref0 (_data_->dlg);
		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_->_tmp40_ = _data_->self->priv->rpc_custom_switch;
	_data_->_tmp41_ = _data_->self->priv->app_window;
	_data_->_tmp42_ = _data_->_tmp41_->settings;
	_data_->_tmp43_ = dc_settings_manager_get_rpc_server_path (_data_->_tmp42_);
	_data_->_tmp44_ = _data_->_tmp43_;
	_data_->_tmp45_ = strlen (_data_->_tmp44_);
	_data_->_tmp46_ = _data_->_tmp45_;
	gtk_switch_set_active (_data_->_tmp40_, _data_->_tmp46_ > 0);
	dc_settings_dialog_update_rpc_row (_data_->self);
	_g_free0 (_data_->start);
	_g_object_unref0 (_data_->dlg);
	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;
}

static void
__lambda150_ (DcSettingsDialog* self)
{
	DcWindow* _tmp0_;
	GtkApplication* _tmp1_;
	GtkApplication* _tmp2_;
	dc_settings_dialog_delete_parla_config ();
	_tmp0_ = self->priv->app_window;
	_tmp1_ = gtk_window_get_application ((GtkWindow*) _tmp0_);
	_tmp2_ = _tmp1_;
	g_application_quit ((GApplication*) _tmp2_);
}

static void
___lambda150__dc_void_func (gpointer self)
{
	__lambda150_ ((DcSettingsDialog*) self);
}

static void
dc_settings_dialog_on_reset_settings (DcSettingsDialog* self)
{
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->app_window;
	dc_confirm_action ((GtkWidget*) _tmp0_, "Factory Reset", "This will delete all Parla configuration files and close the applicati" \
"on. " "Your Delta Chat accounts and messages are not affected.", "reset", "Reset & Close", ___lambda150__dc_void_func, g_object_ref (self), g_object_unref);
}

static void
dc_settings_dialog_delete_parla_config (void)
{
	gchar* dir = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = g_get_user_config_dir ();
	_tmp1_ = g_build_filename (_tmp0_, "parla", NULL);
	dir = _tmp1_;
	_tmp2_ = g_build_filename (dir, "settings.ini", NULL);
	_tmp3_ = _tmp2_;
	g_unlink (_tmp3_);
	_g_free0 (_tmp3_);
	g_rmdir (dir);
	_g_free0 (dir);
}

static void
dc_settings_dialog_class_init (DcSettingsDialogClass * klass,
                               gpointer klass_data)
{
	dc_settings_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcSettingsDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_settings_dialog_finalize;
}

static void
dc_settings_dialog_instance_init (DcSettingsDialog * self,
                                  gpointer klass)
{
	self->priv = dc_settings_dialog_get_instance_private (self);
}

static void
dc_settings_dialog_finalize (GObject * obj)
{
	DcSettingsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_SETTINGS_DIALOG, DcSettingsDialog);
	_g_object_unref0 (self->priv->content);
	_g_object_unref0 (self->priv->rpc_row);
	_g_object_unref0 (self->priv->rpc_custom_switch);
	G_OBJECT_CLASS (dc_settings_dialog_parent_class)->finalize (obj);
}

static GType
dc_settings_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcSettingsDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_settings_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcSettingsDialog), 0, (GInstanceInitFunc) dc_settings_dialog_instance_init, NULL };
	GType dc_settings_dialog_type_id;
	dc_settings_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcSettingsDialog", &g_define_type_info, 0);
	DcSettingsDialog_private_offset = g_type_add_instance_private (dc_settings_dialog_type_id, sizeof (DcSettingsDialogPrivate));
	return dc_settings_dialog_type_id;
}

GType
dc_settings_dialog_get_type (void)
{
	static volatile gsize dc_settings_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_settings_dialog_type_id__once)) {
		GType dc_settings_dialog_type_id;
		dc_settings_dialog_type_id = dc_settings_dialog_get_type_once ();
		g_once_init_leave (&dc_settings_dialog_type_id__once, dc_settings_dialog_type_id);
	}
	return dc_settings_dialog_type_id__once;
}

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);
}

