/* preferences-dialog.c generated by valac 0.56.19, the Vala compiler
 * generated from preferences-dialog.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * Copyright (C) 2022 Nils Lück
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_PREFERENCES_DIALOG (preferences_dialog_get_type ())
#define PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialog))
#define PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))
#define IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES_DIALOG))
#define IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES_DIALOG))
#define PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))

typedef struct _PreferencesDialog PreferencesDialog;
typedef struct _PreferencesDialogClass PreferencesDialogClass;
typedef struct _PreferencesDialogPrivate PreferencesDialogPrivate;

#define TYPE_PREFERENCES (preferences_get_type ())
#define PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES, Preferences))
#define PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES, PreferencesClass))
#define IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES))
#define IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES))
#define PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES, PreferencesClass))

typedef struct _Preferences Preferences;
typedef struct _PreferencesClass PreferencesClass;
enum  {
	PREFERENCES_DIALOG_0_PROPERTY,
	PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* preferences_dialog_properties[PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	BOARD_ORIENTATION_HUMAN_SIDE,
	BOARD_ORIENTATION_WHITE_SIDE,
	BOARD_ORIENTATION_BLACK_SIDE,
	BOARD_ORIENTATION_CURRENT_PLAYER
} BoardOrientation;

#define TYPE_BOARD_ORIENTATION (board_orientation_get_type ())
typedef enum  {
	MOVE_FORMAT_HUMAN,
	MOVE_FORMAT_STANDARD_ALGEBRAIC,
	MOVE_FORMAT_LONG_ALGEBRAIC,
	MOVE_FORMAT_FIGURINE
} MoveFormat;

#define TYPE_MOVE_FORMAT (move_format_get_type ())
typedef enum  {
	PIECE_STYLE_SIMPLE,
	PIECE_STYLE_FANCY
} PieceStyle;

#define TYPE_PIECE_STYLE (piece_style_get_type ())

struct _PreferencesDialog {
	AdwPreferencesDialog parent_instance;
	PreferencesDialogPrivate * priv;
};

struct _PreferencesDialogClass {
	AdwPreferencesDialogClass parent_class;
};

struct _PreferencesDialogPrivate {
	Preferences* preferences;
	AdwComboRow* board_orientation_combo;
	AdwComboRow* move_format_combo;
	AdwComboRow* piece_style_combo;
	GtkSwitch* board_numbering_switch;
};

static gint PreferencesDialog_private_offset;
static gpointer preferences_dialog_parent_class = NULL;

VALA_EXTERN GType preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PreferencesDialog, g_object_unref)
VALA_EXTERN GType preferences_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Preferences, g_object_unref)
VALA_EXTERN PreferencesDialog* preferences_dialog_new (Preferences* preferences);
VALA_EXTERN PreferencesDialog* preferences_dialog_construct (GType object_type,
                                                 Preferences* preferences);
static gchar* preferences_dialog_board_orientation_display_name_cb (PreferencesDialog* self,
                                                             AdwEnumListItem* item);
VALA_EXTERN GType board_orientation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* board_orientation_display_name (BoardOrientation self);
static gchar* preferences_dialog_move_format_display_name_cb (PreferencesDialog* self,
                                                       AdwEnumListItem* item);
VALA_EXTERN GType move_format_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* move_format_display_name (MoveFormat self);
static gchar* preferences_dialog_piece_style_display_name_cb (PreferencesDialog* self,
                                                       AdwEnumListItem* item);
VALA_EXTERN GType piece_style_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* piece_style_display_name (PieceStyle self);
static void preferences_dialog_finalize (GObject * obj);
static GType preferences_dialog_get_type_once (void);

static inline gpointer
preferences_dialog_get_instance_private (PreferencesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, PreferencesDialog_private_offset);
}

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

PreferencesDialog*
preferences_dialog_construct (GType object_type,
                              Preferences* preferences)
{
	PreferencesDialog * self = NULL;
	Preferences* _tmp0_;
	GtkSwitch* _tmp1_;
	AdwComboRow* _tmp2_;
	AdwComboRow* _tmp3_;
	AdwComboRow* _tmp4_;
	g_return_val_if_fail (preferences != NULL, NULL);
	self = (PreferencesDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (preferences);
	_g_object_unref0 (self->priv->preferences);
	self->priv->preferences = _tmp0_;
	_tmp1_ = self->priv->board_numbering_switch;
	g_object_bind_property_with_closures ((GObject*) preferences, "show-board-numbering", (GObject*) _tmp1_, "active", G_BINDING_BIDIRECTIONAL | 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)));
	_tmp2_ = self->priv->piece_style_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "piece-style", (GObject*) _tmp2_, "selected", G_BINDING_BIDIRECTIONAL | 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)));
	_tmp3_ = self->priv->move_format_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "move-format", (GObject*) _tmp3_, "selected", G_BINDING_BIDIRECTIONAL | 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)));
	_tmp4_ = self->priv->board_orientation_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "board-orientation", (GObject*) _tmp4_, "selected", G_BINDING_BIDIRECTIONAL | 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)));
	return self;
}

PreferencesDialog*
preferences_dialog_new (Preferences* preferences)
{
	return preferences_dialog_construct (TYPE_PREFERENCES_DIALOG, preferences);
}

static gchar*
preferences_dialog_board_orientation_display_name_cb (PreferencesDialog* self,
                                                      AdwEnumListItem* item)
{
	BoardOrientation value = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = adw_enum_list_item_get_value (item);
	_tmp1_ = _tmp0_;
	value = (BoardOrientation) _tmp1_;
	_tmp2_ = board_orientation_display_name (value);
	result = _tmp2_;
	return result;
}

static gchar*
preferences_dialog_move_format_display_name_cb (PreferencesDialog* self,
                                                AdwEnumListItem* item)
{
	MoveFormat value = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = adw_enum_list_item_get_value (item);
	_tmp1_ = _tmp0_;
	value = (MoveFormat) _tmp1_;
	_tmp2_ = move_format_display_name (value);
	result = _tmp2_;
	return result;
}

static gchar*
preferences_dialog_piece_style_display_name_cb (PreferencesDialog* self,
                                                AdwEnumListItem* item)
{
	PieceStyle value = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = adw_enum_list_item_get_value (item);
	_tmp1_ = _tmp0_;
	value = (PieceStyle) _tmp1_;
	_tmp2_ = piece_style_display_name (value);
	result = _tmp2_;
	return result;
}

static void
preferences_dialog_class_init (PreferencesDialogClass * klass,
                               gpointer klass_data)
{
	preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PreferencesDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = preferences_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Chess/ui/preferences-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "board_orientation_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, board_orientation_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "move_format_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, move_format_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "piece_style_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, piece_style_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "board_numbering_switch", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, board_numbering_switch));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "board_orientation_display_name_cb", G_CALLBACK(preferences_dialog_board_orientation_display_name_cb));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "move_format_display_name_cb", G_CALLBACK(preferences_dialog_move_format_display_name_cb));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "piece_style_display_name_cb", G_CALLBACK(preferences_dialog_piece_style_display_name_cb));
}

static void
preferences_dialog_instance_init (PreferencesDialog * self,
                                  gpointer klass)
{
	self->priv = preferences_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
preferences_dialog_finalize (GObject * obj)
{
	PreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PREFERENCES_DIALOG, PreferencesDialog);
	_g_object_unref0 (self->priv->preferences);
	G_OBJECT_CLASS (preferences_dialog_parent_class)->finalize (obj);
}

static GType
preferences_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesDialog), 0, (GInstanceInitFunc) preferences_dialog_instance_init, NULL };
	GType preferences_dialog_type_id;
	preferences_dialog_type_id = g_type_register_static (adw_preferences_dialog_get_type (), "PreferencesDialog", &g_define_type_info, 0);
	PreferencesDialog_private_offset = g_type_add_instance_private (preferences_dialog_type_id, sizeof (PreferencesDialogPrivate));
	return preferences_dialog_type_id;
}

GType
preferences_dialog_get_type (void)
{
	static volatile gsize preferences_dialog_type_id__once = 0;
	if (g_once_init_enter (&preferences_dialog_type_id__once)) {
		GType preferences_dialog_type_id;
		preferences_dialog_type_id = preferences_dialog_get_type_once ();
		g_once_init_leave (&preferences_dialog_type_id__once, preferences_dialog_type_id);
	}
	return preferences_dialog_type_id__once;
}

