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

/*
 * This file is part of budgie-desktop
 * 
 * Copyright (C) 2015-2016 Ikey Doherty <ikey@solus-project.com>
 * 
 * This program 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 2 of the License, or
 * (at your option) any later version.
 */

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


#define TYPE_MPRIS_WIDGET (mpris_widget_get_type ())
#define MPRIS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_WIDGET, MprisWidget))
#define MPRIS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_WIDGET, MprisWidgetClass))
#define IS_MPRIS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_WIDGET))
#define IS_MPRIS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_WIDGET))
#define MPRIS_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_WIDGET, MprisWidgetClass))

typedef struct _MprisWidget MprisWidget;
typedef struct _MprisWidgetClass MprisWidgetClass;
typedef struct _MprisWidgetPrivate MprisWidgetPrivate;

#define TYPE_DBUS_IMPL (dbus_impl_get_type ())
#define DBUS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DBUS_IMPL, DBusImpl))
#define IS_DBUS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DBUS_IMPL))
#define DBUS_IMPL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_DBUS_IMPL, DBusImplIface))

typedef struct _DBusImpl DBusImpl;
typedef struct _DBusImplIface DBusImplIface;

#define TYPE_DBUS_IMPL_PROXY (dbus_impl_proxy_get_type ())

#define TYPE_CLIENT_WIDGET (client_widget_get_type ())
#define CLIENT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CLIENT_WIDGET, ClientWidget))
#define CLIENT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CLIENT_WIDGET, ClientWidgetClass))
#define IS_CLIENT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CLIENT_WIDGET))
#define IS_CLIENT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CLIENT_WIDGET))
#define CLIENT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CLIENT_WIDGET, ClientWidgetClass))

typedef struct _ClientWidget ClientWidget;
typedef struct _ClientWidgetClass ClientWidgetClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

#define TYPE_MPRIS_CLIENT (mpris_client_get_type ())
#define MPRIS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CLIENT, MprisClient))
#define MPRIS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CLIENT, MprisClientClass))
#define IS_MPRIS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CLIENT))
#define IS_MPRIS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CLIENT))
#define MPRIS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CLIENT, MprisClientClass))

typedef struct _MprisClient MprisClient;
typedef struct _MprisClientClass MprisClientClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block6Data Block6Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _MprisWidgetSetupDbusData MprisWidgetSetupDbusData;

struct _MprisWidget {
	GtkBox parent_instance;
	MprisWidgetPrivate * priv;
};

struct _MprisWidgetClass {
	GtkBoxClass parent_class;
};

struct _DBusImplIface {
	GTypeInterface parent_iface;
	void (*list_names) (DBusImpl* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gchar** (*list_names_finish) (DBusImpl* self, GAsyncResult* _res_, int* result_length1, GError** error);
};

struct _MprisWidgetPrivate {
	DBusImpl* impl;
	GHashTable* ifaces;
	gint our_width;
};

struct _Block6Data {
	int _ref_count_;
	MprisWidget* self;
	gchar* n;
};

struct _MprisWidgetSetupDbusData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	MprisWidget* self;
	DBusImpl* _tmp0_;
	DBusImpl* _tmp1_;
	DBusImpl* _tmp2_;
	gchar** names;
	DBusImpl* _tmp3_;
	gint _tmp4_;
	gchar** _tmp5_;
	gint names_length1;
	gint _names_size_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** name_collection;
	gint name_collection_length1;
	gint _name_collection_size_;
	gint name_it;
	gchar* _tmp7_;
	gchar* name;
	const gchar* _tmp8_;
	gboolean _tmp9_;
	MprisClient* iface;
	const gchar* _tmp10_;
	MprisClient* _tmp11_;
	MprisClient* _tmp12_;
	const gchar* _tmp13_;
	MprisClient* _tmp14_;
	DBusImpl* _tmp15_;
	GError* e;
	GError* _tmp16_;
	const gchar* _tmp17_;
	GError * _inner_error_;
};


static gpointer mpris_widget_parent_class = NULL;

GType mpris_widget_get_type (void) G_GNUC_CONST;
GType dbus_impl_proxy_get_type (void) G_GNUC_CONST;
guint dbus_impl_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
GType dbus_impl_get_type (void) G_GNUC_CONST;
GType client_widget_get_type (void) G_GNUC_CONST;
#define MPRIS_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_WIDGET, MprisWidgetPrivate))
enum  {
	MPRIS_WIDGET_DUMMY_PROPERTY
};
MprisWidget* mpris_widget_new (void);
MprisWidget* mpris_widget_construct (GType object_type);
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
void mpris_widget_setup_dbus (MprisWidget* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris_widget_setup_dbus_finish (MprisWidget* self, GAsyncResult* _res_);
static void mpris_widget_on_size_allocate (MprisWidget* self);
static void _mpris_widget_on_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GtkAllocation* allocation, gpointer self);
GType mpris_client_get_type (void) G_GNUC_CONST;
static void mpris_widget_add_iface (MprisWidget* self, const gchar* name, MprisClient* iface);
ClientWidget* client_widget_new (MprisClient* client, gint width);
ClientWidget* client_widget_construct (GType object_type, MprisClient* client, gint width);
static void mpris_widget_destroy_iface (MprisWidget* self, const gchar* name);
static void mpris_widget_on_name_owner_changed (MprisWidget* self, const gchar* n, const gchar* o, const gchar* ne);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
void new_iface (const gchar* busname, GAsyncReadyCallback _callback_, gpointer _user_data_);
MprisClient* new_iface_finish (GAsyncResult* _res_);
static void ___lambda23_ (Block6Data* _data6_, GObject* o, GAsyncResult* r);
static void ____lambda23__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static gboolean ___lambda24_ (Block6Data* _data6_);
static gboolean ____lambda24__gsource_func (gpointer self);
static void mpris_widget_setup_dbus_data_free (gpointer _data);
static gboolean mpris_widget_setup_dbus_co (MprisWidgetSetupDbusData* _data_);
static void mpris_widget_setup_dbus_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void dbus_impl_list_names (DBusImpl* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
gchar** dbus_impl_list_names_finish (DBusImpl* self, GAsyncResult* _res_, int* result_length1, GError** error);
static void _mpris_widget_on_name_owner_changed_dbus_impl_name_owner_changed (DBusImpl* _sender, const gchar* name, const gchar* old_owner, const gchar* new_owner, gpointer self);
static void mpris_widget_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


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


static void _mpris_widget_on_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender, GtkAllocation* allocation, gpointer self) {
	mpris_widget_on_size_allocate ((MprisWidget*) self);
}


MprisWidget* mpris_widget_construct (GType object_type) {
	MprisWidget * self = NULL;
	GHashFunc _tmp0_ = NULL;
	GEqualFunc _tmp1_ = NULL;
	GHashTable* _tmp2_ = NULL;
	self = (MprisWidget*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->ifaces);
	self->priv->ifaces = _tmp2_;
	mpris_widget_setup_dbus (self, NULL, NULL);
	g_signal_connect_object ((GtkWidget*) self, "size-allocate", (GCallback) _mpris_widget_on_size_allocate_gtk_widget_size_allocate, self, 0);
	gtk_widget_show_all ((GtkWidget*) self);
	return self;
}


MprisWidget* mpris_widget_new (void) {
	return mpris_widget_construct (TYPE_MPRIS_WIDGET);
}


static void mpris_widget_on_size_allocate (MprisWidget* self) {
	gint w = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_widget_get_allocated_width ((GtkWidget*) self);
	w = _tmp0_;
	_tmp1_ = w;
	_tmp2_ = self->priv->our_width;
	if (_tmp1_ > _tmp2_) {
		gint _tmp3_ = 0;
		_tmp3_ = w;
		self->priv->our_width = _tmp3_;
	}
}


/**
     * Add an interface handler/widget to known list and UI
     *
     * @param name DBUS name (object path)
     * @param iface The constructed MprisClient instance
     */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void mpris_widget_add_iface (MprisWidget* self, const gchar* name, MprisClient* iface) {
	ClientWidget* widg = NULL;
	MprisClient* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	ClientWidget* _tmp2_ = NULL;
	GHashTable* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	ClientWidget* _tmp6_ = NULL;
	GtkWidget* _tmp7_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (iface != NULL);
	_tmp0_ = iface;
	_tmp1_ = self->priv->our_width;
	_tmp2_ = client_widget_new (_tmp0_, _tmp1_);
	g_object_ref_sink (_tmp2_);
	widg = _tmp2_;
	gtk_widget_show_all ((GtkWidget*) widg);
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) widg, FALSE, FALSE, (guint) 0);
	_tmp3_ = self->priv->ifaces;
	_tmp4_ = name;
	_tmp5_ = g_strdup (_tmp4_);
	_tmp6_ = _g_object_ref0 (widg);
	g_hash_table_insert (_tmp3_, _tmp5_, _tmp6_);
	gtk_widget_queue_draw ((GtkWidget*) self);
	_tmp7_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	gtk_widget_queue_draw (_tmp7_);
	_g_object_unref0 (widg);
}


/**
     * Destroy an interface handler and remove from UI
     *
     * @param name DBUS name to remove handler for
     */
static void mpris_widget_destroy_iface (MprisWidget* self, const gchar* name) {
	ClientWidget* widg = NULL;
	GHashTable* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gconstpointer _tmp2_ = NULL;
	ClientWidget* _tmp3_ = NULL;
	ClientWidget* _tmp4_ = NULL;
	GtkWidget* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->priv->ifaces;
	_tmp1_ = name;
	_tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
	_tmp3_ = _g_object_ref0 ((ClientWidget*) _tmp2_);
	widg = _tmp3_;
	_tmp4_ = widg;
	if (_tmp4_ != NULL) {
		ClientWidget* _tmp5_ = NULL;
		GHashTable* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		_tmp5_ = widg;
		gtk_container_remove ((GtkContainer*) self, (GtkWidget*) _tmp5_);
		_tmp6_ = self->priv->ifaces;
		_tmp7_ = name;
		g_hash_table_remove (_tmp6_, _tmp7_);
	}
	gtk_widget_queue_draw ((GtkWidget*) self);
	_tmp8_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	gtk_widget_queue_draw (_tmp8_);
	_g_object_unref0 (widg);
}


static Block6Data* block6_data_ref (Block6Data* _data6_) {
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}


static void block6_data_unref (void * _userdata_) {
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		MprisWidget* self;
		self = _data6_->self;
		_g_free0 (_data6_->n);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}


static void ___lambda23_ (Block6Data* _data6_, GObject* o, GAsyncResult* r) {
	MprisWidget* self;
	MprisClient* iface = NULL;
	GAsyncResult* _tmp0_ = NULL;
	MprisClient* _tmp1_ = NULL;
	MprisClient* _tmp2_ = NULL;
	self = _data6_->self;
	g_return_if_fail (r != NULL);
	_tmp0_ = r;
	_tmp1_ = new_iface_finish (_tmp0_);
	iface = _tmp1_;
	_tmp2_ = iface;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_ = NULL;
		MprisClient* _tmp4_ = NULL;
		_tmp3_ = _data6_->n;
		_tmp4_ = iface;
		mpris_widget_add_iface (self, _tmp3_, _tmp4_);
	}
	_g_object_unref0 (iface);
}


static void ____lambda23__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	___lambda23_ (self, source_object, res);
	block6_data_unref (self);
}


static gboolean ___lambda24_ (Block6Data* _data6_) {
	MprisWidget* self;
	gboolean result = FALSE;
	const gchar* _tmp0_ = NULL;
	self = _data6_->self;
	_tmp0_ = _data6_->n;
	mpris_widget_destroy_iface (self, _tmp0_);
	result = FALSE;
	return result;
}


static gboolean ____lambda24__gsource_func (gpointer self) {
	gboolean result;
	result = ___lambda24_ (self);
	return result;
}


static void mpris_widget_on_name_owner_changed (MprisWidget* self, const gchar* n, const gchar* o, const gchar* ne) {
	Block6Data* _data6_;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp4_ = NULL;
	g_return_if_fail (self != NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = g_object_ref (self);
	_tmp0_ = n;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (_data6_->n);
	_data6_->n = _tmp1_;
	_tmp2_ = _data6_->n;
	_tmp3_ = g_str_has_prefix (_tmp2_, "org.mpris.MediaPlayer2.");
	if (!_tmp3_) {
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return;
	}
	_tmp4_ = o;
	if (g_strcmp0 (_tmp4_, "") == 0) {
		const gchar* _tmp5_ = NULL;
		_tmp5_ = _data6_->n;
		new_iface (_tmp5_, ____lambda23__gasync_ready_callback, block6_data_ref (_data6_));
	} else {
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda24__gsource_func, block6_data_ref (_data6_), block6_data_unref);
	}
	block6_data_unref (_data6_);
	_data6_ = NULL;
}


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


void mpris_widget_setup_dbus (MprisWidget* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	MprisWidgetSetupDbusData* _data_;
	MprisWidget* _tmp0_ = NULL;
	_data_ = g_slice_new0 (MprisWidgetSetupDbusData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, mpris_widget_setup_dbus);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, mpris_widget_setup_dbus_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	mpris_widget_setup_dbus_co (_data_);
}


void mpris_widget_setup_dbus_finish (MprisWidget* self, GAsyncResult* _res_) {
	MprisWidgetSetupDbusData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


/**
     * Do basic dbus initialisation
     */
static void mpris_widget_setup_dbus_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	MprisWidgetSetupDbusData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	mpris_widget_setup_dbus_co (_data_);
}


static void _mpris_widget_on_name_owner_changed_dbus_impl_name_owner_changed (DBusImpl* _sender, const gchar* name, const gchar* old_owner, const gchar* new_owner, gpointer self) {
	mpris_widget_on_name_owner_changed ((MprisWidget*) self, name, old_owner, new_owner);
}


static gboolean mpris_widget_setup_dbus_co (MprisWidgetSetupDbusData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_state_ = 1;
		g_async_initable_new_async (TYPE_DBUS_IMPL_PROXY, 0, NULL, mpris_widget_setup_dbus_ready, _data_, "g-flags", 0, "g-name", "org.freedesktop.DBus", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/freedesktop/DBus", "g-interface-name", "org.freedesktop.DBus", "g-interface-info", g_type_get_qdata (TYPE_DBUS_IMPL, g_quark_from_static_string ("vala-dbus-interface-info")), NULL);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = g_async_initable_new_finish (_data_->_source_object_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp0_ = (DBusImpl*) _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch22_g_error;
		}
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->self->priv->impl);
		_data_->self->priv->impl = _data_->_tmp2_;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = _data_->self->priv->impl;
		_data_->_tmp4_ = 0;
		_data_->_state_ = 2;
		dbus_impl_list_names (_data_->_tmp3_, mpris_widget_setup_dbus_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp5_ = NULL;
		_data_->_tmp5_ = dbus_impl_list_names_finish (_data_->_tmp3_, _data_->_res_, &_data_->_tmp4_, &_data_->_inner_error_);
		_data_->names_length1 = 0;
		_data_->_names_size_ = 0;
		_data_->names = _data_->_tmp5_;
		_data_->names_length1 = _data_->_tmp4_;
		_data_->_names_size_ = _data_->names_length1;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_object_unref0 (_data_->_tmp0_);
			goto __catch22_g_error;
		}
		_data_->_tmp6_ = NULL;
		_data_->_tmp6__length1 = 0;
		_data_->_tmp6_ = _data_->names;
		_data_->_tmp6__length1 = _data_->names_length1;
		{
			_data_->name_collection_length1 = 0;
			_data_->_name_collection_size_ = 0;
			_data_->name_collection = _data_->_tmp6_;
			_data_->name_collection_length1 = _data_->_tmp6__length1;
			for (_data_->name_it = 0; _data_->name_it < _data_->_tmp6__length1; _data_->name_it = _data_->name_it + 1) {
				_data_->_tmp7_ = NULL;
				_data_->_tmp7_ = g_strdup (_data_->name_collection[_data_->name_it]);
				_data_->name = _data_->_tmp7_;
				{
					_data_->_tmp8_ = NULL;
					_data_->_tmp8_ = _data_->name;
					_data_->_tmp9_ = FALSE;
					_data_->_tmp9_ = g_str_has_prefix (_data_->_tmp8_, "org.mpris.MediaPlayer2.");
					if (_data_->_tmp9_) {
						_data_->_tmp10_ = NULL;
						_data_->_tmp10_ = _data_->name;
						_data_->_state_ = 3;
						new_iface (_data_->_tmp10_, mpris_widget_setup_dbus_ready, _data_);
						return FALSE;
						_state_3:
						_data_->_tmp11_ = NULL;
						_data_->_tmp11_ = new_iface_finish (_data_->_res_);
						_data_->iface = _data_->_tmp11_;
						_data_->_tmp12_ = NULL;
						_data_->_tmp12_ = _data_->iface;
						if (_data_->_tmp12_ != NULL) {
							_data_->_tmp13_ = NULL;
							_data_->_tmp13_ = _data_->name;
							_data_->_tmp14_ = NULL;
							_data_->_tmp14_ = _data_->iface;
							mpris_widget_add_iface (_data_->self, _data_->_tmp13_, _data_->_tmp14_);
						}
						_g_object_unref0 (_data_->iface);
					}
					_g_free0 (_data_->name);
				}
			}
		}
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = _data_->self->priv->impl;
		g_signal_connect_object (_data_->_tmp15_, "name-owner-changed", (GCallback) _mpris_widget_on_name_owner_changed_dbus_impl_name_owner_changed, _data_->self, 0);
		_data_->names = (_vala_array_free (_data_->names, _data_->names_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally22;
	__catch22_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp16_ = NULL;
		_data_->_tmp16_ = _data_->e;
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = _data_->_tmp16_->message;
		g_warning ("MprisWidget.vala:116: Failed to initialise dbus: %s", _data_->_tmp17_);
		_g_error_free0 (_data_->e);
	}
	__finally22:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void mpris_widget_class_init (MprisWidgetClass * klass) {
	mpris_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MprisWidgetPrivate));
	G_OBJECT_CLASS (klass)->finalize = mpris_widget_finalize;
}


static void mpris_widget_instance_init (MprisWidget * self) {
	self->priv = MPRIS_WIDGET_GET_PRIVATE (self);
	self->priv->our_width = 250;
}


static void mpris_widget_finalize (GObject* obj) {
	MprisWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MPRIS_WIDGET, MprisWidget);
	_g_object_unref0 (self->priv->impl);
	_g_hash_table_unref0 (self->priv->ifaces);
	G_OBJECT_CLASS (mpris_widget_parent_class)->finalize (obj);
}


GType mpris_widget_get_type (void) {
	static volatile gsize mpris_widget_type_id__volatile = 0;
	if (g_once_init_enter (&mpris_widget_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MprisWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mpris_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MprisWidget), 0, (GInstanceInitFunc) mpris_widget_instance_init, NULL };
		GType mpris_widget_type_id;
		mpris_widget_type_id = g_type_register_static (gtk_box_get_type (), "MprisWidget", &g_define_type_info, 0);
		g_once_init_leave (&mpris_widget_type_id__volatile, mpris_widget_type_id);
	}
	return mpris_widget_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



