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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "CbMedia.h"
#include <float.h>
#include <math.h>


#define TYPE_MULTI_MEDIA_WIDGET (multi_media_widget_get_type ())
#define MULTI_MEDIA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidget))
#define MULTI_MEDIA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidgetClass))
#define IS_MULTI_MEDIA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MULTI_MEDIA_WIDGET))
#define IS_MULTI_MEDIA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MULTI_MEDIA_WIDGET))
#define MULTI_MEDIA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidgetClass))

typedef struct _MultiMediaWidget MultiMediaWidget;
typedef struct _MultiMediaWidgetClass MultiMediaWidgetClass;
typedef struct _MultiMediaWidgetPrivate MultiMediaWidgetPrivate;

#define TYPE_MEDIA_BUTTON (media_button_get_type ())
#define MEDIA_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MEDIA_BUTTON, MediaButton))
#define MEDIA_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MEDIA_BUTTON, MediaButtonClass))
#define IS_MEDIA_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MEDIA_BUTTON))
#define IS_MEDIA_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MEDIA_BUTTON))
#define MEDIA_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MEDIA_BUTTON, MediaButtonClass))

typedef struct _MediaButton MediaButton;
typedef struct _MediaButtonClass MediaButtonClass;
enum  {
	MULTI_MEDIA_WIDGET_0_PROPERTY,
	MULTI_MEDIA_WIDGET_NUM_PROPERTIES
};
static GParamSpec* multi_media_widget_properties[MULTI_MEDIA_WIDGET_NUM_PROPERTIES];
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
typedef struct _MediaButtonPrivate MediaButtonPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	MULTI_MEDIA_WIDGET_MEDIA_CLICKED_SIGNAL,
	MULTI_MEDIA_WIDGET_MEDIA_INVALID_SIGNAL,
	MULTI_MEDIA_WIDGET_NUM_SIGNALS
};
static guint multi_media_widget_signals[MULTI_MEDIA_WIDGET_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _MultiMediaWidget {
	GtkBox parent_instance;
	MultiMediaWidgetPrivate * priv;
	gboolean restrict_height;
	GtkWindow* window;
};

struct _MultiMediaWidgetClass {
	GtkBoxClass parent_class;
};

struct _MultiMediaWidgetPrivate {
	MediaButton** media_buttons;
	gint media_buttons_length1;
	gint _media_buttons_size_;
	gint media_count;
	gboolean media_invalid_fired;
};

struct _MediaButton {
	GtkWidget parent_instance;
	MediaButtonPrivate * priv;
	GtkWindow* window;
};

struct _MediaButtonClass {
	GtkWidgetClass parent_class;
};


static gpointer multi_media_widget_parent_class = NULL;

GType multi_media_widget_get_type (void) G_GNUC_CONST;
GType media_button_get_type (void) G_GNUC_CONST;
#define MULTI_MEDIA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidgetPrivate))
#define MULTI_MEDIA_WIDGET_MAX_HEIGHT 180
void multi_media_widget_set_all_media (MultiMediaWidget* self, CbMedia** medias, int medias_length1);
static void multi_media_widget_remove_all (MultiMediaWidget* self);
void multi_media_widget_set_media (MultiMediaWidget* self, gint index, CbMedia* media);
static void __lambda30_ (MultiMediaWidget* self, GtkWidget* w);
static void ___lambda30__gfunc (gconstpointer data, gpointer self);
MediaButton* media_button_new (CbMedia* media, gboolean restrict_height);
MediaButton* media_button_construct (GType object_type, CbMedia* media, gboolean restrict_height);
void media_button_set_media (MediaButton* self, CbMedia* value);
static void multi_media_widget_media_loaded_cb (MultiMediaWidget* self, CbMedia* source);
static void _multi_media_widget_media_loaded_cb_cb_media_progress (CbMedia* _sender, gpointer self);
static void multi_media_widget_button_clicked_cb (MultiMediaWidget* self, MediaButton* source, gdouble px, gdouble py);
static void _multi_media_widget_button_clicked_cb_media_button_clicked (MediaButton* _sender, MediaButton* source, gdouble px, gdouble py, gpointer self);
CbMedia* media_button_get_media (MediaButton* self);
MultiMediaWidget* multi_media_widget_new (void);
MultiMediaWidget* multi_media_widget_construct (GType object_type);
static void g_cclosure_user_marshal_VOID__OBJECT_INT_DOUBLE_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static GObject * multi_media_widget_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void multi_media_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);


void multi_media_widget_set_all_media (MultiMediaWidget* self, CbMedia** medias, int medias_length1) {
	CbMedia** _tmp0_;
	gint _tmp0__length1;
	MediaButton** _tmp1_;
	CbMedia** _tmp2_;
	gint _tmp2__length1;
	g_return_if_fail (IS_MULTI_MEDIA_WIDGET (self));
	multi_media_widget_remove_all (self);
	_tmp0_ = medias;
	_tmp0__length1 = medias_length1;
	_tmp1_ = g_new0 (MediaButton*, _tmp0__length1 + 1);
	self->priv->media_buttons = (_vala_array_free (self->priv->media_buttons, self->priv->media_buttons_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->media_buttons = _tmp1_;
	self->priv->media_buttons_length1 = _tmp0__length1;
	self->priv->_media_buttons_size_ = self->priv->media_buttons_length1;
	_tmp2_ = medias;
	_tmp2__length1 = medias_length1;
	self->priv->media_count = _tmp2__length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				gint _tmp5_;
				CbMedia** _tmp6_;
				gint _tmp6__length1;
				CbMedia** _tmp7_;
				gint _tmp7__length1;
				gint _tmp8_;
				CbMedia* _tmp9_;
				gint _tmp10_;
				CbMedia** _tmp11_;
				gint _tmp11__length1;
				gint _tmp12_;
				CbMedia* _tmp13_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = i;
				_tmp6_ = medias;
				_tmp6__length1 = medias_length1;
				if (!(_tmp5_ < _tmp6__length1)) {
					break;
				}
				_tmp7_ = medias;
				_tmp7__length1 = medias_length1;
				_tmp8_ = i;
				_tmp9_ = _tmp7_[_tmp8_];
				_vala_assert (_tmp9_ != NULL, "medias[i] != null");
				_tmp10_ = i;
				_tmp11_ = medias;
				_tmp11__length1 = medias_length1;
				_tmp12_ = i;
				_tmp13_ = _tmp11_[_tmp12_];
				multi_media_widget_set_media (self, _tmp10_, _tmp13_);
			}
		}
	}
}


static void __lambda30_ (MultiMediaWidget* self, GtkWidget* w) {
	GtkWidget* _tmp0_;
	g_return_if_fail (GTK_IS_WIDGET (w));
	_tmp0_ = w;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), _tmp0_);
}


static void ___lambda30__gfunc (gconstpointer data, gpointer self) {
	__lambda30_ ((MultiMediaWidget*) self, (GtkWidget*) data);
}


static void multi_media_widget_remove_all (MultiMediaWidget* self) {
	GList* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (IS_MULTI_MEDIA_WIDGET (self));
	_tmp0_ = gtk_container_get_children (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer));
	_tmp1_ = _tmp0_;
	g_list_foreach (_tmp1_, ___lambda30__gfunc, self);
	_g_list_free0 (_tmp1_);
}


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


static void _multi_media_widget_media_loaded_cb_cb_media_progress (CbMedia* _sender, gpointer self) {
	multi_media_widget_media_loaded_cb ((MultiMediaWidget*) self, _sender);
}


static void _multi_media_widget_button_clicked_cb_media_button_clicked (MediaButton* _sender, MediaButton* source, gdouble px, gdouble py, gpointer self) {
	multi_media_widget_button_clicked_cb ((MultiMediaWidget*) self, source, px, py);
}


void multi_media_widget_set_media (MultiMediaWidget* self, gint index, CbMedia* media) {
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	CbMedia* _tmp3_;
	gboolean _tmp4_;
	MediaButton* button = NULL;
	gboolean _tmp7_;
	MediaButton* _tmp8_;
	MediaButton* _tmp9_;
	gint _tmp10_;
	MediaButton* _tmp11_;
	GtkWindow* _tmp12_;
	MediaButton** _tmp13_;
	gint _tmp13__length1;
	gint _tmp14_;
	MediaButton* _tmp15_;
	MediaButton* _tmp16_;
	MediaButton* _tmp17_;
	CbMedia* _tmp18_;
	gboolean _tmp19_;
	MediaButton* _tmp29_;
	MediaButton* _tmp30_;
	MediaButton* _tmp31_;
	g_return_if_fail (IS_MULTI_MEDIA_WIDGET (self));
	g_return_if_fail (CB_IS_MEDIA (media));
	_tmp0_ = index;
	_tmp1_ = self->priv->media_count;
	_vala_assert (_tmp0_ < _tmp1_, "index < media_count");
	_tmp3_ = media;
	_tmp4_ = _tmp3_->loaded;
	if (_tmp4_) {
		CbMedia* _tmp5_;
		gboolean _tmp6_;
		_tmp5_ = media;
		_tmp6_ = _tmp5_->invalid;
		_tmp2_ = _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		return;
	}
	_tmp7_ = self->restrict_height;
	_tmp8_ = media_button_new (NULL, _tmp7_);
	g_object_ref_sink (_tmp8_);
	button = _tmp8_;
	_tmp9_ = button;
	_tmp10_ = index;
	g_object_set_data_full (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, G_TYPE_OBJECT, GObject), "pos", (gpointer) ((gintptr) _tmp10_), NULL);
	_tmp11_ = button;
	_tmp12_ = self->window;
	_tmp11_->window = _tmp12_;
	_tmp13_ = self->priv->media_buttons;
	_tmp13__length1 = self->priv->media_buttons_length1;
	_tmp14_ = index;
	_tmp15_ = button;
	_tmp16_ = _g_object_ref0 (_tmp15_);
	_g_object_unref0 (_tmp13_[_tmp14_]);
	_tmp13_[_tmp14_] = _tmp16_;
	_tmp17_ = _tmp13_[_tmp14_];
	_tmp18_ = media;
	_tmp19_ = _tmp18_->loaded;
	if (_tmp19_) {
		MediaButton** _tmp20_;
		gint _tmp20__length1;
		gint _tmp21_;
		MediaButton* _tmp22_;
		CbMedia* _tmp23_;
		_tmp20_ = self->priv->media_buttons;
		_tmp20__length1 = self->priv->media_buttons_length1;
		_tmp21_ = index;
		_tmp22_ = _tmp20_[_tmp21_];
		_tmp23_ = media;
		media_button_set_media (_tmp22_, _tmp23_);
	} else {
		MediaButton** _tmp24_;
		gint _tmp24__length1;
		gint _tmp25_;
		MediaButton* _tmp26_;
		CbMedia* _tmp27_;
		CbMedia* _tmp28_;
		_tmp24_ = self->priv->media_buttons;
		_tmp24__length1 = self->priv->media_buttons_length1;
		_tmp25_ = index;
		_tmp26_ = _tmp24_[_tmp25_];
		_tmp27_ = media;
		media_button_set_media (_tmp26_, _tmp27_);
		_tmp28_ = media;
		g_signal_connect_object (_tmp28_, "progress", (GCallback) _multi_media_widget_media_loaded_cb_cb_media_progress, self, 0);
	}
	_tmp29_ = button;
	gtk_widget_set_visible (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_widget_get_type (), GtkWidget), TRUE);
	_tmp30_ = button;
	g_signal_connect_object (_tmp30_, "clicked", (GCallback) _multi_media_widget_button_clicked_cb_media_button_clicked, self, 0);
	_tmp31_ = button;
	gtk_box_pack_start (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 0);
	gtk_widget_queue_draw (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (button);
}


static void multi_media_widget_button_clicked_cb (MultiMediaWidget* self, MediaButton* source, gdouble px, gdouble py) {
	gboolean _tmp0_ = FALSE;
	MediaButton* _tmp1_;
	CbMedia* _tmp2_;
	CbMedia* _tmp3_;
	g_return_if_fail (IS_MULTI_MEDIA_WIDGET (self));
	g_return_if_fail (IS_MEDIA_BUTTON (source));
	_tmp1_ = source;
	_tmp2_ = media_button_get_media (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != NULL) {
		MediaButton* _tmp4_;
		CbMedia* _tmp5_;
		CbMedia* _tmp6_;
		gboolean _tmp7_;
		_tmp4_ = source;
		_tmp5_ = media_button_get_media (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _tmp6_->loaded;
		_tmp0_ = _tmp7_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint index = 0;
		MediaButton* _tmp8_;
		gconstpointer _tmp9_;
		MediaButton* _tmp10_;
		CbMedia* _tmp11_;
		CbMedia* _tmp12_;
		gint _tmp13_;
		gdouble _tmp14_;
		gdouble _tmp15_;
		_tmp8_ = source;
		_tmp9_ = g_object_get_data (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, G_TYPE_OBJECT, GObject), "pos");
		index = (gint) ((gintptr) _tmp9_);
		_tmp10_ = source;
		_tmp11_ = media_button_get_media (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = index;
		_tmp14_ = px;
		_tmp15_ = py;
		g_signal_emit (self, multi_media_widget_signals[MULTI_MEDIA_WIDGET_MEDIA_CLICKED_SIGNAL], 0, _tmp12_, _tmp13_, _tmp14_, _tmp15_);
	}
}


static void multi_media_widget_media_loaded_cb (MultiMediaWidget* self, CbMedia* source) {
	CbMedia* _tmp0_;
	gdouble _tmp1_;
	CbMedia* _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (IS_MULTI_MEDIA_WIDGET (self));
	g_return_if_fail (CB_IS_MEDIA (source));
	_tmp0_ = source;
	_tmp1_ = _tmp0_->percent_loaded;
	if (_tmp1_ < ((gdouble) 100)) {
		return;
	}
	_tmp2_ = source;
	_tmp3_ = _tmp2_->invalid;
	if (_tmp3_) {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp4_ = FALSE;
				_tmp4_ = TRUE;
				while (TRUE) {
					gint _tmp6_;
					gint _tmp7_;
					gboolean _tmp8_ = FALSE;
					MediaButton** _tmp9_;
					gint _tmp9__length1;
					gint _tmp10_;
					MediaButton* _tmp11_;
					if (!_tmp4_) {
						gint _tmp5_;
						_tmp5_ = i;
						i = _tmp5_ + 1;
					}
					_tmp4_ = FALSE;
					_tmp6_ = i;
					_tmp7_ = self->priv->media_count;
					if (!(_tmp6_ < _tmp7_)) {
						break;
					}
					_tmp9_ = self->priv->media_buttons;
					_tmp9__length1 = self->priv->media_buttons_length1;
					_tmp10_ = i;
					_tmp11_ = _tmp9_[_tmp10_];
					if (_tmp11_ != NULL) {
						MediaButton** _tmp12_;
						gint _tmp12__length1;
						gint _tmp13_;
						MediaButton* _tmp14_;
						CbMedia* _tmp15_;
						CbMedia* _tmp16_;
						CbMedia* _tmp17_;
						_tmp12_ = self->priv->media_buttons;
						_tmp12__length1 = self->priv->media_buttons_length1;
						_tmp13_ = i;
						_tmp14_ = _tmp12_[_tmp13_];
						_tmp15_ = media_button_get_media (_tmp14_);
						_tmp16_ = _tmp15_;
						_tmp17_ = source;
						_tmp8_ = _tmp16_ == _tmp17_;
					} else {
						_tmp8_ = FALSE;
					}
					if (_tmp8_) {
						MediaButton** _tmp18_;
						gint _tmp18__length1;
						gint _tmp19_;
						MediaButton* _tmp20_;
						MediaButton** _tmp21_;
						gint _tmp21__length1;
						gint _tmp22_;
						MediaButton* _tmp23_;
						gboolean _tmp24_;
						_tmp18_ = self->priv->media_buttons;
						_tmp18__length1 = self->priv->media_buttons_length1;
						_tmp19_ = i;
						_tmp20_ = _tmp18_[_tmp19_];
						gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget));
						_tmp21_ = self->priv->media_buttons;
						_tmp21__length1 = self->priv->media_buttons_length1;
						_tmp22_ = i;
						_g_object_unref0 (_tmp21_[_tmp22_]);
						_tmp21_[_tmp22_] = NULL;
						_tmp23_ = _tmp21_[_tmp22_];
						_tmp24_ = self->priv->media_invalid_fired;
						if (!_tmp24_) {
							g_signal_emit (self, multi_media_widget_signals[MULTI_MEDIA_WIDGET_MEDIA_INVALID_SIGNAL], 0);
							self->priv->media_invalid_fired = TRUE;
						}
						return;
					}
				}
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp25_ = FALSE;
			_tmp25_ = TRUE;
			while (TRUE) {
				gint _tmp27_;
				gint _tmp28_;
				gboolean _tmp29_ = FALSE;
				MediaButton** _tmp30_;
				gint _tmp30__length1;
				gint _tmp31_;
				MediaButton* _tmp32_;
				if (!_tmp25_) {
					gint _tmp26_;
					_tmp26_ = i;
					i = _tmp26_ + 1;
				}
				_tmp25_ = FALSE;
				_tmp27_ = i;
				_tmp28_ = self->priv->media_count;
				if (!(_tmp27_ < _tmp28_)) {
					break;
				}
				_tmp30_ = self->priv->media_buttons;
				_tmp30__length1 = self->priv->media_buttons_length1;
				_tmp31_ = i;
				_tmp32_ = _tmp30_[_tmp31_];
				if (_tmp32_ != NULL) {
					MediaButton** _tmp33_;
					gint _tmp33__length1;
					gint _tmp34_;
					MediaButton* _tmp35_;
					CbMedia* _tmp36_;
					CbMedia* _tmp37_;
					CbMedia* _tmp38_;
					_tmp33_ = self->priv->media_buttons;
					_tmp33__length1 = self->priv->media_buttons_length1;
					_tmp34_ = i;
					_tmp35_ = _tmp33_[_tmp34_];
					_tmp36_ = media_button_get_media (_tmp35_);
					_tmp37_ = _tmp36_;
					_tmp38_ = source;
					_tmp29_ = _tmp37_ == _tmp38_;
				} else {
					_tmp29_ = FALSE;
				}
				if (_tmp29_) {
					MediaButton** _tmp39_;
					gint _tmp39__length1;
					gint _tmp40_;
					MediaButton* _tmp41_;
					_tmp39_ = self->priv->media_buttons;
					_tmp39__length1 = self->priv->media_buttons_length1;
					_tmp40_ = i;
					_tmp41_ = _tmp39_[_tmp40_];
					gtk_widget_queue_draw (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, gtk_widget_get_type (), GtkWidget));
					break;
				}
			}
		}
	}
}


MultiMediaWidget* multi_media_widget_construct (GType object_type) {
	MultiMediaWidget * self = NULL;
	self = (MultiMediaWidget*) g_object_new (object_type, NULL);
	return self;
}


MultiMediaWidget* multi_media_widget_new (void) {
	return multi_media_widget_construct (TYPE_MULTI_MEDIA_WIDGET);
}


static void g_cclosure_user_marshal_VOID__OBJECT_INT_DOUBLE_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__OBJECT_INT_DOUBLE_DOUBLE) (gpointer data1, gpointer arg_1, gint arg_2, gdouble arg_3, gdouble arg_4, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_INT_DOUBLE_DOUBLE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_INT_DOUBLE_DOUBLE) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_int (param_values + 2), g_value_get_double (param_values + 3), g_value_get_double (param_values + 4), data2);
}


static GObject * multi_media_widget_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	MultiMediaWidget * self;
	parent_class = G_OBJECT_CLASS (multi_media_widget_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidget);
	gtk_orientable_set_orientation (G_TYPE_CHECK_INSTANCE_CAST (self, GTK_TYPE_ORIENTABLE, GtkOrientable), GTK_ORIENTATION_HORIZONTAL);
	gtk_box_set_homogeneous (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), TRUE);
	return obj;
}


static void multi_media_widget_class_init (MultiMediaWidgetClass * klass) {
	multi_media_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MultiMediaWidgetPrivate));
	G_OBJECT_CLASS (klass)->constructor = multi_media_widget_constructor;
	G_OBJECT_CLASS (klass)->finalize = multi_media_widget_finalize;
	multi_media_widget_signals[MULTI_MEDIA_WIDGET_MEDIA_CLICKED_SIGNAL] = g_signal_new ("media-clicked", TYPE_MULTI_MEDIA_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_INT_DOUBLE_DOUBLE, G_TYPE_NONE, 4, CB_TYPE_MEDIA, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
	multi_media_widget_signals[MULTI_MEDIA_WIDGET_MEDIA_INVALID_SIGNAL] = g_signal_new ("media-invalid", TYPE_MULTI_MEDIA_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void multi_media_widget_instance_init (MultiMediaWidget * self) {
	self->priv = MULTI_MEDIA_WIDGET_GET_PRIVATE (self);
	self->restrict_height = FALSE;
	self->priv->media_count = 0;
	self->priv->media_invalid_fired = FALSE;
}


static void multi_media_widget_finalize (GObject * obj) {
	MultiMediaWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MULTI_MEDIA_WIDGET, MultiMediaWidget);
	self->priv->media_buttons = (_vala_array_free (self->priv->media_buttons, self->priv->media_buttons_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (multi_media_widget_parent_class)->finalize (obj);
}


GType multi_media_widget_get_type (void) {
	static volatile gsize multi_media_widget_type_id__volatile = 0;
	if (g_once_init_enter (&multi_media_widget_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MultiMediaWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) multi_media_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MultiMediaWidget), 0, (GInstanceInitFunc) multi_media_widget_instance_init, NULL };
		GType multi_media_widget_type_id;
		multi_media_widget_type_id = g_type_register_static (gtk_box_get_type (), "MultiMediaWidget", &g_define_type_info, 0);
		g_once_init_leave (&multi_media_widget_type_id__volatile, multi_media_widget_type_id);
	}
	return multi_media_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);
}



