/* preferences-window.c generated by valac 0.56.3, the Vala compiler
 * generated from preferences-window.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_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_WINDOW (preferences_window_get_type ())
#define PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES_WINDOW, PreferencesWindow))
#define PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES_WINDOW, PreferencesWindowClass))
#define IS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES_WINDOW))
#define IS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES_WINDOW))
#define PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES_WINDOW, PreferencesWindowClass))

typedef struct _PreferencesWindow PreferencesWindow;
typedef struct _PreferencesWindowClass PreferencesWindowClass;
typedef struct _PreferencesWindowPrivate PreferencesWindowPrivate;

#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_WINDOW_0_PROPERTY,
	PREFERENCES_WINDOW_NUM_PROPERTIES
};
static GParamSpec* preferences_window_properties[PREFERENCES_WINDOW_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 _PreferencesWindow {
	AdwPreferencesWindow parent_instance;
	PreferencesWindowPrivate * priv;
};

struct _PreferencesWindowClass {
	AdwPreferencesWindowClass parent_class;
};

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

static gint PreferencesWindow_private_offset;
static gpointer preferences_window_parent_class = NULL;

VALA_EXTERN GType preferences_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PreferencesWindow, g_object_unref)
VALA_EXTERN GType preferences_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Preferences, g_object_unref)
VALA_EXTERN PreferencesWindow* preferences_window_new (GtkWindow* window,
                                           Preferences* preferences);
VALA_EXTERN PreferencesWindow* preferences_window_construct (GType object_type,
                                                 GtkWindow* window,
                                                 Preferences* preferences);
static gchar* preferences_window_board_orientation_display_name_cb (PreferencesWindow* 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_window_move_format_display_name_cb (PreferencesWindow* 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_window_piece_style_display_name_cb (PreferencesWindow* 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_window_finalize (GObject * obj);
static GType preferences_window_get_type_once (void);

static inline gpointer
preferences_window_get_instance_private (PreferencesWindow* self)
{
	return G_STRUCT_MEMBER_P (self, PreferencesWindow_private_offset);
}

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

PreferencesWindow*
preferences_window_construct (GType object_type,
                              GtkWindow* window,
                              Preferences* preferences)
{
	PreferencesWindow * self = NULL;
	Preferences* _tmp0_;
	GtkSwitch* _tmp1_;
	GtkSwitch* _tmp2_;
	AdwComboRow* _tmp3_;
	AdwComboRow* _tmp4_;
	AdwComboRow* _tmp5_;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (preferences != NULL, NULL);
	self = (PreferencesWindow*) g_object_new (object_type, NULL);
	gtk_window_set_transient_for ((GtkWindow*) self, window);
	_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->move_hints_switch;
	g_object_bind_property_with_closures ((GObject*) preferences, "show-move-hints", (GObject*) _tmp2_, "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)));
	_tmp3_ = self->priv->piece_style_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "piece-style", (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->move_format_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "move-format", (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)));
	_tmp5_ = self->priv->board_orientation_combo;
	g_object_bind_property_with_closures ((GObject*) preferences, "board-orientation", (GObject*) _tmp5_, "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;
}

PreferencesWindow*
preferences_window_new (GtkWindow* window,
                        Preferences* preferences)
{
	return preferences_window_construct (TYPE_PREFERENCES_WINDOW, window, preferences);
}

static gchar*
preferences_window_board_orientation_display_name_cb (PreferencesWindow* 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_window_move_format_display_name_cb (PreferencesWindow* 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_window_piece_style_display_name_cb (PreferencesWindow* 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_window_class_init (PreferencesWindowClass * klass,
                               gpointer klass_data)
{
	preferences_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PreferencesWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = preferences_window_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Chess/ui/preferences-window.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "board_orientation_combo", FALSE, PreferencesWindow_private_offset + G_STRUCT_OFFSET (PreferencesWindowPrivate, board_orientation_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "move_format_combo", FALSE, PreferencesWindow_private_offset + G_STRUCT_OFFSET (PreferencesWindowPrivate, move_format_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "piece_style_combo", FALSE, PreferencesWindow_private_offset + G_STRUCT_OFFSET (PreferencesWindowPrivate, piece_style_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "board_numbering_switch", FALSE, PreferencesWindow_private_offset + G_STRUCT_OFFSET (PreferencesWindowPrivate, board_numbering_switch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "move_hints_switch", FALSE, PreferencesWindow_private_offset + G_STRUCT_OFFSET (PreferencesWindowPrivate, move_hints_switch));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "board_orientation_display_name_cb", G_CALLBACK(preferences_window_board_orientation_display_name_cb));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "move_format_display_name_cb", G_CALLBACK(preferences_window_move_format_display_name_cb));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "piece_style_display_name_cb", G_CALLBACK(preferences_window_piece_style_display_name_cb));
}

static void
preferences_window_instance_init (PreferencesWindow * self,
                                  gpointer klass)
{
	self->priv = preferences_window_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
preferences_window_finalize (GObject * obj)
{
	PreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PREFERENCES_WINDOW, PreferencesWindow);
	_g_object_unref0 (self->priv->preferences);
	G_OBJECT_CLASS (preferences_window_parent_class)->finalize (obj);
}

static GType
preferences_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PreferencesWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesWindow), 0, (GInstanceInitFunc) preferences_window_instance_init, NULL };
	GType preferences_window_type_id;
	preferences_window_type_id = g_type_register_static (adw_preferences_window_get_type (), "PreferencesWindow", &g_define_type_info, 0);
	PreferencesWindow_private_offset = g_type_add_instance_private (preferences_window_type_id, sizeof (PreferencesWindowPrivate));
	return preferences_window_type_id;
}

GType
preferences_window_get_type (void)
{
	static volatile gsize preferences_window_type_id__once = 0;
	if (g_once_init_enter (&preferences_window_type_id__once)) {
		GType preferences_window_type_id;
		preferences_window_type_id = preferences_window_get_type_once ();
		g_once_init_leave (&preferences_window_type_id__once, preferences_window_type_id);
	}
	return preferences_window_type_id__once;
}

