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

/*
* Copyright (c) 2011-2016 Felipe Escoto (https://github.com/Philip-Scott/Notes-up)
*
* 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 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authored by: Felipe Escoto <felescoto95@hotmail.com>
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gtksourceview/gtksource.h>
#include <granite.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <webkit2/webkit2.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define ENOTES_TYPE_PREFERENCES_DIALOG (enotes_preferences_dialog_get_type ())
#define ENOTES_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PREFERENCES_DIALOG, ENotesPreferencesDialog))
#define ENOTES_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PREFERENCES_DIALOG, ENotesPreferencesDialogClass))
#define ENOTES_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PREFERENCES_DIALOG))
#define ENOTES_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PREFERENCES_DIALOG))
#define ENOTES_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PREFERENCES_DIALOG, ENotesPreferencesDialogClass))

typedef struct _ENotesPreferencesDialog ENotesPreferencesDialog;
typedef struct _ENotesPreferencesDialogClass ENotesPreferencesDialogClass;
typedef struct _ENotesPreferencesDialogPrivate ENotesPreferencesDialogPrivate;
enum  {
	ENOTES_PREFERENCES_DIALOG_0_PROPERTY,
	ENOTES_PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* enotes_preferences_dialog_properties[ENOTES_PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define ENOTES_TYPE_APPLICATION (enotes_application_get_type ())
#define ENOTES_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_APPLICATION, ENotesApplication))
#define ENOTES_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_APPLICATION, ENotesApplicationClass))
#define ENOTES_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_APPLICATION))
#define ENOTES_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_APPLICATION))
#define ENOTES_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_APPLICATION, ENotesApplicationClass))

typedef struct _ENotesApplication ENotesApplication;
typedef struct _ENotesApplicationClass ENotesApplicationClass;

#define ENOTES_TYPE_WINDOW (enotes_window_get_type ())
#define ENOTES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_WINDOW, ENotesWindow))
#define ENOTES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_WINDOW, ENotesWindowClass))
#define ENOTES_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_WINDOW))
#define ENOTES_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_WINDOW))
#define ENOTES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_WINDOW, ENotesWindowClass))

typedef struct _ENotesWindow ENotesWindow;
typedef struct _ENotesWindowClass ENotesWindowClass;
typedef struct _ENotesApplicationPrivate ENotesApplicationPrivate;

#define ENOTES_APPLICATION_TYPE_STATE (enotes_application_state_get_type ())
#define ENOTES_APPLICATION_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationState))
#define ENOTES_APPLICATION_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationStateClass))
#define ENOTES_APPLICATION_IS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_APPLICATION_TYPE_STATE))
#define ENOTES_APPLICATION_IS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_APPLICATION_TYPE_STATE))
#define ENOTES_APPLICATION_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationStateClass))

typedef struct _ENotesApplicationState ENotesApplicationState;
typedef struct _ENotesApplicationStateClass ENotesApplicationStateClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define ENOTES_SERVICES_TYPE_SETTINGS (enotes_services_settings_get_type ())
#define ENOTES_SERVICES_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettings))
#define ENOTES_SERVICES_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettingsClass))
#define ENOTES_SERVICES_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_SERVICES_TYPE_SETTINGS))
#define ENOTES_SERVICES_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_SERVICES_TYPE_SETTINGS))
#define ENOTES_SERVICES_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_SERVICES_TYPE_SETTINGS, ENotesServicesSettingsClass))

typedef struct _ENotesServicesSettings ENotesServicesSettings;
typedef struct _ENotesServicesSettingsClass ENotesServicesSettingsClass;

#define ENOTES_TYPE_VIEW_EDIT_STACK (enotes_view_edit_stack_get_type ())
#define ENOTES_VIEW_EDIT_STACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStack))
#define ENOTES_VIEW_EDIT_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStackClass))
#define ENOTES_IS_VIEW_EDIT_STACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_VIEW_EDIT_STACK))
#define ENOTES_IS_VIEW_EDIT_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_VIEW_EDIT_STACK))
#define ENOTES_VIEW_EDIT_STACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStackClass))

typedef struct _ENotesViewEditStack ENotesViewEditStack;
typedef struct _ENotesViewEditStackClass ENotesViewEditStackClass;

#define ENOTES_TYPE_EDITOR (enotes_editor_get_type ())
#define ENOTES_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_EDITOR, ENotesEditor))
#define ENOTES_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_EDITOR, ENotesEditorClass))
#define ENOTES_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_EDITOR))
#define ENOTES_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_EDITOR))
#define ENOTES_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_EDITOR, ENotesEditorClass))

typedef struct _ENotesEditor ENotesEditor;
typedef struct _ENotesEditorClass ENotesEditorClass;

#define TYPE_DATABASE_TABLE (database_table_get_type ())
#define DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_TABLE, DatabaseTable))
#define DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_TABLE, DatabaseTableClass))
#define IS_DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_TABLE))
#define IS_DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_TABLE))
#define DATABASE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_TABLE, DatabaseTableClass))

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define ENOTES_TYPE_PAGE_TABLE (enotes_page_table_get_type ())
#define ENOTES_PAGE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PAGE_TABLE, ENotesPageTable))
#define ENOTES_PAGE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PAGE_TABLE, ENotesPageTableClass))
#define ENOTES_IS_PAGE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PAGE_TABLE))
#define ENOTES_IS_PAGE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PAGE_TABLE))
#define ENOTES_PAGE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PAGE_TABLE, ENotesPageTableClass))

typedef struct _ENotesPageTable ENotesPageTable;
typedef struct _ENotesPageTableClass ENotesPageTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define ENOTES_TYPE_VIEWER (enotes_viewer_get_type ())
#define ENOTES_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_VIEWER, ENotesViewer))
#define ENOTES_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_VIEWER, ENotesViewerClass))
#define ENOTES_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_VIEWER))
#define ENOTES_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_VIEWER))
#define ENOTES_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_VIEWER, ENotesViewerClass))

typedef struct _ENotesViewer ENotesViewer;
typedef struct _ENotesViewerClass ENotesViewerClass;

#define ENOTES_TYPE_PAGE (enotes_page_get_type ())
#define ENOTES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PAGE, ENotesPage))
#define ENOTES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PAGE, ENotesPageClass))
#define ENOTES_IS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PAGE))
#define ENOTES_IS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PAGE))
#define ENOTES_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PAGE, ENotesPageClass))

typedef struct _ENotesPage ENotesPage;
typedef struct _ENotesPageClass ENotesPageClass;

struct _ENotesPreferencesDialog {
	GtkDialog parent_instance;
	ENotesPreferencesDialogPrivate * priv;
};

struct _ENotesPreferencesDialogClass {
	GtkDialogClass parent_class;
};

struct _ENotesPreferencesDialogPrivate {
	GtkFontButton* font_button;
	GtkSourceStyleSchemeChooserWidget* scheme_box;
	GtkComboBox* stylesheet_box;
	GtkTextView* style_box;
	GtkStack* stack;
	GtkSwitch* indent_switch;
	GtkSwitch* line_numbers_switch;
	GtkSwitch* spellcheck_switch;
};

struct _ENotesApplication {
	GraniteApplication parent_instance;
	ENotesApplicationPrivate * priv;
	gboolean running;
	ENotesApplicationState* state;
};

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

static gint ENotesPreferencesDialog_private_offset;
static gpointer enotes_preferences_dialog_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;
VALA_EXTERN ENotesServicesSettings* enotes_settings;
VALA_EXTERN gchar** enotes_style_loader_STYLES;
VALA_EXTERN gint enotes_style_loader_STYLES_length1;

VALA_EXTERN GType enotes_preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPreferencesDialog, g_object_unref)
VALA_EXTERN ENotesPreferencesDialog* enotes_preferences_dialog_new (void);
VALA_EXTERN ENotesPreferencesDialog* enotes_preferences_dialog_construct (GType object_type);
VALA_EXTERN GType enotes_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplication, g_object_unref)
VALA_EXTERN GType enotes_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesWindow, g_object_unref)
VALA_EXTERN ENotesWindow* enotes_application_get_app_window (ENotesApplication* self);
static void enotes_preferences_dialog_build_ui (ENotesPreferencesDialog* self);
static void enotes_preferences_dialog_connect_signals (ENotesPreferencesDialog* self);
static GtkGrid* enotes_preferences_dialog_editor_grid (ENotesPreferencesDialog* self);
static GtkGrid* enotes_preferences_dialog_viewer_grid (ENotesPreferencesDialog* self);
VALA_EXTERN GType enotes_application_state_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplicationState, g_object_unref)
VALA_EXTERN const gchar* enotes_application_state_get_editor_font (ENotesApplicationState* self);
VALA_EXTERN gboolean enotes_application_state_get_editor_auto_indent (ENotesApplicationState* self);
VALA_EXTERN gboolean enotes_application_state_get_editor_show_line_numbers (ENotesApplicationState* self);
VALA_EXTERN GType enotes_services_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesServicesSettings, g_object_unref)
VALA_EXTERN gboolean enotes_services_settings_get_spellcheck (ENotesServicesSettings* self);
VALA_EXTERN const gchar* enotes_services_settings_get_render_stylesheet (ENotesServicesSettings* self);
static void enotes_preferences_dialog_make_store (ENotesPreferencesDialog* self);
static gboolean __lambda110_ (ENotesPreferencesDialog* self,
                       gboolean state);
VALA_EXTERN void enotes_application_state_set_editor_auto_indent (ENotesApplicationState* self,
                                                      gboolean value);
static gboolean ___lambda110__gtk_switch_state_set (GtkSwitch* _sender,
                                             gboolean state,
                                             gpointer self);
static gboolean __lambda111_ (ENotesPreferencesDialog* self,
                       gboolean state);
VALA_EXTERN void enotes_application_state_set_editor_show_line_numbers (ENotesApplicationState* self,
                                                            gboolean value);
static gboolean ___lambda111__gtk_switch_state_set (GtkSwitch* _sender,
                                             gboolean state,
                                             gpointer self);
static gboolean __lambda112_ (ENotesPreferencesDialog* self,
                       gboolean state);
VALA_EXTERN void enotes_services_settings_set_spellcheck (ENotesServicesSettings* self,
                                              gboolean value);
VALA_EXTERN GType enotes_view_edit_stack_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesViewEditStack, g_object_unref)
VALA_EXTERN ENotesViewEditStack* enotes_view_edit_stack_get_instance (void);
VALA_EXTERN GType enotes_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesEditor, g_object_unref)
VALA_EXTERN ENotesEditor* enotes_view_edit_stack_get_editor (ENotesViewEditStack* self);
VALA_EXTERN void enotes_editor_set_spellcheck (ENotesEditor* self,
                                   gboolean value);
static gboolean ___lambda112__gtk_switch_state_set (GtkSwitch* _sender,
                                             gboolean state,
                                             gpointer self);
static void __lambda113_ (ENotesPreferencesDialog* self);
VALA_EXTERN void enotes_application_state_set_editor_font (ENotesApplicationState* self,
                                               const gchar* value);
static void ___lambda113__gtk_font_button_font_set (GtkFontButton* _sender,
                                             gpointer self);
static void __lambda114_ (ENotesPreferencesDialog* self);
VALA_EXTERN void enotes_application_state_set_editor_scheme (ENotesApplicationState* self,
                                                 const gchar* value);
static void ___lambda114__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda115_ (ENotesPreferencesDialog* self);
static void enotes_preferences_dialog_save_notebook_style (ENotesPreferencesDialog* self,
                                                    gint selected);
static void ___lambda115__gtk_combo_box_changed (GtkComboBox* _sender,
                                          gpointer self);
static void enotes_preferences_dialog_on_response (ENotesPreferencesDialog* self,
                                            GtkDialog* source,
                                            gint response_id);
static void _enotes_preferences_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                                 gint response_id,
                                                                 gpointer self);
VALA_EXTERN gpointer database_table_ref (gpointer instance);
VALA_EXTERN void database_table_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_database_table (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_database_table (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_database_table (const GValue* value);
VALA_EXTERN GType database_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseTable, database_table_unref)
VALA_EXTERN GType enotes_page_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPageTable, database_table_unref)
VALA_EXTERN ENotesPageTable* enotes_page_table_get_instance (void);
VALA_EXTERN void enotes_page_table_clear_cache_on (ENotesPageTable* self,
                                       gint64 id);
VALA_EXTERN void enotes_services_settings_set_render_stylesheet (ENotesServicesSettings* self,
                                                     const gchar* value);
VALA_EXTERN GType enotes_viewer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesViewer, g_object_unref)
VALA_EXTERN ENotesViewer* enotes_view_edit_stack_get_viewer (ENotesViewEditStack* self);
VALA_EXTERN GType enotes_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPage, g_object_unref)
VALA_EXTERN void enotes_viewer_load_css (ENotesViewer* self,
                             ENotesPage* page,
                             gboolean overrride);
VALA_EXTERN void enotes_viewer_reload_page (ENotesViewer* self);
static gint enotes_preferences_dialog_get_notebook_style (ENotesPreferencesDialog* self);
VALA_EXTERN const gchar* enotes_services_settings_get_stylesheet (ENotesServicesSettings* self);
VALA_EXTERN void enotes_services_settings_set_stylesheet (ENotesServicesSettings* self,
                                              const gchar* value);
static void enotes_preferences_dialog_finalize (GObject * obj);
static GType enotes_preferences_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_preferences_dialog_get_instance_private (ENotesPreferencesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesPreferencesDialog_private_offset);
}

ENotesPreferencesDialog*
enotes_preferences_dialog_construct (GType object_type)
{
	ENotesPreferencesDialog * self = NULL;
	ENotesApplication* _tmp0_;
	ENotesWindow* _tmp1_;
	ENotesWindow* _tmp2_;
	self = (ENotesPreferencesDialog*) g_object_new (object_type, NULL);
	_tmp0_ = enotes_app;
	_tmp1_ = enotes_application_get_app_window (_tmp0_);
	_tmp2_ = _tmp1_;
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	enotes_preferences_dialog_build_ui (self);
	enotes_preferences_dialog_connect_signals (self);
	return self;
}

ENotesPreferencesDialog*
enotes_preferences_dialog_new (void)
{
	return enotes_preferences_dialog_construct (ENOTES_TYPE_PREFERENCES_DIALOG);
}

static void
enotes_preferences_dialog_build_ui (ENotesPreferencesDialog* self)
{
	GtkStack* _tmp0_;
	GtkStack* _tmp1_;
	GtkGrid* _tmp2_;
	GtkGrid* _tmp3_;
	GtkStack* _tmp4_;
	GtkGrid* _tmp5_;
	GtkGrid* _tmp6_;
	GtkStack* _tmp7_;
	GtkStackSwitcher* switcher = NULL;
	GtkStackSwitcher* _tmp8_;
	GtkStack* _tmp9_;
	GtkBox* box = NULL;
	GtkBox* _tmp10_;
	GtkStack* _tmp11_;
	GtkBox* _tmp12_;
	g_return_if_fail (self != NULL);
	gtk_container_set_border_width ((GtkContainer*) self, (guint) 12);
	gtk_window_set_title ((GtkWindow*) self, _ ("Preferences"));
	g_object_set ((GtkWindow*) self, "window-position", GTK_WIN_POS_CENTER, NULL);
	gtk_widget_set_size_request ((GtkWidget*) self, 590, 530);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	gtk_window_set_deletable ((GtkWindow*) self, FALSE);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp0_;
	_tmp1_ = self->priv->stack;
	_tmp2_ = enotes_preferences_dialog_editor_grid (self);
	_tmp3_ = _tmp2_;
	gtk_stack_add_titled (_tmp1_, (GtkWidget*) _tmp3_, "editor", _ ("Editor"));
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->stack;
	_tmp5_ = enotes_preferences_dialog_viewer_grid (self);
	_tmp6_ = _tmp5_;
	gtk_stack_add_titled (_tmp4_, (GtkWidget*) _tmp6_, "viewer", _ ("Viewer"));
	_g_object_unref0 (_tmp6_);
	_tmp7_ = self->priv->stack;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp7_, 12);
	_tmp8_ = (GtkStackSwitcher*) gtk_stack_switcher_new ();
	g_object_ref_sink (_tmp8_);
	switcher = _tmp8_;
	_tmp9_ = self->priv->stack;
	gtk_stack_switcher_set_stack (switcher, _tmp9_);
	gtk_widget_set_halign ((GtkWidget*) switcher, GTK_ALIGN_CENTER);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp10_);
	box = _tmp10_;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) switcher);
	_tmp11_ = self->priv->stack;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) _tmp11_);
	_tmp12_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	gtk_container_add ((GtkContainer*) _tmp12_, (GtkWidget*) box);
	gtk_dialog_add_button ((GtkDialog*) self, _ ("_Close"), (gint) GTK_RESPONSE_CLOSE);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (box);
	_g_object_unref0 (switcher);
}

static GtkGrid*
enotes_preferences_dialog_editor_grid (ENotesPreferencesDialog* self)
{
	GtkGrid* grid = NULL;
	GtkGrid* _tmp0_;
	GtkLabel* font_label = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkFontButton* _tmp3_;
	GtkFontButton* _tmp4_;
	GtkFontButton* _tmp5_;
	ENotesApplication* _tmp6_;
	ENotesApplicationState* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	GtkLabel* scheme_label = NULL;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkSourceStyleSchemeChooserWidget* _tmp19_;
	GtkSourceStyleSchemeChooserWidget* _tmp20_;
	GtkStyleContext* _tmp21_;
	GtkScrolledWindow* scheme_box_scroll = NULL;
	GtkScrolledWindow* _tmp22_;
	GtkSourceStyleSchemeChooserWidget* _tmp23_;
	GtkLabel* indent_label = NULL;
	GtkLabel* _tmp24_;
	GtkSwitch* _tmp25_;
	GtkSwitch* _tmp26_;
	ENotesApplication* _tmp27_;
	ENotesApplicationState* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	GtkBox* switch_box = NULL;
	GtkBox* _tmp31_;
	GtkSwitch* _tmp32_;
	GtkLabel* line_numbers_label = NULL;
	GtkLabel* _tmp33_;
	GtkSwitch* _tmp34_;
	GtkSwitch* _tmp35_;
	ENotesApplication* _tmp36_;
	ENotesApplicationState* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	GtkBox* switch_box_ln = NULL;
	GtkBox* _tmp40_;
	GtkSwitch* _tmp41_;
	GtkLabel* spellcheck_label = NULL;
	GtkLabel* _tmp42_;
	GtkSwitch* _tmp43_;
	GtkSwitch* _tmp44_;
	ENotesServicesSettings* _tmp45_;
	gboolean _tmp46_;
	gboolean _tmp47_;
	GtkBox* switch_box_spl = NULL;
	GtkBox* _tmp48_;
	GtkSwitch* _tmp49_;
	GtkGrid* _tmp50_;
	GtkLabel* _tmp51_;
	GtkGrid* _tmp52_;
	GtkFontButton* _tmp53_;
	GtkGrid* _tmp54_;
	GtkGrid* _tmp55_;
	GtkGrid* _tmp56_;
	GtkGrid* _tmp57_;
	GtkGrid* _tmp58_;
	GtkGrid* _tmp59_;
	GtkGrid* _tmp60_;
	GtkGrid* _tmp61_;
	GtkGrid* _tmp62_;
	GtkGrid* _tmp63_;
	GtkGrid* _tmp64_;
	GtkGrid* _tmp65_;
	GtkGrid* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp0_);
	grid = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (_ ("Font:"));
	g_object_ref_sink (_tmp1_);
	font_label = _tmp1_;
	_tmp2_ = font_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_END);
	_tmp3_ = (GtkFontButton*) gtk_font_button_new ();
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->font_button);
	self->priv->font_button = _tmp3_;
	_tmp4_ = self->priv->font_button;
	gtk_font_button_set_use_font (_tmp4_, TRUE);
	_tmp5_ = self->priv->font_button;
	gtk_font_button_set_use_size (_tmp5_, FALSE);
	_tmp6_ = enotes_app;
	_tmp7_ = _tmp6_->state;
	_tmp8_ = enotes_application_state_get_editor_font (_tmp7_);
	_tmp9_ = _tmp8_;
	if (g_strcmp0 (_tmp9_, "") != 0) {
		GtkFontButton* _tmp10_;
		ENotesApplication* _tmp11_;
		ENotesApplicationState* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		_tmp10_ = self->priv->font_button;
		_tmp11_ = enotes_app;
		_tmp12_ = _tmp11_->state;
		_tmp13_ = enotes_application_state_get_editor_font (_tmp12_);
		_tmp14_ = _tmp13_;
		gtk_font_chooser_set_font ((GtkFontChooser*) _tmp10_, _tmp14_);
	}
	_tmp15_ = g_strdup_printf ("<b>%s</b>", _ ("Theme:"));
	_tmp16_ = _tmp15_;
	_tmp17_ = (GtkLabel*) gtk_label_new (_tmp16_);
	g_object_ref_sink (_tmp17_);
	_tmp18_ = _tmp17_;
	_g_free0 (_tmp16_);
	scheme_label = _tmp18_;
	gtk_label_set_use_markup (scheme_label, TRUE);
	gtk_widget_set_halign ((GtkWidget*) scheme_label, GTK_ALIGN_START);
	_tmp19_ = (GtkSourceStyleSchemeChooserWidget*) gtk_source_style_scheme_chooser_widget_new ();
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->scheme_box);
	self->priv->scheme_box = _tmp19_;
	_tmp20_ = self->priv->scheme_box;
	_tmp21_ = gtk_widget_get_style_context ((GtkWidget*) _tmp20_);
	gtk_style_context_add_class (_tmp21_, "frame");
	_tmp22_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp22_);
	scheme_box_scroll = _tmp22_;
	g_object_set ((GtkWidget*) scheme_box_scroll, "expand", TRUE, NULL);
	_tmp23_ = self->priv->scheme_box;
	gtk_container_add ((GtkContainer*) scheme_box_scroll, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkLabel*) gtk_label_new (_ ("Automatic indentation:"));
	g_object_ref_sink (_tmp24_);
	indent_label = _tmp24_;
	gtk_widget_set_halign ((GtkWidget*) indent_label, GTK_ALIGN_END);
	_tmp25_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->indent_switch);
	self->priv->indent_switch = _tmp25_;
	_tmp26_ = self->priv->indent_switch;
	_tmp27_ = enotes_app;
	_tmp28_ = _tmp27_->state;
	_tmp29_ = enotes_application_state_get_editor_auto_indent (_tmp28_);
	_tmp30_ = _tmp29_;
	gtk_switch_set_state (_tmp26_, _tmp30_);
	_tmp31_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp31_);
	switch_box = _tmp31_;
	_tmp32_ = self->priv->indent_switch;
	gtk_container_add ((GtkContainer*) switch_box, (GtkWidget*) _tmp32_);
	_tmp33_ = (GtkLabel*) gtk_label_new (_ ("Show line Numbers:"));
	g_object_ref_sink (_tmp33_);
	line_numbers_label = _tmp33_;
	gtk_widget_set_halign ((GtkWidget*) line_numbers_label, GTK_ALIGN_END);
	_tmp34_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp34_);
	_g_object_unref0 (self->priv->line_numbers_switch);
	self->priv->line_numbers_switch = _tmp34_;
	_tmp35_ = self->priv->line_numbers_switch;
	_tmp36_ = enotes_app;
	_tmp37_ = _tmp36_->state;
	_tmp38_ = enotes_application_state_get_editor_show_line_numbers (_tmp37_);
	_tmp39_ = _tmp38_;
	gtk_switch_set_state (_tmp35_, _tmp39_);
	_tmp40_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp40_);
	switch_box_ln = _tmp40_;
	_tmp41_ = self->priv->line_numbers_switch;
	gtk_container_add ((GtkContainer*) switch_box_ln, (GtkWidget*) _tmp41_);
	_tmp42_ = (GtkLabel*) gtk_label_new (_ ("Spellcheck:"));
	g_object_ref_sink (_tmp42_);
	spellcheck_label = _tmp42_;
	gtk_widget_set_halign ((GtkWidget*) spellcheck_label, GTK_ALIGN_END);
	_tmp43_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp43_);
	_g_object_unref0 (self->priv->spellcheck_switch);
	self->priv->spellcheck_switch = _tmp43_;
	_tmp44_ = self->priv->spellcheck_switch;
	_tmp45_ = enotes_settings;
	_tmp46_ = enotes_services_settings_get_spellcheck (_tmp45_);
	_tmp47_ = _tmp46_;
	gtk_switch_set_state (_tmp44_, _tmp47_);
	_tmp48_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp48_);
	switch_box_spl = _tmp48_;
	_tmp49_ = self->priv->spellcheck_switch;
	gtk_container_add ((GtkContainer*) switch_box_spl, (GtkWidget*) _tmp49_);
	_tmp50_ = grid;
	_tmp51_ = font_label;
	gtk_grid_attach (_tmp50_, (GtkWidget*) _tmp51_, 0, 1, 1, 1);
	_tmp52_ = grid;
	_tmp53_ = self->priv->font_button;
	gtk_grid_attach (_tmp52_, (GtkWidget*) _tmp53_, 1, 1, 1, 1);
	_tmp54_ = grid;
	gtk_grid_attach (_tmp54_, (GtkWidget*) indent_label, 0, 2, 1, 1);
	_tmp55_ = grid;
	gtk_grid_attach (_tmp55_, (GtkWidget*) switch_box, 1, 2, 1, 1);
	_tmp56_ = grid;
	gtk_grid_attach (_tmp56_, (GtkWidget*) line_numbers_label, 0, 3, 1, 1);
	_tmp57_ = grid;
	gtk_grid_attach (_tmp57_, (GtkWidget*) switch_box_ln, 1, 3, 1, 1);
	_tmp58_ = grid;
	gtk_grid_attach (_tmp58_, (GtkWidget*) spellcheck_label, 0, 4, 1, 1);
	_tmp59_ = grid;
	gtk_grid_attach (_tmp59_, (GtkWidget*) switch_box_spl, 1, 4, 1, 1);
	_tmp60_ = grid;
	gtk_grid_attach (_tmp60_, (GtkWidget*) scheme_label, 0, 5, 1, 1);
	_tmp61_ = grid;
	gtk_grid_attach (_tmp61_, (GtkWidget*) scheme_box_scroll, 0, 6, 2, 1);
	_tmp62_ = grid;
	gtk_grid_set_column_homogeneous (_tmp62_, FALSE);
	_tmp63_ = grid;
	gtk_grid_set_row_homogeneous (_tmp63_, FALSE);
	_tmp64_ = grid;
	gtk_grid_set_row_spacing (_tmp64_, 6);
	_tmp65_ = grid;
	gtk_grid_set_column_spacing (_tmp65_, 12);
	result = grid;
	_g_object_unref0 (switch_box_spl);
	_g_object_unref0 (spellcheck_label);
	_g_object_unref0 (switch_box_ln);
	_g_object_unref0 (line_numbers_label);
	_g_object_unref0 (switch_box);
	_g_object_unref0 (indent_label);
	_g_object_unref0 (scheme_box_scroll);
	_g_object_unref0 (scheme_label);
	_g_object_unref0 (font_label);
	return result;
}

static GtkGrid*
enotes_preferences_dialog_viewer_grid (ENotesPreferencesDialog* self)
{
	GtkLabel* title = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkTextView* _tmp4_;
	GtkTextView* _tmp5_;
	GtkTextView* _tmp6_;
	GtkTextView* _tmp7_;
	GtkTextView* _tmp8_;
	GtkTextBuffer* _tmp9_;
	GtkTextBuffer* _tmp10_;
	ENotesServicesSettings* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GtkScrolledWindow* scrolled = NULL;
	GtkScrolledWindow* _tmp14_;
	GtkTextView* _tmp15_;
	GtkLabel* styles_label = NULL;
	GtkLabel* _tmp16_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp17_;
	GtkComboBox* _tmp18_;
	GtkGrid* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup_printf ("<b>%s</b>", _ ("Global style modifications"));
	_tmp1_ = _tmp0_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	title = _tmp3_;
	gtk_label_set_use_markup (title, TRUE);
	gtk_widget_set_halign ((GtkWidget*) title, GTK_ALIGN_START);
	_tmp4_ = (GtkTextView*) gtk_text_view_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->style_box);
	self->priv->style_box = _tmp4_;
	_tmp5_ = self->priv->style_box;
	gtk_text_view_set_wrap_mode (_tmp5_, GTK_WRAP_WORD);
	_tmp6_ = self->priv->style_box;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = self->priv->style_box;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp7_, TRUE);
	_tmp8_ = self->priv->style_box;
	_tmp9_ = gtk_text_view_get_buffer (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = enotes_settings;
	_tmp12_ = enotes_services_settings_get_render_stylesheet (_tmp11_);
	_tmp13_ = _tmp12_;
	g_object_set (_tmp10_, "text", _tmp13_, NULL);
	_tmp14_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp14_);
	scrolled = _tmp14_;
	_tmp15_ = self->priv->style_box;
	gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkLabel*) gtk_label_new (_ ("Stylesheet:"));
	g_object_ref_sink (_tmp16_);
	styles_label = _tmp16_;
	gtk_widget_set_halign ((GtkWidget*) styles_label, GTK_ALIGN_END);
	enotes_preferences_dialog_make_store (self);
	_tmp17_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp17_);
	grid = _tmp17_;
	gtk_grid_set_column_homogeneous (grid, FALSE);
	gtk_grid_set_row_homogeneous (grid, FALSE);
	gtk_grid_set_row_spacing (grid, 8);
	gtk_grid_set_column_spacing (grid, 8);
	gtk_grid_attach (grid, (GtkWidget*) styles_label, 0, 2, 1, 1);
	_tmp18_ = self->priv->stylesheet_box;
	gtk_grid_attach (grid, (GtkWidget*) _tmp18_, 1, 2, 1, 1);
	gtk_grid_attach (grid, (GtkWidget*) title, 0, 0, 2, 1);
	gtk_grid_attach (grid, (GtkWidget*) scrolled, 0, 1, 2, 1);
	result = grid;
	_g_object_unref0 (styles_label);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (title);
	return result;
}

static gboolean
__lambda110_ (ENotesPreferencesDialog* self,
              gboolean state)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	gboolean result;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	enotes_application_state_set_editor_auto_indent (_tmp1_, state);
	result = FALSE;
	return result;
}

static gboolean
___lambda110__gtk_switch_state_set (GtkSwitch* _sender,
                                    gboolean state,
                                    gpointer self)
{
	gboolean result;
	result = __lambda110_ ((ENotesPreferencesDialog*) self, state);
	return result;
}

static gboolean
__lambda111_ (ENotesPreferencesDialog* self,
              gboolean state)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	gboolean result;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	enotes_application_state_set_editor_show_line_numbers (_tmp1_, state);
	result = FALSE;
	return result;
}

static gboolean
___lambda111__gtk_switch_state_set (GtkSwitch* _sender,
                                    gboolean state,
                                    gpointer self)
{
	gboolean result;
	result = __lambda111_ ((ENotesPreferencesDialog*) self, state);
	return result;
}

static gboolean
__lambda112_ (ENotesPreferencesDialog* self,
              gboolean state)
{
	ENotesServicesSettings* _tmp0_;
	ENotesViewEditStack* _tmp1_;
	ENotesViewEditStack* _tmp2_;
	ENotesEditor* _tmp3_;
	ENotesEditor* _tmp4_;
	gboolean result;
	_tmp0_ = enotes_settings;
	enotes_services_settings_set_spellcheck (_tmp0_, state);
	_tmp1_ = enotes_view_edit_stack_get_instance ();
	_tmp2_ = _tmp1_;
	_tmp3_ = enotes_view_edit_stack_get_editor (_tmp2_);
	_tmp4_ = _tmp3_;
	enotes_editor_set_spellcheck (_tmp4_, state);
	_g_object_unref0 (_tmp2_);
	result = FALSE;
	return result;
}

static gboolean
___lambda112__gtk_switch_state_set (GtkSwitch* _sender,
                                    gboolean state,
                                    gpointer self)
{
	gboolean result;
	result = __lambda112_ ((ENotesPreferencesDialog*) self, state);
	return result;
}

static void
__lambda113_ (ENotesPreferencesDialog* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	GtkFontButton* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = self->priv->font_button;
	_tmp3_ = gtk_font_chooser_get_font ((GtkFontChooser*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	enotes_application_state_set_editor_font (_tmp1_, _tmp5_);
	_g_free0 (_tmp5_);
}

static void
___lambda113__gtk_font_button_font_set (GtkFontButton* _sender,
                                        gpointer self)
{
	__lambda113_ ((ENotesPreferencesDialog*) self);
}

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

static void
__lambda114_ (ENotesPreferencesDialog* self)
{
	GtkSourceStyleScheme* scheme = NULL;
	GtkSourceStyleSchemeChooserWidget* _tmp0_;
	GtkSourceStyleScheme* _tmp1_;
	GtkSourceStyleScheme* _tmp2_;
	ENotesApplication* _tmp3_;
	ENotesApplicationState* _tmp4_;
	const gchar* _tmp5_;
	_tmp0_ = self->priv->scheme_box;
	_tmp1_ = gtk_source_style_scheme_chooser_get_style_scheme ((GtkSourceStyleSchemeChooser*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	scheme = _tmp2_;
	_tmp3_ = enotes_app;
	_tmp4_ = _tmp3_->state;
	_tmp5_ = gtk_source_style_scheme_get_id (scheme);
	enotes_application_state_set_editor_scheme (_tmp4_, _tmp5_);
	_g_object_unref0 (scheme);
}

static void
___lambda114__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda114_ ((ENotesPreferencesDialog*) self);
}

static void
__lambda115_ (ENotesPreferencesDialog* self)
{
	GtkComboBox* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	_tmp0_ = self->priv->stylesheet_box;
	_tmp1_ = gtk_combo_box_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	enotes_preferences_dialog_save_notebook_style (self, _tmp2_);
}

static void
___lambda115__gtk_combo_box_changed (GtkComboBox* _sender,
                                     gpointer self)
{
	__lambda115_ ((ENotesPreferencesDialog*) self);
}

static void
_enotes_preferences_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                            gint response_id,
                                                            gpointer self)
{
	enotes_preferences_dialog_on_response ((ENotesPreferencesDialog*) self, _sender, response_id);
}

static void
enotes_preferences_dialog_connect_signals (ENotesPreferencesDialog* self)
{
	GtkSwitch* _tmp0_;
	GtkSwitch* _tmp1_;
	GtkSwitch* _tmp2_;
	GtkFontButton* _tmp3_;
	GtkSourceStyleSchemeChooserWidget* _tmp4_;
	GtkComboBox* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->indent_switch;
	g_signal_connect_object (_tmp0_, "state-set", (GCallback) ___lambda110__gtk_switch_state_set, self, 0);
	_tmp1_ = self->priv->line_numbers_switch;
	g_signal_connect_object (_tmp1_, "state-set", (GCallback) ___lambda111__gtk_switch_state_set, self, 0);
	_tmp2_ = self->priv->spellcheck_switch;
	g_signal_connect_object (_tmp2_, "state-set", (GCallback) ___lambda112__gtk_switch_state_set, self, 0);
	_tmp3_ = self->priv->font_button;
	g_signal_connect_object (_tmp3_, "font-set", (GCallback) ___lambda113__gtk_font_button_font_set, self, 0);
	_tmp4_ = self->priv->scheme_box;
	g_signal_connect_object ((GObject*) _tmp4_, "notify::style-scheme", (GCallback) ___lambda114__g_object_notify, self, 0);
	_tmp5_ = self->priv->stylesheet_box;
	g_signal_connect_object (_tmp5_, "changed", (GCallback) ___lambda115__gtk_combo_box_changed, self, 0);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _enotes_preferences_dialog_on_response_gtk_dialog_response, self, 0);
}

static void
enotes_preferences_dialog_on_response (ENotesPreferencesDialog* self,
                                       GtkDialog* source,
                                       gint response_id)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	switch (response_id) {
		case GTK_RESPONSE_CLOSE:
		{
			ENotesServicesSettings* _tmp0_;
			const gchar* _tmp1_;
			const gchar* _tmp2_;
			GtkTextView* _tmp3_;
			GtkTextBuffer* _tmp4_;
			GtkTextBuffer* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gboolean _tmp9_;
			ENotesServicesSettings* _tmp12_;
			GtkTextView* _tmp13_;
			GtkTextBuffer* _tmp14_;
			GtkTextBuffer* _tmp15_;
			gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			ENotesViewEditStack* _tmp19_;
			ENotesViewEditStack* _tmp20_;
			ENotesViewer* _tmp21_;
			ENotesViewer* _tmp22_;
			ENotesViewEditStack* _tmp23_;
			ENotesViewEditStack* _tmp24_;
			ENotesViewer* _tmp25_;
			ENotesViewer* _tmp26_;
			_tmp0_ = enotes_settings;
			_tmp1_ = enotes_services_settings_get_render_stylesheet (_tmp0_);
			_tmp2_ = _tmp1_;
			_tmp3_ = self->priv->style_box;
			_tmp4_ = gtk_text_view_get_buffer (_tmp3_);
			_tmp5_ = _tmp4_;
			g_object_get (_tmp5_, "text", &_tmp6_, NULL);
			_tmp7_ = _tmp6_;
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strcmp0 (_tmp2_, _tmp8_) != 0;
			_g_free0 (_tmp8_);
			if (_tmp9_) {
				ENotesPageTable* _tmp10_;
				ENotesPageTable* _tmp11_;
				_tmp10_ = enotes_page_table_get_instance ();
				_tmp11_ = _tmp10_;
				enotes_page_table_clear_cache_on (_tmp11_, (gint64) 0);
				_database_table_unref0 (_tmp11_);
			}
			_tmp12_ = enotes_settings;
			_tmp13_ = self->priv->style_box;
			_tmp14_ = gtk_text_view_get_buffer (_tmp13_);
			_tmp15_ = _tmp14_;
			g_object_get (_tmp15_, "text", &_tmp16_, NULL);
			_tmp17_ = _tmp16_;
			_tmp18_ = _tmp17_;
			enotes_services_settings_set_render_stylesheet (_tmp12_, _tmp18_);
			_g_free0 (_tmp18_);
			_tmp19_ = enotes_view_edit_stack_get_instance ();
			_tmp20_ = _tmp19_;
			_tmp21_ = enotes_view_edit_stack_get_viewer (_tmp20_);
			_tmp22_ = _tmp21_;
			enotes_viewer_load_css (_tmp22_, NULL, TRUE);
			_g_object_unref0 (_tmp20_);
			_tmp23_ = enotes_view_edit_stack_get_instance ();
			_tmp24_ = _tmp23_;
			_tmp25_ = enotes_view_edit_stack_get_viewer (_tmp24_);
			_tmp26_ = _tmp25_;
			enotes_viewer_reload_page (_tmp26_);
			_g_object_unref0 (_tmp24_);
			gtk_widget_destroy ((GtkWidget*) self);
			break;
		}
		default:
		break;
	}
}

static void
enotes_preferences_dialog_make_store (ENotesPreferencesDialog* self)
{
	GtkListStore* list_store = NULL;
	GtkListStore* _tmp0_;
	GtkTreeIter iter = {0};
	gchar** _tmp1_;
	gint _tmp1__length1;
	GtkListStore* _tmp11_;
	GtkComboBox* _tmp12_;
	GtkCellRendererText* renderer = NULL;
	GtkCellRendererText* _tmp13_;
	GtkComboBox* _tmp14_;
	GtkComboBox* _tmp15_;
	GtkComboBox* _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT, -1);
	list_store = _tmp0_;
	_tmp1_ = enotes_style_loader_STYLES;
	_tmp1__length1 = enotes_style_loader_STYLES_length1;
	{
		gchar** style_collection = NULL;
		gint style_collection_length1 = 0;
		gint _style_collection_size_ = 0;
		gint style_it = 0;
		style_collection = _tmp1_;
		style_collection_length1 = _tmp1__length1;
		for (style_it = 0; style_it < style_collection_length1; style_it = style_it + 1) {
			gchar* _tmp2_;
			gchar* style = NULL;
			_tmp2_ = g_strdup (style_collection[style_it]);
			style = _tmp2_;
			{
				const gchar* _tmp3_;
				gchar** _tmp4_;
				gint _tmp4__length1;
				const gchar* _tmp5_;
				GtkListStore* _tmp6_;
				GtkTreeIter _tmp7_ = {0};
				GtkListStore* _tmp8_;
				GtkTreeIter _tmp9_;
				const gchar* _tmp10_;
				_tmp3_ = style;
				_tmp4_ = enotes_style_loader_STYLES;
				_tmp4__length1 = enotes_style_loader_STYLES_length1;
				_tmp5_ = _tmp4_[0];
				if (g_strcmp0 (_tmp3_, _tmp5_) == 0) {
					_g_free0 (style);
					continue;
				}
				_tmp6_ = list_store;
				gtk_list_store_append (_tmp6_, &_tmp7_);
				iter = _tmp7_;
				_tmp8_ = list_store;
				_tmp9_ = iter;
				_tmp10_ = style;
				gtk_list_store_set (_tmp8_, &_tmp9_, 0, _tmp10_, -1);
				_g_free0 (style);
			}
		}
	}
	_tmp11_ = list_store;
	_tmp12_ = (GtkComboBox*) gtk_combo_box_new_with_model ((GtkTreeModel*) _tmp11_);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->stylesheet_box);
	self->priv->stylesheet_box = _tmp12_;
	_tmp13_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp13_);
	renderer = _tmp13_;
	_tmp14_ = self->priv->stylesheet_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp14_, (GtkCellRenderer*) renderer, TRUE);
	_tmp15_ = self->priv->stylesheet_box;
	gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp15_, (GtkCellRenderer*) renderer, "text", 0);
	_tmp16_ = self->priv->stylesheet_box;
	gtk_combo_box_set_active (_tmp16_, enotes_preferences_dialog_get_notebook_style (self));
	_g_object_unref0 (renderer);
	_g_object_unref0 (list_store);
}

static gint
enotes_preferences_dialog_get_notebook_style (ENotesPreferencesDialog* self)
{
	gint active = 0;
	gchar* value = NULL;
	ENotesServicesSettings* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	active = -1;
	_tmp0_ = enotes_settings;
	_tmp1_ = enotes_services_settings_get_stylesheet (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	value = _tmp3_;
	_tmp4_ = enotes_style_loader_STYLES;
	_tmp4__length1 = enotes_style_loader_STYLES_length1;
	{
		gchar** style_collection = NULL;
		gint style_collection_length1 = 0;
		gint _style_collection_size_ = 0;
		gint style_it = 0;
		style_collection = _tmp4_;
		style_collection_length1 = _tmp4__length1;
		for (style_it = 0; style_it < style_collection_length1; style_it = style_it + 1) {
			gchar* _tmp5_;
			gchar* style = NULL;
			_tmp5_ = g_strdup (style_collection[style_it]);
			style = _tmp5_;
			{
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				gint _tmp8_;
				_tmp6_ = value;
				_tmp7_ = style;
				if (g_strcmp0 (_tmp6_, _tmp7_) == 0) {
					result = active;
					_g_free0 (style);
					_g_free0 (value);
					return result;
				}
				_tmp8_ = active;
				active = _tmp8_ + 1;
				_g_free0 (style);
			}
		}
	}
	result = 0;
	_g_free0 (value);
	return result;
}

static void
enotes_preferences_dialog_save_notebook_style (ENotesPreferencesDialog* self,
                                               gint selected)
{
	ENotesPageTable* _tmp0_;
	ENotesPageTable* _tmp1_;
	ENotesServicesSettings* _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	const gchar* _tmp4_;
	ENotesViewEditStack* _tmp5_;
	ENotesViewEditStack* _tmp6_;
	ENotesViewer* _tmp7_;
	ENotesViewer* _tmp8_;
	ENotesViewEditStack* _tmp9_;
	ENotesViewEditStack* _tmp10_;
	ENotesViewer* _tmp11_;
	ENotesViewer* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_page_table_get_instance ();
	_tmp1_ = _tmp0_;
	enotes_page_table_clear_cache_on (_tmp1_, (gint64) 0);
	_database_table_unref0 (_tmp1_);
	_tmp2_ = enotes_settings;
	_tmp3_ = enotes_style_loader_STYLES;
	_tmp3__length1 = enotes_style_loader_STYLES_length1;
	_tmp4_ = _tmp3_[selected + 1];
	enotes_services_settings_set_stylesheet (_tmp2_, _tmp4_);
	_tmp5_ = enotes_view_edit_stack_get_instance ();
	_tmp6_ = _tmp5_;
	_tmp7_ = enotes_view_edit_stack_get_viewer (_tmp6_);
	_tmp8_ = _tmp7_;
	enotes_viewer_load_css (_tmp8_, NULL, TRUE);
	_g_object_unref0 (_tmp6_);
	_tmp9_ = enotes_view_edit_stack_get_instance ();
	_tmp10_ = _tmp9_;
	_tmp11_ = enotes_view_edit_stack_get_viewer (_tmp10_);
	_tmp12_ = _tmp11_;
	enotes_viewer_reload_page (_tmp12_);
	_g_object_unref0 (_tmp10_);
}

static void
enotes_preferences_dialog_class_init (ENotesPreferencesDialogClass * klass,
                                      gpointer klass_data)
{
	enotes_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesPreferencesDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = enotes_preferences_dialog_finalize;
}

static void
enotes_preferences_dialog_instance_init (ENotesPreferencesDialog * self,
                                         gpointer klass)
{
	self->priv = enotes_preferences_dialog_get_instance_private (self);
}

static void
enotes_preferences_dialog_finalize (GObject * obj)
{
	ENotesPreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_PREFERENCES_DIALOG, ENotesPreferencesDialog);
	_g_object_unref0 (self->priv->font_button);
	_g_object_unref0 (self->priv->scheme_box);
	_g_object_unref0 (self->priv->stylesheet_box);
	_g_object_unref0 (self->priv->style_box);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->indent_switch);
	_g_object_unref0 (self->priv->line_numbers_switch);
	_g_object_unref0 (self->priv->spellcheck_switch);
	G_OBJECT_CLASS (enotes_preferences_dialog_parent_class)->finalize (obj);
}

static GType
enotes_preferences_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesPreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesPreferencesDialog), 0, (GInstanceInitFunc) enotes_preferences_dialog_instance_init, NULL };
	GType enotes_preferences_dialog_type_id;
	enotes_preferences_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "ENotesPreferencesDialog", &g_define_type_info, 0);
	ENotesPreferencesDialog_private_offset = g_type_add_instance_private (enotes_preferences_dialog_type_id, sizeof (ENotesPreferencesDialogPrivate));
	return enotes_preferences_dialog_type_id;
}

GType
enotes_preferences_dialog_get_type (void)
{
	static volatile gsize enotes_preferences_dialog_type_id__once = 0;
	if (g_once_init_enter (&enotes_preferences_dialog_type_id__once)) {
		GType enotes_preferences_dialog_type_id;
		enotes_preferences_dialog_type_id = enotes_preferences_dialog_get_type_once ();
		g_once_init_leave (&enotes_preferences_dialog_type_id__once, enotes_preferences_dialog_type_id);
	}
	return enotes_preferences_dialog_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

