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

/*
 * SPDX-License-Identifier: LGPL-3.0-or-later
 * SPDX-FileCopyrightText: 2017–2026 elementary, Inc. <https://elementary.io>
 *                         2013 Julien Spautz <spautz.julien@gmail.com>
 */

#include "codecore.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>

#define SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_RENAME_AFTER_NEW_DELAY_MSEC ((guint) 500)
#define SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_MAX_TEMPLATES 2048
#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

enum  {
	SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_0_PROPERTY,
	SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_LOADING_REQUIRED_PROPERTY,
	SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_NUM_PROPERTIES
};
static GParamSpec* scratch_folder_manager_folder_item_properties[SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block23Data Block23Data;
typedef struct _Block24Data Block24Data;
typedef struct _ScratchFolderManagerFolderItemLoadChildrenAsyncData ScratchFolderManagerFolderItemLoadChildrenAsyncData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _Block25Data Block25Data;
typedef struct _Block26Data Block26Data;
typedef struct _Block27Data Block27Data;
typedef struct _Block28Data Block28Data;
typedef struct _Block29Data Block29Data;
typedef struct _Block30Data Block30Data;
typedef struct _Block31Data Block31Data;
typedef struct _Block32Data Block32Data;
typedef struct _Block33Data Block33Data;
enum  {
	SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_CHILDREN_FINISHED_LOADING_SIGNAL,
	SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_NUM_SIGNALS
};
static guint scratch_folder_manager_folder_item_signals[SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ScratchFolderManagerFolderItemPrivate {
	GFileMonitor* monitor;
	gboolean children_loaded;
	gboolean has_dummy;
	CodeWidgetsSourceListItem* dummy;
};

struct _Block23Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	gpointer _async_data_;
};

struct _Block24Data {
	int _ref_count_;
	Block23Data * _data23_;
	ScratchFolderManagerFile* child;
};

struct _ScratchFolderManagerFolderItemLoadChildrenAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ScratchFolderManagerFolderItem* self;
	Block23Data* _data23_;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GeeIterator* _child_it;
	ScratchFolderManagerFile* _tmp2_;
	ScratchFolderManagerFile* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeIterator* _tmp7_;
	GeeIterator* _tmp8_;
	Block24Data* _data24_;
	GeeIterator* _tmp9_;
	GeeIterator* _tmp10_;
	gpointer _tmp11_;
};

struct _Block25Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	GMenu* template_submenu;
};

struct _Block26Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	gchar* template_path;
};

struct _Block27Data {
	int _ref_count_;
	Block26Data * _data26_;
	gulong once;
};

struct _Block28Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	GFile* new_file;
	gulong once;
};

struct _Block29Data {
	int _ref_count_;
	Block28Data * _data28_;
	gchar* path;
};

struct _Block30Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	gchar* name;
	gboolean is_folder;
};

struct _Block31Data {
	int _ref_count_;
	Block30Data * _data30_;
	gulong once;
};

struct _Block32Data {
	int _ref_count_;
	ScratchFolderManagerFolderItem* self;
	ScratchFolderManagerItemRenameItem* rename_item;
};

struct _Block33Data {
	int _ref_count_;
	Block32Data * _data32_;
	gulong once;
};

static gint ScratchFolderManagerFolderItem_private_offset;
static gpointer scratch_folder_manager_folder_item_parent_class = NULL;

static void scratch_folder_manager_folder_item_add_child (ScratchFolderManagerFolderItem* self,
                                                   ScratchFolderManagerFile* child);
static void scratch_folder_manager_folder_item_after_children_loaded (ScratchFolderManagerFolderItem* self);
static void scratch_folder_manager_folder_item_load_children_async_data_free (gpointer _data);
static void scratch_folder_manager_folder_item_load_children_async (ScratchFolderManagerFolderItem* self,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static void scratch_folder_manager_folder_item_load_children_finish (ScratchFolderManagerFolderItem* self,
                                                              GAsyncResult* _res_);
static gboolean scratch_folder_manager_folder_item_load_children_async_co (ScratchFolderManagerFolderItemLoadChildrenAsyncData* _data_);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
static gboolean _____lambda143_ (Block24Data* _data24_);
static gboolean ______lambda143__gsource_func (gpointer self);
static void scratch_folder_manager_folder_item_on_toggled (ScratchFolderManagerFolderItem* self);
static GMenu* scratch_folder_manager_folder_item_real_get_context_menu (CodeWidgetsSourceListItem* base);
static GVariant* _variant_new17 (const gchar* value);
static guint scratch_folder_manager_folder_item_load_templates_from_folder (ScratchFolderManagerFolderItem* self,
                                                                     GFile* template_folder,
                                                                     GMenu* template_submenu);
static Block25Data* block25_data_ref (Block25Data* _data25_);
static void block25_data_unref (void * _userdata_);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static gint __lambda144_ (GFile* a,
                   GFile* b);
static gint ___lambda144__gcompare_func (gconstpointer a,
                                  gconstpointer b);
static gint __lambda145_ (GFile* a,
                   GFile* b);
static gint ___lambda145__gcompare_func (gconstpointer a,
                                  gconstpointer b);
static void __lambda146_ (Block25Data* _data25_,
                   GFile* template);
static void ___lambda146__gfunc (gconstpointer data,
                          gpointer self);
static void scratch_folder_manager_folder_item_remove_badge (ScratchFolderManagerFolderItem* self,
                                                      CodeWidgetsSourceListItem* item);
static void scratch_folder_manager_folder_item_real_on_changed (ScratchFolderManagerFolderItem* self,
                                                         GFile* source,
                                                         GFile* dest,
                                                         GFileMonitorEvent event);
static ScratchFolderManagerItem* scratch_folder_manager_folder_item_find_item_for_path (ScratchFolderManagerFolderItem* self,
                                                                                 const gchar* path);
static Block26Data* block26_data_ref (Block26Data* _data26_);
static void block26_data_unref (void * _userdata_);
static Block27Data* block27_data_ref (Block27Data* _data27_);
static void block27_data_unref (void * _userdata_);
static void ___lambda119_ (Block27Data* _data27_);
static void scratch_folder_manager_folder_item_copy_template (ScratchFolderManagerFolderItem* self,
                                                       const gchar* template_path);
static void ____lambda119__scratch_folder_manager_folder_item_children_finished_loading (ScratchFolderManagerFolderItem* _sender,
                                                                                  gpointer self);
static Block28Data* block28_data_ref (Block28Data* _data28_);
static void block28_data_unref (void * _userdata_);
static void __lambda120_ (Block28Data* _data28_);
static Block29Data* block29_data_ref (Block29Data* _data29_);
static void block29_data_unref (void * _userdata_);
static gboolean __lambda121_ (Block29Data* _data29_);
static GVariant* _variant_new18 (const gchar* value);
static gboolean ___lambda121__gsource_func (gpointer self);
static void ___lambda120__code_widgets_source_list_expandable_item_child_added (CodeWidgetsSourceListExpandableItem* _sender,
                                                                         CodeWidgetsSourceListItem* item,
                                                                         gpointer self);
static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
static Block31Data* block31_data_ref (Block31Data* _data31_);
static void block31_data_unref (void * _userdata_);
static void ___lambda115_ (Block31Data* _data31_);
static void scratch_folder_manager_folder_item_rename_new (ScratchFolderManagerFolderItem* self,
                                                    const gchar* name,
                                                    gboolean is_folder);
static void ____lambda115__scratch_folder_manager_folder_item_children_finished_loading (ScratchFolderManagerFolderItem* _sender,
                                                                                  gpointer self);
static Block32Data* block32_data_ref (Block32Data* _data32_);
static void block32_data_unref (void * _userdata_);
static gboolean __lambda116_ (Block32Data* _data32_);
static Block33Data* block33_data_ref (Block33Data* _data33_);
static void block33_data_unref (void * _userdata_);
static void ___lambda117_ (Block33Data* _data33_);
static void ____lambda117__code_widgets_source_list_item_edited (CodeWidgetsSourceListItem* _sender,
                                                          const gchar* new_name,
                                                          gpointer self);
static gboolean ___lambda118_ (Block33Data* _data33_);
static gboolean ____lambda118__gsource_func (gpointer self);
static gboolean ___lambda116__gsource_func (gpointer self);
static GObject * scratch_folder_manager_folder_item_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties);
static void _scratch_folder_manager_folder_item_on_toggled_code_widgets_source_list_expandable_item_toggled (CodeWidgetsSourceListExpandableItem* _sender,
                                                                                                      gpointer self);
static void _scratch_folder_manager_folder_item_on_changed_g_file_monitor_changed (GFileMonitor* _sender,
                                                                            GFile* file,
                                                                            GFile* other_file,
                                                                            GFileMonitorEvent event_type,
                                                                            gpointer self);
static void scratch_folder_manager_folder_item_finalize (GObject * obj);
static GType scratch_folder_manager_folder_item_get_type_once (void);
static void _vala_scratch_folder_manager_folder_item_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);

static inline gpointer
scratch_folder_manager_folder_item_get_instance_private (ScratchFolderManagerFolderItem* self)
{
	return G_STRUCT_MEMBER_P (self, ScratchFolderManagerFolderItem_private_offset);
}

ScratchFolderManagerFolderItem*
scratch_folder_manager_folder_item_construct (GType object_type,
                                              ScratchFolderManagerFile* file,
                                              ScratchFolderManagerFileView* view)
{
	ScratchFolderManagerFolderItem * self = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (view != NULL, NULL);
	self = (ScratchFolderManagerFolderItem*) g_object_new (object_type, "file", file, "view", view, NULL);
	return self;
}

ScratchFolderManagerFolderItem*
scratch_folder_manager_folder_item_new (ScratchFolderManagerFile* file,
                                        ScratchFolderManagerFileView* view)
{
	return scratch_folder_manager_folder_item_construct (SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, file, view);
}

void
scratch_folder_manager_folder_item_load_children (ScratchFolderManagerFolderItem* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = scratch_folder_manager_folder_item_get_loading_required (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		{
			GeeIterator* _child_it = NULL;
			ScratchFolderManagerFile* _tmp2_;
			ScratchFolderManagerFile* _tmp3_;
			GeeCollection* _tmp4_;
			GeeCollection* _tmp5_;
			GeeCollection* _tmp6_;
			GeeIterator* _tmp7_;
			GeeIterator* _tmp8_;
			_tmp2_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
			_tmp3_ = _tmp2_;
			_tmp4_ = scratch_folder_manager_file_get_children (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = _tmp5_;
			_tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_);
			_tmp8_ = _tmp7_;
			_g_object_unref0 (_tmp6_);
			_child_it = _tmp8_;
			while (TRUE) {
				GeeIterator* _tmp9_;
				ScratchFolderManagerFile* child = NULL;
				GeeIterator* _tmp10_;
				gpointer _tmp11_;
				ScratchFolderManagerFile* _tmp12_;
				_tmp9_ = _child_it;
				if (!gee_iterator_next (_tmp9_)) {
					break;
				}
				_tmp10_ = _child_it;
				_tmp11_ = gee_iterator_get (_tmp10_);
				child = (ScratchFolderManagerFile*) _tmp11_;
				_tmp12_ = child;
				scratch_folder_manager_folder_item_add_child (self, _tmp12_);
				_g_object_unref0 (child);
			}
			_g_object_unref0 (_child_it);
		}
		scratch_folder_manager_folder_item_after_children_loaded (self);
	}
}

static void
scratch_folder_manager_folder_item_load_children_async_data_free (gpointer _data)
{
	ScratchFolderManagerFolderItemLoadChildrenAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ScratchFolderManagerFolderItemLoadChildrenAsyncData, _data_);
}

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

static void
scratch_folder_manager_folder_item_load_children_async (ScratchFolderManagerFolderItem* self,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	ScratchFolderManagerFolderItemLoadChildrenAsyncData* _data_;
	ScratchFolderManagerFolderItem* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ScratchFolderManagerFolderItemLoadChildrenAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, scratch_folder_manager_folder_item_load_children_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	scratch_folder_manager_folder_item_load_children_async_co (_data_);
}

static void
scratch_folder_manager_folder_item_load_children_finish (ScratchFolderManagerFolderItem* self,
                                                         GAsyncResult* _res_)
{
	ScratchFolderManagerFolderItemLoadChildrenAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data23_->self;
		_g_object_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data24_->_data23_->self;
		_g_object_unref0 (_data24_->child);
		block23_data_unref (_data24_->_data23_);
		_data24_->_data23_ = NULL;
		g_slice_free (Block24Data, _data24_);
	}
}

static gboolean
_____lambda143_ (Block24Data* _data24_)
{
	Block23Data* _data23_;
	ScratchFolderManagerFolderItem* self;
	ScratchFolderManagerFile* _tmp0_;
	gboolean result;
	_data23_ = _data24_->_data23_;
	self = _data23_->self;
	_tmp0_ = _data24_->child;
	scratch_folder_manager_folder_item_add_child (self, _tmp0_);
	scratch_folder_manager_folder_item_load_children_async_co (_data23_->_async_data_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
______lambda143__gsource_func (gpointer self)
{
	gboolean result;
	result = _____lambda143_ (self);
	return result;
}

static gboolean
scratch_folder_manager_folder_item_load_children_async_co (ScratchFolderManagerFolderItemLoadChildrenAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data23_ = g_slice_new0 (Block23Data);
	_data_->_data23_->_ref_count_ = 1;
	_data_->_data23_->self = g_object_ref (_data_->self);
	_data_->_data23_->_async_data_ = _data_;
	_data_->_tmp0_ = scratch_folder_manager_folder_item_get_loading_required (_data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_) {
		{
			_data_->_tmp2_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) _data_->self);
			_data_->_tmp3_ = _data_->_tmp2_;
			_data_->_tmp4_ = scratch_folder_manager_file_get_children (_data_->_tmp3_);
			_data_->_tmp5_ = _data_->_tmp4_;
			_data_->_tmp6_ = _data_->_tmp5_;
			_data_->_tmp7_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp6_);
			_data_->_tmp8_ = _data_->_tmp7_;
			_g_object_unref0 (_data_->_tmp6_);
			_data_->_child_it = _data_->_tmp8_;
			while (TRUE) {
				_data_->_data24_ = g_slice_new0 (Block24Data);
				_data_->_data24_->_ref_count_ = 1;
				_data_->_data24_->_data23_ = block23_data_ref (_data_->_data23_);
				_data_->_tmp9_ = _data_->_child_it;
				if (!gee_iterator_next (_data_->_tmp9_)) {
					block24_data_unref (_data_->_data24_);
					_data_->_data24_ = NULL;
					break;
				}
				_data_->_tmp10_ = _data_->_child_it;
				_data_->_tmp11_ = gee_iterator_get (_data_->_tmp10_);
				_data_->_data24_->child = (ScratchFolderManagerFile*) _data_->_tmp11_;
				g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ______lambda143__gsource_func, block24_data_ref (_data_->_data24_), block24_data_unref);
				_data_->_state_ = 1;
				return FALSE;
				_state_1:
				;
				block24_data_unref (_data_->_data24_);
				_data_->_data24_ = NULL;
			}
			_g_object_unref0 (_data_->_child_it);
		}
	}
	scratch_folder_manager_folder_item_after_children_loaded (_data_->self);
	block23_data_unref (_data_->_data23_);
	_data_->_data23_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
scratch_folder_manager_folder_item_add_child (ScratchFolderManagerFolderItem* self,
                                              ScratchFolderManagerFile* child)
{
	CodeWidgetsSourceListItem* item = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	CodeWidgetsSourceListItem* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	item = NULL;
	_tmp0_ = scratch_folder_manager_file_get_is_valid_directory (child);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		ScratchFolderManagerFileView* _tmp2_;
		ScratchFolderManagerFileView* _tmp3_;
		ScratchFolderManagerFolderItem* _tmp4_;
		_tmp2_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
		_tmp3_ = _tmp2_;
		_tmp4_ = scratch_folder_manager_folder_item_new (child, _tmp3_);
		_g_object_unref0 (item);
		item = (CodeWidgetsSourceListItem*) _tmp4_;
	} else {
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp5_ = scratch_folder_manager_file_get_is_valid_textfile (child);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			ScratchFolderManagerFileView* _tmp7_;
			ScratchFolderManagerFileView* _tmp8_;
			ScratchFolderManagerFileItem* _tmp9_;
			_tmp7_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
			_tmp8_ = _tmp7_;
			_tmp9_ = scratch_folder_manager_file_item_new (child, _tmp8_);
			_g_object_unref0 (item);
			item = (CodeWidgetsSourceListItem*) _tmp9_;
		}
	}
	_tmp10_ = item;
	if (_tmp10_ != NULL) {
		CodeWidgetsSourceListItem* _tmp11_;
		_tmp11_ = item;
		scratch_folder_manager_folder_item_add (self, _tmp11_);
	}
	_g_object_unref0 (item);
}

static void
scratch_folder_manager_folder_item_after_children_loaded (ScratchFolderManagerFolderItem* self)
{
	ScratchFolderManagerProjectFolderItem* root = NULL;
	ScratchFolderManagerProjectFolderItem* _tmp0_;
	ScratchFolderManagerProjectFolderItem* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->children_loaded = TRUE;
	_tmp0_ = scratch_folder_manager_item_get_root_folder ((ScratchFolderManagerItem*) self, NULL);
	root = _tmp0_;
	_tmp1_ = root;
	if (_tmp1_ != NULL) {
		ScratchFolderManagerProjectFolderItem* _tmp2_;
		_tmp2_ = root;
		scratch_folder_manager_project_folder_item_child_folder_loaded (_tmp2_, self);
	}
	g_signal_emit (self, scratch_folder_manager_folder_item_signals[SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_CHILDREN_FINISHED_LOADING_SIGNAL], 0);
	_g_object_unref0 (root);
}

static void
scratch_folder_manager_folder_item_on_toggled (ScratchFolderManagerFolderItem* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = code_widgets_source_list_expandable_item_get_expanded ((CodeWidgetsSourceListExpandableItem*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		scratch_folder_manager_folder_item_load_children_async (self, NULL, NULL);
		return;
	} else {
		ScratchFolderManagerProjectFolderItem* root = NULL;
		ScratchFolderManagerProjectFolderItem* _tmp2_;
		gboolean _tmp3_ = FALSE;
		ScratchFolderManagerProjectFolderItem* _tmp4_;
		_tmp2_ = scratch_folder_manager_item_get_root_folder ((ScratchFolderManagerItem*) self, NULL);
		root = _tmp2_;
		_tmp4_ = root;
		if (_tmp4_ != NULL) {
			ScratchFolderManagerProjectFolderItem* _tmp5_;
			ScratchServicesMonitoredRepository* _tmp6_;
			ScratchServicesMonitoredRepository* _tmp7_;
			_tmp5_ = root;
			_tmp6_ = scratch_folder_manager_project_folder_item_get_monitored_repo (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp3_ = _tmp7_ != NULL;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			ScratchFolderManagerProjectFolderItem* _tmp8_;
			_tmp8_ = root;
			scratch_folder_manager_project_folder_item_update_item_status (_tmp8_, self);
		}
		_g_object_unref0 (root);
	}
}

static GMenu*
scratch_folder_manager_folder_item_real_get_context_menu (CodeWidgetsSourceListItem* base)
{
	ScratchFolderManagerFolderItem * self;
	GFileInfo* info = NULL;
	gchar* file_type = NULL;
	GFileInfo* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	GMenu* contractor_items = NULL;
	ScratchFolderManagerFile* _tmp12_;
	ScratchFolderManagerFile* _tmp13_;
	GFile* _tmp14_;
	GFile* _tmp15_;
	GMenu* _tmp16_;
	GMenuItem* rename_menu_item = NULL;
	ScratchFolderManagerFile* _tmp17_;
	ScratchFolderManagerFile* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	GVariant* _tmp21_;
	GVariant* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	GMenuItem* _tmp25_;
	GMenuItem* _tmp26_;
	GMenuItem* delete_item = NULL;
	ScratchFolderManagerFile* _tmp27_;
	ScratchFolderManagerFile* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	GVariant* _tmp31_;
	GVariant* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	GMenuItem* _tmp35_;
	GMenuItem* _tmp36_;
	GMenuItem* search_item = NULL;
	ScratchFolderManagerFile* _tmp37_;
	ScratchFolderManagerFile* _tmp38_;
	GFile* _tmp39_;
	GFile* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	GVariant* _tmp43_;
	GVariant* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	GMenuItem* _tmp47_;
	GMenuItem* _tmp48_;
	GMenu* external_actions_section = NULL;
	GMenu* _tmp49_;
	GMenu* _tmp50_;
	const gchar* _tmp51_;
	GMenuItem* _tmp52_;
	GMenuItem* _tmp53_;
	GMenu* _tmp54_;
	GMenu* direct_actions_section = NULL;
	GMenu* _tmp57_;
	GMenuItem* _tmp58_;
	GMenuItem* _tmp59_;
	GMenuItem* _tmp60_;
	GMenuItem* _tmp61_;
	GMenu* search_section = NULL;
	GMenu* _tmp62_;
	GMenuItem* _tmp63_;
	GMenu* menu_model = NULL;
	GMenu* _tmp64_;
	GMenu* _tmp65_;
	GError* _inner_error0_ = NULL;
	GMenu* result;
	self = (ScratchFolderManagerFolderItem*) base;
	info = NULL;
	{
		GFileInfo* _tmp0_ = NULL;
		ScratchFolderManagerFile* _tmp1_;
		ScratchFolderManagerFile* _tmp2_;
		GFile* _tmp3_;
		GFile* _tmp4_;
		GFileInfo* _tmp5_;
		GFileInfo* _tmp6_;
		_tmp1_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp2_ = _tmp1_;
		_tmp3_ = scratch_folder_manager_file_get_file (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_file_query_info (_tmp4_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp0_ = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (info);
		info = _tmp6_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("FolderItem.vala:122: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (info);
		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;
	}
	_tmp9_ = info;
	_tmp10_ = g_file_info_get_content_type (_tmp9_);
	_tmp11_ = g_strdup (_tmp10_);
	file_type = _tmp11_;
	_tmp12_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp13_ = _tmp12_;
	_tmp14_ = scratch_folder_manager_file_get_file (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = scratch_utils_create_contract_items_for_file (_tmp15_);
	contractor_items = _tmp16_;
	_tmp17_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp18_ = _tmp17_;
	_tmp19_ = scratch_folder_manager_file_get_path (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_variant_new_string (_tmp20_);
	g_variant_ref_sink (_tmp21_);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_RENAME_FOLDER, _tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_menu_item_new (_ ("Rename"), _tmp24_);
	_tmp26_ = _tmp25_;
	_g_free0 (_tmp24_);
	_g_variant_unref0 (_tmp22_);
	rename_menu_item = _tmp26_;
	_tmp27_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp28_ = _tmp27_;
	_tmp29_ = scratch_folder_manager_file_get_path (_tmp28_);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_variant_new_string (_tmp30_);
	g_variant_ref_sink (_tmp31_);
	_tmp32_ = _tmp31_;
	_tmp33_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_DELETE, _tmp32_);
	_tmp34_ = _tmp33_;
	_tmp35_ = g_menu_item_new (_ ("Move to Trash"), _tmp34_);
	_tmp36_ = _tmp35_;
	_g_free0 (_tmp34_);
	_g_variant_unref0 (_tmp32_);
	delete_item = _tmp36_;
	_tmp37_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp38_ = _tmp37_;
	_tmp39_ = scratch_folder_manager_file_get_file (_tmp38_);
	_tmp40_ = _tmp39_;
	_tmp41_ = g_file_get_path (_tmp40_);
	_tmp42_ = _tmp41_;
	_tmp43_ = g_variant_new_string (_tmp42_);
	g_variant_ref_sink (_tmp43_);
	_tmp44_ = _tmp43_;
	_tmp45_ = g_action_print_detailed_name (SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_FIND_GLOBAL, _tmp44_);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_menu_item_new (_ ("Find in Folder…"), _tmp46_);
	_tmp48_ = _tmp47_;
	_g_free0 (_tmp46_);
	_g_variant_unref0 (_tmp44_);
	_g_free0 (_tmp42_);
	search_item = _tmp48_;
	_tmp49_ = g_menu_new ();
	external_actions_section = _tmp49_;
	_tmp50_ = external_actions_section;
	_tmp51_ = file_type;
	_tmp52_ = scratch_folder_manager_folder_item_create_submenu_for_open_in (self, _tmp51_);
	_tmp53_ = _tmp52_;
	g_menu_append_item (_tmp50_, _tmp53_);
	_g_object_unref0 (_tmp53_);
	_tmp54_ = contractor_items;
	if (g_menu_model_get_n_items ((GMenuModel*) _tmp54_) > 0) {
		GMenu* _tmp55_;
		GMenu* _tmp56_;
		_tmp55_ = external_actions_section;
		_tmp56_ = contractor_items;
		g_menu_append_submenu (_tmp55_, _ ("Other Actions"), (GMenuModel*) _tmp56_);
	}
	_tmp57_ = g_menu_new ();
	direct_actions_section = _tmp57_;
	_tmp58_ = scratch_folder_manager_folder_item_create_submenu_for_new (self);
	_tmp59_ = _tmp58_;
	g_menu_append_item (direct_actions_section, _tmp59_);
	_g_object_unref0 (_tmp59_);
	_tmp60_ = rename_menu_item;
	g_menu_append_item (direct_actions_section, _tmp60_);
	_tmp61_ = delete_item;
	g_menu_append_item (direct_actions_section, _tmp61_);
	_tmp62_ = g_menu_new ();
	search_section = _tmp62_;
	_tmp63_ = search_item;
	g_menu_append_item (search_section, _tmp63_);
	_tmp64_ = g_menu_new ();
	menu_model = _tmp64_;
	_tmp65_ = external_actions_section;
	g_menu_append_section (menu_model, NULL, (GMenuModel*) _tmp65_);
	g_menu_append_section (menu_model, NULL, (GMenuModel*) direct_actions_section);
	g_menu_append_section (menu_model, NULL, (GMenuModel*) search_section);
	result = menu_model;
	_g_object_unref0 (search_section);
	_g_object_unref0 (direct_actions_section);
	_g_object_unref0 (external_actions_section);
	_g_object_unref0 (search_item);
	_g_object_unref0 (delete_item);
	_g_object_unref0 (rename_menu_item);
	_g_object_unref0 (contractor_items);
	_g_free0 (file_type);
	_g_object_unref0 (info);
	return result;
}

static GVariant*
_variant_new17 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

GMenuItem*
scratch_folder_manager_folder_item_create_submenu_for_open_in (ScratchFolderManagerFolderItem* self,
                                                               const gchar* file_type)
{
	GMenuItem* open_in_terminal_pane_item = NULL;
	ScratchFolderManagerFile* _tmp0_;
	ScratchFolderManagerFile* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GVariant* _tmp4_;
	GVariant* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GMenuItem* _tmp8_;
	GMenuItem* _tmp9_;
	GMenuItem* _tmp10_;
	GThemedIcon* _tmp11_;
	GThemedIcon* _tmp12_;
	GMenuItem* other_menu_item = NULL;
	ScratchFolderManagerFile* _tmp13_;
	ScratchFolderManagerFile* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GVariant* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GMenuItem* _tmp20_;
	GMenuItem* _tmp21_;
	GMenu* extra_section = NULL;
	GMenu* _tmp22_;
	GMenu* _tmp23_;
	GMenuItem* _tmp24_;
	GMenu* terminal_pane_section = NULL;
	GMenu* _tmp25_;
	GMenu* _tmp26_;
	GMenuItem* _tmp27_;
	const gchar* _tmp28_ = NULL;
	GMenu* open_in_menu = NULL;
	GMenu* _tmp29_;
	GMenu* _tmp30_;
	ScratchFolderManagerFile* _tmp31_;
	ScratchFolderManagerFile* _tmp32_;
	GFile* _tmp33_;
	GFile* _tmp34_;
	GMenu* _tmp35_;
	GMenu* _tmp36_;
	GMenu* _tmp37_;
	GMenuItem* open_in_menu_item = NULL;
	GMenuItem* _tmp38_;
	GMenuItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_file_get_path (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_variant_new_string (_tmp3_);
	g_variant_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_action_print_detailed_name (SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_OPEN_IN_TERMINAL, _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_menu_item_new (_ ("Terminal Pane"), _tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	_g_variant_unref0 (_tmp5_);
	open_in_terminal_pane_item = _tmp9_;
	_tmp10_ = open_in_terminal_pane_item;
	_tmp11_ = (GThemedIcon*) g_themed_icon_new ("panel-bottom-symbolic");
	_tmp12_ = _tmp11_;
	g_menu_item_set_icon (_tmp10_, (GIcon*) _tmp12_);
	_g_object_unref0 (_tmp12_);
	_tmp13_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp14_ = _tmp13_;
	_tmp15_ = scratch_folder_manager_file_get_path (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = _variant_new17 (_tmp16_);
	_tmp18_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_SHOW_APP_CHOOSER, _tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_menu_item_new (_ ("Other Application…"), _tmp19_);
	_tmp21_ = _tmp20_;
	_g_free0 (_tmp19_);
	_g_variant_unref0 (_tmp17_);
	other_menu_item = _tmp21_;
	_tmp22_ = g_menu_new ();
	extra_section = _tmp22_;
	_tmp23_ = extra_section;
	_tmp24_ = other_menu_item;
	g_menu_append_item (_tmp23_, _tmp24_);
	_tmp25_ = g_menu_new ();
	terminal_pane_section = _tmp25_;
	_tmp26_ = terminal_pane_section;
	_tmp27_ = open_in_terminal_pane_item;
	g_menu_append_item (_tmp26_, _tmp27_);
	_tmp28_ = file_type;
	if (_tmp28_ == NULL) {
		_tmp28_ = "inode/directory";
	}
	file_type = _tmp28_;
	_tmp29_ = g_menu_new ();
	open_in_menu = _tmp29_;
	_tmp30_ = terminal_pane_section;
	g_menu_append_section (open_in_menu, NULL, (GMenuModel*) _tmp30_);
	_tmp31_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp32_ = _tmp31_;
	_tmp33_ = scratch_folder_manager_file_get_file (_tmp32_);
	_tmp34_ = _tmp33_;
	_tmp35_ = scratch_utils_create_executable_app_items_for_file (_tmp34_, file_type);
	_tmp36_ = _tmp35_;
	g_menu_append_section (open_in_menu, NULL, (GMenuModel*) _tmp36_);
	_g_object_unref0 (_tmp36_);
	_tmp37_ = extra_section;
	g_menu_append_section (open_in_menu, NULL, (GMenuModel*) _tmp37_);
	_tmp38_ = g_menu_item_new_submenu (_ ("Open In"), (GMenuModel*) open_in_menu);
	open_in_menu_item = _tmp38_;
	result = open_in_menu_item;
	_g_object_unref0 (open_in_menu);
	_g_object_unref0 (terminal_pane_section);
	_g_object_unref0 (extra_section);
	_g_object_unref0 (other_menu_item);
	_g_object_unref0 (open_in_terminal_pane_item);
	return result;
}

GMenuItem*
scratch_folder_manager_folder_item_create_submenu_for_new (ScratchFolderManagerFolderItem* self)
{
	GMenuItem* new_folder_item = NULL;
	ScratchFolderManagerFile* _tmp0_;
	ScratchFolderManagerFile* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GVariant* _tmp4_;
	GVariant* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GMenuItem* _tmp8_;
	GMenuItem* _tmp9_;
	GMenuItem* new_file_item = NULL;
	ScratchFolderManagerFile* _tmp10_;
	ScratchFolderManagerFile* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GVariant* _tmp14_;
	GVariant* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	GMenuItem* _tmp18_;
	GMenuItem* _tmp19_;
	GMenu* new_menu = NULL;
	GMenu* _tmp20_;
	GMenu* _tmp21_;
	GMenuItem* _tmp22_;
	GMenu* _tmp23_;
	GMenuItem* _tmp24_;
	const gchar* template_path = NULL;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	GMenuItem* new_item = NULL;
	GMenu* _tmp38_;
	GMenuItem* _tmp39_;
	GMenu* _tmp40_;
	GMenuItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_file_get_path (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_variant_new_string (_tmp3_);
	g_variant_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_NEW_FOLDER, _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_menu_item_new (_ ("Folder"), _tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	_g_variant_unref0 (_tmp5_);
	new_folder_item = _tmp9_;
	_tmp10_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp11_ = _tmp10_;
	_tmp12_ = scratch_folder_manager_file_get_path (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_variant_new_string (_tmp13_);
	g_variant_ref_sink (_tmp14_);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_NEW_FILE, _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_menu_item_new (_ ("Empty File"), _tmp17_);
	_tmp19_ = _tmp18_;
	_g_free0 (_tmp17_);
	_g_variant_unref0 (_tmp15_);
	new_file_item = _tmp19_;
	_tmp20_ = g_menu_new ();
	new_menu = _tmp20_;
	_tmp21_ = new_menu;
	_tmp22_ = new_folder_item;
	g_menu_append_item (_tmp21_, _tmp22_);
	_tmp23_ = new_menu;
	_tmp24_ = new_file_item;
	g_menu_append_item (_tmp23_, _tmp24_);
	_tmp25_ = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
	template_path = _tmp25_;
	_tmp26_ = template_path;
	if (_tmp26_ != NULL) {
		GMenu* template_submenu = NULL;
		GMenu* _tmp27_;
		guint template_count = 0U;
		const gchar* _tmp28_;
		GFile* _tmp29_;
		GFile* _tmp30_;
		GMenu* _tmp31_;
		guint _tmp32_;
		_tmp27_ = g_menu_new ();
		template_submenu = _tmp27_;
		_tmp28_ = template_path;
		_tmp29_ = g_file_new_for_path (_tmp28_);
		_tmp30_ = _tmp29_;
		_tmp31_ = template_submenu;
		_tmp32_ = scratch_folder_manager_folder_item_load_templates_from_folder (self, _tmp30_, _tmp31_);
		_g_object_unref0 (_tmp30_);
		template_count = _tmp32_;
		if (template_count > ((guint) 0)) {
			GMenu* _tmp36_;
			GMenu* _tmp37_;
			if (template_count > ((guint) SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_MAX_TEMPLATES)) {
				GMenu* _tmp33_;
				GMenuItem* _tmp34_;
				GMenuItem* _tmp35_;
				_tmp33_ = template_submenu;
				_tmp34_ = g_menu_item_new (_ ("…too many templates"), NULL);
				_tmp35_ = _tmp34_;
				g_menu_append_item (_tmp33_, _tmp35_);
				_g_object_unref0 (_tmp35_);
			}
			_tmp36_ = new_menu;
			_tmp37_ = template_submenu;
			g_menu_append_submenu (_tmp36_, _ ("Templates"), (GMenuModel*) _tmp37_);
		}
		_g_object_unref0 (template_submenu);
	}
	_tmp38_ = new_menu;
	_tmp39_ = g_menu_item_new_submenu (_ ("New"), (GMenuModel*) _tmp38_);
	new_item = _tmp39_;
	_tmp40_ = new_menu;
	g_menu_item_set_submenu (new_item, (GMenuModel*) _tmp40_);
	result = new_item;
	_g_object_unref0 (new_menu);
	_g_object_unref0 (new_file_item);
	_g_object_unref0 (new_folder_item);
	return result;
}

static Block25Data*
block25_data_ref (Block25Data* _data25_)
{
	g_atomic_int_inc (&_data25_->_ref_count_);
	return _data25_;
}

static void
block25_data_unref (void * _userdata_)
{
	Block25Data* _data25_;
	_data25_ = (Block25Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data25_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data25_->self;
		_g_object_unref0 (_data25_->template_submenu);
		_g_object_unref0 (self);
		g_slice_free (Block25Data, _data25_);
	}
}

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

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

static gint
__lambda144_ (GFile* a,
              GFile* b)
{
	GCompareFunc _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gint _tmp9_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = ((GCompareFunc) g_strcmp0);
	_tmp1_ = g_file_get_basename (a);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_utf8_strdown (_tmp2_, (gssize) -1);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_get_basename (b);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_utf8_strdown (_tmp6_, (gssize) -1);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp0_ (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	result = _tmp9_;
	return result;
}

static gint
___lambda144__gcompare_func (gconstpointer a,
                             gconstpointer b)
{
	gint result;
	result = __lambda144_ ((GFile*) a, (GFile*) b);
	return result;
}

static gint
__lambda145_ (GFile* a,
              GFile* b)
{
	GCompareFunc _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gint _tmp9_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = ((GCompareFunc) g_strcmp0);
	_tmp1_ = g_file_get_basename (a);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_utf8_strdown (_tmp2_, (gssize) -1);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_get_basename (b);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_utf8_strdown (_tmp6_, (gssize) -1);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp0_ (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	result = _tmp9_;
	return result;
}

static gint
___lambda145__gcompare_func (gconstpointer a,
                             gconstpointer b)
{
	gint result;
	result = __lambda145_ ((GFile*) a, (GFile*) b);
	return result;
}

static void
__lambda146_ (Block25Data* _data25_,
              GFile* template)
{
	ScratchFolderManagerFolderItem* self;
	GMenuItem* template_menuitem = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GVariant* _tmp7_;
	GVariant* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GMenuItem* _tmp11_;
	GMenuItem* _tmp12_;
	self = _data25_->self;
	g_return_if_fail (template != NULL);
	_tmp0_ = g_file_get_basename (template);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_item_get_path ((ScratchFolderManagerItem*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_get_path (template);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_variant_new ("(ss)", _tmp4_, _tmp6_, NULL);
	g_variant_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_action_print_detailed_name (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_PREFIX SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_NEW_FROM_TEMPLATE, _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_menu_item_new (_tmp1_, _tmp10_);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp10_);
	_g_variant_unref0 (_tmp8_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp1_);
	template_menuitem = _tmp12_;
	g_menu_append_item (_data25_->template_submenu, template_menuitem);
	_g_object_unref0 (template_menuitem);
}

static void
___lambda146__gfunc (gconstpointer data,
                     gpointer self)
{
	__lambda146_ (self, (GFile*) data);
}

static guint
scratch_folder_manager_folder_item_load_templates_from_folder (ScratchFolderManagerFolderItem* self,
                                                               GFile* template_folder,
                                                               GMenu* template_submenu)
{
	Block25Data* _data25_;
	GMenu* _tmp0_;
	GList* template_list = NULL;
	GList* folder_list = NULL;
	GFileEnumerator* enumerator = NULL;
	GFileQueryInfoFlags flags = 0U;
	guint count = 0U;
	GList* fl = NULL;
	GList* _tmp23_;
	GList* _tmp41_;
	GError* _inner_error0_ = NULL;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (template_folder != NULL, 0U);
	g_return_val_if_fail (template_submenu != NULL, 0U);
	_data25_ = g_slice_new0 (Block25Data);
	_data25_->_ref_count_ = 1;
	_data25_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (template_submenu);
	_g_object_unref0 (_data25_->template_submenu);
	_data25_->template_submenu = _tmp0_;
	template_list = NULL;
	folder_list = NULL;
	flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
	count = (guint) 0;
	{
		GFileEnumerator* _tmp1_ = NULL;
		GFileEnumerator* _tmp2_;
		GFileEnumerator* _tmp3_;
		GFile* location = NULL;
		GFileInfo* info = NULL;
		GFileEnumerator* _tmp4_;
		GFileInfo* _tmp5_;
		_tmp2_ = g_file_enumerate_children (template_folder, "standard::*", flags, NULL, &_inner_error0_);
		_tmp1_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = _tmp1_;
		_tmp1_ = NULL;
		_g_object_unref0 (enumerator);
		enumerator = _tmp3_;
		_tmp4_ = enumerator;
		_tmp5_ = g_file_enumerator_next_file (_tmp4_, NULL, &_inner_error0_);
		info = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (location);
			_g_object_unref0 (_tmp1_);
			goto __catch0_g_error;
		}
		while (TRUE) {
			gboolean _tmp6_ = FALSE;
			GFileInfo* _tmp8_;
			GFileInfo* _tmp18_ = NULL;
			GFileEnumerator* _tmp19_;
			GFileInfo* _tmp20_;
			GFileInfo* _tmp21_;
			if (count < ((guint) SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_MAX_TEMPLATES)) {
				GFileInfo* _tmp7_;
				_tmp7_ = info;
				_tmp6_ = _tmp7_ != NULL;
			} else {
				_tmp6_ = FALSE;
			}
			if (!_tmp6_) {
				break;
			}
			_tmp8_ = info;
			if (!g_file_info_get_attribute_boolean (_tmp8_, G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP)) {
				GFileInfo* _tmp9_;
				const gchar* _tmp10_;
				GFile* _tmp11_;
				GFileInfo* _tmp12_;
				guint _tmp17_;
				_tmp9_ = info;
				_tmp10_ = g_file_info_get_name (_tmp9_);
				_tmp11_ = g_file_get_child (template_folder, _tmp10_);
				_g_object_unref0 (location);
				location = _tmp11_;
				_tmp12_ = info;
				if (g_file_info_get_file_type (_tmp12_) == G_FILE_TYPE_DIRECTORY) {
					GFile* _tmp13_;
					GFile* _tmp14_;
					_tmp13_ = location;
					_tmp14_ = _g_object_ref0 (_tmp13_);
					folder_list = g_list_prepend (folder_list, _tmp14_);
				} else {
					GFile* _tmp15_;
					GFile* _tmp16_;
					_tmp15_ = location;
					_tmp16_ = _g_object_ref0 (_tmp15_);
					template_list = g_list_prepend (template_list, _tmp16_);
				}
				_tmp17_ = count;
				count = _tmp17_ + 1;
			}
			_tmp19_ = enumerator;
			_tmp20_ = g_file_enumerator_next_file (_tmp19_, NULL, &_inner_error0_);
			_tmp18_ = _tmp20_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (info);
				_g_object_unref0 (location);
				_g_object_unref0 (_tmp1_);
				goto __catch0_g_error;
			}
			_tmp21_ = _tmp18_;
			_tmp18_ = NULL;
			_g_object_unref0 (info);
			info = _tmp21_;
			_g_object_unref0 (_tmp18_);
		}
		_g_object_unref0 (info);
		_g_object_unref0 (location);
		_g_object_unref0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = (guint) 0;
		_g_object_unref0 (enumerator);
		(folder_list == NULL) ? NULL : (folder_list = (_g_list_free__g_object_unref0_ (folder_list), NULL));
		(template_list == NULL) ? NULL : (template_list = (_g_list_free__g_object_unref0_ (template_list), NULL));
		block25_data_unref (_data25_);
		_data25_ = NULL;
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		guint _tmp22_ = 0U;
		_g_object_unref0 (enumerator);
		(folder_list == NULL) ? NULL : (folder_list = (_g_list_free__g_object_unref0_ (folder_list), NULL));
		(template_list == NULL) ? NULL : (template_list = (_g_list_free__g_object_unref0_ (template_list), NULL));
		block25_data_unref (_data25_);
		_data25_ = 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 _tmp22_;
	}
	folder_list = g_list_sort (folder_list, ___lambda144__gcompare_func);
	_tmp23_ = folder_list;
	fl = _tmp23_;
	while (TRUE) {
		gboolean _tmp24_ = FALSE;
		GList* _tmp25_;
		GFile* folder = NULL;
		GList* _tmp26_;
		gconstpointer _tmp27_;
		GFile* _tmp28_;
		GMenu* folder_submenu = NULL;
		GMenu* _tmp29_;
		GMenuItem* folder_submenuitem = NULL;
		GFile* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		GMenu* _tmp33_;
		GMenuItem* _tmp34_;
		GMenuItem* _tmp35_;
		guint sub_count = 0U;
		GFile* _tmp36_;
		GMenu* _tmp37_;
		GList* _tmp39_;
		GList* _tmp40_;
		_tmp25_ = fl;
		if (_tmp25_ != NULL) {
			_tmp24_ = count < ((guint) SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_MAX_TEMPLATES);
		} else {
			_tmp24_ = FALSE;
		}
		if (!_tmp24_) {
			break;
		}
		_tmp26_ = fl;
		_tmp27_ = _tmp26_->data;
		_tmp28_ = _g_object_ref0 ((GFile*) _tmp27_);
		folder = _tmp28_;
		_tmp29_ = g_menu_new ();
		folder_submenu = _tmp29_;
		_tmp30_ = folder;
		_tmp31_ = g_file_get_basename (_tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = folder_submenu;
		_tmp34_ = g_menu_item_new_submenu (_tmp32_, (GMenuModel*) _tmp33_);
		_tmp35_ = _tmp34_;
		_g_free0 (_tmp32_);
		folder_submenuitem = _tmp35_;
		_tmp36_ = folder;
		_tmp37_ = folder_submenu;
		sub_count = scratch_folder_manager_folder_item_load_templates_from_folder (self, _tmp36_, _tmp37_);
		if (sub_count > ((guint) 0)) {
			GMenuItem* _tmp38_;
			_tmp38_ = folder_submenuitem;
			g_menu_append_item (_data25_->template_submenu, _tmp38_);
			count += sub_count;
		} else {
			count -= (guint) 1;
		}
		_tmp39_ = fl;
		_tmp40_ = _tmp39_->next;
		fl = _tmp40_;
		_g_object_unref0 (folder_submenuitem);
		_g_object_unref0 (folder_submenu);
		_g_object_unref0 (folder);
	}
	if (count > ((guint) SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_MAX_TEMPLATES)) {
		g_warning ("FolderItem.vala:308: too many templates! %u", count);
		result = count;
		_g_object_unref0 (enumerator);
		(folder_list == NULL) ? NULL : (folder_list = (_g_list_free__g_object_unref0_ (folder_list), NULL));
		(template_list == NULL) ? NULL : (template_list = (_g_list_free__g_object_unref0_ (template_list), NULL));
		block25_data_unref (_data25_);
		_data25_ = NULL;
		return result;
	}
	template_list = g_list_sort (template_list, ___lambda145__gcompare_func);
	_tmp41_ = template_list;
	g_list_foreach (_tmp41_, ___lambda146__gfunc, _data25_);
	result = count;
	_g_object_unref0 (enumerator);
	(folder_list == NULL) ? NULL : (folder_list = (_g_list_free__g_object_unref0_ (folder_list), NULL));
	(template_list == NULL) ? NULL : (template_list = (_g_list_free__g_object_unref0_ (template_list), NULL));
	block25_data_unref (_data25_);
	_data25_ = NULL;
	return result;
}

void
scratch_folder_manager_folder_item_remove_all_badges (ScratchFolderManagerFolderItem* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _child_it = NULL;
		GeeCollection* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeIterator* _tmp3_;
		GeeIterator* _tmp4_;
		_tmp0_ = code_widgets_source_list_expandable_item_get_children ((CodeWidgetsSourceListExpandableItem*) self);
		_tmp1_ = _tmp0_;
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_iterable_iterator ((GeeIterable*) _tmp2_);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp2_);
		_child_it = _tmp4_;
		while (TRUE) {
			GeeIterator* _tmp5_;
			CodeWidgetsSourceListItem* child = NULL;
			GeeIterator* _tmp6_;
			gpointer _tmp7_;
			CodeWidgetsSourceListItem* _tmp8_;
			_tmp5_ = _child_it;
			if (!gee_iterator_next (_tmp5_)) {
				break;
			}
			_tmp6_ = _child_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			child = (CodeWidgetsSourceListItem*) _tmp7_;
			_tmp8_ = child;
			scratch_folder_manager_folder_item_remove_badge (self, _tmp8_);
			_g_object_unref0 (child);
		}
		_g_object_unref0 (_child_it);
	}
}

static void
scratch_folder_manager_folder_item_remove_badge (ScratchFolderManagerFolderItem* self,
                                                 CodeWidgetsSourceListItem* item)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	if (SCRATCH_FOLDER_MANAGER_IS_FOLDER_ITEM (item)) {
		scratch_folder_manager_folder_item_remove_all_badges (G_TYPE_CHECK_INSTANCE_CAST (item, SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem));
	}
	code_widgets_source_list_item_set_badge (item, "");
}

void
scratch_folder_manager_folder_item_add (ScratchFolderManagerFolderItem* self,
                                        CodeWidgetsSourceListItem* item)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	if (self->priv->has_dummy) {
		guint _tmp1_;
		guint _tmp2_;
		_tmp1_ = code_widgets_source_list_expandable_item_get_n_children ((CodeWidgetsSourceListExpandableItem*) self);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_ == ((guint) 1);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		CodeWidgetsSourceListItem* _tmp3_;
		_tmp3_ = self->priv->dummy;
		code_widgets_source_list_expandable_item_remove (G_TYPE_CHECK_INSTANCE_CAST (self, CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem), _tmp3_);
		self->priv->has_dummy = FALSE;
	}
	code_widgets_source_list_expandable_item_add ((CodeWidgetsSourceListExpandableItem*) G_TYPE_CHECK_INSTANCE_CAST (self, SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItem), item);
}

void
scratch_folder_manager_folder_item_remove (ScratchFolderManagerFolderItem* self,
                                           CodeWidgetsSourceListItem* item)
{
	gboolean _tmp12_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	if (SCRATCH_FOLDER_MANAGER_IS_FOLDER_ITEM (item)) {
		ScratchFolderManagerFolderItem* folder = NULL;
		ScratchFolderManagerFolderItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (item, SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem));
		folder = _tmp0_;
		{
			GeeIterator* _child_it = NULL;
			ScratchFolderManagerFolderItem* _tmp1_;
			GeeCollection* _tmp2_;
			GeeCollection* _tmp3_;
			GeeCollection* _tmp4_;
			GeeIterator* _tmp5_;
			GeeIterator* _tmp6_;
			_tmp1_ = folder;
			_tmp2_ = code_widgets_source_list_expandable_item_get_children ((CodeWidgetsSourceListExpandableItem*) _tmp1_);
			_tmp3_ = _tmp2_;
			_tmp4_ = _tmp3_;
			_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
			_tmp6_ = _tmp5_;
			_g_object_unref0 (_tmp4_);
			_child_it = _tmp6_;
			while (TRUE) {
				GeeIterator* _tmp7_;
				CodeWidgetsSourceListItem* child = NULL;
				GeeIterator* _tmp8_;
				gpointer _tmp9_;
				ScratchFolderManagerFolderItem* _tmp10_;
				CodeWidgetsSourceListItem* _tmp11_;
				_tmp7_ = _child_it;
				if (!gee_iterator_next (_tmp7_)) {
					break;
				}
				_tmp8_ = _child_it;
				_tmp9_ = gee_iterator_get (_tmp8_);
				child = (CodeWidgetsSourceListItem*) _tmp9_;
				_tmp10_ = folder;
				_tmp11_ = child;
				scratch_folder_manager_folder_item_remove (_tmp10_, _tmp11_);
				_g_object_unref0 (child);
			}
			_g_object_unref0 (_child_it);
		}
		_g_object_unref0 (folder);
	}
	code_widgets_source_list_expandable_item_remove (G_TYPE_CHECK_INSTANCE_CAST (self, CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem), item);
	if (self->priv->has_dummy) {
		_tmp12_ = TRUE;
	} else {
		guint _tmp13_;
		guint _tmp14_;
		_tmp13_ = code_widgets_source_list_expandable_item_get_n_children ((CodeWidgetsSourceListExpandableItem*) self);
		_tmp14_ = _tmp13_;
		_tmp12_ = _tmp14_ > ((guint) 0);
	}
	if (!_tmp12_) {
		CodeWidgetsSourceListItem* _tmp15_;
		_tmp15_ = self->priv->dummy;
		code_widgets_source_list_expandable_item_add (G_TYPE_CHECK_INSTANCE_CAST (self, CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem), _tmp15_);
		self->priv->has_dummy = TRUE;
	}
}

void
scratch_folder_manager_folder_item_clear (ScratchFolderManagerFolderItem* self)
{
	g_return_if_fail (self != NULL);
	code_widgets_source_list_expandable_item_clear (G_TYPE_CHECK_INSTANCE_CAST (self, CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem));
	self->priv->has_dummy = FALSE;
}

static void
scratch_folder_manager_folder_item_real_on_changed (ScratchFolderManagerFolderItem* self,
                                                    GFile* source,
                                                    GFile* dest,
                                                    GFileMonitorEvent event)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	ScratchFolderManagerFileView* _tmp3_;
	ScratchFolderManagerFileView* _tmp4_;
	g_return_if_fail (source != NULL);
	_tmp0_ = g_file_get_basename (source);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_str_has_prefix (_tmp1_, ".goutputstream");
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		return;
	}
	_tmp3_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
	_tmp4_ = _tmp3_;
	scratch_folder_manager_file_view_folder_item_update_hook (_tmp4_, source, dest, event);
	if (!self->priv->children_loaded) {
		switch (event) {
			case G_FILE_MONITOR_EVENT_DELETED:
			{
				ScratchFolderManagerFile* _tmp5_;
				ScratchFolderManagerFile* _tmp6_;
				gboolean _tmp7_;
				gboolean _tmp8_;
				_tmp5_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
				_tmp6_ = _tmp5_;
				scratch_folder_manager_file_invalidate_cache (_tmp6_);
				_tmp7_ = code_widgets_source_list_expandable_item_get_expanded ((CodeWidgetsSourceListExpandableItem*) self);
				_tmp8_ = _tmp7_;
				if (_tmp8_) {
					g_signal_emit_by_name ((CodeWidgetsSourceListExpandableItem*) self, "toggled");
				}
				break;
			}
			case G_FILE_MONITOR_EVENT_CREATED:
			{
				ScratchFolderManagerFile* _tmp9_;
				ScratchFolderManagerFile* _tmp10_;
				gboolean _tmp11_;
				gboolean _tmp12_;
				_tmp9_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
				_tmp10_ = _tmp9_;
				scratch_folder_manager_file_invalidate_cache (_tmp10_);
				_tmp11_ = code_widgets_source_list_expandable_item_get_expanded ((CodeWidgetsSourceListExpandableItem*) self);
				_tmp12_ = _tmp11_;
				if (_tmp12_) {
					g_signal_emit_by_name ((CodeWidgetsSourceListExpandableItem*) self, "toggled");
				}
				break;
			}
			case G_FILE_MONITOR_EVENT_RENAMED:
			case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
			case G_FILE_MONITOR_EVENT_UNMOUNTED:
			case G_FILE_MONITOR_EVENT_CHANGED:
			case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
			case G_FILE_MONITOR_EVENT_MOVED:
			case G_FILE_MONITOR_EVENT_MOVED_IN:
			case G_FILE_MONITOR_EVENT_MOVED_OUT:
			case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
			{
				break;
			}
			default:
			break;
		}
	} else {
		switch (event) {
			case G_FILE_MONITOR_EVENT_DELETED:
			{
				ScratchFolderManagerItem* path_item = NULL;
				gchar* _tmp13_;
				gchar* _tmp14_;
				ScratchFolderManagerItem* _tmp15_;
				ScratchFolderManagerItem* _tmp16_;
				ScratchFolderManagerItem* _tmp17_;
				_tmp13_ = g_file_get_path (source);
				_tmp14_ = _tmp13_;
				_tmp15_ = scratch_folder_manager_folder_item_find_item_for_path (self, _tmp14_);
				_tmp16_ = _tmp15_;
				_g_free0 (_tmp14_);
				path_item = _tmp16_;
				_tmp17_ = path_item;
				if (_tmp17_ != NULL) {
					ScratchFolderManagerItem* _tmp18_;
					_tmp18_ = path_item;
					scratch_folder_manager_folder_item_remove (self, (CodeWidgetsSourceListItem*) _tmp18_);
				}
				_g_object_unref0 (path_item);
				break;
			}
			case G_FILE_MONITOR_EVENT_CREATED:
			{
				ScratchFolderManagerItem* path_item = NULL;
				gchar* _tmp19_;
				gchar* _tmp20_;
				ScratchFolderManagerItem* _tmp21_;
				ScratchFolderManagerItem* _tmp22_;
				ScratchFolderManagerItem* _tmp23_;
				if (g_file_query_exists (source, NULL) == FALSE) {
					return;
				}
				_tmp19_ = g_file_get_path (source);
				_tmp20_ = _tmp19_;
				_tmp21_ = scratch_folder_manager_folder_item_find_item_for_path (self, _tmp20_);
				_tmp22_ = _tmp21_;
				_g_free0 (_tmp20_);
				path_item = _tmp22_;
				_tmp23_ = path_item;
				if (_tmp23_ == NULL) {
					ScratchFolderManagerFile* file = NULL;
					gchar* _tmp24_;
					gchar* _tmp25_;
					ScratchFolderManagerFile* _tmp26_;
					ScratchFolderManagerFile* _tmp27_;
					ScratchFolderManagerFile* _tmp28_;
					gboolean _tmp29_;
					gboolean _tmp30_;
					ScratchFolderManagerItem* _tmp42_;
					_tmp24_ = g_file_get_path (source);
					_tmp25_ = _tmp24_;
					_tmp26_ = scratch_folder_manager_file_new (_tmp25_);
					_tmp27_ = _tmp26_;
					_g_free0 (_tmp25_);
					file = _tmp27_;
					_tmp28_ = file;
					_tmp29_ = scratch_folder_manager_file_get_is_valid_directory (_tmp28_);
					_tmp30_ = _tmp29_;
					if (_tmp30_) {
						ScratchFolderManagerFile* _tmp31_;
						ScratchFolderManagerFileView* _tmp32_;
						ScratchFolderManagerFileView* _tmp33_;
						ScratchFolderManagerFolderItem* _tmp34_;
						_tmp31_ = file;
						_tmp32_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
						_tmp33_ = _tmp32_;
						_tmp34_ = scratch_folder_manager_folder_item_new (_tmp31_, _tmp33_);
						_g_object_unref0 (path_item);
						path_item = (ScratchFolderManagerItem*) _tmp34_;
					} else {
						ScratchFolderManagerFile* _tmp35_;
						gboolean _tmp36_;
						gboolean _tmp37_;
						_tmp35_ = file;
						_tmp36_ = scratch_folder_manager_file_get_is_valid_textfile (_tmp35_);
						_tmp37_ = _tmp36_;
						if (_tmp37_) {
							ScratchFolderManagerFile* _tmp38_;
							ScratchFolderManagerFileView* _tmp39_;
							ScratchFolderManagerFileView* _tmp40_;
							ScratchFolderManagerFileItem* _tmp41_;
							_tmp38_ = file;
							_tmp39_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
							_tmp40_ = _tmp39_;
							_tmp41_ = scratch_folder_manager_file_item_new (_tmp38_, _tmp40_);
							_g_object_unref0 (path_item);
							path_item = (ScratchFolderManagerItem*) _tmp41_;
						}
					}
					_tmp42_ = path_item;
					scratch_folder_manager_folder_item_add (self, (CodeWidgetsSourceListItem*) _tmp42_);
					_g_object_unref0 (file);
				}
				_g_object_unref0 (path_item);
				break;
			}
			case G_FILE_MONITOR_EVENT_RENAMED:
			case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
			case G_FILE_MONITOR_EVENT_UNMOUNTED:
			case G_FILE_MONITOR_EVENT_CHANGED:
			case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
			case G_FILE_MONITOR_EVENT_MOVED:
			case G_FILE_MONITOR_EVENT_MOVED_IN:
			case G_FILE_MONITOR_EVENT_MOVED_OUT:
			case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
			{
				break;
			}
			default:
			break;
		}
	}
	if (event == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
		ScratchFolderManagerProjectFolderItem* root = NULL;
		ScratchFolderManagerProjectFolderItem* _tmp43_;
		ScratchFolderManagerProjectFolderItem* _tmp44_;
		_tmp43_ = scratch_folder_manager_item_get_root_folder ((ScratchFolderManagerItem*) self, (CodeWidgetsSourceListExpandableItem*) self);
		root = _tmp43_;
		_tmp44_ = root;
		if (_tmp44_ != NULL) {
			ScratchFolderManagerProjectFolderItem* _tmp45_;
			_tmp45_ = root;
			scratch_folder_manager_project_folder_item_child_folder_changed (_tmp45_, self);
		}
		_g_object_unref0 (root);
	}
}

void
scratch_folder_manager_folder_item_on_changed (ScratchFolderManagerFolderItem* self,
                                               GFile* source,
                                               GFile* dest,
                                               GFileMonitorEvent event)
{
	ScratchFolderManagerFolderItemClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_GET_CLASS (self);
	if (_klass_->on_changed) {
		_klass_->on_changed (self, source, dest, event);
	}
}

static ScratchFolderManagerItem*
scratch_folder_manager_folder_item_find_item_for_path (ScratchFolderManagerFolderItem* self,
                                                       const gchar* path)
{
	ScratchFolderManagerItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (path != NULL, NULL);
	{
		GeeIterator* _item_it = NULL;
		GeeCollection* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeIterator* _tmp3_;
		GeeIterator* _tmp4_;
		_tmp0_ = code_widgets_source_list_expandable_item_get_children ((CodeWidgetsSourceListExpandableItem*) self);
		_tmp1_ = _tmp0_;
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_iterable_iterator ((GeeIterable*) _tmp2_);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp2_);
		_item_it = _tmp4_;
		while (TRUE) {
			GeeIterator* _tmp5_;
			CodeWidgetsSourceListItem* item = NULL;
			GeeIterator* _tmp6_;
			gpointer _tmp7_;
			gboolean _tmp8_ = FALSE;
			CodeWidgetsSourceListItem* _tmp9_;
			_tmp5_ = _item_it;
			if (!gee_iterator_next (_tmp5_)) {
				break;
			}
			_tmp6_ = _item_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			item = (CodeWidgetsSourceListItem*) _tmp7_;
			_tmp9_ = item;
			if (SCRATCH_FOLDER_MANAGER_IS_ITEM (_tmp9_)) {
				CodeWidgetsSourceListItem* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				_tmp10_ = item;
				_tmp11_ = scratch_folder_manager_item_get_path (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItem));
				_tmp12_ = _tmp11_;
				_tmp13_ = _tmp12_;
				_tmp8_ = g_strcmp0 (_tmp13_, path) == 0;
				_g_free0 (_tmp13_);
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				CodeWidgetsSourceListItem* _tmp14_;
				ScratchFolderManagerItem* _tmp15_;
				_tmp14_ = item;
				_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, SCRATCH_FOLDER_MANAGER_TYPE_ITEM, ScratchFolderManagerItem));
				result = _tmp15_;
				_g_object_unref0 (item);
				_g_object_unref0 (_item_it);
				return result;
			}
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_it);
	}
	result = NULL;
	return result;
}

static Block26Data*
block26_data_ref (Block26Data* _data26_)
{
	g_atomic_int_inc (&_data26_->_ref_count_);
	return _data26_;
}

static void
block26_data_unref (void * _userdata_)
{
	Block26Data* _data26_;
	_data26_ = (Block26Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data26_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data26_->self;
		_g_free0 (_data26_->template_path);
		_g_object_unref0 (self);
		g_slice_free (Block26Data, _data26_);
	}
}

static Block27Data*
block27_data_ref (Block27Data* _data27_)
{
	g_atomic_int_inc (&_data27_->_ref_count_);
	return _data27_;
}

static void
block27_data_unref (void * _userdata_)
{
	Block27Data* _data27_;
	_data27_ = (Block27Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data27_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data27_->_data26_->self;
		block26_data_unref (_data27_->_data26_);
		_data27_->_data26_ = NULL;
		g_slice_free (Block27Data, _data27_);
	}
}

static void
___lambda119_ (Block27Data* _data27_)
{
	Block26Data* _data26_;
	ScratchFolderManagerFolderItem* self;
	_data26_ = _data27_->_data26_;
	self = _data26_->self;
	g_signal_handler_disconnect ((GObject*) self, _data27_->once);
	scratch_folder_manager_folder_item_copy_template (self, _data26_->template_path);
}

static void
____lambda119__scratch_folder_manager_folder_item_children_finished_loading (ScratchFolderManagerFolderItem* _sender,
                                                                             gpointer self)
{
	___lambda119_ (self);
}

void
scratch_folder_manager_folder_item_on_add_template (ScratchFolderManagerFolderItem* self,
                                                    const gchar* template_path)
{
	Block26Data* _data26_;
	gchar* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (template_path != NULL);
	_data26_ = g_slice_new0 (Block26Data);
	_data26_->_ref_count_ = 1;
	_data26_->self = g_object_ref (self);
	_tmp0_ = g_strdup (template_path);
	_g_free0 (_data26_->template_path);
	_data26_->template_path = _tmp0_;
	_tmp1_ = code_widgets_source_list_expandable_item_get_expanded ((CodeWidgetsSourceListExpandableItem*) self);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		Block27Data* _data27_;
		gulong _tmp3_;
		_data27_ = g_slice_new0 (Block27Data);
		_data27_->_ref_count_ = 1;
		_data27_->_data26_ = block26_data_ref (_data26_);
		code_widgets_source_list_expandable_item_set_expanded ((CodeWidgetsSourceListExpandableItem*) self, TRUE);
		_data27_->once = (gulong) 0;
		_tmp3_ = g_signal_connect_data (self, "children-finished-loading", (GCallback) ____lambda119__scratch_folder_manager_folder_item_children_finished_loading, block27_data_ref (_data27_), (GClosureNotify) block27_data_unref, 0);
		_data27_->once = _tmp3_;
		block27_data_unref (_data27_);
		_data27_ = NULL;
	} else {
		scratch_folder_manager_folder_item_copy_template (self, _data26_->template_path);
	}
	block26_data_unref (_data26_);
	_data26_ = NULL;
}

static Block28Data*
block28_data_ref (Block28Data* _data28_)
{
	g_atomic_int_inc (&_data28_->_ref_count_);
	return _data28_;
}

static void
block28_data_unref (void * _userdata_)
{
	Block28Data* _data28_;
	_data28_ = (Block28Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data28_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data28_->self;
		_g_object_unref0 (_data28_->new_file);
		_g_object_unref0 (self);
		g_slice_free (Block28Data, _data28_);
	}
}

static Block29Data*
block29_data_ref (Block29Data* _data29_)
{
	g_atomic_int_inc (&_data29_->_ref_count_);
	return _data29_;
}

static void
block29_data_unref (void * _userdata_)
{
	Block29Data* _data29_;
	_data29_ = (Block29Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data29_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data29_->_data28_->self;
		_g_free0 (_data29_->path);
		block28_data_unref (_data29_->_data28_);
		_data29_->_data28_ = NULL;
		g_slice_free (Block29Data, _data29_);
	}
}

static GVariant*
_variant_new18 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static gboolean
__lambda121_ (Block29Data* _data29_)
{
	Block28Data* _data28_;
	ScratchFolderManagerFolderItem* self;
	GSimpleAction* rename_action = NULL;
	ScratchFolderManagerFileView* _tmp0_;
	ScratchFolderManagerFileView* _tmp1_;
	GSimpleActionGroup* _tmp2_;
	GSimpleActionGroup* _tmp3_;
	GSimpleAction* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GSimpleAction* _tmp6_;
	gboolean result;
	_data28_ = _data29_->_data28_;
	self = _data28_->self;
	_tmp0_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_file_view_get_actions (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = scratch_utils_action_from_group (SCRATCH_FOLDER_MANAGER_FILE_VIEW_ACTION_RENAME_FILE, _tmp3_);
	rename_action = _tmp4_;
	_tmp6_ = rename_action;
	if (_tmp6_ != NULL) {
		GSimpleAction* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = rename_action;
		_tmp8_ = g_action_get_enabled ((GAction*) _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GSimpleAction* _tmp10_;
		GVariant* _tmp11_;
		_tmp10_ = rename_action;
		_tmp11_ = _variant_new18 (_data29_->path);
		g_signal_emit_by_name (_tmp10_, "activate", _tmp11_);
		_g_variant_unref0 (_tmp11_);
	} else {
		g_critical ("FolderItem.vala:530: Rename action not available");
	}
	result = G_SOURCE_REMOVE;
	_g_object_unref0 (rename_action);
	return result;
}

static gboolean
___lambda121__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda121_ (self);
	return result;
}

static void
__lambda120_ (Block28Data* _data28_)
{
	ScratchFolderManagerFolderItem* self;
	Block29Data* _data29_;
	GFile* _tmp0_;
	gchar* _tmp1_;
	self = _data28_->self;
	_data29_ = g_slice_new0 (Block29Data);
	_data29_->_ref_count_ = 1;
	_data29_->_data28_ = block28_data_ref (_data28_);
	g_signal_handler_disconnect ((GObject*) self, _data28_->once);
	_tmp0_ = _data28_->new_file;
	_tmp1_ = g_file_get_path (_tmp0_);
	_data29_->path = _tmp1_;
	g_timeout_add_full (G_PRIORITY_DEFAULT, SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_RENAME_AFTER_NEW_DELAY_MSEC, ___lambda121__gsource_func, block29_data_ref (_data29_), block29_data_unref);
	block29_data_unref (_data29_);
	_data29_ = NULL;
}

static void
___lambda120__code_widgets_source_list_expandable_item_child_added (CodeWidgetsSourceListExpandableItem* _sender,
                                                                    CodeWidgetsSourceListItem* item,
                                                                    gpointer self)
{
	__lambda120_ (self);
}

static void
scratch_folder_manager_folder_item_copy_template (ScratchFolderManagerFolderItem* self,
                                                  const gchar* template_path)
{
	Block28Data* _data28_;
	ScratchFolderManagerFile* _tmp0_;
	ScratchFolderManagerFile* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GFile* template_file = NULL;
	GFile* _tmp4_;
	GFile* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	ScratchFolderManagerFile* _tmp8_;
	ScratchFolderManagerFile* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GFile* _tmp14_;
	gint n = 0;
	GFile* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gulong _tmp33_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (template_path != NULL);
	_data28_ = g_slice_new0 (Block28Data);
	_data28_->_ref_count_ = 1;
	_data28_->self = g_object_ref (self);
	_tmp0_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_file_get_is_executable (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		g_warning ("FolderItem.vala:490: Unable to open parent folder");
		block28_data_unref (_data28_);
		_data28_ = NULL;
		return;
	}
	_tmp4_ = g_file_new_for_path (template_path);
	template_file = _tmp4_;
	_tmp5_ = template_file;
	_tmp6_ = g_file_get_basename (_tmp5_);
	_tmp7_ = _tmp6_;
	code_widgets_source_list_item_set_name ((CodeWidgetsSourceListItem*) self, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = scratch_folder_manager_file_get_file (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = code_widgets_source_list_item_get_name ((CodeWidgetsSourceListItem*) self);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_file_get_child (_tmp11_, _tmp13_);
	_data28_->new_file = _tmp14_;
	n = 1;
	while (TRUE) {
		GFile* _tmp15_;
		ScratchFolderManagerFile* _tmp16_;
		ScratchFolderManagerFile* _tmp17_;
		GFile* _tmp18_;
		GFile* _tmp19_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		GFile* _tmp24_;
		gint _tmp25_;
		_tmp15_ = _data28_->new_file;
		if (!g_file_query_exists (_tmp15_, NULL)) {
			break;
		}
		_tmp16_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp17_ = _tmp16_;
		_tmp18_ = scratch_folder_manager_file_get_file (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = code_widgets_source_list_item_get_name ((CodeWidgetsSourceListItem*) self);
		_tmp21_ = _tmp20_;
		_tmp22_ = g_strdup_printf ("%s %d", _tmp21_, n);
		_tmp23_ = _tmp22_;
		_tmp24_ = g_file_get_child (_tmp19_, _tmp23_);
		_g_object_unref0 (_data28_->new_file);
		_data28_->new_file = _tmp24_;
		_g_free0 (_tmp23_);
		_tmp25_ = n;
		n = _tmp25_ + 1;
	}
	_tmp26_ = _data28_->new_file;
	_tmp27_ = g_file_get_basename (_tmp26_);
	_tmp28_ = _tmp27_;
	code_widgets_source_list_item_set_name ((CodeWidgetsSourceListItem*) self, _tmp28_);
	_g_free0 (_tmp28_);
	{
		GFile* _tmp29_;
		GFile* _tmp30_;
		_tmp29_ = template_file;
		_tmp30_ = _data28_->new_file;
		g_file_copy (_tmp29_, _tmp30_, (G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME | G_FILE_COPY_TARGET_DEFAULT_PERMS) | G_FILE_COPY_NOFOLLOW_SYMLINKS, NULL, NULL, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp31_;
		const gchar* _tmp32_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp31_ = e;
		_tmp32_ = _tmp31_->message;
		g_warning ("FolderItem.vala:514: Error copying template %s", _tmp32_);
		_g_error_free0 (e);
		_g_object_unref0 (template_file);
		block28_data_unref (_data28_);
		_data28_ = NULL;
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (template_file);
		block28_data_unref (_data28_);
		_data28_ = 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;
	}
	_data28_->once = (gulong) 0;
	_tmp33_ = g_signal_connect_data ((CodeWidgetsSourceListExpandableItem*) self, "child-added", (GCallback) ___lambda120__code_widgets_source_list_expandable_item_child_added, block28_data_ref (_data28_), (GClosureNotify) block28_data_unref, 0);
	_data28_->once = _tmp33_;
	_g_object_unref0 (template_file);
	block28_data_unref (_data28_);
	_data28_ = NULL;
}

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data30_->self;
		_g_free0 (_data30_->name);
		_g_object_unref0 (self);
		g_slice_free (Block30Data, _data30_);
	}
}

static Block31Data*
block31_data_ref (Block31Data* _data31_)
{
	g_atomic_int_inc (&_data31_->_ref_count_);
	return _data31_;
}

static void
block31_data_unref (void * _userdata_)
{
	Block31Data* _data31_;
	_data31_ = (Block31Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data31_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data31_->_data30_->self;
		block30_data_unref (_data31_->_data30_);
		_data31_->_data30_ = NULL;
		g_slice_free (Block31Data, _data31_);
	}
}

static void
___lambda115_ (Block31Data* _data31_)
{
	Block30Data* _data30_;
	ScratchFolderManagerFolderItem* self;
	const gchar* _tmp0_;
	_data30_ = _data31_->_data30_;
	self = _data30_->self;
	g_signal_handler_disconnect ((GObject*) self, _data31_->once);
	_tmp0_ = _data30_->name;
	scratch_folder_manager_folder_item_rename_new (self, _tmp0_, _data30_->is_folder);
}

static void
____lambda115__scratch_folder_manager_folder_item_children_finished_loading (ScratchFolderManagerFolderItem* _sender,
                                                                             gpointer self)
{
	___lambda115_ (self);
}

void
scratch_folder_manager_folder_item_on_add_new (ScratchFolderManagerFolderItem* self,
                                               gboolean is_folder)
{
	Block30Data* _data30_;
	ScratchFolderManagerFile* _tmp0_;
	ScratchFolderManagerFile* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	GFile* new_file = NULL;
	ScratchFolderManagerFile* _tmp6_;
	ScratchFolderManagerFile* _tmp7_;
	GFile* _tmp8_;
	GFile* _tmp9_;
	const gchar* _tmp10_;
	GFile* _tmp11_;
	gint n = 0;
	GFile* _tmp22_;
	gchar* _tmp23_;
	gboolean _tmp24_;
	gboolean _tmp25_;
	g_return_if_fail (self != NULL);
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	_data30_->self = g_object_ref (self);
	_data30_->is_folder = is_folder;
	_tmp0_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = scratch_folder_manager_file_get_is_executable (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		g_warning ("FolderItem.vala:541: Unable to open parent folder");
		block30_data_unref (_data30_);
		_data30_ = NULL;
		return;
	}
	if (_data30_->is_folder) {
		_tmp4_ = _ ("untitled folder");
	} else {
		_tmp4_ = _ ("new file");
	}
	_tmp5_ = g_strdup (_tmp4_);
	_data30_->name = _tmp5_;
	_tmp6_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = scratch_folder_manager_file_get_file (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _data30_->name;
	_tmp11_ = g_file_get_child (_tmp9_, _tmp10_);
	new_file = _tmp11_;
	n = 1;
	while (TRUE) {
		GFile* _tmp12_;
		ScratchFolderManagerFile* _tmp13_;
		ScratchFolderManagerFile* _tmp14_;
		GFile* _tmp15_;
		GFile* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		GFile* _tmp20_;
		gint _tmp21_;
		_tmp12_ = new_file;
		if (!g_file_query_exists (_tmp12_, NULL)) {
			break;
		}
		_tmp13_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp14_ = _tmp13_;
		_tmp15_ = scratch_folder_manager_file_get_file (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = _data30_->name;
		_tmp18_ = g_strdup_printf ("%s %d", _tmp17_, n);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_file_get_child (_tmp16_, _tmp19_);
		_g_object_unref0 (new_file);
		new_file = _tmp20_;
		_g_free0 (_tmp19_);
		_tmp21_ = n;
		n = _tmp21_ + 1;
	}
	_tmp22_ = new_file;
	_tmp23_ = g_file_get_basename (_tmp22_);
	_g_free0 (_data30_->name);
	_data30_->name = _tmp23_;
	_tmp24_ = code_widgets_source_list_expandable_item_get_expanded ((CodeWidgetsSourceListExpandableItem*) self);
	_tmp25_ = _tmp24_;
	if (!_tmp25_) {
		Block31Data* _data31_;
		gulong _tmp26_;
		_data31_ = g_slice_new0 (Block31Data);
		_data31_->_ref_count_ = 1;
		_data31_->_data30_ = block30_data_ref (_data30_);
		_data31_->once = (gulong) 0;
		_tmp26_ = g_signal_connect_data (self, "children-finished-loading", (GCallback) ____lambda115__scratch_folder_manager_folder_item_children_finished_loading, block31_data_ref (_data31_), (GClosureNotify) block31_data_unref, 0);
		_data31_->once = _tmp26_;
		code_widgets_source_list_expandable_item_set_expanded ((CodeWidgetsSourceListExpandableItem*) self, TRUE);
		block31_data_unref (_data31_);
		_data31_ = NULL;
	} else {
		const gchar* _tmp27_;
		_tmp27_ = _data30_->name;
		scratch_folder_manager_folder_item_rename_new (self, _tmp27_, _data30_->is_folder);
	}
	_g_object_unref0 (new_file);
	block30_data_unref (_data30_);
	_data30_ = NULL;
}

static Block32Data*
block32_data_ref (Block32Data* _data32_)
{
	g_atomic_int_inc (&_data32_->_ref_count_);
	return _data32_;
}

static void
block32_data_unref (void * _userdata_)
{
	Block32Data* _data32_;
	_data32_ = (Block32Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data32_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data32_->self;
		_g_object_unref0 (_data32_->rename_item);
		_g_object_unref0 (self);
		g_slice_free (Block32Data, _data32_);
	}
}

static Block33Data*
block33_data_ref (Block33Data* _data33_)
{
	g_atomic_int_inc (&_data33_->_ref_count_);
	return _data33_;
}

static void
block33_data_unref (void * _userdata_)
{
	Block33Data* _data33_;
	_data33_ = (Block33Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data33_->_ref_count_)) {
		ScratchFolderManagerFolderItem* self;
		self = _data33_->_data32_->self;
		block32_data_unref (_data33_->_data32_);
		_data33_->_data32_ = NULL;
		g_slice_free (Block33Data, _data33_);
	}
}

static void
___lambda117_ (Block33Data* _data33_)
{
	Block32Data* _data32_;
	ScratchFolderManagerFolderItem* self;
	gchar* new_name = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GError* _inner_error0_ = NULL;
	_data32_ = _data33_->_data32_;
	self = _data32_->self;
	g_signal_handler_disconnect ((GObject*) _data32_->rename_item, _data33_->once);
	_tmp0_ = code_widgets_source_list_item_get_name ((CodeWidgetsSourceListItem*) _data32_->rename_item);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	new_name = _tmp2_;
	{
		GFile* gfile = NULL;
		ScratchFolderManagerFile* _tmp3_;
		ScratchFolderManagerFile* _tmp4_;
		GFile* _tmp5_;
		GFile* _tmp6_;
		const gchar* _tmp7_;
		GFile* _tmp8_;
		gboolean _tmp9_;
		gboolean _tmp10_;
		_tmp3_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp4_ = _tmp3_;
		_tmp5_ = scratch_folder_manager_file_get_file (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = new_name;
		_tmp8_ = g_file_get_child_for_display_name (_tmp6_, _tmp7_, &_inner_error0_);
		gfile = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = scratch_folder_manager_item_rename_item_get_is_folder (_data32_->rename_item);
		_tmp10_ = _tmp9_;
		if (_tmp10_) {
			GFile* _tmp11_;
			_tmp11_ = gfile;
			g_file_make_directory (_tmp11_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (gfile);
				goto __catch0_g_error;
			}
		} else {
			GFile* _tmp12_;
			GFileOutputStream* _tmp13_;
			GFileOutputStream* _tmp14_;
			ScratchFolderManagerFileView* _tmp15_;
			ScratchFolderManagerFileView* _tmp16_;
			GFile* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			_tmp12_ = gfile;
			_tmp13_ = g_file_create (_tmp12_, G_FILE_CREATE_NONE, NULL, &_inner_error0_);
			_tmp14_ = _tmp13_;
			_g_object_unref0 (_tmp14_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (gfile);
				goto __catch0_g_error;
			}
			_tmp15_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
			_tmp16_ = _tmp15_;
			_tmp17_ = gfile;
			_tmp18_ = g_file_get_path (_tmp17_);
			_tmp19_ = _tmp18_;
			g_signal_emit_by_name (_tmp16_, "activate", _tmp19_);
			_g_free0 (_tmp19_);
		}
		_g_object_unref0 (gfile);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp20_;
		const gchar* _tmp21_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp20_ = e;
		_tmp21_ = _tmp20_->message;
		g_warning ("FolderItem.vala:593: %s", _tmp21_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (new_name);
		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;
	}
	_g_free0 (new_name);
}

static void
____lambda117__code_widgets_source_list_item_edited (CodeWidgetsSourceListItem* _sender,
                                                     const gchar* new_name,
                                                     gpointer self)
{
	___lambda117_ (self);
}

static gboolean
___lambda118_ (Block33Data* _data33_)
{
	Block32Data* _data32_;
	ScratchFolderManagerFolderItem* self;
	ScratchFolderManagerFileView* _tmp0_;
	ScratchFolderManagerFileView* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean result;
	_data32_ = _data33_->_data32_;
	self = _data32_->self;
	_tmp0_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = code_widgets_source_list_get_editing ((CodeWidgetsSourceList*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		result = G_SOURCE_CONTINUE;
		return result;
	} else {
		scratch_folder_manager_folder_item_remove (self, (CodeWidgetsSourceListItem*) _data32_->rename_item);
		result = G_SOURCE_REMOVE;
		return result;
	}
}

static gboolean
____lambda118__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda118_ (self);
	return result;
}

static gboolean
__lambda116_ (Block32Data* _data32_)
{
	ScratchFolderManagerFolderItem* self;
	ScratchFolderManagerFileView* _tmp0_;
	ScratchFolderManagerFileView* _tmp1_;
	gboolean result;
	self = _data32_->self;
	_tmp0_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	if (code_widgets_source_list_start_editing_item ((CodeWidgetsSourceList*) _tmp1_, (CodeWidgetsSourceListItem*) _data32_->rename_item)) {
		Block33Data* _data33_;
		gulong _tmp2_;
		_data33_ = g_slice_new0 (Block33Data);
		_data33_->_ref_count_ = 1;
		_data33_->_data32_ = block32_data_ref (_data32_);
		_data33_->once = (gulong) 0;
		_tmp2_ = g_signal_connect_data ((CodeWidgetsSourceListItem*) _data32_->rename_item, "edited", (GCallback) ____lambda117__code_widgets_source_list_item_edited, block33_data_ref (_data33_), (GClosureNotify) block33_data_unref, 0);
		_data33_->once = _tmp2_;
		g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, ____lambda118__gsource_func, block33_data_ref (_data33_), block33_data_unref);
		block33_data_unref (_data33_);
		_data33_ = NULL;
	} else {
		g_critical ("FolderItem.vala:607: Failed to rename new item");
		scratch_folder_manager_folder_item_remove (self, (CodeWidgetsSourceListItem*) _data32_->rename_item);
	}
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda116__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda116_ (self);
	return result;
}

static void
scratch_folder_manager_folder_item_rename_new (ScratchFolderManagerFolderItem* self,
                                               const gchar* name,
                                               gboolean is_folder)
{
	ScratchFolderManagerFileView* _tmp0_;
	ScratchFolderManagerFileView* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	Block32Data* _data32_;
	ScratchFolderManagerItemRenameItem* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = scratch_folder_manager_item_get_view ((ScratchFolderManagerItem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = code_widgets_source_list_get_editing ((CodeWidgetsSourceList*) _tmp1_);
	_tmp3_ = _tmp2_;
	_vala_return_if_fail (!_tmp3_, "!view.editing");
	_data32_ = g_slice_new0 (Block32Data);
	_data32_->_ref_count_ = 1;
	_data32_->self = g_object_ref (self);
	_tmp4_ = scratch_folder_manager_item_rename_item_new (name, is_folder);
	_data32_->rename_item = _tmp4_;
	scratch_folder_manager_folder_item_add (self, (CodeWidgetsSourceListItem*) _data32_->rename_item);
	g_timeout_add_full (G_PRIORITY_DEFAULT, SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_RENAME_AFTER_NEW_DELAY_MSEC, ___lambda116__gsource_func, block32_data_ref (_data32_), block32_data_unref);
	block32_data_unref (_data32_);
	_data32_ = NULL;
}

gboolean
scratch_folder_manager_folder_item_get_loading_required (ScratchFolderManagerFolderItem* self)
{
	gboolean result;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!self->priv->children_loaded) {
		guint _tmp2_;
		guint _tmp3_;
		_tmp2_ = code_widgets_source_list_expandable_item_get_n_children ((CodeWidgetsSourceListExpandableItem*) self);
		_tmp3_ = _tmp2_;
		_tmp1_ = _tmp3_ <= ((guint) 1);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ScratchFolderManagerFile* _tmp4_;
		ScratchFolderManagerFile* _tmp5_;
		GeeCollection* _tmp6_;
		GeeCollection* _tmp7_;
		GeeCollection* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp4_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = scratch_folder_manager_file_get_children (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = _tmp7_;
		_tmp9_ = gee_collection_get_size (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp0_ = _tmp10_ > 0;
		_g_object_unref0 (_tmp8_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
_scratch_folder_manager_folder_item_on_toggled_code_widgets_source_list_expandable_item_toggled (CodeWidgetsSourceListExpandableItem* _sender,
                                                                                                 gpointer self)
{
	scratch_folder_manager_folder_item_on_toggled ((ScratchFolderManagerFolderItem*) self);
}

static void
_scratch_folder_manager_folder_item_on_changed_g_file_monitor_changed (GFileMonitor* _sender,
                                                                       GFile* file,
                                                                       GFile* other_file,
                                                                       GFileMonitorEvent event_type,
                                                                       gpointer self)
{
	scratch_folder_manager_folder_item_on_changed ((ScratchFolderManagerFolderItem*) self, file, other_file, event_type);
}

static GObject *
scratch_folder_manager_folder_item_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ScratchFolderManagerFolderItem * self;
	CodeWidgetsSourceListItem* _tmp0_;
	CodeWidgetsSourceListItem* _tmp1_;
	CodeWidgetsSourceListItem* _tmp2_;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (scratch_folder_manager_folder_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem);
	code_widgets_source_list_item_set_selectable ((CodeWidgetsSourceListItem*) self, FALSE);
	_tmp0_ = code_widgets_source_list_item_new ("");
	_g_object_unref0 (self->priv->dummy);
	self->priv->dummy = _tmp0_;
	_tmp1_ = self->priv->dummy;
	code_widgets_source_list_item_set_selectable (_tmp1_, FALSE);
	_tmp2_ = self->priv->dummy;
	code_widgets_source_list_expandable_item_add (G_TYPE_CHECK_INSTANCE_CAST (self, CODE_WIDGETS_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, CodeWidgetsSourceListExpandableItem), _tmp2_);
	self->priv->has_dummy = TRUE;
	g_signal_connect_object ((CodeWidgetsSourceListExpandableItem*) self, "toggled", (GCallback) _scratch_folder_manager_folder_item_on_toggled_code_widgets_source_list_expandable_item_toggled, self, 0);
	{
		GFileMonitor* _tmp3_ = NULL;
		ScratchFolderManagerFile* _tmp4_;
		ScratchFolderManagerFile* _tmp5_;
		GFile* _tmp6_;
		GFile* _tmp7_;
		GFileMonitor* _tmp8_;
		GFileMonitor* _tmp9_;
		GFileMonitor* _tmp10_;
		_tmp4_ = scratch_folder_manager_item_get_file ((ScratchFolderManagerItem*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = scratch_folder_manager_file_get_file (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_file_monitor_directory (_tmp7_, G_FILE_MONITOR_NONE, NULL, &_inner_error0_);
		_tmp3_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = _tmp3_;
		_tmp3_ = NULL;
		_g_object_unref0 (self->priv->monitor);
		self->priv->monitor = _tmp9_;
		_tmp10_ = self->priv->monitor;
		g_signal_connect_object (_tmp10_, "changed", (GCallback) _scratch_folder_manager_folder_item_on_changed_g_file_monitor_changed, self, 0);
		_g_object_unref0 (_tmp3_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp11_;
		const gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp11_ = e;
		_tmp12_ = _tmp11_->message;
		g_warning ("FolderItem.vala:50: %s", _tmp12_);
		_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 obj;
}

static void
scratch_folder_manager_folder_item_class_init (ScratchFolderManagerFolderItemClass * klass,
                                               gpointer klass_data)
{
	scratch_folder_manager_folder_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ScratchFolderManagerFolderItem_private_offset);
	((CodeWidgetsSourceListItemClass *) klass)->get_context_menu = (GMenu* (*) (CodeWidgetsSourceListItem*)) scratch_folder_manager_folder_item_real_get_context_menu;
	((ScratchFolderManagerFolderItemClass *) klass)->on_changed = (void (*) (ScratchFolderManagerFolderItem*, GFile*, GFile*, GFileMonitorEvent)) scratch_folder_manager_folder_item_real_on_changed;
	G_OBJECT_CLASS (klass)->get_property = _vala_scratch_folder_manager_folder_item_get_property;
	G_OBJECT_CLASS (klass)->constructor = scratch_folder_manager_folder_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = scratch_folder_manager_folder_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_LOADING_REQUIRED_PROPERTY, scratch_folder_manager_folder_item_properties[SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_LOADING_REQUIRED_PROPERTY] = g_param_spec_boolean ("loading-required", "loading-required", "loading-required", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	scratch_folder_manager_folder_item_signals[SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_CHILDREN_FINISHED_LOADING_SIGNAL] = g_signal_new ("children-finished-loading", SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
scratch_folder_manager_folder_item_instance_init (ScratchFolderManagerFolderItem * self,
                                                  gpointer klass)
{
	self->priv = scratch_folder_manager_folder_item_get_instance_private (self);
	self->priv->children_loaded = FALSE;
}

static void
scratch_folder_manager_folder_item_finalize (GObject * obj)
{
	ScratchFolderManagerFolderItem * self;
	GFileMonitor* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem);
	_tmp0_ = self->priv->monitor;
	g_file_monitor_cancel (_tmp0_);
	_g_object_unref0 (self->priv->monitor);
	_g_object_unref0 (self->priv->dummy);
	G_OBJECT_CLASS (scratch_folder_manager_folder_item_parent_class)->finalize (obj);
}

/**
     * Expandable item in the source list, represents a folder.
     * Monitored for changes inside the directory.
     */
 G_GNUC_NO_INLINE static GType
scratch_folder_manager_folder_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ScratchFolderManagerFolderItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) scratch_folder_manager_folder_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScratchFolderManagerFolderItem), 0, (GInstanceInitFunc) scratch_folder_manager_folder_item_instance_init, NULL };
	GType scratch_folder_manager_folder_item_type_id;
	scratch_folder_manager_folder_item_type_id = g_type_register_static (SCRATCH_FOLDER_MANAGER_TYPE_ITEM, "ScratchFolderManagerFolderItem", &g_define_type_info, G_TYPE_FLAG_NONE);
	ScratchFolderManagerFolderItem_private_offset = g_type_add_instance_private (scratch_folder_manager_folder_item_type_id, sizeof (ScratchFolderManagerFolderItemPrivate));
	return scratch_folder_manager_folder_item_type_id;
}

GType
scratch_folder_manager_folder_item_get_type (void)
{
	static gsize scratch_folder_manager_folder_item_type_id__once = 0;
	if (g_once_init_enter (&scratch_folder_manager_folder_item_type_id__once)) {
		GType scratch_folder_manager_folder_item_type_id;
		scratch_folder_manager_folder_item_type_id = scratch_folder_manager_folder_item_get_type_once ();
		g_once_init_leave (&scratch_folder_manager_folder_item_type_id__once, scratch_folder_manager_folder_item_type_id);
	}
	return scratch_folder_manager_folder_item_type_id__once;
}

static void
_vala_scratch_folder_manager_folder_item_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	ScratchFolderManagerFolderItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_FOLDER_MANAGER_TYPE_FOLDER_ITEM, ScratchFolderManagerFolderItem);
	switch (property_id) {
		case SCRATCH_FOLDER_MANAGER_FOLDER_ITEM_LOADING_REQUIRED_PROPERTY:
		g_value_set_boolean (value, scratch_folder_manager_folder_item_get_loading_required (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

