/* Sidebar.c generated by valac 0.56.19, the Vala compiler
 * generated from Sidebar.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 <glib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <granite.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>

#define ENOTES_SIDEBAR_STYLE ".source-list {-gtk-icon-style: symbolic; }"
#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 GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH (granite_widgets_source_list_patch_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatch))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatchClass))
#define GRANITE_WIDGETS_IS_SOURCE_LIST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH))
#define GRANITE_WIDGETS_IS_SOURCE_LIST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatchClass))

typedef struct _GraniteWidgetsSourceListPatch GraniteWidgetsSourceListPatch;
typedef struct _GraniteWidgetsSourceListPatchClass GraniteWidgetsSourceListPatchClass;
typedef struct _GraniteWidgetsSourceListPatchPrivate GraniteWidgetsSourceListPatchPrivate;

#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM (granite_widgets_source_list_patch_item_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItem))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItemClass))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItemClass))

typedef struct _GraniteWidgetsSourceListPatchItem GraniteWidgetsSourceListPatchItem;
typedef struct _GraniteWidgetsSourceListPatchItemClass GraniteWidgetsSourceListPatchItemClass;

#define ENOTES_TYPE_SIDEBAR (enotes_sidebar_get_type ())
#define ENOTES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_SIDEBAR, ENotesSidebar))
#define ENOTES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_SIDEBAR, ENotesSidebarClass))
#define ENOTES_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_SIDEBAR))
#define ENOTES_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_SIDEBAR))
#define ENOTES_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_SIDEBAR, ENotesSidebarClass))

typedef struct _ENotesSidebar ENotesSidebar;
typedef struct _ENotesSidebarClass ENotesSidebarClass;
typedef struct _ENotesSidebarPrivate ENotesSidebarPrivate;

#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM (granite_widgets_source_list_patch_expandable_item_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItem))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItemClass))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItemClass))

typedef struct _GraniteWidgetsSourceListPatchExpandableItem GraniteWidgetsSourceListPatchExpandableItem;
typedef struct _GraniteWidgetsSourceListPatchExpandableItemClass GraniteWidgetsSourceListPatchExpandableItemClass;

#define ENOTES_TYPE_NOTEBOOK_LIST (enotes_notebook_list_get_type ())
#define ENOTES_NOTEBOOK_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_LIST, ENotesNotebookList))
#define ENOTES_NOTEBOOK_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_LIST, ENotesNotebookListClass))
#define ENOTES_IS_NOTEBOOK_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_LIST))
#define ENOTES_IS_NOTEBOOK_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_LIST))
#define ENOTES_NOTEBOOK_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_LIST, ENotesNotebookListClass))

typedef struct _ENotesNotebookList ENotesNotebookList;
typedef struct _ENotesNotebookListClass ENotesNotebookListClass;

#define ENOTES_TYPE_SIDEBAR_ITEM (enotes_sidebar_item_get_type ())
#define ENOTES_SIDEBAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItem))
#define ENOTES_SIDEBAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItemClass))
#define ENOTES_IS_SIDEBAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_SIDEBAR_ITEM))
#define ENOTES_IS_SIDEBAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_SIDEBAR_ITEM))
#define ENOTES_SIDEBAR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItemClass))

typedef struct _ENotesSidebarItem ENotesSidebarItem;
typedef struct _ENotesSidebarItemClass ENotesSidebarItemClass;

#define ENOTES_TYPE_NOTEBOOK_ITEM (enotes_notebook_item_get_type ())
#define ENOTES_NOTEBOOK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_ITEM, ENotesNotebookItem))
#define ENOTES_NOTEBOOK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_ITEM, ENotesNotebookItemClass))
#define ENOTES_IS_NOTEBOOK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_ITEM))
#define ENOTES_IS_NOTEBOOK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_ITEM))
#define ENOTES_NOTEBOOK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_ITEM, ENotesNotebookItemClass))

typedef struct _ENotesNotebookItem ENotesNotebookItem;
typedef struct _ENotesNotebookItemClass ENotesNotebookItemClass;

#define ENOTES_TYPE_TAG_ITEM (enotes_tag_item_get_type ())
#define ENOTES_TAG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAG_ITEM, ENotesTagItem))
#define ENOTES_TAG_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAG_ITEM, ENotesTagItemClass))
#define ENOTES_IS_TAG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAG_ITEM))
#define ENOTES_IS_TAG_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAG_ITEM))
#define ENOTES_TAG_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAG_ITEM, ENotesTagItemClass))

typedef struct _ENotesTagItem ENotesTagItem;
typedef struct _ENotesTagItemClass ENotesTagItemClass;
enum  {
	ENOTES_SIDEBAR_0_PROPERTY,
	ENOTES_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* enotes_sidebar_properties[ENOTES_SIDEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define ENOTES_TYPE_NOTEBOOK (enotes_notebook_get_type ())
#define ENOTES_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK, ENotesNotebook))
#define ENOTES_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK, ENotesNotebookClass))
#define ENOTES_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK))
#define ENOTES_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK))
#define ENOTES_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK, ENotesNotebookClass))

typedef struct _ENotesNotebook ENotesNotebook;
typedef struct _ENotesNotebookClass ENotesNotebookClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

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

typedef struct _ENotesApplication ENotesApplication;
typedef struct _ENotesApplicationClass ENotesApplicationClass;
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_BOOKMARK_ITEM (enotes_bookmark_item_get_type ())
#define ENOTES_BOOKMARK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItem))
#define ENOTES_BOOKMARK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItemClass))
#define ENOTES_IS_BOOKMARK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_BOOKMARK_ITEM))
#define ENOTES_IS_BOOKMARK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_BOOKMARK_ITEM))
#define ENOTES_BOOKMARK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItemClass))

typedef struct _ENotesBookmarkItem ENotesBookmarkItem;
typedef struct _ENotesBookmarkItemClass ENotesBookmarkItemClass;

#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 _ENotesPagePrivate ENotesPagePrivate;

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

typedef struct _ENotesViewEditStack ENotesViewEditStack;
typedef struct _ENotesViewEditStackClass ENotesViewEditStackClass;

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

typedef struct _ENotesEditor ENotesEditor;
typedef struct _ENotesEditorClass ENotesEditorClass;

#define ENOTES_TYPE_TAG (enotes_tag_get_type ())
#define ENOTES_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAG, ENotesTag))
#define ENOTES_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAG, ENotesTagClass))
#define ENOTES_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAG))
#define ENOTES_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAG))
#define ENOTES_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAG, ENotesTagClass))

typedef struct _ENotesTag ENotesTag;
typedef struct _ENotesTagClass ENotesTagClass;
typedef struct _ENotesNotebookPrivate ENotesNotebookPrivate;
typedef struct _GraniteWidgetsSourceListPatchItemPrivate GraniteWidgetsSourceListPatchItemPrivate;

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

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define ENOTES_TYPE_NOTEBOOK_TABLE (enotes_notebook_table_get_type ())
#define ENOTES_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTable))
#define ENOTES_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))
#define ENOTES_IS_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_IS_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_NOTEBOOK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))

typedef struct _ENotesNotebookTable ENotesNotebookTable;
typedef struct _ENotesNotebookTableClass ENotesNotebookTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define ENOTES_TYPE_BOOKMARK (enotes_bookmark_get_type ())
#define ENOTES_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_BOOKMARK, ENotesBookmark))
#define ENOTES_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_BOOKMARK, ENotesBookmarkClass))
#define ENOTES_IS_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_BOOKMARK))
#define ENOTES_IS_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_BOOKMARK))
#define ENOTES_BOOKMARK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_BOOKMARK, ENotesBookmarkClass))

typedef struct _ENotesBookmark ENotesBookmark;
typedef struct _ENotesBookmarkClass ENotesBookmarkClass;

#define ENOTES_TYPE_BOOKMARK_TABLE (enotes_bookmark_table_get_type ())
#define ENOTES_BOOKMARK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTable))
#define ENOTES_BOOKMARK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTableClass))
#define ENOTES_IS_BOOKMARK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_BOOKMARK_TABLE))
#define ENOTES_IS_BOOKMARK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_BOOKMARK_TABLE))
#define ENOTES_BOOKMARK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTableClass))

typedef struct _ENotesBookmarkTable ENotesBookmarkTable;
typedef struct _ENotesBookmarkTableClass ENotesBookmarkTableClass;

#define ENOTES_TYPE_TAGS_TABLE (enotes_tags_table_get_type ())
#define ENOTES_TAGS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTable))
#define ENOTES_TAGS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTableClass))
#define ENOTES_IS_TAGS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAGS_TABLE))
#define ENOTES_IS_TAGS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAGS_TABLE))
#define ENOTES_TAGS_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTableClass))

typedef struct _ENotesTagsTable ENotesTagsTable;
typedef struct _ENotesTagsTableClass ENotesTagsTableClass;
typedef struct _ENotesTagPrivate ENotesTagPrivate;

#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 ENOTES_TYPE_TRASH_ITEM (enotes_trash_item_get_type ())
#define ENOTES_TRASH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TRASH_ITEM, ENotesTrashItem))
#define ENOTES_TRASH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TRASH_ITEM, ENotesTrashItemClass))
#define ENOTES_IS_TRASH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TRASH_ITEM))
#define ENOTES_IS_TRASH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TRASH_ITEM))
#define ENOTES_TRASH_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TRASH_ITEM, ENotesTrashItemClass))

typedef struct _ENotesTrashItem ENotesTrashItem;
typedef struct _ENotesTrashItemClass ENotesTrashItemClass;

struct _GraniteWidgetsSourceListPatch {
	GtkScrolledWindow parent_instance;
	GraniteWidgetsSourceListPatchPrivate * priv;
};

struct _GraniteWidgetsSourceListPatchClass {
	GtkScrolledWindowClass parent_class;
	void (*item_selected) (GraniteWidgetsSourceListPatch* self, GraniteWidgetsSourceListPatchItem* item);
};

struct _ENotesSidebar {
	GraniteWidgetsSourceListPatch parent_instance;
	ENotesSidebarPrivate * priv;
};

struct _ENotesSidebarClass {
	GraniteWidgetsSourceListPatchClass parent_class;
};

struct _ENotesSidebarPrivate {
	gboolean selecting_sidebar_item;
	GraniteWidgetsSourceListPatchExpandableItem* bookmarks;
	GraniteWidgetsSourceListPatchExpandableItem* trash;
	GraniteWidgetsSourceListPatchExpandableItem* tags;
	GraniteWidgetsSourceListPatchItem* previous_selection;
	GraniteWidgetsSourceListPatchItem* all_notes;
	ENotesNotebookList* notebooks;
	GeeHashMap* added_notebooks;
	GeeHashMap* added_tags;
};

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 _ENotesNotebook {
	GObject parent_instance;
	ENotesNotebookPrivate * priv;
	gint64 id;
	gint64* parent_id;
	GdkRGBA rgb;
	gchar* name;
	gchar* css;
	gchar* stylesheet;
};

struct _ENotesNotebookClass {
	GObjectClass parent_class;
};

struct _GraniteWidgetsSourceListPatchItem {
	GObject parent_instance;
	GraniteWidgetsSourceListPatchItemPrivate * priv;
	gboolean use_pango_style;
	gboolean force_visible;
};

struct _GraniteWidgetsSourceListPatchItemClass {
	GObjectClass parent_class;
	GtkMenu* (*get_context_menu) (GraniteWidgetsSourceListPatchItem* self);
	void (*edited) (GraniteWidgetsSourceListPatchItem* self, const gchar* new_name);
	void (*action_activated) (GraniteWidgetsSourceListPatchItem* self);
	void (*activated) (GraniteWidgetsSourceListPatchItem* self);
};

struct _ENotesTag {
	GObject parent_instance;
	ENotesTagPrivate * priv;
	gint64 id;
	gchar* name;
	gchar* data;
};

struct _ENotesTagClass {
	GObjectClass parent_class;
};

static gint ENotesSidebar_private_offset;
static gpointer enotes_sidebar_parent_class = NULL;
static ENotesSidebar* enotes_sidebar_instance;
static ENotesSidebar* enotes_sidebar_instance = NULL;
VALA_EXTERN ENotesApplication* enotes_app;

VALA_EXTERN GType granite_widgets_source_list_patch_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatch, g_object_unref)
VALA_EXTERN GType granite_widgets_source_list_patch_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatchItem, g_object_unref)
VALA_EXTERN GType enotes_sidebar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesSidebar, g_object_unref)
VALA_EXTERN GType granite_widgets_source_list_patch_expandable_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatchExpandableItem, g_object_unref)
VALA_EXTERN GType enotes_notebook_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookList, g_object_unref)
VALA_EXTERN GType enotes_sidebar_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesSidebarItem, g_object_unref)
VALA_EXTERN GType enotes_notebook_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookItem, g_object_unref)
VALA_EXTERN GType enotes_tag_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTagItem, g_object_unref)
VALA_EXTERN GraniteWidgetsSourceListPatchExpandableItem* granite_widgets_source_list_patch_expandable_item_new (const gchar* name);
VALA_EXTERN GraniteWidgetsSourceListPatchExpandableItem* granite_widgets_source_list_patch_expandable_item_construct (GType object_type,
                                                                                                          const gchar* name);
VALA_EXTERN ENotesNotebookList* enotes_notebook_list_new (const gchar* name);
VALA_EXTERN ENotesNotebookList* enotes_notebook_list_construct (GType object_type,
                                                    const gchar* name);
VALA_EXTERN ENotesSidebar* enotes_sidebar_get_instance (void);
VALA_EXTERN ENotesSidebar* enotes_sidebar_new (void);
VALA_EXTERN ENotesSidebar* enotes_sidebar_construct (GType object_type);
VALA_EXTERN GraniteWidgetsSourceListPatch* granite_widgets_source_list_patch_new (GraniteWidgetsSourceListPatchExpandableItem* root);
VALA_EXTERN GraniteWidgetsSourceListPatch* granite_widgets_source_list_patch_construct (GType object_type,
                                                                            GraniteWidgetsSourceListPatchExpandableItem* root);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_icon (GraniteWidgetsSourceListPatchItem* self,
                                                      GIcon* value);
static void enotes_sidebar_build_new_ui (ENotesSidebar* self,
                                  const gchar* all_notes_title);
VALA_EXTERN GType enotes_notebook_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebook, g_object_unref)
VALA_EXTERN void enotes_sidebar_load_notebooks (ENotesSidebar* self,
                                    gboolean add_menus,
                                    ENotesNotebook* to_ignore);
VALA_EXTERN void enotes_sidebar_load_bookmarks (ENotesSidebar* self);
VALA_EXTERN void enotes_sidebar_load_tags (ENotesSidebar* self);
static void enotes_sidebar_connect_signals (ENotesSidebar* self);
VALA_EXTERN void granite_widgets_source_list_patch_expandable_item_collapse_all (GraniteWidgetsSourceListPatchExpandableItem* self,
                                                                     gboolean inclusive,
                                                                     gboolean recursive);
VALA_EXTERN GraniteWidgetsSourceListPatchExpandableItem* granite_widgets_source_list_patch_get_root (GraniteWidgetsSourceListPatch* self);
VALA_EXTERN void granite_widgets_source_list_patch_expandable_item_expand_all (GraniteWidgetsSourceListPatchExpandableItem* self,
                                                                   gboolean inclusive,
                                                                   gboolean recursive);
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 __lambda78_ (ENotesSidebar* self);
VALA_EXTERN void enotes_sidebar_first_start (ENotesSidebar* self);
VALA_EXTERN void granite_widgets_source_list_patch_expandable_item_clear (GraniteWidgetsSourceListPatchExpandableItem* self);
static void ___lambda78__enotes_application_state_post_database_change (ENotesApplicationState* _sender,
                                                                 gpointer self);
static void __lambda79_ (ENotesSidebar* self,
                  GraniteWidgetsSourceListPatchItem* item);
VALA_EXTERN GType enotes_bookmark_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesBookmarkItem, g_object_unref)
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);
VALA_EXTERN gboolean enotes_page_equals (ENotesPage* self,
                             ENotesPage* page);
VALA_EXTERN ENotesPage* enotes_bookmark_item_get_page (ENotesBookmarkItem* self);
VALA_EXTERN void enotes_application_state_open_notebook (ENotesApplicationState* self,
                                             gint64 notebook_id);
VALA_EXTERN gint64 enotes_bookmark_item_get_parent_notebook (ENotesBookmarkItem* self);
VALA_EXTERN void enotes_application_state_open_page (ENotesApplicationState* self,
                                         gint64 page_id);
VALA_EXTERN void granite_widgets_source_list_patch_set_selected (GraniteWidgetsSourceListPatch* self,
                                                     GraniteWidgetsSourceListPatchItem* value);
VALA_EXTERN GType enotes_view_edit_stack_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesViewEditStack, g_object_unref)
VALA_EXTERN ENotesViewEditStack* enotes_view_edit_stack_get_instance (void);
VALA_EXTERN GType enotes_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesEditor, g_object_unref)
VALA_EXTERN ENotesEditor* enotes_view_edit_stack_get_editor (ENotesViewEditStack* self);
VALA_EXTERN void enotes_editor_save_file (ENotesEditor* self);
VALA_EXTERN ENotesNotebook* enotes_notebook_item_get_notebook (ENotesNotebookItem* self);
VALA_EXTERN void enotes_application_state_set_opened_notebook (ENotesApplicationState* self,
                                                   ENotesNotebook* value);
VALA_EXTERN GType enotes_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTag, g_object_unref)
VALA_EXTERN ENotesTag* enotes_tag_item_get_tag (ENotesTagItem* self);
static void ___lambda79__granite_widgets_source_list_patch_item_selected (GraniteWidgetsSourceListPatch* _sender,
                                                                   GraniteWidgetsSourceListPatchItem* item,
                                                                   gpointer self);
static void __lambda80_ (ENotesSidebar* self);
VALA_EXTERN ENotesNotebook* enotes_application_state_get_opened_notebook (ENotesApplicationState* self);
static void enotes_sidebar_select_notebook (ENotesSidebar* self,
                                     gint64 notebook_id);
static void ___lambda80__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda81_ (ENotesSidebar* self);
static void ___lambda81__enotes_application_state_opened_notebook_updated (ENotesApplicationState* _sender,
                                                                    gpointer self);
static void __lambda82_ (ENotesSidebar* self);
static void ___lambda82__enotes_application_state_tags_changed (ENotesApplicationState* _sender,
                                                         gpointer self);
VALA_EXTERN ENotesSidebar* enotes_sidebar_new_notebook_list (ENotesNotebook* to_ignore);
VALA_EXTERN ENotesSidebar* enotes_sidebar_construct_notebook_list (GType object_type,
                                                       ENotesNotebook* to_ignore);
VALA_EXTERN GraniteWidgetsSourceListPatchItem* granite_widgets_source_list_patch_item_new (const gchar* name);
VALA_EXTERN GraniteWidgetsSourceListPatchItem* granite_widgets_source_list_patch_item_construct (GType object_type,
                                                                                     const gchar* name);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_selectable (GraniteWidgetsSourceListPatchItem* self,
                                                            gboolean value);
VALA_EXTERN void granite_widgets_source_list_patch_expandable_item_add (GraniteWidgetsSourceListPatchExpandableItem* self,
                                                            GraniteWidgetsSourceListPatchItem* item);
VALA_EXTERN gpointer database_table_ref (gpointer instance);
VALA_EXTERN void database_table_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_database_table (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_database_table (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_database_table (const GValue* value);
VALA_EXTERN GType database_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseTable, database_table_unref)
VALA_EXTERN GType enotes_notebook_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookTable, database_table_unref)
VALA_EXTERN ENotesNotebookTable* enotes_notebook_table_get_instance (void);
VALA_EXTERN GeeArrayList* enotes_notebook_table_get_notebooks (ENotesNotebookTable* self);
VALA_EXTERN ENotesNotebookItem* enotes_notebook_item_new (ENotesNotebook* notebook,
                                              gboolean add_menu);
VALA_EXTERN ENotesNotebookItem* enotes_notebook_item_construct (GType object_type,
                                                    ENotesNotebook* notebook,
                                                    gboolean add_menu);
static gboolean _int64_equal (const gint64 * s1,
                       const gint64 * s2);
VALA_EXTERN GType enotes_bookmark_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesBookmark, g_object_unref)
VALA_EXTERN GType enotes_bookmark_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesBookmarkTable, database_table_unref)
VALA_EXTERN ENotesBookmarkTable* enotes_bookmark_table_get_instance (void);
VALA_EXTERN GeeArrayList* enotes_bookmark_table_get_bookmarks (ENotesBookmarkTable* self);
VALA_EXTERN ENotesBookmarkItem* enotes_bookmark_item_new (ENotesBookmark* bookmark);
VALA_EXTERN ENotesBookmarkItem* enotes_bookmark_item_construct (GType object_type,
                                                    ENotesBookmark* bookmark);
VALA_EXTERN GraniteWidgetsSourceListPatchItem* granite_widgets_source_list_patch_get_selected (GraniteWidgetsSourceListPatch* self);
VALA_EXTERN GType enotes_tags_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTagsTable, database_table_unref)
VALA_EXTERN ENotesTagsTable* enotes_tags_table_get_instance (void);
VALA_EXTERN GeeArrayList* enotes_tags_table_get_tags (ENotesTagsTable* self);
VALA_EXTERN ENotesTagItem* enotes_tag_item_new (ENotesTag* tag);
VALA_EXTERN ENotesTagItem* enotes_tag_item_construct (GType object_type,
                                          ENotesTag* tag);
static void enotes_sidebar_select_tag (ENotesSidebar* self,
                                gint64 _tag);
VALA_EXTERN GeeCollection* granite_widgets_source_list_patch_expandable_item_get_children (GraniteWidgetsSourceListPatchExpandableItem* self);
static void enotes_sidebar_first_notebook (ENotesSidebar* self);
VALA_EXTERN gint64 enotes_notebook_table_new_notebook (ENotesNotebookTable* self,
                                           gint64 parent,
                                           const gchar* name,
                                           GdkRGBA* rgb,
                                           const gchar* css,
                                           const gchar* stylesheet);
static void __lambda71_ (ENotesSidebar* self,
                  ENotesNotebook* notebook);
static void ___lambda71__enotes_notebook_table_notebook_added (ENotesNotebookTable* _sender,
                                                        ENotesNotebook* notebook,
                                                        gpointer self);
static void __lambda72_ (ENotesSidebar* self,
                  ENotesNotebook* notebook);
VALA_EXTERN void enotes_notebook_item_set_notebook (ENotesNotebookItem* self,
                                        ENotesNotebook* value);
static void ___lambda72__enotes_notebook_table_notebook_changed (ENotesNotebookTable* _sender,
                                                          ENotesNotebook* notebook,
                                                          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);
static void __lambda73_ (ENotesSidebar* self,
                  ENotesPage* page);
VALA_EXTERN GType enotes_trash_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTrashItem, g_object_unref)
VALA_EXTERN ENotesTrashItem* enotes_trash_item_new_page (ENotesPage* page);
VALA_EXTERN ENotesTrashItem* enotes_trash_item_construct_page (GType object_type,
                                                   ENotesPage* page);
static void ___lambda73__enotes_trash_page_added (ENotesTrash* _sender,
                                           ENotesPage* page,
                                           gpointer self);
static void __lambda75_ (ENotesSidebar* self,
                  ENotesPage* page);
static void ___lambda75__enotes_trash_page_removed (ENotesTrash* _sender,
                                             ENotesPage* page,
                                             gpointer self);
static void __lambda76_ (ENotesSidebar* self,
                  ENotesNotebook* notebook);
VALA_EXTERN ENotesTrashItem* enotes_trash_item_new_notebook (ENotesNotebook* notebook);
VALA_EXTERN ENotesTrashItem* enotes_trash_item_construct_notebook (GType object_type,
                                                       ENotesNotebook* notebook);
static void ___lambda76__enotes_trash_notebook_added (ENotesTrash* _sender,
                                               ENotesNotebook* notebook,
                                               gpointer self);
static void __lambda77_ (ENotesSidebar* self,
                  ENotesNotebook* notebook);
static void ___lambda77__enotes_trash_notebook_removed (ENotesTrash* _sender,
                                                 ENotesNotebook* notebook,
                                                 gpointer self);
static void enotes_sidebar_finalize (GObject * obj);
static GType enotes_sidebar_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_sidebar_get_instance_private (ENotesSidebar* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesSidebar_private_offset);
}

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

ENotesSidebar*
enotes_sidebar_get_instance (void)
{
	ENotesSidebar* _tmp0_;
	ENotesSidebar* _tmp2_;
	ENotesSidebar* _tmp3_;
	ENotesSidebar* result;
	_tmp0_ = enotes_sidebar_instance;
	if (_tmp0_ == NULL) {
		ENotesSidebar* _tmp1_;
		_tmp1_ = enotes_sidebar_new ();
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (enotes_sidebar_instance);
		enotes_sidebar_instance = _tmp1_;
	}
	_tmp2_ = enotes_sidebar_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
__lambda78_ (ENotesSidebar* self)
{
	GraniteWidgetsSourceListPatchExpandableItem* _tmp0_;
	self->priv->selecting_sidebar_item = TRUE;
	enotes_sidebar_load_notebooks (self, TRUE, NULL);
	enotes_sidebar_load_bookmarks (self);
	enotes_sidebar_load_tags (self);
	enotes_sidebar_connect_signals (self);
	enotes_sidebar_first_start (self);
	_tmp0_ = self->priv->trash;
	granite_widgets_source_list_patch_expandable_item_clear (_tmp0_);
	self->priv->selecting_sidebar_item = FALSE;
}

static void
___lambda78__enotes_application_state_post_database_change (ENotesApplicationState* _sender,
                                                            gpointer self)
{
	__lambda78_ ((ENotesSidebar*) self);
}

static void
__lambda79_ (ENotesSidebar* self,
             GraniteWidgetsSourceListPatchItem* item)
{
	gboolean _tmp0_ = FALSE;
	if (self->priv->selecting_sidebar_item) {
		return;
	}
	if (item != NULL) {
		_tmp0_ = ENOTES_IS_BOOKMARK_ITEM (item);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		ENotesApplication* _tmp1_;
		ENotesApplicationState* _tmp2_;
		ENotesPage* _tmp3_;
		ENotesPage* _tmp4_;
		ENotesPage* _tmp5_;
		ENotesPage* _tmp6_;
		gboolean _tmp7_;
		_tmp1_ = enotes_app;
		_tmp2_ = _tmp1_->state;
		_tmp3_ = enotes_application_state_get_opened_page (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = enotes_bookmark_item_get_page (G_TYPE_CHECK_INSTANCE_CAST (item, ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItem));
		_tmp6_ = _tmp5_;
		_tmp7_ = enotes_page_equals (_tmp4_, _tmp6_);
		_g_object_unref0 (_tmp6_);
		if (_tmp7_) {
			ENotesApplication* _tmp8_;
			ENotesApplicationState* _tmp9_;
			gint64 _tmp10_;
			gint64 _tmp11_;
			ENotesApplication* _tmp12_;
			ENotesApplicationState* _tmp13_;
			ENotesPage* _tmp14_;
			ENotesPage* _tmp15_;
			_tmp8_ = enotes_app;
			_tmp9_ = _tmp8_->state;
			_tmp10_ = enotes_bookmark_item_get_parent_notebook (G_TYPE_CHECK_INSTANCE_CAST (item, ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItem));
			_tmp11_ = _tmp10_;
			enotes_application_state_open_notebook (_tmp9_, _tmp11_);
			_tmp12_ = enotes_app;
			_tmp13_ = _tmp12_->state;
			_tmp14_ = enotes_bookmark_item_get_page (G_TYPE_CHECK_INSTANCE_CAST (item, ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItem));
			_tmp15_ = _tmp14_;
			enotes_application_state_open_page (_tmp13_, _tmp15_->id);
			_g_object_unref0 (_tmp15_);
		} else {
			ENotesApplication* _tmp16_;
			ENotesApplicationState* _tmp17_;
			ENotesPage* _tmp18_;
			ENotesPage* _tmp19_;
			GraniteWidgetsSourceListPatchItem* _tmp20_;
			_tmp16_ = enotes_app;
			_tmp17_ = _tmp16_->state;
			_tmp18_ = enotes_bookmark_item_get_page (G_TYPE_CHECK_INSTANCE_CAST (item, ENOTES_TYPE_BOOKMARK_ITEM, ENotesBookmarkItem));
			_tmp19_ = _tmp18_;
			enotes_application_state_open_page (_tmp17_, _tmp19_->id);
			_g_object_unref0 (_tmp19_);
			_tmp20_ = self->priv->previous_selection;
			granite_widgets_source_list_patch_set_selected ((GraniteWidgetsSourceListPatch*) self, _tmp20_);
		}
	} else {
		if (ENOTES_IS_NOTEBOOK_ITEM (item)) {
			GraniteWidgetsSourceListPatchItem* _tmp21_;
			ENotesViewEditStack* _tmp22_;
			ENotesViewEditStack* _tmp23_;
			ENotesEditor* _tmp24_;
			ENotesEditor* _tmp25_;
			ENotesApplication* _tmp26_;
			ENotesApplicationState* _tmp27_;
			ENotesNotebook* _tmp28_;
			ENotesNotebook* _tmp29_;
			_tmp21_ = _g_object_ref0 (item);
			_g_object_unref0 (self->priv->previous_selection);
			self->priv->previous_selection = _tmp21_;
			_tmp22_ = enotes_view_edit_stack_get_instance ();
			_tmp23_ = _tmp22_;
			_tmp24_ = enotes_view_edit_stack_get_editor (_tmp23_);
			_tmp25_ = _tmp24_;
			enotes_editor_save_file (_tmp25_);
			_g_object_unref0 (_tmp23_);
			_tmp26_ = enotes_app;
			_tmp27_ = _tmp26_->state;
			_tmp28_ = enotes_notebook_item_get_notebook (G_TYPE_CHECK_INSTANCE_CAST (item, ENOTES_TYPE_NOTEBOOK_ITEM, ENotesNotebookItem));
			_tmp29_ = _tmp28_;
			enotes_application_state_set_opened_notebook (_tmp27_, _tmp29_);
		} else {
			if (ENOTES_IS_TAG_ITEM (item)) {
				ENotesTagItem* tag_item = NULL;
				ENotesTagItem* _tmp30_;
				ENotesApplication* _tmp31_;
				ENotesApplicationState* _tmp32_;
				ENotesApplication* _tmp33_;
				ENotesApplicationState* _tmp34_;
				ENotesTagItem* _tmp35_;
				ENotesTag* _tmp36_;
				ENotesTag* _tmp37_;
				_tmp30_ = _g_object_ref0 (ENOTES_IS_TAG_ITEM (item) ? ((ENotesTagItem*) item) : NULL);
				tag_item = _tmp30_;
				_tmp31_ = enotes_app;
				_tmp32_ = _tmp31_->state;
				enotes_application_state_set_opened_notebook (_tmp32_, NULL);
				_tmp33_ = enotes_app;
				_tmp34_ = _tmp33_->state;
				_tmp35_ = tag_item;
				_tmp36_ = enotes_tag_item_get_tag (_tmp35_);
				_tmp37_ = _tmp36_;
				g_signal_emit_by_name (_tmp34_, "show-pages-in-tag", _tmp37_);
				_g_object_unref0 (tag_item);
			} else {
				GraniteWidgetsSourceListPatchItem* _tmp38_;
				_tmp38_ = self->priv->all_notes;
				if (item == _tmp38_) {
					ENotesApplication* _tmp39_;
					ENotesApplicationState* _tmp40_;
					ENotesApplication* _tmp41_;
					ENotesApplicationState* _tmp42_;
					_tmp39_ = enotes_app;
					_tmp40_ = _tmp39_->state;
					enotes_application_state_set_opened_notebook (_tmp40_, NULL);
					_tmp41_ = enotes_app;
					_tmp42_ = _tmp41_->state;
					g_signal_emit_by_name (_tmp42_, "show-all-pages");
				}
			}
		}
	}
}

static void
___lambda79__granite_widgets_source_list_patch_item_selected (GraniteWidgetsSourceListPatch* _sender,
                                                              GraniteWidgetsSourceListPatchItem* item,
                                                              gpointer self)
{
	__lambda79_ ((ENotesSidebar*) self, item);
}

static void
__lambda80_ (ENotesSidebar* self)
{
	ENotesNotebook* notebook = NULL;
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesNotebook* _tmp2_;
	ENotesNotebook* _tmp3_;
	ENotesNotebook* _tmp4_;
	ENotesNotebook* _tmp5_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_notebook (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	notebook = _tmp4_;
	_tmp5_ = notebook;
	if (_tmp5_ != NULL) {
		ENotesNotebook* _tmp6_;
		_tmp6_ = notebook;
		enotes_sidebar_select_notebook (self, _tmp6_->id);
	}
	_g_object_unref0 (notebook);
}

static void
___lambda80__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda80_ ((ENotesSidebar*) self);
}

static void
__lambda81_ (ENotesSidebar* self)
{
	enotes_sidebar_load_notebooks (self, TRUE, NULL);
}

static void
___lambda81__enotes_application_state_opened_notebook_updated (ENotesApplicationState* _sender,
                                                               gpointer self)
{
	__lambda81_ ((ENotesSidebar*) self);
}

static void
__lambda82_ (ENotesSidebar* self)
{
	enotes_sidebar_load_tags (self);
}

static void
___lambda82__enotes_application_state_tags_changed (ENotesApplicationState* _sender,
                                                    gpointer self)
{
	__lambda82_ ((ENotesSidebar*) self);
}

ENotesSidebar*
enotes_sidebar_construct (GType object_type)
{
	ENotesSidebar * self = NULL;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp0_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp1_;
	ENotesNotebookList* _tmp2_;
	GThemedIcon* _tmp3_;
	GThemedIcon* _tmp4_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp5_;
	GThemedIcon* _tmp6_;
	GThemedIcon* _tmp7_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp8_;
	GThemedIcon* _tmp9_;
	GThemedIcon* _tmp10_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp11_;
	GThemedIcon* _tmp12_;
	GThemedIcon* _tmp13_;
	ENotesNotebookList* _tmp14_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp15_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp16_;
	ENotesApplication* _tmp24_;
	ENotesApplicationState* _tmp25_;
	ENotesApplication* _tmp26_;
	ENotesApplicationState* _tmp27_;
	ENotesApplication* _tmp28_;
	ENotesApplicationState* _tmp29_;
	ENotesApplication* _tmp30_;
	ENotesApplicationState* _tmp31_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = granite_widgets_source_list_patch_expandable_item_new ("");
	_tmp1_ = _tmp0_;
	self = (ENotesSidebar*) granite_widgets_source_list_patch_construct (object_type, _tmp1_);
	_g_object_unref0 (_tmp1_);
	self->priv->selecting_sidebar_item = TRUE;
	_tmp2_ = self->priv->notebooks;
	_tmp3_ = (GThemedIcon*) g_themed_icon_new ("notebook-symbolic");
	_tmp4_ = _tmp3_;
	granite_widgets_source_list_patch_item_set_icon ((GraniteWidgetsSourceListPatchItem*) _tmp2_, (GIcon*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = self->priv->trash;
	_tmp6_ = (GThemedIcon*) g_themed_icon_new ("edit-delete-symbolic");
	_tmp7_ = _tmp6_;
	granite_widgets_source_list_patch_item_set_icon ((GraniteWidgetsSourceListPatchItem*) _tmp5_, (GIcon*) _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->tags;
	_tmp9_ = (GThemedIcon*) g_themed_icon_new ("tag-symbolic");
	_tmp10_ = _tmp9_;
	granite_widgets_source_list_patch_item_set_icon ((GraniteWidgetsSourceListPatchItem*) _tmp8_, (GIcon*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->bookmarks;
	_tmp12_ = (GThemedIcon*) g_themed_icon_new ("user-bookmarks-symbolic");
	_tmp13_ = _tmp12_;
	granite_widgets_source_list_patch_item_set_icon ((GraniteWidgetsSourceListPatchItem*) _tmp11_, (GIcon*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	enotes_sidebar_build_new_ui (self, _ ("All Notes"));
	enotes_sidebar_load_notebooks (self, TRUE, NULL);
	enotes_sidebar_load_bookmarks (self);
	enotes_sidebar_load_tags (self);
	enotes_sidebar_connect_signals (self);
	_tmp14_ = self->priv->notebooks;
	granite_widgets_source_list_patch_expandable_item_collapse_all ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp14_, TRUE, TRUE);
	_tmp15_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp16_ = _tmp15_;
	granite_widgets_source_list_patch_expandable_item_expand_all (_tmp16_, FALSE, FALSE);
	self->priv->selecting_sidebar_item = FALSE;
	{
		GtkCssProvider* provider = NULL;
		GtkCssProvider* _tmp17_;
		GtkWidget* _tmp18_;
		GtkStyleContext* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		_tmp17_ = gtk_css_provider_new ();
		provider = _tmp17_;
		_tmp18_ = gtk_bin_get_child ((GtkBin*) self);
		_tmp19_ = gtk_widget_get_style_context (_tmp18_);
		gtk_style_context_add_provider (_tmp19_, (GtkStyleProvider*) provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
		_tmp20_ = strlen (ENOTES_SIDEBAR_STYLE);
		_tmp21_ = _tmp20_;
		gtk_css_provider_load_from_data (provider, ENOTES_SIDEBAR_STYLE, (gssize) _tmp21_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (provider);
			goto __catch0_g_error;
		}
		_g_object_unref0 (provider);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp22_;
		const gchar* _tmp23_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp22_ = e;
		_tmp23_ = _tmp22_->message;
		g_warning ("Sidebar.vala:71: Style error: %s", _tmp23_);
		_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 NULL;
	}
	_tmp24_ = enotes_app;
	_tmp25_ = _tmp24_->state;
	g_signal_connect_object (_tmp25_, "post-database-change", (GCallback) ___lambda78__enotes_application_state_post_database_change, self, 0);
	g_signal_connect_object ((GraniteWidgetsSourceListPatch*) self, "item-selected", (GCallback) ___lambda79__granite_widgets_source_list_patch_item_selected, self, 0);
	_tmp26_ = enotes_app;
	_tmp27_ = _tmp26_->state;
	g_signal_connect_object ((GObject*) _tmp27_, "notify::opened-notebook", (GCallback) ___lambda80__g_object_notify, self, 0);
	_tmp28_ = enotes_app;
	_tmp29_ = _tmp28_->state;
	g_signal_connect_object (_tmp29_, "opened-notebook-updated", (GCallback) ___lambda81__enotes_application_state_opened_notebook_updated, self, 0);
	_tmp30_ = enotes_app;
	_tmp31_ = _tmp30_->state;
	g_signal_connect_object (_tmp31_, "tags-changed", (GCallback) ___lambda82__enotes_application_state_tags_changed, self, 0);
	return self;
}

ENotesSidebar*
enotes_sidebar_new (void)
{
	return enotes_sidebar_construct (ENOTES_TYPE_SIDEBAR);
}

ENotesSidebar*
enotes_sidebar_construct_notebook_list (GType object_type,
                                        ENotesNotebook* to_ignore)
{
	ENotesSidebar * self = NULL;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp0_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp1_;
	GtkWidget* _tmp2_;
	GtkStyleContext* _tmp3_;
	GtkWidget* _tmp4_;
	GtkStyleContext* _tmp5_;
	GraniteWidgetsSourceListPatchItem* _tmp6_;
	ENotesNotebookList* _tmp7_;
	_tmp0_ = granite_widgets_source_list_patch_expandable_item_new ("");
	_tmp1_ = _tmp0_;
	self = (ENotesSidebar*) granite_widgets_source_list_patch_construct (object_type, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gtk_bin_get_child ((GtkBin*) self);
	_tmp3_ = gtk_widget_get_style_context (_tmp2_);
	gtk_style_context_remove_class (_tmp3_, "source-list");
	_tmp4_ = gtk_bin_get_child ((GtkBin*) self);
	_tmp5_ = gtk_widget_get_style_context (_tmp4_);
	gtk_style_context_remove_class (_tmp5_, "view");
	enotes_sidebar_build_new_ui (self, _ ("Without a Section"));
	_tmp6_ = self->priv->all_notes;
	_tmp6_->use_pango_style = FALSE;
	_tmp7_ = self->priv->notebooks;
	granite_widgets_source_list_patch_expandable_item_expand_all ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp7_, TRUE, FALSE);
	enotes_sidebar_load_notebooks (self, FALSE, to_ignore);
	return self;
}

ENotesSidebar*
enotes_sidebar_new_notebook_list (ENotesNotebook* to_ignore)
{
	return enotes_sidebar_construct_notebook_list (ENOTES_TYPE_SIDEBAR, to_ignore);
}

static void
enotes_sidebar_build_new_ui (ENotesSidebar* self,
                             const gchar* all_notes_title)
{
	GraniteWidgetsSourceListPatchItem* _tmp0_;
	GraniteWidgetsSourceListPatchItem* _tmp1_;
	GThemedIcon* _tmp2_;
	GThemedIcon* _tmp3_;
	GraniteWidgetsSourceListPatchItem* _tmp4_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp5_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp6_;
	GraniteWidgetsSourceListPatchItem* _tmp7_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp8_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp9_;
	ENotesNotebookList* _tmp10_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp11_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp12_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp13_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp14_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp15_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp16_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp17_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp18_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (all_notes_title != NULL);
	_tmp0_ = granite_widgets_source_list_patch_item_new (all_notes_title);
	_g_object_unref0 (self->priv->all_notes);
	self->priv->all_notes = _tmp0_;
	_tmp1_ = self->priv->all_notes;
	_tmp2_ = (GThemedIcon*) g_themed_icon_new ("text-x-generic-symbolic");
	_tmp3_ = _tmp2_;
	granite_widgets_source_list_patch_item_set_icon (_tmp1_, (GIcon*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->all_notes;
	granite_widgets_source_list_patch_item_set_selectable (_tmp4_, TRUE);
	_tmp5_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->all_notes;
	granite_widgets_source_list_patch_expandable_item_add (_tmp6_, _tmp7_);
	_tmp8_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = self->priv->notebooks;
	granite_widgets_source_list_patch_expandable_item_add (_tmp9_, (GraniteWidgetsSourceListPatchItem*) _tmp10_);
	_tmp11_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp12_ = _tmp11_;
	_tmp13_ = self->priv->bookmarks;
	granite_widgets_source_list_patch_expandable_item_add (_tmp12_, (GraniteWidgetsSourceListPatchItem*) _tmp13_);
	_tmp14_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp15_ = _tmp14_;
	_tmp16_ = self->priv->tags;
	granite_widgets_source_list_patch_expandable_item_add (_tmp15_, (GraniteWidgetsSourceListPatchItem*) _tmp16_);
	_tmp17_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
	_tmp18_ = _tmp17_;
	_tmp19_ = self->priv->trash;
	granite_widgets_source_list_patch_expandable_item_add (_tmp18_, (GraniteWidgetsSourceListPatchItem*) _tmp19_);
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	g_object_set ((GtkWidget*) self, "width-request", 150, NULL);
}

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

void
enotes_sidebar_load_notebooks (ENotesSidebar* self,
                               gboolean add_menus,
                               ENotesNotebook* to_ignore)
{
	ENotesNotebookList* _tmp0_;
	GeeArrayList* notebook_list = NULL;
	ENotesNotebookTable* _tmp1_;
	ENotesNotebookTable* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeHashMap* _tmp5_;
	GeeArrayList* to_add = NULL;
	GeeArrayList* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->notebooks;
	granite_widgets_source_list_patch_expandable_item_clear ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp0_);
	_tmp1_ = enotes_notebook_table_get_instance ();
	_tmp2_ = _tmp1_;
	_tmp3_ = enotes_notebook_table_get_notebooks (_tmp2_);
	_tmp4_ = _tmp3_;
	_database_table_unref0 (_tmp2_);
	notebook_list = _tmp4_;
	_tmp5_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, ENOTES_TYPE_NOTEBOOK_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->added_notebooks);
	self->priv->added_notebooks = _tmp5_;
	_tmp6_ = gee_array_list_new (ENOTES_TYPE_NOTEBOOK_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	to_add = _tmp6_;
	{
		GeeArrayList* _notebook_list = NULL;
		GeeArrayList* _tmp7_;
		gint _notebook_size = 0;
		GeeArrayList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		gint _notebook_index = 0;
		_tmp7_ = notebook_list;
		_notebook_list = _tmp7_;
		_tmp8_ = _notebook_list;
		_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		_notebook_size = _tmp10_;
		_notebook_index = -1;
		while (TRUE) {
			gint _tmp11_;
			gint _tmp12_;
			ENotesNotebook* notebook = NULL;
			GeeArrayList* _tmp13_;
			gpointer _tmp14_;
			ENotesNotebookItem* item = NULL;
			ENotesNotebook* _tmp15_;
			ENotesNotebookItem* _tmp16_;
			GeeHashMap* _tmp17_;
			ENotesNotebook* _tmp18_;
			ENotesNotebookItem* _tmp19_;
			gboolean _tmp20_ = FALSE;
			ENotesNotebook* _tmp22_;
			gint64* _tmp23_;
			gint64 _tmp24_;
			_notebook_index = _notebook_index + 1;
			_tmp11_ = _notebook_index;
			_tmp12_ = _notebook_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _notebook_list;
			_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, _notebook_index);
			notebook = (ENotesNotebook*) _tmp14_;
			_tmp15_ = notebook;
			_tmp16_ = enotes_notebook_item_new (_tmp15_, add_menus);
			item = _tmp16_;
			_tmp17_ = self->priv->added_notebooks;
			_tmp18_ = notebook;
			_tmp19_ = item;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp17_, (gpointer) ((gintptr) _tmp18_->id), _tmp19_);
			if (to_ignore != NULL) {
				ENotesNotebook* _tmp21_;
				_tmp21_ = notebook;
				_tmp20_ = to_ignore->id == _tmp21_->id;
			} else {
				_tmp20_ = FALSE;
			}
			if (_tmp20_) {
				_g_object_unref0 (item);
				_g_object_unref0 (notebook);
				continue;
			}
			_tmp22_ = notebook;
			_tmp23_ = _tmp22_->parent_id;
			_tmp24_ = (gint64) 0;
			if (_int64_equal (_tmp23_, &_tmp24_) == TRUE) {
				if (add_menus) {
					ENotesNotebookList* _tmp25_;
					ENotesNotebookItem* _tmp26_;
					_tmp25_ = self->priv->notebooks;
					_tmp26_ = item;
					granite_widgets_source_list_patch_expandable_item_add ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp25_, (GraniteWidgetsSourceListPatchItem*) _tmp26_);
				} else {
					GraniteWidgetsSourceListPatchExpandableItem* _tmp27_;
					GraniteWidgetsSourceListPatchExpandableItem* _tmp28_;
					ENotesNotebookItem* _tmp29_;
					_tmp27_ = granite_widgets_source_list_patch_get_root ((GraniteWidgetsSourceListPatch*) self);
					_tmp28_ = _tmp27_;
					_tmp29_ = item;
					granite_widgets_source_list_patch_expandable_item_add (_tmp28_, (GraniteWidgetsSourceListPatchItem*) _tmp29_);
				}
			} else {
				GeeArrayList* _tmp30_;
				ENotesNotebookItem* _tmp31_;
				_tmp30_ = to_add;
				_tmp31_ = item;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp30_, _tmp31_);
			}
			_g_object_unref0 (item);
			_g_object_unref0 (notebook);
		}
	}
	{
		GeeArrayList* _item_list = NULL;
		GeeArrayList* _tmp32_;
		gint _item_size = 0;
		GeeArrayList* _tmp33_;
		gint _tmp34_;
		gint _tmp35_;
		gint _item_index = 0;
		_tmp32_ = to_add;
		_item_list = _tmp32_;
		_tmp33_ = _item_list;
		_tmp34_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp33_);
		_tmp35_ = _tmp34_;
		_item_size = _tmp35_;
		_item_index = -1;
		while (TRUE) {
			gint _tmp36_;
			gint _tmp37_;
			ENotesNotebookItem* item = NULL;
			GeeArrayList* _tmp38_;
			gpointer _tmp39_;
			GeeHashMap* _tmp40_;
			ENotesNotebookItem* _tmp41_;
			ENotesNotebook* _tmp42_;
			ENotesNotebook* _tmp43_;
			gint64* _tmp44_;
			_item_index = _item_index + 1;
			_tmp36_ = _item_index;
			_tmp37_ = _item_size;
			if (!(_tmp36_ < _tmp37_)) {
				break;
			}
			_tmp38_ = _item_list;
			_tmp39_ = gee_abstract_list_get ((GeeAbstractList*) _tmp38_, _item_index);
			item = (ENotesNotebookItem*) _tmp39_;
			_tmp40_ = self->priv->added_notebooks;
			_tmp41_ = item;
			_tmp42_ = enotes_notebook_item_get_notebook (_tmp41_);
			_tmp43_ = _tmp42_;
			_tmp44_ = _tmp43_->parent_id;
			if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp40_, (gpointer) ((gintptr) (*_tmp44_)))) {
				GeeHashMap* _tmp45_;
				ENotesNotebookItem* _tmp46_;
				ENotesNotebook* _tmp47_;
				ENotesNotebook* _tmp48_;
				gint64* _tmp49_;
				gpointer _tmp50_;
				ENotesNotebookItem* _tmp51_;
				ENotesNotebookItem* _tmp52_;
				_tmp45_ = self->priv->added_notebooks;
				_tmp46_ = item;
				_tmp47_ = enotes_notebook_item_get_notebook (_tmp46_);
				_tmp48_ = _tmp47_;
				_tmp49_ = _tmp48_->parent_id;
				_tmp50_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp45_, (gpointer) ((gintptr) (*_tmp49_)));
				_tmp51_ = (ENotesNotebookItem*) _tmp50_;
				_tmp52_ = item;
				granite_widgets_source_list_patch_expandable_item_add ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp51_, (GraniteWidgetsSourceListPatchItem*) _tmp52_);
				_g_object_unref0 (_tmp51_);
			}
			_g_object_unref0 (item);
		}
	}
	_g_object_unref0 (to_add);
	_g_object_unref0 (notebook_list);
}

void
enotes_sidebar_load_bookmarks (ENotesSidebar* self)
{
	GraniteWidgetsSourceListPatchExpandableItem* _tmp0_;
	GeeArrayList* bookmark_list = NULL;
	ENotesBookmarkTable* _tmp1_;
	ENotesBookmarkTable* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->bookmarks;
	granite_widgets_source_list_patch_expandable_item_clear (_tmp0_);
	_tmp1_ = enotes_bookmark_table_get_instance ();
	_tmp2_ = _tmp1_;
	_tmp3_ = enotes_bookmark_table_get_bookmarks (_tmp2_);
	_tmp4_ = _tmp3_;
	_database_table_unref0 (_tmp2_);
	bookmark_list = _tmp4_;
	{
		GeeArrayList* _bm_list = NULL;
		GeeArrayList* _tmp5_;
		gint _bm_size = 0;
		GeeArrayList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _bm_index = 0;
		_tmp5_ = bookmark_list;
		_bm_list = _tmp5_;
		_tmp6_ = _bm_list;
		_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_bm_size = _tmp8_;
		_bm_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			ENotesBookmark* bm = NULL;
			GeeArrayList* _tmp11_;
			gpointer _tmp12_;
			ENotesBookmarkItem* bookmark = NULL;
			ENotesBookmark* _tmp13_;
			ENotesBookmarkItem* _tmp14_;
			GraniteWidgetsSourceListPatchExpandableItem* _tmp15_;
			ENotesBookmarkItem* _tmp16_;
			_bm_index = _bm_index + 1;
			_tmp9_ = _bm_index;
			_tmp10_ = _bm_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _bm_list;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _bm_index);
			bm = (ENotesBookmark*) _tmp12_;
			_tmp13_ = bm;
			_tmp14_ = enotes_bookmark_item_new (_tmp13_);
			bookmark = _tmp14_;
			_tmp15_ = self->priv->bookmarks;
			_tmp16_ = bookmark;
			granite_widgets_source_list_patch_expandable_item_add (_tmp15_, (GraniteWidgetsSourceListPatchItem*) _tmp16_);
			_g_object_unref0 (bookmark);
			_g_object_unref0 (bm);
		}
	}
	_tmp17_ = self->priv->bookmarks;
	granite_widgets_source_list_patch_expandable_item_expand_all (_tmp17_, TRUE, TRUE);
	_g_object_unref0 (bookmark_list);
}

void
enotes_sidebar_load_tags (ENotesSidebar* self)
{
	ENotesTagItem* last_tag_selected = NULL;
	GraniteWidgetsSourceListPatchItem* _tmp0_;
	GraniteWidgetsSourceListPatchItem* _tmp1_;
	ENotesTagItem* _tmp2_;
	GeeHashMap* _tmp3_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp4_;
	GeeArrayList* tags_list = NULL;
	ENotesTagsTable* _tmp5_;
	ENotesTagsTable* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp24_;
	ENotesTagItem* _tmp25_;
	g_return_if_fail (self != NULL);
	self->priv->selecting_sidebar_item = TRUE;
	_tmp0_ = granite_widgets_source_list_patch_get_selected ((GraniteWidgetsSourceListPatch*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (ENOTES_IS_TAG_ITEM (_tmp1_) ? ((ENotesTagItem*) _tmp1_) : NULL);
	last_tag_selected = _tmp2_;
	_tmp3_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, ENOTES_TYPE_TAG_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->added_tags);
	self->priv->added_tags = _tmp3_;
	_tmp4_ = self->priv->tags;
	granite_widgets_source_list_patch_expandable_item_clear (_tmp4_);
	_tmp5_ = enotes_tags_table_get_instance ();
	_tmp6_ = _tmp5_;
	_tmp7_ = enotes_tags_table_get_tags (_tmp6_);
	_tmp8_ = _tmp7_;
	_database_table_unref0 (_tmp6_);
	tags_list = _tmp8_;
	{
		GeeArrayList* _tag_list = NULL;
		GeeArrayList* _tmp9_;
		gint _tag_size = 0;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		gint _tag_index = 0;
		_tmp9_ = tags_list;
		_tag_list = _tmp9_;
		_tmp10_ = _tag_list;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tag_size = _tmp12_;
		_tag_index = -1;
		while (TRUE) {
			gint _tmp13_;
			gint _tmp14_;
			ENotesTag* tag = NULL;
			GeeArrayList* _tmp15_;
			gpointer _tmp16_;
			ENotesTagItem* tag_item = NULL;
			ENotesTag* _tmp17_;
			ENotesTagItem* _tmp18_;
			GraniteWidgetsSourceListPatchExpandableItem* _tmp19_;
			ENotesTagItem* _tmp20_;
			GeeHashMap* _tmp21_;
			ENotesTag* _tmp22_;
			ENotesTagItem* _tmp23_;
			_tag_index = _tag_index + 1;
			_tmp13_ = _tag_index;
			_tmp14_ = _tag_size;
			if (!(_tmp13_ < _tmp14_)) {
				break;
			}
			_tmp15_ = _tag_list;
			_tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _tag_index);
			tag = (ENotesTag*) _tmp16_;
			_tmp17_ = tag;
			_tmp18_ = enotes_tag_item_new (_tmp17_);
			tag_item = _tmp18_;
			_tmp19_ = self->priv->tags;
			_tmp20_ = tag_item;
			granite_widgets_source_list_patch_expandable_item_add (_tmp19_, (GraniteWidgetsSourceListPatchItem*) _tmp20_);
			_tmp21_ = self->priv->added_tags;
			_tmp22_ = tag;
			_tmp23_ = tag_item;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp21_, (gpointer) ((gintptr) _tmp22_->id), _tmp23_);
			_g_object_unref0 (tag_item);
			_g_object_unref0 (tag);
		}
	}
	_tmp24_ = self->priv->tags;
	granite_widgets_source_list_patch_expandable_item_expand_all (_tmp24_, TRUE, TRUE);
	self->priv->selecting_sidebar_item = FALSE;
	_tmp25_ = last_tag_selected;
	if (_tmp25_ != NULL) {
		ENotesTagItem* _tmp26_;
		ENotesTag* _tmp27_;
		ENotesTag* _tmp28_;
		_tmp26_ = last_tag_selected;
		_tmp27_ = enotes_tag_item_get_tag (_tmp26_);
		_tmp28_ = _tmp27_;
		enotes_sidebar_select_tag (self, _tmp28_->id);
	}
	_g_object_unref0 (tags_list);
	_g_object_unref0 (last_tag_selected);
}

static void
enotes_sidebar_select_tag (ENotesSidebar* self,
                           gint64 _tag)
{
	gint tag = 0;
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	tag = (gint) _tag;
	_tmp0_ = self->priv->added_tags;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, (gpointer) ((gintptr) tag))) {
		ENotesTagItem* to_select = NULL;
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		ENotesTagItem* _tmp3_;
		_tmp1_ = self->priv->added_tags;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, (gpointer) ((gintptr) tag));
		to_select = (ENotesTagItem*) _tmp2_;
		_tmp3_ = to_select;
		granite_widgets_source_list_patch_set_selected ((GraniteWidgetsSourceListPatch*) self, (GraniteWidgetsSourceListPatchItem*) _tmp3_);
		_g_object_unref0 (to_select);
	}
}

static void
enotes_sidebar_select_notebook (ENotesSidebar* self,
                                gint64 notebook_id)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->selecting_sidebar_item = TRUE;
	_tmp0_ = self->priv->added_notebooks;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, (gpointer) ((gintptr) notebook_id))) {
		ENotesNotebookItem* last_selected = NULL;
		GraniteWidgetsSourceListPatchItem* _tmp1_;
		GraniteWidgetsSourceListPatchItem* _tmp2_;
		ENotesNotebookItem* _tmp3_;
		gboolean _tmp4_ = FALSE;
		ENotesNotebookItem* _tmp5_;
		_tmp1_ = granite_widgets_source_list_patch_get_selected ((GraniteWidgetsSourceListPatch*) self);
		_tmp2_ = _tmp1_;
		_tmp3_ = _g_object_ref0 (ENOTES_IS_NOTEBOOK_ITEM (_tmp2_) ? ((ENotesNotebookItem*) _tmp2_) : NULL);
		last_selected = _tmp3_;
		_tmp5_ = last_selected;
		if (_tmp5_ != NULL) {
			ENotesNotebookItem* _tmp6_;
			ENotesNotebook* _tmp7_;
			ENotesNotebook* _tmp8_;
			_tmp6_ = last_selected;
			_tmp7_ = enotes_notebook_item_get_notebook (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp4_ = _tmp8_->id != notebook_id;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			ENotesNotebookItem* to_select = NULL;
			GeeHashMap* _tmp9_;
			gpointer _tmp10_;
			ENotesNotebookItem* _tmp11_;
			ENotesNotebookItem* _tmp12_;
			ENotesNotebookItem* _tmp13_;
			_tmp9_ = self->priv->added_notebooks;
			_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp9_, (gpointer) ((gintptr) notebook_id));
			_tmp11_ = (ENotesNotebookItem*) _tmp10_;
			_tmp12_ = ENOTES_IS_NOTEBOOK_ITEM (_tmp11_) ? ((ENotesNotebookItem*) _tmp11_) : NULL;
			if (_tmp12_ == NULL) {
				_g_object_unref0 (_tmp11_);
			}
			to_select = _tmp12_;
			_tmp13_ = to_select;
			granite_widgets_source_list_patch_set_selected ((GraniteWidgetsSourceListPatch*) self, (GraniteWidgetsSourceListPatchItem*) _tmp13_);
			_g_object_unref0 (to_select);
		} else {
			gboolean _tmp14_ = FALSE;
			ENotesNotebookItem* _tmp15_;
			_tmp15_ = last_selected;
			if (_tmp15_ == NULL) {
				_tmp14_ = TRUE;
			} else {
				GraniteWidgetsSourceListPatchItem* _tmp16_;
				GraniteWidgetsSourceListPatchItem* _tmp17_;
				_tmp16_ = granite_widgets_source_list_patch_get_selected ((GraniteWidgetsSourceListPatch*) self);
				_tmp17_ = _tmp16_;
				_tmp14_ = _tmp17_ == NULL;
			}
			if (_tmp14_) {
				ENotesNotebookItem* to_select = NULL;
				GeeHashMap* _tmp18_;
				gpointer _tmp19_;
				ENotesNotebookItem* _tmp20_;
				ENotesNotebookItem* _tmp21_;
				ENotesNotebookItem* _tmp22_;
				_tmp18_ = self->priv->added_notebooks;
				_tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp18_, (gpointer) ((gintptr) notebook_id));
				_tmp20_ = (ENotesNotebookItem*) _tmp19_;
				_tmp21_ = ENOTES_IS_NOTEBOOK_ITEM (_tmp20_) ? ((ENotesNotebookItem*) _tmp20_) : NULL;
				if (_tmp21_ == NULL) {
					_g_object_unref0 (_tmp20_);
				}
				to_select = _tmp21_;
				_tmp22_ = to_select;
				granite_widgets_source_list_patch_set_selected ((GraniteWidgetsSourceListPatch*) self, (GraniteWidgetsSourceListPatchItem*) _tmp22_);
				_g_object_unref0 (to_select);
			}
		}
		_g_object_unref0 (last_selected);
	}
	self->priv->selecting_sidebar_item = FALSE;
}

void
enotes_sidebar_first_start (ENotesSidebar* self)
{
	ENotesNotebookList* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->notebooks;
	_tmp1_ = granite_widgets_source_list_patch_expandable_item_get_children ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_collection_get_is_empty (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp3_);
	if (_tmp6_) {
		enotes_sidebar_first_notebook (self);
	}
}

static void
enotes_sidebar_first_notebook (ENotesSidebar* self)
{
	gint64 notebook_id = 0LL;
	ENotesNotebookTable* _tmp0_;
	ENotesNotebookTable* _tmp1_;
	GdkRGBA _tmp2_ = {0};
	gint64 _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_notebook_table_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_.red = (gdouble) 1;
	_tmp2_.green = (gdouble) 0;
	_tmp2_.blue = (gdouble) 0;
	_tmp3_ = enotes_notebook_table_new_notebook (_tmp1_, (gint64) 0, _ ("My Notes"), &_tmp2_, "", "");
	_database_table_unref0 (_tmp1_);
	notebook_id = _tmp3_;
	enotes_sidebar_load_notebooks (self, TRUE, NULL);
	enotes_sidebar_select_notebook (self, notebook_id);
}

static void
__lambda71_ (ENotesSidebar* self,
             ENotesNotebook* notebook)
{
	ENotesNotebookItem* item = NULL;
	ENotesNotebookItem* _tmp0_;
	gint parent_id = 0;
	gint64* _tmp1_;
	GeeHashMap* _tmp9_;
	ENotesNotebookItem* _tmp10_;
	g_return_if_fail (notebook != NULL);
	_tmp0_ = enotes_notebook_item_new (notebook, TRUE);
	item = _tmp0_;
	_tmp1_ = notebook->parent_id;
	parent_id = (gint) (*_tmp1_);
	if (parent_id == 0) {
		ENotesNotebookList* _tmp2_;
		ENotesNotebookItem* _tmp3_;
		_tmp2_ = self->priv->notebooks;
		_tmp3_ = item;
		granite_widgets_source_list_patch_expandable_item_add ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp2_, (GraniteWidgetsSourceListPatchItem*) _tmp3_);
	} else {
		GeeHashMap* _tmp4_;
		_tmp4_ = self->priv->added_notebooks;
		if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp4_, (gpointer) ((gintptr) parent_id))) {
			GeeHashMap* _tmp5_;
			gpointer _tmp6_;
			ENotesNotebookItem* _tmp7_;
			ENotesNotebookItem* _tmp8_;
			_tmp5_ = self->priv->added_notebooks;
			_tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, (gpointer) ((gintptr) parent_id));
			_tmp7_ = (ENotesNotebookItem*) _tmp6_;
			_tmp8_ = item;
			granite_widgets_source_list_patch_expandable_item_add ((GraniteWidgetsSourceListPatchExpandableItem*) _tmp7_, (GraniteWidgetsSourceListPatchItem*) _tmp8_);
			_g_object_unref0 (_tmp7_);
		}
	}
	_tmp9_ = self->priv->added_notebooks;
	_tmp10_ = item;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, (gpointer) ((gintptr) notebook->id), _tmp10_);
	_g_object_unref0 (item);
}

static void
___lambda71__enotes_notebook_table_notebook_added (ENotesNotebookTable* _sender,
                                                   ENotesNotebook* notebook,
                                                   gpointer self)
{
	__lambda71_ ((ENotesSidebar*) self, notebook);
}

static void
__lambda72_ (ENotesSidebar* self,
             ENotesNotebook* notebook)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (notebook != NULL);
	_tmp0_ = self->priv->added_notebooks;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, (gpointer) ((gintptr) notebook->id))) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		ENotesNotebookItem* _tmp3_;
		_tmp1_ = self->priv->added_notebooks;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, (gpointer) ((gintptr) notebook->id));
		_tmp3_ = (ENotesNotebookItem*) _tmp2_;
		enotes_notebook_item_set_notebook (_tmp3_, notebook);
		_g_object_unref0 (_tmp3_);
	}
}

static void
___lambda72__enotes_notebook_table_notebook_changed (ENotesNotebookTable* _sender,
                                                     ENotesNotebook* notebook,
                                                     gpointer self)
{
	__lambda72_ ((ENotesSidebar*) self, notebook);
}

static void
__lambda73_ (ENotesSidebar* self,
             ENotesPage* page)
{
	ENotesTrashItem* trash_item = NULL;
	ENotesTrashItem* _tmp0_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp1_;
	g_return_if_fail (page != NULL);
	_tmp0_ = enotes_trash_item_new_page (page);
	trash_item = _tmp0_;
	_tmp1_ = self->priv->trash;
	granite_widgets_source_list_patch_expandable_item_add (_tmp1_, (GraniteWidgetsSourceListPatchItem*) trash_item);
	_g_object_unref0 (trash_item);
}

static void
___lambda73__enotes_trash_page_added (ENotesTrash* _sender,
                                      ENotesPage* page,
                                      gpointer self)
{
	__lambda73_ ((ENotesSidebar*) self, page);
}

static void
__lambda75_ (ENotesSidebar* self,
             ENotesPage* page)
{
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	g_return_if_fail (page != NULL);
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	enotes_application_state_open_page (_tmp1_, page->id);
}

static void
___lambda75__enotes_trash_page_removed (ENotesTrash* _sender,
                                        ENotesPage* page,
                                        gpointer self)
{
	__lambda75_ ((ENotesSidebar*) self, page);
}

static void
__lambda76_ (ENotesSidebar* self,
             ENotesNotebook* notebook)
{
	ENotesTrashItem* trash_item = NULL;
	ENotesTrashItem* _tmp0_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp1_;
	g_return_if_fail (notebook != NULL);
	_tmp0_ = enotes_trash_item_new_notebook (notebook);
	trash_item = _tmp0_;
	_tmp1_ = self->priv->trash;
	granite_widgets_source_list_patch_expandable_item_add (_tmp1_, (GraniteWidgetsSourceListPatchItem*) trash_item);
	_g_object_unref0 (trash_item);
}

static void
___lambda76__enotes_trash_notebook_added (ENotesTrash* _sender,
                                          ENotesNotebook* notebook,
                                          gpointer self)
{
	__lambda76_ ((ENotesSidebar*) self, notebook);
}

static void
__lambda77_ (ENotesSidebar* self,
             ENotesNotebook* notebook)
{
	g_return_if_fail (notebook != NULL);
	enotes_sidebar_select_notebook (self, notebook->id);
}

static void
___lambda77__enotes_trash_notebook_removed (ENotesTrash* _sender,
                                            ENotesNotebook* notebook,
                                            gpointer self)
{
	__lambda77_ ((ENotesSidebar*) self, notebook);
}

static void
enotes_sidebar_connect_signals (ENotesSidebar* self)
{
	ENotesNotebookTable* _tmp0_;
	ENotesNotebookTable* _tmp1_;
	ENotesNotebookTable* _tmp2_;
	ENotesNotebookTable* _tmp3_;
	ENotesTrash* _tmp4_;
	ENotesTrash* _tmp5_;
	ENotesTrash* _tmp6_;
	ENotesTrash* _tmp7_;
	ENotesTrash* _tmp8_;
	ENotesTrash* _tmp9_;
	ENotesTrash* _tmp10_;
	ENotesTrash* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_notebook_table_get_instance ();
	_tmp1_ = _tmp0_;
	g_signal_connect_object (_tmp1_, "notebook-added", (GCallback) ___lambda71__enotes_notebook_table_notebook_added, self, 0);
	_database_table_unref0 (_tmp1_);
	_tmp2_ = enotes_notebook_table_get_instance ();
	_tmp3_ = _tmp2_;
	g_signal_connect_object (_tmp3_, "notebook-changed", (GCallback) ___lambda72__enotes_notebook_table_notebook_changed, self, 0);
	_database_table_unref0 (_tmp3_);
	_tmp4_ = enotes_trash_get_instance ();
	_tmp5_ = _tmp4_;
	g_signal_connect_object (_tmp5_, "page-added", (GCallback) ___lambda73__enotes_trash_page_added, self, 0);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = enotes_trash_get_instance ();
	_tmp7_ = _tmp6_;
	g_signal_connect_object (_tmp7_, "page-removed", (GCallback) ___lambda75__enotes_trash_page_removed, self, 0);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = enotes_trash_get_instance ();
	_tmp9_ = _tmp8_;
	g_signal_connect_object (_tmp9_, "notebook-added", (GCallback) ___lambda76__enotes_trash_notebook_added, self, 0);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = enotes_trash_get_instance ();
	_tmp11_ = _tmp10_;
	g_signal_connect_object (_tmp11_, "notebook-removed", (GCallback) ___lambda77__enotes_trash_notebook_removed, self, 0);
	_g_object_unref0 (_tmp11_);
}

static void
enotes_sidebar_class_init (ENotesSidebarClass * klass,
                           gpointer klass_data)
{
	enotes_sidebar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesSidebar_private_offset);
	G_OBJECT_CLASS (klass)->finalize = enotes_sidebar_finalize;
}

static void
enotes_sidebar_instance_init (ENotesSidebar * self,
                              gpointer klass)
{
	GraniteWidgetsSourceListPatchExpandableItem* _tmp0_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp1_;
	GraniteWidgetsSourceListPatchExpandableItem* _tmp2_;
	ENotesNotebookList* _tmp3_;
	self->priv = enotes_sidebar_get_instance_private (self);
	self->priv->selecting_sidebar_item = FALSE;
	_tmp0_ = granite_widgets_source_list_patch_expandable_item_new (_ ("Bookmarks"));
	self->priv->bookmarks = _tmp0_;
	_tmp1_ = granite_widgets_source_list_patch_expandable_item_new (_ ("Trash"));
	self->priv->trash = _tmp1_;
	_tmp2_ = granite_widgets_source_list_patch_expandable_item_new (_ ("Tags"));
	self->priv->tags = _tmp2_;
	self->priv->previous_selection = NULL;
	_tmp3_ = enotes_notebook_list_new (_ ("Sections"));
	self->priv->notebooks = _tmp3_;
}

static void
enotes_sidebar_finalize (GObject * obj)
{
	ENotesSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_SIDEBAR, ENotesSidebar);
	_g_object_unref0 (self->priv->bookmarks);
	_g_object_unref0 (self->priv->trash);
	_g_object_unref0 (self->priv->tags);
	_g_object_unref0 (self->priv->previous_selection);
	_g_object_unref0 (self->priv->all_notes);
	_g_object_unref0 (self->priv->notebooks);
	_g_object_unref0 (self->priv->added_notebooks);
	_g_object_unref0 (self->priv->added_tags);
	G_OBJECT_CLASS (enotes_sidebar_parent_class)->finalize (obj);
}

static GType
enotes_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesSidebarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesSidebar), 0, (GInstanceInitFunc) enotes_sidebar_instance_init, NULL };
	GType enotes_sidebar_type_id;
	enotes_sidebar_type_id = g_type_register_static (GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, "ENotesSidebar", &g_define_type_info, 0);
	ENotesSidebar_private_offset = g_type_add_instance_private (enotes_sidebar_type_id, sizeof (ENotesSidebarPrivate));
	return enotes_sidebar_type_id;
}

GType
enotes_sidebar_get_type (void)
{
	static volatile gsize enotes_sidebar_type_id__once = 0;
	if (g_once_init_enter (&enotes_sidebar_type_id__once)) {
		GType enotes_sidebar_type_id;
		enotes_sidebar_type_id = enotes_sidebar_get_type_once ();
		g_once_init_leave (&enotes_sidebar_type_id__once, enotes_sidebar_type_id);
	}
	return enotes_sidebar_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;
}

