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

#include "pantheon-files-contractor.h"
#include <gtk/gtk.h>
#include "pantheon-files-core.h"
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gee.h>
#include <granite.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _files_plugins_base_unref0(var) ((var == NULL) ? NULL : (var = (files_plugins_base_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block2Data Block2Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#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 _FilesPluginsContractorPrivate {
	GtkMenu* menu;
	FilesFile* current_directory;
};

struct _Block1Data {
	int _ref_count_;
	FilesPluginsContractor* self;
	GFile** files;
	gint files_length1;
	gint _files_size_;
};

struct _Block2Data {
	int _ref_count_;
	Block1Data * _data1_;
	GraniteServicesContract* contract;
};

static gint FilesPluginsContractor_private_offset;
static gpointer files_plugins_contractor_parent_class = NULL;

static void files_plugins_contractor_real_context_menu (FilesPluginsBase* base,
                                                 GtkWidget* widget,
                                                 GList* gof_files);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void _vala_array_add1 (GFile** * array,
                       gint* length,
                       gint* size,
                       GFile* value);
static GFile** files_plugins_contractor_get_file_array (GList* files,
                                                 gint* result_length1);
static gchar** files_plugins_contractor_get_mimetypes (GList* files,
                                                gint* result_length1);
static void files_plugins_contractor_add_menuitem (FilesPluginsContractor* self,
                                            GtkMenu* menu,
                                            GtkMenuItem* menu_item);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void ______lambda4_ (Block2Data* _data2_);
static void _______lambda4__g_simple_action_activate (GSimpleAction* _sender,
                                               GVariant* parameter,
                                               gpointer self);
static void files_plugins_contractor_real_directory_loaded (FilesPluginsBase* base,
                                                     GtkApplicationWindow* window,
                                                     FilesAbstractSlot* view,
                                                     FilesFile* directory);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add3 (GFile** * array,
                       gint* length,
                       gint* size,
                       GFile* value);
static void _vala_array_add4 (GFile** * array,
                       gint* length,
                       gint* size,
                       GFile* value);
static void files_plugins_contractor_finalize (FilesPluginsBase * obj);
static GType files_plugins_contractor_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
files_plugins_contractor_get_instance_private (FilesPluginsContractor* self)
{
	return G_STRUCT_MEMBER_P (self, FilesPluginsContractor_private_offset);
}

FilesPluginsContractor*
files_plugins_contractor_construct (GType object_type)
{
	FilesPluginsContractor* self = NULL;
	self = (FilesPluginsContractor*) files_plugins_base_construct (object_type);
	return self;
}

FilesPluginsContractor*
files_plugins_contractor_new (void)
{
	return files_plugins_contractor_construct (FILES_PLUGINS_TYPE_CONTRACTOR);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		FilesPluginsContractor* self;
		self = _data1_->self;
		_data1_->files = (_vala_array_free (_data1_->files, _data1_->files_length1, (GDestroyNotify) g_object_unref), NULL);
		_files_plugins_base_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

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

static void
_vala_array_add1 (GFile** * array,
                  gint* length,
                  gint* size,
                  GFile* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

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

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		FilesPluginsContractor* self;
		self = _data2_->_data1_->self;
		_g_object_unref0 (_data2_->contract);
		block1_data_unref (_data2_->_data1_);
		_data2_->_data1_ = NULL;
		g_slice_free (Block2Data, _data2_);
	}
}

static void
______lambda4_ (Block2Data* _data2_)
{
	Block1Data* _data1_;
	FilesPluginsContractor* self;
	GError* _inner_error0_ = NULL;
	_data1_ = _data2_->_data1_;
	self = _data1_->self;
	{
		GraniteServicesContract* _tmp0_;
		GFile** _tmp1_;
		gint _tmp1__length1;
		_tmp0_ = _data2_->contract;
		_tmp1_ = _data1_->files;
		_tmp1__length1 = _data1_->files_length1;
		granite_services_contract_execute_with_files (_tmp0_, _tmp1_, (gint) _tmp1__length1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = err;
		_tmp3_ = _tmp2_->message;
		g_warning ("plugin.vala:82: %s", _tmp3_);
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
_______lambda4__g_simple_action_activate (GSimpleAction* _sender,
                                          GVariant* parameter,
                                          gpointer self)
{
	______lambda4_ (self);
}

static void
files_plugins_contractor_real_context_menu (FilesPluginsBase* base,
                                            GtkWidget* widget,
                                            GList* gof_files)
{
	FilesPluginsContractor * self;
	Block1Data* _data1_;
	GtkMenu* _tmp0_;
	GeeList* contracts = NULL;
	GError* _inner_error0_ = NULL;
	self = (FilesPluginsContractor*) base;
	g_return_if_fail (widget != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = files_plugins_base_ref (self);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_menu_get_type ()) ? ((GtkMenu*) widget) : NULL);
	_g_object_unref0 (self->priv->menu);
	self->priv->menu = _tmp0_;
	_data1_->files = NULL;
	_data1_->files_length1 = 0;
	_data1_->_files_size_ = _data1_->files_length1;
	contracts = NULL;
	{
		GFile** _tmp25_;
		gint _tmp25__length1;
		GeeList* _tmp26_;
		GtkSeparatorMenuItem* separator_item = NULL;
		GtkSeparatorMenuItem* _tmp27_;
		GtkMenu* _tmp28_;
		GtkSeparatorMenuItem* _tmp29_;
		GSimpleActionGroup* action_group = NULL;
		GSimpleActionGroup* _tmp30_;
		GtkMenu* _tmp31_;
		GSimpleActionGroup* _tmp32_;
		if (gof_files == NULL) {
			FilesFile* _tmp1_;
			GFile** _tmp2_;
			FilesFile* _tmp3_;
			GFile* _tmp4_;
			GFile* _tmp5_;
			GFile* _tmp6_;
			gchar* mimetype = NULL;
			FilesFile* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			gchar* _tmp10_;
			const gchar* _tmp11_;
			GeeList* _tmp12_ = NULL;
			const gchar* _tmp13_;
			GeeList* _tmp14_;
			GeeList* _tmp15_;
			_tmp1_ = self->priv->current_directory;
			if (_tmp1_ == NULL) {
				_g_object_unref0 (contracts);
				block1_data_unref (_data1_);
				_data1_ = NULL;
				return;
			}
			_tmp2_ = g_new0 (GFile*, 0 + 1);
			_data1_->files = (_vala_array_free (_data1_->files, _data1_->files_length1, (GDestroyNotify) g_object_unref), NULL);
			_data1_->files = _tmp2_;
			_data1_->files_length1 = 0;
			_data1_->_files_size_ = _data1_->files_length1;
			_tmp3_ = self->priv->current_directory;
			_tmp4_ = files_file_get_location (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = _g_object_ref0 (_tmp5_);
			_vala_array_add1 (&_data1_->files, &_data1_->files_length1, &_data1_->_files_size_, _tmp6_);
			_tmp7_ = self->priv->current_directory;
			_tmp8_ = files_file_get_content_type (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_strdup (_tmp9_);
			mimetype = _tmp10_;
			_tmp11_ = mimetype;
			if (_tmp11_ == NULL) {
				_g_free0 (mimetype);
				_g_object_unref0 (contracts);
				block1_data_unref (_data1_);
				_data1_ = NULL;
				return;
			}
			_tmp13_ = mimetype;
			_tmp14_ = granite_services_contractor_proxy_get_contracts_by_mime (_tmp13_, &_inner_error0_);
			_tmp12_ = _tmp14_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (mimetype);
				goto __catch0_g_error;
			}
			_tmp15_ = _tmp12_;
			_tmp12_ = NULL;
			_g_object_unref0 (contracts);
			contracts = _tmp15_;
			_g_object_unref0 (_tmp12_);
			_g_free0 (mimetype);
		} else {
			gint _tmp16_ = 0;
			GFile** _tmp17_;
			gchar** mimetypes = NULL;
			gint _tmp18_ = 0;
			gchar** _tmp19_;
			gint mimetypes_length1;
			gint _mimetypes_size_;
			gchar** _tmp20_;
			gint _tmp20__length1;
			_tmp17_ = files_plugins_contractor_get_file_array (gof_files, &_tmp16_);
			_data1_->files = (_vala_array_free (_data1_->files, _data1_->files_length1, (GDestroyNotify) g_object_unref), NULL);
			_data1_->files = _tmp17_;
			_data1_->files_length1 = _tmp16_;
			_data1_->_files_size_ = _data1_->files_length1;
			_tmp19_ = files_plugins_contractor_get_mimetypes (gof_files, &_tmp18_);
			mimetypes = _tmp19_;
			mimetypes_length1 = _tmp18_;
			_mimetypes_size_ = mimetypes_length1;
			_tmp20_ = mimetypes;
			_tmp20__length1 = mimetypes_length1;
			if (_tmp20__length1 > 0) {
				GeeList* _tmp21_ = NULL;
				gchar** _tmp22_;
				gint _tmp22__length1;
				GeeList* _tmp23_;
				GeeList* _tmp24_;
				_tmp22_ = mimetypes;
				_tmp22__length1 = mimetypes_length1;
				_tmp23_ = granite_services_contractor_proxy_get_contracts_by_mimelist (_tmp22_, (gint) _tmp22__length1, &_inner_error0_);
				_tmp21_ = _tmp23_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					mimetypes = (_vala_array_free (mimetypes, mimetypes_length1, (GDestroyNotify) g_free), NULL);
					goto __catch0_g_error;
				}
				_tmp24_ = _tmp21_;
				_tmp21_ = NULL;
				_g_object_unref0 (contracts);
				contracts = _tmp24_;
				_g_object_unref0 (_tmp21_);
			}
			mimetypes = (_vala_array_free (mimetypes, mimetypes_length1, (GDestroyNotify) g_free), NULL);
		}
		_tmp25_ = _data1_->files;
		_tmp25__length1 = _data1_->files_length1;
		_vala_assert (_tmp25_ != NULL, "files != null");
		_tmp26_ = contracts;
		if (_tmp26_ == NULL) {
			_g_object_unref0 (contracts);
			block1_data_unref (_data1_);
			_data1_ = NULL;
			return;
		}
		_tmp27_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
		g_object_ref_sink (_tmp27_);
		separator_item = _tmp27_;
		_tmp28_ = self->priv->menu;
		_tmp29_ = separator_item;
		files_plugins_contractor_add_menuitem (self, _tmp28_, (GtkMenuItem*) _tmp29_);
		_tmp30_ = g_simple_action_group_new ();
		action_group = _tmp30_;
		_tmp31_ = self->priv->menu;
		_tmp32_ = action_group;
		gtk_widget_insert_action_group ((GtkWidget*) _tmp31_, "contractor", (GActionGroup*) _tmp32_);
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp33_ = FALSE;
				_tmp33_ = TRUE;
				while (TRUE) {
					Block2Data* _data2_;
					GeeList* _tmp35_;
					gint _tmp36_;
					gint _tmp37_;
					GeeList* _tmp38_;
					gpointer _tmp39_;
					GSimpleAction* action = NULL;
					gchar* _tmp40_;
					gchar* _tmp41_;
					GSimpleAction* _tmp42_;
					GSimpleAction* _tmp43_;
					GSimpleAction* _tmp44_;
					GSimpleActionGroup* _tmp45_;
					GSimpleAction* _tmp46_;
					GtkMenuItem* menu_item = NULL;
					GraniteServicesContract* _tmp47_;
					gchar* _tmp48_;
					gchar* _tmp49_;
					gchar* _tmp50_;
					GtkMenuItem* _tmp51_ = NULL;
					GtkMenuItem* _tmp52_;
					GtkMenu* _tmp53_;
					GtkMenuItem* _tmp54_;
					_data2_ = g_slice_new0 (Block2Data);
					_data2_->_ref_count_ = 1;
					_data2_->_data1_ = block1_data_ref (_data1_);
					if (!_tmp33_) {
						gint _tmp34_;
						_tmp34_ = i;
						i = _tmp34_ + 1;
					}
					_tmp33_ = FALSE;
					_tmp35_ = contracts;
					_tmp36_ = gee_collection_get_size ((GeeCollection*) _tmp35_);
					_tmp37_ = _tmp36_;
					if (!(i < _tmp37_)) {
						block2_data_unref (_data2_);
						_data2_ = NULL;
						break;
					}
					_tmp38_ = contracts;
					_tmp39_ = gee_list_get (_tmp38_, i);
					_data2_->contract = (GraniteServicesContract*) _tmp39_;
					_tmp40_ = g_strdup_printf ("contract-%i", i);
					_tmp41_ = _tmp40_;
					_tmp42_ = g_simple_action_new (_tmp41_, NULL);
					_tmp43_ = _tmp42_;
					_g_free0 (_tmp41_);
					action = _tmp43_;
					_tmp44_ = action;
					g_signal_connect_data (_tmp44_, "activate", (GCallback) _______lambda4__g_simple_action_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
					_tmp45_ = action_group;
					_tmp46_ = action;
					g_action_map_add_action ((GActionMap*) _tmp45_, (GAction*) _tmp46_);
					_tmp47_ = _data2_->contract;
					_tmp48_ = granite_services_contract_get_display_name (_tmp47_);
					_tmp49_ = _tmp48_;
					_tmp50_ = g_strdup_printf ("contractor.contract-%i", i);
					_tmp51_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_tmp49_);
					gtk_actionable_set_action_name ((GtkActionable*) _tmp51_, _tmp50_);
					_g_free0 (_tmp50_);
					g_object_ref_sink (_tmp51_);
					_tmp52_ = _tmp51_;
					_g_free0 (_tmp49_);
					menu_item = _tmp52_;
					_tmp53_ = self->priv->menu;
					_tmp54_ = menu_item;
					files_plugins_contractor_add_menuitem (self, _tmp53_, _tmp54_);
					_g_object_unref0 (menu_item);
					_g_object_unref0 (action);
					block2_data_unref (_data2_);
					_data2_ = NULL;
				}
			}
		}
		_g_object_unref0 (action_group);
		_g_object_unref0 (separator_item);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp55_;
		const gchar* _tmp56_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp55_ = e;
		_tmp56_ = _tmp55_->message;
		g_warning ("plugin.vala:95: %s", _tmp56_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (contracts);
		block1_data_unref (_data1_);
		_data1_ = 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;
	}
	_g_object_unref0 (contracts);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
files_plugins_contractor_real_directory_loaded (FilesPluginsBase* base,
                                                GtkApplicationWindow* window,
                                                FilesAbstractSlot* view,
                                                FilesFile* directory)
{
	FilesPluginsContractor * self;
	FilesFile* _tmp0_;
	self = (FilesPluginsContractor*) base;
	g_return_if_fail (window != NULL);
	g_return_if_fail (view != NULL);
	g_return_if_fail (directory != NULL);
	_tmp0_ = _g_object_ref0 (directory);
	_g_object_unref0 (self->priv->current_directory);
	self->priv->current_directory = _tmp0_;
}

static void
files_plugins_contractor_add_menuitem (FilesPluginsContractor* self,
                                       GtkMenu* menu,
                                       GtkMenuItem* menu_item)
{
	FilesPluginManager* _tmp0_;
	GeeList* _tmp1_;
	GeeList* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (menu != NULL);
	g_return_if_fail (menu_item != NULL);
	gtk_menu_shell_append ((GtkMenuShell*) menu, menu_item);
	gtk_widget_show ((GtkWidget*) menu_item);
	_tmp0_ = plugins;
	_tmp1_ = files_plugin_manager_get_menuitem_references (_tmp0_);
	_tmp2_ = _tmp1_;
	gee_collection_add ((GeeCollection*) _tmp2_, (GtkWidget*) menu_item);
}

static void
_vala_array_add2 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar**
files_plugins_contractor_get_mimetypes (GList* files,
                                        gint* result_length1)
{
	gchar** mimetypes = NULL;
	gchar** _tmp0_;
	gint mimetypes_length1;
	gint _mimetypes_size_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar** result;
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	mimetypes = _tmp0_;
	mimetypes_length1 = 0;
	_mimetypes_size_ = mimetypes_length1;
	{
		GList* file_collection = NULL;
		GList* file_it = NULL;
		file_collection = files;
		for (file_it = file_collection; file_it != NULL; file_it = file_it->next) {
			FilesFile* file = NULL;
			file = (FilesFile*) file_it->data;
			{
				gchar* ftype = NULL;
				FilesFile* _tmp1_;
				const gchar* _tmp2_;
				const gchar* _tmp3_;
				gchar* _tmp4_;
				const gchar* _tmp5_;
				_tmp1_ = file;
				_tmp2_ = files_file_get_content_type (_tmp1_);
				_tmp3_ = _tmp2_;
				_tmp4_ = g_strdup (_tmp3_);
				ftype = _tmp4_;
				_tmp5_ = ftype;
				if (_tmp5_ != NULL) {
					const gchar* _tmp6_;
					gchar* _tmp7_;
					_tmp6_ = ftype;
					_tmp7_ = g_strdup (_tmp6_);
					_vala_array_add2 (&mimetypes, &mimetypes_length1, &_mimetypes_size_, _tmp7_);
				}
				_g_free0 (ftype);
			}
		}
	}
	_tmp8_ = mimetypes;
	_tmp8__length1 = mimetypes_length1;
	if (result_length1) {
		*result_length1 = _tmp8__length1;
	}
	result = _tmp8_;
	return result;
}

static void
_vala_array_add3 (GFile** * array,
                  gint* length,
                  gint* size,
                  GFile* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add4 (GFile** * array,
                  gint* length,
                  gint* size,
                  GFile* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static GFile**
files_plugins_contractor_get_file_array (GList* files,
                                         gint* result_length1)
{
	GFile** file_array = NULL;
	GFile** _tmp0_;
	gint file_array_length1;
	gint _file_array_size_;
	GFile** _tmp18_;
	gint _tmp18__length1;
	GFile** result;
	_tmp0_ = g_new0 (GFile*, 0 + 1);
	file_array = _tmp0_;
	file_array_length1 = 0;
	_file_array_size_ = file_array_length1;
	{
		GList* file_collection = NULL;
		GList* file_it = NULL;
		file_collection = files;
		for (file_it = file_collection; file_it != NULL; file_it = file_it->next) {
			FilesFile* file = NULL;
			file = (FilesFile*) file_it->data;
			{
				FilesFile* _tmp1_;
				GFile* _tmp2_;
				GFile* _tmp3_;
				_tmp1_ = file;
				_tmp2_ = files_file_get_location (_tmp1_);
				_tmp3_ = _tmp2_;
				if (_tmp3_ != NULL) {
					FilesFile* _tmp4_;
					GFile* _tmp5_;
					GFile* _tmp6_;
					gchar* _tmp7_;
					gchar* _tmp8_;
					gboolean _tmp9_;
					_tmp4_ = file;
					_tmp5_ = files_file_get_location (_tmp4_);
					_tmp6_ = _tmp5_;
					_tmp7_ = g_file_get_uri_scheme (_tmp6_);
					_tmp8_ = _tmp7_;
					_tmp9_ = g_strcmp0 (_tmp8_, "recent") == 0;
					_g_free0 (_tmp8_);
					if (_tmp9_) {
						FilesFile* _tmp10_;
						gchar* _tmp11_;
						gchar* _tmp12_;
						GFile* _tmp13_;
						_tmp10_ = file;
						_tmp11_ = files_file_get_display_target_uri (_tmp10_);
						_tmp12_ = _tmp11_;
						_tmp13_ = g_file_new_for_uri (_tmp12_);
						_vala_array_add3 (&file_array, &file_array_length1, &_file_array_size_, _tmp13_);
						_g_free0 (_tmp12_);
					} else {
						FilesFile* _tmp14_;
						GFile* _tmp15_;
						GFile* _tmp16_;
						GFile* _tmp17_;
						_tmp14_ = file;
						_tmp15_ = files_file_get_location (_tmp14_);
						_tmp16_ = _tmp15_;
						_tmp17_ = _g_object_ref0 (_tmp16_);
						_vala_array_add4 (&file_array, &file_array_length1, &_file_array_size_, _tmp17_);
					}
				}
			}
		}
	}
	_tmp18_ = file_array;
	_tmp18__length1 = file_array_length1;
	if (result_length1) {
		*result_length1 = _tmp18__length1;
	}
	result = _tmp18_;
	return result;
}

static void
files_plugins_contractor_class_init (FilesPluginsContractorClass * klass,
                                     gpointer klass_data)
{
	files_plugins_contractor_parent_class = g_type_class_peek_parent (klass);
	((FilesPluginsBaseClass *) klass)->finalize = files_plugins_contractor_finalize;
	g_type_class_adjust_private_offset (klass, &FilesPluginsContractor_private_offset);
	((FilesPluginsBaseClass *) klass)->context_menu = (void (*) (FilesPluginsBase*, GtkWidget*, GList*)) files_plugins_contractor_real_context_menu;
	((FilesPluginsBaseClass *) klass)->directory_loaded = (void (*) (FilesPluginsBase*, GtkApplicationWindow*, FilesAbstractSlot*, FilesFile*)) files_plugins_contractor_real_directory_loaded;
}

static void
files_plugins_contractor_instance_init (FilesPluginsContractor * self,
                                        gpointer klass)
{
	self->priv = files_plugins_contractor_get_instance_private (self);
	self->priv->current_directory = NULL;
}

static void
files_plugins_contractor_finalize (FilesPluginsBase * obj)
{
	FilesPluginsContractor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_PLUGINS_TYPE_CONTRACTOR, FilesPluginsContractor);
	_g_object_unref0 (self->priv->menu);
	_g_object_unref0 (self->priv->current_directory);
	FILES_PLUGINS_BASE_CLASS (files_plugins_contractor_parent_class)->finalize (obj);
}

/***
    Authors:
      Lucas Baudin <xapantu@gmail.com>
      ammonkey <am.monkeyd@gmail.com>
      Victor Martinez <victoreduardm@gmail.com>

    Copyright (c) Lucas Baudin 2011 <xapantu@gmail.com>
    Copyright (c) 2013-2018 elementary LLC <https://elementary.io>

    Marlin is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Marlin is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program.  If not, see <http://www.gnu.org/licenses/>.
***/
 G_GNUC_NO_INLINE static GType
files_plugins_contractor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesPluginsContractorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_plugins_contractor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesPluginsContractor), 0, (GInstanceInitFunc) files_plugins_contractor_instance_init, NULL };
	GType files_plugins_contractor_type_id;
	files_plugins_contractor_type_id = g_type_register_static (FILES_PLUGINS_TYPE_BASE, "FilesPluginsContractor", &g_define_type_info, 0);
	FilesPluginsContractor_private_offset = g_type_add_instance_private (files_plugins_contractor_type_id, sizeof (FilesPluginsContractorPrivate));
	return files_plugins_contractor_type_id;
}

GType
files_plugins_contractor_get_type (void)
{
	static volatile gsize files_plugins_contractor_type_id__once = 0;
	if (g_once_init_enter (&files_plugins_contractor_type_id__once)) {
		GType files_plugins_contractor_type_id;
		files_plugins_contractor_type_id = files_plugins_contractor_get_type_once ();
		g_once_init_leave (&files_plugins_contractor_type_id__once, files_plugins_contractor_type_id);
	}
	return files_plugins_contractor_type_id__once;
}

FilesPluginsBase*
module_init (void)
{
	FilesPluginsContractor* _tmp0_;
	FilesPluginsBase* result;
	_tmp0_ = files_plugins_contractor_new ();
	result = (FilesPluginsBase*) _tmp0_;
	return result;
}

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

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

