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

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include "gnome-games.h"
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>

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

#define GAMES_TYPE_MEDIA_MENU_BUTTON (games_media_menu_button_get_type ())
#define GAMES_MEDIA_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButton))
#define GAMES_MEDIA_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButtonClass))
#define GAMES_IS_MEDIA_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MEDIA_MENU_BUTTON))
#define GAMES_IS_MEDIA_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MEDIA_MENU_BUTTON))
#define GAMES_MEDIA_MENU_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButtonClass))

typedef struct _GamesMediaMenuButton GamesMediaMenuButton;
typedef struct _GamesMediaMenuButtonClass GamesMediaMenuButtonClass;
typedef struct _GamesMediaMenuButtonPrivate GamesMediaMenuButtonPrivate;
enum  {
	GAMES_MEDIA_MENU_BUTTON_0_PROPERTY,
	GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY,
	GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY,
	GAMES_MEDIA_MENU_BUTTON_NUM_PROPERTIES
};
static GParamSpec* games_media_menu_button_properties[GAMES_MEDIA_MENU_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block30Data Block30Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GAMES_TYPE_CHECKMARK_ITEM (games_checkmark_item_get_type ())
#define GAMES_CHECKMARK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_CHECKMARK_ITEM, GamesCheckmarkItem))
#define GAMES_CHECKMARK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_CHECKMARK_ITEM, GamesCheckmarkItemClass))
#define GAMES_IS_CHECKMARK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_CHECKMARK_ITEM))
#define GAMES_IS_CHECKMARK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_CHECKMARK_ITEM))
#define GAMES_CHECKMARK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_CHECKMARK_ITEM, GamesCheckmarkItemClass))

typedef struct _GamesCheckmarkItem GamesCheckmarkItem;
typedef struct _GamesCheckmarkItemClass GamesCheckmarkItemClass;

struct _GamesMediaMenuButton {
	GtkBin parent_instance;
	GamesMediaMenuButtonPrivate * priv;
};

struct _GamesMediaMenuButtonClass {
	GtkBinClass parent_class;
};

struct _GamesMediaMenuButtonPrivate {
	GtkImage* media_image;
	GtkPopover* popover;
	GtkListBox* list_box;
	gboolean _active;
	GamesMediaSet* _media_set;
	gulong media_set_changed_id;
};

struct _Block30Data {
	int _ref_count_;
	GamesMediaMenuButton* self;
	gint media_number;
};

static gint GamesMediaMenuButton_private_offset;
static gpointer games_media_menu_button_parent_class = NULL;

VALA_EXTERN GType games_media_menu_button_get_type (void) G_GNUC_CONST ;
static void games_media_menu_button_reset_media (GamesMediaMenuButton* self);
static void games_media_menu_button_remove_media (GamesMediaMenuButton* self);
static void games_media_menu_button_update_media (GamesMediaMenuButton* self);
VALA_EXTERN GamesMediaSet* games_media_menu_button_get_media_set (GamesMediaMenuButton* self);
static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
static void __lambda56_ (Block30Data* _data30_,
                  GamesMedia* media);
VALA_EXTERN GType games_checkmark_item_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesCheckmarkItem* games_checkmark_item_new (const gchar* label);
VALA_EXTERN GamesCheckmarkItem* games_checkmark_item_construct (GType object_type,
                                                    const gchar* label);
VALA_EXTERN void games_checkmark_item_set_checkmark_visible (GamesCheckmarkItem* self,
                                                 gboolean value);
static void ___lambda56__games_media_set_media_callback (GamesMedia* media,
                                                  gpointer self);
static void __lambda55_ (GamesMediaMenuButton* self,
                  GtkWidget* child);
static void ___lambda55__gtk_callback (GtkWidget* widget,
                                gpointer self);
static void games_media_menu_button_on_row_activated (GamesMediaMenuButton* self,
                                               GtkListBoxRow* activated_row);
static void _games_media_menu_button_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                           GtkListBoxRow* row,
                                                                           gpointer self);
VALA_EXTERN GamesMediaMenuButton* games_media_menu_button_new (void);
VALA_EXTERN GamesMediaMenuButton* games_media_menu_button_construct (GType object_type);
VALA_EXTERN gboolean games_media_menu_button_get_active (GamesMediaMenuButton* self);
VALA_EXTERN void games_media_menu_button_set_active (GamesMediaMenuButton* self,
                                         gboolean value);
VALA_EXTERN void games_media_menu_button_set_media_set (GamesMediaMenuButton* self,
                                            GamesMediaSet* value);
static void _games_media_menu_button_reset_media_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self);
static void games_media_menu_button_finalize (GObject * obj);
static GType games_media_menu_button_get_type_once (void);
static void _vala_games_media_menu_button_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_games_media_menu_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_media_menu_button_get_instance_private (GamesMediaMenuButton* self)
{
	return G_STRUCT_MEMBER_P (self, GamesMediaMenuButton_private_offset);
}

static void
games_media_menu_button_reset_media (GamesMediaMenuButton* self)
{
	gboolean _tmp0_ = FALSE;
	GamesMediaSet* _tmp1_;
	GamesMediaSet* _tmp2_;
	g_return_if_fail (self != NULL);
	games_media_menu_button_remove_media (self);
	games_media_menu_button_update_media (self);
	_tmp1_ = games_media_menu_button_get_media_set (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		GamesMediaSet* _tmp3_;
		GamesMediaSet* _tmp4_;
		_tmp3_ = games_media_menu_button_get_media_set (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = games_media_set_get_size (_tmp4_) > 1;
	} else {
		_tmp0_ = FALSE;
	}
	gtk_widget_set_visible ((GtkWidget*) self, _tmp0_);
}

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		GamesMediaMenuButton* self;
		self = _data30_->self;
		_g_object_unref0 (self);
		g_slice_free (Block30Data, _data30_);
	}
}

static void
__lambda56_ (Block30Data* _data30_,
             GamesMedia* media)
{
	GamesMediaMenuButton* self;
	gchar* media_name = NULL;
	GamesTitle* _tmp0_;
	GamesTitle* _tmp1_;
	GamesCheckmarkItem* checkmark_item = NULL;
	const gchar* _tmp11_;
	GamesCheckmarkItem* _tmp12_;
	gboolean media_has_uris = FALSE;
	gint _tmp13_ = 0;
	GamesUri** _tmp14_;
	GamesUri** _tmp15_;
	gint _tmp15__length1;
	gboolean _tmp16_;
	gboolean is_current_media = FALSE;
	GamesMediaSet* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	GtkListBox* _tmp20_;
	gint _tmp21_;
	GError* _inner_error0_ = NULL;
	self = _data30_->self;
	g_return_if_fail (media != NULL);
	_tmp0_ = games_media_get_title (media);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup_printf (_ ("Media %d"), _data30_->media_number);
		_g_free0 (media_name);
		media_name = _tmp2_;
	} else {
		{
			gchar* _tmp3_ = NULL;
			GamesTitle* _tmp4_;
			GamesTitle* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp4_ = games_media_get_title (media);
			_tmp5_ = _tmp4_;
			_tmp6_ = games_title_get_title (_tmp5_, &_inner_error0_);
			_tmp3_ = _tmp6_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp7_ = _tmp3_;
			_tmp3_ = NULL;
			_g_free0 (media_name);
			media_name = _tmp7_;
			_g_free0 (_tmp3_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp8_;
			const gchar* _tmp9_;
			gchar* _tmp10_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp8_ = e;
			_tmp9_ = _tmp8_->message;
			g_warning ("media-menu-button.vala:58: %s", _tmp9_);
			_tmp10_ = g_strdup ("");
			_g_free0 (media_name);
			media_name = _tmp10_;
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (media_name);
			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;
		}
	}
	_tmp11_ = media_name;
	_tmp12_ = games_checkmark_item_new (_tmp11_);
	g_object_ref_sink (_tmp12_);
	checkmark_item = _tmp12_;
	_tmp14_ = games_media_get_uris (media, &_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp15__length1 = _tmp13_;
	_tmp16_ = _tmp13_ != 0;
	_tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) games_uri_unref), NULL);
	media_has_uris = _tmp16_;
	gtk_widget_set_sensitive ((GtkWidget*) checkmark_item, media_has_uris);
	_tmp17_ = self->priv->_media_set;
	_tmp18_ = games_media_set_get_selected_media_number (_tmp17_);
	_tmp19_ = _tmp18_;
	is_current_media = _tmp19_ == _data30_->media_number;
	games_checkmark_item_set_checkmark_visible (checkmark_item, is_current_media);
	_tmp20_ = self->priv->list_box;
	gtk_container_add ((GtkContainer*) _tmp20_, (GtkWidget*) checkmark_item);
	_tmp21_ = _data30_->media_number;
	_data30_->media_number = _tmp21_ + 1;
	_g_object_unref0 (checkmark_item);
	_g_free0 (media_name);
}

static void
___lambda56__games_media_set_media_callback (GamesMedia* media,
                                             gpointer self)
{
	__lambda56_ (self, media);
}

static void
games_media_menu_button_update_media (GamesMediaMenuButton* self)
{
	Block30Data* _data30_;
	GamesMediaSet* _tmp0_;
	GamesMediaSet* _tmp1_;
	g_return_if_fail (self != NULL);
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	_data30_->self = g_object_ref (self);
	_data30_->media_number = 0;
	_tmp0_ = self->priv->_media_set;
	if (_tmp0_ == NULL) {
		block30_data_unref (_data30_);
		_data30_ = NULL;
		return;
	}
	_tmp1_ = self->priv->_media_set;
	games_media_set_foreach_media (_tmp1_, ___lambda56__games_media_set_media_callback, _data30_);
	block30_data_unref (_data30_);
	_data30_ = NULL;
}

static void
__lambda55_ (GamesMediaMenuButton* self,
             GtkWidget* child)
{
	g_return_if_fail (child != NULL);
	gtk_widget_destroy (child);
}

static void
___lambda55__gtk_callback (GtkWidget* widget,
                           gpointer self)
{
	__lambda55_ ((GamesMediaMenuButton*) self, widget);
}

static void
games_media_menu_button_remove_media (GamesMediaMenuButton* self)
{
	GtkListBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list_box;
	gtk_container_foreach ((GtkContainer*) _tmp0_, ___lambda55__gtk_callback, self);
}

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

static void
games_media_menu_button_on_row_activated (GamesMediaMenuButton* self,
                                          GtkListBoxRow* activated_row)
{
	gint media_number = 0;
	GamesMediaSet* _tmp0_;
	gint i = 0;
	GtkListBoxRow* row = NULL;
	GtkListBox* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	GtkPopover* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (activated_row != NULL);
	media_number = gtk_list_box_row_get_index (activated_row);
	_tmp0_ = self->priv->_media_set;
	games_media_set_set_selected_media_number (_tmp0_, media_number);
	i = 0;
	_tmp1_ = self->priv->list_box;
	_tmp2_ = gtk_list_box_get_row_at_index (_tmp1_, i);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	row = _tmp3_;
	while (TRUE) {
		GtkListBoxRow* _tmp4_;
		GamesCheckmarkItem* checkmark_item = NULL;
		GtkListBoxRow* _tmp5_;
		GamesCheckmarkItem* _tmp6_;
		GamesCheckmarkItem* _tmp7_;
		GtkListBox* _tmp8_;
		gint _tmp9_;
		GtkListBoxRow* _tmp10_;
		GtkListBoxRow* _tmp11_;
		_tmp4_ = row;
		if (!(_tmp4_ != NULL)) {
			break;
		}
		_tmp5_ = row;
		_tmp6_ = _g_object_ref0 (GAMES_IS_CHECKMARK_ITEM (_tmp5_) ? ((GamesCheckmarkItem*) _tmp5_) : NULL);
		checkmark_item = _tmp6_;
		_tmp7_ = checkmark_item;
		games_checkmark_item_set_checkmark_visible (_tmp7_, i == media_number);
		_tmp8_ = self->priv->list_box;
		i = i + 1;
		_tmp9_ = i;
		_tmp10_ = gtk_list_box_get_row_at_index (_tmp8_, _tmp9_);
		_tmp11_ = _g_object_ref0 (_tmp10_);
		_g_object_unref0 (row);
		row = _tmp11_;
		_g_object_unref0 (checkmark_item);
	}
	_tmp12_ = self->priv->popover;
	gtk_popover_popdown (_tmp12_);
	_g_object_unref0 (row);
}

static void
_games_media_menu_button_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                      GtkListBoxRow* row,
                                                                      gpointer self)
{
	games_media_menu_button_on_row_activated ((GamesMediaMenuButton*) self, row);
}

GamesMediaMenuButton*
games_media_menu_button_construct (GType object_type)
{
	GamesMediaMenuButton * self = NULL;
	self = (GamesMediaMenuButton*) g_object_new (object_type, NULL);
	return self;
}

GamesMediaMenuButton*
games_media_menu_button_new (void)
{
	return games_media_menu_button_construct (GAMES_TYPE_MEDIA_MENU_BUTTON);
}

gboolean
games_media_menu_button_get_active (GamesMediaMenuButton* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_active;
	return result;
}

void
games_media_menu_button_set_active (GamesMediaMenuButton* self,
                                    gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_media_menu_button_get_active (self);
	if (old_value != value) {
		self->priv->_active = value;
		g_object_notify_by_pspec ((GObject *) self, games_media_menu_button_properties[GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY]);
	}
}

GamesMediaSet*
games_media_menu_button_get_media_set (GamesMediaMenuButton* self)
{
	GamesMediaSet* result;
	GamesMediaSet* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_media_set;
	result = _tmp0_;
	return result;
}

static void
_games_media_menu_button_reset_media_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self)
{
	games_media_menu_button_reset_media ((GamesMediaMenuButton*) self);
}

void
games_media_menu_button_set_media_set (GamesMediaMenuButton* self,
                                       GamesMediaSet* value)
{
	GamesMediaSet* _tmp1_;
	GamesMediaSet* _tmp2_;
	g_return_if_fail (self != NULL);
	if (self->priv->media_set_changed_id != ((gulong) 0)) {
		GamesMediaSet* _tmp0_;
		_tmp0_ = self->priv->_media_set;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->media_set_changed_id);
		self->priv->media_set_changed_id = (gulong) 0;
	}
	_tmp1_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_media_set);
	self->priv->_media_set = _tmp1_;
	_tmp2_ = self->priv->_media_set;
	if (_tmp2_ != NULL) {
		GamesMediaSet* _tmp3_;
		gulong _tmp4_;
		GtkImage* _tmp5_;
		GamesMediaSet* _tmp6_;
		GamesMediaSet* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp3_ = self->priv->_media_set;
		_tmp4_ = g_signal_connect_object ((GObject*) _tmp3_, "notify::selected-media-number", (GCallback) _games_media_menu_button_reset_media_g_object_notify, self, 0);
		self->priv->media_set_changed_id = _tmp4_;
		_tmp5_ = self->priv->media_image;
		_tmp6_ = games_media_menu_button_get_media_set (self);
		_tmp7_ = _tmp6_;
		_tmp8_ = games_media_set_get_icon_name (_tmp7_);
		_tmp9_ = _tmp8_;
		gtk_image_set_from_icon_name (_tmp5_, _tmp9_, (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	}
	games_media_menu_button_reset_media (self);
	g_object_notify_by_pspec ((GObject *) self, games_media_menu_button_properties[GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY]);
}

static void
games_media_menu_button_class_init (GamesMediaMenuButtonClass * klass,
                                    gpointer klass_data)
{
	games_media_menu_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesMediaMenuButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_media_menu_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_media_menu_button_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_media_menu_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY, games_media_menu_button_properties[GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY, games_media_menu_button_properties[GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY] = g_param_spec_object ("media-set", "media-set", "media-set", GAMES_TYPE_MEDIA_SET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/media-menu-button.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "media_image", FALSE, GamesMediaMenuButton_private_offset + G_STRUCT_OFFSET (GamesMediaMenuButtonPrivate, media_image));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "popover", FALSE, GamesMediaMenuButton_private_offset + G_STRUCT_OFFSET (GamesMediaMenuButtonPrivate, popover));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_box", FALSE, GamesMediaMenuButton_private_offset + G_STRUCT_OFFSET (GamesMediaMenuButtonPrivate, list_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_row_activated", G_CALLBACK(_games_media_menu_button_on_row_activated_gtk_list_box_row_activated));
}

static void
games_media_menu_button_instance_init (GamesMediaMenuButton * self,
                                       gpointer klass)
{
	self->priv = games_media_menu_button_get_instance_private (self);
	self->priv->media_set_changed_id = (gulong) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_media_menu_button_finalize (GObject * obj)
{
	GamesMediaMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButton);
	_g_object_unref0 (self->priv->_media_set);
	G_OBJECT_CLASS (games_media_menu_button_parent_class)->finalize (obj);
}

static GType
games_media_menu_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesMediaMenuButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_media_menu_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesMediaMenuButton), 0, (GInstanceInitFunc) games_media_menu_button_instance_init, NULL };
	GType games_media_menu_button_type_id;
	games_media_menu_button_type_id = g_type_register_static (gtk_bin_get_type (), "GamesMediaMenuButton", &g_define_type_info, 0);
	GamesMediaMenuButton_private_offset = g_type_add_instance_private (games_media_menu_button_type_id, sizeof (GamesMediaMenuButtonPrivate));
	return games_media_menu_button_type_id;
}

GType
games_media_menu_button_get_type (void)
{
	static volatile gsize games_media_menu_button_type_id__once = 0;
	if (g_once_init_enter (&games_media_menu_button_type_id__once)) {
		GType games_media_menu_button_type_id;
		games_media_menu_button_type_id = games_media_menu_button_get_type_once ();
		g_once_init_leave (&games_media_menu_button_type_id__once, games_media_menu_button_type_id);
	}
	return games_media_menu_button_type_id__once;
}

static void
_vala_games_media_menu_button_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	GamesMediaMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButton);
	switch (property_id) {
		case GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY:
		g_value_set_boolean (value, games_media_menu_button_get_active (self));
		break;
		case GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY:
		g_value_set_object (value, games_media_menu_button_get_media_set (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_media_menu_button_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	GamesMediaMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButton);
	switch (property_id) {
		case GAMES_MEDIA_MENU_BUTTON_ACTIVE_PROPERTY:
		games_media_menu_button_set_active (self, g_value_get_boolean (value));
		break;
		case GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY:
		games_media_menu_button_set_media_set (self, g_value_get_object (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 inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

