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

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

#include <gtk/gtk.h>
#include <glib-object.h>
#include "gnome-games.h"
#include <glib.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_PLATFORM_LIST_ITEM (games_platform_list_item_get_type ())
#define GAMES_PLATFORM_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItem))
#define GAMES_PLATFORM_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItemClass))
#define GAMES_IS_PLATFORM_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLATFORM_LIST_ITEM))
#define GAMES_IS_PLATFORM_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLATFORM_LIST_ITEM))
#define GAMES_PLATFORM_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItemClass))

typedef struct _GamesPlatformListItem GamesPlatformListItem;
typedef struct _GamesPlatformListItemClass GamesPlatformListItemClass;
typedef struct _GamesPlatformListItemPrivate GamesPlatformListItemPrivate;
enum  {
	GAMES_PLATFORM_LIST_ITEM_0_PROPERTY,
	GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY,
	GAMES_PLATFORM_LIST_ITEM_NUM_PROPERTIES
};
static GParamSpec* games_platform_list_item_properties[GAMES_PLATFORM_LIST_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesPlatformListItem {
	GtkListBoxRow parent_instance;
	GamesPlatformListItemPrivate * priv;
	GtkLabel* label;
};

struct _GamesPlatformListItemClass {
	GtkListBoxRowClass parent_class;
};

struct _GamesPlatformListItemPrivate {
	GamesPlatform* _platform;
};

static gint GamesPlatformListItem_private_offset;
static gpointer games_platform_list_item_parent_class = NULL;

VALA_EXTERN GType games_platform_list_item_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesPlatformListItem* games_platform_list_item_new (GamesPlatform* platform);
VALA_EXTERN GamesPlatformListItem* games_platform_list_item_construct (GType object_type,
                                                           GamesPlatform* platform);
VALA_EXTERN GamesPlatform* games_platform_list_item_get_platform (GamesPlatformListItem* self);
static void games_platform_list_item_set_platform (GamesPlatformListItem* self,
                                            GamesPlatform* value);
static GObject * games_platform_list_item_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void games_platform_list_item_finalize (GObject * obj);
static GType games_platform_list_item_get_type_once (void);
static void _vala_games_platform_list_item_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_games_platform_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_platform_list_item_get_instance_private (GamesPlatformListItem* self)
{
	return G_STRUCT_MEMBER_P (self, GamesPlatformListItem_private_offset);
}

GamesPlatformListItem*
games_platform_list_item_construct (GType object_type,
                                    GamesPlatform* platform)
{
	GamesPlatformListItem * self = NULL;
	g_return_val_if_fail (platform != NULL, NULL);
	self = (GamesPlatformListItem*) g_object_new (object_type, "platform", platform, NULL);
	return self;
}

GamesPlatformListItem*
games_platform_list_item_new (GamesPlatform* platform)
{
	return games_platform_list_item_construct (GAMES_TYPE_PLATFORM_LIST_ITEM, platform);
}

GamesPlatform*
games_platform_list_item_get_platform (GamesPlatformListItem* self)
{
	GamesPlatform* result;
	GamesPlatform* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_platform;
	result = _tmp0_;
	return result;
}

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

static void
games_platform_list_item_set_platform (GamesPlatformListItem* self,
                                       GamesPlatform* value)
{
	GamesPlatform* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_platform_list_item_get_platform (self);
	if (old_value != value) {
		GamesPlatform* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_platform);
		self->priv->_platform = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_platform_list_item_properties[GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY]);
	}
}

static GObject *
games_platform_list_item_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesPlatformListItem * self;
	GtkLabel* _tmp0_;
	GamesPlatform* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	parent_class = G_OBJECT_CLASS (games_platform_list_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItem);
	_tmp0_ = self->label;
	_tmp1_ = self->priv->_platform;
	_tmp2_ = games_platform_get_name (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_label_set_label (_tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
	return obj;
}

static void
games_platform_list_item_class_init (GamesPlatformListItemClass * klass,
                                     gpointer klass_data)
{
	games_platform_list_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesPlatformListItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_platform_list_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_platform_list_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_platform_list_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_platform_list_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY, games_platform_list_item_properties[GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY] = g_param_spec_object ("platform", "platform", "platform", GAMES_TYPE_PLATFORM, 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/platform-list-item.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "label", FALSE, G_STRUCT_OFFSET (GamesPlatformListItem, label));
}

static void
games_platform_list_item_instance_init (GamesPlatformListItem * self,
                                        gpointer klass)
{
	self->priv = games_platform_list_item_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_platform_list_item_finalize (GObject * obj)
{
	GamesPlatformListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItem);
	_g_object_unref0 (self->priv->_platform);
	G_OBJECT_CLASS (games_platform_list_item_parent_class)->finalize (obj);
}

static GType
games_platform_list_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesPlatformListItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_platform_list_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPlatformListItem), 0, (GInstanceInitFunc) games_platform_list_item_instance_init, NULL };
	GType games_platform_list_item_type_id;
	games_platform_list_item_type_id = g_type_register_static (gtk_list_box_row_get_type (), "GamesPlatformListItem", &g_define_type_info, 0);
	GamesPlatformListItem_private_offset = g_type_add_instance_private (games_platform_list_item_type_id, sizeof (GamesPlatformListItemPrivate));
	return games_platform_list_item_type_id;
}

GType
games_platform_list_item_get_type (void)
{
	static volatile gsize games_platform_list_item_type_id__once = 0;
	if (g_once_init_enter (&games_platform_list_item_type_id__once)) {
		GType games_platform_list_item_type_id;
		games_platform_list_item_type_id = games_platform_list_item_get_type_once ();
		g_once_init_leave (&games_platform_list_item_type_id__once, games_platform_list_item_type_id);
	}
	return games_platform_list_item_type_id__once;
}

static void
_vala_games_platform_list_item_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GamesPlatformListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItem);
	switch (property_id) {
		case GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY:
		g_value_set_object (value, games_platform_list_item_get_platform (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_platform_list_item_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GamesPlatformListItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PLATFORM_LIST_ITEM, GamesPlatformListItem);
	switch (property_id) {
		case GAMES_PLATFORM_LIST_ITEM_PLATFORM_PROPERTY:
		games_platform_list_item_set_platform (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;
}

