/* screen-layout-item.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from screen-layout-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>
#include <float.h>
#include <math.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_SCREEN_LAYOUT_ITEM (games_screen_layout_item_get_type ())
#define GAMES_SCREEN_LAYOUT_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItem))
#define GAMES_SCREEN_LAYOUT_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItemClass))
#define GAMES_IS_SCREEN_LAYOUT_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SCREEN_LAYOUT_ITEM))
#define GAMES_IS_SCREEN_LAYOUT_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SCREEN_LAYOUT_ITEM))
#define GAMES_SCREEN_LAYOUT_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItemClass))

typedef struct _GamesScreenLayoutItem GamesScreenLayoutItem;
typedef struct _GamesScreenLayoutItemClass GamesScreenLayoutItemClass;
typedef struct _GamesScreenLayoutItemPrivate GamesScreenLayoutItemPrivate;
enum  {
	GAMES_SCREEN_LAYOUT_ITEM_0_PROPERTY,
	GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY,
	GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY,
	GAMES_SCREEN_LAYOUT_ITEM_NUM_PROPERTIES
};
static GParamSpec* games_screen_layout_item_properties[GAMES_SCREEN_LAYOUT_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesScreenLayoutItem {
	GtkListBoxRow parent_instance;
	GamesScreenLayoutItemPrivate * priv;
};

struct _GamesScreenLayoutItemClass {
	GtkListBoxRowClass parent_class;
};

struct _GamesScreenLayoutItemPrivate {
	GtkImage* icon;
	GtkLabel* title;
	GtkImage* checkmark;
	GamesScreenLayout _layout;
	gboolean _selected;
};

static gint GamesScreenLayoutItem_private_offset;
static gpointer games_screen_layout_item_parent_class = NULL;

VALA_EXTERN GType games_screen_layout_item_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesScreenLayoutItem* games_screen_layout_item_new (GamesScreenLayout layout);
VALA_EXTERN GamesScreenLayoutItem* games_screen_layout_item_construct (GType object_type,
                                                           GamesScreenLayout layout);
static void games_screen_layout_item_real_constructed (GObject* base);
VALA_EXTERN GamesScreenLayout games_screen_layout_item_get_layout (GamesScreenLayoutItem* self);
static void games_screen_layout_item_set_layout (GamesScreenLayoutItem* self,
                                          GamesScreenLayout value);
VALA_EXTERN gboolean games_screen_layout_item_get_selected (GamesScreenLayoutItem* self);
VALA_EXTERN void games_screen_layout_item_set_selected (GamesScreenLayoutItem* self,
                                            gboolean value);
static GObject * games_screen_layout_item_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void _games_screen_layout_item___lambda91_ (GamesScreenLayoutItem* self);
static void __games_screen_layout_item___lambda91__g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self);
static void games_screen_layout_item_finalize (GObject * obj);
static GType games_screen_layout_item_get_type_once (void);
static void _vala_games_screen_layout_item_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_games_screen_layout_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_screen_layout_item_get_instance_private (GamesScreenLayoutItem* self)
{
	return G_STRUCT_MEMBER_P (self, GamesScreenLayoutItem_private_offset);
}

GamesScreenLayoutItem*
games_screen_layout_item_construct (GType object_type,
                                    GamesScreenLayout layout)
{
	GamesScreenLayoutItem * self = NULL;
	self = (GamesScreenLayoutItem*) g_object_new (object_type, "layout", layout, NULL);
	return self;
}

GamesScreenLayoutItem*
games_screen_layout_item_new (GamesScreenLayout layout)
{
	return games_screen_layout_item_construct (GAMES_TYPE_SCREEN_LAYOUT_ITEM, layout);
}

static void
games_screen_layout_item_real_constructed (GObject* base)
{
	GamesScreenLayoutItem * self;
	GtkImage* _tmp0_;
	GamesScreenLayout _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GamesScreenLayout _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	self = (GamesScreenLayoutItem*) base;
	_tmp0_ = self->priv->icon;
	_tmp1_ = self->priv->_layout;
	_tmp2_ = games_screen_layout_get_icon (_tmp1_);
	_tmp3_ = _tmp2_;
	g_object_set (_tmp0_, "icon-name", _tmp3_, NULL);
	_g_free0 (_tmp3_);
	_tmp4_ = self->priv->title;
	_tmp5_ = self->priv->_layout;
	_tmp6_ = games_screen_layout_get_title (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_label_set_label (_tmp4_, _tmp7_);
	_g_free0 (_tmp7_);
	G_OBJECT_CLASS (games_screen_layout_item_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_list_box_row_get_type (), GtkListBoxRow));
}

GamesScreenLayout
games_screen_layout_item_get_layout (GamesScreenLayoutItem* self)
{
	GamesScreenLayout result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_layout;
	return result;
}

static void
games_screen_layout_item_set_layout (GamesScreenLayoutItem* self,
                                     GamesScreenLayout value)
{
	GamesScreenLayout old_value;
	g_return_if_fail (self != NULL);
	old_value = games_screen_layout_item_get_layout (self);
	if (old_value != value) {
		self->priv->_layout = value;
		g_object_notify_by_pspec ((GObject *) self, games_screen_layout_item_properties[GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY]);
	}
}

gboolean
games_screen_layout_item_get_selected (GamesScreenLayoutItem* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selected;
	return result;
}

void
games_screen_layout_item_set_selected (GamesScreenLayoutItem* self,
                                       gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_screen_layout_item_get_selected (self);
	if (old_value != value) {
		self->priv->_selected = value;
		g_object_notify_by_pspec ((GObject *) self, games_screen_layout_item_properties[GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY]);
	}
}

static void
_games_screen_layout_item___lambda91_ (GamesScreenLayoutItem* self)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_;
	GtkImage* _tmp2_;
	_tmp1_ = self->priv->_selected;
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	_tmp2_ = self->priv->checkmark;
	gtk_widget_set_opacity ((GtkWidget*) _tmp2_, (gdouble) _tmp0_);
}

static void
__games_screen_layout_item___lambda91__g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self)
{
	_games_screen_layout_item___lambda91_ ((GamesScreenLayoutItem*) self);
}

static GObject *
games_screen_layout_item_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesScreenLayoutItem * self;
	parent_class = G_OBJECT_CLASS (games_screen_layout_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItem);
	g_signal_connect_object ((GObject*) self, "notify::selected", (GCallback) __games_screen_layout_item___lambda91__g_object_notify, self, 0);
	return obj;
}

static void
games_screen_layout_item_class_init (GamesScreenLayoutItemClass * klass,
                                     gpointer klass_data)
{
	games_screen_layout_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesScreenLayoutItem_private_offset);
	((GObjectClass *) klass)->constructed = (void (*) (GObject*)) games_screen_layout_item_real_constructed;
	G_OBJECT_CLASS (klass)->get_property = _vala_games_screen_layout_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_screen_layout_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_screen_layout_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_screen_layout_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY, games_screen_layout_item_properties[GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY] = g_param_spec_enum ("layout", "layout", "layout", GAMES_TYPE_SCREEN_LAYOUT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY, games_screen_layout_item_properties[GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", 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/screen-layout/screen-layout-item.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "icon", FALSE, GamesScreenLayoutItem_private_offset + G_STRUCT_OFFSET (GamesScreenLayoutItemPrivate, icon));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title", FALSE, GamesScreenLayoutItem_private_offset + G_STRUCT_OFFSET (GamesScreenLayoutItemPrivate, title));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "checkmark", FALSE, GamesScreenLayoutItem_private_offset + G_STRUCT_OFFSET (GamesScreenLayoutItemPrivate, checkmark));
}

static void
games_screen_layout_item_instance_init (GamesScreenLayoutItem * self,
                                        gpointer klass)
{
	self->priv = games_screen_layout_item_get_instance_private (self);
	self->priv->_selected = FALSE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_screen_layout_item_finalize (GObject * obj)
{
	GamesScreenLayoutItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItem);
	G_OBJECT_CLASS (games_screen_layout_item_parent_class)->finalize (obj);
}

static GType
games_screen_layout_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesScreenLayoutItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_screen_layout_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesScreenLayoutItem), 0, (GInstanceInitFunc) games_screen_layout_item_instance_init, NULL };
	GType games_screen_layout_item_type_id;
	games_screen_layout_item_type_id = g_type_register_static (gtk_list_box_row_get_type (), "GamesScreenLayoutItem", &g_define_type_info, 0);
	GamesScreenLayoutItem_private_offset = g_type_add_instance_private (games_screen_layout_item_type_id, sizeof (GamesScreenLayoutItemPrivate));
	return games_screen_layout_item_type_id;
}

GType
games_screen_layout_item_get_type (void)
{
	static volatile gsize games_screen_layout_item_type_id__once = 0;
	if (g_once_init_enter (&games_screen_layout_item_type_id__once)) {
		GType games_screen_layout_item_type_id;
		games_screen_layout_item_type_id = games_screen_layout_item_get_type_once ();
		g_once_init_leave (&games_screen_layout_item_type_id__once, games_screen_layout_item_type_id);
	}
	return games_screen_layout_item_type_id__once;
}

static void
_vala_games_screen_layout_item_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GamesScreenLayoutItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItem);
	switch (property_id) {
		case GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY:
		g_value_set_enum (value, games_screen_layout_item_get_layout (self));
		break;
		case GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY:
		g_value_set_boolean (value, games_screen_layout_item_get_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_screen_layout_item_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GamesScreenLayoutItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_SCREEN_LAYOUT_ITEM, GamesScreenLayoutItem);
	switch (property_id) {
		case GAMES_SCREEN_LAYOUT_ITEM_LAYOUT_PROPERTY:
		games_screen_layout_item_set_layout (self, g_value_get_enum (value));
		break;
		case GAMES_SCREEN_LAYOUT_ITEM_SELECTED_PROPERTY:
		games_screen_layout_item_set_selected (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;
}

