/* game-icon-view.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from game-icon-view.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>

#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_GAME_ICON_VIEW (games_game_icon_view_get_type ())
#define GAMES_GAME_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconView))
#define GAMES_GAME_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconViewClass))
#define GAMES_IS_GAME_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_ICON_VIEW))
#define GAMES_IS_GAME_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAME_ICON_VIEW))
#define GAMES_GAME_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconViewClass))

typedef struct _GamesGameIconView GamesGameIconView;
typedef struct _GamesGameIconViewClass GamesGameIconViewClass;
typedef struct _GamesGameIconViewPrivate GamesGameIconViewPrivate;

#define GAMES_TYPE_GAME_THUMBNAIL (games_game_thumbnail_get_type ())
#define GAMES_GAME_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_THUMBNAIL, GamesGameThumbnail))
#define GAMES_GAME_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAME_THUMBNAIL, GamesGameThumbnailClass))
#define GAMES_IS_GAME_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_THUMBNAIL))
#define GAMES_IS_GAME_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAME_THUMBNAIL))
#define GAMES_GAME_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAME_THUMBNAIL, GamesGameThumbnailClass))

typedef struct _GamesGameThumbnail GamesGameThumbnail;
typedef struct _GamesGameThumbnailClass GamesGameThumbnailClass;
enum  {
	GAMES_GAME_ICON_VIEW_0_PROPERTY,
	GAMES_GAME_ICON_VIEW_GAME_PROPERTY,
	GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY,
	GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY,
	GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY,
	GAMES_GAME_ICON_VIEW_NUM_PROPERTIES
};
static GParamSpec* games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesGameIconView {
	GtkFlowBoxChild parent_instance;
	GamesGameIconViewPrivate * priv;
};

struct _GamesGameIconViewClass {
	GtkFlowBoxChildClass parent_class;
};

struct _GamesGameIconViewPrivate {
	GamesGameThumbnail* thumbnail;
	GtkLabel* title;
	gulong game_replaced_id;
	GamesGame* _game;
	gboolean _checked;
	gboolean _is_selection_mode;
	gboolean _is_favorite;
};

static gint GamesGameIconView_private_offset;
static gpointer games_game_icon_view_parent_class = NULL;

VALA_EXTERN GType games_game_icon_view_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_game_thumbnail_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesGameIconView* games_game_icon_view_new (GamesGame* game);
VALA_EXTERN GamesGameIconView* games_game_icon_view_construct (GType object_type,
                                                   GamesGame* game);
static void games_game_icon_view_game_replaced (GamesGameIconView* self,
                                         GamesGame* new_game);
VALA_EXTERN void games_game_icon_view_set_game (GamesGameIconView* self,
                                    GamesGame* value);
VALA_EXTERN guint games_game_icon_view_hash (GamesGameIconView* key);
VALA_EXTERN GamesGame* games_game_icon_view_get_game (GamesGameIconView* self);
VALA_EXTERN gboolean games_game_icon_view_equal (GamesGameIconView* a,
                                     GamesGameIconView* b);
VALA_EXTERN void games_game_thumbnail_set_game (GamesGameThumbnail* self,
                                    GamesGame* value);
static void _games_game_icon_view_game_replaced_games_game_replaced (GamesGame* _sender,
                                                              GamesGame* new_game,
                                                              gpointer self);
VALA_EXTERN gboolean games_game_icon_view_get_checked (GamesGameIconView* self);
VALA_EXTERN void games_game_icon_view_set_checked (GamesGameIconView* self,
                                       gboolean value);
VALA_EXTERN gboolean games_game_icon_view_get_is_selection_mode (GamesGameIconView* self);
VALA_EXTERN void games_game_icon_view_set_is_selection_mode (GamesGameIconView* self,
                                                 gboolean value);
VALA_EXTERN gboolean games_game_icon_view_get_is_favorite (GamesGameIconView* self);
VALA_EXTERN void games_game_icon_view_set_is_favorite (GamesGameIconView* self,
                                           gboolean value);
static void games_game_icon_view_finalize (GObject * obj);
static GType games_game_icon_view_get_type_once (void);
static void _vala_games_game_icon_view_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_games_game_icon_view_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_game_icon_view_get_instance_private (GamesGameIconView* self)
{
	return G_STRUCT_MEMBER_P (self, GamesGameIconView_private_offset);
}

GamesGameIconView*
games_game_icon_view_construct (GType object_type,
                                GamesGame* game)
{
	GamesGameIconView * self = NULL;
	g_return_val_if_fail (game != NULL, NULL);
	self = (GamesGameIconView*) g_object_new (object_type, "game", game, NULL);
	return self;
}

GamesGameIconView*
games_game_icon_view_new (GamesGame* game)
{
	return games_game_icon_view_construct (GAMES_TYPE_GAME_ICON_VIEW, game);
}

static void
games_game_icon_view_game_replaced (GamesGameIconView* self,
                                    GamesGame* new_game)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_game != NULL);
	games_game_icon_view_set_game (self, new_game);
}

guint
games_game_icon_view_hash (GamesGameIconView* key)
{
	GamesGame* _tmp0_;
	GamesGame* _tmp1_;
	guint result;
	g_return_val_if_fail (key != NULL, 0U);
	_tmp0_ = games_game_icon_view_get_game (key);
	_tmp1_ = _tmp0_;
	result = games_game_hash (_tmp1_);
	return result;
}

gboolean
games_game_icon_view_equal (GamesGameIconView* a,
                            GamesGameIconView* b)
{
	GamesGame* _tmp0_;
	GamesGame* _tmp1_;
	GamesGame* _tmp2_;
	GamesGame* _tmp3_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = games_game_icon_view_get_game (a);
	_tmp1_ = _tmp0_;
	_tmp2_ = games_game_icon_view_get_game (b);
	_tmp3_ = _tmp2_;
	result = games_game_equal (_tmp1_, _tmp3_);
	return result;
}

GamesGame*
games_game_icon_view_get_game (GamesGameIconView* self)
{
	GamesGame* result;
	GamesGame* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_game;
	result = _tmp0_;
	return result;
}

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

static void
_games_game_icon_view_game_replaced_games_game_replaced (GamesGame* _sender,
                                                         GamesGame* new_game,
                                                         gpointer self)
{
	games_game_icon_view_game_replaced ((GamesGameIconView*) self, new_game);
}

void
games_game_icon_view_set_game (GamesGameIconView* self,
                               GamesGame* value)
{
	GamesGame* _tmp0_;
	GamesGame* _tmp1_;
	GamesGame* _tmp4_;
	GamesGameThumbnail* _tmp5_;
	GamesGame* _tmp6_;
	GamesGame* _tmp7_;
	GtkLabel* _tmp8_;
	GamesGame* _tmp9_;
	GamesGame* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	GamesGame* _tmp13_;
	GamesGame* _tmp14_;
	GamesGame* _tmp15_;
	GamesGame* _tmp16_;
	gulong _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = games_game_icon_view_get_game (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == value) {
		return;
	}
	if (self->priv->game_replaced_id > ((gulong) 0)) {
		GamesGame* _tmp2_;
		GamesGame* _tmp3_;
		_tmp2_ = games_game_icon_view_get_game (self);
		_tmp3_ = _tmp2_;
		g_signal_handler_disconnect ((GObject*) _tmp3_, self->priv->game_replaced_id);
	}
	_tmp4_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_game);
	self->priv->_game = _tmp4_;
	_tmp5_ = self->priv->thumbnail;
	_tmp6_ = games_game_icon_view_get_game (self);
	_tmp7_ = _tmp6_;
	games_game_thumbnail_set_game (_tmp5_, _tmp7_);
	_tmp8_ = self->priv->title;
	_tmp9_ = games_game_icon_view_get_game (self);
	_tmp10_ = _tmp9_;
	_tmp11_ = games_game_get_name (_tmp10_);
	_tmp12_ = _tmp11_;
	gtk_label_set_label (_tmp8_, _tmp12_);
	_tmp13_ = games_game_icon_view_get_game (self);
	_tmp14_ = _tmp13_;
	g_object_bind_property_with_closures ((GObject*) _tmp14_, "is-favorite", (GObject*) self, "is-favorite", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp15_ = games_game_icon_view_get_game (self);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_signal_connect_object (_tmp16_, "replaced", (GCallback) _games_game_icon_view_game_replaced_games_game_replaced, self, 0);
	self->priv->game_replaced_id = _tmp17_;
	g_object_notify_by_pspec ((GObject *) self, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_GAME_PROPERTY]);
}

gboolean
games_game_icon_view_get_checked (GamesGameIconView* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_checked;
	return result;
}

void
games_game_icon_view_set_checked (GamesGameIconView* self,
                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_game_icon_view_get_checked (self);
	if (old_value != value) {
		self->priv->_checked = value;
		g_object_notify_by_pspec ((GObject *) self, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY]);
	}
}

gboolean
games_game_icon_view_get_is_selection_mode (GamesGameIconView* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_selection_mode;
	return result;
}

void
games_game_icon_view_set_is_selection_mode (GamesGameIconView* self,
                                            gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_game_icon_view_get_is_selection_mode (self);
	if (old_value != value) {
		self->priv->_is_selection_mode = value;
		g_object_notify_by_pspec ((GObject *) self, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY]);
	}
}

gboolean
games_game_icon_view_get_is_favorite (GamesGameIconView* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_favorite;
	return result;
}

void
games_game_icon_view_set_is_favorite (GamesGameIconView* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_game_icon_view_get_is_favorite (self);
	if (old_value != value) {
		self->priv->_is_favorite = value;
		g_object_notify_by_pspec ((GObject *) self, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY]);
	}
}

static void
games_game_icon_view_class_init (GamesGameIconViewClass * klass,
                                 gpointer klass_data)
{
	games_game_icon_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesGameIconView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_game_icon_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_game_icon_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_game_icon_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAME_ICON_VIEW_GAME_PROPERTY, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_GAME_PROPERTY] = g_param_spec_object ("game", "game", "game", GAMES_TYPE_GAME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY] = g_param_spec_boolean ("checked", "checked", "checked", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY] = g_param_spec_boolean ("is-selection-mode", "is-selection-mode", "is-selection-mode", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY, games_game_icon_view_properties[GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY] = g_param_spec_boolean ("is-favorite", "is-favorite", "is-favorite", FALSE, 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/game-icon-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "thumbnail", FALSE, GamesGameIconView_private_offset + G_STRUCT_OFFSET (GamesGameIconViewPrivate, thumbnail));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title", FALSE, GamesGameIconView_private_offset + G_STRUCT_OFFSET (GamesGameIconViewPrivate, title));
}

static void
games_game_icon_view_instance_init (GamesGameIconView * self,
                                    gpointer klass)
{
	self->priv = games_game_icon_view_get_instance_private (self);
	g_type_ensure (GAMES_TYPE_GAME_THUMBNAIL);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_game_icon_view_finalize (GObject * obj)
{
	GamesGameIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconView);
	_g_object_unref0 (self->priv->_game);
	G_OBJECT_CLASS (games_game_icon_view_parent_class)->finalize (obj);
}

static GType
games_game_icon_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesGameIconViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_game_icon_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGameIconView), 0, (GInstanceInitFunc) games_game_icon_view_instance_init, NULL };
	GType games_game_icon_view_type_id;
	games_game_icon_view_type_id = g_type_register_static (gtk_flow_box_child_get_type (), "GamesGameIconView", &g_define_type_info, 0);
	GamesGameIconView_private_offset = g_type_add_instance_private (games_game_icon_view_type_id, sizeof (GamesGameIconViewPrivate));
	return games_game_icon_view_type_id;
}

GType
games_game_icon_view_get_type (void)
{
	static volatile gsize games_game_icon_view_type_id__once = 0;
	if (g_once_init_enter (&games_game_icon_view_type_id__once)) {
		GType games_game_icon_view_type_id;
		games_game_icon_view_type_id = games_game_icon_view_get_type_once ();
		g_once_init_leave (&games_game_icon_view_type_id__once, games_game_icon_view_type_id);
	}
	return games_game_icon_view_type_id__once;
}

static void
_vala_games_game_icon_view_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GamesGameIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconView);
	switch (property_id) {
		case GAMES_GAME_ICON_VIEW_GAME_PROPERTY:
		g_value_set_object (value, games_game_icon_view_get_game (self));
		break;
		case GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY:
		g_value_set_boolean (value, games_game_icon_view_get_checked (self));
		break;
		case GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY:
		g_value_set_boolean (value, games_game_icon_view_get_is_selection_mode (self));
		break;
		case GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY:
		g_value_set_boolean (value, games_game_icon_view_get_is_favorite (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_game_icon_view_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GamesGameIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_GAME_ICON_VIEW, GamesGameIconView);
	switch (property_id) {
		case GAMES_GAME_ICON_VIEW_GAME_PROPERTY:
		games_game_icon_view_set_game (self, g_value_get_object (value));
		break;
		case GAMES_GAME_ICON_VIEW_CHECKED_PROPERTY:
		games_game_icon_view_set_checked (self, g_value_get_boolean (value));
		break;
		case GAMES_GAME_ICON_VIEW_IS_SELECTION_MODE_PROPERTY:
		games_game_icon_view_set_is_selection_mode (self, g_value_get_boolean (value));
		break;
		case GAMES_GAME_ICON_VIEW_IS_FAVORITE_PROPERTY:
		games_game_icon_view_set_is_favorite (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

