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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2022 elementary LLC. (https://elementary.io),
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation, either version 3 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 warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Jeremy Wootten <jeremy@elementaryos.org>
 */

#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksource.h>
#include <gio/gio.h>

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

#define SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER (scratch_services_document_manager_get_type ())
#define SCRATCH_SERVICES_DOCUMENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER, ScratchServicesDocumentManager))
#define SCRATCH_SERVICES_DOCUMENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER, ScratchServicesDocumentManagerClass))
#define SCRATCH_SERVICES_IS_DOCUMENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER))
#define SCRATCH_SERVICES_IS_DOCUMENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER))
#define SCRATCH_SERVICES_DOCUMENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER, ScratchServicesDocumentManagerClass))

typedef struct _ScratchServicesDocumentManager ScratchServicesDocumentManager;
typedef struct _ScratchServicesDocumentManagerClass ScratchServicesDocumentManagerClass;
typedef struct _ScratchServicesDocumentManagerPrivate ScratchServicesDocumentManagerPrivate;
enum  {
	SCRATCH_SERVICES_DOCUMENT_MANAGER_0_PROPERTY,
	SCRATCH_SERVICES_DOCUMENT_MANAGER_NUM_PROPERTIES
};
static GParamSpec* scratch_services_document_manager_properties[SCRATCH_SERVICES_DOCUMENT_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define SCRATCH_SERVICES_TYPE_DOCUMENT (scratch_services_document_get_type ())
#define SCRATCH_SERVICES_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocument))
#define SCRATCH_SERVICES_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocumentClass))
#define SCRATCH_SERVICES_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT))
#define SCRATCH_SERVICES_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT))
#define SCRATCH_SERVICES_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocumentClass))

typedef struct _ScratchServicesDocument ScratchServicesDocument;
typedef struct _ScratchServicesDocumentClass ScratchServicesDocumentClass;

#define SCRATCH_WIDGETS_TYPE_SOURCE_VIEW (scratch_widgets_source_view_get_type ())
#define SCRATCH_WIDGETS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceView))
#define SCRATCH_WIDGETS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceViewClass))
#define SCRATCH_WIDGETS_IS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW))
#define SCRATCH_WIDGETS_IS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW))
#define SCRATCH_WIDGETS_SOURCE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceViewClass))

typedef struct _ScratchWidgetsSourceView ScratchWidgetsSourceView;
typedef struct _ScratchWidgetsSourceViewClass ScratchWidgetsSourceViewClass;

#define CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM (code_widgets_source_list_item_get_type ())
#define CODE_WIDGETS_SOURCE_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM, CodeWidgetsSourceListItem))
#define CODE_WIDGETS_SOURCE_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM, CodeWidgetsSourceListItemClass))
#define CODE_WIDGETS_SOURCE_LIST_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM))
#define CODE_WIDGETS_SOURCE_LIST_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM))
#define CODE_WIDGETS_SOURCE_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_ITEM, CodeWidgetsSourceListItemClass))

typedef struct _CodeWidgetsSourceListItem CodeWidgetsSourceListItem;
typedef struct _CodeWidgetsSourceListItemClass CodeWidgetsSourceListItemClass;

#define CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM (code_widgets_source_list_expandable_item_get_type ())
#define CODE_WIDGETS_SOURCE_LIST_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem))
#define CODE_WIDGETS_SOURCE_LIST_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItemClass))
#define CODE_WIDGETS_SOURCE_LIST_IS_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM))
#define CODE_WIDGETS_SOURCE_LIST_IS_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM))
#define CODE_WIDGETS_SOURCE_LIST_EXPANDABLE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItemClass))

typedef struct _CodeWidgetsSourceListExpandableItem CodeWidgetsSourceListExpandableItem;
typedef struct _CodeWidgetsSourceListExpandableItemClass CodeWidgetsSourceListExpandableItemClass;

#define SCRATCH_FOLDER_MANAGER_TYPE_ITEM (scratch_folder_manager_item_get_type ())
#define SCRATCH_FOLDER_MANAGER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItem))
#define SCRATCH_FOLDER_MANAGER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItemClass))
#define SCRATCH_FOLDER_MANAGER_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_FOLDER_MANAGER_TYPE_ITEM))
#define SCRATCH_FOLDER_MANAGER_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_FOLDER_MANAGER_TYPE_ITEM))
#define SCRATCH_FOLDER_MANAGER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItemClass))

typedef struct _ScratchFolderManagerItem ScratchFolderManagerItem;
typedef struct _ScratchFolderManagerItemClass ScratchFolderManagerItemClass;

#define SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM (scratch_folder_manager_folder_item_get_type ())
#define SCRATCH_FOLDER_MANAGER_FOLDER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem))
#define SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItemClass))
#define SCRATCH_FOLDER_MANAGER_IS_FOLDER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM))
#define SCRATCH_FOLDER_MANAGER_IS_FOLDER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM))
#define SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItemClass))

typedef struct _ScratchFolderManagerFolderItem ScratchFolderManagerFolderItem;
typedef struct _ScratchFolderManagerFolderItemClass ScratchFolderManagerFolderItemClass;

#define SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM (scratch_folder_manager_project_folder_item_get_type ())
#define SCRATCH_FOLDER_MANAGER_PROJECT_FOLDER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM, ScratchFolderManagerProjectFolderItem))
#define SCRATCH_FOLDER_MANAGER_PROJECT_FOLDER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM, ScratchFolderManagerProjectFolderItemClass))
#define SCRATCH_FOLDER_MANAGER_IS_PROJECT_FOLDER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM))
#define SCRATCH_FOLDER_MANAGER_IS_PROJECT_FOLDER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM))
#define SCRATCH_FOLDER_MANAGER_PROJECT_FOLDER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_FOLDER_MANAGER_TYPE_PROJECT_FOLDER_ITEM, ScratchFolderManagerProjectFolderItemClass))

typedef struct _ScratchFolderManagerProjectFolderItem ScratchFolderManagerProjectFolderItem;
typedef struct _ScratchFolderManagerProjectFolderItemClass ScratchFolderManagerProjectFolderItemClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ScratchServicesDocumentManager {
	GObject parent_instance;
	ScratchServicesDocumentManagerPrivate * priv;
};

struct _ScratchServicesDocumentManagerClass {
	GObjectClass parent_class;
};

static gpointer scratch_services_document_manager_parent_class = NULL;
static GeeHashMultiMap* scratch_services_document_manager_project_restorable_docs_map;
static GeeHashMultiMap* scratch_services_document_manager_project_restorable_docs_map = NULL;
static GeeHashMultiMap* scratch_services_document_manager_project_open_docs_map;
static GeeHashMultiMap* scratch_services_document_manager_project_open_docs_map = NULL;
static ScratchServicesDocumentManager* scratch_services_document_manager_instance;
static ScratchServicesDocumentManager* scratch_services_document_manager_instance = NULL;

VALA_EXTERN GType scratch_services_document_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchServicesDocumentManager, g_object_unref)
VALA_EXTERN ScratchServicesDocumentManager* scratch_services_document_manager_get_instance (void);
VALA_EXTERN ScratchServicesDocumentManager* scratch_services_document_manager_new (void);
VALA_EXTERN ScratchServicesDocumentManager* scratch_services_document_manager_construct (GType object_type);
VALA_EXTERN GType scratch_services_document_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchServicesDocument, g_object_unref)
VALA_EXTERN void scratch_services_document_manager_make_restorable (ScratchServicesDocumentManager* self,
                                                        ScratchServicesDocument* doc);
VALA_EXTERN GType scratch_widgets_source_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchWidgetsSourceView, g_object_unref)
VALA_EXTERN ScratchWidgetsSourceView* scratch_services_document_get_source_view (ScratchServicesDocument* self);
VALA_EXTERN GType code_widgets_source_list_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CodeWidgetsSourceListItem, g_object_unref)
VALA_EXTERN GType code_widgets_source_list_expandable_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CodeWidgetsSourceListExpandableItem, g_object_unref)
VALA_EXTERN GType scratch_folder_manager_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchFolderManagerItem, g_object_unref)
VALA_EXTERN GType scratch_folder_manager_folder_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchFolderManagerFolderItem, g_object_unref)
VALA_EXTERN GType scratch_folder_manager_project_folder_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchFolderManagerProjectFolderItem, g_object_unref)
VALA_EXTERN ScratchFolderManagerProjectFolderItem* scratch_widgets_source_view_get_project (ScratchWidgetsSourceView* self);
VALA_EXTERN gchar* scratch_folder_manager_item_get_path (ScratchFolderManagerItem* self);
VALA_EXTERN GFile* scratch_services_document_get_file (ScratchServicesDocument* self);
VALA_EXTERN void scratch_services_document_manager_add_open_document (ScratchServicesDocumentManager* self,
                                                          ScratchServicesDocument* doc);
VALA_EXTERN void scratch_services_document_manager_remove_open_document (ScratchServicesDocumentManager* self,
                                                             ScratchServicesDocument* doc);
VALA_EXTERN void scratch_services_document_manager_remove_project (ScratchServicesDocumentManager* self,
                                                       const gchar* project_path);
VALA_EXTERN GeeCollection* scratch_services_document_manager_take_restorable_paths (ScratchServicesDocumentManager* self,
                                                                        const gchar* project_path);
VALA_EXTERN guint scratch_services_document_manager_restorable_for_project (ScratchServicesDocumentManager* self,
                                                                const gchar* project_path);
VALA_EXTERN guint scratch_services_document_manager_open_for_project (ScratchServicesDocumentManager* self,
                                                          const gchar* project_path);
static void scratch_services_document_manager_finalize (GObject * obj);
static GType scratch_services_document_manager_get_type_once (void);

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

ScratchServicesDocumentManager*
scratch_services_document_manager_get_instance (void)
{
	ScratchServicesDocumentManager* _tmp0_;
	ScratchServicesDocumentManager* _tmp2_;
	ScratchServicesDocumentManager* _tmp3_;
	ScratchServicesDocumentManager* result;
	_tmp0_ = scratch_services_document_manager_instance;
	if (_tmp0_ == NULL) {
		ScratchServicesDocumentManager* _tmp1_;
		_tmp1_ = scratch_services_document_manager_new ();
		_g_object_unref0 (scratch_services_document_manager_instance);
		scratch_services_document_manager_instance = _tmp1_;
	}
	_tmp2_ = scratch_services_document_manager_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

void
scratch_services_document_manager_make_restorable (ScratchServicesDocumentManager* self,
                                                   ScratchServicesDocument* doc)
{
	GeeHashMultiMap* _tmp0_;
	ScratchWidgetsSourceView* _tmp1_;
	ScratchWidgetsSourceView* _tmp2_;
	ScratchFolderManagerProjectFolderItem* _tmp3_;
	ScratchFolderManagerProjectFolderItem* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GFile* _tmp8_;
	GFile* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (doc != NULL);
	_tmp0_ = scratch_services_document_manager_project_restorable_docs_map;
	_tmp1_ = scratch_services_document_get_source_view (doc);
	_tmp2_ = _tmp1_;
	_tmp3_ = scratch_widgets_source_view_get_project (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = scratch_folder_manager_item_get_path ((ScratchFolderManagerItem*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = scratch_services_document_get_file (doc);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_file_get_path (_tmp9_);
	_tmp11_ = _tmp10_;
	gee_multi_map_set ((GeeMultiMap*) _tmp0_, _tmp7_, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp7_);
}

void
scratch_services_document_manager_add_open_document (ScratchServicesDocumentManager* self,
                                                     ScratchServicesDocument* doc)
{
	ScratchWidgetsSourceView* _tmp0_;
	ScratchWidgetsSourceView* _tmp1_;
	ScratchFolderManagerProjectFolderItem* _tmp2_;
	ScratchFolderManagerProjectFolderItem* _tmp3_;
	GeeHashMultiMap* _tmp4_;
	ScratchWidgetsSourceView* _tmp5_;
	ScratchWidgetsSourceView* _tmp6_;
	ScratchFolderManagerProjectFolderItem* _tmp7_;
	ScratchFolderManagerProjectFolderItem* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GFile* _tmp12_;
	GFile* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (doc != NULL);
	_tmp0_ = scratch_services_document_get_source_view (doc);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_widgets_source_view_get_project (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		return;
	}
	_tmp4_ = scratch_services_document_manager_project_open_docs_map;
	_tmp5_ = scratch_services_document_get_source_view (doc);
	_tmp6_ = _tmp5_;
	_tmp7_ = scratch_widgets_source_view_get_project (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = scratch_folder_manager_item_get_path ((ScratchFolderManagerItem*) _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp12_ = scratch_services_document_get_file (doc);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_file_get_path (_tmp13_);
	_tmp15_ = _tmp14_;
	gee_multi_map_set ((GeeMultiMap*) _tmp4_, _tmp11_, _tmp15_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp11_);
}

void
scratch_services_document_manager_remove_open_document (ScratchServicesDocumentManager* self,
                                                        ScratchServicesDocument* doc)
{
	ScratchWidgetsSourceView* _tmp0_;
	ScratchWidgetsSourceView* _tmp1_;
	ScratchFolderManagerProjectFolderItem* _tmp2_;
	ScratchFolderManagerProjectFolderItem* _tmp3_;
	GeeHashMultiMap* _tmp4_;
	ScratchWidgetsSourceView* _tmp5_;
	ScratchWidgetsSourceView* _tmp6_;
	ScratchFolderManagerProjectFolderItem* _tmp7_;
	ScratchFolderManagerProjectFolderItem* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GFile* _tmp12_;
	GFile* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (doc != NULL);
	_tmp0_ = scratch_services_document_get_source_view (doc);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_widgets_source_view_get_project (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		return;
	}
	_tmp4_ = scratch_services_document_manager_project_open_docs_map;
	_tmp5_ = scratch_services_document_get_source_view (doc);
	_tmp6_ = _tmp5_;
	_tmp7_ = scratch_widgets_source_view_get_project (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = scratch_folder_manager_item_get_path ((ScratchFolderManagerItem*) _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp12_ = scratch_services_document_get_file (doc);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_file_get_path (_tmp13_);
	_tmp15_ = _tmp14_;
	gee_multi_map_remove ((GeeMultiMap*) _tmp4_, _tmp11_, _tmp15_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp11_);
}

void
scratch_services_document_manager_remove_project (ScratchServicesDocumentManager* self,
                                                  const gchar* project_path)
{
	GeeHashMultiMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (project_path != NULL);
	_tmp0_ = scratch_services_document_manager_project_restorable_docs_map;
	gee_multi_map_remove_all ((GeeMultiMap*) _tmp0_, project_path);
}

GeeCollection*
scratch_services_document_manager_take_restorable_paths (ScratchServicesDocumentManager* self,
                                                         const gchar* project_path)
{
	GeeCollection* docs = NULL;
	GeeHashMultiMap* _tmp0_;
	GeeCollection* _tmp1_;
	GeeHashMultiMap* _tmp2_;
	GeeCollection* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (project_path != NULL, NULL);
	_tmp0_ = scratch_services_document_manager_project_restorable_docs_map;
	_tmp1_ = gee_multi_map_get ((GeeMultiMap*) _tmp0_, project_path);
	docs = _tmp1_;
	_tmp2_ = scratch_services_document_manager_project_restorable_docs_map;
	gee_multi_map_remove_all ((GeeMultiMap*) _tmp2_, project_path);
	result = docs;
	return result;
}

guint
scratch_services_document_manager_restorable_for_project (ScratchServicesDocumentManager* self,
                                                          const gchar* project_path)
{
	GeeHashMultiMap* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	guint _tmp5_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (project_path != NULL, 0U);
	_tmp0_ = scratch_services_document_manager_project_restorable_docs_map;
	_tmp1_ = gee_multi_map_get ((GeeMultiMap*) _tmp0_, project_path);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = (guint) _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

guint
scratch_services_document_manager_open_for_project (ScratchServicesDocumentManager* self,
                                                    const gchar* project_path)
{
	GeeHashMultiMap* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	guint _tmp5_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (project_path != NULL, 0U);
	_tmp0_ = scratch_services_document_manager_project_open_docs_map;
	_tmp1_ = gee_multi_map_get ((GeeMultiMap*) _tmp0_, project_path);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = (guint) _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

ScratchServicesDocumentManager*
scratch_services_document_manager_construct (GType object_type)
{
	ScratchServicesDocumentManager * self = NULL;
	self = (ScratchServicesDocumentManager*) g_object_new (object_type, NULL);
	return self;
}

ScratchServicesDocumentManager*
scratch_services_document_manager_new (void)
{
	return scratch_services_document_manager_construct (SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER);
}

static void
scratch_services_document_manager_class_init (ScratchServicesDocumentManagerClass * klass,
                                              gpointer klass_data)
{
	GeeHashMultiMap* _tmp0_;
	GeeHashMultiMap* _tmp1_;
	scratch_services_document_manager_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = scratch_services_document_manager_finalize;
	_tmp0_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (scratch_services_document_manager_project_restorable_docs_map);
	scratch_services_document_manager_project_restorable_docs_map = _tmp0_;
	_tmp1_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (scratch_services_document_manager_project_open_docs_map);
	scratch_services_document_manager_project_open_docs_map = _tmp1_;
}

static void
scratch_services_document_manager_instance_init (ScratchServicesDocumentManager * self,
                                                 gpointer klass)
{
}

static void
scratch_services_document_manager_finalize (GObject * obj)
{
	ScratchServicesDocumentManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_SERVICES_TYPE_DOCUMENT_MANAGER, ScratchServicesDocumentManager);
	G_OBJECT_CLASS (scratch_services_document_manager_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
scratch_services_document_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ScratchServicesDocumentManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) scratch_services_document_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScratchServicesDocumentManager), 0, (GInstanceInitFunc) scratch_services_document_manager_instance_init, NULL };
	GType scratch_services_document_manager_type_id;
	scratch_services_document_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "ScratchServicesDocumentManager", &g_define_type_info, G_TYPE_FLAG_NONE);
	return scratch_services_document_manager_type_id;
}

GType
scratch_services_document_manager_get_type (void)
{
	static gsize scratch_services_document_manager_type_id__once = 0;
	if (g_once_init_enter (&scratch_services_document_manager_type_id__once)) {
		GType scratch_services_document_manager_type_id;
		scratch_services_document_manager_type_id = scratch_services_document_manager_get_type_once ();
		g_once_init_leave (&scratch_services_document_manager_type_id__once, scratch_services_document_manager_type_id);
	}
	return scratch_services_document_manager_type_id__once;
}

