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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
   This file is part of GNOME Reversi, also known as Iagno.

   Copyright 2010-2013 Robert Ancell
   Copyright 2013-2014 Michael Catanzaro
   Copyright 2014-2020 Arnaud Bonatti

   GNOME Reversi 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.

   GNOME Reversi is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNOME Reversi.  If not, see <https://www.gnu.org/licenses/>.
*/

#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <locale.h>
#include <stdio.h>
#include <gdk/gdk.h>

#define IAGNO_PROGRAM_NAME _ ("Reversi")
#define IAGNO_QUICK_MOVE_DELAY 0.4
#define IAGNO_MODERATE_MOVE_DELAY 1.7
#define IAGNO_SLOW_MOVE_DELAY 1.9
#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_IAGNO (iagno_get_type ())
#define IAGNO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IAGNO, Iagno))
#define IAGNO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IAGNO, IagnoClass))
#define IS_IAGNO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IAGNO))
#define IS_IAGNO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IAGNO))
#define IAGNO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IAGNO, IagnoClass))

typedef struct _Iagno Iagno;
typedef struct _IagnoClass IagnoClass;
typedef struct _IagnoPrivate IagnoPrivate;

#define TYPE_GAME_WINDOW (game_window_get_type ())
#define GAME_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GAME_WINDOW, GameWindow))
#define GAME_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GAME_WINDOW, GameWindowClass))
#define IS_GAME_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GAME_WINDOW))
#define IS_GAME_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GAME_WINDOW))
#define GAME_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GAME_WINDOW, GameWindowClass))

typedef struct _GameWindow GameWindow;
typedef struct _GameWindowClass GameWindowClass;

#define TYPE_REVERSI_VIEW (reversi_view_get_type ())
#define REVERSI_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_REVERSI_VIEW, ReversiView))
#define REVERSI_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_REVERSI_VIEW, ReversiViewClass))
#define IS_REVERSI_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_REVERSI_VIEW))
#define IS_REVERSI_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_REVERSI_VIEW))
#define REVERSI_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_REVERSI_VIEW, ReversiViewClass))

typedef struct _ReversiView ReversiView;
typedef struct _ReversiViewClass ReversiViewClass;

#define TYPE_THEME_MANAGER (theme_manager_get_type ())
#define THEME_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME_MANAGER, ThemeManager))
#define THEME_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME_MANAGER, ThemeManagerClass))
#define IS_THEME_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME_MANAGER))
#define IS_THEME_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME_MANAGER))
#define THEME_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME_MANAGER, ThemeManagerClass))

typedef struct _ThemeManager ThemeManager;
typedef struct _ThemeManagerClass ThemeManagerClass;

#define TYPE_COMPUTER_PLAYER (computer_player_get_type ())
#define COMPUTER_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_PLAYER, ComputerPlayer))
#define COMPUTER_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_PLAYER, ComputerPlayerClass))
#define IS_COMPUTER_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_PLAYER))
#define IS_COMPUTER_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_PLAYER))
#define COMPUTER_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_PLAYER, ComputerPlayerClass))

typedef struct _ComputerPlayer ComputerPlayer;
typedef struct _ComputerPlayerClass ComputerPlayerClass;
typedef enum  {
	PLAYER_NONE,
	PLAYER_DARK,
	PLAYER_LIGHT
} Player;

#define TYPE_PLAYER (player_get_type ())

#define TYPE_GAME (game_get_type ())
#define GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GAME, Game))
#define GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GAME, GameClass))
#define IS_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GAME))
#define IS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GAME))
#define GAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GAME, GameClass))

typedef struct _Game Game;
typedef struct _GameClass GameClass;
enum  {
	IAGNO_0_PROPERTY,
	IAGNO_COMPUTER_PROPERTY,
	IAGNO_PLAYER_ONE_PROPERTY,
	IAGNO_NUM_PROPERTIES
};
static GParamSpec* iagno_properties[IAGNO_NUM_PROPERTIES];
typedef enum  {
	IAGNO_SOUND_FLIP,
	IAGNO_SOUND_GAMEOVER
} IagnoSound;

#define IAGNO_TYPE_SOUND (iagno_sound_get_type ())
typedef enum  {
	IAGNO_SOUND_CONTEXT_STATE_INITIAL,
	IAGNO_SOUND_CONTEXT_STATE_WORKING,
	IAGNO_SOUND_CONTEXT_STATE_ERRORED
} IagnoSoundContextState;

#define IAGNO_TYPE_SOUND_CONTEXT_STATE (iagno_sound_context_state_get_type ())
typedef void (*GSimpleActionChangeStateCallback) (GSimpleAction* action, GVariant* value, gpointer user_data);
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))

#define TYPE_THEME (theme_get_type ())
#define THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME, Theme))
#define THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME, ThemeClass))
#define IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME))
#define IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME))
#define THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME, ThemeClass))

typedef struct _Theme Theme;
typedef struct _ThemeClass ThemeClass;
typedef struct _ThemePrivate ThemePrivate;
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef enum  {
	OPENING_HUMANS,
	OPENING_REVERSI,
	OPENING_INVERTED,
	OPENING_ALTER_TOP,
	OPENING_ALTER_LEFT,
	OPENING_ALTER_RIGHT,
	OPENING_ALTER_BOTTOM
} Opening;

#define TYPE_OPENING (opening_get_type ())

#define TYPE_COMPUTER_REVERSI (computer_reversi_get_type ())
#define COMPUTER_REVERSI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_REVERSI, ComputerReversi))
#define COMPUTER_REVERSI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_REVERSI, ComputerReversiClass))
#define IS_COMPUTER_REVERSI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_REVERSI))
#define IS_COMPUTER_REVERSI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_REVERSI))
#define COMPUTER_REVERSI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_REVERSI, ComputerReversiClass))

typedef struct _ComputerReversi ComputerReversi;
typedef struct _ComputerReversiClass ComputerReversiClass;

#define TYPE_COMPUTER_REVERSE_EASY (computer_reverse_easy_get_type ())
#define COMPUTER_REVERSE_EASY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_REVERSE_EASY, ComputerReverseEasy))
#define COMPUTER_REVERSE_EASY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_REVERSE_EASY, ComputerReverseEasyClass))
#define IS_COMPUTER_REVERSE_EASY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_REVERSE_EASY))
#define IS_COMPUTER_REVERSE_EASY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_REVERSE_EASY))
#define COMPUTER_REVERSE_EASY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_REVERSE_EASY, ComputerReverseEasyClass))

typedef struct _ComputerReverseEasy ComputerReverseEasy;
typedef struct _ComputerReverseEasyClass ComputerReverseEasyClass;

#define TYPE_COMPUTER_REVERSE_HARD (computer_reverse_hard_get_type ())
#define COMPUTER_REVERSE_HARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_REVERSE_HARD, ComputerReverseHard))
#define COMPUTER_REVERSE_HARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_REVERSE_HARD, ComputerReverseHardClass))
#define IS_COMPUTER_REVERSE_HARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_REVERSE_HARD))
#define IS_COMPUTER_REVERSE_HARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_REVERSE_HARD))
#define COMPUTER_REVERSE_HARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_REVERSE_HARD, ComputerReverseHardClass))

typedef struct _ComputerReverseHard ComputerReverseHard;
typedef struct _ComputerReverseHardClass ComputerReverseHardClass;

#define TYPE_COMPUTER_REVERSI_EASY (computer_reversi_easy_get_type ())
#define COMPUTER_REVERSI_EASY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_REVERSI_EASY, ComputerReversiEasy))
#define COMPUTER_REVERSI_EASY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_REVERSI_EASY, ComputerReversiEasyClass))
#define IS_COMPUTER_REVERSI_EASY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_REVERSI_EASY))
#define IS_COMPUTER_REVERSI_EASY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_REVERSI_EASY))
#define COMPUTER_REVERSI_EASY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_REVERSI_EASY, ComputerReversiEasyClass))

typedef struct _ComputerReversiEasy ComputerReversiEasy;
typedef struct _ComputerReversiEasyClass ComputerReversiEasyClass;

#define TYPE_COMPUTER_REVERSI_HARD (computer_reversi_hard_get_type ())
#define COMPUTER_REVERSI_HARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPUTER_REVERSI_HARD, ComputerReversiHard))
#define COMPUTER_REVERSI_HARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPUTER_REVERSI_HARD, ComputerReversiHardClass))
#define IS_COMPUTER_REVERSI_HARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPUTER_REVERSI_HARD))
#define IS_COMPUTER_REVERSI_HARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPUTER_REVERSI_HARD))
#define COMPUTER_REVERSI_HARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPUTER_REVERSI_HARD, ComputerReversiHardClass))

typedef struct _ComputerReversiHard ComputerReversiHard;
typedef struct _ComputerReversiHardClass ComputerReversiHardClass;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Iagno {
	AdwApplication parent_instance;
	IagnoPrivate * priv;
};

struct _IagnoClass {
	AdwApplicationClass parent_class;
};

struct _IagnoPrivate {
	GSettings* settings;
	GameWindow* window;
	ReversiView* view;
	ThemeManager* theme_manager;
	ComputerPlayer* _computer;
	Player _player_one;
	Game* game;
	gboolean game_is_set;
	GSimpleAction* alternate_who_starts_action;
	gboolean game_type_changed_1;
	gboolean game_type_changed_2;
	gboolean level_changed;
	GSimpleAction* change_level_action;
	gboolean first_player_is_human;
	GtkMediaFile* last_played;
};

struct _Theme {
	GObject parent_instance;
	ThemePrivate * priv;
	gchar* filename;
	gchar* name;
};

struct _ThemeClass {
	GObjectClass parent_class;
};

static gint Iagno_private_offset;
static gpointer iagno_parent_class = NULL;
static gboolean iagno_alternative_start;
static gboolean iagno_classic_game;
static gboolean iagno_fast_mode;
static gchar* iagno_level;
static gboolean iagno_print_logs;
static gboolean iagno_random_start;
static gboolean iagno_reverse_game;
static gint iagno_size;
static gboolean iagno_usual_start;
static gboolean iagno_fast_mode = FALSE;
static gboolean iagno_print_logs = FALSE;
static gboolean iagno_alternative_start = FALSE;
static gboolean iagno_random_start = FALSE;
static gboolean iagno_usual_start = FALSE;
static gboolean iagno_classic_game = FALSE;
static gboolean iagno_reverse_game = FALSE;
static gchar* iagno_level = NULL;
static gint iagno_size = 8;
static gboolean* iagno_sound;
static gboolean* iagno_sound = NULL;
static gboolean iagno_two_players;
static gboolean iagno_two_players = FALSE;
static gboolean* iagno_play_first;
static gboolean* iagno_play_first = NULL;

VALA_EXTERN GType iagno_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Iagno, g_object_unref)
VALA_EXTERN GType game_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GameWindow, g_object_unref)
VALA_EXTERN GType reversi_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ReversiView, g_object_unref)
VALA_EXTERN GType theme_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ThemeManager, g_object_unref)
VALA_EXTERN GType computer_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerPlayer, g_object_unref)
VALA_EXTERN GType player_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType game_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Game, g_object_unref)
static GType iagno_sound_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static GType iagno_sound_context_state_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void iagno_change_alternate_who_starts (Iagno* self,
                                        GSimpleAction* action,
                                        GVariant* gvariant);
static void _iagno_change_alternate_who_starts_gsimple_action_change_state_callback (GSimpleAction* action,
                                                                              GVariant* value,
                                                                              gpointer self);
static void iagno_change_game_type (Iagno* self,
                             GSimpleAction* action,
                             GVariant* gvariant);
static void _iagno_change_game_type_gsimple_action_activate_callback (GSimpleAction* action,
                                                               GVariant* parameter,
                                                               gpointer self);
static void iagno_change_level_cb (Iagno* self,
                            GSimpleAction* action,
                            GVariant* gvariant);
static void _iagno_change_level_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                              GVariant* parameter,
                                                              gpointer self);
static void iagno_set_use_night_mode (Iagno* self,
                               GSimpleAction* action,
                               GVariant* gvariant);
static void _iagno_set_use_night_mode_gsimple_action_activate_callback (GSimpleAction* action,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void iagno_help (Iagno* self);
static void _iagno_help_gsimple_action_activate_callback (GSimpleAction* action,
                                                   GVariant* parameter,
                                                   gpointer self);
static void iagno_about (Iagno* self);
static void _iagno_about_gsimple_action_activate_callback (GSimpleAction* action,
                                                    GVariant* parameter,
                                                    gpointer self);
static void _g_application_quit_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self);
VALA_EXTERN ThemeManager* theme_manager_new (void);
VALA_EXTERN ThemeManager* theme_manager_construct (GType object_type);
static gint iagno_main (gchar** args,
                 gint args_length1);
static Iagno* iagno_new (void);
static Iagno* iagno_construct (GType object_type);
static gint iagno_real_handle_local_options (GApplication* base,
                                      GVariantDict* options);
static gboolean* _bool_dup (gboolean* self);
static void iagno_real_startup (GApplication* base);
static void iagno_create_window (Iagno* self);
VALA_EXTERN ReversiView* reversi_view_new (Iagno* iagno_instance);
VALA_EXTERN ReversiView* reversi_view_construct (GType object_type,
                                     Iagno* iagno_instance);
static void iagno_player_move_cb (Iagno* self,
                           guint8 x,
                           guint8 y);
static void _iagno_player_move_cb_reversi_view_move (ReversiView* _sender,
                                              guint8 x,
                                              guint8 y,
                                              gpointer self);
static void iagno_clear_impossible_to_move_here_warning (Iagno* self);
static void _iagno_clear_impossible_to_move_here_warning_reversi_view_clear_impossible_to_move_here_warning (ReversiView* _sender,
                                                                                                      gpointer self);
VALA_EXTERN GType theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Theme, g_object_unref)
VALA_EXTERN GPtrArray* theme_manager_get_themes (ThemeManager* self);
VALA_EXTERN GameWindow* game_window_new (AdwApplication* app,
                             gboolean start_now,
                             GtkWidget* view_content,
                             GMenu* appearance_menu);
VALA_EXTERN GameWindow* game_window_construct (GType object_type,
                                   AdwApplication* app,
                                   gboolean start_now,
                                   GtkWidget* view_content,
                                   GMenu* appearance_menu);
VALA_EXTERN void game_window_update_level_menu (GameWindow* self,
                                    GMenu* menu);
static void __lambda15_ (Iagno* self,
                  gboolean undoing);
VALA_EXTERN void game_window_set_game_finished (GameWindow* self,
                                    gboolean finished);
static void ___lambda15__reversi_view_notify_final_animation (ReversiView* _sender,
                                                       gboolean undo,
                                                       gpointer self);
static void iagno_start_game (Iagno* self);
static void _iagno_start_game_game_window_play (GameWindow* _sender,
                                         gpointer self);
static void iagno_wait_cb (Iagno* self);
static void _iagno_wait_cb_game_window_wait (GameWindow* _sender,
                                      gpointer self);
static void iagno_back_cb (Iagno* self);
static void _iagno_back_cb_game_window_back (GameWindow* _sender,
                                      gpointer self);
static void iagno_undo_cb (Iagno* self);
static void _iagno_undo_cb_game_window_undo (GameWindow* _sender,
                                      gpointer self);
VALA_EXTERN void theme_manager_set_theme_name (ThemeManager* self,
                                   const gchar* value);
static void __lambda16_ (Iagno* self,
                  GSettings* _settings,
                  const gchar* key_name);
static void ___lambda16__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void __lambda17_ (Iagno* self);
static void iagno_update_level_button_state (Iagno* self,
                                      gint level);
static void ___lambda17__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void __lambda18_ (Iagno* self);
static void iagno_update_game_type_button_label (Iagno* self,
                                          const gchar* type);
static void ___lambda18__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void __lambda19_ (Iagno* self);
static void ___lambda19__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void iagno_real_activate (GApplication* base);
static void iagno_real_shutdown (GApplication* base);
VALA_EXTERN void game_window_update_game_type_label (GameWindow* self,
                                         const gchar* label);
VALA_EXTERN void game_window_update_level_sensitivity (GameWindow* self,
                                           gboolean new_sensitivity);
static void iagno_update_level_button_label (Iagno* self,
                                      guint8 level);
VALA_EXTERN void game_window_update_level_label (GameWindow* self,
                                     const gchar* label);
static void iagno_set_window_title (Iagno* self);
VALA_EXTERN Player game_get_current_color (Game* self);
VALA_EXTERN Player iagno_get_player_one (Iagno* self);
VALA_EXTERN ComputerPlayer* iagno_get_computer (Iagno* self);
VALA_EXTERN gboolean game_get_is_complete (Game* self);
VALA_EXTERN void computer_player_move (ComputerPlayer* self,
                           gdouble delay_seconds);
static void iagno_game_complete (Iagno* self,
                          gboolean play_gameover_sound);
VALA_EXTERN void computer_player_cancel_move (ComputerPlayer* self);
VALA_EXTERN GType opening_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Game* game_new (gboolean _reverse,
                Opening _opening,
                guint8 _size,
                gboolean _print_logs);
VALA_EXTERN Game* game_construct (GType object_type,
                      gboolean _reverse,
                      Opening _opening,
                      guint8 _size,
                      gboolean _print_logs);
static void iagno_turn_ended_cb (Iagno* self,
                          gboolean undoing,
                          gboolean no_draw);
static void _iagno_turn_ended_cb_game_turn_ended (Game* _sender,
                                           gboolean undoing,
                                           gboolean no_draw,
                                           gpointer self);
VALA_EXTERN void reversi_view_set_game (ReversiView* self,
                            Game* value);
VALA_EXTERN void game_window_set_player (GameWindow* self,
                             Player player);
static void iagno_set_computer (Iagno* self,
                         ComputerPlayer* value);
VALA_EXTERN ComputerReverseEasy* computer_reverse_easy_new (Game* game);
VALA_EXTERN ComputerReverseEasy* computer_reverse_easy_construct (GType object_type,
                                                      Game* game);
VALA_EXTERN GType computer_reversi_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerReversi, g_object_unref)
VALA_EXTERN GType computer_reverse_easy_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerReverseEasy, g_object_unref)
VALA_EXTERN ComputerReverseHard* computer_reverse_hard_new (Game* game,
                                                guint8 initial_depth,
                                                gboolean fixed_heuristic);
VALA_EXTERN ComputerReverseHard* computer_reverse_hard_construct (GType object_type,
                                                      Game* game,
                                                      guint8 initial_depth,
                                                      gboolean fixed_heuristic);
VALA_EXTERN GType computer_reverse_hard_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerReverseHard, g_object_unref)
VALA_EXTERN ComputerReversiEasy* computer_reversi_easy_new (Game* game);
VALA_EXTERN ComputerReversiEasy* computer_reversi_easy_construct (GType object_type,
                                                      Game* game);
VALA_EXTERN GType computer_reversi_easy_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerReversiEasy, g_object_unref)
VALA_EXTERN ComputerReversiHard* computer_reversi_hard_new (Game* game,
                                                guint8 initial_depth,
                                                gboolean fixed_heuristic);
VALA_EXTERN ComputerReversiHard* computer_reversi_hard_construct (GType object_type,
                                                      Game* game,
                                                      guint8 initial_depth,
                                                      gboolean fixed_heuristic);
VALA_EXTERN GType computer_reversi_hard_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ComputerReversiHard, g_object_unref)
static void iagno_set_player_one (Iagno* self,
                           Player value);
static void iagno_update_ui (Iagno* self);
VALA_EXTERN guint8 game_get_number_of_moves (Game* self);
VALA_EXTERN void game_window_new_turn_start (GameWindow* self,
                                 gboolean can_undo);
VALA_EXTERN gboolean reversi_view_undo_final_animation (ReversiView* self);
static void iagno_play_sound (Iagno* self,
                       IagnoSound sound);
VALA_EXTERN void game_undo (Game* self,
                guint8 count);
VALA_EXTERN gboolean game_get_current_player_can_move (Game* self);
static void iagno_update_scoreboard (Iagno* self);
static void iagno_prepare_move (Iagno* self);
static void iagno_pass (Iagno* self);
VALA_EXTERN gboolean game_pass (Game* self);
VALA_EXTERN void game_window_show_notification (GameWindow* self,
                                    const gchar* notification);
VALA_EXTERN void game_window_finish_game (GameWindow* self);
VALA_EXTERN gboolean game_get_reverse (Game* self);
VALA_EXTERN guint8 game_get_n_light_tiles (Game* self);
VALA_EXTERN guint8 game_get_n_dark_tiles (Game* self);
VALA_EXTERN gboolean game_place_tile (Game* self,
                          guint8 x,
                          guint8 y);
VALA_EXTERN Opening game_get_opening (Game* self);
VALA_EXTERN guint8 game_get_size (Game* self);
VALA_EXTERN void game_window_update_title (GameWindow* self,
                               const gchar* new_title);
VALA_EXTERN Theme* theme_manager_get_theme (ThemeManager* self);
VALA_EXTERN const gchar* theme_get_sound_flip (Theme* self);
VALA_EXTERN const gchar* theme_get_sound_gameover (Theme* self);
static void iagno_finalize (GObject * obj);
static GType iagno_get_type_once (void);
static void _vala_iagno_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec);
static void _vala_iagno_set_property (GObject * object,
                               guint property_id,
                               const GValue * value,
                               GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static const GOptionEntry IAGNO_option_entries[16] = {{"alternative-start", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_alternative_start, N_ ("Start with an alternative position"), NULL}, {"classic", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_classic_game, N_ ("Play Classic Reversi"), NULL}, {"fast-mode", 'f', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_fast_mode, N_ ("Reduce delay before AI moves"), NULL}, {"first", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Play first"), NULL}, {"level", 'l', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &iagno_level, N_ ("Set the level of the computer’s AI"), N_ ("LEVEL")}, {"mute", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Turn off the sound"), NULL}, {"print-logs", (gchar) 0, (gint) G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &iagno_print_logs, N_ ("Log the game moves"), NULL}, {"random-start", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_random_start, N_ ("Start with a random position"), NULL}, {"reverse", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_reverse_game, N_ ("Play Reverse Reversi"), NULL}, {"second", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Play second"), NULL}, {"size", 's', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_INT, &iagno_size, N_ ("Size of the board (debug only)"), N_ ("SIZE")}, {"two-players", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Two-players mode"), NULL}, {"unmute", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Turn on the sound"), NULL}, {"usual-start", (gchar) 0, (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &iagno_usual_start, N_ ("Start with the usual position"), NULL}, {"version", 'v', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Print release version and exit"), NULL}, {0}};
static const GActionEntry IAGNO_app_actions[7] = {{"alternate-who-starts", NULL, NULL, "false", _iagno_change_alternate_who_starts_gsimple_action_change_state_callback}, {"game-type", _iagno_change_game_type_gsimple_action_activate_callback, "s"}, {"change-level", _iagno_change_level_cb_gsimple_action_activate_callback, "s"}, {"set-use-night-mode", _iagno_set_use_night_mode_gsimple_action_activate_callback, "b"}, {"help", _iagno_help_gsimple_action_activate_callback}, {"about", _iagno_about_gsimple_action_activate_callback}, {"quit", _g_application_quit_gsimple_action_activate_callback}};

static inline gpointer
iagno_get_instance_private (Iagno* self)
{
	return G_STRUCT_MEMBER_P (self, Iagno_private_offset);
}

 G_GNUC_NO_INLINE static GType
iagno_sound_get_type_once (void)
{
	static const GEnumValue values[] = {{IAGNO_SOUND_FLIP, "IAGNO_SOUND_FLIP", "flip"}, {IAGNO_SOUND_GAMEOVER, "IAGNO_SOUND_GAMEOVER", "gameover"}, {0, NULL, NULL}};
	GType iagno_sound_type_id;
	iagno_sound_type_id = g_enum_register_static ("IagnoSound", values);
	return iagno_sound_type_id;
}

static GType
iagno_sound_get_type (void)
{
	static gsize iagno_sound_type_id__once = 0;
	if (g_once_init_enter (&iagno_sound_type_id__once)) {
		GType iagno_sound_type_id;
		iagno_sound_type_id = iagno_sound_get_type_once ();
		g_once_init_leave (&iagno_sound_type_id__once, iagno_sound_type_id);
	}
	return iagno_sound_type_id__once;
}

 G_GNUC_NO_INLINE static GType
iagno_sound_context_state_get_type_once (void)
{
	static const GEnumValue values[] = {{IAGNO_SOUND_CONTEXT_STATE_INITIAL, "IAGNO_SOUND_CONTEXT_STATE_INITIAL", "initial"}, {IAGNO_SOUND_CONTEXT_STATE_WORKING, "IAGNO_SOUND_CONTEXT_STATE_WORKING", "working"}, {IAGNO_SOUND_CONTEXT_STATE_ERRORED, "IAGNO_SOUND_CONTEXT_STATE_ERRORED", "errored"}, {0, NULL, NULL}};
	GType iagno_sound_context_state_type_id;
	iagno_sound_context_state_type_id = g_enum_register_static ("IagnoSoundContextState", values);
	return iagno_sound_context_state_type_id;
}

static GType
iagno_sound_context_state_get_type (void)
{
	static gsize iagno_sound_context_state_type_id__once = 0;
	if (g_once_init_enter (&iagno_sound_context_state_type_id__once)) {
		GType iagno_sound_context_state_type_id;
		iagno_sound_context_state_type_id = iagno_sound_context_state_get_type_once ();
		g_once_init_leave (&iagno_sound_context_state_type_id__once, iagno_sound_context_state_type_id);
	}
	return iagno_sound_context_state_type_id__once;
}

static void
_iagno_change_alternate_who_starts_gsimple_action_change_state_callback (GSimpleAction* action,
                                                                         GVariant* value,
                                                                         gpointer self)
{
	iagno_change_alternate_who_starts ((Iagno*) self, action, value);
}

static void
_iagno_change_game_type_gsimple_action_activate_callback (GSimpleAction* action,
                                                          GVariant* parameter,
                                                          gpointer self)
{
	iagno_change_game_type ((Iagno*) self, action, parameter);
}

static void
_iagno_change_level_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                         GVariant* parameter,
                                                         gpointer self)
{
	iagno_change_level_cb ((Iagno*) self, action, parameter);
}

static void
_iagno_set_use_night_mode_gsimple_action_activate_callback (GSimpleAction* action,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	iagno_set_use_night_mode ((Iagno*) self, action, parameter);
}

static void
_iagno_help_gsimple_action_activate_callback (GSimpleAction* action,
                                              GVariant* parameter,
                                              gpointer self)
{
	iagno_help ((Iagno*) self);
}

static void
_iagno_about_gsimple_action_activate_callback (GSimpleAction* action,
                                               GVariant* parameter,
                                               gpointer self)
{
	iagno_about ((Iagno*) self);
}

static void
_g_application_quit_gsimple_action_activate_callback (GSimpleAction* action,
                                                      GVariant* parameter,
                                                      gpointer self)
{
	g_application_quit ((GApplication*) self);
}

static gint
iagno_main (gchar** args,
            gint args_length1)
{
	Iagno* _tmp0_;
	Iagno* _tmp1_;
	gint _tmp2_;
	gint result;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	g_set_application_name (IAGNO_PROGRAM_NAME);
	adw_init ();
	_tmp0_ = iagno_new ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_application_run ((GApplication*) _tmp1_, (gint) args_length1, args);
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

int
main (int argc,
      char ** argv)
{
	return iagno_main (argv, argc);
}

static Iagno*
iagno_construct (GType object_type)
{
	Iagno * self = NULL;
	self = (Iagno*) g_object_new (object_type, "application-id", APP_ID, "flags", G_APPLICATION_FLAGS_NONE, NULL);
	g_application_add_main_option_entries ((GApplication*) self, IAGNO_option_entries);
	return self;
}

static Iagno*
iagno_new (void)
{
	return iagno_construct (TYPE_IAGNO);
}

static gboolean*
_bool_dup (gboolean* self)
{
	gboolean* dup;
	dup = g_new0 (gboolean, 1);
	memcpy (dup, self, sizeof (gboolean));
	return dup;
}

static gpointer
__bool_dup0 (gpointer self)
{
	return self ? _bool_dup (self) : NULL;
}

static gint
iagno_real_handle_local_options (GApplication* base,
                                 GVariantDict* options)
{
	Iagno * self;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gint result;
	self = (Iagno*) base;
	g_return_val_if_fail (options != NULL, -1);
	if (g_variant_dict_contains (options, "version")) {
		FILE* _tmp0_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "%1$s %2$s\n", "iagno", VERSION);
		result = EXIT_SUCCESS;
		return result;
	}
	if (iagno_usual_start) {
		_tmp3_ = iagno_random_start;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		gboolean _tmp4_ = FALSE;
		if (iagno_random_start) {
			_tmp4_ = iagno_alternative_start;
		} else {
			_tmp4_ = FALSE;
		}
		_tmp2_ = _tmp4_;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp5_ = FALSE;
		if (iagno_alternative_start) {
			_tmp5_ = iagno_usual_start;
		} else {
			_tmp5_ = FALSE;
		}
		_tmp1_ = _tmp5_;
	}
	if (_tmp1_) {
		FILE* _tmp6_;
		_tmp6_ = stderr;
		fprintf (_tmp6_, "%s\n", _ ("The “--alternative-start”, “--random-start” and “--usual-start” argume" \
"nts are mutually exclusive."));
		result = EXIT_FAILURE;
		return result;
	}
	if (iagno_classic_game) {
		_tmp7_ = iagno_reverse_game;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		FILE* _tmp8_;
		_tmp8_ = stderr;
		fprintf (_tmp8_, "%s\n", _ ("The “--classic” and “--reverse” arguments are mutually exclusive."));
		result = EXIT_FAILURE;
		return result;
	}
	if (iagno_size < 4) {
		FILE* _tmp9_;
		_tmp9_ = stderr;
		fprintf (_tmp9_, "%s\n", _ ("Size must be at least 4."));
		result = EXIT_FAILURE;
		return result;
	}
	if (iagno_size > 16) {
		FILE* _tmp10_;
		_tmp10_ = stderr;
		fprintf (_tmp10_, "%s\n", _ ("Size must not be more than 16."));
		result = EXIT_FAILURE;
		return result;
	}
	if (g_variant_dict_contains (options, "mute")) {
		gboolean _tmp11_;
		gboolean* _tmp12_;
		_tmp11_ = FALSE;
		_tmp12_ = __bool_dup0 (&_tmp11_);
		_g_free0 (iagno_sound);
		iagno_sound = _tmp12_;
	} else {
		if (g_variant_dict_contains (options, "unmute")) {
			gboolean _tmp13_;
			gboolean* _tmp14_;
			_tmp13_ = TRUE;
			_tmp14_ = __bool_dup0 (&_tmp13_);
			_g_free0 (iagno_sound);
			iagno_sound = _tmp14_;
		}
	}
	if (g_variant_dict_contains (options, "two-players")) {
		iagno_two_players = TRUE;
	} else {
		if (g_variant_dict_contains (options, "first")) {
			gboolean _tmp15_;
			gboolean* _tmp16_;
			_tmp15_ = TRUE;
			_tmp16_ = __bool_dup0 (&_tmp15_);
			_g_free0 (iagno_play_first);
			iagno_play_first = _tmp16_;
		} else {
			if (g_variant_dict_contains (options, "second")) {
				gboolean _tmp17_;
				gboolean* _tmp18_;
				_tmp17_ = FALSE;
				_tmp18_ = __bool_dup0 (&_tmp17_);
				_g_free0 (iagno_play_first);
				iagno_play_first = _tmp18_;
			}
		}
	}
	result = -1;
	return result;
}

static void
iagno_real_startup (GApplication* base)
{
	Iagno * self;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar* _tmp17_;
	gchar** _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* _tmp23_;
	gchar** _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	GSettings* _tmp26_;
	GAction* _tmp27_;
	GAction* _tmp28_;
	GSettings* _tmp29_;
	GAction* _tmp30_;
	GAction* _tmp31_;
	gboolean _tmp32_ = FALSE;
	gboolean _tmp33_ = FALSE;
	GSettings* _tmp37_;
	GAction* _tmp38_;
	GAction* _tmp39_;
	GSettings* _tmp40_;
	GAction* _tmp41_;
	GAction* _tmp42_;
	GtkCssProvider* css_provider = NULL;
	GtkCssProvider* _tmp43_;
	GdkDisplay* _tmp44_;
	self = (Iagno*) base;
	G_APPLICATION_CLASS (iagno_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp0_ = g_settings_new ("org.gnome.Reversi");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp0_;
	g_action_map_add_action_entries ((GActionMap*) self, IAGNO_app_actions, (gint) G_N_ELEMENTS (IAGNO_app_actions), self);
	_tmp1_ = g_strdup ("<Primary>n");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "ui.new-game", _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp4_ = g_strdup ("<Shift><Primary>n");
	_tmp5_ = g_new0 (gchar*, 1 + 1);
	_tmp5_[0] = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "ui.start-game", _tmp6_);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	_tmp7_ = g_strdup ("<Primary>q");
	_tmp8_ = g_strdup ("<Shift><Primary>q");
	_tmp9_ = g_new0 (gchar*, 2 + 1);
	_tmp9_[0] = _tmp7_;
	_tmp9_[1] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 2;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp10_);
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	_tmp11_ = g_strdup ("<Primary>z");
	_tmp12_ = g_new0 (gchar*, 1 + 1);
	_tmp12_[0] = _tmp11_;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "ui.undo", _tmp13_);
	_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) g_free), NULL);
	_tmp14_ = g_strdup ("Escape");
	_tmp15_ = g_new0 (gchar*, 1 + 1);
	_tmp15_[0] = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "base.escape", _tmp16_);
	_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
	_tmp17_ = g_strdup ("F10");
	_tmp18_ = g_new0 (gchar*, 1 + 1);
	_tmp18_[0] = _tmp17_;
	_tmp19_ = _tmp18_;
	_tmp19__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "base.toggle-hamburger", _tmp19_);
	_tmp19_ = (_vala_array_free (_tmp19_, _tmp19__length1, (GDestroyNotify) g_free), NULL);
	_tmp20_ = g_strdup ("F1");
	_tmp21_ = g_new0 (gchar*, 1 + 1);
	_tmp21_[0] = _tmp20_;
	_tmp22_ = _tmp21_;
	_tmp22__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.help", _tmp22_);
	_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_free), NULL);
	_tmp23_ = g_strdup ("<Shift>F1");
	_tmp24_ = g_new0 (gchar*, 1 + 1);
	_tmp24_[0] = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp25__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.about", _tmp25_);
	_tmp25_ = (_vala_array_free (_tmp25_, _tmp25__length1, (GDestroyNotify) g_free), NULL);
	_tmp26_ = self->priv->settings;
	_tmp27_ = g_settings_create_action (_tmp26_, "highlight-playable-tiles");
	_tmp28_ = _tmp27_;
	g_action_map_add_action ((GActionMap*) self, _tmp28_);
	_g_object_unref0 (_tmp28_);
	_tmp29_ = self->priv->settings;
	_tmp30_ = g_settings_create_action (_tmp29_, "highlight-turnable-tiles");
	_tmp31_ = _tmp30_;
	g_action_map_add_action ((GActionMap*) self, _tmp31_);
	_g_object_unref0 (_tmp31_);
	if (!iagno_alternative_start) {
		_tmp33_ = !iagno_random_start;
	} else {
		_tmp33_ = FALSE;
	}
	if (_tmp33_) {
		_tmp32_ = !iagno_usual_start;
	} else {
		_tmp32_ = FALSE;
	}
	if (_tmp32_) {
		GSettings* _tmp34_;
		GAction* _tmp35_;
		GAction* _tmp36_;
		_tmp34_ = self->priv->settings;
		_tmp35_ = g_settings_create_action (_tmp34_, "random-start-position");
		_tmp36_ = _tmp35_;
		g_action_map_add_action ((GActionMap*) self, _tmp36_);
		_g_object_unref0 (_tmp36_);
	}
	_tmp37_ = self->priv->settings;
	_tmp38_ = g_settings_create_action (_tmp37_, "sound");
	_tmp39_ = _tmp38_;
	g_action_map_add_action ((GActionMap*) self, _tmp39_);
	_g_object_unref0 (_tmp39_);
	_tmp40_ = self->priv->settings;
	_tmp41_ = g_settings_create_action (_tmp40_, "theme");
	_tmp42_ = _tmp41_;
	g_action_map_add_action ((GActionMap*) self, _tmp42_);
	_g_object_unref0 (_tmp42_);
	_tmp43_ = gtk_css_provider_new ();
	css_provider = _tmp43_;
	gtk_css_provider_load_from_resource (css_provider, "/org/gnome/Reversi/ui/style.css");
	_tmp44_ = gdk_display_get_default ();
	gtk_style_context_add_provider_for_display (G_TYPE_CHECK_INSTANCE_CAST (_tmp44_, gdk_display_get_type (), GdkDisplay), (GtkStyleProvider*) css_provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_g_object_unref0 (css_provider);
}

static void
_iagno_player_move_cb_reversi_view_move (ReversiView* _sender,
                                         guint8 x,
                                         guint8 y,
                                         gpointer self)
{
	iagno_player_move_cb ((Iagno*) self, x, y);
}

static void
_iagno_clear_impossible_to_move_here_warning_reversi_view_clear_impossible_to_move_here_warning (ReversiView* _sender,
                                                                                                 gpointer self)
{
	iagno_clear_impossible_to_move_here_warning ((Iagno*) self);
}

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

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
__lambda15_ (Iagno* self,
             gboolean undoing)
{
	GameWindow* _tmp0_;
	_tmp0_ = self->priv->window;
	game_window_set_game_finished (_tmp0_, !undoing);
}

static void
___lambda15__reversi_view_notify_final_animation (ReversiView* _sender,
                                                  gboolean undo,
                                                  gpointer self)
{
	__lambda15_ ((Iagno*) self, undo);
}

static void
_iagno_start_game_game_window_play (GameWindow* _sender,
                                    gpointer self)
{
	iagno_start_game ((Iagno*) self);
}

static void
_iagno_wait_cb_game_window_wait (GameWindow* _sender,
                                 gpointer self)
{
	iagno_wait_cb ((Iagno*) self);
}

static void
_iagno_back_cb_game_window_back (GameWindow* _sender,
                                 gpointer self)
{
	iagno_back_cb ((Iagno*) self);
}

static void
_iagno_undo_cb_game_window_undo (GameWindow* _sender,
                                 gpointer self)
{
	iagno_undo_cb ((Iagno*) self);
}

static void
__lambda16_ (Iagno* self,
             GSettings* _settings,
             const gchar* key_name)
{
	GSimpleAction* _tmp0_;
	GVariant* _tmp1_;
	GVariant* _tmp2_;
	g_return_if_fail (_settings != NULL);
	g_return_if_fail (key_name != NULL);
	_tmp0_ = self->priv->alternate_who_starts_action;
	_tmp1_ = g_settings_get_value (_settings, key_name);
	_tmp2_ = _tmp1_;
	g_simple_action_set_state (_tmp0_, _tmp2_);
	_g_variant_unref0 (_tmp2_);
}

static void
___lambda16__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda16_ ((Iagno*) self, _sender, key);
}

static void
__lambda17_ (Iagno* self)
{
	if (self->priv->level_changed) {
		self->priv->level_changed = FALSE;
	} else {
		GSettings* _tmp0_;
		_tmp0_ = self->priv->settings;
		if (g_settings_get_int (_tmp0_, "num-players") == 1) {
			GSettings* _tmp1_;
			_tmp1_ = self->priv->settings;
			iagno_update_level_button_state (self, g_settings_get_int (_tmp1_, "computer-level"));
		}
	}
}

static void
___lambda17__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda17_ ((Iagno*) self);
}

static void
__lambda18_ (Iagno* self)
{
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	if (self->priv->game_type_changed_1) {
		self->priv->game_type_changed_1 = FALSE;
		return;
	}
	_tmp0_ = self->priv->settings;
	if (g_settings_get_int (_tmp0_, "num-players") == 2) {
		return;
	}
	_tmp1_ = self->priv->settings;
	_tmp2_ = g_settings_get_string (_tmp1_, "color");
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strcmp0 (_tmp3_, "dark") == 0;
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		iagno_update_game_type_button_label (self, "dark");
	} else {
		iagno_update_game_type_button_label (self, "light");
	}
}

static void
___lambda18__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda18_ ((Iagno*) self);
}

static void
__lambda19_ (Iagno* self)
{
	GSettings* _tmp0_;
	if (self->priv->game_type_changed_2) {
		self->priv->game_type_changed_2 = FALSE;
		return;
	}
	_tmp0_ = self->priv->settings;
	if (g_settings_get_int (_tmp0_, "num-players") == 2) {
		iagno_update_level_button_state (self, 0);
		iagno_update_game_type_button_label (self, "two");
	} else {
		GSettings* _tmp1_;
		GSettings* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gboolean _tmp5_;
		_tmp1_ = self->priv->settings;
		iagno_update_level_button_state (self, g_settings_get_int (_tmp1_, "computer-level"));
		_tmp2_ = self->priv->settings;
		_tmp3_ = g_settings_get_string (_tmp2_, "color");
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strcmp0 (_tmp4_, "dark") == 0;
		_g_free0 (_tmp4_);
		if (_tmp5_) {
			iagno_update_game_type_button_label (self, "dark");
		} else {
			iagno_update_game_type_button_label (self, "light");
		}
	}
}

static void
___lambda19__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda19_ ((Iagno*) self);
}

static void
iagno_create_window (Iagno* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean start_now = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean* _tmp6_;
	ReversiView* _tmp30_;
	ReversiView* _tmp31_;
	ReversiView* _tmp32_;
	GMenu* level_menu = NULL;
	GMenu* _tmp33_;
	GMenu* section = NULL;
	GMenu* _tmp34_;
	GMenu* _tmp35_;
	GMenu* _tmp36_;
	GMenu* _tmp37_;
	GMenu* _tmp38_;
	GMenu* _tmp39_;
	GMenu* _tmp40_;
	gboolean _tmp41_ = FALSE;
	gboolean _tmp42_ = FALSE;
	GMenu* _tmp48_;
	GMenu* appearance_menu = NULL;
	GMenu* _tmp49_;
	GMenu* _tmp50_;
	GMenu* _tmp51_;
	ThemeManager* _tmp52_;
	GPtrArray* _tmp53_;
	GMenu* _tmp63_;
	GMenu* _tmp64_;
	GMenu* _tmp65_;
	GMenu* _tmp66_;
	GMenu* _tmp67_;
	GMenu* _tmp68_;
	GMenu* _tmp69_;
	GMenu* _tmp70_;
	GMenu* _tmp71_;
	GMenu* _tmp72_;
	ReversiView* _tmp73_;
	GMenu* _tmp74_;
	GameWindow* _tmp75_;
	GameWindow* _tmp76_;
	GMenu* _tmp77_;
	ReversiView* _tmp78_;
	GameWindow* _tmp79_;
	GameWindow* _tmp80_;
	GameWindow* _tmp81_;
	GameWindow* _tmp82_;
	GSettings* _tmp83_;
	ReversiView* _tmp84_;
	GSettings* _tmp85_;
	ReversiView* _tmp86_;
	GSettings* _tmp87_;
	ThemeManager* _tmp88_;
	ThemeManager* _tmp89_;
	GameWindow* _tmp90_;
	ThemeManager* _tmp91_;
	ReversiView* _tmp92_;
	gchar* wanted_theme_id = NULL;
	GSettings* _tmp93_;
	gchar* _tmp94_;
	gboolean theme_name_found = FALSE;
	ThemeManager* _tmp95_;
	GPtrArray* _tmp96_;
	gboolean _tmp103_ = FALSE;
	GAction* _tmp110_;
	GSimpleAction* _tmp111_;
	GAction* _tmp112_;
	GSimpleAction* _tmp113_;
	GSettings* _tmp114_;
	GSimpleAction* _tmp115_;
	GSettings* _tmp116_;
	GVariant* _tmp117_;
	GVariant* _tmp118_;
	GSettings* _tmp119_;
	GSettings* _tmp120_;
	GSettings* _tmp121_;
	GSettings* _tmp122_;
	GameWindow* _tmp129_;
	g_return_if_fail (self != NULL);
	if (iagno_two_players == TRUE) {
		_tmp0_ = TRUE;
	} else {
		gboolean* _tmp1_;
		_tmp1_ = iagno_play_first;
		_tmp0_ = _tmp1_ != NULL;
	}
	start_now = _tmp0_;
	_tmp6_ = iagno_sound;
	if (_tmp6_ != NULL) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = start_now;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = iagno_level;
		_tmp4_ = _tmp7_ != NULL;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = iagno_classic_game;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = iagno_reverse_game;
	}
	if (_tmp2_) {
		GSettings* _tmp8_;
		gboolean* _tmp11_;
		gboolean* _tmp16_;
		const gchar* _tmp20_;
		GSettings* _tmp29_;
		_tmp8_ = self->priv->settings;
		g_settings_delay (_tmp8_);
		if (iagno_classic_game) {
			GSettings* _tmp9_;
			_tmp9_ = self->priv->settings;
			g_settings_set_string (_tmp9_, "type", "classic");
		} else {
			if (iagno_reverse_game) {
				GSettings* _tmp10_;
				_tmp10_ = self->priv->settings;
				g_settings_set_string (_tmp10_, "type", "reverse");
			}
		}
		_tmp11_ = iagno_sound;
		if (_tmp11_ != NULL) {
			GSettings* _tmp12_;
			gboolean* _tmp13_;
			_tmp12_ = self->priv->settings;
			_tmp13_ = iagno_sound;
			g_settings_set_boolean (_tmp12_, "sound", (gboolean) (*_tmp13_));
		}
		if (start_now) {
			gint _tmp14_ = 0;
			GSettings* _tmp15_;
			if (iagno_two_players) {
				_tmp14_ = 2;
			} else {
				_tmp14_ = 1;
			}
			_tmp15_ = self->priv->settings;
			g_settings_set_int (_tmp15_, "num-players", _tmp14_);
		}
		_tmp16_ = iagno_play_first;
		if (_tmp16_ != NULL) {
			const gchar* _tmp17_ = NULL;
			gboolean* _tmp18_;
			GSettings* _tmp19_;
			_tmp18_ = iagno_play_first;
			if ((gboolean) (*_tmp18_)) {
				_tmp17_ = "dark";
			} else {
				_tmp17_ = "light";
			}
			_tmp19_ = self->priv->settings;
			g_settings_set_string (_tmp19_, "color", _tmp17_);
		}
		_tmp20_ = iagno_level;
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			const gchar* _tmp22_;
			GQuark _tmp24_ = 0U;
			static GQuark _tmp23_label0 = 0;
			static GQuark _tmp23_label1 = 0;
			static GQuark _tmp23_label2 = 0;
			static GQuark _tmp23_label3 = 0;
			static GQuark _tmp23_label4 = 0;
			static GQuark _tmp23_label5 = 0;
			static GQuark _tmp23_label6 = 0;
			static GQuark _tmp23_label7 = 0;
			static GQuark _tmp23_label8 = 0;
			_tmp21_ = iagno_level;
			_tmp22_ = (const gchar*) _tmp21_;
			_tmp24_ = (NULL == _tmp22_) ? 0 : g_quark_from_string (_tmp22_);
			if (((_tmp24_ == ((0 != _tmp23_label0) ? _tmp23_label0 : (_tmp23_label0 = g_quark_from_static_string ("1")))) || (_tmp24_ == ((0 != _tmp23_label1) ? _tmp23_label1 : (_tmp23_label1 = g_quark_from_static_string ("easy"))))) || (_tmp24_ == ((0 != _tmp23_label2) ? _tmp23_label2 : (_tmp23_label2 = g_quark_from_static_string ("one"))))) {
				switch (0) {
					default:
					{
						GSettings* _tmp25_;
						_tmp25_ = self->priv->settings;
						g_settings_set_int (_tmp25_, "computer-level", 1);
						break;
					}
				}
			} else if (((_tmp24_ == ((0 != _tmp23_label3) ? _tmp23_label3 : (_tmp23_label3 = g_quark_from_static_string ("2")))) || (_tmp24_ == ((0 != _tmp23_label4) ? _tmp23_label4 : (_tmp23_label4 = g_quark_from_static_string ("medium"))))) || (_tmp24_ == ((0 != _tmp23_label5) ? _tmp23_label5 : (_tmp23_label5 = g_quark_from_static_string ("two"))))) {
				switch (0) {
					default:
					{
						GSettings* _tmp26_;
						_tmp26_ = self->priv->settings;
						g_settings_set_int (_tmp26_, "computer-level", 2);
						break;
					}
				}
			} else if (((_tmp24_ == ((0 != _tmp23_label6) ? _tmp23_label6 : (_tmp23_label6 = g_quark_from_static_string ("3")))) || (_tmp24_ == ((0 != _tmp23_label7) ? _tmp23_label7 : (_tmp23_label7 = g_quark_from_static_string ("hard"))))) || (_tmp24_ == ((0 != _tmp23_label8) ? _tmp23_label8 : (_tmp23_label8 = g_quark_from_static_string ("three"))))) {
				switch (0) {
					default:
					{
						GSettings* _tmp27_;
						_tmp27_ = self->priv->settings;
						g_settings_set_int (_tmp27_, "computer-level", 3);
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						FILE* _tmp28_;
						_tmp28_ = stderr;
						fprintf (_tmp28_, "%s\n", _ ("Level should be between 1 (easy) and 3 (hard). Settings unchanged."));
						break;
					}
				}
			}
		}
		_tmp29_ = self->priv->settings;
		g_settings_apply (_tmp29_);
	}
	_tmp30_ = reversi_view_new (self);
	g_object_ref_sink (_tmp30_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp30_;
	_tmp31_ = self->priv->view;
	g_signal_connect_object (_tmp31_, "move", (GCallback) _iagno_player_move_cb_reversi_view_move, self, 0);
	_tmp32_ = self->priv->view;
	g_signal_connect_object (_tmp32_, "clear-impossible-to-move-here-warning", (GCallback) _iagno_clear_impossible_to_move_here_warning_reversi_view_clear_impossible_to_move_here_warning, self, 0);
	_tmp33_ = g_menu_new ();
	level_menu = _tmp33_;
	_tmp34_ = g_menu_new ();
	section = _tmp34_;
	_tmp35_ = level_menu;
	g_menu_append (_tmp35_, _ ("_Easy"), "app.change-level('1')");
	_tmp36_ = level_menu;
	g_menu_append (_tmp36_, _ ("_Medium"), "app.change-level('2')");
	_tmp37_ = level_menu;
	g_menu_append (_tmp37_, _ ("_Hard"), "app.change-level('3')");
	_tmp38_ = section;
	g_menu_freeze (_tmp38_);
	_tmp39_ = level_menu;
	_tmp40_ = section;
	g_menu_append_section (_tmp39_, NULL, (GMenuModel*) _tmp40_);
	if (!iagno_alternative_start) {
		_tmp42_ = !iagno_random_start;
	} else {
		_tmp42_ = FALSE;
	}
	if (_tmp42_) {
		_tmp41_ = !iagno_usual_start;
	} else {
		_tmp41_ = FALSE;
	}
	if (_tmp41_) {
		GMenu* _tmp43_;
		GMenu* _tmp44_;
		GMenu* _tmp45_;
		GMenu* _tmp46_;
		GMenu* _tmp47_;
		_tmp43_ = g_menu_new ();
		_g_object_unref0 (section);
		section = _tmp43_;
		_tmp44_ = section;
		g_menu_append (_tmp44_, _ ("_Vary start position"), "app.random-start-position");
		_tmp45_ = section;
		g_menu_freeze (_tmp45_);
		_tmp46_ = level_menu;
		_tmp47_ = section;
		g_menu_append_section (_tmp46_, NULL, (GMenuModel*) _tmp47_);
	}
	_tmp48_ = level_menu;
	g_menu_freeze (_tmp48_);
	_tmp49_ = g_menu_new ();
	appearance_menu = _tmp49_;
	_tmp50_ = g_menu_new ();
	_g_object_unref0 (section);
	section = _tmp50_;
	_tmp51_ = section;
	g_menu_append (_tmp51_, _ ("Default"), "app.theme('default')");
	_tmp52_ = self->priv->theme_manager;
	_tmp53_ = theme_manager_get_themes (_tmp52_);
	{
		GPtrArray* theme_collection = NULL;
		guint theme_index = 0U;
		theme_collection = _tmp53_;
		for (theme_index = 0; theme_index < theme_collection->len; theme_index = theme_index + 1) {
			Theme* _tmp54_;
			Theme* theme = NULL;
			_tmp54_ = _g_object_ref0 ((Theme*) g_ptr_array_index (theme_collection, theme_index));
			theme = _tmp54_;
			{
				GMenu* _tmp55_;
				Theme* _tmp56_;
				const gchar* _tmp57_;
				Theme* _tmp58_;
				const gchar* _tmp59_;
				const gchar* _tmp60_;
				gchar* _tmp61_;
				gchar* _tmp62_;
				_tmp55_ = section;
				_tmp56_ = theme;
				_tmp57_ = _tmp56_->name;
				_tmp58_ = theme;
				_tmp59_ = _tmp58_->filename;
				_tmp60_ = string_to_string ((const gchar*) _tmp59_);
				_tmp61_ = g_strconcat ("app.theme('", _tmp60_, "')", NULL);
				_tmp62_ = _tmp61_;
				g_menu_append (_tmp55_, _tmp57_, _tmp62_);
				_g_free0 (_tmp62_);
				_g_object_unref0 (theme);
			}
		}
		_g_ptr_array_unref0 (theme_collection);
	}
	_tmp63_ = section;
	g_menu_freeze (_tmp63_);
	_tmp64_ = appearance_menu;
	_tmp65_ = section;
	g_menu_append_section (_tmp64_, NULL, (GMenuModel*) _tmp65_);
	_tmp66_ = g_menu_new ();
	_g_object_unref0 (section);
	section = _tmp66_;
	_tmp67_ = section;
	g_menu_append (_tmp67_, _ ("Pla_yable tiles"), "app.highlight-playable-tiles");
	_tmp68_ = section;
	g_menu_append (_tmp68_, _ ("_Capturable tiles"), "app.highlight-turnable-tiles");
	_tmp69_ = section;
	g_menu_freeze (_tmp69_);
	_tmp70_ = appearance_menu;
	_tmp71_ = section;
	g_menu_append_section (_tmp70_, _ ("Highlights"), (GMenuModel*) _tmp71_);
	_tmp72_ = appearance_menu;
	g_menu_freeze (_tmp72_);
	_tmp73_ = self->priv->view;
	_tmp74_ = appearance_menu;
	_tmp75_ = game_window_new ((AdwApplication*) self, start_now, (GtkWidget*) _tmp73_, _tmp74_);
	g_object_ref_sink (_tmp75_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp75_;
	_tmp76_ = self->priv->window;
	_tmp77_ = level_menu;
	game_window_update_level_menu (_tmp76_, _tmp77_);
	_tmp78_ = self->priv->view;
	g_signal_connect_object (_tmp78_, "notify-final-animation", (GCallback) ___lambda15__reversi_view_notify_final_animation, self, 0);
	_tmp79_ = self->priv->window;
	g_signal_connect_object (_tmp79_, "play", (GCallback) _iagno_start_game_game_window_play, self, 0);
	_tmp80_ = self->priv->window;
	g_signal_connect_object (_tmp80_, "wait", (GCallback) _iagno_wait_cb_game_window_wait, self, 0);
	_tmp81_ = self->priv->window;
	g_signal_connect_object (_tmp81_, "back", (GCallback) _iagno_back_cb_game_window_back, self, 0);
	_tmp82_ = self->priv->window;
	g_signal_connect_object (_tmp82_, "undo", (GCallback) _iagno_undo_cb_game_window_undo, self, 0);
	_tmp83_ = self->priv->settings;
	_tmp84_ = self->priv->view;
	g_settings_bind (_tmp83_, "highlight-playable-tiles", (GObject*) _tmp84_, "show-playable-tiles", G_SETTINGS_BIND_GET);
	_tmp85_ = self->priv->settings;
	_tmp86_ = self->priv->view;
	g_settings_bind (_tmp85_, "highlight-turnable-tiles", (GObject*) _tmp86_, "show-turnable-tiles", G_SETTINGS_BIND_GET);
	_tmp87_ = self->priv->settings;
	_tmp88_ = self->priv->theme_manager;
	g_settings_bind (_tmp87_, "theme", (GObject*) _tmp88_, "theme-name", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
	_tmp89_ = self->priv->theme_manager;
	_tmp90_ = self->priv->window;
	g_object_bind_property_with_closures ((GObject*) _tmp89_, "theme", (GObject*) _tmp90_, "theme", 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)));
	_tmp91_ = self->priv->theme_manager;
	_tmp92_ = self->priv->view;
	g_object_bind_property_with_closures ((GObject*) _tmp91_, "theme", (GObject*) _tmp92_, "theme", 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)));
	_tmp93_ = self->priv->settings;
	_tmp94_ = g_settings_get_string (_tmp93_, "theme");
	wanted_theme_id = _tmp94_;
	theme_name_found = FALSE;
	_tmp95_ = self->priv->theme_manager;
	_tmp96_ = theme_manager_get_themes (_tmp95_);
	{
		GPtrArray* theme_collection = NULL;
		guint theme_index = 0U;
		theme_collection = _tmp96_;
		for (theme_index = 0; theme_index < theme_collection->len; theme_index = theme_index + 1) {
			Theme* _tmp97_;
			Theme* theme = NULL;
			_tmp97_ = _g_object_ref0 ((Theme*) g_ptr_array_index (theme_collection, theme_index));
			theme = _tmp97_;
			{
				const gchar* _tmp98_;
				Theme* _tmp99_;
				const gchar* _tmp100_;
				_tmp98_ = wanted_theme_id;
				_tmp99_ = theme;
				_tmp100_ = _tmp99_->filename;
				if (g_strcmp0 (_tmp98_, _tmp100_) == 0) {
					ThemeManager* _tmp101_;
					const gchar* _tmp102_;
					theme_name_found = TRUE;
					_tmp101_ = self->priv->theme_manager;
					_tmp102_ = wanted_theme_id;
					theme_manager_set_theme_name (_tmp101_, _tmp102_);
				}
				_g_object_unref0 (theme);
			}
		}
		_g_ptr_array_unref0 (theme_collection);
	}
	if (!theme_name_found) {
		const gchar* _tmp104_;
		_tmp104_ = wanted_theme_id;
		_tmp103_ = g_strcmp0 (_tmp104_, "default") != 0;
	} else {
		_tmp103_ = FALSE;
	}
	if (_tmp103_) {
		const gchar* _tmp105_;
		const gchar* _tmp106_;
		gchar* _tmp107_;
		gchar* _tmp108_;
		GSettings* _tmp109_;
		_tmp105_ = wanted_theme_id;
		_tmp106_ = string_to_string (_tmp105_);
		_tmp107_ = g_strconcat ("Theme ", _tmp106_, " not found, using default.", NULL);
		_tmp108_ = _tmp107_;
		g_warning ("iagno.vala:379: %s", _tmp108_);
		_g_free0 (_tmp108_);
		_tmp109_ = self->priv->settings;
		g_settings_set_string (_tmp109_, "theme", "default");
	}
	_tmp110_ = g_action_map_lookup_action ((GActionMap*) self, "alternate-who-starts");
	_tmp111_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp110_, g_simple_action_get_type (), GSimpleAction));
	_g_object_unref0 (self->priv->alternate_who_starts_action);
	self->priv->alternate_who_starts_action = _tmp111_;
	_tmp112_ = g_action_map_lookup_action ((GActionMap*) self, "change-level");
	_tmp113_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp112_, g_simple_action_get_type (), GSimpleAction));
	_g_object_unref0 (self->priv->change_level_action);
	self->priv->change_level_action = _tmp113_;
	_tmp114_ = self->priv->settings;
	g_signal_connect_object (_tmp114_, "changed::alternate-who-starts", (GCallback) ___lambda16__g_settings_changed, self, 0);
	_tmp115_ = self->priv->alternate_who_starts_action;
	_tmp116_ = self->priv->settings;
	_tmp117_ = g_settings_get_value (_tmp116_, "alternate-who-starts");
	_tmp118_ = _tmp117_;
	g_simple_action_set_state (_tmp115_, _tmp118_);
	_g_variant_unref0 (_tmp118_);
	_tmp119_ = self->priv->settings;
	g_signal_connect_object (_tmp119_, "changed::computer-level", (GCallback) ___lambda17__g_settings_changed, self, 0);
	_tmp120_ = self->priv->settings;
	g_signal_connect_object (_tmp120_, "changed::color", (GCallback) ___lambda18__g_settings_changed, self, 0);
	_tmp121_ = self->priv->settings;
	g_signal_connect_object (_tmp121_, "changed::num-players", (GCallback) ___lambda19__g_settings_changed, self, 0);
	_tmp122_ = self->priv->settings;
	if (g_settings_get_int (_tmp122_, "num-players") == 2) {
		GSimpleAction* _tmp123_;
		iagno_update_level_button_state (self, 0);
		iagno_update_game_type_button_label (self, "two");
		_tmp123_ = self->priv->alternate_who_starts_action;
		g_simple_action_set_enabled (_tmp123_, FALSE);
	} else {
		GSettings* _tmp124_;
		GSettings* _tmp125_;
		gchar* _tmp126_;
		gchar* _tmp127_;
		gboolean _tmp128_;
		_tmp124_ = self->priv->settings;
		iagno_update_level_button_state (self, g_settings_get_int (_tmp124_, "computer-level"));
		_tmp125_ = self->priv->settings;
		_tmp126_ = g_settings_get_string (_tmp125_, "color");
		_tmp127_ = _tmp126_;
		_tmp128_ = g_strcmp0 (_tmp127_, "dark") == 0;
		_g_free0 (_tmp127_);
		if (_tmp128_) {
			iagno_update_game_type_button_label (self, "dark");
		} else {
			iagno_update_game_type_button_label (self, "light");
		}
	}
	if (start_now) {
		iagno_start_game (self);
	}
	_tmp129_ = self->priv->window;
	gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) _tmp129_);
	_g_free0 (wanted_theme_id);
	_g_object_unref0 (appearance_menu);
	_g_object_unref0 (section);
	_g_object_unref0 (level_menu);
}

static void
iagno_real_activate (GApplication* base)
{
	Iagno * self;
	GtkWindow* _tmp0_;
	GameWindow* _tmp1_;
	self = (Iagno*) base;
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	if (_tmp0_ == NULL) {
		iagno_create_window (self);
	}
	_tmp1_ = self->priv->window;
	gtk_window_present ((GtkWindow*) _tmp1_);
}

static void
iagno_real_shutdown (GApplication* base)
{
	Iagno * self;
	GtkWindow* _tmp0_;
	self = (Iagno*) base;
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	if (_tmp0_ != NULL) {
		GameWindow* _tmp1_;
		_tmp1_ = self->priv->window;
		gtk_window_destroy ((GtkWindow*) _tmp1_);
	}
	G_APPLICATION_CLASS (iagno_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
}

static void
iagno_set_use_night_mode (Iagno* self,
                          GSimpleAction* action,
                          GVariant* gvariant)
{
	AdwStyleManager* style_manager = NULL;
	AdwStyleManager* _tmp0_;
	AdwStyleManager* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_vala_return_if_fail (gvariant != NULL, "gvariant != null");
	_tmp0_ = adw_style_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	style_manager = _tmp1_;
	if (g_variant_get_boolean ((GVariant*) gvariant)) {
		AdwStyleManager* _tmp2_;
		_tmp2_ = style_manager;
		adw_style_manager_set_color_scheme (_tmp2_, ADW_COLOR_SCHEME_PREFER_DARK);
	} else {
		AdwStyleManager* _tmp3_;
		_tmp3_ = style_manager;
		adw_style_manager_set_color_scheme (_tmp3_, ADW_COLOR_SCHEME_FORCE_LIGHT);
	}
	_g_object_unref0 (style_manager);
}

static void
iagno_change_alternate_who_starts (Iagno* self,
                                   GSimpleAction* action,
                                   GVariant* gvariant)
{
	GSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_vala_return_if_fail (gvariant != NULL, "gvariant != null");
	_tmp0_ = self->priv->settings;
	g_settings_set_value (_tmp0_, "alternate-who-starts", (GVariant*) gvariant);
}

static void
iagno_change_game_type (Iagno* self,
                        GSimpleAction* action,
                        GVariant* gvariant)
{
	gchar* type = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	GQuark _tmp6_ = 0U;
	static GQuark _tmp5_label0 = 0;
	static GQuark _tmp5_label1 = 0;
	static GQuark _tmp5_label2 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_vala_return_if_fail (gvariant != NULL, "gvariant != null");
	_tmp0_ = g_variant_get_string ((GVariant*) gvariant, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	type = _tmp1_;
	_tmp2_ = type;
	iagno_update_game_type_button_label (self, _tmp2_);
	self->priv->game_type_changed_1 = TRUE;
	self->priv->game_type_changed_2 = TRUE;
	_tmp3_ = type;
	_tmp4_ = _tmp3_;
	_tmp6_ = (NULL == _tmp4_) ? 0 : g_quark_from_string (_tmp4_);
	if (_tmp6_ == ((0 != _tmp5_label0) ? _tmp5_label0 : (_tmp5_label0 = g_quark_from_static_string ("two")))) {
		switch (0) {
			default:
			{
				GSettings* _tmp7_;
				GSimpleAction* _tmp8_;
				_tmp7_ = self->priv->settings;
				g_settings_set_int (_tmp7_, "num-players", 2);
				iagno_update_level_button_state (self, 0);
				_tmp8_ = self->priv->alternate_who_starts_action;
				g_simple_action_set_enabled (_tmp8_, FALSE);
				_g_free0 (type);
				return;
			}
		}
	} else if (_tmp6_ == ((0 != _tmp5_label1) ? _tmp5_label1 : (_tmp5_label1 = g_quark_from_static_string ("dark")))) {
		switch (0) {
			default:
			{
				GSettings* _tmp9_;
				GSettings* _tmp10_;
				GSettings* _tmp11_;
				GSimpleAction* _tmp12_;
				_tmp9_ = self->priv->settings;
				g_settings_set_int (_tmp9_, "num-players", 1);
				_tmp10_ = self->priv->settings;
				iagno_update_level_button_state (self, g_settings_get_int (_tmp10_, "computer-level"));
				_tmp11_ = self->priv->settings;
				g_settings_set_string (_tmp11_, "color", "dark");
				_tmp12_ = self->priv->alternate_who_starts_action;
				g_simple_action_set_enabled (_tmp12_, TRUE);
				_g_free0 (type);
				return;
			}
		}
	} else if (_tmp6_ == ((0 != _tmp5_label2) ? _tmp5_label2 : (_tmp5_label2 = g_quark_from_static_string ("light")))) {
		switch (0) {
			default:
			{
				GSettings* _tmp13_;
				GSettings* _tmp14_;
				GSettings* _tmp15_;
				GSimpleAction* _tmp16_;
				_tmp13_ = self->priv->settings;
				g_settings_set_int (_tmp13_, "num-players", 1);
				_tmp14_ = self->priv->settings;
				iagno_update_level_button_state (self, g_settings_get_int (_tmp14_, "computer-level"));
				_tmp15_ = self->priv->settings;
				g_settings_set_string (_tmp15_, "color", "light");
				_tmp16_ = self->priv->alternate_who_starts_action;
				g_simple_action_set_enabled (_tmp16_, TRUE);
				_g_free0 (type);
				return;
			}
		}
	} else {
		switch (0) {
			default:
			{
				g_assert_not_reached ();
			}
		}
	}
}

static void
iagno_update_game_type_button_label (Iagno* self,
                                     const gchar* type)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	_tmp0_ = type;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("two")))) {
		switch (0) {
			default:
			{
				GameWindow* _tmp3_;
				_tmp3_ = self->priv->window;
				game_window_update_game_type_label (_tmp3_, _ ("Two players"));
				return;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("dark")))) {
		switch (0) {
			default:
			{
				GameWindow* _tmp4_;
				_tmp4_ = self->priv->window;
				game_window_update_game_type_label (_tmp4_, _ ("Color: Dark"));
				return;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("light")))) {
		switch (0) {
			default:
			{
				GameWindow* _tmp5_;
				_tmp5_ = self->priv->window;
				game_window_update_game_type_label (_tmp5_, _ ("Color: Light"));
				return;
			}
		}
	} else {
		switch (0) {
			default:
			{
				g_assert_not_reached ();
			}
		}
	}
}

static void
iagno_change_level_cb (Iagno* self,
                       GSimpleAction* action,
                       GVariant* gvariant)
{
	GSettings* _tmp0_;
	gint level = 0;
	const gchar* _tmp1_;
	GSettings* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_vala_return_if_fail (gvariant != NULL, "gvariant != null");
	_tmp0_ = self->priv->settings;
	if (g_settings_get_int (_tmp0_, "num-players") == 2) {
		return;
	}
	self->priv->level_changed = TRUE;
	_tmp1_ = g_variant_get_string ((GVariant*) gvariant, NULL);
	level = atoi (_tmp1_);
	iagno_update_level_button_state (self, level);
	_tmp2_ = self->priv->settings;
	g_settings_set_int (_tmp2_, "computer-level", level);
}

static void
iagno_update_level_button_state (Iagno* self,
                                 gint level)
{
	g_return_if_fail (self != NULL);
	switch (level) {
		case 0:
		{
			GSimpleAction* _tmp0_;
			gboolean _tmp1_ = FALSE;
			gboolean _tmp2_ = FALSE;
			_tmp0_ = self->priv->change_level_action;
			g_simple_action_set_enabled (_tmp0_, FALSE);
			if (iagno_alternative_start) {
				_tmp2_ = TRUE;
			} else {
				_tmp2_ = iagno_random_start;
			}
			if (_tmp2_) {
				_tmp1_ = TRUE;
			} else {
				_tmp1_ = iagno_usual_start;
			}
			if (_tmp1_) {
				GameWindow* _tmp3_;
				GSettings* _tmp4_;
				_tmp3_ = self->priv->window;
				game_window_update_level_sensitivity (_tmp3_, FALSE);
				_tmp4_ = self->priv->settings;
				iagno_update_level_button_label (self, (guint8) g_settings_get_int (_tmp4_, "computer-level"));
			} else {
				iagno_update_level_button_label (self, (guint8) 0);
			}
			return;
		}
		case 1:
		{
			GSimpleAction* _tmp5_;
			GameWindow* _tmp6_;
			_tmp5_ = self->priv->change_level_action;
			g_simple_action_set_enabled (_tmp5_, TRUE);
			_tmp6_ = self->priv->window;
			game_window_update_level_sensitivity (_tmp6_, TRUE);
			iagno_update_level_button_label (self, (guint8) 1);
			return;
		}
		case 2:
		{
			GSimpleAction* _tmp7_;
			GameWindow* _tmp8_;
			_tmp7_ = self->priv->change_level_action;
			g_simple_action_set_enabled (_tmp7_, TRUE);
			_tmp8_ = self->priv->window;
			game_window_update_level_sensitivity (_tmp8_, TRUE);
			iagno_update_level_button_label (self, (guint8) 2);
			return;
		}
		case 3:
		{
			GSimpleAction* _tmp9_;
			GameWindow* _tmp10_;
			_tmp9_ = self->priv->change_level_action;
			g_simple_action_set_enabled (_tmp9_, TRUE);
			_tmp10_ = self->priv->window;
			game_window_update_level_sensitivity (_tmp10_, TRUE);
			iagno_update_level_button_label (self, (guint8) 3);
			return;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static void
iagno_update_level_button_label (Iagno* self,
                                 guint8 level)
{
	g_return_if_fail (self != NULL);
	switch (level) {
		case 0:
		{
			GameWindow* _tmp0_;
			_tmp0_ = self->priv->window;
			game_window_update_level_label (_tmp0_, _ ("More options"));
			return;
		}
		case 1:
		{
			GameWindow* _tmp1_;
			_tmp1_ = self->priv->window;
			game_window_update_level_label (_tmp1_, _ ("Difficulty: Easy"));
			return;
		}
		case 2:
		{
			GameWindow* _tmp2_;
			_tmp2_ = self->priv->window;
			game_window_update_level_label (_tmp2_, _ ("Difficulty: Medium"));
			return;
		}
		case 3:
		{
			GameWindow* _tmp3_;
			_tmp3_ = self->priv->window;
			game_window_update_level_label (_tmp3_, _ ("Difficulty: Hard"));
			return;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static void
iagno_back_cb (Iagno* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	Game* _tmp2_;
	Player _tmp3_;
	Player _tmp4_;
	Player _tmp5_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	iagno_set_window_title (self);
	_tmp2_ = self->priv->game;
	_tmp3_ = game_get_current_color (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_player_one;
	if (_tmp4_ != _tmp5_) {
		ComputerPlayer* _tmp6_;
		_tmp6_ = self->priv->_computer;
		_tmp1_ = _tmp6_ != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		Game* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = self->priv->game;
		_tmp8_ = game_get_is_complete (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp0_ = !_tmp9_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		ComputerPlayer* _tmp10_;
		_tmp10_ = self->priv->_computer;
		computer_player_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, TYPE_COMPUTER_PLAYER, ComputerPlayer), IAGNO_SLOW_MOVE_DELAY);
	} else {
		Game* _tmp11_;
		gboolean _tmp12_;
		gboolean _tmp13_;
		_tmp11_ = self->priv->game;
		_tmp12_ = game_get_is_complete (_tmp11_);
		_tmp13_ = _tmp12_;
		if (_tmp13_) {
			iagno_game_complete (self, FALSE);
		}
	}
}

static void
iagno_wait_cb (Iagno* self)
{
	ComputerPlayer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_computer;
	if (_tmp0_ != NULL) {
		ComputerPlayer* _tmp1_;
		_tmp1_ = self->priv->_computer;
		computer_player_cancel_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_COMPUTER_PLAYER, ComputerPlayer));
	}
}

static void
_iagno_turn_ended_cb_game_turn_ended (Game* _sender,
                                      gboolean undoing,
                                      gboolean no_draw,
                                      gpointer self)
{
	iagno_turn_ended_cb ((Iagno*) self, undoing, no_draw);
}

static void
iagno_start_game (Iagno* self)
{
	ComputerPlayer* _tmp1_;
	gboolean two_players = FALSE;
	GSettings* _tmp3_;
	gboolean even_board = FALSE;
	gboolean random_start_settings = FALSE;
	GSettings* _tmp4_;
	Opening opening = 0;
	gboolean reverse = FALSE;
	GSettings* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gboolean _tmp13_;
	Game* _tmp14_;
	Game* _tmp15_;
	ReversiView* _tmp16_;
	Game* _tmp17_;
	GameWindow* _tmp18_;
	GameWindow* _tmp19_;
	GSettings* _tmp39_;
	gboolean _tmp40_ = FALSE;
	g_return_if_fail (self != NULL);
	if (self->priv->game_is_set) {
		Game* _tmp0_;
		_tmp0_ = self->priv->game;
		g_signal_handlers_disconnect_by_func (_tmp0_, NULL, self);
	}
	_tmp1_ = self->priv->_computer;
	if (_tmp1_ != NULL) {
		ComputerPlayer* _tmp2_;
		_tmp2_ = self->priv->_computer;
		computer_player_cancel_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_COMPUTER_PLAYER, ComputerPlayer));
	}
	_tmp3_ = self->priv->settings;
	two_players = g_settings_get_int (_tmp3_, "num-players") == 2;
	even_board = (iagno_size % 2) == 0;
	_tmp4_ = self->priv->settings;
	random_start_settings = g_settings_get_boolean (_tmp4_, "random-start-position");
	if (iagno_alternative_start) {
		if (even_board) {
			Opening _tmp5_ = 0;
			if (gtk_get_locale_direction () == GTK_TEXT_DIR_LTR) {
				_tmp5_ = OPENING_ALTER_LEFT;
			} else {
				_tmp5_ = OPENING_ALTER_RIGHT;
			}
			opening = _tmp5_;
		} else {
			Opening _tmp6_ = 0;
			if (gtk_get_locale_direction () == GTK_TEXT_DIR_LTR) {
				_tmp6_ = OPENING_ALTER_RIGHT;
			} else {
				_tmp6_ = OPENING_ALTER_LEFT;
			}
			opening = _tmp6_;
		}
	} else {
		if (iagno_usual_start) {
			opening = OPENING_REVERSI;
		} else {
			gboolean _tmp7_ = FALSE;
			gboolean _tmp8_ = FALSE;
			if (two_players) {
				_tmp8_ = random_start_settings;
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				_tmp7_ = !iagno_random_start;
			} else {
				_tmp7_ = FALSE;
			}
			if (_tmp7_) {
				opening = OPENING_HUMANS;
			} else {
				gboolean _tmp9_ = FALSE;
				if (iagno_random_start) {
					_tmp9_ = TRUE;
				} else {
					_tmp9_ = random_start_settings;
				}
				if (_tmp9_) {
					switch (g_random_int_range ((gint32) 0, (gint32) 8)) {
						case 0:
						case 1:
						{
							opening = OPENING_REVERSI;
							break;
						}
						case 2:
						case 3:
						{
							opening = OPENING_INVERTED;
							break;
						}
						case 4:
						{
							opening = OPENING_ALTER_TOP;
							break;
						}
						case 5:
						{
							opening = OPENING_ALTER_LEFT;
							break;
						}
						case 6:
						{
							opening = OPENING_ALTER_RIGHT;
							break;
						}
						case 7:
						{
							opening = OPENING_ALTER_BOTTOM;
							break;
						}
						default:
						{
							g_assert_not_reached ();
						}
					}
				} else {
					opening = OPENING_REVERSI;
				}
			}
		}
	}
	_tmp10_ = self->priv->settings;
	_tmp11_ = g_settings_get_string (_tmp10_, "type");
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strcmp0 (_tmp12_, "reverse") == 0;
	_g_free0 (_tmp12_);
	reverse = _tmp13_;
	_tmp14_ = game_new (reverse, opening, (guint8) iagno_size, iagno_print_logs);
	_g_object_unref0 (self->priv->game);
	self->priv->game = _tmp14_;
	iagno_set_window_title (self);
	self->priv->game_is_set = TRUE;
	_tmp15_ = self->priv->game;
	g_signal_connect_object (_tmp15_, "turn-ended", (GCallback) _iagno_turn_ended_cb_game_turn_ended, self, 0);
	_tmp16_ = self->priv->view;
	_tmp17_ = self->priv->game;
	reversi_view_set_game (_tmp16_, _tmp17_);
	_tmp18_ = self->priv->window;
	game_window_set_player (_tmp18_, PLAYER_DARK);
	_tmp19_ = self->priv->window;
	game_window_set_game_finished (_tmp19_, FALSE);
	if (two_players) {
		iagno_set_computer (self, NULL);
	} else {
		guint8 computer_level = 0U;
		GSettings* _tmp20_;
		_tmp20_ = self->priv->settings;
		computer_level = (guint8) g_settings_get_int (_tmp20_, "computer-level");
		if (reverse) {
			switch (computer_level) {
				case 1:
				{
					Game* _tmp21_;
					ComputerReverseEasy* _tmp22_;
					ComputerReverseEasy* _tmp23_;
					_tmp21_ = self->priv->game;
					_tmp22_ = computer_reverse_easy_new (_tmp21_);
					_tmp23_ = _tmp22_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp23_);
					_g_object_unref0 (_tmp23_);
					break;
				}
				case 2:
				{
					Game* _tmp24_;
					ComputerReverseHard* _tmp25_;
					ComputerReverseHard* _tmp26_;
					_tmp24_ = self->priv->game;
					_tmp25_ = computer_reverse_hard_new (_tmp24_, (guint8) 1, FALSE);
					_tmp26_ = _tmp25_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp26_);
					_g_object_unref0 (_tmp26_);
					break;
				}
				case 3:
				{
					Game* _tmp27_;
					ComputerReverseHard* _tmp28_;
					ComputerReverseHard* _tmp29_;
					_tmp27_ = self->priv->game;
					_tmp28_ = computer_reverse_hard_new (_tmp27_, (guint8) 2, FALSE);
					_tmp29_ = _tmp28_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp29_);
					_g_object_unref0 (_tmp29_);
					break;
				}
				default:
				{
					g_assert_not_reached ();
				}
			}
		} else {
			switch (computer_level) {
				case 1:
				{
					Game* _tmp30_;
					ComputerReversiEasy* _tmp31_;
					ComputerReversiEasy* _tmp32_;
					_tmp30_ = self->priv->game;
					_tmp31_ = computer_reversi_easy_new (_tmp30_);
					_tmp32_ = _tmp31_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp32_);
					_g_object_unref0 (_tmp32_);
					break;
				}
				case 2:
				{
					Game* _tmp33_;
					ComputerReversiHard* _tmp34_;
					ComputerReversiHard* _tmp35_;
					_tmp33_ = self->priv->game;
					_tmp34_ = computer_reversi_hard_new (_tmp33_, (guint8) 0, FALSE);
					_tmp35_ = _tmp34_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp35_);
					_g_object_unref0 (_tmp35_);
					break;
				}
				case 3:
				{
					Game* _tmp36_;
					ComputerReversiHard* _tmp37_;
					ComputerReversiHard* _tmp38_;
					_tmp36_ = self->priv->game;
					_tmp37_ = computer_reversi_hard_new (_tmp36_, (guint8) 1, FALSE);
					_tmp38_ = _tmp37_;
					iagno_set_computer (self, (ComputerPlayer*) _tmp38_);
					_g_object_unref0 (_tmp38_);
					break;
				}
				default:
				{
					g_assert_not_reached ();
				}
			}
		}
	}
	_tmp39_ = self->priv->settings;
	if (g_settings_get_enum (_tmp39_, "color") == 1) {
		iagno_set_player_one (self, PLAYER_LIGHT);
	} else {
		iagno_set_player_one (self, PLAYER_DARK);
	}
	if (two_players) {
		_tmp40_ = TRUE;
	} else {
		Player _tmp41_;
		_tmp41_ = self->priv->_player_one;
		_tmp40_ = _tmp41_ == PLAYER_DARK;
	}
	self->priv->first_player_is_human = _tmp40_;
	iagno_update_ui (self);
	if (!two_players) {
		Player _tmp42_;
		_tmp42_ = self->priv->_player_one;
		if (_tmp42_ == PLAYER_DARK) {
			GSettings* _tmp43_;
			_tmp43_ = self->priv->settings;
			if (g_settings_get_boolean (_tmp43_, "alternate-who-starts")) {
				GSettings* _tmp44_;
				_tmp44_ = self->priv->settings;
				g_settings_set_string (_tmp44_, "color", "light");
			}
		} else {
			GSettings* _tmp45_;
			ComputerPlayer* _tmp47_;
			_tmp45_ = self->priv->settings;
			if (g_settings_get_boolean (_tmp45_, "alternate-who-starts")) {
				GSettings* _tmp46_;
				_tmp46_ = self->priv->settings;
				g_settings_set_string (_tmp46_, "color", "dark");
			}
			_tmp47_ = self->priv->_computer;
			computer_player_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, TYPE_COMPUTER_PLAYER, ComputerPlayer), IAGNO_MODERATE_MOVE_DELAY);
		}
	}
}

static void
iagno_update_ui (Iagno* self)
{
	gboolean _tmp0_ = FALSE;
	GameWindow* _tmp7_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	if (self->priv->first_player_is_human) {
		Game* _tmp1_;
		guint8 _tmp2_;
		guint8 _tmp3_;
		_tmp1_ = self->priv->game;
		_tmp2_ = game_get_number_of_moves (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = ((gint) _tmp3_) >= 1;
	} else {
		Game* _tmp4_;
		guint8 _tmp5_;
		guint8 _tmp6_;
		_tmp4_ = self->priv->game;
		_tmp5_ = game_get_number_of_moves (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = ((gint) _tmp6_) >= 2;
	}
	_tmp7_ = self->priv->window;
	game_window_new_turn_start (_tmp7_, _tmp0_);
}

static void
iagno_undo_cb (Iagno* self)
{
	ReversiView* _tmp0_;
	ComputerPlayer* _tmp1_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	_tmp0_ = self->priv->view;
	if (reversi_view_undo_final_animation (_tmp0_)) {
		iagno_play_sound (self, IAGNO_SOUND_GAMEOVER);
		return;
	}
	_tmp1_ = self->priv->_computer;
	if (_tmp1_ == NULL) {
		Game* _tmp2_;
		Game* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp2_ = self->priv->game;
		game_undo (_tmp2_, (guint8) 1);
		_tmp3_ = self->priv->game;
		_tmp4_ = game_get_current_player_can_move (_tmp3_);
		_tmp5_ = _tmp4_;
		if (!_tmp5_) {
			Game* _tmp6_;
			_tmp6_ = self->priv->game;
			game_undo (_tmp6_, (guint8) 1);
		}
	} else {
		ComputerPlayer* _tmp7_;
		Game* _tmp8_;
		Player _tmp9_;
		Player _tmp10_;
		Player _tmp11_;
		_tmp7_ = self->priv->_computer;
		computer_player_cancel_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_COMPUTER_PLAYER, ComputerPlayer));
		_tmp8_ = self->priv->game;
		_tmp9_ = game_get_current_color (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->_player_one;
		if (_tmp10_ != _tmp11_) {
			Game* _tmp12_;
			_tmp12_ = self->priv->game;
			game_undo (_tmp12_, (guint8) 1);
		} else {
			Game* _tmp13_;
			_tmp13_ = self->priv->game;
			game_undo (_tmp13_, (guint8) 2);
		}
		while (TRUE) {
			Game* _tmp14_;
			gboolean _tmp15_;
			gboolean _tmp16_;
			Game* _tmp17_;
			_tmp14_ = self->priv->game;
			_tmp15_ = game_get_current_player_can_move (_tmp14_);
			_tmp16_ = _tmp15_;
			if (!(!_tmp16_)) {
				break;
			}
			_tmp17_ = self->priv->game;
			game_undo (_tmp17_, (guint8) 2);
		}
	}
	iagno_update_ui (self);
	iagno_update_scoreboard (self);
}

static void
iagno_turn_ended_cb (Iagno* self,
                     gboolean undoing,
                     gboolean no_draw)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	if (undoing) {
		_tmp0_ = no_draw;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	iagno_update_ui (self);
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_current_player_can_move (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		iagno_prepare_move (self);
	} else {
		Game* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->game;
		_tmp5_ = game_get_is_complete (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			iagno_game_complete (self, TRUE);
		} else {
			iagno_pass (self);
		}
	}
}

static void
iagno_prepare_move (Iagno* self)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	Player _tmp2_;
	Player _tmp3_;
	Player _tmp4_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	iagno_update_scoreboard (self);
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_current_color (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->_player_one;
	if (_tmp3_ != _tmp4_) {
		ComputerPlayer* _tmp5_;
		_tmp5_ = self->priv->_computer;
		_tmp0_ = _tmp5_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gdouble _tmp6_ = 0.0;
		ComputerPlayer* _tmp7_;
		if (iagno_fast_mode) {
			_tmp6_ = IAGNO_QUICK_MOVE_DELAY;
		} else {
			_tmp6_ = IAGNO_SLOW_MOVE_DELAY;
		}
		_tmp7_ = self->priv->_computer;
		computer_player_move (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_COMPUTER_PLAYER, ComputerPlayer), _tmp6_);
	}
}

static void
iagno_pass (Iagno* self)
{
	Game* _tmp0_;
	Game* _tmp1_;
	Player _tmp2_;
	Player _tmp3_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	iagno_update_scoreboard (self);
	_tmp0_ = self->priv->game;
	if (!game_pass (_tmp0_)) {
		g_assert_not_reached ();
	}
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_current_color (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == PLAYER_DARK) {
		GameWindow* _tmp4_;
		_tmp4_ = self->priv->window;
		game_window_show_notification (_tmp4_, _ ("Light must pass, Dark’s move"));
	} else {
		GameWindow* _tmp5_;
		_tmp5_ = self->priv->window;
		game_window_show_notification (_tmp5_, _ ("Dark must pass, Light’s move"));
	}
}

static void
iagno_game_complete (Iagno* self,
                     gboolean play_gameover_sound)
{
	GameWindow* _tmp0_;
	GameWindow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	Game* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	_tmp0_ = self->priv->window;
	game_window_finish_game (_tmp0_);
	_tmp1_ = self->priv->window;
	game_window_set_player (_tmp1_, PLAYER_NONE);
	_tmp4_ = self->priv->game;
	_tmp5_ = game_get_reverse (_tmp4_);
	_tmp6_ = _tmp5_;
	if (!_tmp6_) {
		Game* _tmp7_;
		guint8 _tmp8_;
		guint8 _tmp9_;
		Game* _tmp10_;
		guint8 _tmp11_;
		guint8 _tmp12_;
		_tmp7_ = self->priv->game;
		_tmp8_ = game_get_n_light_tiles (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = self->priv->game;
		_tmp11_ = game_get_n_dark_tiles (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp3_ = _tmp9_ > _tmp12_;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		gboolean _tmp13_ = FALSE;
		Game* _tmp14_;
		gboolean _tmp15_;
		gboolean _tmp16_;
		_tmp14_ = self->priv->game;
		_tmp15_ = game_get_reverse (_tmp14_);
		_tmp16_ = _tmp15_;
		if (_tmp16_) {
			Game* _tmp17_;
			guint8 _tmp18_;
			guint8 _tmp19_;
			Game* _tmp20_;
			guint8 _tmp21_;
			guint8 _tmp22_;
			_tmp17_ = self->priv->game;
			_tmp18_ = game_get_n_light_tiles (_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp20_ = self->priv->game;
			_tmp21_ = game_get_n_dark_tiles (_tmp20_);
			_tmp22_ = _tmp21_;
			_tmp13_ = _tmp19_ < _tmp22_;
		} else {
			_tmp13_ = FALSE;
		}
		_tmp2_ = _tmp13_;
	}
	if (_tmp2_) {
		GameWindow* _tmp23_;
		Game* _tmp24_;
		guint8 _tmp25_;
		guint8 _tmp26_;
		Game* _tmp27_;
		guint8 _tmp28_;
		guint8 _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		_tmp23_ = self->priv->window;
		_tmp24_ = self->priv->game;
		_tmp25_ = game_get_n_light_tiles (_tmp24_);
		_tmp26_ = _tmp25_;
		_tmp27_ = self->priv->game;
		_tmp28_ = game_get_n_dark_tiles (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = g_strdup_printf (_ ("Light wins! (%u-%u)"), (guint) _tmp26_, (guint) _tmp29_);
		_tmp31_ = _tmp30_;
		game_window_show_notification (_tmp23_, _tmp31_);
		_g_free0 (_tmp31_);
	} else {
		gboolean _tmp32_ = FALSE;
		gboolean _tmp33_ = FALSE;
		Game* _tmp34_;
		gboolean _tmp35_;
		gboolean _tmp36_;
		_tmp34_ = self->priv->game;
		_tmp35_ = game_get_reverse (_tmp34_);
		_tmp36_ = _tmp35_;
		if (!_tmp36_) {
			Game* _tmp37_;
			guint8 _tmp38_;
			guint8 _tmp39_;
			Game* _tmp40_;
			guint8 _tmp41_;
			guint8 _tmp42_;
			_tmp37_ = self->priv->game;
			_tmp38_ = game_get_n_light_tiles (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = self->priv->game;
			_tmp41_ = game_get_n_dark_tiles (_tmp40_);
			_tmp42_ = _tmp41_;
			_tmp33_ = _tmp39_ < _tmp42_;
		} else {
			_tmp33_ = FALSE;
		}
		if (_tmp33_) {
			_tmp32_ = TRUE;
		} else {
			gboolean _tmp43_ = FALSE;
			Game* _tmp44_;
			gboolean _tmp45_;
			gboolean _tmp46_;
			_tmp44_ = self->priv->game;
			_tmp45_ = game_get_reverse (_tmp44_);
			_tmp46_ = _tmp45_;
			if (_tmp46_) {
				Game* _tmp47_;
				guint8 _tmp48_;
				guint8 _tmp49_;
				Game* _tmp50_;
				guint8 _tmp51_;
				guint8 _tmp52_;
				_tmp47_ = self->priv->game;
				_tmp48_ = game_get_n_light_tiles (_tmp47_);
				_tmp49_ = _tmp48_;
				_tmp50_ = self->priv->game;
				_tmp51_ = game_get_n_dark_tiles (_tmp50_);
				_tmp52_ = _tmp51_;
				_tmp43_ = _tmp49_ > _tmp52_;
			} else {
				_tmp43_ = FALSE;
			}
			_tmp32_ = _tmp43_;
		}
		if (_tmp32_) {
			GameWindow* _tmp53_;
			Game* _tmp54_;
			guint8 _tmp55_;
			guint8 _tmp56_;
			Game* _tmp57_;
			guint8 _tmp58_;
			guint8 _tmp59_;
			gchar* _tmp60_;
			gchar* _tmp61_;
			_tmp53_ = self->priv->window;
			_tmp54_ = self->priv->game;
			_tmp55_ = game_get_n_dark_tiles (_tmp54_);
			_tmp56_ = _tmp55_;
			_tmp57_ = self->priv->game;
			_tmp58_ = game_get_n_light_tiles (_tmp57_);
			_tmp59_ = _tmp58_;
			_tmp60_ = g_strdup_printf (_ ("Dark wins! (%u-%u)"), (guint) _tmp56_, (guint) _tmp59_);
			_tmp61_ = _tmp60_;
			game_window_show_notification (_tmp53_, _tmp61_);
			_g_free0 (_tmp61_);
		} else {
			GameWindow* _tmp62_;
			_tmp62_ = self->priv->window;
			game_window_show_notification (_tmp62_, _ ("The game is draw."));
		}
	}
	if (play_gameover_sound) {
		iagno_play_sound (self, IAGNO_SOUND_GAMEOVER);
	}
}

static void
iagno_player_move_cb (Iagno* self,
                      guint8 x,
                      guint8 y)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	Game* _tmp2_;
	Player _tmp3_;
	Player _tmp4_;
	Player _tmp5_;
	Game* _tmp10_;
	Game* _tmp11_;
	Opening _tmp12_;
	Opening _tmp13_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
	_tmp2_ = self->priv->game;
	_tmp3_ = game_get_current_color (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_player_one;
	if (_tmp4_ != _tmp5_) {
		ComputerPlayer* _tmp6_;
		_tmp6_ = self->priv->_computer;
		_tmp1_ = _tmp6_ != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		Game* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = self->priv->game;
		_tmp8_ = game_get_current_player_can_move (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp0_ = !_tmp9_;
	}
	if (_tmp0_) {
		return;
	}
	_tmp10_ = self->priv->game;
	if (game_place_tile (_tmp10_, x, y)) {
		return;
	}
	_tmp11_ = self->priv->game;
	_tmp12_ = game_get_opening (_tmp11_);
	_tmp13_ = _tmp12_;
	if (_tmp13_ != OPENING_HUMANS) {
		GameWindow* _tmp14_;
		_tmp14_ = self->priv->window;
		game_window_show_notification (_tmp14_, _ ("You can’t move there!"));
	} else {
		gboolean _tmp15_ = FALSE;
		gboolean _tmp16_ = FALSE;
		gboolean _tmp17_ = FALSE;
		Game* _tmp18_;
		Player _tmp19_;
		Player _tmp20_;
		_tmp18_ = self->priv->game;
		_tmp19_ = game_get_current_color (_tmp18_);
		_tmp20_ = _tmp19_;
		if (_tmp20_ == PLAYER_LIGHT) {
			Game* _tmp21_;
			guint8 _tmp22_;
			guint8 _tmp23_;
			_tmp21_ = self->priv->game;
			_tmp22_ = game_get_n_light_tiles (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp17_ = ((gint) _tmp23_) == 0;
		} else {
			_tmp17_ = FALSE;
		}
		if (_tmp17_) {
			gboolean _tmp24_ = FALSE;
			Game* _tmp25_;
			guint8 _tmp26_;
			guint8 _tmp27_;
			_tmp25_ = self->priv->game;
			_tmp26_ = game_get_size (_tmp25_);
			_tmp27_ = _tmp26_;
			if (((gint) x) == ((_tmp27_ / 2) - 1)) {
				_tmp24_ = TRUE;
			} else {
				Game* _tmp28_;
				guint8 _tmp29_;
				guint8 _tmp30_;
				_tmp28_ = self->priv->game;
				_tmp29_ = game_get_size (_tmp28_);
				_tmp30_ = _tmp29_;
				_tmp24_ = ((gint) x) == (_tmp30_ / 2);
			}
			_tmp16_ = _tmp24_;
		} else {
			_tmp16_ = FALSE;
		}
		if (_tmp16_) {
			gboolean _tmp31_ = FALSE;
			Game* _tmp32_;
			guint8 _tmp33_;
			guint8 _tmp34_;
			_tmp32_ = self->priv->game;
			_tmp33_ = game_get_size (_tmp32_);
			_tmp34_ = _tmp33_;
			if (((gint) y) == ((_tmp34_ / 2) - 1)) {
				_tmp31_ = TRUE;
			} else {
				Game* _tmp35_;
				guint8 _tmp36_;
				guint8 _tmp37_;
				_tmp35_ = self->priv->game;
				_tmp36_ = game_get_size (_tmp35_);
				_tmp37_ = _tmp36_;
				_tmp31_ = ((gint) y) == (_tmp37_ / 2);
			}
			_tmp15_ = _tmp31_;
		} else {
			_tmp15_ = FALSE;
		}
		if (_tmp15_) {
			GameWindow* _tmp38_;
			_tmp38_ = self->priv->window;
			game_window_show_notification (_tmp38_, _ ("In this opening, Light can only play on tiles bordering on Dark one."));
		} else {
			GameWindow* _tmp39_;
			_tmp39_ = self->priv->window;
			game_window_show_notification (_tmp39_, _ ("Click on one of the highlighted tiles to move the selected piece there" \
"."));
		}
	}
}

static void
iagno_clear_impossible_to_move_here_warning (Iagno* self)
{
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (self->priv->game_is_set, "game_is_set");
}

static void
iagno_update_scoreboard (Iagno* self)
{
	GameWindow* _tmp0_;
	Game* _tmp1_;
	Player _tmp2_;
	Player _tmp3_;
	g_return_if_fail (self != NULL);
	iagno_play_sound (self, IAGNO_SOUND_FLIP);
	_tmp0_ = self->priv->window;
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_current_color (_tmp1_);
	_tmp3_ = _tmp2_;
	game_window_set_player (_tmp0_, _tmp3_);
}

static void
iagno_set_window_title (Iagno* self)
{
	const gchar* _tmp0_ = NULL;
	Game* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GameWindow* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_reverse (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_tmp0_ = _ ("Reverse Reversi");
	} else {
		_tmp0_ = _ ("Classic Reversi");
	}
	_tmp4_ = self->priv->window;
	game_window_update_title (_tmp4_, _tmp0_);
}

static void
iagno_play_sound (Iagno* self,
                  IagnoSound sound)
{
	GSettings* _tmp0_;
	gchar* name = NULL;
	const gchar* _tmp13_;
	gchar* path = NULL;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	GtkMediaFile* media_file = NULL;
	const gchar* _tmp16_;
	GtkMediaFile* _tmp17_;
	GtkMediaFile* _tmp18_;
	GtkMediaFile* _tmp19_;
	GtkMediaFile* _tmp20_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	if (!g_settings_get_boolean (_tmp0_, "sound")) {
		return;
	}
	switch (sound) {
		case IAGNO_SOUND_FLIP:
		{
			ThemeManager* _tmp1_;
			Theme* _tmp2_;
			Theme* _tmp3_;
			const gchar* _tmp4_;
			const gchar* _tmp5_;
			gchar* _tmp6_;
			_tmp1_ = self->priv->theme_manager;
			_tmp2_ = theme_manager_get_theme (_tmp1_);
			_tmp3_ = _tmp2_;
			_tmp4_ = theme_get_sound_flip (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strdup (_tmp5_);
			_g_free0 (name);
			name = _tmp6_;
			break;
		}
		case IAGNO_SOUND_GAMEOVER:
		{
			ThemeManager* _tmp7_;
			Theme* _tmp8_;
			Theme* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			_tmp7_ = self->priv->theme_manager;
			_tmp8_ = theme_manager_get_theme (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = theme_get_sound_gameover (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_strdup (_tmp11_);
			_g_free0 (name);
			name = _tmp12_;
			break;
		}
		default:
		{
			_g_free0 (name);
			return;
		}
	}
	_tmp13_ = name;
	if (g_strcmp0 (_tmp13_, "") == 0) {
		g_assert_not_reached ();
	}
	_tmp14_ = name;
	_tmp15_ = g_build_filename (SOUND_DIRECTORY, _tmp14_, NULL);
	path = _tmp15_;
	_tmp16_ = path;
	_tmp17_ = (GtkMediaFile*) gtk_media_file_new_for_filename (_tmp16_);
	media_file = _tmp17_;
	_tmp18_ = media_file;
	_tmp19_ = _g_object_ref0 (_tmp18_);
	_g_object_unref0 (self->priv->last_played);
	self->priv->last_played = _tmp19_;
	_tmp20_ = media_file;
	G_TYPE_INSTANCE_GET_CLASS ((GtkMediaStream*) _tmp20_, gtk_media_stream_get_type (), GtkMediaStreamClass)->play ((GtkMediaStream*) _tmp20_);
	_g_object_unref0 (media_file);
	_g_free0 (path);
	_g_free0 (name);
}

static void
iagno_help (Iagno* self)
{
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp1_ = _tmp0_;
	gtk_show_uri (_tmp1_, "help:iagno", (guint32) GDK_CURRENT_TIME);
}

static void
iagno_about (Iagno* self)
{
	AdwAboutDialog* about_dialog = NULL;
	AdwAboutDialog* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar** _tmp31_;
	gchar** _tmp32_;
	gint _tmp32__length1;
	GtkWindow* _tmp33_;
	GtkWindow* _tmp34_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (AdwAboutDialog*) adw_about_dialog_new ();
	g_object_ref_sink (_tmp0_);
	about_dialog = _tmp0_;
	adw_dialog_set_title ((AdwDialog*) about_dialog, _ ("About"));
	adw_about_dialog_set_application_icon (about_dialog, APP_ID);
	adw_about_dialog_set_application_name (about_dialog, IAGNO_PROGRAM_NAME);
	adw_about_dialog_set_version (about_dialog, VERSION);
	adw_about_dialog_set_license_type (about_dialog, GTK_LICENSE_GPL_3_0);
	_tmp1_ = g_strdup (_ ("Masuichi Ito (pieces)"));
	_tmp2_ = g_strdup (_ ("Arnaud Bonatti (themes)"));
	_tmp3_ = g_new0 (gchar*, 2 + 1);
	_tmp3_[0] = _tmp1_;
	_tmp3_[1] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 2;
	adw_about_dialog_set_artists (about_dialog, _tmp4_);
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = g_strdup (_ ("Ian Peters"));
	_tmp6_ = g_strdup (_ ("Robert Ancell"));
	_tmp7_ = g_strdup (_ ("Arnaud Bonatti"));
	_tmp8_ = g_new0 (gchar*, 3 + 1);
	_tmp8_[0] = _tmp5_;
	_tmp8_[1] = _tmp6_;
	_tmp8_[2] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 3;
	adw_about_dialog_set_developers (about_dialog, _tmp9_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_comments (about_dialog, _ ("A disk flipping game derived from Reversi"));
	_tmp10_ = g_strdup_printf (_ ("Copyright \xc2\xa9 %u-%u – Ian Peters"), (guint) 1998, (guint) 2008);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strconcat (_tmp11_, "\n", NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strdup_printf (_ ("Copyright \xc2\xa9 %u-%u – Michael Catanzaro"), (guint) 2013, (guint) 2015);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp13_, _tmp15_, NULL);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_strconcat (_tmp17_, "\n", NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strdup_printf (_ ("Copyright \xc2\xa9 %u-%u – Arnaud Bonatti"), (guint) 2014, (guint) 2020);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp19_, _tmp21_, NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, "\n", NULL);
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strdup_printf (_ ("Copyright \xc2\xa9 %u-%u – Andrey Kutejko"), (guint) 2025, (guint) 2026);
	_tmp27_ = _tmp26_;
	_tmp28_ = g_strconcat (_tmp25_, _tmp27_, NULL);
	_tmp29_ = _tmp28_;
	adw_about_dialog_set_copyright (about_dialog, _tmp29_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp19_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp11_);
	_tmp30_ = g_strdup (_ ("Tiffany Antopolski"));
	_tmp31_ = g_new0 (gchar*, 1 + 1);
	_tmp31_[0] = _tmp30_;
	_tmp32_ = _tmp31_;
	_tmp32__length1 = 1;
	adw_about_dialog_set_documenters (about_dialog, _tmp32_);
	_tmp32_ = (_vala_array_free (_tmp32_, _tmp32__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_translator_credits (about_dialog, _ ("translator-credits"));
	adw_about_dialog_set_website (about_dialog, "https://wiki.gnome.org/Apps/Reversi");
	_tmp33_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp34_ = _tmp33_;
	adw_dialog_present ((AdwDialog*) about_dialog, (GtkWidget*) _tmp34_);
	_g_object_unref0 (about_dialog);
}

ComputerPlayer*
iagno_get_computer (Iagno* self)
{
	ComputerPlayer* result;
	ComputerPlayer* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_computer;
	result = _tmp0_;
	return result;
}

static void
iagno_set_computer (Iagno* self,
                    ComputerPlayer* value)
{
	ComputerPlayer* old_value;
	g_return_if_fail (self != NULL);
	old_value = iagno_get_computer (self);
	if (old_value != value) {
		ComputerPlayer* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_computer);
		self->priv->_computer = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, iagno_properties[IAGNO_COMPUTER_PROPERTY]);
	}
}

Player
iagno_get_player_one (Iagno* self)
{
	Player result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_player_one;
	return result;
}

static void
iagno_set_player_one (Iagno* self,
                      Player value)
{
	Player old_value;
	g_return_if_fail (self != NULL);
	old_value = iagno_get_player_one (self);
	if (old_value != value) {
		self->priv->_player_one = value;
		g_object_notify_by_pspec ((GObject *) self, iagno_properties[IAGNO_PLAYER_ONE_PROPERTY]);
	}
}

static void
iagno_class_init (IagnoClass * klass,
                  gpointer klass_data)
{
	iagno_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Iagno_private_offset);
	((GApplicationClass *) klass)->handle_local_options = (gint (*) (GApplication*, GVariantDict*)) iagno_real_handle_local_options;
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) iagno_real_startup;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) iagno_real_activate;
	((GApplicationClass *) klass)->shutdown = (void (*) (GApplication*)) iagno_real_shutdown;
	G_OBJECT_CLASS (klass)->get_property = _vala_iagno_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_iagno_set_property;
	G_OBJECT_CLASS (klass)->finalize = iagno_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), IAGNO_COMPUTER_PROPERTY, iagno_properties[IAGNO_COMPUTER_PROPERTY] = g_param_spec_object ("computer", "computer", "computer", TYPE_COMPUTER_PLAYER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), IAGNO_PLAYER_ONE_PROPERTY, iagno_properties[IAGNO_PLAYER_ONE_PROPERTY] = g_param_spec_enum ("player-one", "player-one", "player-one", TYPE_PLAYER, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
iagno_instance_init (Iagno * self,
                     gpointer klass)
{
	ThemeManager* _tmp0_;
	self->priv = iagno_get_instance_private (self);
	_tmp0_ = theme_manager_new ();
	self->priv->theme_manager = _tmp0_;
	self->priv->_computer = NULL;
	self->priv->game_is_set = FALSE;
	self->priv->game_type_changed_1 = FALSE;
	self->priv->game_type_changed_2 = FALSE;
	self->priv->level_changed = FALSE;
	self->priv->first_player_is_human = FALSE;
}

static void
iagno_finalize (GObject * obj)
{
	Iagno * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_IAGNO, Iagno);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->theme_manager);
	_g_object_unref0 (self->priv->_computer);
	_g_object_unref0 (self->priv->game);
	_g_object_unref0 (self->priv->alternate_who_starts_action);
	_g_object_unref0 (self->priv->change_level_action);
	_g_object_unref0 (self->priv->last_played);
	G_OBJECT_CLASS (iagno_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
iagno_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (IagnoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) iagno_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Iagno), 0, (GInstanceInitFunc) iagno_instance_init, NULL };
	GType iagno_type_id;
	iagno_type_id = g_type_register_static (adw_application_get_type (), "Iagno", &g_define_type_info, G_TYPE_FLAG_NONE);
	Iagno_private_offset = g_type_add_instance_private (iagno_type_id, sizeof (IagnoPrivate));
	return iagno_type_id;
}

GType
iagno_get_type (void)
{
	static gsize iagno_type_id__once = 0;
	if (g_once_init_enter (&iagno_type_id__once)) {
		GType iagno_type_id;
		iagno_type_id = iagno_get_type_once ();
		g_once_init_leave (&iagno_type_id__once, iagno_type_id);
	}
	return iagno_type_id__once;
}

static void
_vala_iagno_get_property (GObject * object,
                          guint property_id,
                          GValue * value,
                          GParamSpec * pspec)
{
	Iagno * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IAGNO, Iagno);
	switch (property_id) {
		case IAGNO_COMPUTER_PROPERTY:
		g_value_set_object (value, iagno_get_computer (self));
		break;
		case IAGNO_PLAYER_ONE_PROPERTY:
		g_value_set_enum (value, iagno_get_player_one (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_iagno_set_property (GObject * object,
                          guint property_id,
                          const GValue * value,
                          GParamSpec * pspec)
{
	Iagno * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IAGNO, Iagno);
	switch (property_id) {
		case IAGNO_COMPUTER_PROPERTY:
		iagno_set_computer (self, g_value_get_object (value));
		break;
		case IAGNO_PLAYER_ONE_PROPERTY:
		iagno_set_player_one (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

