/* collection-list-item.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from collection-list-item.vala, do not modify */

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

#include <handy.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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_LIST_ITEM (games_collection_list_item_get_type ())
#define GAMES_COLLECTION_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItem))
#define GAMES_COLLECTION_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItemClass))
#define GAMES_IS_COLLECTION_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COLLECTION_LIST_ITEM))
#define GAMES_IS_COLLECTION_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_COLLECTION_LIST_ITEM))
#define GAMES_COLLECTION_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItemClass))

typedef struct _GamesCollectionListItem GamesCollectionListItem;
typedef struct _GamesCollectionListItemClass GamesCollectionListItemClass;
typedef struct _GamesCollectionListItemPrivate GamesCollectionListItemPrivate;

#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_LIST_ITEM_0_PROPERTY,
	GAMES_COLLECTION_LIST_ITEM_COLLECTION_PROPERTY,
	GAMES_COLLECTION_LIST_ITEM_NUM_PROPERTIES
};
static GParamSpec* games_collection_list_item_properties[GAMES_COLLECTION_LIST_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesCollectionListItem {
	HdyActionRow parent_instance;
	GamesCollectionListItemPrivate * priv;
};

struct _GamesCollectionListItemClass {
	HdyActionRowClass 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 _GamesCollectionListItemPrivate {
	GamesCollection* _collection;
};

static gint GamesCollectionListItem_private_offset;
static gpointer games_collection_list_item_parent_class = NULL;

VALA_EXTERN GType games_collection_list_item_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 GamesCollectionListItem* games_collection_list_item_new (GamesCollection* collection);
VALA_EXTERN GamesCollectionListItem* games_collection_list_item_construct (GType object_type,
                                                               GamesCollection* collection);
VALA_EXTERN GamesCollection* games_collection_list_item_get_collection (GamesCollectionListItem* self);
static void games_collection_list_item_set_collection (GamesCollectionListItem* self,
                                                GamesCollection* value);
static GObject * games_collection_list_item_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
VALA_EXTERN const gchar* games_collection_get_title (GamesCollection* self);
static void games_collection_list_item_finalize (GObject * obj);
static GType games_collection_list_item_get_type_once (void);
static void _vala_games_collection_list_item_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_games_collection_list_item_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_list_item_get_instance_private (GamesCollectionListItem* self)
{
	return G_STRUCT_MEMBER_P (self, GamesCollectionListItem_private_offset);
}

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

GamesCollectionListItem*
games_collection_list_item_new (GamesCollection* collection)
{
	return games_collection_list_item_construct (GAMES_TYPE_COLLECTION_LIST_ITEM, collection);
}

GamesCollection*
games_collection_list_item_get_collection (GamesCollectionListItem* 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;
}

static void
games_collection_list_item_set_collection (GamesCollectionListItem* self,
                                           GamesCollection* value)
{
	GamesCollection* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_collection_list_item_get_collection (self);
	if (old_value != value) {
		GamesCollection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_collection);
		self->priv->_collection = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_collection_list_item_properties[GAMES_COLLECTION_LIST_ITEM_COLLECTION_PROPERTY]);
	}
}

static GObject *
games_collection_list_item_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesCollectionListItem * self;
	GamesCollection* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	parent_class = G_OBJECT_CLASS (games_collection_list_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItem);
	_tmp0_ = self->priv->_collection;
	_tmp1_ = games_collection_get_title (_tmp0_);
	_tmp2_ = _tmp1_;
	hdy_preferences_row_set_title ((HdyPreferencesRow*) self, _tmp2_);
	return obj;
}

static void
games_collection_list_item_class_init (GamesCollectionListItemClass * klass,
                                       gpointer klass_data)
{
	games_collection_list_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesCollectionListItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_collection_list_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_collection_list_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_collection_list_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_collection_list_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_COLLECTION_LIST_ITEM_COLLECTION_PROPERTY, games_collection_list_item_properties[GAMES_COLLECTION_LIST_ITEM_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_ONLY));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/collection-list-item.ui");
}

static void
games_collection_list_item_instance_init (GamesCollectionListItem * self,
                                          gpointer klass)
{
	self->priv = games_collection_list_item_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_collection_list_item_finalize (GObject * obj)
{
	GamesCollectionListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItem);
	_g_object_unref0 (self->priv->_collection);
	G_OBJECT_CLASS (games_collection_list_item_parent_class)->finalize (obj);
}

static GType
games_collection_list_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesCollectionListItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_collection_list_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesCollectionListItem), 0, (GInstanceInitFunc) games_collection_list_item_instance_init, NULL };
	GType games_collection_list_item_type_id;
	games_collection_list_item_type_id = g_type_register_static (hdy_action_row_get_type (), "GamesCollectionListItem", &g_define_type_info, 0);
	GamesCollectionListItem_private_offset = g_type_add_instance_private (games_collection_list_item_type_id, sizeof (GamesCollectionListItemPrivate));
	return games_collection_list_item_type_id;
}

GType
games_collection_list_item_get_type (void)
{
	static volatile gsize games_collection_list_item_type_id__once = 0;
	if (g_once_init_enter (&games_collection_list_item_type_id__once)) {
		GType games_collection_list_item_type_id;
		games_collection_list_item_type_id = games_collection_list_item_get_type_once ();
		g_once_init_leave (&games_collection_list_item_type_id__once, games_collection_list_item_type_id);
	}
	return games_collection_list_item_type_id__once;
}

static void
_vala_games_collection_list_item_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GamesCollectionListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItem);
	switch (property_id) {
		case GAMES_COLLECTION_LIST_ITEM_COLLECTION_PROPERTY:
		g_value_set_object (value, games_collection_list_item_get_collection (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_collection_list_item_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GamesCollectionListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_COLLECTION_LIST_ITEM, GamesCollectionListItem);
	switch (property_id) {
		case GAMES_COLLECTION_LIST_ITEM_COLLECTION_PROPERTY:
		games_collection_list_item_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;
}

