/* Editor.c generated by valac 0.56.19, the Vala compiler
 * generated from Editor.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 <gtkspell/gtkspell.h>
#include <glib.h>
#include <granite.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <pango/pango.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_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;
typedef struct _ENotesEditorPrivate ENotesEditorPrivate;

#define ENOTES_TYPE_TOOLBAR_BUTTON (enotes_toolbar_button_get_type ())
#define ENOTES_TOOLBAR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TOOLBAR_BUTTON, ENotesToolbarButton))
#define ENOTES_TOOLBAR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TOOLBAR_BUTTON, ENotesToolbarButtonClass))
#define ENOTES_IS_TOOLBAR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TOOLBAR_BUTTON))
#define ENOTES_IS_TOOLBAR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TOOLBAR_BUTTON))
#define ENOTES_TOOLBAR_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TOOLBAR_BUTTON, ENotesToolbarButtonClass))

typedef struct _ENotesToolbarButton ENotesToolbarButton;
typedef struct _ENotesToolbarButtonClass ENotesToolbarButtonClass;

#define ENOTES_TYPE_HELP_BOX (enotes_help_box_get_type ())
#define ENOTES_HELP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_HELP_BOX, ENotesHelpBox))
#define ENOTES_HELP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_HELP_BOX, ENotesHelpBoxClass))
#define ENOTES_IS_HELP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_HELP_BOX))
#define ENOTES_IS_HELP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_HELP_BOX))
#define ENOTES_HELP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_HELP_BOX, ENotesHelpBoxClass))

typedef struct _ENotesHelpBox ENotesHelpBox;
typedef struct _ENotesHelpBoxClass ENotesHelpBoxClass;
enum  {
	ENOTES_EDITOR_0_PROPERTY,
	ENOTES_EDITOR_SPELLCHECK_PROPERTY,
	ENOTES_EDITOR_NUM_PROPERTIES
};
static GParamSpec* enotes_editor_properties[ENOTES_EDITOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_WORD_WRAPPER (word_wrapper_get_type ())
#define WORD_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WORD_WRAPPER, WordWrapper))
#define WORD_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WORD_WRAPPER, WordWrapperClass))
#define IS_WORD_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WORD_WRAPPER))
#define IS_WORD_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WORD_WRAPPER))
#define WORD_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WORD_WRAPPER, WordWrapperClass))

typedef struct _WordWrapper WordWrapper;
typedef struct _WordWrapperClass WordWrapperClass;

#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_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;
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 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;
typedef struct _Block2Data Block2Data;
#define _g_free0(var) (var = (g_free (var), NULL))

#define ENOTES_TYPE_PLUGIN_MANAGER (enotes_plugin_manager_get_type ())
#define ENOTES_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PLUGIN_MANAGER, ENotesPluginManager))
#define ENOTES_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PLUGIN_MANAGER, ENotesPluginManagerClass))
#define ENOTES_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PLUGIN_MANAGER))
#define ENOTES_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PLUGIN_MANAGER))
#define ENOTES_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PLUGIN_MANAGER, ENotesPluginManagerClass))

typedef struct _ENotesPluginManager ENotesPluginManager;
typedef struct _ENotesPluginManagerClass ENotesPluginManagerClass;

#define ENOTES_TYPE_PLUGIN (enotes_plugin_get_type ())
#define ENOTES_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PLUGIN, ENotesPlugin))
#define ENOTES_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PLUGIN, ENotesPluginClass))
#define ENOTES_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PLUGIN))
#define ENOTES_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PLUGIN))
#define ENOTES_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PLUGIN, ENotesPluginClass))

typedef struct _ENotesPlugin ENotesPlugin;
typedef struct _ENotesPluginClass ENotesPluginClass;
typedef struct _ENotesPagePrivate ENotesPagePrivate;
#define __vala_PangoFontDescription_free0(var) ((var == NULL) ? NULL : (var = (_vala_PangoFontDescription_free (var), NULL)))

#define ENOTES_TYPE_TRASH (enotes_trash_get_type ())
#define ENOTES_TRASH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TRASH, ENotesTrash))
#define ENOTES_TRASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TRASH, ENotesTrashClass))
#define ENOTES_IS_TRASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TRASH))
#define ENOTES_IS_TRASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TRASH))
#define ENOTES_TRASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TRASH, ENotesTrashClass))

typedef struct _ENotesTrash ENotesTrash;
typedef struct _ENotesTrashClass ENotesTrashClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _ENotesEditor {
	GtkBox parent_instance;
	ENotesEditorPrivate * priv;
	ENotesToolbarButton* bold_button;
	ENotesToolbarButton* italics_button;
	ENotesToolbarButton* strike_button;
};

struct _ENotesEditorClass {
	GtkBoxClass parent_class;
};

struct _ENotesEditorPrivate {
	GtkSourceView* code_view;
	GtkSourceBuffer* code_buffer;
	GtkBox* editor_and_help;
	ENotesHelpBox* help;
	GtkSpellChecker* spell;
	gboolean edited;
	GtkSourceSearchContext* search_context;
	GtkSourceSearchSettings* search_settings;
	guint text_change_timeout;
};

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

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

struct _Block2Data {
	int _ref_count_;
	ENotesEditor* self;
	GtkToggleButton* help_button;
};

struct _ENotesPage {
	GObject parent_instance;
	ENotesPagePrivate * priv;
	gint64 id;
	gint64 notebook_id;
	gchar* name;
	gchar* data;
	gchar* subtitle;
	gchar* html_cache;
	gint64 creation_date;
	gint64 modification_date;
	gboolean new_page;
	gboolean cache_changed;
	gchar* full_path;
};

struct _ENotesPageClass {
	GObjectClass parent_class;
};

static gint ENotesEditor_private_offset;
static gpointer enotes_editor_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;

VALA_EXTERN GType enotes_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesEditor, g_object_unref)
VALA_EXTERN GType enotes_toolbar_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesToolbarButton, g_object_unref)
VALA_EXTERN GType enotes_help_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesHelpBox, g_object_unref)
VALA_EXTERN ENotesEditor* enotes_editor_new (void);
VALA_EXTERN ENotesEditor* enotes_editor_construct (GType object_type);
static void enotes_editor_build_ui (ENotesEditor* self);
VALA_EXTERN void enotes_editor_reset (ENotesEditor* self,
                          gboolean disable_save);
static gboolean __lambda51_ (ENotesEditor* self);
VALA_EXTERN void enotes_editor_save_file (ENotesEditor* self);
static gboolean ___lambda51__gsource_func (gpointer self);
VALA_EXTERN WordWrapper* word_wrapper_new (void);
VALA_EXTERN WordWrapper* word_wrapper_construct (GType object_type);
VALA_EXTERN GType word_wrapper_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WordWrapper, g_object_unref)
static void enotes_editor_trigger_changed (ENotesEditor* self);
static void _enotes_editor_trigger_changed_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                             gpointer self);
static void enotes_editor_show_line_numbers (ENotesEditor* self,
                                      gboolean show);
VALA_EXTERN GType enotes_services_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesServicesSettings, g_object_unref)
VALA_EXTERN ENotesServicesSettings* enotes_services_settings_get_instance (void);
VALA_EXTERN gboolean enotes_services_settings_get_spellcheck (ENotesServicesSettings* self);
VALA_EXTERN void enotes_editor_set_spellcheck (ENotesEditor* self,
                                   gboolean value);
static void __lambda41_ (ENotesEditor* self);
VALA_EXTERN void enotes_services_settings_set_spellcheck_language (ENotesServicesSettings* self,
                                                       const gchar* value);
static void ___lambda41__gtk_spell_checker_language_changed (GtkSpellChecker* _sender,
                                                      const gchar* new_lang,
                                                      gpointer self);
static GtkBox* enotes_editor_build_toolbar (ENotesEditor* self);
VALA_EXTERN GType enotes_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplication, g_object_unref)
VALA_EXTERN GType enotes_application_state_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplicationState, g_object_unref)
static void __lambda44_ (ENotesEditor* self);
VALA_EXTERN GType enotes_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPage, g_object_unref)
VALA_EXTERN ENotesPage* enotes_application_state_get_opened_page (ENotesApplicationState* self);
static void enotes_editor_set_current_page (ENotesEditor* self,
                                     ENotesPage* value);
static void ___lambda44__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda45_ (ENotesEditor* self);
static void ___lambda45__enotes_application_state_request_saving_page_info (ENotesApplicationState* _sender,
                                                                     gpointer self);
static void __lambda46_ (ENotesEditor* self);
static void enotes_editor_set_font (ENotesEditor* self,
                             const gchar* name);
VALA_EXTERN const gchar* enotes_application_state_get_editor_font (ENotesApplicationState* self);
static void ___lambda46__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda47_ (ENotesEditor* self);
static void enotes_editor_set_scheme (ENotesEditor* self,
                               const gchar* id);
VALA_EXTERN const gchar* enotes_application_state_get_editor_scheme (ENotesApplicationState* self);
static void ___lambda47__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda48_ (ENotesEditor* self);
VALA_EXTERN gboolean enotes_application_state_get_editor_show_line_numbers (ENotesApplicationState* self);
static void ___lambda48__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda49_ (ENotesEditor* self);
VALA_EXTERN gboolean enotes_application_state_get_editor_auto_indent (ENotesApplicationState* self);
static void ___lambda49__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda50_ (ENotesEditor* self);
VALA_EXTERN const gchar* enotes_application_state_get_search_field (ENotesApplicationState* self);
static void ___lambda50__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_new (const gchar* icon,
                                                const gchar* first_half,
                                                const gchar* second_half,
                                                const gchar* description,
                                                GtkSourceBuffer* code_buffer);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_construct (GType object_type,
                                                      const gchar* icon,
                                                      const gchar* first_half,
                                                      const gchar* second_half,
                                                      const gchar* description,
                                                      GtkSourceBuffer* code_buffer);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_new_is_image_button (const gchar* icon,
                                                                const gchar* first_half,
                                                                const gchar* second_half,
                                                                const gchar* description,
                                                                GtkSourceBuffer* code_buffer);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_construct_is_image_button (GType object_type,
                                                                      const gchar* icon,
                                                                      const gchar* first_half,
                                                                      const gchar* second_half,
                                                                      const gchar* description,
                                                                      GtkSourceBuffer* code_buffer);
VALA_EXTERN GType enotes_plugin_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPluginManager, g_object_unref)
VALA_EXTERN ENotesPluginManager* enotes_plugin_manager_get_instance (void);
VALA_EXTERN GType enotes_plugin_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPlugin, g_object_unref)
VALA_EXTERN ENotesPlugin** enotes_plugin_manager_get_plugs (ENotesPluginManager* self,
                                                gint* result_length1);
VALA_EXTERN GtkWidget* enotes_plugin_editor_button (ENotesPlugin* self);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_new_from_plugin (ENotesPlugin* plugin,
                                                            GtkWidget* widget,
                                                            GtkSourceBuffer* code_buffer);
VALA_EXTERN ENotesToolbarButton* enotes_toolbar_button_construct_from_plugin (GType object_type,
                                                                  ENotesPlugin* plugin,
                                                                  GtkWidget* widget,
                                                                  GtkSourceBuffer* code_buffer);
static void __lambda42_ (Block2Data* _data2_);
VALA_EXTERN ENotesHelpBox* enotes_help_box_new (void);
VALA_EXTERN ENotesHelpBox* enotes_help_box_construct (GType object_type);
static void ___lambda43_ (ENotesEditor* self,
                   const gchar* text);
static void ____lambda43__enotes_help_box_insert_requested (ENotesHelpBox* _sender,
                                                     const gchar* text,
                                                     gpointer self);
static void ___lambda42__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                             gpointer self);
VALA_EXTERN gchar* enotes_editor_get_text (ENotesEditor* self);
VALA_EXTERN void enotes_application_state_save_opened_page (ENotesApplicationState* self);
VALA_EXTERN void enotes_editor_give_focus (ENotesEditor* self);
static void _vala_PangoFontDescription_free (PangoFontDescription* self);
static gboolean __lambda40_ (ENotesEditor* self);
static gboolean ___lambda40__gsource_func (gpointer self);
VALA_EXTERN GType enotes_trash_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTrash, g_object_unref)
VALA_EXTERN ENotesTrash* enotes_trash_get_instance (void);
VALA_EXTERN gboolean enotes_trash_is_page_trashed (ENotesTrash* self,
                                       ENotesPage* to_check);
VALA_EXTERN const gchar* enotes_services_settings_get_spellcheck_language (ENotesServicesSettings* self);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
static void enotes_editor_finalize (GObject * obj);
static GType enotes_editor_get_type_once (void);
static void _vala_enotes_editor_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_editor_get_instance_private (ENotesEditor* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesEditor_private_offset);
}

static gboolean
__lambda51_ (ENotesEditor* self)
{
	gboolean result;
	enotes_editor_save_file (self);
	result = TRUE;
	return result;
}

static gboolean
___lambda51__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda51_ ((ENotesEditor*) self);
	return result;
}

ENotesEditor*
enotes_editor_construct (GType object_type)
{
	ENotesEditor * self = NULL;
	WordWrapper* _tmp0_;
	WordWrapper* _tmp1_;
	GtkSourceSearchSettings* _tmp2_;
	GtkSourceSearchSettings* _tmp3_;
	GtkSourceSearchSettings* _tmp4_;
	GtkSourceBuffer* _tmp5_;
	GtkSourceSearchSettings* _tmp6_;
	GtkSourceSearchContext* _tmp7_;
	self = (ENotesEditor*) g_object_new (object_type, NULL);
	enotes_editor_build_ui (self);
	enotes_editor_reset (self, FALSE);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 60000, ___lambda51__gsource_func, g_object_ref (self), g_object_unref);
	_tmp0_ = word_wrapper_new ();
	_tmp1_ = _tmp0_;
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gtk_source_search_settings_new ();
	_g_object_unref0 (self->priv->search_settings);
	self->priv->search_settings = _tmp2_;
	_tmp3_ = self->priv->search_settings;
	gtk_source_search_settings_set_case_sensitive (_tmp3_, FALSE);
	_tmp4_ = self->priv->search_settings;
	gtk_source_search_settings_set_regex_enabled (_tmp4_, FALSE);
	_tmp5_ = self->priv->code_buffer;
	_tmp6_ = self->priv->search_settings;
	_tmp7_ = gtk_source_search_context_new (_tmp5_, _tmp6_);
	_g_object_unref0 (self->priv->search_context);
	self->priv->search_context = _tmp7_;
	return self;
}

ENotesEditor*
enotes_editor_new (void)
{
	return enotes_editor_construct (ENOTES_TYPE_EDITOR);
}

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

static void
_enotes_editor_trigger_changed_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                        gpointer self)
{
	enotes_editor_trigger_changed ((ENotesEditor*) self);
}

static void
__lambda41_ (ENotesEditor* self)
{
	ENotesServicesSettings* _tmp0_;
	ENotesServicesSettings* _tmp1_;
	GtkSpellChecker* _tmp2_;
	const gchar* _tmp3_;
	_tmp0_ = enotes_services_settings_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->spell;
	_tmp3_ = gtk_spell_checker_get_language (_tmp2_);
	enotes_services_settings_set_spellcheck_language (_tmp1_, _tmp3_);
	_g_object_unref0 (_tmp1_);
}

static void
___lambda41__gtk_spell_checker_language_changed (GtkSpellChecker* _sender,
                                                 const gchar* new_lang,
                                                 gpointer self)
{
	__lambda41_ ((ENotesEditor*) self);
}

static void
__lambda44_ (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesPage* _tmp2_;
	ENotesPage* _tmp3_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_page (_tmp1_);
	_tmp3_ = _tmp2_;
	enotes_editor_set_current_page (self, _tmp3_);
}

static void
___lambda44__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda44_ ((ENotesEditor*) self);
}

static void
__lambda45_ (ENotesEditor* self)
{
	enotes_editor_save_file (self);
}

static void
___lambda45__enotes_application_state_request_saving_page_info (ENotesApplicationState* _sender,
                                                                gpointer self)
{
	__lambda45_ ((ENotesEditor*) self);
}

static void
__lambda46_ (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_editor_font (_tmp1_);
	_tmp3_ = _tmp2_;
	enotes_editor_set_font (self, _tmp3_);
}

static void
___lambda46__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda46_ ((ENotesEditor*) self);
}

static void
__lambda47_ (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_editor_scheme (_tmp1_);
	_tmp3_ = _tmp2_;
	enotes_editor_set_scheme (self, _tmp3_);
}

static void
___lambda47__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda47_ ((ENotesEditor*) self);
}

static void
__lambda48_ (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_editor_show_line_numbers (_tmp1_);
	_tmp3_ = _tmp2_;
	enotes_editor_show_line_numbers (self, _tmp3_);
}

static void
___lambda48__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda48_ ((ENotesEditor*) self);
}

static void
__lambda49_ (ENotesEditor* self)
{
	GtkSourceView* _tmp0_;
	ENotesApplication* _tmp1_;
	ENotesApplicationState* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	_tmp0_ = self->priv->code_view;
	_tmp1_ = enotes_app;
	_tmp2_ = _tmp1_->state;
	_tmp3_ = enotes_application_state_get_editor_auto_indent (_tmp2_);
	_tmp4_ = _tmp3_;
	gtk_source_view_set_auto_indent (_tmp0_, _tmp4_);
}

static void
___lambda49__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda49_ ((ENotesEditor*) self);
}

static void
__lambda50_ (ENotesEditor* self)
{
	GtkSourceSearchSettings* _tmp0_;
	ENotesApplication* _tmp1_;
	ENotesApplicationState* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	_tmp0_ = self->priv->search_settings;
	_tmp1_ = enotes_app;
	_tmp2_ = _tmp1_->state;
	_tmp3_ = enotes_application_state_get_search_field (_tmp2_);
	_tmp4_ = _tmp3_;
	gtk_source_search_settings_set_search_text (_tmp0_, _tmp4_);
}

static void
___lambda50__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda50_ ((ENotesEditor*) self);
}

static void
enotes_editor_build_ui (ENotesEditor* self)
{
	GtkSourceLanguageManager* manager = NULL;
	GtkSourceLanguageManager* _tmp0_;
	GtkSourceLanguageManager* _tmp1_;
	GtkSourceLanguage* language = NULL;
	GtkSourceLanguage* _tmp2_;
	GtkSourceLanguage* _tmp3_;
	GtkSourceBuffer* _tmp4_;
	GtkSourceBuffer* _tmp5_;
	GtkSourceBuffer* _tmp6_;
	GtkSourceView* _tmp7_;
	GtkSourceBuffer* _tmp8_;
	GtkSourceView* _tmp9_;
	GtkSourceView* _tmp10_;
	GtkScrolledWindow* scroll_box = NULL;
	GtkScrolledWindow* _tmp11_;
	GtkSourceView* _tmp12_;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	GtkSpellChecker* _tmp15_;
	GtkSpellChecker* _tmp16_;
	ENotesServicesSettings* _tmp17_;
	ENotesServicesSettings* _tmp18_;
	gboolean _tmp19_;
	gboolean _tmp20_;
	GtkSpellChecker* _tmp21_;
	GtkBox* _tmp22_;
	GtkBox* _tmp23_;
	GtkSeparator* _tmp24_;
	GtkSeparator* _tmp25_;
	GtkBox* _tmp26_;
	ENotesApplication* _tmp27_;
	ENotesApplicationState* _tmp28_;
	ENotesApplication* _tmp29_;
	ENotesApplicationState* _tmp30_;
	ENotesApplication* _tmp31_;
	ENotesApplicationState* _tmp32_;
	ENotesApplication* _tmp33_;
	ENotesApplicationState* _tmp34_;
	ENotesApplication* _tmp35_;
	ENotesApplicationState* _tmp36_;
	ENotesApplication* _tmp37_;
	ENotesApplicationState* _tmp38_;
	ENotesApplication* _tmp39_;
	ENotesApplicationState* _tmp40_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_source_language_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	manager = _tmp1_;
	_tmp2_ = gtk_source_language_manager_guess_language (manager, NULL, "text/x-markdown");
	_tmp3_ = _g_object_ref0 (_tmp2_);
	language = _tmp3_;
	_tmp4_ = gtk_source_buffer_new_with_language (language);
	_g_object_unref0 (self->priv->code_buffer);
	self->priv->code_buffer = _tmp4_;
	_tmp5_ = self->priv->code_buffer;
	gtk_source_buffer_set_max_undo_levels (_tmp5_, 100);
	_tmp6_ = self->priv->code_buffer;
	_tmp7_ = (GtkSourceView*) gtk_source_view_new_with_buffer (_tmp6_);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->code_view);
	self->priv->code_view = _tmp7_;
	gtk_widget_set_size_request ((GtkWidget*) self, 250, 50);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	g_object_set ((GtkWidget*) self, "expand", TRUE, NULL);
	_tmp8_ = self->priv->code_buffer;
	g_signal_connect_object ((GtkTextBuffer*) _tmp8_, "changed", (GCallback) _enotes_editor_trigger_changed_gtk_text_buffer_changed, self, 0);
	_tmp9_ = self->priv->code_view;
	gtk_text_view_set_pixels_below_lines ((GtkTextView*) _tmp9_, 6);
	_tmp10_ = self->priv->code_view;
	gtk_text_view_set_wrap_mode ((GtkTextView*) _tmp10_, GTK_WRAP_WORD);
	enotes_editor_show_line_numbers (self, FALSE);
	_tmp11_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp11_);
	scroll_box = _tmp11_;
	_tmp12_ = self->priv->code_view;
	gtk_container_add ((GtkContainer*) scroll_box, (GtkWidget*) _tmp12_);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->editor_and_help);
	self->priv->editor_and_help = _tmp13_;
	_tmp14_ = self->priv->editor_and_help;
	gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) scroll_box);
	_tmp15_ = gtk_spell_checker_new ();
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->spell);
	self->priv->spell = _tmp15_;
	_tmp16_ = self->priv->spell;
	g_object_set (_tmp16_, "decode-language-codes", TRUE, NULL);
	_tmp17_ = enotes_services_settings_get_instance ();
	_tmp18_ = _tmp17_;
	_tmp19_ = enotes_services_settings_get_spellcheck (_tmp18_);
	_tmp20_ = _tmp19_;
	enotes_editor_set_spellcheck (self, _tmp20_);
	_g_object_unref0 (_tmp18_);
	_tmp21_ = self->priv->spell;
	g_signal_connect_object (_tmp21_, "language-changed", (GCallback) ___lambda41__gtk_spell_checker_language_changed, self, 0);
	_tmp22_ = enotes_editor_build_toolbar (self);
	_tmp23_ = _tmp22_;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp23_);
	_g_object_unref0 (_tmp23_);
	_tmp24_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp24_);
	_tmp25_ = _tmp24_;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp25_);
	_g_object_unref0 (_tmp25_);
	_tmp26_ = self->priv->editor_and_help;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp26_);
	gtk_widget_set_sensitive ((GtkWidget*) self, FALSE);
	g_object_set ((GtkWidget*) scroll_box, "expand", TRUE, NULL);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp27_ = enotes_app;
	_tmp28_ = _tmp27_->state;
	g_signal_connect_object ((GObject*) _tmp28_, "notify::opened-page", (GCallback) ___lambda44__g_object_notify, self, 0);
	_tmp29_ = enotes_app;
	_tmp30_ = _tmp29_->state;
	g_signal_connect_object (_tmp30_, "request-saving-page-info", (GCallback) ___lambda45__enotes_application_state_request_saving_page_info, self, 0);
	_tmp31_ = enotes_app;
	_tmp32_ = _tmp31_->state;
	g_signal_connect_object ((GObject*) _tmp32_, "notify::editor-font", (GCallback) ___lambda46__g_object_notify, self, 0);
	_tmp33_ = enotes_app;
	_tmp34_ = _tmp33_->state;
	g_signal_connect_object ((GObject*) _tmp34_, "notify::editor-scheme", (GCallback) ___lambda47__g_object_notify, self, 0);
	_tmp35_ = enotes_app;
	_tmp36_ = _tmp35_->state;
	g_signal_connect_object ((GObject*) _tmp36_, "notify::editor-show-line-numbers", (GCallback) ___lambda48__g_object_notify, self, 0);
	_tmp37_ = enotes_app;
	_tmp38_ = _tmp37_->state;
	g_signal_connect_object ((GObject*) _tmp38_, "notify::editor-auto-indent", (GCallback) ___lambda49__g_object_notify, self, 0);
	_tmp39_ = enotes_app;
	_tmp40_ = _tmp39_->state;
	g_signal_connect_object ((GObject*) _tmp40_, "notify::search-field", (GCallback) ___lambda50__g_object_notify, self, 0);
	_g_object_unref0 (scroll_box);
	_g_object_unref0 (language);
	_g_object_unref0 (manager);
}

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

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

static void
___lambda43_ (ENotesEditor* self,
              const gchar* text)
{
	GtkSourceBuffer* _tmp0_;
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->code_buffer;
	gtk_text_buffer_insert_at_cursor ((GtkTextBuffer*) _tmp0_, text, -1);
}

static void
____lambda43__enotes_help_box_insert_requested (ENotesHelpBox* _sender,
                                                const gchar* text,
                                                gpointer self)
{
	___lambda43_ ((ENotesEditor*) self, text);
}

static void
__lambda42_ (Block2Data* _data2_)
{
	ENotesEditor* self;
	ENotesHelpBox* _tmp0_;
	ENotesHelpBox* _tmp5_;
	self = _data2_->self;
	_tmp0_ = self->priv->help;
	if (_tmp0_ == NULL) {
		ENotesHelpBox* _tmp1_;
		ENotesHelpBox* _tmp2_;
		GtkBox* _tmp3_;
		ENotesHelpBox* _tmp4_;
		_tmp1_ = enotes_help_box_new ();
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->help);
		self->priv->help = _tmp1_;
		_tmp2_ = self->priv->help;
		g_signal_connect_object (_tmp2_, "insert-requested", (GCallback) ____lambda43__enotes_help_box_insert_requested, self, 0);
		_tmp3_ = self->priv->editor_and_help;
		_tmp4_ = self->priv->help;
		gtk_container_add ((GtkContainer*) _tmp3_, (GtkWidget*) _tmp4_);
	}
	_tmp5_ = self->priv->help;
	gtk_revealer_set_reveal_child ((GtkRevealer*) _tmp5_, gtk_toggle_button_get_active (_data2_->help_button));
}

static void
___lambda42__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                        gpointer self)
{
	__lambda42_ (self);
}

static GtkBox*
enotes_editor_build_toolbar (ENotesEditor* self)
{
	Block2Data* _data2_;
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkStyleContext* _tmp2_;
	ENotesApplication* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkSourceBuffer* _tmp9_;
	ENotesToolbarButton* _tmp10_;
	ENotesApplication* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GtkSourceBuffer* _tmp17_;
	ENotesToolbarButton* _tmp18_;
	ENotesApplication* _tmp19_;
	gchar** _tmp20_;
	gchar** _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* _tmp23_;
	gchar* _tmp24_;
	GtkSourceBuffer* _tmp25_;
	ENotesToolbarButton* _tmp26_;
	ENotesToolbarButton* quote_button = NULL;
	GtkSourceBuffer* _tmp27_;
	ENotesToolbarButton* _tmp28_;
	ENotesToolbarButton* code_button = NULL;
	GtkSourceBuffer* _tmp29_;
	ENotesToolbarButton* _tmp30_;
	ENotesToolbarButton* link_button = NULL;
	GtkSourceBuffer* _tmp31_;
	ENotesToolbarButton* _tmp32_;
	ENotesToolbarButton* bulleted_button = NULL;
	GtkSourceBuffer* _tmp33_;
	ENotesToolbarButton* _tmp34_;
	ENotesToolbarButton* numbered_button = NULL;
	GtkSourceBuffer* _tmp35_;
	ENotesToolbarButton* _tmp36_;
	ENotesToolbarButton* webimage_button = NULL;
	GtkSourceBuffer* _tmp37_;
	ENotesToolbarButton* _tmp38_;
	GtkSeparator* separator1 = NULL;
	GtkSeparator* _tmp39_;
	GtkSeparator* separator2 = NULL;
	GtkSeparator* _tmp40_;
	GtkSeparator* separator3 = NULL;
	GtkSeparator* _tmp41_;
	GtkSeparator* _tmp42_;
	GtkSeparator* _tmp43_;
	GtkSeparator* _tmp44_;
	GtkSeparator* _tmp45_;
	GtkSeparator* _tmp46_;
	GtkSeparator* _tmp47_;
	GtkBox* _tmp48_;
	ENotesToolbarButton* _tmp49_;
	GtkBox* _tmp50_;
	ENotesToolbarButton* _tmp51_;
	GtkBox* _tmp52_;
	ENotesToolbarButton* _tmp53_;
	GtkBox* _tmp54_;
	GtkSeparator* _tmp55_;
	GtkBox* _tmp56_;
	ENotesToolbarButton* _tmp57_;
	GtkBox* _tmp58_;
	ENotesToolbarButton* _tmp59_;
	GtkBox* _tmp60_;
	ENotesToolbarButton* _tmp61_;
	GtkBox* _tmp62_;
	ENotesToolbarButton* _tmp63_;
	GtkBox* _tmp64_;
	GtkSeparator* _tmp65_;
	GtkBox* _tmp66_;
	ENotesToolbarButton* _tmp67_;
	GtkBox* _tmp68_;
	ENotesToolbarButton* _tmp69_;
	GtkBox* _tmp70_;
	GtkSeparator* _tmp71_;
	ENotesPluginManager* _tmp72_;
	ENotesPluginManager* _tmp73_;
	gint _tmp74_ = 0;
	ENotesPlugin** _tmp75_;
	ENotesPlugin** _tmp76_;
	gint _tmp76__length1;
	GtkToggleButton* _tmp87_;
	GtkImage* help_icon = NULL;
	GtkImage* _tmp88_;
	GtkStyleContext* _tmp89_;
	GtkBox* _tmp90_;
	GtkBox* result;
	g_return_val_if_fail (self != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = box;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, "inline-toolbar");
	_tmp3_ = enotes_app;
	_tmp5_ = _tmp4_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp3_, "win.bold-action");
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _vala_array_length (_tmp4_);
	_tmp7_ = granite_markup_accel_tooltip (_tmp6_, (gint) _vala_array_length (_tmp4_), _ ("Add bold to text"));
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->code_buffer;
	_tmp10_ = enotes_toolbar_button_new ("format-text-bold-symbolic", "**", "**", _tmp8_, _tmp9_);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->bold_button);
	self->bold_button = _tmp10_;
	_g_free0 (_tmp8_);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	_tmp11_ = enotes_app;
	_tmp13_ = _tmp12_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp11_, "win.italics-action");
	_tmp14_ = _tmp13_;
	_tmp14__length1 = _vala_array_length (_tmp12_);
	_tmp15_ = granite_markup_accel_tooltip (_tmp14_, (gint) _vala_array_length (_tmp12_), _ ("Add italic to text"));
	_tmp16_ = _tmp15_;
	_tmp17_ = self->priv->code_buffer;
	_tmp18_ = enotes_toolbar_button_new ("format-text-italic-symbolic", "_", "_", _tmp16_, _tmp17_);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->italics_button);
	self->italics_button = _tmp18_;
	_g_free0 (_tmp16_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	_tmp19_ = enotes_app;
	_tmp21_ = _tmp20_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp19_, "win.strike-action");
	_tmp22_ = _tmp21_;
	_tmp22__length1 = _vala_array_length (_tmp20_);
	_tmp23_ = granite_markup_accel_tooltip (_tmp22_, (gint) _vala_array_length (_tmp20_), _ ("Strikethrough text"));
	_tmp24_ = _tmp23_;
	_tmp25_ = self->priv->code_buffer;
	_tmp26_ = enotes_toolbar_button_new ("format-text-strikethrough-symbolic", "~~", "~~", _tmp24_, _tmp25_);
	g_object_ref_sink (_tmp26_);
	_g_object_unref0 (self->strike_button);
	self->strike_button = _tmp26_;
	_g_free0 (_tmp24_);
	_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_free), NULL);
	_tmp27_ = self->priv->code_buffer;
	_tmp28_ = enotes_toolbar_button_new ("format-indent-less-rtl", "> ", "", _ ("Insert a quote"), _tmp27_);
	g_object_ref_sink (_tmp28_);
	quote_button = _tmp28_;
	_tmp29_ = self->priv->code_buffer;
	_tmp30_ = enotes_toolbar_button_new ("system-run", "`", "`", _ ("Insert code"), _tmp29_);
	g_object_ref_sink (_tmp30_);
	code_button = _tmp30_;
	_tmp31_ = self->priv->code_buffer;
	_tmp32_ = enotes_toolbar_button_new ("insert-link", "[Link Text](", ")", _ ("Insert a link"), _tmp31_);
	g_object_ref_sink (_tmp32_);
	link_button = _tmp32_;
	_tmp33_ = self->priv->code_buffer;
	_tmp34_ = enotes_toolbar_button_new ("zoom-out", "\n- ", "", _ ("Add a bulleted list"), _tmp33_);
	g_object_ref_sink (_tmp34_);
	bulleted_button = _tmp34_;
	_tmp35_ = self->priv->code_buffer;
	_tmp36_ = enotes_toolbar_button_new ("zoom-original", "\n1. ", "", _ ("Add a Numbered list"), _tmp35_);
	g_object_ref_sink (_tmp36_);
	numbered_button = _tmp36_;
	_tmp37_ = self->priv->code_buffer;
	_tmp38_ = enotes_toolbar_button_new_is_image_button ("insert-image", "![](", ")", _ ("Insert an image"), _tmp37_);
	g_object_ref_sink (_tmp38_);
	webimage_button = _tmp38_;
	_tmp39_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp39_);
	separator1 = _tmp39_;
	_tmp40_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp40_);
	separator2 = _tmp40_;
	_tmp41_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp41_);
	separator3 = _tmp41_;
	_tmp42_ = separator1;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp42_, 4);
	_tmp43_ = separator2;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp43_, 4);
	_tmp44_ = separator3;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp44_, 4);
	_tmp45_ = separator1;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp45_, 4);
	_tmp46_ = separator2;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp46_, 4);
	_tmp47_ = separator3;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp47_, 4);
	_tmp48_ = box;
	_tmp49_ = self->bold_button;
	gtk_container_add ((GtkContainer*) _tmp48_, (GtkWidget*) _tmp49_);
	_tmp50_ = box;
	_tmp51_ = self->italics_button;
	gtk_container_add ((GtkContainer*) _tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = box;
	_tmp53_ = self->strike_button;
	gtk_container_add ((GtkContainer*) _tmp52_, (GtkWidget*) _tmp53_);
	_tmp54_ = box;
	_tmp55_ = separator1;
	gtk_container_add ((GtkContainer*) _tmp54_, (GtkWidget*) _tmp55_);
	_tmp56_ = box;
	_tmp57_ = quote_button;
	gtk_container_add ((GtkContainer*) _tmp56_, (GtkWidget*) _tmp57_);
	_tmp58_ = box;
	_tmp59_ = code_button;
	gtk_container_add ((GtkContainer*) _tmp58_, (GtkWidget*) _tmp59_);
	_tmp60_ = box;
	_tmp61_ = bulleted_button;
	gtk_container_add ((GtkContainer*) _tmp60_, (GtkWidget*) _tmp61_);
	_tmp62_ = box;
	_tmp63_ = numbered_button;
	gtk_container_add ((GtkContainer*) _tmp62_, (GtkWidget*) _tmp63_);
	_tmp64_ = box;
	_tmp65_ = separator2;
	gtk_container_add ((GtkContainer*) _tmp64_, (GtkWidget*) _tmp65_);
	_tmp66_ = box;
	_tmp67_ = link_button;
	gtk_container_add ((GtkContainer*) _tmp66_, (GtkWidget*) _tmp67_);
	_tmp68_ = box;
	_tmp69_ = webimage_button;
	gtk_container_add ((GtkContainer*) _tmp68_, (GtkWidget*) _tmp69_);
	_tmp70_ = box;
	_tmp71_ = separator3;
	gtk_container_add ((GtkContainer*) _tmp70_, (GtkWidget*) _tmp71_);
	_tmp72_ = enotes_plugin_manager_get_instance ();
	_tmp73_ = _tmp72_;
	_tmp75_ = enotes_plugin_manager_get_plugs (_tmp73_, &_tmp74_);
	_tmp76_ = _tmp75_;
	_tmp76__length1 = _tmp74_;
	_g_object_unref0 (_tmp73_);
	{
		ENotesPlugin** plugin_collection = NULL;
		gint plugin_collection_length1 = 0;
		gint _plugin_collection_size_ = 0;
		gint plugin_it = 0;
		plugin_collection = _tmp76_;
		plugin_collection_length1 = _tmp76__length1;
		for (plugin_it = 0; plugin_it < plugin_collection_length1; plugin_it = plugin_it + 1) {
			ENotesPlugin* _tmp77_;
			ENotesPlugin* plugin = NULL;
			_tmp77_ = _g_object_ref0 (plugin_collection[plugin_it]);
			plugin = _tmp77_;
			{
				GtkWidget* widget = NULL;
				ENotesPlugin* _tmp78_;
				GtkWidget* _tmp79_;
				GtkWidget* _tmp80_;
				_tmp78_ = plugin;
				_tmp79_ = enotes_plugin_editor_button (_tmp78_);
				widget = _tmp79_;
				_tmp80_ = widget;
				if (_tmp80_ != NULL) {
					GtkBox* _tmp81_;
					ENotesPlugin* _tmp82_;
					GtkWidget* _tmp83_;
					GtkSourceBuffer* _tmp84_;
					ENotesToolbarButton* _tmp85_;
					ENotesToolbarButton* _tmp86_;
					_tmp81_ = box;
					_tmp82_ = plugin;
					_tmp83_ = widget;
					_tmp84_ = self->priv->code_buffer;
					_tmp85_ = enotes_toolbar_button_new_from_plugin (_tmp82_, _tmp83_, _tmp84_);
					g_object_ref_sink (_tmp85_);
					_tmp86_ = _tmp85_;
					gtk_container_add ((GtkContainer*) _tmp81_, (GtkWidget*) _tmp86_);
					_g_object_unref0 (_tmp86_);
				}
				_g_object_unref0 (widget);
				_g_object_unref0 (plugin);
			}
		}
	}
	_tmp87_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp87_);
	_data2_->help_button = _tmp87_;
	_tmp88_ = (GtkImage*) gtk_image_new_from_icon_name ("dialog-question-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp88_);
	help_icon = _tmp88_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _data2_->help_button, _ ("Formatting"));
	_tmp89_ = gtk_widget_get_style_context ((GtkWidget*) _data2_->help_button);
	gtk_style_context_add_class (_tmp89_, "flat");
	gtk_widget_set_can_focus ((GtkWidget*) _data2_->help_button, FALSE);
	gtk_widget_set_hexpand ((GtkWidget*) _data2_->help_button, TRUE);
	gtk_widget_set_halign ((GtkWidget*) _data2_->help_button, GTK_ALIGN_END);
	g_signal_connect_data (_data2_->help_button, "toggled", (GCallback) ___lambda42__gtk_toggle_button_toggled, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	gtk_container_add ((GtkContainer*) _data2_->help_button, (GtkWidget*) help_icon);
	_tmp90_ = box;
	gtk_container_add ((GtkContainer*) _tmp90_, (GtkWidget*) _data2_->help_button);
	result = box;
	_g_object_unref0 (help_icon);
	_g_object_unref0 (separator3);
	_g_object_unref0 (separator2);
	_g_object_unref0 (separator1);
	_g_object_unref0 (webimage_button);
	_g_object_unref0 (numbered_button);
	_g_object_unref0 (bulleted_button);
	_g_object_unref0 (link_button);
	_g_object_unref0 (code_button);
	_g_object_unref0 (quote_button);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return result;
}

void
enotes_editor_save_file (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesPage* _tmp2_;
	ENotesPage* _tmp3_;
	gboolean _tmp14_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_page (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		return;
	}
	if (self->priv->edited) {
		ENotesApplication* _tmp4_;
		ENotesApplicationState* _tmp5_;
		ENotesPage* _tmp6_;
		ENotesPage* _tmp7_;
		gchar* _tmp8_;
		ENotesApplication* _tmp9_;
		ENotesApplicationState* _tmp10_;
		ENotesPage* _tmp11_;
		ENotesPage* _tmp12_;
		gchar* _tmp13_;
		_tmp4_ = enotes_app;
		_tmp5_ = _tmp4_->state;
		_tmp6_ = enotes_application_state_get_opened_page (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = enotes_editor_get_text (self);
		_g_free0 (_tmp7_->data);
		_tmp7_->data = _tmp8_;
		_tmp9_ = enotes_app;
		_tmp10_ = _tmp9_->state;
		_tmp11_ = enotes_application_state_get_opened_page (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strdup ("");
		_g_free0 (_tmp12_->html_cache);
		_tmp12_->html_cache = _tmp13_;
	}
	if (self->priv->edited) {
		_tmp14_ = TRUE;
	} else {
		ENotesApplication* _tmp15_;
		ENotesApplicationState* _tmp16_;
		ENotesPage* _tmp17_;
		ENotesPage* _tmp18_;
		_tmp15_ = enotes_app;
		_tmp16_ = _tmp15_->state;
		_tmp17_ = enotes_application_state_get_opened_page (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp14_ = _tmp18_->cache_changed;
	}
	if (_tmp14_) {
		ENotesApplication* _tmp19_;
		ENotesApplicationState* _tmp20_;
		_tmp19_ = enotes_app;
		_tmp20_ = _tmp19_->state;
		enotes_application_state_save_opened_page (_tmp20_);
	}
	self->priv->edited = FALSE;
}

void
enotes_editor_reset (ENotesEditor* self,
                     gboolean disable_save)
{
	GtkSourceBuffer* _tmp0_;
	g_return_if_fail (self != NULL);
	if (disable_save) {
		self->priv->edited = FALSE;
	}
	_tmp0_ = self->priv->code_buffer;
	g_object_set ((GtkTextBuffer*) _tmp0_, "text", "", NULL);
}

gchar*
enotes_editor_get_text (ENotesEditor* self)
{
	GtkSourceView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->code_view;
	_tmp1_ = gtk_text_view_get_buffer ((GtkTextView*) _tmp0_);
	_tmp2_ = _tmp1_;
	g_object_get (_tmp2_, "text", &_tmp3_, NULL);
	_tmp4_ = _tmp3_;
	result = _tmp4_;
	return result;
}

void
enotes_editor_give_focus (ENotesEditor* self)
{
	GtkSourceView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->code_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
}

static void
enotes_editor_show_line_numbers (ENotesEditor* self,
                                 gboolean show)
{
	GtkSourceView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->code_view;
	gtk_source_view_set_show_line_numbers (_tmp0_, show);
	if (show) {
		GtkSourceView* _tmp1_;
		_tmp1_ = self->priv->code_view;
		gtk_text_view_set_left_margin ((GtkTextView*) _tmp1_, 6);
	} else {
		GtkSourceView* _tmp2_;
		_tmp2_ = self->priv->code_view;
		gtk_text_view_set_left_margin ((GtkTextView*) _tmp2_, 12);
	}
}

static void
_vala_PangoFontDescription_free (PangoFontDescription* self)
{
	g_boxed_free (pango_font_description_get_type (), self);
}

static void
enotes_editor_set_font (ENotesEditor* self,
                        const gchar* name)
{
	PangoFontDescription* font = NULL;
	PangoFontDescription* _tmp0_;
	GtkSourceView* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = pango_font_description_from_string (name);
	font = _tmp0_;
	_tmp1_ = self->priv->code_view;
	gtk_widget_override_font ((GtkWidget*) _tmp1_, font);
	__vala_PangoFontDescription_free0 (font);
}

static void
enotes_editor_set_scheme (ENotesEditor* self,
                          const gchar* id)
{
	GtkSourceStyleSchemeManager* style_manager = NULL;
	GtkSourceStyleSchemeManager* _tmp0_;
	GtkSourceStyleSchemeManager* _tmp1_;
	GtkSourceStyleScheme* style = NULL;
	GtkSourceStyleScheme* _tmp2_;
	GtkSourceStyleScheme* _tmp3_;
	GtkSourceBuffer* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (id != NULL);
	_tmp0_ = gtk_source_style_scheme_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	style_manager = _tmp1_;
	_tmp2_ = gtk_source_style_scheme_manager_get_scheme (style_manager, id);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	style = _tmp3_;
	_tmp4_ = self->priv->code_buffer;
	gtk_source_buffer_set_style_scheme (_tmp4_, style);
	_g_object_unref0 (style);
	_g_object_unref0 (style_manager);
}

static gboolean
__lambda40_ (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesPage* _tmp2_;
	ENotesPage* _tmp3_;
	gchar* _tmp4_;
	ENotesApplication* _tmp5_;
	ENotesApplicationState* _tmp6_;
	gboolean result;
	self->priv->text_change_timeout = (guint) 0;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_page (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = enotes_editor_get_text (self);
	_g_free0 (_tmp3_->data);
	_tmp3_->data = _tmp4_;
	_tmp5_ = enotes_app;
	_tmp6_ = _tmp5_->state;
	g_signal_emit_by_name (_tmp6_, "page-text-updated");
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda40__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda40_ ((ENotesEditor*) self);
	return result;
}

static void
enotes_editor_trigger_changed (ENotesEditor* self)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesPage* _tmp2_;
	ENotesPage* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_page (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		return;
	}
	if (self->priv->text_change_timeout != ((guint) 0)) {
		g_source_remove (self->priv->text_change_timeout);
		self->priv->text_change_timeout = (guint) 0;
	}
	self->priv->edited = TRUE;
	self->priv->text_change_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1000, ___lambda40__gsource_func, g_object_ref (self), g_object_unref);
}

static void
enotes_editor_set_current_page (ENotesEditor* self,
                                ENotesPage* value)
{
	GtkSourceBuffer* _tmp8_;
	guint _tmp9_;
	GtkSourceBuffer* _tmp10_;
	GtkSourceBuffer* _tmp11_;
	const gchar* _tmp12_;
	GtkSourceBuffer* _tmp13_;
	GtkSourceBuffer* _tmp14_;
	g_return_if_fail (self != NULL);
	if (self->priv->text_change_timeout != ((guint) 0)) {
		g_source_remove (self->priv->text_change_timeout);
		self->priv->text_change_timeout = (guint) 0;
	}
	if (value == NULL) {
		GtkSourceBuffer* _tmp0_;
		guint _tmp1_;
		GtkSourceBuffer* _tmp2_;
		GtkSourceBuffer* _tmp3_;
		GtkSourceBuffer* _tmp4_;
		GtkSourceBuffer* _tmp5_;
		gtk_widget_set_sensitive ((GtkWidget*) self, FALSE);
		_tmp0_ = self->priv->code_buffer;
		g_signal_parse_name ("changed", gtk_text_buffer_get_type (), &_tmp1_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkTextBuffer*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _enotes_editor_trigger_changed_gtk_text_buffer_changed, self);
		_tmp2_ = self->priv->code_buffer;
		gtk_source_buffer_begin_not_undoable_action (_tmp2_);
		_tmp3_ = self->priv->code_buffer;
		g_object_set ((GtkTextBuffer*) _tmp3_, "text", "", NULL);
		self->priv->edited = FALSE;
		_tmp4_ = self->priv->code_buffer;
		gtk_source_buffer_end_not_undoable_action (_tmp4_);
		_tmp5_ = self->priv->code_buffer;
		g_signal_connect_object ((GtkTextBuffer*) _tmp5_, "changed", (GCallback) _enotes_editor_trigger_changed_gtk_text_buffer_changed, self, 0);
		return;
	} else {
		ENotesTrash* _tmp6_;
		ENotesTrash* _tmp7_;
		_tmp6_ = enotes_trash_get_instance ();
		_tmp7_ = _tmp6_;
		gtk_widget_set_sensitive ((GtkWidget*) self, !enotes_trash_is_page_trashed (_tmp7_, value));
		_g_object_unref0 (_tmp7_);
	}
	_tmp8_ = self->priv->code_buffer;
	g_signal_parse_name ("changed", gtk_text_buffer_get_type (), &_tmp9_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkTextBuffer*) _tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp9_, 0, NULL, (GCallback) _enotes_editor_trigger_changed_gtk_text_buffer_changed, self);
	_tmp10_ = self->priv->code_buffer;
	gtk_source_buffer_begin_not_undoable_action (_tmp10_);
	_tmp11_ = self->priv->code_buffer;
	_tmp12_ = value->data;
	g_object_set ((GtkTextBuffer*) _tmp11_, "text", _tmp12_, NULL);
	self->priv->edited = FALSE;
	_tmp13_ = self->priv->code_buffer;
	gtk_source_buffer_end_not_undoable_action (_tmp13_);
	_tmp14_ = self->priv->code_buffer;
	g_signal_connect_object ((GtkTextBuffer*) _tmp14_, "changed", (GCallback) _enotes_editor_trigger_changed_gtk_text_buffer_changed, self, 0);
}

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

static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}

void
enotes_editor_set_spellcheck (ENotesEditor* self,
                              gboolean value)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	if (value) {
		{
			gchar* last_language = NULL;
			ENotesServicesSettings* _tmp0_;
			ENotesServicesSettings* _tmp1_;
			const gchar* _tmp2_;
			const gchar* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			GList* language_list = NULL;
			GList* _tmp6_;
			gboolean language_set = FALSE;
			GList* _tmp7_;
			GList* _tmp13_;
			GtkSpellChecker* _tmp21_;
			GtkSourceView* _tmp22_;
			_tmp0_ = enotes_services_settings_get_instance ();
			_tmp1_ = _tmp0_;
			_tmp2_ = enotes_services_settings_get_spellcheck_language (_tmp1_);
			_tmp3_ = _tmp2_;
			_tmp4_ = g_strdup (_tmp3_);
			_tmp5_ = _tmp4_;
			_g_object_unref0 (_tmp1_);
			last_language = _tmp5_;
			_tmp6_ = gtk_spell_checker_get_language_list ();
			language_list = _tmp6_;
			language_set = FALSE;
			_tmp7_ = language_list;
			{
				GList* element_collection = NULL;
				GList* element_it = NULL;
				element_collection = _tmp7_;
				for (element_it = element_collection; element_it != NULL; element_it = element_it->next) {
					gchar* _tmp8_;
					gchar* element = NULL;
					_tmp8_ = g_strdup ((const gchar*) element_it->data);
					element = _tmp8_;
					{
						const gchar* _tmp9_;
						const gchar* _tmp10_;
						_tmp9_ = last_language;
						_tmp10_ = element;
						if (g_strcmp0 (_tmp9_, _tmp10_) == 0) {
							GtkSpellChecker* _tmp11_;
							const gchar* _tmp12_;
							_tmp11_ = self->priv->spell;
							_tmp12_ = last_language;
							gtk_spell_checker_set_language (_tmp11_, _tmp12_, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_g_free0 (element);
								(language_list == NULL) ? NULL : (language_list = (_g_list_free__g_free0_ (language_list), NULL));
								_g_free0 (last_language);
								goto __catch0_g_error;
							}
							language_set = TRUE;
							_g_free0 (element);
							break;
						}
						_g_free0 (element);
					}
				}
			}
			_tmp13_ = language_list;
			if (g_list_length (_tmp13_) == ((guint) 0)) {
				GtkSpellChecker* _tmp14_;
				_tmp14_ = self->priv->spell;
				gtk_spell_checker_set_language (_tmp14_, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					(language_list == NULL) ? NULL : (language_list = (_g_list_free__g_free0_ (language_list), NULL));
					_g_free0 (last_language);
					goto __catch0_g_error;
				}
			} else {
				if (!language_set) {
					GList* _tmp15_;
					GList* _tmp16_;
					gconstpointer _tmp17_;
					gchar* _tmp18_;
					GtkSpellChecker* _tmp19_;
					const gchar* _tmp20_;
					_tmp15_ = language_list;
					_tmp16_ = g_list_first (_tmp15_);
					_tmp17_ = _tmp16_->data;
					_tmp18_ = g_strdup ((const gchar*) _tmp17_);
					_g_free0 (last_language);
					last_language = _tmp18_;
					_tmp19_ = self->priv->spell;
					_tmp20_ = last_language;
					gtk_spell_checker_set_language (_tmp19_, _tmp20_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						(language_list == NULL) ? NULL : (language_list = (_g_list_free__g_free0_ (language_list), NULL));
						_g_free0 (last_language);
						goto __catch0_g_error;
					}
				}
			}
			_tmp21_ = self->priv->spell;
			_tmp22_ = self->priv->code_view;
			gtk_spell_checker_attach (_tmp21_, (GtkTextView*) _tmp22_);
			(language_list == NULL) ? NULL : (language_list = (_g_list_free__g_free0_ (language_list), NULL));
			_g_free0 (last_language);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp23_;
			const gchar* _tmp24_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp23_ = e;
			_tmp24_ = _tmp23_->message;
			g_warning ("Editor.vala:87: %s", _tmp24_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			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;
		}
	} else {
		GtkSpellChecker* _tmp25_;
		_tmp25_ = self->priv->spell;
		gtk_spell_checker_detach (_tmp25_);
	}
	g_object_notify_by_pspec ((GObject *) self, enotes_editor_properties[ENOTES_EDITOR_SPELLCHECK_PROPERTY]);
}

static void
enotes_editor_class_init (ENotesEditorClass * klass,
                          gpointer klass_data)
{
	enotes_editor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesEditor_private_offset);
	G_OBJECT_CLASS (klass)->set_property = _vala_enotes_editor_set_property;
	G_OBJECT_CLASS (klass)->finalize = enotes_editor_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ENOTES_EDITOR_SPELLCHECK_PROPERTY, enotes_editor_properties[ENOTES_EDITOR_SPELLCHECK_PROPERTY] = g_param_spec_boolean ("spellcheck", "spellcheck", "spellcheck", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
}

static void
enotes_editor_instance_init (ENotesEditor * self,
                             gpointer klass)
{
	self->priv = enotes_editor_get_instance_private (self);
	self->priv->help = NULL;
	self->priv->spell = NULL;
	self->priv->edited = FALSE;
	self->priv->text_change_timeout = (guint) 0;
}

static void
enotes_editor_finalize (GObject * obj)
{
	ENotesEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_EDITOR, ENotesEditor);
	_g_object_unref0 (self->priv->code_view);
	_g_object_unref0 (self->priv->code_buffer);
	_g_object_unref0 (self->priv->editor_and_help);
	_g_object_unref0 (self->priv->help);
	_g_object_unref0 (self->priv->spell);
	_g_object_unref0 (self->priv->search_context);
	_g_object_unref0 (self->priv->search_settings);
	_g_object_unref0 (self->bold_button);
	_g_object_unref0 (self->italics_button);
	_g_object_unref0 (self->strike_button);
	G_OBJECT_CLASS (enotes_editor_parent_class)->finalize (obj);
}

static GType
enotes_editor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesEditorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_editor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesEditor), 0, (GInstanceInitFunc) enotes_editor_instance_init, NULL };
	GType enotes_editor_type_id;
	enotes_editor_type_id = g_type_register_static (gtk_box_get_type (), "ENotesEditor", &g_define_type_info, 0);
	ENotesEditor_private_offset = g_type_add_instance_private (enotes_editor_type_id, sizeof (ENotesEditorPrivate));
	return enotes_editor_type_id;
}

GType
enotes_editor_get_type (void)
{
	static volatile gsize enotes_editor_type_id__once = 0;
	if (g_once_init_enter (&enotes_editor_type_id__once)) {
		GType enotes_editor_type_id;
		enotes_editor_type_id = enotes_editor_get_type_once ();
		g_once_init_leave (&enotes_editor_type_id__once, enotes_editor_type_id);
	}
	return enotes_editor_type_id__once;
}

static void
_vala_enotes_editor_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	ENotesEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ENOTES_TYPE_EDITOR, ENotesEditor);
	switch (property_id) {
		case ENOTES_EDITOR_SPELLCHECK_PROPERTY:
		enotes_editor_set_spellcheck (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

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

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

