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

/*
* Copyright (c) 2015-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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include <granite.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.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_FILE_MANAGER (enotes_file_manager_get_type ())
#define ENOTES_FILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_FILE_MANAGER, ENotesFileManager))
#define ENOTES_FILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_FILE_MANAGER, ENotesFileManagerClass))
#define ENOTES_IS_FILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_FILE_MANAGER))
#define ENOTES_IS_FILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_FILE_MANAGER))
#define ENOTES_FILE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_FILE_MANAGER, ENotesFileManagerClass))

typedef struct _ENotesFileManager ENotesFileManager;
typedef struct _ENotesFileManagerClass ENotesFileManagerClass;
typedef struct _ENotesFileManagerPrivate ENotesFileManagerPrivate;
enum  {
	ENOTES_FILE_MANAGER_0_PROPERTY,
	ENOTES_FILE_MANAGER_NUM_PROPERTIES
};
static GParamSpec* enotes_file_manager_properties[ENOTES_FILE_MANAGER_NUM_PROPERTIES];

#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_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;

#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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#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 _ENotesPagePrivate ENotesPagePrivate;
typedef struct _Block10Data Block10Data;
typedef struct _Block11Data Block11Data;

struct _ENotesFileManager {
	GObject parent_instance;
	ENotesFileManagerPrivate * priv;
};

struct _ENotesFileManagerClass {
	GObjectClass parent_class;
};

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

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

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

struct _Block10Data {
	int _ref_count_;
	GFile* file;
	gchar* contents;
};

struct _Block11Data {
	int _ref_count_;
	GtkFileChooserDialog* dialog;
};

static gpointer enotes_file_manager_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;

VALA_EXTERN GType enotes_file_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesFileManager, g_object_unref)
VALA_EXTERN GFile* enotes_file_manager_export_pdf_action (const gchar* file_path);
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_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_page (ENotesViewer* self,
                              ENotesPage* page,
                              gboolean force_load);
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)
VALA_EXTERN ENotesPage* enotes_application_state_get_opened_page (ENotesApplicationState* self);
VALA_EXTERN GFile* enotes_file_manager_get_file_from_user (const gchar* filetype,
                                               GtkFileChooserAction* chooser_action);
VALA_EXTERN void enotes_file_manager_write_file (GFile* file,
                                     const gchar* contents,
                                     gboolean overrite,
                                     GError** error);
VALA_EXTERN GFile* enotes_file_manager_export_markdown_action (const gchar* file_path);
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_save_file (ENotesEditor* self);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
VALA_EXTERN void enotes_file_manager_create_file_if_not_exists (GFile* file,
                                                    GError** error);
static void __lambda38_ (Block10Data* _data10_,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda38__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gboolean _gtk_file_chooser_action_equal (const GtkFileChooserAction * s1,
                                         const GtkFileChooserAction * s2);
static void __lambda37_ (Block11Data* _data11_,
                  GtkFileFilter* filter);
static void ___lambda37__gfunc (gconstpointer data,
                         gpointer self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN ENotesFileManager* enotes_file_manager_new (void);
VALA_EXTERN ENotesFileManager* enotes_file_manager_construct (GType object_type);
static GType enotes_file_manager_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GFile*
enotes_file_manager_export_pdf_action (const gchar* file_path)
{
	ENotesViewEditStack* _tmp0_;
	ENotesViewEditStack* _tmp1_;
	ENotesViewer* _tmp2_;
	ENotesViewer* _tmp3_;
	ENotesApplication* _tmp4_;
	ENotesApplicationState* _tmp5_;
	ENotesPage* _tmp6_;
	ENotesPage* _tmp7_;
	GFile* file = NULL;
	GFile* _tmp11_;
	GFile* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gboolean _tmp17_;
	WebKitPrintOperation* op = NULL;
	ENotesViewEditStack* _tmp27_;
	ENotesViewEditStack* _tmp28_;
	ENotesViewer* _tmp29_;
	ENotesViewer* _tmp30_;
	WebKitPrintOperation* _tmp31_;
	WebKitPrintOperation* _tmp32_;
	GtkPrintSettings* settings = NULL;
	GtkPrintSettings* _tmp33_;
	GtkPrintSettings* _tmp34_;
	GtkPrintSettings* _tmp35_;
	GFile* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	WebKitPrintOperation* _tmp39_;
	GtkPrintSettings* _tmp40_;
	WebKitPrintOperation* _tmp41_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	_tmp0_ = enotes_view_edit_stack_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = enotes_view_edit_stack_get_viewer (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = enotes_app;
	_tmp5_ = _tmp4_->state;
	_tmp6_ = enotes_application_state_get_opened_page (_tmp5_);
	_tmp7_ = _tmp6_;
	enotes_viewer_load_page (_tmp3_, _tmp7_, TRUE);
	_g_object_unref0 (_tmp1_);
	if (file_path == NULL) {
		GtkFileChooserAction _tmp8_;
		GFile* _tmp9_;
		_tmp8_ = GTK_FILE_CHOOSER_ACTION_SAVE;
		_tmp9_ = enotes_file_manager_get_file_from_user ("pdf", &_tmp8_);
		_g_object_unref0 (file);
		file = _tmp9_;
	} else {
		GFile* _tmp10_;
		_tmp10_ = g_file_new_for_path (file_path);
		_g_object_unref0 (file);
		file = _tmp10_;
	}
	_tmp11_ = file;
	if (_tmp11_ == NULL) {
		result = NULL;
		_g_object_unref0 (file);
		return result;
	}
	_tmp12_ = file;
	_tmp13_ = g_file_get_basename (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_utf8_strdown (_tmp14_, (gssize) -1);
	_tmp16_ = _tmp15_;
	_tmp17_ = !g_str_has_suffix (_tmp16_, ".pdf");
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	if (_tmp17_) {
		GFile* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		GFile* _tmp23_;
		_tmp18_ = file;
		_tmp19_ = g_file_get_path (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = g_strconcat (_tmp20_, ".pdf", NULL);
		_tmp22_ = _tmp21_;
		_tmp23_ = g_file_new_for_path (_tmp22_);
		_g_object_unref0 (file);
		file = _tmp23_;
		_g_free0 (_tmp22_);
		_g_free0 (_tmp20_);
	}
	{
		GFile* _tmp24_;
		_tmp24_ = file;
		enotes_file_manager_write_file (_tmp24_, "", FALSE, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp25_;
		const gchar* _tmp26_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp25_ = e;
		_tmp26_ = _tmp25_->message;
		g_warning ("FileManager.vala:45: Could not write initial PDF file: %s", _tmp26_);
		result = NULL;
		_g_error_free0 (e);
		_g_object_unref0 (file);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp27_ = enotes_view_edit_stack_get_instance ();
	_tmp28_ = _tmp27_;
	_tmp29_ = enotes_view_edit_stack_get_viewer (_tmp28_);
	_tmp30_ = _tmp29_;
	_tmp31_ = webkit_print_operation_new ((WebKitWebView*) _tmp30_);
	_tmp32_ = _tmp31_;
	_g_object_unref0 (_tmp28_);
	op = _tmp32_;
	_tmp33_ = gtk_print_settings_new ();
	settings = _tmp33_;
	_tmp34_ = settings;
	gtk_print_settings_set_printer (_tmp34_, g_dgettext ("gtk30", "Print to File"));
	_tmp35_ = settings;
	_tmp36_ = file;
	_tmp37_ = g_file_get_uri (_tmp36_);
	_tmp38_ = _tmp37_;
	gtk_print_settings_set (_tmp35_, GTK_PRINT_SETTINGS_OUTPUT_URI, _tmp38_);
	_g_free0 (_tmp38_);
	_tmp39_ = op;
	_tmp40_ = settings;
	webkit_print_operation_set_print_settings (_tmp39_, _tmp40_);
	_tmp41_ = op;
	webkit_print_operation_print (_tmp41_);
	result = file;
	_g_object_unref0 (settings);
	_g_object_unref0 (op);
	return result;
}

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

static gchar*
string_to_utf8 (const gchar* self,
                gint* result_length1)
{
	gint string_length = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _result_ = NULL;
	gchar* _tmp2_;
	gint _result__length1;
	gint __result__size_;
	gint _tmp3_;
	gchar* _tmp4_;
	gint _tmp4__length1;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = _tmp1_;
	_tmp2_ = g_new0 (gchar, string_length + 1);
	_result_ = _tmp2_;
	_result__length1 = string_length + 1;
	__result__size_ = _result__length1;
	_tmp3_ = _result__length1;
	_result__length1 = _tmp3_ - 1;
	memcpy (_result_, self, (gsize) string_length);
	_tmp4_ = _result_;
	_tmp4__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}

GFile*
enotes_file_manager_export_markdown_action (const gchar* file_path)
{
	GFile* file = NULL;
	GFile* _tmp3_;
	GFile* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gboolean _tmp9_;
	ENotesEditor* editor = NULL;
	ENotesViewEditStack* _tmp16_;
	ENotesViewEditStack* _tmp17_;
	ENotesEditor* _tmp18_;
	ENotesEditor* _tmp19_;
	ENotesEditor* _tmp20_;
	ENotesEditor* _tmp21_;
	ENotesEditor* _tmp22_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	if (file_path == NULL) {
		GtkFileChooserAction _tmp0_;
		GFile* _tmp1_;
		_tmp0_ = GTK_FILE_CHOOSER_ACTION_SAVE;
		_tmp1_ = enotes_file_manager_get_file_from_user ("md", &_tmp0_);
		_g_object_unref0 (file);
		file = _tmp1_;
	} else {
		GFile* _tmp2_;
		_tmp2_ = g_file_new_for_path (file_path);
		_g_object_unref0 (file);
		file = _tmp2_;
	}
	_tmp3_ = file;
	if (_tmp3_ == NULL) {
		result = NULL;
		_g_object_unref0 (file);
		return result;
	}
	_tmp4_ = file;
	_tmp5_ = g_file_get_basename (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_utf8_strdown (_tmp6_, (gssize) -1);
	_tmp8_ = _tmp7_;
	_tmp9_ = !g_str_has_suffix (_tmp8_, ".md");
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	if (_tmp9_) {
		GFile* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		GFile* _tmp15_;
		_tmp10_ = file;
		_tmp11_ = g_file_get_path (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strconcat (_tmp12_, ".md", NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_file_new_for_path (_tmp14_);
		_g_object_unref0 (file);
		file = _tmp15_;
		_g_free0 (_tmp14_);
		_g_free0 (_tmp12_);
	}
	_tmp16_ = enotes_view_edit_stack_get_instance ();
	_tmp17_ = _tmp16_;
	_tmp18_ = enotes_view_edit_stack_get_editor (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _g_object_ref0 (_tmp19_);
	_tmp21_ = _tmp20_;
	_g_object_unref0 (_tmp17_);
	editor = _tmp21_;
	_tmp22_ = editor;
	enotes_editor_save_file (_tmp22_);
	{
		GFile* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		ENotesApplication* _tmp26_;
		ENotesApplicationState* _tmp27_;
		ENotesPage* _tmp28_;
		ENotesPage* _tmp29_;
		const gchar* _tmp30_;
		gint _tmp31_ = 0;
		gchar* _tmp32_;
		guint8* _tmp33_;
		gint _tmp33__length1;
		_tmp23_ = file;
		_tmp24_ = g_file_get_path (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = enotes_app;
		_tmp27_ = _tmp26_->state;
		_tmp28_ = enotes_application_state_get_opened_page (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = _tmp29_->data;
		_tmp32_ = string_to_utf8 (_tmp30_, &_tmp31_);
		_tmp33_ = (guint8*) _tmp32_;
		_tmp33__length1 = (_tmp31_ * sizeof (gchar)) / sizeof (guint8);
		g_file_set_contents (_tmp25_, (const char*) _tmp33_, (gsize) ((_tmp31_ * sizeof (gchar)) / sizeof (guint8)), &_inner_error0_);
		_tmp33_ = (g_free (_tmp33_), NULL);
		_g_free0 (_tmp25_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp34_;
		const gchar* _tmp35_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp34_ = e;
		_tmp35_ = _tmp34_->message;
		g_warning ("FileManager.vala:83: Failed to export file %s", _tmp35_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (editor);
		_g_object_unref0 (file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = file;
	_g_object_unref0 (editor);
	return result;
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		_g_object_unref0 (_data10_->file);
		_g_free0 (_data10_->contents);
		g_slice_free (Block10Data, _data10_);
	}
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
__lambda38_ (Block10Data* _data10_,
             GObject* obj,
             GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		GFileIOStream* iostream = NULL;
		GFileIOStream* _tmp0_;
		GOutputStream* ostream = NULL;
		GFileIOStream* _tmp1_;
		GOutputStream* _tmp2_;
		GOutputStream* _tmp3_;
		GOutputStream* _tmp4_;
		GOutputStream* _tmp5_;
		guint8* _tmp6_;
		gint _tmp6__length1;
		gint _tmp7_ = 0;
		guint8* _tmp8_;
		gint _tmp8__length1;
		_tmp0_ = g_file_open_readwrite_finish (_data10_->file, res, &_inner_error0_);
		iostream = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = iostream;
		_tmp2_ = g_io_stream_get_output_stream ((GIOStream*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		ostream = _tmp4_;
		_tmp5_ = ostream;
		_tmp6_ = string_get_data (_data10_->contents, &_tmp7_);
		_tmp6__length1 = _tmp7_;
		_tmp8_ = _tmp6_;
		_tmp8__length1 = _tmp6__length1;
		g_output_stream_write_all (_tmp5_, _tmp8_, (gsize) _tmp8__length1, NULL, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (ostream);
			_g_object_unref0 (iostream);
			goto __catch0_g_error;
		}
		_g_object_unref0 (ostream);
		_g_object_unref0 (iostream);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		gchar* _tmp9_;
		gchar* _tmp10_;
		GError* _tmp11_;
		const gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = g_file_get_basename (_data10_->file);
		_tmp10_ = _tmp9_;
		_tmp11_ = e;
		_tmp12_ = _tmp11_->message;
		g_warning ("FileManager.vala:102: Could not write file \"%s\": %s", _tmp10_, _tmp12_);
		_g_free0 (_tmp10_);
		_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;
	}
}

static void
___lambda38__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda38_ (self, source_object, res);
	block10_data_unref (self);
}

void
enotes_file_manager_write_file (GFile* file,
                                const gchar* contents,
                                gboolean overrite,
                                GError** error)
{
	Block10Data* _data10_;
	GFile* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (file != NULL);
	g_return_if_fail (contents != NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (file);
	_g_object_unref0 (_data10_->file);
	_data10_->file = _tmp0_;
	_tmp1_ = g_strdup (contents);
	_g_free0 (_data10_->contents);
	_data10_->contents = _tmp1_;
	if (g_file_query_exists (_data10_->file, NULL)) {
		_tmp2_ = overrite;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		g_file_delete (_data10_->file, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			block10_data_unref (_data10_);
			_data10_ = NULL;
			return;
		}
	}
	enotes_file_manager_create_file_if_not_exists (_data10_->file, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		block10_data_unref (_data10_);
		_data10_ = NULL;
		return;
	}
	g_file_open_readwrite_async (_data10_->file, G_PRIORITY_DEFAULT, NULL, ___lambda38__gasync_ready_callback, block10_data_ref (_data10_));
	block10_data_unref (_data10_);
	_data10_ = NULL;
}

void
enotes_file_manager_create_file_if_not_exists (GFile* file,
                                               GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (file != NULL);
	if (!g_file_query_exists (file, NULL)) {
		{
			GFileOutputStream* _tmp0_;
			GFileOutputStream* _tmp1_;
			_tmp0_ = g_file_create (file, G_FILE_CREATE_REPLACE_DESTINATION, NULL, &_inner_error0_);
			_tmp1_ = _tmp0_;
			_g_object_unref0 (_tmp1_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp2_;
			const gchar* _tmp3_;
			GError* _tmp4_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp2_ = e;
			_tmp3_ = _tmp2_->message;
			_tmp4_ = g_error_new (g_quark_from_string (""), -1, "Could not write file: %s", _tmp3_);
			_inner_error0_ = _tmp4_;
			_g_error_free0 (e);
			goto __finally0;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		_g_object_unref0 (_data11_->dialog);
		g_slice_free (Block11Data, _data11_);
	}
}

static gboolean
_gtk_file_chooser_action_equal (const GtkFileChooserAction * s1,
                                const GtkFileChooserAction * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static void
__lambda37_ (Block11Data* _data11_,
             GtkFileFilter* filter)
{
	GtkFileChooserDialog* _tmp0_;
	GtkFileFilter* _tmp1_;
	g_return_if_fail (filter != NULL);
	_tmp0_ = _data11_->dialog;
	_tmp1_ = _g_object_ref0 (filter);
	gtk_file_chooser_add_filter ((GtkFileChooser*) _tmp0_, _tmp1_);
}

static void
___lambda37__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda37_ (self, (GtkFileFilter*) data);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

GFile*
enotes_file_manager_get_file_from_user (const gchar* filetype,
                                        GtkFileChooserAction* chooser_action)
{
	Block11Data* _data11_;
	GFile* _result_ = NULL;
	gchar* title = NULL;
	gchar* _tmp0_;
	gchar* accept_button_label = NULL;
	gchar* _tmp1_;
	GList* filters = NULL;
	const gchar* _tmp2_;
	GQuark _tmp4_ = 0U;
	static GQuark _tmp3_label0 = 0;
	static GQuark _tmp3_label1 = 0;
	static GQuark _tmp3_label2 = 0;
	static GQuark _tmp3_label3 = 0;
	GtkFileChooserAction _tmp32_;
	GtkFileFilter* all_filter = NULL;
	GtkFileFilter* _tmp38_;
	GtkFileFilter* _tmp39_;
	GtkFileFilter* _tmp40_;
	GtkFileFilter* _tmp41_;
	GtkFileFilter* _tmp42_;
	const gchar* _tmp43_;
	ENotesApplication* _tmp44_;
	GtkWindow* _tmp45_;
	const gchar* _tmp46_;
	GtkFileChooserDialog* _tmp47_;
	GList* _tmp48_;
	GtkFileChooserDialog* _tmp49_;
	GtkFileChooserDialog* _tmp52_;
	GFile* result;
	g_return_val_if_fail (filetype != NULL, NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_result_ = NULL;
	_tmp0_ = g_strdup ("");
	title = _tmp0_;
	_tmp1_ = g_strdup ("");
	accept_button_label = _tmp1_;
	filters = NULL;
	_tmp2_ = filetype;
	_tmp4_ = (NULL == _tmp2_) ? 0 : g_quark_from_string (_tmp2_);
	if (_tmp4_ == ((0 != _tmp3_label0) ? _tmp3_label0 : (_tmp3_label0 = g_quark_from_static_string ("pdf")))) {
		switch (0) {
			default:
			{
				gchar* _tmp5_;
				GtkFileFilter* filter = NULL;
				GtkFileFilter* _tmp6_;
				GtkFileFilter* _tmp7_;
				GtkFileFilter* _tmp8_;
				GtkFileFilter* _tmp9_;
				GtkFileFilter* _tmp10_;
				GtkFileFilter* _tmp11_;
				_tmp5_ = g_strdup (_ ("Save as PDF"));
				_g_free0 (title);
				title = _tmp5_;
				_tmp6_ = gtk_file_filter_new ();
				g_object_ref_sink (_tmp6_);
				filter = _tmp6_;
				_tmp7_ = filter;
				gtk_file_filter_set_name (_tmp7_, _ ("PDF File"));
				_tmp8_ = filter;
				gtk_file_filter_add_mime_type (_tmp8_, "application/pdf");
				_tmp9_ = filter;
				gtk_file_filter_add_pattern (_tmp9_, "*.pdf");
				_tmp10_ = filter;
				_tmp11_ = _g_object_ref0 (_tmp10_);
				filters = g_list_append (filters, _tmp11_);
				_g_object_unref0 (filter);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label1) ? _tmp3_label1 : (_tmp3_label1 = g_quark_from_static_string ("md")))) {
		switch (0) {
			default:
			{
				gchar* _tmp12_;
				GtkFileFilter* filter = NULL;
				GtkFileFilter* _tmp13_;
				GtkFileFilter* _tmp14_;
				GtkFileFilter* _tmp15_;
				GtkFileFilter* _tmp16_;
				GtkFileFilter* _tmp17_;
				GtkFileFilter* _tmp18_;
				_tmp12_ = g_strdup (_ ("Save as Markdown"));
				_g_free0 (title);
				title = _tmp12_;
				_tmp13_ = gtk_file_filter_new ();
				g_object_ref_sink (_tmp13_);
				filter = _tmp13_;
				_tmp14_ = filter;
				gtk_file_filter_set_name (_tmp14_, _ ("Markdown File"));
				_tmp15_ = filter;
				gtk_file_filter_add_mime_type (_tmp15_, "text/markdown");
				_tmp16_ = filter;
				gtk_file_filter_add_pattern (_tmp16_, "*.md");
				_tmp17_ = filter;
				_tmp18_ = _g_object_ref0 (_tmp17_);
				filters = g_list_append (filters, _tmp18_);
				_g_object_unref0 (filter);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label2) ? _tmp3_label2 : (_tmp3_label2 = g_quark_from_static_string ("image")))) {
		switch (0) {
			default:
			{
				gchar* _tmp19_;
				GtkFileFilter* filter = NULL;
				GtkFileFilter* _tmp20_;
				GtkFileFilter* _tmp21_;
				GtkFileFilter* _tmp22_;
				GtkFileFilter* _tmp23_;
				GtkFileFilter* _tmp24_;
				_tmp19_ = g_strdup (_ ("Open Image"));
				_g_free0 (title);
				title = _tmp19_;
				_tmp20_ = gtk_file_filter_new ();
				g_object_ref_sink (_tmp20_);
				filter = _tmp20_;
				_tmp21_ = filter;
				gtk_file_filter_set_name (_tmp21_, _ ("Images"));
				_tmp22_ = filter;
				gtk_file_filter_add_mime_type (_tmp22_, "image/*");
				_tmp23_ = filter;
				_tmp24_ = _g_object_ref0 (_tmp23_);
				filters = g_list_append (filters, _tmp24_);
				_g_object_unref0 (filter);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label3) ? _tmp3_label3 : (_tmp3_label3 = g_quark_from_static_string ("ndb")))) {
		switch (0) {
			default:
			{
				gchar* _tmp25_;
				GtkFileFilter* filter = NULL;
				GtkFileFilter* _tmp26_;
				GtkFileFilter* _tmp27_;
				GtkFileFilter* _tmp28_;
				GtkFileFilter* _tmp29_;
				GtkFileFilter* _tmp30_;
				GtkFileFilter* _tmp31_;
				_tmp25_ = g_strdup (_ ("Create or Open a Notes-Up File"));
				_g_free0 (title);
				title = _tmp25_;
				_tmp26_ = gtk_file_filter_new ();
				g_object_ref_sink (_tmp26_);
				filter = _tmp26_;
				_tmp27_ = filter;
				gtk_file_filter_set_name (_tmp27_, _ ("Notes-Up Notebook"));
				_tmp28_ = filter;
				gtk_file_filter_add_mime_type (_tmp28_, "application/x-notesup");
				_tmp29_ = filter;
				gtk_file_filter_add_pattern (_tmp29_, "*.ndb");
				_tmp30_ = filter;
				_tmp31_ = _g_object_ref0 (_tmp30_);
				filters = g_list_append (filters, _tmp31_);
				_g_object_unref0 (filter);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				g_assert_not_reached ();
			}
		}
	}
	_tmp32_ = GTK_FILE_CHOOSER_ACTION_SAVE;
	if (_gtk_file_chooser_action_equal (chooser_action, &_tmp32_) == TRUE) {
		gchar* _tmp33_;
		_tmp33_ = g_strdup (_ ("Save"));
		_g_free0 (accept_button_label);
		accept_button_label = _tmp33_;
	} else {
		GtkFileChooserAction _tmp34_;
		_tmp34_ = GTK_FILE_CHOOSER_ACTION_OPEN;
		if (_gtk_file_chooser_action_equal (chooser_action, &_tmp34_) == TRUE) {
			gchar* _tmp35_;
			_tmp35_ = g_strdup (_ ("Open"));
			_g_free0 (accept_button_label);
			accept_button_label = _tmp35_;
		} else {
			gchar* _tmp36_;
			GtkFileChooserAction _tmp37_;
			_tmp36_ = g_strdup (_ ("Open or Create"));
			_g_free0 (accept_button_label);
			accept_button_label = _tmp36_;
			_tmp37_ = GTK_FILE_CHOOSER_ACTION_SAVE;
			chooser_action = &_tmp37_;
		}
	}
	_tmp38_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp38_);
	all_filter = _tmp38_;
	_tmp39_ = all_filter;
	gtk_file_filter_set_name (_tmp39_, _ ("All Files"));
	_tmp40_ = all_filter;
	gtk_file_filter_add_pattern (_tmp40_, "*");
	_tmp41_ = all_filter;
	_tmp42_ = _g_object_ref0 (_tmp41_);
	filters = g_list_append (filters, _tmp42_);
	_tmp43_ = title;
	_tmp44_ = enotes_app;
	_tmp45_ = gtk_application_get_active_window ((GtkApplication*) _tmp44_);
	_tmp46_ = accept_button_label;
	_tmp47_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp43_, _tmp45_, *chooser_action, _ ("Cancel"), GTK_RESPONSE_CANCEL, _tmp46_, GTK_RESPONSE_ACCEPT, NULL);
	g_object_ref_sink (_tmp47_);
	_data11_->dialog = _tmp47_;
	_tmp48_ = filters;
	g_list_foreach (_tmp48_, ___lambda37__gfunc, _data11_);
	_tmp49_ = _data11_->dialog;
	if (gtk_dialog_run ((GtkDialog*) _tmp49_) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserDialog* _tmp50_;
		GFile* _tmp51_;
		_tmp50_ = _data11_->dialog;
		_tmp51_ = gtk_file_chooser_get_file ((GtkFileChooser*) _tmp50_);
		_g_object_unref0 (_result_);
		_result_ = _tmp51_;
	}
	_tmp52_ = _data11_->dialog;
	g_signal_emit_by_name ((GtkDialog*) _tmp52_, "close");
	result = _result_;
	_g_object_unref0 (all_filter);
	(filters == NULL) ? NULL : (filters = (_g_list_free__g_object_unref0_ (filters), NULL));
	_g_free0 (accept_button_label);
	_g_free0 (title);
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}

ENotesFileManager*
enotes_file_manager_construct (GType object_type)
{
	ENotesFileManager * self = NULL;
	self = (ENotesFileManager*) g_object_new (object_type, NULL);
	return self;
}

ENotesFileManager*
enotes_file_manager_new (void)
{
	return enotes_file_manager_construct (ENOTES_TYPE_FILE_MANAGER);
}

static void
enotes_file_manager_class_init (ENotesFileManagerClass * klass,
                                gpointer klass_data)
{
	enotes_file_manager_parent_class = g_type_class_peek_parent (klass);
}

static void
enotes_file_manager_instance_init (ENotesFileManager * self,
                                   gpointer klass)
{
}

static GType
enotes_file_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesFileManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_file_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesFileManager), 0, (GInstanceInitFunc) enotes_file_manager_instance_init, NULL };
	GType enotes_file_manager_type_id;
	enotes_file_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "ENotesFileManager", &g_define_type_info, 0);
	return enotes_file_manager_type_id;
}

GType
enotes_file_manager_get_type (void)
{
	static volatile gsize enotes_file_manager_type_id__once = 0;
	if (g_once_init_enter (&enotes_file_manager_type_id__once)) {
		GType enotes_file_manager_type_id;
		enotes_file_manager_type_id = enotes_file_manager_get_type_once ();
		g_once_init_leave (&enotes_file_manager_type_id__once, enotes_file_manager_type_id);
	}
	return enotes_file_manager_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;
}

