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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <gio/gio.h>

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

#define _g_key_file_unref0(var) ((var == NULL) ? NULL : (var = (g_key_file_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))

VALA_EXTERN void dc_icon_fallback_install (GtkIconTheme* theme);
VALA_EXTERN void dc_icon_fallback_apply (GtkIconTheme* theme);
VALA_EXTERN GKeyFile* dc_icon_fallback_load_hicolor_index (gchar** search_path,
                                               gint search_path_length1);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static void _vala_array_add1 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
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 gssize _vala_array_length (gpointer array);

const gchar* DC_ICON_FALLBACK_FALLBACK_THEMES[1] = {"Adwaita"};

void
dc_icon_fallback_install (GtkIconTheme* theme)
{
	g_return_if_fail (theme != NULL);
	dc_icon_fallback_apply (theme);
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_vala_array_add1 (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 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*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

void
dc_icon_fallback_apply (GtkIconTheme* theme)
{
	gchar** search_path = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint search_path_length1;
	gint _search_path_size_;
	GKeyFile* kf = NULL;
	gchar** _tmp2_;
	gint _tmp2__length1;
	GKeyFile* _tmp3_;
	GKeyFile* _tmp4_;
	gchar** inherits = NULL;
	gchar** _tmp5_;
	gint inherits_length1;
	gint _inherits_size_;
	GKeyFile* _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar* dir = NULL;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* hicolor_dir = NULL;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* index = NULL;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* data = NULL;
	GKeyFile* _tmp23_;
	gchar* _tmp24_;
	gchar** path = NULL;
	const gchar* _tmp41_;
	gchar* _tmp42_;
	gchar** _tmp43_;
	gint path_length1;
	gint _path_size_;
	gchar** _tmp44_;
	gint _tmp44__length1;
	gchar** _tmp47_;
	gint _tmp47__length1;
	gchar* _tmp48_;
	gchar* _tmp49_;
	const gchar* _tmp50_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (theme != NULL);
	_tmp1_ = _tmp0_ = gtk_icon_theme_get_search_path (theme);
	search_path = _tmp1_;
	search_path_length1 = _vala_array_length (_tmp0_);
	_search_path_size_ = search_path_length1;
	_tmp2_ = search_path;
	_tmp2__length1 = search_path_length1;
	_tmp3_ = dc_icon_fallback_load_hicolor_index (_tmp2_, (gint) _tmp2__length1);
	kf = _tmp3_;
	_tmp4_ = kf;
	if (_tmp4_ == NULL) {
		_g_key_file_unref0 (kf);
		search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp5_ = g_new0 (gchar*, 0 + 1);
	inherits = _tmp5_;
	inherits_length1 = 0;
	_inherits_size_ = inherits_length1;
	{
		gchar** _tmp6_ = NULL;
		GKeyFile* _tmp7_;
		gsize _tmp8_ = 0;
		gchar** _tmp9_;
		gint _tmp6__length1;
		gint __tmp6__size_;
		gchar** _tmp10_;
		gint _tmp10__length1;
		_tmp7_ = kf;
		_tmp9_ = g_key_file_get_string_list (_tmp7_, "Icon Theme", "Inherits", &_tmp8_, &_inner_error0_);
		_tmp6_ = _tmp9_;
		_tmp6__length1 = _tmp8_;
		__tmp6__size_ = _tmp6__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_KEY_FILE_ERROR) {
				goto __catch0_g_key_file_error;
			}
			inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
			_g_key_file_unref0 (kf);
			search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp6_;
		_tmp10__length1 = _tmp6__length1;
		_tmp6_ = NULL;
		_tmp6__length1 = 0;
		inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
		inherits = _tmp10_;
		inherits_length1 = _tmp10__length1;
		_inherits_size_ = inherits_length1;
		_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	}
	goto __finally0;
	__catch0_g_key_file_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
		_g_key_file_unref0 (kf);
		search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), 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;
	}
	{
		const gchar** t_collection = NULL;
		gint t_collection_length1 = 0;
		gint _t_collection_size_ = 0;
		gint t_it = 0;
		t_collection = DC_ICON_FALLBACK_FALLBACK_THEMES;
		t_collection_length1 = G_N_ELEMENTS (DC_ICON_FALLBACK_FALLBACK_THEMES);
		for (t_it = 0; t_it < t_collection_length1; t_it = t_it + 1) {
			const gchar* t = NULL;
			t = t_collection[t_it];
			{
				const gchar* _tmp11_;
				gchar** _tmp12_;
				gint _tmp12__length1;
				_tmp11_ = t;
				_tmp12_ = inherits;
				_tmp12__length1 = inherits_length1;
				if (!_vala_string_array_contains (_tmp12_, _tmp12__length1, _tmp11_)) {
					const gchar* _tmp13_;
					gchar* _tmp14_;
					_tmp13_ = t;
					_tmp14_ = g_strdup (_tmp13_);
					_vala_array_add1 (&inherits, &inherits_length1, &_inherits_size_, _tmp14_);
				}
			}
		}
	}
	_tmp15_ = kf;
	_tmp16_ = inherits;
	_tmp16__length1 = inherits_length1;
	g_key_file_set_string_list (_tmp15_, "Icon Theme", "Inherits", (const gchar* const*) _tmp16_, (gint) _tmp16__length1);
	_tmp17_ = g_get_user_cache_dir ();
	_tmp18_ = g_build_filename (_tmp17_, "parla", "icon-fallback", NULL);
	dir = _tmp18_;
	_tmp19_ = dir;
	_tmp20_ = g_build_filename (_tmp19_, "hicolor", NULL);
	hicolor_dir = _tmp20_;
	_tmp21_ = hicolor_dir;
	_tmp22_ = g_build_filename (_tmp21_, "index.theme", NULL);
	index = _tmp22_;
	_tmp23_ = kf;
	_tmp24_ = g_key_file_to_data (_tmp23_, NULL, NULL);
	data = _tmp24_;
	{
		gchar* old = NULL;
		gboolean _tmp25_ = FALSE;
		gboolean _tmp26_ = FALSE;
		const gchar* _tmp27_;
		gchar* _tmp28_ = NULL;
		gboolean _tmp29_;
		_tmp27_ = index;
		_tmp29_ = g_file_get_contents (_tmp27_, &_tmp28_, NULL, &_inner_error0_);
		_g_free0 (old);
		old = _tmp28_;
		_tmp26_ = _tmp29_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (old);
			if (_inner_error0_->domain == G_FILE_ERROR) {
				goto __catch1_g_file_error;
			}
			_g_free0 (data);
			_g_free0 (index);
			_g_free0 (hicolor_dir);
			_g_free0 (dir);
			inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
			_g_key_file_unref0 (kf);
			search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
			g_critical ("file %s: line %d: unexpected 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;
		}
		if (!_tmp26_) {
			_tmp25_ = TRUE;
		} else {
			const gchar* _tmp30_;
			const gchar* _tmp31_;
			_tmp30_ = old;
			_tmp31_ = data;
			_tmp25_ = g_strcmp0 (_tmp30_, _tmp31_) != 0;
		}
		if (_tmp25_) {
			const gchar* _tmp32_;
			const gchar* _tmp33_;
			const gchar* _tmp34_;
			_tmp32_ = hicolor_dir;
			g_mkdir_with_parents (_tmp32_, 0755);
			_tmp33_ = index;
			_tmp34_ = data;
			g_file_set_contents (_tmp33_, _tmp34_, (gssize) -1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (old);
				if (_inner_error0_->domain == G_FILE_ERROR) {
					goto __catch1_g_file_error;
				}
				_g_free0 (data);
				_g_free0 (index);
				_g_free0 (hicolor_dir);
				_g_free0 (dir);
				inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
				_g_key_file_unref0 (kf);
				search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
				g_critical ("file %s: line %d: unexpected 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 (old);
	}
	goto __finally1;
	__catch1_g_file_error:
	{
		g_clear_error (&_inner_error0_);
		{
			const gchar* _tmp35_;
			const gchar* _tmp36_;
			const gchar* _tmp37_;
			_tmp35_ = hicolor_dir;
			g_mkdir_with_parents (_tmp35_, 0755);
			_tmp36_ = index;
			_tmp37_ = data;
			g_file_set_contents (_tmp36_, _tmp37_, (gssize) -1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == G_FILE_ERROR) {
					goto __catch2_g_file_error;
				}
				_g_free0 (data);
				_g_free0 (index);
				_g_free0 (hicolor_dir);
				_g_free0 (dir);
				inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
				_g_key_file_unref0 (kf);
				search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
				g_critical ("file %s: line %d: unexpected 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;
			}
		}
		goto __finally2;
		__catch2_g_file_error:
		{
			GError* e2 = NULL;
			const gchar* _tmp38_;
			GError* _tmp39_;
			const gchar* _tmp40_;
			e2 = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp38_ = index;
			_tmp39_ = e2;
			_tmp40_ = _tmp39_->message;
			g_debug ("icon_fallback.vala:64: icon fallback: cannot write %s: %s", _tmp38_, _tmp40_);
			_g_error_free0 (e2);
			_g_free0 (data);
			_g_free0 (index);
			_g_free0 (hicolor_dir);
			_g_free0 (dir);
			inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
			_g_key_file_unref0 (kf);
			search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
			return;
		}
		__finally2:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (data);
			_g_free0 (index);
			_g_free0 (hicolor_dir);
			_g_free0 (dir);
			inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
			_g_key_file_unref0 (kf);
			search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
			g_critical ("file %s: line %d: unexpected 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;
		}
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (data);
		_g_free0 (index);
		_g_free0 (hicolor_dir);
		_g_free0 (dir);
		inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
		_g_key_file_unref0 (kf);
		search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), 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;
	}
	_tmp41_ = dir;
	_tmp42_ = g_strdup (_tmp41_);
	_tmp43_ = g_new0 (gchar*, 1 + 1);
	_tmp43_[0] = _tmp42_;
	path = _tmp43_;
	path_length1 = 1;
	_path_size_ = path_length1;
	_tmp44_ = search_path;
	_tmp44__length1 = search_path_length1;
	{
		gchar** p_collection = NULL;
		gint p_collection_length1 = 0;
		gint _p_collection_size_ = 0;
		gint p_it = 0;
		p_collection = _tmp44_;
		p_collection_length1 = _tmp44__length1;
		for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) {
			const gchar* p = NULL;
			p = p_collection[p_it];
			{
				const gchar* _tmp45_;
				gchar* _tmp46_;
				_tmp45_ = p;
				_tmp46_ = g_strdup (_tmp45_);
				_vala_array_add2 (&path, &path_length1, &_path_size_, _tmp46_);
			}
		}
	}
	_tmp47_ = path;
	_tmp47__length1 = path_length1;
	gtk_icon_theme_set_search_path (theme, _tmp47_);
	_tmp48_ = _vala_g_strjoinv (",", DC_ICON_FALLBACK_FALLBACK_THEMES, (gint) G_N_ELEMENTS (DC_ICON_FALLBACK_FALLBACK_THEMES));
	_tmp49_ = _tmp48_;
	_tmp50_ = index;
	g_debug ("icon_fallback.vala:73: icon fallback: inheriting %s via %s", _tmp49_, _tmp50_);
	_g_free0 (_tmp49_);
	path = (_vala_array_free (path, path_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (data);
	_g_free0 (index);
	_g_free0 (hicolor_dir);
	_g_free0 (dir);
	inherits = (_vala_array_free (inherits, inherits_length1, (GDestroyNotify) g_free), NULL);
	_g_key_file_unref0 (kf);
	search_path = (_vala_array_free (search_path, search_path_length1, (GDestroyNotify) g_free), NULL);
}

GKeyFile*
dc_icon_fallback_load_hicolor_index (gchar** search_path,
                                     gint search_path_length1)
{
	GKeyFile* kf = NULL;
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	GKeyFile* result;
	_tmp0_ = g_key_file_new ();
	kf = _tmp0_;
	_tmp1_ = kf;
	g_key_file_set_list_separator (_tmp1_, ',');
	{
		gchar** p_collection = NULL;
		gint p_collection_length1 = 0;
		gint _p_collection_size_ = 0;
		gint p_it = 0;
		p_collection = search_path;
		p_collection_length1 = search_path_length1;
		for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) {
			const gchar* p = NULL;
			p = p_collection[p_it];
			{
				gchar* f = NULL;
				const gchar* _tmp2_;
				gchar* _tmp3_;
				const gchar* _tmp4_;
				_tmp2_ = p;
				_tmp3_ = g_build_filename (_tmp2_, "hicolor", "index.theme", NULL);
				f = _tmp3_;
				_tmp4_ = f;
				if (!g_file_test (_tmp4_, G_FILE_TEST_IS_REGULAR)) {
					_g_free0 (f);
					continue;
				}
				{
					GKeyFile* _tmp5_;
					const gchar* _tmp6_;
					_tmp5_ = kf;
					_tmp6_ = f;
					g_key_file_load_from_file (_tmp5_, _tmp6_, G_KEY_FILE_KEEP_COMMENTS, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					result = kf;
					_g_free0 (f);
					return result;
				}
				goto __finally0;
				__catch0_g_error:
				{
					GError* e = NULL;
					const gchar* _tmp7_;
					GError* _tmp8_;
					const gchar* _tmp9_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp7_ = f;
					_tmp8_ = e;
					_tmp9_ = _tmp8_->message;
					g_debug ("icon_fallback.vala:91: icon fallback: ignoring %s: %s", _tmp7_, _tmp9_);
					_g_error_free0 (e);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (f);
					_g_key_file_unref0 (kf);
					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;
				}
				_g_free0 (f);
			}
		}
	}
	{
		GBytes* bytes = NULL;
		GBytes* _tmp10_;
		GKeyFile* _tmp11_;
		GBytes* _tmp12_;
		_tmp10_ = g_resources_lookup_data ("/org/gtk/libgtk/icons/hicolor.index.theme", G_RESOURCE_LOOKUP_FLAGS_NONE, &_inner_error0_);
		bytes = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp11_ = kf;
		_tmp12_ = bytes;
		g_key_file_load_from_bytes (_tmp11_, _tmp12_, G_KEY_FILE_NONE, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_bytes_unref0 (bytes);
			goto __catch1_g_error;
		}
		result = kf;
		_g_bytes_unref0 (bytes);
		return result;
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp13_;
		const gchar* _tmp14_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp13_ = e;
		_tmp14_ = _tmp13_->message;
		g_debug ("icon_fallback.vala:101: icon fallback: no hicolor index: %s", _tmp14_);
		result = NULL;
		_g_error_free0 (e);
		_g_key_file_unref0 (kf);
		return result;
	}
	__finally1:
	_g_key_file_unref0 (kf);
	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;
}

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

