/* AppChooserButton.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from AppChooserButton.vala, do not modify */

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
 */

#include "applications.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <granite-7.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

enum  {
	DEFAULTS_APP_CHOOSER_BUTTON_0_PROPERTY,
	DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY,
	DEFAULTS_APP_CHOOSER_BUTTON_NUM_PROPERTIES
};
static GParamSpec* defaults_app_chooser_button_properties[DEFAULTS_APP_CHOOSER_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block4Data Block4Data;
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block5Data Block5Data;
#define _gtk_expression_unref0(var) ((var == NULL) ? NULL : (var = (gtk_expression_unref (var), NULL)))

struct _DefaultsAppChooserButtonPrivate {
	gchar* _content_type;
};

struct _Block4Data {
	int _ref_count_;
	DefaultsAppChooserButton* self;
	GListStore* store;
};

struct _Block5Data {
	int _ref_count_;
	DefaultsAppChooserButton* self;
	GtkDropDown* dropdown;
};

static gint DefaultsAppChooserButton_private_offset;
static gpointer defaults_app_chooser_button_parent_class = NULL;

static void defaults_app_chooser_button_load_apps (DefaultsAppChooserButton* self,
                                            GListStore* store,
                                            const gchar* content_type);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static void __lambda21_ (Block4Data* _data4_,
                  GAppInfo* item);
static void ___lambda21__gfunc (gconstpointer data,
                         gpointer self);
static guint defaults_app_chooser_button_find_default_app_pos (DefaultsAppChooserButton* self,
                                                        GListStore* store,
                                                        const gchar* content_type);
static gboolean __lambda22_ (GObject* a,
                      GObject* b);
static gboolean ___lambda22__gequal_func (gconstpointer a,
                                   gconstpointer b);
static void defaults_app_chooser_button_factory_setup (DefaultsAppChooserButton* self,
                                                GObject* object);
static void defaults_app_chooser_button_factory_bind (DefaultsAppChooserButton* self,
                                               GObject* object);
static gchar* defaults_app_chooser_button_get_app_name (DefaultsAppChooserButton* self,
                                                 GAppInfo* app);
static void defaults_app_chooser_button_run_in_thread (DefaultsAppChooserButton* self,
                                                GThreadFunc func,
                                                gpointer func_target);
static void defaults_app_chooser_button_change_default (DefaultsAppChooserButton* self,
                                                 GAppInfo* app,
                                                 const gchar* content_type);
static gchar** defaults_app_chooser_button_get_types_for_app (DefaultsAppChooserButton* self,
                                                       const gchar* app,
                                                       gint* result_length1);
static gchar** _vala_array_dup4 (gchar** self,
                          gssize length);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static GObject * defaults_app_chooser_button_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static void _defaults_app_chooser_button_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                                    GObject* object,
                                                                                    gpointer self);
static void _defaults_app_chooser_button_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                                  GObject* object,
                                                                                  gpointer self);
static void _defaults_app_chooser_button___lambda23_ (Block5Data* _data5_);
static void* __lambda24_ (Block5Data* _data5_);
static gpointer ___lambda24__gthread_func (gpointer self);
static void __defaults_app_chooser_button___lambda23__g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self);
static gboolean _defaults_app_chooser_button___lambda25_ (DefaultsAppChooserButton* self,
                                                   GBinding* binding,
                                                   GValue* _n_items,
                                                   GValue* _sensitive);
static gboolean __defaults_app_chooser_button___lambda25__gbinding_transform_func (GBinding* binding,
                                                                            GValue* from_value,
                                                                            GValue* to_value,
                                                                            gpointer self);
static void defaults_app_chooser_button_finalize (GObject * obj);
static GType defaults_app_chooser_button_get_type_once (void);
static void _vala_defaults_app_chooser_button_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_defaults_app_chooser_button_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);
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);

static inline gpointer
defaults_app_chooser_button_get_instance_private (DefaultsAppChooserButton* self)
{
	return G_STRUCT_MEMBER_P (self, DefaultsAppChooserButton_private_offset);
}

DefaultsAppChooserButton*
defaults_app_chooser_button_construct (GType object_type,
                                       const gchar* content_type)
{
	DefaultsAppChooserButton * self = NULL;
	g_return_val_if_fail (content_type != NULL, NULL);
	self = (DefaultsAppChooserButton*) g_object_new (object_type, "content-type", content_type, NULL);
	return self;
}

DefaultsAppChooserButton*
defaults_app_chooser_button_new (const gchar* content_type)
{
	return defaults_app_chooser_button_construct (DEFAULTS_TYPE_APP_CHOOSER_BUTTON, content_type);
}

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

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		DefaultsAppChooserButton* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->store);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

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 void
__lambda21_ (Block4Data* _data4_,
             GAppInfo* item)
{
	DefaultsAppChooserButton* self;
	self = _data4_->self;
	g_return_if_fail (item != NULL);
	g_list_store_append (_data4_->store, (GObject*) item);
}

static void
___lambda21__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda21_ (self, (GAppInfo*) data);
}

static void
defaults_app_chooser_button_load_apps (DefaultsAppChooserButton* self,
                                       GListStore* store,
                                       const gchar* content_type)
{
	Block4Data* _data4_;
	GListStore* _tmp0_;
	GList* apps = NULL;
	GList* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (store != NULL);
	g_return_if_fail (content_type != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (store);
	_g_object_unref0 (_data4_->store);
	_data4_->store = _tmp0_;
	g_list_store_remove_all (_data4_->store);
	_tmp1_ = g_app_info_get_recommended_for_type (content_type);
	apps = _tmp1_;
	_tmp2_ = apps;
	if (_tmp2_ == NULL) {
		g_warning ("AppChooserButton.vala:63: AppInfo.get_all_for_type() error. content_ty" \
"pe=%s", content_type);
		(apps == NULL) ? NULL : (apps = (_g_list_free__g_object_unref0_ (apps), NULL));
		block4_data_unref (_data4_);
		_data4_ = NULL;
		return;
	}
	_tmp3_ = apps;
	g_list_foreach (_tmp3_, ___lambda21__gfunc, _data4_);
	(apps == NULL) ? NULL : (apps = (_g_list_free__g_object_unref0_ (apps), NULL));
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

static gboolean
__lambda22_ (GObject* a,
             GObject* b)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = g_app_info_get_id (G_TYPE_CHECK_INSTANCE_CAST (a, g_app_info_get_type (), GAppInfo));
	_tmp1_ = g_app_info_get_id (G_TYPE_CHECK_INSTANCE_CAST (b, g_app_info_get_type (), GAppInfo));
	result = g_strcmp0 (_tmp0_, _tmp1_) == 0;
	return result;
}

static gboolean
___lambda22__gequal_func (gconstpointer a,
                          gconstpointer b)
{
	gboolean result;
	result = __lambda22_ ((GObject*) a, (GObject*) b);
	return result;
}

static guint
defaults_app_chooser_button_find_default_app_pos (DefaultsAppChooserButton* self,
                                                  GListStore* store,
                                                  const gchar* content_type)
{
	GAppInfo* default_app = NULL;
	GAppInfo* _tmp0_;
	GAppInfo* _tmp1_;
	guint pos = 0U;
	gboolean found = FALSE;
	GAppInfo* _tmp2_;
	guint _tmp3_ = 0U;
	gboolean _tmp4_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (store != NULL, 0U);
	g_return_val_if_fail (content_type != NULL, 0U);
	_tmp0_ = g_app_info_get_default_for_type (content_type, FALSE);
	default_app = _tmp0_;
	_tmp1_ = default_app;
	if (_tmp1_ == NULL) {
		g_warning ("AppChooserButton.vala:75: AppInfo.get_default_for_type() error. conten" \
"t_type=%s", content_type);
		result = GTK_INVALID_LIST_POSITION;
		_g_object_unref0 (default_app);
		return result;
	}
	_tmp2_ = default_app;
	_tmp4_ = g_list_store_find_with_equal_func (store, (GObject*) _tmp2_, ___lambda22__gequal_func, &_tmp3_);
	pos = _tmp3_;
	found = _tmp4_;
	if (!found) {
		GAppInfo* _tmp5_;
		const gchar* _tmp6_;
		_tmp5_ = default_app;
		_tmp6_ = g_app_info_get_id (_tmp5_);
		g_warning ("AppChooserButton.vala:88: BUG: default app not found in all apps store" \
"! default_app=%s", _tmp6_);
		result = GTK_INVALID_LIST_POSITION;
		_g_object_unref0 (default_app);
		return result;
	}
	result = pos;
	_g_object_unref0 (default_app);
	return result;
}

static void
defaults_app_chooser_button_factory_setup (DefaultsAppChooserButton* self,
                                           GObject* object)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	AppChooserButtonRow* row = NULL;
	AppChooserButtonRow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_list_item_get_type ()) ? ((GtkListItem*) object) : NULL);
	item = _tmp0_;
	_tmp1_ = app_chooser_button_row_new ();
	g_object_ref_sink (_tmp1_);
	row = _tmp1_;
	gtk_list_item_set_child (item, (GtkWidget*) row);
	_g_object_unref0 (row);
	_g_object_unref0 (item);
}

static void
defaults_app_chooser_button_factory_bind (DefaultsAppChooserButton* self,
                                          GObject* object)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GAppInfo* app = NULL;
	GObject* _tmp1_;
	GObject* _tmp2_;
	GAppInfo* _tmp3_;
	AppChooserButtonRow* row = NULL;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	AppChooserButtonRow* _tmp6_;
	GIcon* _tmp7_;
	const gchar* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_list_item_get_type ()) ? ((GtkListItem*) object) : NULL);
	item = _tmp0_;
	_tmp1_ = gtk_list_item_get_item (item);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, g_app_info_get_type ()) ? ((GAppInfo*) _tmp2_) : NULL);
	app = _tmp3_;
	_tmp4_ = gtk_list_item_get_child (item);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (IS_APP_CHOOSER_BUTTON_ROW (_tmp5_) ? ((AppChooserButtonRow*) _tmp5_) : NULL);
	row = _tmp6_;
	_tmp7_ = g_app_info_get_icon (app);
	app_chooser_button_row_set_app_icon (row, _tmp7_);
	_tmp8_ = g_app_info_get_name (app);
	app_chooser_button_row_set_app_name (row, _tmp8_);
	_g_object_unref0 (row);
	_g_object_unref0 (app);
	_g_object_unref0 (item);
}

static gchar*
defaults_app_chooser_button_get_app_name (DefaultsAppChooserButton* self,
                                          GAppInfo* app)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (app != NULL, NULL);
	_tmp0_ = g_app_info_get_name (app);
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
defaults_app_chooser_button_run_in_thread (DefaultsAppChooserButton* self,
                                           GThreadFunc func,
                                           gpointer func_target)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		GThreadFunc _tmp0_;
		gpointer _tmp0__target;
		GThread* _tmp1_;
		GThread* _tmp2_;
		_tmp0_ = func;
		_tmp0__target = func_target;
		func = NULL;
		func_target = NULL;
		_tmp1_ = g_thread_try_new (NULL, _tmp0_, _tmp0__target, &_inner_error0_);
		_tmp2_ = _tmp1_;
		_g_thread_unref0 (_tmp2_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("AppChooserButton.vala:119: Could not create a new thread: %s", _tmp4_);
		_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;
	}
}

static gchar**
_vala_array_dup4 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

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
defaults_app_chooser_button_change_default (DefaultsAppChooserButton* self,
                                            GAppInfo* app,
                                            const gchar* content_type)
{
	gchar** types = NULL;
	gint _tmp0_ = 0;
	gchar** _tmp1_;
	gint types_length1;
	gint _types_size_;
	gchar** supported_types = NULL;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gint supported_types_length1;
	gint _supported_types_size_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (app != NULL);
	g_return_if_fail (content_type != NULL);
	_tmp1_ = defaults_app_chooser_button_get_types_for_app (self, content_type, &_tmp0_);
	types = _tmp1_;
	types_length1 = _tmp0_;
	_types_size_ = types_length1;
	_tmp3_ = _tmp2_ = g_app_info_get_supported_types (app);
	_tmp4_ = (_tmp3_ != NULL) ? _vala_array_dup4 (_tmp3_, _vala_array_length (_tmp2_)) : _tmp3_;
	_tmp4__length1 = _vala_array_length (_tmp2_);
	supported_types = _tmp4_;
	supported_types_length1 = _tmp4__length1;
	_supported_types_size_ = supported_types_length1;
	_tmp5_ = types;
	_tmp5__length1 = types_length1;
	{
		gchar** type_collection = NULL;
		gint type_collection_length1 = 0;
		gint _type_collection_size_ = 0;
		gint type_it = 0;
		type_collection = _tmp5_;
		type_collection_length1 = _tmp5__length1;
		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
			const gchar* type = NULL;
			type = type_collection[type_it];
			{
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				gchar** _tmp8_;
				gint _tmp8__length1;
				_tmp6_ = type;
				g_app_info_reset_type_associations (_tmp6_);
				_tmp7_ = type;
				_tmp8_ = supported_types;
				_tmp8__length1 = supported_types_length1;
				if (_vala_string_array_contains (_tmp8_, _tmp8__length1, _tmp7_)) {
					{
						const gchar* _tmp9_;
						const gchar* _tmp10_;
						const gchar* _tmp11_;
						_tmp9_ = type;
						g_app_info_set_as_default_for_type (app, _tmp9_, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp10_ = g_app_info_get_name (app);
						_tmp11_ = type;
						g_debug ("AppChooserButton.vala:132: %s now default for content type %s", _tmp10_, _tmp11_);
					}
					goto __finally0;
					__catch0_g_error:
					{
						GError* e = NULL;
						GError* _tmp12_;
						const gchar* _tmp13_;
						e = _inner_error0_;
						_inner_error0_ = NULL;
						_tmp12_ = e;
						_tmp13_ = _tmp12_->message;
						g_critical ("AppChooserButton.vala:134: Error setting default app: %s", _tmp13_);
						_g_error_free0 (e);
					}
					__finally0:
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						supported_types = (_vala_array_free (supported_types, supported_types_length1, (GDestroyNotify) g_free), NULL);
						types = (_vala_array_free (types, types_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;
					}
				} else {
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					_tmp14_ = g_app_info_get_name (app);
					_tmp15_ = type;
					g_critical ("AppChooserButton.vala:137: %s does not support content type %s", _tmp14_, _tmp15_);
				}
			}
		}
	}
	supported_types = (_vala_array_free (supported_types, supported_types_length1, (GDestroyNotify) g_free), NULL);
	types = (_vala_array_free (types, types_length1, (GDestroyNotify) g_free), NULL);
}

static gchar**
defaults_app_chooser_button_get_types_for_app (DefaultsAppChooserButton* self,
                                               const gchar* app,
                                               gint* result_length1)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	static GQuark _tmp1_label3 = 0;
	static GQuark _tmp1_label4 = 0;
	static GQuark _tmp1_label5 = 0;
	static GQuark _tmp1_label6 = 0;
	static GQuark _tmp1_label7 = 0;
	static GQuark _tmp1_label8 = 0;
	static GQuark _tmp1_label9 = 0;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (app != NULL, NULL);
	_tmp0_ = app;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if ((((_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("x-scheme-handler/mailto")))) || (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("text/calendar"))))) || (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("x-scheme-handler/geo"))))) || (_tmp2_ == ((0 != _tmp1_label3) ? _tmp1_label3 : (_tmp1_label3 = g_quark_from_static_string ("application/pdf"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp3_;
				gchar** _tmp4_;
				gchar** _tmp5_;
				gint _tmp5__length1;
				_tmp3_ = g_strdup (app);
				_tmp4_ = g_new0 (gchar*, 1 + 1);
				_tmp4_[0] = _tmp3_;
				_tmp5_ = _tmp4_;
				_tmp5__length1 = 1;
				if (result_length1) {
					*result_length1 = _tmp5__length1;
				}
				result = _tmp5_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label4) ? _tmp1_label4 : (_tmp1_label4 = g_quark_from_static_string ("x-scheme-handler/https")))) {
		switch (0) {
			default:
			{
				gchar* _tmp6_;
				gchar* _tmp7_;
				gchar* _tmp8_;
				gchar* _tmp9_;
				gchar** _tmp10_;
				gchar** _tmp11_;
				gint _tmp11__length1;
				_tmp6_ = g_strdup ("x-scheme-handler/http");
				_tmp7_ = g_strdup ("x-scheme-handler/https");
				_tmp8_ = g_strdup ("text/html");
				_tmp9_ = g_strdup ("application/xhtml+xml");
				_tmp10_ = g_new0 (gchar*, 4 + 1);
				_tmp10_[0] = _tmp6_;
				_tmp10_[1] = _tmp7_;
				_tmp10_[2] = _tmp8_;
				_tmp10_[3] = _tmp9_;
				_tmp11_ = _tmp10_;
				_tmp11__length1 = 4;
				if (result_length1) {
					*result_length1 = _tmp11__length1;
				}
				result = _tmp11_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label5) ? _tmp1_label5 : (_tmp1_label5 = g_quark_from_static_string ("video/x-ogm+ogg")))) {
		switch (0) {
			default:
			{
				gchar* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				gchar* _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				gchar* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				gchar* _tmp22_;
				gchar* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				gchar* _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				gchar* _tmp29_;
				gchar* _tmp30_;
				gchar* _tmp31_;
				gchar* _tmp32_;
				gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				gchar* _tmp36_;
				gchar* _tmp37_;
				gchar* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				gchar* _tmp41_;
				gchar* _tmp42_;
				gchar* _tmp43_;
				gchar* _tmp44_;
				gchar** _tmp45_;
				gchar** _tmp46_;
				gint _tmp46__length1;
				_tmp12_ = g_strdup ("application/x-quicktimeplayer");
				_tmp13_ = g_strdup ("application/vnd.rn-realmedia");
				_tmp14_ = g_strdup ("application/asx");
				_tmp15_ = g_strdup ("application/x-mplayer2");
				_tmp16_ = g_strdup ("application/x-ms-wmv");
				_tmp17_ = g_strdup ("video/quicktime");
				_tmp18_ = g_strdup ("video/x-quicktime");
				_tmp19_ = g_strdup ("video/vnd.rn-realvideo");
				_tmp20_ = g_strdup ("video/x-ms-asf-plugin");
				_tmp21_ = g_strdup ("video/x-msvideo");
				_tmp22_ = g_strdup ("video/msvideo");
				_tmp23_ = g_strdup ("video/x-ms-asf");
				_tmp24_ = g_strdup ("video/x-ms-wm");
				_tmp25_ = g_strdup ("video/x-ms-wmv");
				_tmp26_ = g_strdup ("video/x-ms-wmp");
				_tmp27_ = g_strdup ("video/x-ms-wvx");
				_tmp28_ = g_strdup ("video/mpeg");
				_tmp29_ = g_strdup ("video/x-mpeg");
				_tmp30_ = g_strdup ("video/x-mpeg2");
				_tmp31_ = g_strdup ("video/mp4");
				_tmp32_ = g_strdup ("video/3gpp");
				_tmp33_ = g_strdup ("video/fli");
				_tmp34_ = g_strdup ("video/x-fli");
				_tmp35_ = g_strdup ("video/x-flv");
				_tmp36_ = g_strdup ("video/vnd.vivo");
				_tmp37_ = g_strdup ("video/x-matroska");
				_tmp38_ = g_strdup ("video/matroska");
				_tmp39_ = g_strdup ("video/x-mng");
				_tmp40_ = g_strdup ("video/webm");
				_tmp41_ = g_strdup ("video/x-webm");
				_tmp42_ = g_strdup ("video/mp2t");
				_tmp43_ = g_strdup ("video/vnd.mpegurl");
				_tmp44_ = g_strdup ("video/x-ogm+ogg");
				_tmp45_ = g_new0 (gchar*, 33 + 1);
				_tmp45_[0] = _tmp12_;
				_tmp45_[1] = _tmp13_;
				_tmp45_[2] = _tmp14_;
				_tmp45_[3] = _tmp15_;
				_tmp45_[4] = _tmp16_;
				_tmp45_[5] = _tmp17_;
				_tmp45_[6] = _tmp18_;
				_tmp45_[7] = _tmp19_;
				_tmp45_[8] = _tmp20_;
				_tmp45_[9] = _tmp21_;
				_tmp45_[10] = _tmp22_;
				_tmp45_[11] = _tmp23_;
				_tmp45_[12] = _tmp24_;
				_tmp45_[13] = _tmp25_;
				_tmp45_[14] = _tmp26_;
				_tmp45_[15] = _tmp27_;
				_tmp45_[16] = _tmp28_;
				_tmp45_[17] = _tmp29_;
				_tmp45_[18] = _tmp30_;
				_tmp45_[19] = _tmp31_;
				_tmp45_[20] = _tmp32_;
				_tmp45_[21] = _tmp33_;
				_tmp45_[22] = _tmp34_;
				_tmp45_[23] = _tmp35_;
				_tmp45_[24] = _tmp36_;
				_tmp45_[25] = _tmp37_;
				_tmp45_[26] = _tmp38_;
				_tmp45_[27] = _tmp39_;
				_tmp45_[28] = _tmp40_;
				_tmp45_[29] = _tmp41_;
				_tmp45_[30] = _tmp42_;
				_tmp45_[31] = _tmp43_;
				_tmp45_[32] = _tmp44_;
				_tmp46_ = _tmp45_;
				_tmp46__length1 = 33;
				if (result_length1) {
					*result_length1 = _tmp46__length1;
				}
				result = _tmp46_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label6) ? _tmp1_label6 : (_tmp1_label6 = g_quark_from_static_string ("audio/x-vorbis+ogg")))) {
		switch (0) {
			default:
			{
				gchar* _tmp47_;
				gchar* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				gchar* _tmp51_;
				gchar* _tmp52_;
				gchar* _tmp53_;
				gchar* _tmp54_;
				gchar* _tmp55_;
				gchar* _tmp56_;
				gchar* _tmp57_;
				gchar* _tmp58_;
				gchar* _tmp59_;
				gchar* _tmp60_;
				gchar* _tmp61_;
				gchar* _tmp62_;
				gchar* _tmp63_;
				gchar* _tmp64_;
				gchar* _tmp65_;
				gchar* _tmp66_;
				gchar* _tmp67_;
				gchar* _tmp68_;
				gchar* _tmp69_;
				gchar* _tmp70_;
				gchar* _tmp71_;
				gchar* _tmp72_;
				gchar* _tmp73_;
				gchar* _tmp74_;
				gchar* _tmp75_;
				gchar* _tmp76_;
				gchar* _tmp77_;
				gchar* _tmp78_;
				gchar* _tmp79_;
				gchar* _tmp80_;
				gchar* _tmp81_;
				gchar* _tmp82_;
				gchar* _tmp83_;
				gchar* _tmp84_;
				gchar* _tmp85_;
				gchar* _tmp86_;
				gchar* _tmp87_;
				gchar* _tmp88_;
				gchar* _tmp89_;
				gchar* _tmp90_;
				gchar* _tmp91_;
				gchar* _tmp92_;
				gchar* _tmp93_;
				gchar* _tmp94_;
				gchar* _tmp95_;
				gchar* _tmp96_;
				gchar* _tmp97_;
				gchar* _tmp98_;
				gchar* _tmp99_;
				gchar* _tmp100_;
				gchar* _tmp101_;
				gchar* _tmp102_;
				gchar* _tmp103_;
				gchar* _tmp104_;
				gchar* _tmp105_;
				gchar* _tmp106_;
				gchar** _tmp107_;
				gchar** _tmp108_;
				gint _tmp108__length1;
				_tmp47_ = g_strdup ("audio/ogg");
				_tmp48_ = g_strdup ("audio/mpeg");
				_tmp49_ = g_strdup ("audio/mp4");
				_tmp50_ = g_strdup ("audio/flac");
				_tmp51_ = g_strdup ("application/x-musepack");
				_tmp52_ = g_strdup ("application/musepack");
				_tmp53_ = g_strdup ("application/x-ape");
				_tmp54_ = g_strdup ("application/x-id3");
				_tmp55_ = g_strdup ("application/ogg");
				_tmp56_ = g_strdup ("application/x-ogg");
				_tmp57_ = g_strdup ("application/x-vorbis+ogg");
				_tmp58_ = g_strdup ("application/x-flac");
				_tmp59_ = g_strdup ("application/vnd.rn-realaudio");
				_tmp60_ = g_strdup ("application/x-nsv-vp3-mp3");
				_tmp61_ = g_strdup ("audio/x-musepack");
				_tmp62_ = g_strdup ("audio/musepack");
				_tmp63_ = g_strdup ("audio/ape");
				_tmp64_ = g_strdup ("audio/x-ape");
				_tmp65_ = g_strdup ("audio/x-mp3");
				_tmp66_ = g_strdup ("audio/mpeg");
				_tmp67_ = g_strdup ("audio/x-mpeg");
				_tmp68_ = g_strdup ("audio/x-mpeg-3");
				_tmp69_ = g_strdup ("audio/mpeg3");
				_tmp70_ = g_strdup ("audio/mp3");
				_tmp71_ = g_strdup ("audio/mp4");
				_tmp72_ = g_strdup ("audio/x-m4a");
				_tmp73_ = g_strdup ("audio/mpc");
				_tmp74_ = g_strdup ("audio/x-mpc");
				_tmp75_ = g_strdup ("audio/mp");
				_tmp76_ = g_strdup ("audio/x-mp");
				_tmp77_ = g_strdup ("audio/x-vorbis+ogg");
				_tmp78_ = g_strdup ("audio/vorbis");
				_tmp79_ = g_strdup ("audio/x-vorbis");
				_tmp80_ = g_strdup ("audio/ogg");
				_tmp81_ = g_strdup ("audio/x-ogg");
				_tmp82_ = g_strdup ("audio/x-flac");
				_tmp83_ = g_strdup ("audio/flac");
				_tmp84_ = g_strdup ("audio/x-s3m");
				_tmp85_ = g_strdup ("audio/x-mod");
				_tmp86_ = g_strdup ("audio/x-xm");
				_tmp87_ = g_strdup ("audio/x-it");
				_tmp88_ = g_strdup ("audio/x-pn-realaudio");
				_tmp89_ = g_strdup ("audio/x-realaudio");
				_tmp90_ = g_strdup ("audio/x-pn-realaudio-plugin");
				_tmp91_ = g_strdup ("audio/x-ms-wmv");
				_tmp92_ = g_strdup ("audio/x-ms-wax");
				_tmp93_ = g_strdup ("audio/x-ms-wma");
				_tmp94_ = g_strdup ("audio/wav");
				_tmp95_ = g_strdup ("audio/x-wav");
				_tmp96_ = g_strdup ("audio/mpeg2");
				_tmp97_ = g_strdup ("audio/x-mpeg2");
				_tmp98_ = g_strdup ("audio/x-mpeg3");
				_tmp99_ = g_strdup ("audio/x-mpegurl");
				_tmp100_ = g_strdup ("audio/basic");
				_tmp101_ = g_strdup ("audio/x-basic");
				_tmp102_ = g_strdup ("audio/midi");
				_tmp103_ = g_strdup ("audio/x-scpls");
				_tmp104_ = g_strdup ("audio/webm");
				_tmp105_ = g_strdup ("audio/x-webm");
				_tmp106_ = g_strdup ("x-content/audio-player");
				_tmp107_ = g_new0 (gchar*, 60 + 1);
				_tmp107_[0] = _tmp47_;
				_tmp107_[1] = _tmp48_;
				_tmp107_[2] = _tmp49_;
				_tmp107_[3] = _tmp50_;
				_tmp107_[4] = _tmp51_;
				_tmp107_[5] = _tmp52_;
				_tmp107_[6] = _tmp53_;
				_tmp107_[7] = _tmp54_;
				_tmp107_[8] = _tmp55_;
				_tmp107_[9] = _tmp56_;
				_tmp107_[10] = _tmp57_;
				_tmp107_[11] = _tmp58_;
				_tmp107_[12] = _tmp59_;
				_tmp107_[13] = _tmp60_;
				_tmp107_[14] = _tmp61_;
				_tmp107_[15] = _tmp62_;
				_tmp107_[16] = _tmp63_;
				_tmp107_[17] = _tmp64_;
				_tmp107_[18] = _tmp65_;
				_tmp107_[19] = _tmp66_;
				_tmp107_[20] = _tmp67_;
				_tmp107_[21] = _tmp68_;
				_tmp107_[22] = _tmp69_;
				_tmp107_[23] = _tmp70_;
				_tmp107_[24] = _tmp71_;
				_tmp107_[25] = _tmp72_;
				_tmp107_[26] = _tmp73_;
				_tmp107_[27] = _tmp74_;
				_tmp107_[28] = _tmp75_;
				_tmp107_[29] = _tmp76_;
				_tmp107_[30] = _tmp77_;
				_tmp107_[31] = _tmp78_;
				_tmp107_[32] = _tmp79_;
				_tmp107_[33] = _tmp80_;
				_tmp107_[34] = _tmp81_;
				_tmp107_[35] = _tmp82_;
				_tmp107_[36] = _tmp83_;
				_tmp107_[37] = _tmp84_;
				_tmp107_[38] = _tmp85_;
				_tmp107_[39] = _tmp86_;
				_tmp107_[40] = _tmp87_;
				_tmp107_[41] = _tmp88_;
				_tmp107_[42] = _tmp89_;
				_tmp107_[43] = _tmp90_;
				_tmp107_[44] = _tmp91_;
				_tmp107_[45] = _tmp92_;
				_tmp107_[46] = _tmp93_;
				_tmp107_[47] = _tmp94_;
				_tmp107_[48] = _tmp95_;
				_tmp107_[49] = _tmp96_;
				_tmp107_[50] = _tmp97_;
				_tmp107_[51] = _tmp98_;
				_tmp107_[52] = _tmp99_;
				_tmp107_[53] = _tmp100_;
				_tmp107_[54] = _tmp101_;
				_tmp107_[55] = _tmp102_;
				_tmp107_[56] = _tmp103_;
				_tmp107_[57] = _tmp104_;
				_tmp107_[58] = _tmp105_;
				_tmp107_[59] = _tmp106_;
				_tmp108_ = _tmp107_;
				_tmp108__length1 = 60;
				if (result_length1) {
					*result_length1 = _tmp108__length1;
				}
				result = _tmp108_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label7) ? _tmp1_label7 : (_tmp1_label7 = g_quark_from_static_string ("image/jpeg")))) {
		switch (0) {
			default:
			{
				gchar* _tmp109_;
				gchar* _tmp110_;
				gchar* _tmp111_;
				gchar* _tmp112_;
				gchar* _tmp113_;
				gchar* _tmp114_;
				gchar* _tmp115_;
				gchar* _tmp116_;
				gchar* _tmp117_;
				gchar* _tmp118_;
				gchar* _tmp119_;
				gchar* _tmp120_;
				gchar* _tmp121_;
				gchar* _tmp122_;
				gchar* _tmp123_;
				gchar* _tmp124_;
				gchar* _tmp125_;
				gchar* _tmp126_;
				gchar* _tmp127_;
				gchar* _tmp128_;
				gchar* _tmp129_;
				gchar* _tmp130_;
				gchar* _tmp131_;
				gchar* _tmp132_;
				gchar* _tmp133_;
				gchar* _tmp134_;
				gchar* _tmp135_;
				gchar* _tmp136_;
				gchar* _tmp137_;
				gchar* _tmp138_;
				gchar* _tmp139_;
				gchar* _tmp140_;
				gchar* _tmp141_;
				gchar* _tmp142_;
				gchar* _tmp143_;
				gchar* _tmp144_;
				gchar* _tmp145_;
				gchar* _tmp146_;
				gchar* _tmp147_;
				gchar* _tmp148_;
				gchar* _tmp149_;
				gchar* _tmp150_;
				gchar* _tmp151_;
				gchar* _tmp152_;
				gchar* _tmp153_;
				gchar* _tmp154_;
				gchar* _tmp155_;
				gchar* _tmp156_;
				gchar* _tmp157_;
				gchar* _tmp158_;
				gchar* _tmp159_;
				gchar* _tmp160_;
				gchar* _tmp161_;
				gchar* _tmp162_;
				gchar* _tmp163_;
				gchar* _tmp164_;
				gchar** _tmp165_;
				gchar** _tmp166_;
				gint _tmp166__length1;
				_tmp109_ = g_strdup ("image/jpeg");
				_tmp110_ = g_strdup ("image/jpg");
				_tmp111_ = g_strdup ("image/pjpeg");
				_tmp112_ = g_strdup ("image/png");
				_tmp113_ = g_strdup ("image/tiff");
				_tmp114_ = g_strdup ("image/x-3fr");
				_tmp115_ = g_strdup ("image/x-adobe-dng");
				_tmp116_ = g_strdup ("image/x-arw");
				_tmp117_ = g_strdup ("image/x-bay");
				_tmp118_ = g_strdup ("image/x-bmp");
				_tmp119_ = g_strdup ("image/x-canon-cr2");
				_tmp120_ = g_strdup ("image/x-canon-crw");
				_tmp121_ = g_strdup ("image/x-cap");
				_tmp122_ = g_strdup ("image/x-cr2");
				_tmp123_ = g_strdup ("image/x-crw");
				_tmp124_ = g_strdup ("image/x-dcr");
				_tmp125_ = g_strdup ("image/x-dcraw");
				_tmp126_ = g_strdup ("image/x-dcs");
				_tmp127_ = g_strdup ("image/x-dng");
				_tmp128_ = g_strdup ("image/x-drf");
				_tmp129_ = g_strdup ("image/x-eip");
				_tmp130_ = g_strdup ("image/x-erf");
				_tmp131_ = g_strdup ("image/x-fff");
				_tmp132_ = g_strdup ("image/x-fuji-raf");
				_tmp133_ = g_strdup ("image/x-iiq");
				_tmp134_ = g_strdup ("image/x-k25");
				_tmp135_ = g_strdup ("image/x-kdc");
				_tmp136_ = g_strdup ("image/x-mef");
				_tmp137_ = g_strdup ("image/x-minolta-mrw");
				_tmp138_ = g_strdup ("image/x-mos");
				_tmp139_ = g_strdup ("image/x-mrw");
				_tmp140_ = g_strdup ("image/x-nef");
				_tmp141_ = g_strdup ("image/x-nikon-nef");
				_tmp142_ = g_strdup ("image/x-nrw");
				_tmp143_ = g_strdup ("image/x-olympus-orf");
				_tmp144_ = g_strdup ("image/x-orf");
				_tmp145_ = g_strdup ("image/x-panasonic-raw");
				_tmp146_ = g_strdup ("image/x-pef");
				_tmp147_ = g_strdup ("image/x-pentax-pef");
				_tmp148_ = g_strdup ("image/x-png");
				_tmp149_ = g_strdup ("image/x-ptx");
				_tmp150_ = g_strdup ("image/x-pxn");
				_tmp151_ = g_strdup ("image/x-r3d");
				_tmp152_ = g_strdup ("image/x-raf");
				_tmp153_ = g_strdup ("image/x-raw");
				_tmp154_ = g_strdup ("image/x-raw");
				_tmp155_ = g_strdup ("image/x-rw2");
				_tmp156_ = g_strdup ("image/x-rwl");
				_tmp157_ = g_strdup ("image/x-rwz");
				_tmp158_ = g_strdup ("image/x-sigma-x3f");
				_tmp159_ = g_strdup ("image/x-sony-arw");
				_tmp160_ = g_strdup ("image/x-sony-sr2");
				_tmp161_ = g_strdup ("image/x-sony-srf");
				_tmp162_ = g_strdup ("image/x-sr2");
				_tmp163_ = g_strdup ("image/x-srf");
				_tmp164_ = g_strdup ("image/x-x3f");
				_tmp165_ = g_new0 (gchar*, 56 + 1);
				_tmp165_[0] = _tmp109_;
				_tmp165_[1] = _tmp110_;
				_tmp165_[2] = _tmp111_;
				_tmp165_[3] = _tmp112_;
				_tmp165_[4] = _tmp113_;
				_tmp165_[5] = _tmp114_;
				_tmp165_[6] = _tmp115_;
				_tmp165_[7] = _tmp116_;
				_tmp165_[8] = _tmp117_;
				_tmp165_[9] = _tmp118_;
				_tmp165_[10] = _tmp119_;
				_tmp165_[11] = _tmp120_;
				_tmp165_[12] = _tmp121_;
				_tmp165_[13] = _tmp122_;
				_tmp165_[14] = _tmp123_;
				_tmp165_[15] = _tmp124_;
				_tmp165_[16] = _tmp125_;
				_tmp165_[17] = _tmp126_;
				_tmp165_[18] = _tmp127_;
				_tmp165_[19] = _tmp128_;
				_tmp165_[20] = _tmp129_;
				_tmp165_[21] = _tmp130_;
				_tmp165_[22] = _tmp131_;
				_tmp165_[23] = _tmp132_;
				_tmp165_[24] = _tmp133_;
				_tmp165_[25] = _tmp134_;
				_tmp165_[26] = _tmp135_;
				_tmp165_[27] = _tmp136_;
				_tmp165_[28] = _tmp137_;
				_tmp165_[29] = _tmp138_;
				_tmp165_[30] = _tmp139_;
				_tmp165_[31] = _tmp140_;
				_tmp165_[32] = _tmp141_;
				_tmp165_[33] = _tmp142_;
				_tmp165_[34] = _tmp143_;
				_tmp165_[35] = _tmp144_;
				_tmp165_[36] = _tmp145_;
				_tmp165_[37] = _tmp146_;
				_tmp165_[38] = _tmp147_;
				_tmp165_[39] = _tmp148_;
				_tmp165_[40] = _tmp149_;
				_tmp165_[41] = _tmp150_;
				_tmp165_[42] = _tmp151_;
				_tmp165_[43] = _tmp152_;
				_tmp165_[44] = _tmp153_;
				_tmp165_[45] = _tmp154_;
				_tmp165_[46] = _tmp155_;
				_tmp165_[47] = _tmp156_;
				_tmp165_[48] = _tmp157_;
				_tmp165_[49] = _tmp158_;
				_tmp165_[50] = _tmp159_;
				_tmp165_[51] = _tmp160_;
				_tmp165_[52] = _tmp161_;
				_tmp165_[53] = _tmp162_;
				_tmp165_[54] = _tmp163_;
				_tmp165_[55] = _tmp164_;
				_tmp166_ = _tmp165_;
				_tmp166__length1 = 56;
				if (result_length1) {
					*result_length1 = _tmp166__length1;
				}
				result = _tmp166_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label8) ? _tmp1_label8 : (_tmp1_label8 = g_quark_from_static_string ("text/plain")))) {
		switch (0) {
			default:
			{
				gchar* _tmp167_;
				gchar* _tmp168_;
				gchar* _tmp169_;
				gchar* _tmp170_;
				gchar* _tmp171_;
				gchar* _tmp172_;
				gchar* _tmp173_;
				gchar* _tmp174_;
				gchar* _tmp175_;
				gchar* _tmp176_;
				gchar* _tmp177_;
				gchar* _tmp178_;
				gchar* _tmp179_;
				gchar* _tmp180_;
				gchar** _tmp181_;
				gchar** _tmp182_;
				gint _tmp182__length1;
				_tmp167_ = g_strdup ("application/xml");
				_tmp168_ = g_strdup ("application/x-perl");
				_tmp169_ = g_strdup ("text/mathml");
				_tmp170_ = g_strdup ("text/plain");
				_tmp171_ = g_strdup ("text/xml");
				_tmp172_ = g_strdup ("text/x-c++hdr");
				_tmp173_ = g_strdup ("text/x-c++src");
				_tmp174_ = g_strdup ("text/x-xsrc");
				_tmp175_ = g_strdup ("text/x-chdr");
				_tmp176_ = g_strdup ("text/x-csrc");
				_tmp177_ = g_strdup ("text/x-dtd");
				_tmp178_ = g_strdup ("text/x-java");
				_tmp179_ = g_strdup ("text/x-python");
				_tmp180_ = g_strdup ("text/x-sql");
				_tmp181_ = g_new0 (gchar*, 14 + 1);
				_tmp181_[0] = _tmp167_;
				_tmp181_[1] = _tmp168_;
				_tmp181_[2] = _tmp169_;
				_tmp181_[3] = _tmp170_;
				_tmp181_[4] = _tmp171_;
				_tmp181_[5] = _tmp172_;
				_tmp181_[6] = _tmp173_;
				_tmp181_[7] = _tmp174_;
				_tmp181_[8] = _tmp175_;
				_tmp181_[9] = _tmp176_;
				_tmp181_[10] = _tmp177_;
				_tmp181_[11] = _tmp178_;
				_tmp181_[12] = _tmp179_;
				_tmp181_[13] = _tmp180_;
				_tmp182_ = _tmp181_;
				_tmp182__length1 = 14;
				if (result_length1) {
					*result_length1 = _tmp182__length1;
				}
				result = _tmp182_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label9) ? _tmp1_label9 : (_tmp1_label9 = g_quark_from_static_string ("inode/directory")))) {
		switch (0) {
			default:
			{
				gchar* _tmp183_;
				gchar* _tmp184_;
				gchar* _tmp185_;
				gchar** _tmp186_;
				gchar** _tmp187_;
				gint _tmp187__length1;
				_tmp183_ = g_strdup ("inode/directory");
				_tmp184_ = g_strdup ("x-directory/normal");
				_tmp185_ = g_strdup ("x-directory/gnome-default-handler");
				_tmp186_ = g_new0 (gchar*, 3 + 1);
				_tmp186_[0] = _tmp183_;
				_tmp186_[1] = _tmp184_;
				_tmp186_[2] = _tmp185_;
				_tmp187_ = _tmp186_;
				_tmp187__length1 = 3;
				if (result_length1) {
					*result_length1 = _tmp187__length1;
				}
				result = _tmp187_;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				gchar** _tmp188_;
				gchar** _tmp189_;
				gint _tmp189__length1;
				_tmp188_ = g_new0 (gchar*, 0 + 1);
				_tmp189_ = _tmp188_;
				_tmp189__length1 = 0;
				if (result_length1) {
					*result_length1 = _tmp189__length1;
				}
				result = _tmp189_;
				return result;
			}
		}
	}
}

const gchar*
defaults_app_chooser_button_get_content_type (DefaultsAppChooserButton* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_content_type;
	result = _tmp0_;
	return result;
}

static void
defaults_app_chooser_button_set_content_type (DefaultsAppChooserButton* self,
                                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = defaults_app_chooser_button_get_content_type (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_content_type);
		self->priv->_content_type = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, defaults_app_chooser_button_properties[DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY]);
	}
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		DefaultsAppChooserButton* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->dropdown);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static void
_defaults_app_chooser_button_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                               GObject* object,
                                                                               gpointer self)
{
	defaults_app_chooser_button_factory_setup ((DefaultsAppChooserButton*) self, object);
}

static void
_defaults_app_chooser_button_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                             GObject* object,
                                                                             gpointer self)
{
	defaults_app_chooser_button_factory_bind ((DefaultsAppChooserButton*) self, object);
}

static gpointer
_gtk_expression_ref0 (gpointer self)
{
	return self ? gtk_expression_ref (self) : NULL;
}

static void*
__lambda24_ (Block5Data* _data5_)
{
	DefaultsAppChooserButton* self;
	GAppInfo* app = NULL;
	GtkDropDown* _tmp0_;
	GObject* _tmp1_;
	GObject* _tmp2_;
	GAppInfo* _tmp3_;
	GAppInfo* _tmp4_;
	const gchar* _tmp5_;
	void* result;
	self = _data5_->self;
	_tmp0_ = _data5_->dropdown;
	_tmp1_ = gtk_drop_down_get_selected_item (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_app_info_get_type (), GAppInfo));
	app = _tmp3_;
	_tmp4_ = app;
	_tmp5_ = self->priv->_content_type;
	defaults_app_chooser_button_change_default (self, _tmp4_, _tmp5_);
	result = NULL;
	_g_object_unref0 (app);
	return result;
}

static gpointer
___lambda24__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda24_ (self);
	block5_data_unref (self);
	return result;
}

static void
_defaults_app_chooser_button___lambda23_ (Block5Data* _data5_)
{
	DefaultsAppChooserButton* self;
	self = _data5_->self;
	defaults_app_chooser_button_run_in_thread (self, ___lambda24__gthread_func, block5_data_ref (_data5_));
}

static void
__defaults_app_chooser_button___lambda23__g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self)
{
	_defaults_app_chooser_button___lambda23_ (self);
}

static gboolean
_defaults_app_chooser_button___lambda25_ (DefaultsAppChooserButton* self,
                                          GBinding* binding,
                                          GValue* _n_items,
                                          GValue* _sensitive)
{
	GValue _tmp0_;
	GValue _tmp1_ = {0};
	gboolean result;
	g_return_val_if_fail (binding != NULL, FALSE);
	g_return_val_if_fail (_n_items != NULL, FALSE);
	g_return_val_if_fail (_sensitive != NULL, FALSE);
	_tmp0_ = *_n_items;
	g_value_init (&_tmp1_, G_TYPE_BOOLEAN);
	g_value_set_boolean (&_tmp1_, g_value_get_uint (&_tmp0_) > ((guint) 0));
	G_IS_VALUE (_sensitive) ? (g_value_unset (_sensitive), NULL) : NULL;
	*_sensitive = _tmp1_;
	result = TRUE;
	return result;
}

static gboolean
__defaults_app_chooser_button___lambda25__gbinding_transform_func (GBinding* binding,
                                                                   GValue* from_value,
                                                                   GValue* to_value,
                                                                   gpointer self)
{
	gboolean result;
	result = _defaults_app_chooser_button___lambda25_ ((DefaultsAppChooserButton*) self, binding, from_value, to_value);
	return result;
}

static GObject *
defaults_app_chooser_button_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DefaultsAppChooserButton * self;
	Block5Data* _data5_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp0_;
	GtkSignalListItemFactory* _tmp1_;
	GtkSignalListItemFactory* _tmp2_;
	GListStore* apps_store = NULL;
	GListStore* _tmp3_;
	GListStore* _tmp4_;
	const gchar* _tmp5_;
	GtkConstantExpression* app_expr = NULL;
	GListStore* _tmp6_;
	GtkConstantExpression* _tmp7_;
	GtkCClosureExpression* app_name_expr = NULL;
	GtkConstantExpression* _tmp8_;
	GtkExpression* _tmp9_;
	GtkExpression** _tmp10_;
	GtkCClosureExpression* _tmp11_;
	GListStore* _tmp12_;
	GListModel* _tmp13_;
	GtkCClosureExpression* _tmp14_;
	GtkExpression* _tmp15_;
	GtkSignalListItemFactory* _tmp16_;
	GtkListItemFactory* _tmp17_;
	GtkDropDown* _tmp18_ = NULL;
	GtkDropDown* _tmp19_;
	GListStore* _tmp20_;
	const gchar* _tmp21_;
	GtkDropDown* _tmp22_;
	GListStore* _tmp23_;
	GtkDropDown* _tmp24_;
	GtkDropDown* _tmp25_;
	parent_class = G_OBJECT_CLASS (defaults_app_chooser_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEFAULTS_TYPE_APP_CHOOSER_BUTTON, DefaultsAppChooserButton);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	factory = _tmp0_;
	_tmp1_ = factory;
	g_signal_connect_object (_tmp1_, "setup", (GCallback) _defaults_app_chooser_button_factory_setup_gtk_signal_list_item_factory_setup, self, 0);
	_tmp2_ = factory;
	g_signal_connect_object (_tmp2_, "bind", (GCallback) _defaults_app_chooser_button_factory_bind_gtk_signal_list_item_factory_bind, self, 0);
	_tmp3_ = g_list_store_new (g_app_info_get_type ());
	apps_store = _tmp3_;
	_tmp4_ = apps_store;
	_tmp5_ = self->priv->_content_type;
	defaults_app_chooser_button_load_apps (self, _tmp4_, _tmp5_);
	_tmp6_ = apps_store;
	_tmp7_ = (GtkConstantExpression*) gtk_constant_expression_new (g_list_store_get_type (), _tmp6_, NULL);
	app_expr = _tmp7_;
	_tmp8_ = app_expr;
	_tmp9_ = _gtk_expression_ref0 ((GtkExpression*) _tmp8_);
	_tmp10_ = g_new0 (GtkExpression*, 1 + 1);
	_tmp10_[0] = _tmp9_;
	_tmp11_ = (GtkCClosureExpression*) gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 1, _tmp10_, (GCallback) defaults_app_chooser_button_get_app_name, NULL, NULL);
	app_name_expr = _tmp11_;
	_tmp12_ = apps_store;
	_tmp13_ = _g_object_ref0 ((GListModel*) _tmp12_);
	_tmp14_ = app_name_expr;
	_tmp15_ = _gtk_expression_ref0 ((GtkExpression*) _tmp14_);
	_tmp16_ = factory;
	_tmp17_ = _g_object_ref0 ((GtkListItemFactory*) _tmp16_);
	_tmp18_ = (GtkDropDown*) gtk_drop_down_new (_tmp13_, _tmp15_);
	gtk_drop_down_set_factory (_tmp18_, _tmp17_);
	_g_object_unref0 (_tmp17_);
	g_object_ref_sink (_tmp18_);
	_data5_->dropdown = _tmp18_;
	_tmp19_ = _data5_->dropdown;
	_tmp20_ = apps_store;
	_tmp21_ = self->priv->_content_type;
	gtk_drop_down_set_selected (_tmp19_, defaults_app_chooser_button_find_default_app_pos (self, _tmp20_, _tmp21_));
	_tmp22_ = _data5_->dropdown;
	g_signal_connect_data ((GObject*) _tmp22_, "notify::selected-item", (GCallback) __defaults_app_chooser_button___lambda23__g_object_notify, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_tmp23_ = apps_store;
	_tmp24_ = _data5_->dropdown;
	g_object_bind_property_with_closures ((GObject*) _tmp23_, "n-items", (GObject*) _tmp24_, "sensitive", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE, (GClosure*) ((__defaults_app_chooser_button___lambda25__gbinding_transform_func == NULL) ? NULL : g_cclosure_new ((GCallback) __defaults_app_chooser_button___lambda25__gbinding_transform_func, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp25_ = _data5_->dropdown;
	granite_bin_set_child ((GraniteBin*) self, (GtkWidget*) _tmp25_);
	_gtk_expression_unref0 (app_name_expr);
	_gtk_expression_unref0 (app_expr);
	_g_object_unref0 (apps_store);
	_g_object_unref0 (factory);
	block5_data_unref (_data5_);
	_data5_ = NULL;
	return obj;
}

static void
defaults_app_chooser_button_class_init (DefaultsAppChooserButtonClass * klass,
                                        gpointer klass_data)
{
	defaults_app_chooser_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DefaultsAppChooserButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_defaults_app_chooser_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_defaults_app_chooser_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = defaults_app_chooser_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = defaults_app_chooser_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY, defaults_app_chooser_button_properties[DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY] = g_param_spec_string ("content-type", "content-type", "content-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
defaults_app_chooser_button_instance_init (DefaultsAppChooserButton * self,
                                           gpointer klass)
{
	self->priv = defaults_app_chooser_button_get_instance_private (self);
}

static void
defaults_app_chooser_button_finalize (GObject * obj)
{
	DefaultsAppChooserButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEFAULTS_TYPE_APP_CHOOSER_BUTTON, DefaultsAppChooserButton);
	_g_free0 (self->priv->_content_type);
	G_OBJECT_CLASS (defaults_app_chooser_button_parent_class)->finalize (obj);
}

static GType
defaults_app_chooser_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DefaultsAppChooserButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) defaults_app_chooser_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DefaultsAppChooserButton), 0, (GInstanceInitFunc) defaults_app_chooser_button_instance_init, NULL };
	GType defaults_app_chooser_button_type_id;
	defaults_app_chooser_button_type_id = g_type_register_static (GRANITE_TYPE_BIN, "DefaultsAppChooserButton", &g_define_type_info, 0);
	DefaultsAppChooserButton_private_offset = g_type_add_instance_private (defaults_app_chooser_button_type_id, sizeof (DefaultsAppChooserButtonPrivate));
	return defaults_app_chooser_button_type_id;
}

GType
defaults_app_chooser_button_get_type (void)
{
	static volatile gsize defaults_app_chooser_button_type_id__once = 0;
	if (g_once_init_enter (&defaults_app_chooser_button_type_id__once)) {
		GType defaults_app_chooser_button_type_id;
		defaults_app_chooser_button_type_id = defaults_app_chooser_button_get_type_once ();
		g_once_init_leave (&defaults_app_chooser_button_type_id__once, defaults_app_chooser_button_type_id);
	}
	return defaults_app_chooser_button_type_id__once;
}

static void
_vala_defaults_app_chooser_button_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	DefaultsAppChooserButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEFAULTS_TYPE_APP_CHOOSER_BUTTON, DefaultsAppChooserButton);
	switch (property_id) {
		case DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY:
		g_value_set_string (value, defaults_app_chooser_button_get_content_type (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_defaults_app_chooser_button_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	DefaultsAppChooserButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEFAULTS_TYPE_APP_CHOOSER_BUTTON, DefaultsAppChooserButton);
	switch (property_id) {
		case DEFAULTS_APP_CHOOSER_BUTTON_CONTENT_TYPE_PROPERTY:
		defaults_app_chooser_button_set_content_type (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

