/* collection-icon-view.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from collection-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 <stdlib.h>
#include <string.h>
#include "gnome-games.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_COLLECTION_ICON_VIEW (games_collection_icon_view_get_type ())
#define GAMES_COLLECTION_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconView))
#define GAMES_COLLECTION_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconViewClass))
#define GAMES_IS_COLLECTION_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COLLECTION_ICON_VIEW))
#define GAMES_IS_COLLECTION_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_COLLECTION_ICON_VIEW))
#define GAMES_COLLECTION_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconViewClass))

typedef struct _GamesCollectionIconView GamesCollectionIconView;
typedef struct _GamesCollectionIconViewClass GamesCollectionIconViewClass;
typedef struct _GamesCollectionIconViewPrivate GamesCollectionIconViewPrivate;

#define GAMES_TYPE_COLLECTION_THUMBNAIL (games_collection_thumbnail_get_type ())
#define GAMES_COLLECTION_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COLLECTION_THUMBNAIL, GamesCollectionThumbnail))
#define GAMES_COLLECTION_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_COLLECTION_THUMBNAIL, GamesCollectionThumbnailClass))
#define GAMES_IS_COLLECTION_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COLLECTION_THUMBNAIL))
#define GAMES_IS_COLLECTION_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_COLLECTION_THUMBNAIL))
#define GAMES_COLLECTION_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_COLLECTION_THUMBNAIL, GamesCollectionThumbnailClass))

typedef struct _GamesCollectionThumbnail GamesCollectionThumbnail;
typedef struct _GamesCollectionThumbnailClass GamesCollectionThumbnailClass;

#define GAMES_TYPE_COLLECTION (games_collection_get_type ())
#define GAMES_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COLLECTION, GamesCollection))
#define GAMES_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COLLECTION))
#define GAMES_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_COLLECTION, GamesCollectionIface))

typedef struct _GamesCollection GamesCollection;
typedef struct _GamesCollectionIface GamesCollectionIface;

#define GAMES_TYPE_GAME_MODEL (games_game_model_get_type ())
#define GAMES_GAME_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_MODEL, GamesGameModel))
#define GAMES_GAME_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAME_MODEL, GamesGameModelClass))
#define GAMES_IS_GAME_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_MODEL))
#define GAMES_IS_GAME_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAME_MODEL))
#define GAMES_GAME_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAME_MODEL, GamesGameModelClass))

typedef struct _GamesGameModel GamesGameModel;
typedef struct _GamesGameModelClass GamesGameModelClass;
typedef enum  {
	GAMES_COLLECTION_TYPE_AUTO,
	GAMES_COLLECTION_TYPE_USER,
	GAMES_COLLECTION_TYPE_PLACEHOLDER
} GamesCollectionType;

#define GAMES_TYPE_COLLECTION_TYPE (games_collection_type_get_type ())
enum  {
	GAMES_COLLECTION_ICON_VIEW_0_PROPERTY,
	GAMES_COLLECTION_ICON_VIEW_CHECKED_PROPERTY,
	GAMES_COLLECTION_ICON_VIEW_IS_SELECTION_MODE_PROPERTY,
	GAMES_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY,
	GAMES_COLLECTION_ICON_VIEW_NUM_PROPERTIES
};
static GParamSpec* games_collection_icon_view_properties[GAMES_COLLECTION_ICON_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesCollectionIconView {
	GtkFlowBoxChild parent_instance;
	GamesCollectionIconViewPrivate * priv;
};

struct _GamesCollectionIconViewClass {
	GtkFlowBoxChildClass parent_class;
};

struct _GamesCollectionIface {
	GTypeInterface parent_iface;
	void (*load) (GamesCollection* self);
	gchar* (*get_id) (GamesCollection* self);
	gboolean (*get_hide_stars) (GamesCollection* self);
	GamesGameModel* (*get_game_model) (GamesCollection* self);
	GamesCollectionType (*get_collection_type) (GamesCollection* self);
	void (*add_games) (GamesCollection* self, GamesGame** games, gint games_length1);
	void (*remove_games) (GamesCollection* self, GamesGame** games, gint games_length1);
	void (*on_game_added) (GamesCollection* self, GamesGame* game);
	void (*on_game_removed) (GamesCollection* self, GamesGame* game);
	void (*on_game_replaced) (GamesCollection* self, GamesGame* game, GamesGame* prev_game);
	gboolean (*get_is_empty) (GamesCollection* self);
	const gchar* (*get_title) (GamesCollection* self);
};

struct _GamesCollectionIconViewPrivate {
	GtkLabel* title;
	GamesCollectionThumbnail* thumbnail;
	gboolean _checked;
	gboolean _is_selection_mode;
	GamesCollection* _collection;
};

static gint GamesCollectionIconView_private_offset;
static gpointer games_collection_icon_view_parent_class = NULL;

VALA_EXTERN GType games_collection_icon_view_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_collection_thumbnail_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_game_model_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_collection_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_collection_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesCollectionIconView* games_collection_icon_view_new (GamesCollection* collection);
VALA_EXTERN GamesCollectionIconView* games_collection_icon_view_construct (GType object_type,
                                                               GamesCollection* collection);
VALA_EXTERN guint games_collection_icon_view_hash (GamesCollectionIconView* key);
VALA_EXTERN guint games_collection_hash (GamesCollection* collection);
VALA_EXTERN GamesCollection* games_collection_icon_view_get_collection (GamesCollectionIconView* self);
VALA_EXTERN gboolean games_collection_icon_view_equal (GamesCollectionIconView* a,
                                           GamesCollectionIconView* b);
VALA_EXTERN gboolean games_collection_equal (GamesCollection* a,
                                 GamesCollection* b);
VALA_EXTERN gboolean games_collection_icon_view_get_checked (GamesCollectionIconView* self);
VALA_EXTERN void games_collection_icon_view_set_checked (GamesCollectionIconView* self,
                                             gboolean value);
VALA_EXTERN gboolean games_collection_icon_view_get_is_selection_mode (GamesCollectionIconView* self);
VALA_EXTERN void games_collection_icon_view_set_is_selection_mode (GamesCollectionIconView* self,
                                                       gboolean value);
VALA_EXTERN void games_collection_icon_view_set_collection (GamesCollectionIconView* self,
                                                GamesCollection* value);
VALA_EXTERN const gchar* games_collection_get_title (GamesCollection* self);
VALA_EXTERN void games_collection_thumbnail_set_collection (GamesCollectionThumbnail* self,
                                                GamesCollection* value);
static GObject * games_collection_icon_view_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void games_collection_icon_view_finalize (GObject * obj);
static GType games_collection_icon_view_get_type_once (void);
static void _vala_games_collection_icon_view_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_games_collection_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_collection_icon_view_get_instance_private (GamesCollectionIconView* self)
{
	return G_STRUCT_MEMBER_P (self, GamesCollectionIconView_private_offset);
}

GamesCollectionIconView*
games_collection_icon_view_construct (GType object_type,
                                      GamesCollection* collection)
{
	GamesCollectionIconView * self = NULL;
	g_return_val_if_fail (collection != NULL, NULL);
	self = (GamesCollectionIconView*) g_object_new (object_type, "collection", collection, NULL);
	return self;
}

GamesCollectionIconView*
games_collection_icon_view_new (GamesCollection* collection)
{
	return games_collection_icon_view_construct (GAMES_TYPE_COLLECTION_ICON_VIEW, collection);
}

guint
games_collection_icon_view_hash (GamesCollectionIconView* key)
{
	GamesCollection* _tmp0_;
	GamesCollection* _tmp1_;
	guint result;
	g_return_val_if_fail (key != NULL, 0U);
	_tmp0_ = games_collection_icon_view_get_collection (key);
	_tmp1_ = _tmp0_;
	result = games_collection_hash (_tmp1_);
	return result;
}

gboolean
games_collection_icon_view_equal (GamesCollectionIconView* a,
                                  GamesCollectionIconView* b)
{
	GamesCollection* _tmp0_;
	GamesCollection* _tmp1_;
	GamesCollection* _tmp2_;
	GamesCollection* _tmp3_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = games_collection_icon_view_get_collection (a);
	_tmp1_ = _tmp0_;
	_tmp2_ = games_collection_icon_view_get_collection (b);
	_tmp3_ = _tmp2_;
	result = games_collection_equal (_tmp1_, _tmp3_);
	return result;
}

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

void
games_collection_icon_view_set_checked (GamesCollectionIconView* self,
                                        gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_collection_icon_view_get_checked (self);
	if (old_value != value) {
		self->priv->_checked = value;
		g_object_notify_by_pspec ((GObject *) self, games_collection_icon_view_properties[GAMES_COLLECTION_ICON_VIEW_CHECKED_PROPERTY]);
	}
}

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

void
games_collection_icon_view_set_is_selection_mode (GamesCollectionIconView* self,
                                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_collection_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_collection_icon_view_properties[GAMES_COLLECTION_ICON_VIEW_IS_SELECTION_MODE_PROPERTY]);
	}
}

GamesCollection*
games_collection_icon_view_get_collection (GamesCollectionIconView* self)
{
	GamesCollection* result;
	GamesCollection* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_collection;
	result = _tmp0_;
	return result;
}

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

void
games_collection_icon_view_set_collection (GamesCollectionIconView* self,
                                           GamesCollection* value)
{
	GamesCollection* _tmp0_;
	GtkLabel* _tmp1_;
	GamesCollection* _tmp2_;
	GamesCollection* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GamesCollectionThumbnail* _tmp6_;
	GamesCollection* _tmp7_;
	GamesCollection* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_collection);
	self->priv->_collection = _tmp0_;
	_tmp1_ = self->priv->title;
	_tmp2_ = games_collection_icon_view_get_collection (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = games_collection_get_title (_tmp3_);
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp1_, _tmp5_);
	_tmp6_ = self->priv->thumbnail;
	_tmp7_ = games_collection_icon_view_get_collection (self);
	_tmp8_ = _tmp7_;
	games_collection_thumbnail_set_collection (_tmp6_, _tmp8_);
	g_object_notify_by_pspec ((GObject *) self, games_collection_icon_view_properties[GAMES_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY]);
}

static GObject *
games_collection_icon_view_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesCollectionIconView * self;
	GtkStyleContext* _tmp0_;
	parent_class = G_OBJECT_CLASS (games_collection_icon_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconView);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, "collection-icon-view");
	return obj;
}

static void
games_collection_icon_view_class_init (GamesCollectionIconViewClass * klass,
                                       gpointer klass_data)
{
	games_collection_icon_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesCollectionIconView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_collection_icon_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_collection_icon_view_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_collection_icon_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_collection_icon_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_COLLECTION_ICON_VIEW_CHECKED_PROPERTY, games_collection_icon_view_properties[GAMES_COLLECTION_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_COLLECTION_ICON_VIEW_IS_SELECTION_MODE_PROPERTY, games_collection_icon_view_properties[GAMES_COLLECTION_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_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY, games_collection_icon_view_properties[GAMES_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY] = g_param_spec_object ("collection", "collection", "collection", GAMES_TYPE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/collection-icon-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title", FALSE, GamesCollectionIconView_private_offset + G_STRUCT_OFFSET (GamesCollectionIconViewPrivate, title));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "thumbnail", FALSE, GamesCollectionIconView_private_offset + G_STRUCT_OFFSET (GamesCollectionIconViewPrivate, thumbnail));
}

static void
games_collection_icon_view_instance_init (GamesCollectionIconView * self,
                                          gpointer klass)
{
	self->priv = games_collection_icon_view_get_instance_private (self);
	g_type_ensure (GAMES_TYPE_COLLECTION_THUMBNAIL);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_collection_icon_view_finalize (GObject * obj)
{
	GamesCollectionIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconView);
	_g_object_unref0 (self->priv->_collection);
	G_OBJECT_CLASS (games_collection_icon_view_parent_class)->finalize (obj);
}

static GType
games_collection_icon_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesCollectionIconViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_collection_icon_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesCollectionIconView), 0, (GInstanceInitFunc) games_collection_icon_view_instance_init, NULL };
	GType games_collection_icon_view_type_id;
	games_collection_icon_view_type_id = g_type_register_static (gtk_flow_box_child_get_type (), "GamesCollectionIconView", &g_define_type_info, 0);
	GamesCollectionIconView_private_offset = g_type_add_instance_private (games_collection_icon_view_type_id, sizeof (GamesCollectionIconViewPrivate));
	return games_collection_icon_view_type_id;
}

GType
games_collection_icon_view_get_type (void)
{
	static volatile gsize games_collection_icon_view_type_id__once = 0;
	if (g_once_init_enter (&games_collection_icon_view_type_id__once)) {
		GType games_collection_icon_view_type_id;
		games_collection_icon_view_type_id = games_collection_icon_view_get_type_once ();
		g_once_init_leave (&games_collection_icon_view_type_id__once, games_collection_icon_view_type_id);
	}
	return games_collection_icon_view_type_id__once;
}

static void
_vala_games_collection_icon_view_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GamesCollectionIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconView);
	switch (property_id) {
		case GAMES_COLLECTION_ICON_VIEW_CHECKED_PROPERTY:
		g_value_set_boolean (value, games_collection_icon_view_get_checked (self));
		break;
		case GAMES_COLLECTION_ICON_VIEW_IS_SELECTION_MODE_PROPERTY:
		g_value_set_boolean (value, games_collection_icon_view_get_is_selection_mode (self));
		break;
		case GAMES_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY:
		g_value_set_object (value, games_collection_icon_view_get_collection (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_collection_icon_view_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GamesCollectionIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_COLLECTION_ICON_VIEW, GamesCollectionIconView);
	switch (property_id) {
		case GAMES_COLLECTION_ICON_VIEW_CHECKED_PROPERTY:
		games_collection_icon_view_set_checked (self, g_value_get_boolean (value));
		break;
		case GAMES_COLLECTION_ICON_VIEW_IS_SELECTION_MODE_PROPERTY:
		games_collection_icon_view_set_is_selection_mode (self, g_value_get_boolean (value));
		break;
		case GAMES_COLLECTION_ICON_VIEW_COLLECTION_PROPERTY:
		games_collection_icon_view_set_collection (self, g_value_get_object (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;
}

