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

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

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


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

#define GAMES_TYPE_MEDIA_SET (games_media_set_get_type ())
#define GAMES_MEDIA_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MEDIA_SET, GamesMediaSet))
#define GAMES_MEDIA_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MEDIA_SET, GamesMediaSetClass))
#define GAMES_IS_MEDIA_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MEDIA_SET))
#define GAMES_IS_MEDIA_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MEDIA_SET))
#define GAMES_MEDIA_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MEDIA_SET, GamesMediaSetClass))

typedef struct _GamesMediaSet GamesMediaSet;
typedef struct _GamesMediaSetClass GamesMediaSetClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

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

struct _GamesMediaMenuButtonClass {
	GtkMenuButtonClass parent_class;
};

struct _GamesMediaMenuButtonPrivate {
	GamesMediaSet* _media_set;
	GtkImage* media_image;
};


static gpointer games_media_menu_button_parent_class = NULL;

GType games_media_menu_button_get_type (void) G_GNUC_CONST;
GType games_media_set_get_type (void) G_GNUC_CONST;
#define GAMES_MEDIA_MENU_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_MEDIA_MENU_BUTTON, GamesMediaMenuButtonPrivate))
enum  {
	GAMES_MEDIA_MENU_BUTTON_0_PROPERTY,
	GAMES_MEDIA_MENU_BUTTON_MEDIA_SET_PROPERTY
};
static void games_media_menu_button_on_media_set_changed (GamesMediaMenuButton* self);
GamesMediaSet* games_media_menu_button_get_media_set (GamesMediaMenuButton* self);
gint games_media_set_get_size (GamesMediaSet* self);
GIcon* games_media_set_get_icon (GamesMediaSet* self);
static void _games_media_menu_button_on_media_set_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
GamesMediaMenuButton* games_media_menu_button_new (void);
GamesMediaMenuButton* games_media_menu_button_construct (GType object_type);
void games_media_menu_button_set_media_set (GamesMediaMenuButton* self, GamesMediaSet* value);
static void games_media_menu_button_finalize (GObject * obj);
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 games_media_menu_button_on_media_set_changed (GamesMediaMenuButton* self) {
	gboolean _tmp0_ = FALSE;
	GamesMediaSet* _tmp1_;
	GtkImage* _tmp4_;
	GamesMediaSet* _tmp5_;
	GIcon* _tmp6_;
	GIcon* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_media_set;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GamesMediaSet* _tmp2_;
		gint _tmp3_;
		_tmp2_ = self->priv->_media_set;
		_tmp3_ = games_media_set_get_size (_tmp2_);
		_tmp0_ = _tmp3_ < 2;
	}
	if (_tmp0_) {
		gtk_widget_hide ((GtkWidget*) self);
		return;
	}
	_tmp4_ = self->priv->media_image;
	_tmp5_ = self->priv->_media_set;
	_tmp6_ = games_media_set_get_icon (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_image_set_from_gicon (_tmp4_, _tmp7_, GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_widget_show ((GtkWidget*) self);
}


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


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


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 gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void games_media_menu_button_set_media_set (GamesMediaMenuButton* self, GamesMediaSet* value) {
	g_return_if_fail (self != NULL);
	if (games_media_menu_button_get_media_set (self) != value) {
		GamesMediaSet* _tmp0_;
		GamesMediaSet* _tmp1_;
		_tmp0_ = value;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (self->priv->_media_set);
		self->priv->_media_set = _tmp1_;
		g_object_notify ((GObject *) self, "media-set");
	}
}


static void games_media_menu_button_class_init (GamesMediaMenuButtonClass * klass) {
	gint GamesMediaMenuButton_private_offset;
	games_media_menu_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesMediaMenuButtonPrivate));
	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_MEDIA_SET_PROPERTY, g_param_spec_object ("media-set", "media-set", "media-set", GAMES_TYPE_MEDIA_SET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	GamesMediaMenuButton_private_offset = g_type_class_get_instance_private_offset (klass);
	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_callback_full (GTK_WIDGET_CLASS (klass), "on_media_set_changed", G_CALLBACK(_games_media_menu_button_on_media_set_changed_g_object_notify));
}


static void games_media_menu_button_instance_init (GamesMediaMenuButton * self) {
	self->priv = GAMES_MEDIA_MENU_BUTTON_GET_PRIVATE (self);
	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_unref0 (self->priv->media_image);
	G_OBJECT_CLASS (games_media_menu_button_parent_class)->finalize (obj);
}


GType games_media_menu_button_get_type (void) {
	static volatile gsize games_media_menu_button_type_id__volatile = 0;
	if (g_once_init_enter (&games_media_menu_button_type_id__volatile)) {
		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_menu_button_get_type (), "GamesMediaMenuButton", &g_define_type_info, 0);
		g_once_init_leave (&games_media_menu_button_type_id__volatile, games_media_menu_button_type_id);
	}
	return games_media_menu_button_type_id__volatile;
}


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



