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

/* quadrapassel.vala
 * 
 * Copyright 2010-2013 Robert Ancell
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "libgnome-games-support.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <libmanette.h>
#include "linux/input-event-codes.h"
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <pango/pango.h>
#include <locale.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_QUADRAPASSEL (quadrapassel_get_type ())
#define QUADRAPASSEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_QUADRAPASSEL, Quadrapassel))
#define QUADRAPASSEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_QUADRAPASSEL, QuadrapasselClass))
#define IS_QUADRAPASSEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_QUADRAPASSEL))
#define IS_QUADRAPASSEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_QUADRAPASSEL))
#define QUADRAPASSEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_QUADRAPASSEL, QuadrapasselClass))

typedef struct _Quadrapassel Quadrapassel;
typedef struct _QuadrapasselClass QuadrapasselClass;
typedef struct _QuadrapasselPrivate QuadrapasselPrivate;

#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;

#define TYPE_GAME_VIEW (game_view_get_type ())
#define GAME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GAME_VIEW, GameView))
#define GAME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GAME_VIEW, GameViewClass))
#define IS_GAME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GAME_VIEW))
#define IS_GAME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GAME_VIEW))
#define GAME_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GAME_VIEW, GameViewClass))

typedef struct _GameView GameView;
typedef struct _GameViewClass GameViewClass;

#define TYPE_PREVIEW (preview_get_type ())
#define PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREVIEW, Preview))
#define PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREVIEW, PreviewClass))
#define IS_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREVIEW))
#define IS_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREVIEW))
#define PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREVIEW, PreviewClass))

typedef struct _Preview Preview;
typedef struct _PreviewClass PreviewClass;
enum  {
	QUADRAPASSEL_0_PROPERTY,
	QUADRAPASSEL_NUM_PROPERTIES
};
static GParamSpec* quadrapassel_properties[QUADRAPASSEL_NUM_PROPERTIES];
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 = (g_free (var), NULL))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define __vala_ManetteMonitorIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_ManetteMonitorIter_free (var), NULL)))
typedef struct _GamePrivate GamePrivate;

#define TYPE_SHAPE (shape_get_type ())
#define SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SHAPE, Shape))
#define SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SHAPE, ShapeClass))
#define IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SHAPE))
#define IS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SHAPE))
#define SHAPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SHAPE, ShapeClass))

typedef struct _Shape Shape;
typedef struct _ShapeClass ShapeClass;

#define TYPE_BLOCK (block_get_type ())
#define BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BLOCK, Block))
#define BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BLOCK, BlockClass))
#define IS_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BLOCK))
#define IS_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BLOCK))
#define BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BLOCK, BlockClass))

typedef struct _Block Block;
typedef struct _BlockClass BlockClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block2Data Block2Data;

#define TYPE_MORE_INFO_BUTTON (more_info_button_get_type ())
#define MORE_INFO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MORE_INFO_BUTTON, MoreInfoButton))
#define MORE_INFO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MORE_INFO_BUTTON, MoreInfoButtonClass))
#define IS_MORE_INFO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MORE_INFO_BUTTON))
#define IS_MORE_INFO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MORE_INFO_BUTTON))
#define MORE_INFO_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MORE_INFO_BUTTON, MoreInfoButtonClass))

typedef struct _MoreInfoButton MoreInfoButton;
typedef struct _MoreInfoButtonClass MoreInfoButtonClass;
#define _g_time_zone_unref0(var) ((var == NULL) ? NULL : (var = (g_time_zone_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _Quadrapassel {
	AdwApplication parent_instance;
	QuadrapasselPrivate * priv;
};

struct _QuadrapasselClass {
	AdwApplicationClass parent_class;
};

struct _QuadrapasselPrivate {
	GSettings* settings;
	AdwApplicationWindow* window;
	AdwHeaderBar* headerbar;
	GtkEventControllerKey* event_controller_key;
	GtkGestureSwipe* swipe_gesture;
	GtkGestureLongPress* long_press_gesture;
	GtkMenuButton* menu_button;
	GamesScoresContext* context;
	GamesGridFrame* game_aspect;
	Game* game;
	GameView* view;
	GtkGrid* game_grid;
	Preview* preview;
	GamesGridFrame* preview_frame;
	gchar* next_markup;
	gchar* hold_markup;
	GtkLabel* preview_label;
	GtkLabel* score_label;
	GtkLabel* score_descriptor_label;
	GtkLabel* n_destroyed_label;
	GtkLabel* destroyed_descriptor_label;
	GtkLabel* level_label;
	GtkLabel* level_descriptor_label;
	GSimpleAction* pause_action;
	GtkButton* pause_play_button;
	GtkButton* new_game_button;
	ManetteMonitor* manette_monitor;
	GHashTable* buttons_state;
	gboolean pause_requested;
	GHashTable* keys_state;
};

struct _Block1Data {
	int _ref_count_;
	Quadrapassel* self;
	GtkWidget* toggle_button;
	gboolean popover_shown;
};

struct _Game {
	GObject parent_instance;
	GamePrivate * priv;
	Shape* shape;
	Shape* next_shape;
	Shape* held_shape;
	Block** blocks;
	gint blocks_length1;
	gint blocks_length2;
	gint n_lines_destroyed;
	gint score;
	gint difficulty;
	gboolean pick_difficult_blocks;
	gboolean game_over;
};

struct _GameClass {
	GObjectClass parent_class;
};

struct _Block2Data {
	int _ref_count_;
	Quadrapassel* self;
	AdwSpinRow* difficulty_row;
	AdwSwitchRow* difficult_blocks_toggle;
	AdwSwitchRow* sound_toggle;
	AdwSwitchRow* do_preview_toggle;
	AdwSwitchRow* rotate_counter_clock_wise_toggle;
	AdwSwitchRow* show_shadow_toggle;
	AdwEntryRow* game_seed;
	AdwSwitchRow* use_seed_toggle;
};

static gint Quadrapassel_private_offset;
static gpointer quadrapassel_parent_class = NULL;

VALA_EXTERN GType quadrapassel_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Quadrapassel, g_object_unref)
VALA_EXTERN GType game_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Game, g_object_unref)
VALA_EXTERN GType game_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GameView, g_object_unref)
VALA_EXTERN GType preview_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Preview, g_object_unref)
static void quadrapassel_new_game_cb (Quadrapassel* self);
static void _quadrapassel_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void quadrapassel_pause_cb (Quadrapassel* self);
static void _quadrapassel_pause_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                              GVariant* parameter,
                                                              gpointer self);
static void quadrapassel_scores_cb (Quadrapassel* self);
static void _quadrapassel_scores_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                               GVariant* parameter,
                                                               gpointer self);
static void quadrapassel_menu_cb (Quadrapassel* self);
static void _quadrapassel_menu_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                             GVariant* parameter,
                                                             gpointer self);
static void quadrapassel_theme_cb (Quadrapassel* self);
static void _quadrapassel_theme_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                              GVariant* parameter,
                                                              gpointer self);
static void quadrapassel_preferences_cb (Quadrapassel* self);
static void _quadrapassel_preferences_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                                    GVariant* parameter,
                                                                    gpointer self);
static void quadrapassel_rules_cb (Quadrapassel* self);
static void _quadrapassel_rules_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                              GVariant* parameter,
                                                              gpointer self);
static void quadrapassel_about_cb (Quadrapassel* self);
static void _quadrapassel_about_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                              GVariant* parameter,
                                                              gpointer self);
static void quadrapassel_quit_cb (Quadrapassel* self);
static void _quadrapassel_quit_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                             GVariant* parameter,
                                                             gpointer self);
VALA_EXTERN Quadrapassel* quadrapassel_new (void);
VALA_EXTERN Quadrapassel* quadrapassel_construct (GType object_type);
static void quadrapassel_real_startup (GApplication* base);
static void quadrapassel_create_window (Quadrapassel* self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static gboolean quadrapassel_key_press_event_cb (Quadrapassel* self,
                                          GtkEventControllerKey* controller,
                                          guint keyval,
                                          guint keycode,
                                          GdkModifierType state);
static gboolean _quadrapassel_key_press_event_cb_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                guint keyval,
                                                                                guint keycode,
                                                                                GdkModifierType state,
                                                                                gpointer self);
static void quadrapassel_key_release_event_cb (Quadrapassel* self,
                                        GtkEventControllerKey* controller,
                                        guint keyval,
                                        guint keycode,
                                        GdkModifierType state);
static void _quadrapassel_key_release_event_cb_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                               guint keyval,
                                                                               guint keycode,
                                                                               GdkModifierType state,
                                                                               gpointer self);
static void quadrapassel_swipe_cb (Quadrapassel* self,
                            gdouble velocity_x,
                            gdouble velocity_y);
static void _quadrapassel_swipe_cb_gtk_gesture_swipe_swipe (GtkGestureSwipe* _sender,
                                                     gdouble velocity_x,
                                                     gdouble velocity_y,
                                                     gpointer self);
static void quadrapassel_long_press_cb (Quadrapassel* self,
                                 gdouble x,
                                 gdouble y);
static void _quadrapassel_long_press_cb_gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                                 gdouble x,
                                                                 gdouble y,
                                                                 gpointer self);
static void quadrapassel_on_window_focus_change (Quadrapassel* self);
static void _quadrapassel_on_window_focus_change_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self);
static void __lambda14_ (Block1Data* _data1_);
static void ___lambda14__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda15_ (Block1Data* _data1_);
static void ___lambda15__gtk_widget_show (GtkWidget* _sender,
                                   gpointer self);
static void quadrapassel_breakpoint_apply_cb (Quadrapassel* self);
static void _quadrapassel_breakpoint_apply_cb_adw_breakpoint_apply (AdwBreakpoint* _sender,
                                                             gpointer self);
static void quadrapassel_breakpoint_unapply_cb (Quadrapassel* self);
static void _quadrapassel_breakpoint_unapply_cb_adw_breakpoint_unapply (AdwBreakpoint* _sender,
                                                                 gpointer self);
VALA_EXTERN GameView* game_view_new (void);
VALA_EXTERN GameView* game_view_construct (GType object_type);
VALA_EXTERN void game_view_set_theme (GameView* self,
                          const gchar* value);
VALA_EXTERN void game_view_set_mute (GameView* self,
                         gboolean value);
VALA_EXTERN void game_view_set_show_shadow (GameView* self,
                                gboolean value);
VALA_EXTERN Game* game_new (gint lines,
                gint columns,
                gint difficulty,
                gint filled_lines,
                gint fill_prob,
                gboolean pick_difficult_blocks);
VALA_EXTERN Game* game_construct (GType object_type,
                      gint lines,
                      gint columns,
                      gint difficulty,
                      gint filled_lines,
                      gint fill_prob,
                      gboolean pick_difficult_blocks);
VALA_EXTERN void game_view_set_game (GameView* self,
                         Game* value);
VALA_EXTERN Preview* preview_new (void);
VALA_EXTERN Preview* preview_construct (GType object_type);
VALA_EXTERN void preview_set_theme (Preview* self,
                        const gchar* value);
VALA_EXTERN void preview_set_enabled (Preview* self,
                          gboolean value);
static GamesScoresCategory* quadrapassel_create_category_from_key (Quadrapassel* self,
                                                            const gchar* key);
static GamesScoresCategory* _quadrapassel_create_category_from_key_games_scores_category_request_func (const gchar* category_key,
                                                                                                gpointer self);
static void quadrapassel_parse_old_score (Quadrapassel* self,
                                   const gchar* line,
                                   GamesScoresScore** score,
                                   GamesScoresCategory** category);
static void _quadrapassel_parse_old_score_games_scores_history_file_importer_history_convert_func (const gchar* line,
                                                                                            GamesScoresScore** score,
                                                                                            GamesScoresCategory** category,
                                                                                            gpointer self);
static void quadrapassel_manette_device_connected_cb (Quadrapassel* self,
                                               ManetteDevice* manette_device);
static void _quadrapassel_manette_device_connected_cb_manette_monitor_device_connected (ManetteMonitor* _sender,
                                                                                 ManetteDevice* device,
                                                                                 gpointer self);
static void _vala_ManetteMonitorIter_free (ManetteMonitorIter* self);
static void quadrapassel_real_shutdown (GApplication* base);
VALA_EXTERN GType shape_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Shape, g_object_unref)
VALA_EXTERN GType block_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Block, g_object_unref)
static gchar* quadrapassel_get_game_extra_info (Quadrapassel* self);
static void ___lambda16_ (Quadrapassel* self,
                   GObject* object,
                   GAsyncResult* _result_);
static void ____lambda16__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void quadrapassel_real_activate (GApplication* base);
VALA_EXTERN void game_set_paused (Game* self,
                      gboolean value);
static void quadrapassel_user_pause (Quadrapassel* self);
VALA_EXTERN gboolean game_get_paused (Game* self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN GType more_info_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MoreInfoButton, g_object_unref)
VALA_EXTERN MoreInfoButton* more_info_button_new (void);
VALA_EXTERN MoreInfoButton* more_info_button_construct (GType object_type);
VALA_EXTERN void more_info_button_set_text (MoreInfoButton* self,
                                const gchar* value);
static void __lambda6_ (Block2Data* _data2_);
static void ___lambda6__gtk_editable_changed (GtkEditable* _sender,
                                       gpointer self);
static void __lambda7_ (Block2Data* _data2_);
static void ___lambda7__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void __lambda8_ (Block2Data* _data2_);
static void ___lambda8__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void __lambda9_ (Block2Data* _data2_);
static void ___lambda9__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void __lambda10_ (Block2Data* _data2_);
static void ___lambda10__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda11_ (Block2Data* _data2_);
static void ___lambda11__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda12_ (Block2Data* _data2_);
static void ___lambda12__gtk_editable_changed (GtkEditable* _sender,
                                        gpointer self);
static void __lambda13_ (Block2Data* _data2_);
static void ___lambda13__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static GtkWidget* quadrapassel_theme_update (Quadrapassel* self,
                                      const gchar* theme_name,
                                      GtkWidget* theme_preview_widget);
VALA_EXTERN void preview_update_block (Preview* self,
                           Shape* shape);
static GtkWidget* _quadrapassel_theme_update_games_theme_selector_dialog_change_theme (GamesThemeSelectorDialog* _sender,
                                                                                const gchar* theme_name,
                                                                                GtkWidget* old_theme_preview,
                                                                                gpointer self);
static void quadrapassel_manette_button_press_event_cb (Quadrapassel* self,
                                                 ManetteEvent* event);
static void _quadrapassel_manette_button_press_event_cb_manette_device_button_press_event (ManetteDevice* _sender,
                                                                                    ManetteEvent* event,
                                                                                    gpointer self);
static void quadrapassel_manette_button_release_event_cb (Quadrapassel* self,
                                                   ManetteEvent* event);
static void _quadrapassel_manette_button_release_event_cb_manette_device_button_release_event (ManetteDevice* _sender,
                                                                                        ManetteEvent* event,
                                                                                        gpointer self);
static void quadrapassel_manette_absolute_axis_event_cb (Quadrapassel* self,
                                                  ManetteEvent* event);
static void _quadrapassel_manette_absolute_axis_event_cb_manette_device_absolute_axis_event (ManetteDevice* _sender,
                                                                                      ManetteEvent* event,
                                                                                      gpointer self);
static void quadrapassel_new_game (Quadrapassel* self);
VALA_EXTERN gboolean game_move_left (Game* self);
VALA_EXTERN gboolean game_move_right (Game* self);
VALA_EXTERN gboolean game_rotate_left (Game* self);
VALA_EXTERN gboolean game_rotate_right (Game* self);
VALA_EXTERN void game_set_fast_forward (Game* self,
                            gboolean enable);
VALA_EXTERN void game_hold (Game* self);
VALA_EXTERN void game_drop (Game* self);
VALA_EXTERN gboolean game_stop_moving (Game* self);
VALA_EXTERN gboolean game_get_fast_forward (Game* self);
VALA_EXTERN void game_stop (Game* self);
static void quadrapassel_pause_changed_cb (Quadrapassel* self);
static void _quadrapassel_pause_changed_cb_game_pause_changed (Game* _sender,
                                                        gpointer self);
static void quadrapassel_shape_landed_cb (Quadrapassel* self,
                                   gint* lines,
                                   gint lines_length1,
                                   GList* line_blocks);
static void _quadrapassel_shape_landed_cb_game_shape_landed (Game* _sender,
                                                      gint* lines,
                                                      gint lines_length1,
                                                      GList* line_blocks,
                                                      gpointer self);
static void quadrapassel_shape_added_cb (Quadrapassel* self);
static void _quadrapassel_shape_added_cb_game_shape_added (Game* _sender,
                                                    gpointer self);
static void quadrapassel_shape_held_cb (Quadrapassel* self);
static void _quadrapassel_shape_held_cb_game_shape_held (Game* _sender,
                                                  gpointer self);
static void quadrapassel_complete_cb (Quadrapassel* self);
static void _quadrapassel_complete_cb_game_complete (Game* _sender,
                                              gpointer self);
VALA_EXTERN void game_start (Game* self);
static void quadrapassel_update_score (Quadrapassel* self);
VALA_EXTERN void preview_set_hidden (Preview* self,
                         gboolean hide);
VALA_EXTERN gint game_get_level (Game* self);
static void ___lambda5_ (Quadrapassel* self,
                  GObject* object,
                  GAsyncResult* _result_);
static void ____lambda5__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static gint64 quadrapassel_parse_date (Quadrapassel* self,
                                const gchar* date);
VALA_EXTERN void more_info_button_set_extra_child (MoreInfoButton* self,
                                       GtkWidget* value);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup2 (gchar** self,
                          gssize length);
static gint quadrapassel_main (gchar** args,
                        gint args_length1);
static void quadrapassel_finalize (GObject * obj);
static GType quadrapassel_get_type_once (void);
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 gssize _vala_array_length (gpointer array);

static const guint16 QUADRAPASSEL_MANETTE_BUTTONS[17] = {BTN_A, BTN_B, BTN_X, BTN_Y, BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR, BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT};
static const GActionEntry QUADRAPASSEL_ACTION_ENTRIES[9] = {{"new-game", _quadrapassel_new_game_cb_gsimple_action_activate_callback}, {"pause", _quadrapassel_pause_cb_gsimple_action_activate_callback}, {"scores", _quadrapassel_scores_cb_gsimple_action_activate_callback}, {"menu", _quadrapassel_menu_cb_gsimple_action_activate_callback}, {"theme", _quadrapassel_theme_cb_gsimple_action_activate_callback}, {"preferences", _quadrapassel_preferences_cb_gsimple_action_activate_callback}, {"rules", _quadrapassel_rules_cb_gsimple_action_activate_callback}, {"about", _quadrapassel_about_cb_gsimple_action_activate_callback}, {"quit", _quadrapassel_quit_cb_gsimple_action_activate_callback}};

static inline gpointer
quadrapassel_get_instance_private (Quadrapassel* self)
{
	return G_STRUCT_MEMBER_P (self, Quadrapassel_private_offset);
}

static void
_quadrapassel_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	quadrapassel_new_game_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_pause_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                         GVariant* parameter,
                                                         gpointer self)
{
	quadrapassel_pause_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_scores_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                          GVariant* parameter,
                                                          gpointer self)
{
	quadrapassel_scores_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_menu_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                        GVariant* parameter,
                                                        gpointer self)
{
	quadrapassel_menu_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_theme_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                         GVariant* parameter,
                                                         gpointer self)
{
	quadrapassel_theme_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_preferences_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                               GVariant* parameter,
                                                               gpointer self)
{
	quadrapassel_preferences_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_rules_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                         GVariant* parameter,
                                                         gpointer self)
{
	quadrapassel_rules_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_about_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                         GVariant* parameter,
                                                         gpointer self)
{
	quadrapassel_about_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_quit_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                        GVariant* parameter,
                                                        gpointer self)
{
	quadrapassel_quit_cb ((Quadrapassel*) self);
}

Quadrapassel*
quadrapassel_construct (GType object_type)
{
	Quadrapassel * self = NULL;
	self = (Quadrapassel*) g_object_new (object_type, "application-id", APP_ID, "flags", G_APPLICATION_DEFAULT_FLAGS, "resource-base-path", "/org/gnome/Quadrapassel", NULL);
	return self;
}

Quadrapassel*
quadrapassel_new (void)
{
	return quadrapassel_construct (TYPE_QUADRAPASSEL);
}

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

static void
quadrapassel_real_startup (GApplication* base)
{
	Quadrapassel * self;
	AdwStyleManager* _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_;
	gint _tmp9__length1;
	gchar* _tmp10_;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar* _tmp13_;
	gchar** _tmp14_;
	gchar** _tmp15_;
	gint _tmp15__length1;
	gchar* _tmp16_;
	gchar** _tmp17_;
	gchar** _tmp18_;
	gint _tmp18__length1;
	GAction* _tmp19_;
	GSimpleAction* _tmp20_;
	GSettings* _tmp21_;
	self = (Quadrapassel*) base;
	G_APPLICATION_CLASS (quadrapassel_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp0_ = adw_style_manager_get_default ();
	adw_style_manager_set_color_scheme (_tmp0_, ADW_COLOR_SCHEME_FORCE_DARK);
	g_set_application_name (_ ("Quadrapassel"));
	g_action_map_add_action_entries ((GActionMap*) self, QUADRAPASSEL_ACTION_ENTRIES, (gint) G_N_ELEMENTS (QUADRAPASSEL_ACTION_ENTRIES), 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, "app.new-game", _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp4_ = g_strdup ("F10");
	_tmp5_ = g_new0 (gchar*, 1 + 1);
	_tmp5_[0] = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.menu", _tmp6_);
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	_tmp7_ = g_strdup ("F1");
	_tmp8_ = g_new0 (gchar*, 1 + 1);
	_tmp8_[0] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.rules", _tmp9_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	_tmp10_ = g_strdup ("<Primary>comma");
	_tmp11_ = g_new0 (gchar*, 1 + 1);
	_tmp11_[0] = _tmp10_;
	_tmp12_ = _tmp11_;
	_tmp12__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.preferences", _tmp12_);
	_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_free), NULL);
	_tmp13_ = g_strdup ("<Primary>q");
	_tmp14_ = g_new0 (gchar*, 1 + 1);
	_tmp14_[0] = _tmp13_;
	_tmp15_ = _tmp14_;
	_tmp15__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp15_);
	_tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) g_free), NULL);
	_tmp16_ = g_strdup ("<Primary>w");
	_tmp17_ = g_new0 (gchar*, 1 + 1);
	_tmp17_[0] = _tmp16_;
	_tmp18_ = _tmp17_;
	_tmp18__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "window.close", _tmp18_);
	_tmp18_ = (_vala_array_free (_tmp18_, _tmp18__length1, (GDestroyNotify) g_free), NULL);
	_tmp19_ = g_action_map_lookup_action ((GActionMap*) self, "pause");
	_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp19_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp19_) : NULL);
	_g_object_unref0 (self->priv->pause_action);
	self->priv->pause_action = _tmp20_;
	_tmp21_ = g_settings_new (APP_ID);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp21_;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		Quadrapassel* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->toggle_button);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static gboolean
_quadrapassel_key_press_event_cb_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                       guint keyval,
                                                                       guint keycode,
                                                                       GdkModifierType state,
                                                                       gpointer self)
{
	gboolean result;
	result = quadrapassel_key_press_event_cb ((Quadrapassel*) self, _sender, keyval, keycode, state);
	return result;
}

static void
_quadrapassel_key_release_event_cb_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                          guint keyval,
                                                                          guint keycode,
                                                                          GdkModifierType state,
                                                                          gpointer self)
{
	quadrapassel_key_release_event_cb ((Quadrapassel*) self, _sender, keyval, keycode, state);
}

static void
_quadrapassel_swipe_cb_gtk_gesture_swipe_swipe (GtkGestureSwipe* _sender,
                                                gdouble velocity_x,
                                                gdouble velocity_y,
                                                gpointer self)
{
	quadrapassel_swipe_cb ((Quadrapassel*) self, velocity_x, velocity_y);
}

static void
_quadrapassel_long_press_cb_gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                            gdouble x,
                                                            gdouble y,
                                                            gpointer self)
{
	quadrapassel_long_press_cb ((Quadrapassel*) self, x, y);
}

static void
_quadrapassel_on_window_focus_change_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self)
{
	quadrapassel_on_window_focus_change ((Quadrapassel*) self);
}

static void
__lambda14_ (Block1Data* _data1_)
{
	Quadrapassel* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	AdwApplicationWindow* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	gboolean _tmp7_;
	self = _data1_->self;
	_tmp2_ = self->priv->window;
	g_object_get ((GtkWindow*) _tmp2_, "focus-widget", &_tmp3_, NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp6_ = _data1_->toggle_button;
	_tmp7_ = _tmp5_ == _tmp6_;
	_g_object_unref0 (_tmp5_);
	if (_tmp7_) {
		GtkMenuButton* _tmp8_;
		GtkPopover* _tmp9_;
		GtkPopover* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp8_ = self->priv->menu_button;
		_tmp9_ = gtk_menu_button_get_popover (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gtk_widget_get_visible ((GtkWidget*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tmp1_ = !_tmp12_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = _data1_->popover_shown == TRUE;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GamesGridFrame* _tmp13_;
		_tmp13_ = self->priv->game_aspect;
		gtk_widget_grab_focus ((GtkWidget*) _tmp13_);
		_data1_->popover_shown = FALSE;
	}
	quadrapassel_on_window_focus_change (self);
}

static void
___lambda14__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda14_ (self);
}

static void
__lambda15_ (Block1Data* _data1_)
{
	Quadrapassel* self;
	self = _data1_->self;
	_data1_->popover_shown = TRUE;
}

static void
___lambda15__gtk_widget_show (GtkWidget* _sender,
                              gpointer self)
{
	__lambda15_ (self);
}

static void
_quadrapassel_breakpoint_apply_cb_adw_breakpoint_apply (AdwBreakpoint* _sender,
                                                        gpointer self)
{
	quadrapassel_breakpoint_apply_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_breakpoint_unapply_cb_adw_breakpoint_unapply (AdwBreakpoint* _sender,
                                                            gpointer self)
{
	quadrapassel_breakpoint_unapply_cb ((Quadrapassel*) self);
}

static GamesScoresCategory*
_quadrapassel_create_category_from_key_games_scores_category_request_func (const gchar* category_key,
                                                                           gpointer self)
{
	GamesScoresCategory* result;
	result = quadrapassel_create_category_from_key ((Quadrapassel*) self, category_key);
	return result;
}

static void
_quadrapassel_parse_old_score_games_scores_history_file_importer_history_convert_func (const gchar* line,
                                                                                       GamesScoresScore** score,
                                                                                       GamesScoresCategory** category,
                                                                                       gpointer self)
{
	quadrapassel_parse_old_score ((Quadrapassel*) self, line, score, category);
}

static void
_quadrapassel_manette_device_connected_cb_manette_monitor_device_connected (ManetteMonitor* _sender,
                                                                            ManetteDevice* device,
                                                                            gpointer self)
{
	quadrapassel_manette_device_connected_cb ((Quadrapassel*) self, device);
}

static void
_vala_ManetteMonitorIter_free (ManetteMonitorIter* self)
{
	g_boxed_free (manette_monitor_iter_get_type (), self);
}

static void
quadrapassel_create_window (Quadrapassel* self)
{
	Block1Data* _data1_;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	AdwApplicationWindow* _tmp1_;
	AdwApplicationWindow* _tmp2_;
	AdwApplicationWindow* _tmp3_;
	AdwApplicationWindow* _tmp4_;
	AdwBreakpoint* breakpoint = NULL;
	AdwBreakpointCondition* _tmp5_;
	AdwBreakpoint* _tmp6_;
	AdwApplicationWindow* _tmp7_;
	GtkBuilder* _tmp8_;
	AdwBreakpoint* _tmp9_;
	GtkEventControllerKey* _tmp10_;
	GtkEventControllerKey* _tmp11_;
	GtkEventControllerKey* _tmp12_;
	AdwApplicationWindow* _tmp13_;
	GtkEventControllerKey* _tmp14_;
	GtkEventController* _tmp15_;
	GtkGestureSwipe* _tmp16_;
	GtkGestureSwipe* _tmp17_;
	GtkGestureLongPress* _tmp18_;
	GtkGestureLongPress* _tmp19_;
	AdwApplicationWindow* _tmp20_;
	GSettings* _tmp21_;
	GSettings* _tmp22_;
	GSettings* _tmp23_;
	AdwApplicationWindow* _tmp25_;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp26_;
	AdwHeaderBar* _tmp27_;
	AdwToolbarView* _tmp28_;
	GtkBuilder* _tmp29_;
	AdwHeaderBar* _tmp30_;
	AdwApplicationWindow* _tmp31_;
	AdwToolbarView* _tmp32_;
	GtkButton* _tmp33_;
	GtkButton* _tmp34_;
	GtkButton* _tmp35_;
	AdwHeaderBar* _tmp36_;
	GtkButton* _tmp37_;
	GMenu* menu = NULL;
	GMenu* _tmp38_;
	GMenu* section = NULL;
	GMenu* _tmp39_;
	GMenu* _tmp40_;
	GMenu* _tmp41_;
	GMenu* _tmp42_;
	GMenu* _tmp43_;
	GMenu* _tmp44_;
	GMenu* _tmp45_;
	GMenu* _tmp46_;
	GMenu* _tmp47_;
	GMenu* _tmp48_;
	GMenu* _tmp49_;
	GMenu* _tmp50_;
	GtkMenuButton* _tmp51_;
	GtkMenuButton* _tmp52_;
	GtkMenuButton* _tmp53_;
	GtkMenuButton* _tmp54_;
	GtkMenuButton* _tmp55_;
	GMenu* _tmp56_;
	GtkMenuButton* _tmp57_;
	GtkWidget* _tmp58_;
	GtkWidget* _tmp59_;
	AdwApplicationWindow* _tmp60_;
	GtkMenuButton* _tmp61_;
	GtkPopover* _tmp62_;
	GtkPopover* _tmp63_;
	AdwHeaderBar* _tmp64_;
	GtkMenuButton* _tmp65_;
	GtkGrid* _tmp66_;
	GtkGrid* _tmp67_;
	GtkGrid* _tmp68_;
	GtkGrid* _tmp69_;
	GtkGrid* _tmp70_;
	GtkGrid* _tmp71_;
	AdwToolbarView* _tmp72_;
	GtkGrid* _tmp73_;
	AdwBreakpoint* _tmp74_;
	AdwBreakpoint* _tmp75_;
	GameView* _tmp76_;
	GameView* _tmp77_;
	GSettings* _tmp78_;
	gchar* _tmp79_;
	gchar* _tmp80_;
	GameView* _tmp81_;
	GSettings* _tmp82_;
	GameView* _tmp83_;
	GSettings* _tmp84_;
	GameView* _tmp85_;
	Game* _tmp86_;
	Game* _tmp87_;
	GamesGridFrame* _tmp88_;
	GamesGridFrame* _tmp89_;
	GamesGridFrame* _tmp90_;
	GamesGridFrame* _tmp91_;
	GameView* _tmp92_;
	GamesGridFrame* _tmp93_;
	GtkGestureSwipe* _tmp94_;
	GtkEventController* _tmp95_;
	GamesGridFrame* _tmp96_;
	GtkGestureLongPress* _tmp97_;
	GtkEventController* _tmp98_;
	GamesGridFrame* _tmp99_;
	GamesGridFrame* _tmp100_;
	GamesGridFrame* _tmp101_;
	GtkGrid* _tmp102_;
	GamesGridFrame* _tmp103_;
	GtkButton* _tmp104_;
	GtkButton* _tmp105_;
	GtkButton* _tmp106_;
	GtkButton* _tmp107_;
	GtkButton* _tmp108_;
	AdwHeaderBar* _tmp109_;
	GtkButton* _tmp110_;
	GtkLabel* _tmp111_;
	GtkLabel* _tmp112_;
	const gchar* _tmp113_;
	GtkLabel* _tmp114_;
	GtkLabel* _tmp115_;
	GtkLabel* _tmp116_;
	GtkGrid* _tmp117_;
	GtkLabel* _tmp118_;
	GamesGridFrame* _tmp119_;
	GamesGridFrame* _tmp120_;
	GamesGridFrame* _tmp121_;
	Preview* _tmp122_;
	Preview* _tmp123_;
	GSettings* _tmp124_;
	gchar* _tmp125_;
	gchar* _tmp126_;
	Preview* _tmp127_;
	GSettings* _tmp128_;
	GamesGridFrame* _tmp129_;
	Preview* _tmp130_;
	GtkGrid* _tmp131_;
	GamesGridFrame* _tmp132_;
	GtkLabel* _tmp133_;
	GtkLabel* _tmp134_;
	gchar* _tmp135_;
	gchar* _tmp136_;
	GtkLabel* _tmp137_;
	GtkLabel* _tmp138_;
	GtkLabel* _tmp139_;
	GtkGrid* _tmp140_;
	GtkLabel* _tmp141_;
	GtkLabel* _tmp142_;
	GtkLabel* _tmp143_;
	GtkLabel* _tmp144_;
	GtkLabel* _tmp145_;
	GtkLabel* _tmp146_;
	GtkGrid* _tmp147_;
	GtkLabel* _tmp148_;
	GtkLabel* _tmp149_;
	GtkLabel* _tmp150_;
	gchar* _tmp151_;
	gchar* _tmp152_;
	GtkLabel* _tmp153_;
	GtkLabel* _tmp154_;
	GtkLabel* _tmp155_;
	GtkGrid* _tmp156_;
	GtkLabel* _tmp157_;
	GtkLabel* _tmp158_;
	GtkLabel* _tmp159_;
	GtkLabel* _tmp160_;
	GtkLabel* _tmp161_;
	GtkGrid* _tmp162_;
	GtkLabel* _tmp163_;
	GtkLabel* _tmp164_;
	GtkLabel* _tmp165_;
	gchar* _tmp166_;
	gchar* _tmp167_;
	GtkLabel* _tmp168_;
	GtkLabel* _tmp169_;
	GtkLabel* _tmp170_;
	GtkGrid* _tmp171_;
	GtkLabel* _tmp172_;
	GtkLabel* _tmp173_;
	GtkLabel* _tmp174_;
	GtkLabel* _tmp175_;
	GtkLabel* _tmp176_;
	GtkGrid* _tmp177_;
	GtkLabel* _tmp178_;
	GamesScoresHistoryFileImporter* _tmp179_;
	GamesScoresHistoryFileImporter* _tmp180_;
	GamesScoresContext* _tmp181_;
	ManetteMonitor* _tmp183_;
	ManetteMonitor* _tmp184_;
	ManetteMonitorIter* manette_iterator = NULL;
	ManetteMonitor* _tmp185_;
	ManetteMonitorIter* _tmp186_;
	ManetteDevice* manette_device = NULL;
	guint* keys = NULL;
	guint* _tmp192_;
	gint keys_length1;
	gint _keys_size_;
	guint* _tmp193_;
	gint _tmp193__length1;
	GSimpleAction* _tmp195_;
	GtkButton* _tmp196_;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = gtk_builder_new ();
	builder = _tmp0_;
	_tmp1_ = (AdwApplicationWindow*) adw_application_window_new ((GtkApplication*) self);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp1_;
	_tmp2_ = self->priv->window;
	gtk_widget_set_size_request ((GtkWidget*) _tmp2_, 360, 320);
	_tmp3_ = self->priv->window;
	gtk_window_set_icon_name ((GtkWindow*) _tmp3_, APP_ID);
	_tmp4_ = self->priv->window;
	gtk_window_set_title ((GtkWindow*) _tmp4_, _ ("Quadrapassel"));
	_tmp5_ = adw_breakpoint_condition_new_length (ADW_BREAKPOINT_CONDITION_MAX_WIDTH, (gdouble) 380, ADW_LENGTH_UNIT_PX);
	_tmp6_ = adw_breakpoint_new (_tmp5_);
	breakpoint = _tmp6_;
	_tmp7_ = self->priv->window;
	_tmp8_ = builder;
	_tmp9_ = breakpoint;
	G_TYPE_INSTANCE_GET_INTERFACE ((GtkBuildable*) _tmp7_, gtk_buildable_get_type (), GtkBuildableIface)->add_child ((GtkBuildable*) _tmp7_, _tmp8_, (GObject*) _tmp9_, NULL);
	_tmp10_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	_g_object_unref0 (self->priv->event_controller_key);
	self->priv->event_controller_key = _tmp10_;
	_tmp11_ = self->priv->event_controller_key;
	g_signal_connect_object (_tmp11_, "key-pressed", (GCallback) _quadrapassel_key_press_event_cb_gtk_event_controller_key_key_pressed, self, 0);
	_tmp12_ = self->priv->event_controller_key;
	g_signal_connect_object (_tmp12_, "key-released", (GCallback) _quadrapassel_key_release_event_cb_gtk_event_controller_key_key_released, self, 0);
	_tmp13_ = self->priv->window;
	_tmp14_ = self->priv->event_controller_key;
	_tmp15_ = _g_object_ref0 ((GtkEventController*) _tmp14_);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget), _tmp15_);
	_tmp16_ = (GtkGestureSwipe*) gtk_gesture_swipe_new ();
	_g_object_unref0 (self->priv->swipe_gesture);
	self->priv->swipe_gesture = _tmp16_;
	_tmp17_ = self->priv->swipe_gesture;
	g_signal_connect_object (_tmp17_, "swipe", (GCallback) _quadrapassel_swipe_cb_gtk_gesture_swipe_swipe, self, 0);
	_tmp18_ = (GtkGestureLongPress*) gtk_gesture_long_press_new ();
	_g_object_unref0 (self->priv->long_press_gesture);
	self->priv->long_press_gesture = _tmp18_;
	_tmp19_ = self->priv->long_press_gesture;
	g_signal_connect_object (_tmp19_, "pressed", (GCallback) _quadrapassel_long_press_cb_gtk_gesture_long_press_pressed, self, 0);
	_tmp20_ = self->priv->window;
	_tmp21_ = self->priv->settings;
	_tmp22_ = self->priv->settings;
	gtk_window_set_default_size ((GtkWindow*) _tmp20_, g_settings_get_int (_tmp21_, "window-width"), g_settings_get_int (_tmp22_, "window-height"));
	_tmp23_ = self->priv->settings;
	if (g_settings_get_boolean (_tmp23_, "window-is-maximized")) {
		AdwApplicationWindow* _tmp24_;
		_tmp24_ = self->priv->window;
		gtk_window_maximize ((GtkWindow*) _tmp24_);
	}
	_tmp25_ = self->priv->window;
	g_signal_connect_object ((GObject*) _tmp25_, "notify::is-active", (GCallback) _quadrapassel_on_window_focus_change_g_object_notify, self, 0);
	_tmp26_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp26_);
	toolbar_view = _tmp26_;
	_tmp27_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp27_);
	_g_object_unref0 (self->priv->headerbar);
	self->priv->headerbar = _tmp27_;
	_tmp28_ = toolbar_view;
	_tmp29_ = builder;
	_tmp30_ = self->priv->headerbar;
	G_TYPE_INSTANCE_GET_INTERFACE ((GtkBuildable*) _tmp28_, gtk_buildable_get_type (), GtkBuildableIface)->add_child ((GtkBuildable*) _tmp28_, _tmp29_, (GObject*) _tmp30_, "top");
	_tmp31_ = self->priv->window;
	_tmp32_ = toolbar_view;
	adw_application_window_set_content (_tmp31_, (GtkWidget*) _tmp32_);
	_tmp33_ = (GtkButton*) gtk_button_new_from_icon_name ("view-refresh-symbolic");
	g_object_ref_sink (_tmp33_);
	_g_object_unref0 (self->priv->new_game_button);
	self->priv->new_game_button = _tmp33_;
	_tmp34_ = self->priv->new_game_button;
	gtk_actionable_set_action_name ((GtkActionable*) _tmp34_, "app.new-game");
	_tmp35_ = self->priv->new_game_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp35_, _ ("Start a new game"));
	_tmp36_ = self->priv->headerbar;
	_tmp37_ = self->priv->new_game_button;
	adw_header_bar_pack_start (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = g_menu_new ();
	menu = _tmp38_;
	_tmp39_ = g_menu_new ();
	section = _tmp39_;
	_tmp40_ = menu;
	_tmp41_ = section;
	g_menu_append_section (_tmp40_, NULL, (GMenuModel*) _tmp41_);
	_tmp42_ = section;
	g_menu_append (_tmp42_, _ ("_Scores"), "app.scores");
	_tmp43_ = section;
	g_menu_append (_tmp43_, _ ("App_earance"), "app.theme");
	_tmp44_ = section;
	g_menu_append (_tmp44_, _ ("_Preferences"), "app.preferences");
	_tmp45_ = g_menu_new ();
	_g_object_unref0 (section);
	section = _tmp45_;
	_tmp46_ = menu;
	_tmp47_ = section;
	g_menu_append_section (_tmp46_, NULL, (GMenuModel*) _tmp47_);
	_tmp48_ = section;
	g_menu_append (_tmp48_, _ ("_Keyboard Shortcuts"), "app.shortcuts");
	_tmp49_ = section;
	g_menu_append (_tmp49_, _ ("Game _Rules"), "app.rules");
	_tmp50_ = section;
	g_menu_append (_tmp50_, _ ("_About Quadrapassel"), "app.about");
	_tmp51_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp51_);
	_g_object_unref0 (self->priv->menu_button);
	self->priv->menu_button = _tmp51_;
	_tmp52_ = self->priv->menu_button;
	gtk_menu_button_set_primary (_tmp52_, TRUE);
	_tmp53_ = self->priv->menu_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp53_, _ ("Main Menu"));
	_tmp54_ = self->priv->menu_button;
	gtk_menu_button_set_icon_name (_tmp54_, "open-menu-symbolic");
	_tmp55_ = self->priv->menu_button;
	_tmp56_ = menu;
	gtk_menu_button_set_menu_model (_tmp55_, (GMenuModel*) _tmp56_);
	_tmp57_ = self->priv->menu_button;
	_tmp58_ = gtk_widget_get_first_child ((GtkWidget*) _tmp57_);
	_tmp59_ = _g_object_ref0 (_tmp58_);
	_data1_->toggle_button = _tmp59_;
	_data1_->popover_shown = FALSE;
	_tmp60_ = self->priv->window;
	g_signal_connect_data ((GObject*) _tmp60_, "notify::focus-widget", (GCallback) ___lambda14__g_object_notify, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp61_ = self->priv->menu_button;
	_tmp62_ = gtk_menu_button_get_popover (_tmp61_);
	_tmp63_ = _tmp62_;
	g_signal_connect_data ((GtkWidget*) _tmp63_, "show", (GCallback) ___lambda15__gtk_widget_show, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp64_ = self->priv->headerbar;
	_tmp65_ = self->priv->menu_button;
	adw_header_bar_pack_end (_tmp64_, (GtkWidget*) _tmp65_);
	_tmp66_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp66_);
	_g_object_unref0 (self->priv->game_grid);
	self->priv->game_grid = _tmp66_;
	_tmp67_ = self->priv->game_grid;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp67_, 12);
	_tmp68_ = self->priv->game_grid;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp68_, 12);
	_tmp69_ = self->priv->game_grid;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp69_, 12);
	_tmp70_ = self->priv->game_grid;
	gtk_grid_set_column_spacing (_tmp70_, 12);
	_tmp71_ = self->priv->game_grid;
	gtk_grid_set_row_spacing (_tmp71_, 6);
	_tmp72_ = toolbar_view;
	_tmp73_ = self->priv->game_grid;
	adw_toolbar_view_set_content (_tmp72_, (GtkWidget*) _tmp73_);
	_tmp74_ = breakpoint;
	g_signal_connect_object (_tmp74_, "apply", (GCallback) _quadrapassel_breakpoint_apply_cb_adw_breakpoint_apply, self, 0);
	_tmp75_ = breakpoint;
	g_signal_connect_object (_tmp75_, "unapply", (GCallback) _quadrapassel_breakpoint_unapply_cb_adw_breakpoint_unapply, self, 0);
	_tmp76_ = game_view_new ();
	g_object_ref_sink (_tmp76_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp76_;
	_tmp77_ = self->priv->view;
	_tmp78_ = self->priv->settings;
	_tmp79_ = g_settings_get_string (_tmp78_, "theme");
	_tmp80_ = _tmp79_;
	game_view_set_theme (_tmp77_, _tmp80_);
	_g_free0 (_tmp80_);
	_tmp81_ = self->priv->view;
	_tmp82_ = self->priv->settings;
	game_view_set_mute (_tmp81_, !g_settings_get_boolean (_tmp82_, "sound"));
	_tmp83_ = self->priv->view;
	_tmp84_ = self->priv->settings;
	game_view_set_show_shadow (_tmp83_, g_settings_get_boolean (_tmp84_, "show-shadow"));
	_tmp85_ = self->priv->view;
	_tmp86_ = game_new (20, 10, 1, 20, 10, FALSE);
	_tmp87_ = _tmp86_;
	game_view_set_game (_tmp85_, _tmp87_);
	_g_object_unref0 (_tmp87_);
	_tmp88_ = games_grid_frame_new (10, 20);
	g_object_ref_sink (_tmp88_);
	_g_object_unref0 (self->priv->game_aspect);
	self->priv->game_aspect = _tmp88_;
	_tmp89_ = self->priv->game_aspect;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp89_, TRUE);
	_tmp90_ = self->priv->game_aspect;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp90_, TRUE);
	_tmp91_ = self->priv->game_aspect;
	_tmp92_ = self->priv->view;
	games_grid_frame_set_child (_tmp91_, (GtkWidget*) _tmp92_);
	_tmp93_ = self->priv->game_aspect;
	_tmp94_ = self->priv->swipe_gesture;
	_tmp95_ = _g_object_ref0 ((GtkEventController*) _tmp94_);
	gtk_widget_add_controller ((GtkWidget*) _tmp93_, _tmp95_);
	_tmp96_ = self->priv->game_aspect;
	_tmp97_ = self->priv->long_press_gesture;
	_tmp98_ = _g_object_ref0 ((GtkEventController*) _tmp97_);
	gtk_widget_add_controller ((GtkWidget*) _tmp96_, _tmp98_);
	_tmp99_ = self->priv->game_aspect;
	gtk_widget_set_receives_default ((GtkWidget*) _tmp99_, TRUE);
	_tmp100_ = self->priv->game_aspect;
	gtk_widget_set_focusable ((GtkWidget*) _tmp100_, TRUE);
	_tmp101_ = self->priv->game_aspect;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp101_, 2);
	_tmp102_ = self->priv->game_grid;
	_tmp103_ = self->priv->game_aspect;
	gtk_grid_attach (_tmp102_, (GtkWidget*) _tmp103_, 0, 0, 2, 17);
	_tmp104_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp104_);
	_g_object_unref0 (self->priv->pause_play_button);
	self->priv->pause_play_button = _tmp104_;
	_tmp105_ = self->priv->pause_play_button;
	gtk_button_set_icon_name (_tmp105_, "media-playback-start-symbolic");
	_tmp106_ = self->priv->pause_play_button;
	gtk_actionable_set_action_name ((GtkActionable*) _tmp106_, "app.new-game");
	_tmp107_ = self->priv->pause_play_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp107_, _ ("Start a new game"));
	_tmp108_ = self->priv->pause_play_button;
	gtk_widget_set_receives_default ((GtkWidget*) _tmp108_, FALSE);
	_tmp109_ = self->priv->headerbar;
	_tmp110_ = self->priv->pause_play_button;
	adw_header_bar_pack_end (_tmp109_, (GtkWidget*) _tmp110_);
	_tmp111_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp111_);
	_g_object_unref0 (self->priv->preview_label);
	self->priv->preview_label = _tmp111_;
	_tmp112_ = self->priv->preview_label;
	_tmp113_ = self->priv->next_markup;
	gtk_label_set_markup (_tmp112_, _tmp113_);
	_tmp114_ = self->priv->preview_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp114_, GTK_ALIGN_CENTER);
	_tmp115_ = self->priv->preview_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp115_, GTK_ALIGN_CENTER);
	_tmp116_ = self->priv->preview_label;
	gtk_label_set_ellipsize (_tmp116_, PANGO_ELLIPSIZE_END);
	_tmp117_ = self->priv->game_grid;
	_tmp118_ = self->priv->preview_label;
	gtk_grid_attach (_tmp117_, (GtkWidget*) _tmp118_, 2, 0, 1, 1);
	_tmp119_ = games_grid_frame_new (5, 5);
	g_object_ref_sink (_tmp119_);
	_g_object_unref0 (self->priv->preview_frame);
	self->priv->preview_frame = _tmp119_;
	_tmp120_ = self->priv->preview_frame;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp120_, TRUE);
	_tmp121_ = self->priv->preview_frame;
	gtk_widget_set_size_request ((GtkWidget*) _tmp121_, 50, 50);
	_tmp122_ = preview_new ();
	g_object_ref_sink (_tmp122_);
	_g_object_unref0 (self->priv->preview);
	self->priv->preview = _tmp122_;
	_tmp123_ = self->priv->preview;
	_tmp124_ = self->priv->settings;
	_tmp125_ = g_settings_get_string (_tmp124_, "theme");
	_tmp126_ = _tmp125_;
	preview_set_theme (_tmp123_, _tmp126_);
	_g_free0 (_tmp126_);
	_tmp127_ = self->priv->preview;
	_tmp128_ = self->priv->settings;
	preview_set_enabled (_tmp127_, g_settings_get_boolean (_tmp128_, "do-preview"));
	_tmp129_ = self->priv->preview_frame;
	_tmp130_ = self->priv->preview;
	games_grid_frame_set_child (_tmp129_, (GtkWidget*) _tmp130_);
	_tmp131_ = self->priv->game_grid;
	_tmp132_ = self->priv->preview_frame;
	gtk_grid_attach (_tmp131_, (GtkWidget*) _tmp132_, 2, 1, 1, 3);
	_tmp133_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp133_);
	_g_object_unref0 (self->priv->score_descriptor_label);
	self->priv->score_descriptor_label = _tmp133_;
	_tmp134_ = self->priv->score_descriptor_label;
	_tmp135_ = g_strdup_printf ("<span color='gray'>%s</span>", _ ("Score"));
	_tmp136_ = _tmp135_;
	gtk_label_set_markup (_tmp134_, _tmp136_);
	_g_free0 (_tmp136_);
	_tmp137_ = self->priv->score_descriptor_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp137_, GTK_ALIGN_CENTER);
	_tmp138_ = self->priv->score_descriptor_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp138_, GTK_ALIGN_CENTER);
	_tmp139_ = self->priv->score_descriptor_label;
	gtk_label_set_ellipsize (_tmp139_, PANGO_ELLIPSIZE_END);
	_tmp140_ = self->priv->game_grid;
	_tmp141_ = self->priv->score_descriptor_label;
	gtk_grid_attach (_tmp140_, (GtkWidget*) _tmp141_, 2, 5, 1, 1);
	_tmp142_ = (GtkLabel*) gtk_label_new ("<big>-</big>");
	g_object_ref_sink (_tmp142_);
	_g_object_unref0 (self->priv->score_label);
	self->priv->score_label = _tmp142_;
	_tmp143_ = self->priv->score_label;
	g_object_set ((GtkWidget*) _tmp143_, "width-request", 120, NULL);
	_tmp144_ = self->priv->score_label;
	gtk_label_set_use_markup (_tmp144_, TRUE);
	_tmp145_ = self->priv->score_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp145_, GTK_ALIGN_CENTER);
	_tmp146_ = self->priv->score_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp146_, GTK_ALIGN_CENTER);
	_tmp147_ = self->priv->game_grid;
	_tmp148_ = self->priv->score_label;
	gtk_grid_attach (_tmp147_, (GtkWidget*) _tmp148_, 2, 6, 1, 2);
	_tmp149_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp149_);
	_g_object_unref0 (self->priv->destroyed_descriptor_label);
	self->priv->destroyed_descriptor_label = _tmp149_;
	_tmp150_ = self->priv->destroyed_descriptor_label;
	_tmp151_ = g_strdup_printf ("<span color='gray'>%s</span>", _ ("Rows"));
	_tmp152_ = _tmp151_;
	gtk_label_set_markup (_tmp150_, _tmp152_);
	_g_free0 (_tmp152_);
	_tmp153_ = self->priv->destroyed_descriptor_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp153_, GTK_ALIGN_CENTER);
	_tmp154_ = self->priv->destroyed_descriptor_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp154_, GTK_ALIGN_CENTER);
	_tmp155_ = self->priv->destroyed_descriptor_label;
	gtk_label_set_ellipsize (_tmp155_, PANGO_ELLIPSIZE_END);
	_tmp156_ = self->priv->game_grid;
	_tmp157_ = self->priv->destroyed_descriptor_label;
	gtk_grid_attach (_tmp156_, (GtkWidget*) _tmp157_, 2, 9, 1, 1);
	_tmp158_ = (GtkLabel*) gtk_label_new ("<big>-</big>");
	g_object_ref_sink (_tmp158_);
	_g_object_unref0 (self->priv->n_destroyed_label);
	self->priv->n_destroyed_label = _tmp158_;
	_tmp159_ = self->priv->n_destroyed_label;
	gtk_label_set_use_markup (_tmp159_, TRUE);
	_tmp160_ = self->priv->n_destroyed_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp160_, GTK_ALIGN_CENTER);
	_tmp161_ = self->priv->n_destroyed_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp161_, GTK_ALIGN_CENTER);
	_tmp162_ = self->priv->game_grid;
	_tmp163_ = self->priv->n_destroyed_label;
	gtk_grid_attach (_tmp162_, (GtkWidget*) _tmp163_, 2, 10, 1, 2);
	_tmp164_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp164_);
	_g_object_unref0 (self->priv->level_descriptor_label);
	self->priv->level_descriptor_label = _tmp164_;
	_tmp165_ = self->priv->level_descriptor_label;
	_tmp166_ = g_strdup_printf ("<span color='gray'>%s</span>", _ ("Level"));
	_tmp167_ = _tmp166_;
	gtk_label_set_markup (_tmp165_, _tmp167_);
	_g_free0 (_tmp167_);
	_tmp168_ = self->priv->level_descriptor_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp168_, GTK_ALIGN_CENTER);
	_tmp169_ = self->priv->level_descriptor_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp169_, GTK_ALIGN_CENTER);
	_tmp170_ = self->priv->level_descriptor_label;
	gtk_label_set_ellipsize (_tmp170_, PANGO_ELLIPSIZE_END);
	_tmp171_ = self->priv->game_grid;
	_tmp172_ = self->priv->level_descriptor_label;
	gtk_grid_attach (_tmp171_, (GtkWidget*) _tmp172_, 2, 13, 1, 1);
	_tmp173_ = (GtkLabel*) gtk_label_new ("<big>-</big>");
	g_object_ref_sink (_tmp173_);
	_g_object_unref0 (self->priv->level_label);
	self->priv->level_label = _tmp173_;
	_tmp174_ = self->priv->level_label;
	gtk_label_set_use_markup (_tmp174_, TRUE);
	_tmp175_ = self->priv->level_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp175_, GTK_ALIGN_CENTER);
	_tmp176_ = self->priv->level_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp176_, GTK_ALIGN_CENTER);
	_tmp177_ = self->priv->game_grid;
	_tmp178_ = self->priv->level_label;
	gtk_grid_attach (_tmp177_, (GtkWidget*) _tmp178_, 2, 14, 1, 2);
	_tmp179_ = games_scores_history_file_importer_new (_quadrapassel_parse_old_score_games_scores_history_file_importer_history_convert_func, self);
	_tmp180_ = _tmp179_;
	_tmp181_ = games_scores_context_new ("quadrapassel", _ ("Difficulty"), _quadrapassel_create_category_from_key_games_scores_category_request_func, self, GAMES_SCORES_STYLE_POINTS_GREATER_IS_BETTER, APP_ID, -1, (GamesScoresImporter*) _tmp180_, NULL);
	_g_object_unref0 (self->priv->context);
	self->priv->context = _tmp181_;
	_g_object_unref0 (_tmp180_);
	{
		guint16* button_collection = NULL;
		gint button_collection_length1 = 0;
		gint _button_collection_size_ = 0;
		gint button_it = 0;
		button_collection = QUADRAPASSEL_MANETTE_BUTTONS;
		button_collection_length1 = G_N_ELEMENTS (QUADRAPASSEL_MANETTE_BUTTONS);
		for (button_it = 0; button_it < button_collection_length1; button_it = button_it + 1) {
			guint16 button = 0U;
			button = button_collection[button_it];
			{
				GHashTable* _tmp182_;
				_tmp182_ = self->priv->buttons_state;
				g_hash_table_insert (_tmp182_, (gpointer) ((guintptr) button), (gpointer) ((gintptr) FALSE));
			}
		}
	}
	_tmp183_ = manette_monitor_new ();
	_g_object_unref0 (self->priv->manette_monitor);
	self->priv->manette_monitor = _tmp183_;
	_tmp184_ = self->priv->manette_monitor;
	g_signal_connect_object (_tmp184_, "device-connected", (GCallback) _quadrapassel_manette_device_connected_cb_manette_monitor_device_connected, self, 0);
	_tmp185_ = self->priv->manette_monitor;
	_tmp186_ = manette_monitor_iterate (_tmp185_);
	manette_iterator = _tmp186_;
	manette_device = NULL;
	while (TRUE) {
		ManetteMonitorIter* _tmp187_;
		ManetteDevice* _tmp188_ = NULL;
		gboolean _tmp189_;
		ManetteDevice* _tmp190_;
		ManetteDevice* _tmp191_;
		_tmp187_ = manette_iterator;
		_tmp189_ = manette_monitor_iter_next (_tmp187_, &_tmp188_);
		_g_object_unref0 (manette_device);
		_tmp190_ = _g_object_ref0 (_tmp188_);
		manette_device = _tmp190_;
		if (!_tmp189_) {
			break;
		}
		_tmp191_ = manette_device;
		quadrapassel_manette_device_connected_cb (self, _tmp191_);
	}
	_tmp192_ = g_new0 (guint, 15);
	_tmp192_[0] = GDK_KEY_Return;
	_tmp192_[1] = GDK_KEY_Pause;
	_tmp192_[2] = GDK_KEY_w;
	_tmp192_[3] = GDK_KEY_a;
	_tmp192_[4] = GDK_KEY_s;
	_tmp192_[5] = GDK_KEY_d;
	_tmp192_[6] = GDK_KEY_q;
	_tmp192_[7] = GDK_KEY_e;
	_tmp192_[8] = GDK_KEY_h;
	_tmp192_[9] = GDK_KEY_p;
	_tmp192_[10] = GDK_KEY_space;
	_tmp192_[11] = GDK_KEY_Up;
	_tmp192_[12] = GDK_KEY_Down;
	_tmp192_[13] = GDK_KEY_Left;
	_tmp192_[14] = GDK_KEY_Right;
	keys = _tmp192_;
	keys_length1 = 15;
	_keys_size_ = keys_length1;
	_tmp193_ = keys;
	_tmp193__length1 = keys_length1;
	{
		guint* key_collection = NULL;
		gint key_collection_length1 = 0;
		gint _key_collection_size_ = 0;
		gint key_it = 0;
		key_collection = _tmp193_;
		key_collection_length1 = _tmp193__length1;
		for (key_it = 0; key_it < key_collection_length1; key_it = key_it + 1) {
			guint key = 0U;
			key = key_collection[key_it];
			{
				GHashTable* _tmp194_;
				_tmp194_ = self->priv->keys_state;
				g_hash_table_insert (_tmp194_, (gpointer) ((guintptr) key), (gpointer) ((gintptr) FALSE));
			}
		}
	}
	_tmp195_ = self->priv->pause_action;
	g_simple_action_set_enabled (_tmp195_, FALSE);
	_tmp196_ = self->priv->new_game_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp196_, FALSE);
	keys = (g_free (keys), NULL);
	_g_object_unref0 (manette_device);
	__vala_ManetteMonitorIter_free0 (manette_iterator);
	_g_object_unref0 (section);
	_g_object_unref0 (menu);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (breakpoint);
	_g_object_unref0 (builder);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
___lambda16_ (Quadrapassel* self,
              GObject* object,
              GAsyncResult* _result_)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (_result_ != NULL);
	{
		GamesScoresContext* _tmp0_;
		_tmp0_ = self->priv->context;
		games_scores_context_add_score_full_finish (_tmp0_, _result_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("quadrapassel.vala:359: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
____lambda16__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	___lambda16_ ((Quadrapassel*) self, source_object, res);
	g_object_unref (self);
}

static void
quadrapassel_real_shutdown (GApplication* base)
{
	Quadrapassel * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	Game* _tmp2_;
	GSettings* _tmp17_;
	AdwApplicationWindow* _tmp18_;
	gint width = 0;
	gint height = 0;
	AdwApplicationWindow* _tmp19_;
	gint _tmp20_ = 0;
	gint _tmp21_ = 0;
	GSettings* _tmp22_;
	GSettings* _tmp23_;
	GSettings* _tmp24_;
	AdwApplicationWindow* _tmp25_;
	gboolean _tmp26_;
	gboolean _tmp27_;
	self = (Quadrapassel*) base;
	_tmp2_ = self->priv->game;
	if (_tmp2_ != NULL) {
		Game* _tmp3_;
		_tmp3_ = self->priv->game;
		_tmp1_ = !_tmp3_->game_over;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		Game* _tmp4_;
		_tmp4_ = self->priv->game;
		_tmp0_ = _tmp4_->score > 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* category_key = NULL;
		Game* _tmp5_;
		gchar* _tmp6_;
		Game* _tmp7_;
		GamesScoresContext* _tmp10_;
		Game* _tmp11_;
		const gchar* _tmp12_;
		GamesScoresCategory* _tmp13_;
		GamesScoresCategory* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp5_ = self->priv->game;
		_tmp6_ = g_strdup_printf ("%i", _tmp5_->difficulty);
		category_key = _tmp6_;
		_tmp7_ = self->priv->game;
		if (_tmp7_->pick_difficult_blocks) {
			const gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp8_ = category_key;
			_tmp9_ = g_strconcat (_tmp8_, "-difficult", NULL);
			_g_free0 (category_key);
			category_key = _tmp9_;
		}
		_tmp10_ = self->priv->context;
		_tmp11_ = self->priv->game;
		_tmp12_ = category_key;
		_tmp13_ = quadrapassel_create_category_from_key (self, _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = quadrapassel_get_game_extra_info (self);
		_tmp16_ = _tmp15_;
		games_scores_context_add_score_full (_tmp10_, (glong) _tmp11_->score, _tmp14_, _tmp16_, NULL, FALSE, NULL, ____lambda16__gasync_ready_callback, g_object_ref (self));
		_g_free0 (_tmp16_);
		_g_object_unref0 (_tmp14_);
		_g_free0 (category_key);
	}
	G_APPLICATION_CLASS (quadrapassel_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp17_ = self->priv->settings;
	_tmp18_ = self->priv->window;
	g_settings_set_int (_tmp17_, "window-width", gtk_widget_get_width ((GtkWidget*) _tmp18_));
	_tmp19_ = self->priv->window;
	gtk_window_get_default_size ((GtkWindow*) _tmp19_, &_tmp20_, &_tmp21_);
	width = _tmp20_;
	height = _tmp21_;
	_tmp22_ = self->priv->settings;
	g_settings_set_int (_tmp22_, "window-width", width);
	_tmp23_ = self->priv->settings;
	g_settings_set_int (_tmp23_, "window-height", height);
	_tmp24_ = self->priv->settings;
	_tmp25_ = self->priv->window;
	g_object_get ((GtkWindow*) _tmp25_, "maximized", &_tmp26_, NULL);
	_tmp27_ = _tmp26_;
	g_settings_set_boolean (_tmp24_, "window-is-maximized", _tmp27_);
}

static void
quadrapassel_real_activate (GApplication* base)
{
	Quadrapassel * self;
	AdwApplicationWindow* _tmp0_;
	AdwApplicationWindow* _tmp1_;
	self = (Quadrapassel*) base;
	_tmp0_ = self->priv->window;
	if (_tmp0_ == NULL) {
		quadrapassel_create_window (self);
	}
	_tmp1_ = self->priv->window;
	gtk_window_present ((GtkWindow*) _tmp1_);
}

static void
quadrapassel_breakpoint_apply_cb (Quadrapassel* self)
{
	GtkLabel* _tmp9_;
	GtkGrid* _tmp10_;
	GtkLabel* _tmp11_;
	GtkGrid* _tmp12_;
	GtkLabel* _tmp13_;
	GtkGrid* _tmp14_;
	GtkLabel* _tmp15_;
	GtkGrid* _tmp16_;
	GtkLabel* _tmp17_;
	GtkGrid* _tmp18_;
	GtkLabel* _tmp19_;
	GtkGrid* _tmp20_;
	GtkLabel* _tmp21_;
	GtkGrid* _tmp22_;
	GtkLabel* _tmp23_;
	GtkGrid* _tmp24_;
	GamesGridFrame* _tmp25_;
	GtkGrid* _tmp26_;
	GamesGridFrame* _tmp27_;
	g_return_if_fail (self != NULL);
	{
		guint n_children = 0U;
		GtkGrid* _tmp0_;
		GListModel* _tmp1_;
		GListModel* _tmp2_;
		guint _tmp3_;
		_tmp0_ = self->priv->game_grid;
		_tmp1_ = gtk_widget_observe_children ((GtkWidget*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_list_model_get_n_items (_tmp2_);
		_g_object_unref0 (_tmp2_);
		n_children = _tmp3_;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GtkGrid* _tmp6_;
				GtkGrid* _tmp7_;
				GtkWidget* _tmp8_;
				if (!_tmp4_) {
					guint _tmp5_;
					_tmp5_ = n_children;
					n_children = _tmp5_ - 1;
				}
				_tmp4_ = FALSE;
				if (!(n_children > ((guint) 0))) {
					break;
				}
				_tmp6_ = self->priv->game_grid;
				_tmp7_ = self->priv->game_grid;
				_tmp8_ = gtk_widget_get_first_child ((GtkWidget*) _tmp7_);
				gtk_grid_remove (_tmp6_, _tmp8_);
			}
		}
	}
	_tmp9_ = self->priv->score_label;
	g_object_set ((GtkWidget*) _tmp9_, "width-request", -1, NULL);
	_tmp10_ = self->priv->game_grid;
	_tmp11_ = self->priv->score_descriptor_label;
	gtk_grid_attach (_tmp10_, (GtkWidget*) _tmp11_, 0, 0, 2, 1);
	_tmp12_ = self->priv->game_grid;
	_tmp13_ = self->priv->score_label;
	gtk_grid_attach (_tmp12_, (GtkWidget*) _tmp13_, 2, 0, 2, 1);
	_tmp14_ = self->priv->game_grid;
	_tmp15_ = self->priv->destroyed_descriptor_label;
	gtk_grid_attach (_tmp14_, (GtkWidget*) _tmp15_, 4, 0, 2, 1);
	_tmp16_ = self->priv->game_grid;
	_tmp17_ = self->priv->n_destroyed_label;
	gtk_grid_attach (_tmp16_, (GtkWidget*) _tmp17_, 6, 0, 1, 1);
	_tmp18_ = self->priv->game_grid;
	_tmp19_ = self->priv->level_descriptor_label;
	gtk_grid_attach (_tmp18_, (GtkWidget*) _tmp19_, 7, 0, 2, 1);
	_tmp20_ = self->priv->game_grid;
	_tmp21_ = self->priv->level_label;
	gtk_grid_attach (_tmp20_, (GtkWidget*) _tmp21_, 9, 0, 1, 1);
	_tmp22_ = self->priv->game_grid;
	_tmp23_ = self->priv->preview_label;
	gtk_grid_attach (_tmp22_, (GtkWidget*) _tmp23_, 10, 0, 2, 1);
	_tmp24_ = self->priv->game_grid;
	_tmp25_ = self->priv->preview_frame;
	gtk_grid_attach (_tmp24_, (GtkWidget*) _tmp25_, 12, 0, 2, 1);
	_tmp26_ = self->priv->game_grid;
	_tmp27_ = self->priv->game_aspect;
	gtk_grid_attach (_tmp26_, (GtkWidget*) _tmp27_, 0, 1, 14, 17);
}

static void
quadrapassel_breakpoint_unapply_cb (Quadrapassel* self)
{
	GtkLabel* _tmp9_;
	GtkGrid* _tmp10_;
	GamesGridFrame* _tmp11_;
	GtkGrid* _tmp12_;
	GtkLabel* _tmp13_;
	GtkGrid* _tmp14_;
	GamesGridFrame* _tmp15_;
	GtkGrid* _tmp16_;
	GtkLabel* _tmp17_;
	GtkGrid* _tmp18_;
	GtkLabel* _tmp19_;
	GtkGrid* _tmp20_;
	GtkLabel* _tmp21_;
	GtkGrid* _tmp22_;
	GtkLabel* _tmp23_;
	GtkGrid* _tmp24_;
	GtkLabel* _tmp25_;
	GtkGrid* _tmp26_;
	GtkLabel* _tmp27_;
	g_return_if_fail (self != NULL);
	{
		guint n_children = 0U;
		GtkGrid* _tmp0_;
		GListModel* _tmp1_;
		GListModel* _tmp2_;
		guint _tmp3_;
		_tmp0_ = self->priv->game_grid;
		_tmp1_ = gtk_widget_observe_children ((GtkWidget*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_list_model_get_n_items (_tmp2_);
		_g_object_unref0 (_tmp2_);
		n_children = _tmp3_;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GtkGrid* _tmp6_;
				GtkGrid* _tmp7_;
				GtkWidget* _tmp8_;
				if (!_tmp4_) {
					guint _tmp5_;
					_tmp5_ = n_children;
					n_children = _tmp5_ - 1;
				}
				_tmp4_ = FALSE;
				if (!(n_children > ((guint) 0))) {
					break;
				}
				_tmp6_ = self->priv->game_grid;
				_tmp7_ = self->priv->game_grid;
				_tmp8_ = gtk_widget_get_first_child ((GtkWidget*) _tmp7_);
				gtk_grid_remove (_tmp6_, _tmp8_);
			}
		}
	}
	_tmp9_ = self->priv->score_label;
	g_object_set ((GtkWidget*) _tmp9_, "width-request", 120, NULL);
	_tmp10_ = self->priv->game_grid;
	_tmp11_ = self->priv->game_aspect;
	gtk_grid_attach (_tmp10_, (GtkWidget*) _tmp11_, 0, 0, 2, 18);
	_tmp12_ = self->priv->game_grid;
	_tmp13_ = self->priv->preview_label;
	gtk_grid_attach (_tmp12_, (GtkWidget*) _tmp13_, 2, 0, 1, 1);
	_tmp14_ = self->priv->game_grid;
	_tmp15_ = self->priv->preview_frame;
	gtk_grid_attach (_tmp14_, (GtkWidget*) _tmp15_, 2, 1, 1, 3);
	_tmp16_ = self->priv->game_grid;
	_tmp17_ = self->priv->score_descriptor_label;
	gtk_grid_attach (_tmp16_, (GtkWidget*) _tmp17_, 2, 5, 1, 1);
	_tmp18_ = self->priv->game_grid;
	_tmp19_ = self->priv->score_label;
	gtk_grid_attach (_tmp18_, (GtkWidget*) _tmp19_, 2, 6, 1, 2);
	_tmp20_ = self->priv->game_grid;
	_tmp21_ = self->priv->destroyed_descriptor_label;
	gtk_grid_attach (_tmp20_, (GtkWidget*) _tmp21_, 2, 9, 1, 1);
	_tmp22_ = self->priv->game_grid;
	_tmp23_ = self->priv->n_destroyed_label;
	gtk_grid_attach (_tmp22_, (GtkWidget*) _tmp23_, 2, 10, 1, 2);
	_tmp24_ = self->priv->game_grid;
	_tmp25_ = self->priv->level_descriptor_label;
	gtk_grid_attach (_tmp24_, (GtkWidget*) _tmp25_, 2, 13, 1, 1);
	_tmp26_ = self->priv->game_grid;
	_tmp27_ = self->priv->level_label;
	gtk_grid_attach (_tmp26_, (GtkWidget*) _tmp27_, 2, 14, 1, 2);
}

static void
quadrapassel_on_window_focus_change (Quadrapassel* self)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->game;
	if (_tmp1_ != NULL) {
		Game* _tmp2_;
		_tmp2_ = self->priv->game;
		_tmp0_ = !_tmp2_->game_over;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gboolean _tmp3_ = FALSE;
		GamesGridFrame* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->game_aspect;
		g_object_get ((GtkWidget*) _tmp4_, "has-focus", &_tmp5_, NULL);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			AdwApplicationWindow* _tmp7_;
			gboolean _tmp8_;
			gboolean _tmp9_;
			_tmp7_ = self->priv->window;
			g_object_get ((GtkWindow*) _tmp7_, "is-active", &_tmp8_, NULL);
			_tmp9_ = _tmp8_;
			_tmp3_ = _tmp9_;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			if (!self->priv->pause_requested) {
				Game* _tmp10_;
				_tmp10_ = self->priv->game;
				game_set_paused (_tmp10_, FALSE);
			}
		} else {
			gboolean _tmp11_ = FALSE;
			GtkButton* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_tmp12_ = self->priv->pause_play_button;
			g_object_get ((GtkWidget*) _tmp12_, "has-focus", &_tmp13_, NULL);
			_tmp14_ = _tmp13_;
			if (!_tmp14_) {
				GtkButton* _tmp15_;
				gboolean _tmp16_;
				gboolean _tmp17_;
				_tmp15_ = self->priv->new_game_button;
				g_object_get ((GtkWidget*) _tmp15_, "has-focus", &_tmp16_, NULL);
				_tmp17_ = _tmp16_;
				_tmp11_ = !_tmp17_;
			} else {
				_tmp11_ = FALSE;
			}
			if (_tmp11_) {
				Game* _tmp18_;
				_tmp18_ = self->priv->game;
				game_set_paused (_tmp18_, TRUE);
			}
		}
	}
}

static void
quadrapassel_user_pause (Quadrapassel* self)
{
	Game* _tmp0_;
	Game* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	Game* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_paused (_tmp1_);
	_tmp3_ = _tmp2_;
	game_set_paused (_tmp0_, !_tmp3_);
	_tmp4_ = self->priv->game;
	_tmp5_ = game_get_paused (_tmp4_);
	_tmp6_ = _tmp5_;
	self->priv->pause_requested = _tmp6_;
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		Quadrapassel* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->use_seed_toggle);
		_g_object_unref0 (_data2_->game_seed);
		_g_object_unref0 (_data2_->show_shadow_toggle);
		_g_object_unref0 (_data2_->rotate_counter_clock_wise_toggle);
		_g_object_unref0 (_data2_->do_preview_toggle);
		_g_object_unref0 (_data2_->sound_toggle);
		_g_object_unref0 (_data2_->difficult_blocks_toggle);
		_g_object_unref0 (_data2_->difficulty_row);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
__lambda6_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = self->priv->settings;
	g_settings_set_int (_tmp0_, "difficulty", (gint) adw_spin_row_get_value (_data2_->difficulty_row));
}

static void
___lambda6__gtk_editable_changed (GtkEditable* _sender,
                                  gpointer self)
{
	__lambda6_ (self);
}

static void
__lambda7_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "pick-difficult-blocks", adw_switch_row_get_active (_data2_->difficult_blocks_toggle));
}

static void
___lambda7__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda7_ (self);
}

static void
__lambda8_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	gboolean play_sound = FALSE;
	GSettings* _tmp0_;
	GameView* _tmp1_;
	self = _data2_->self;
	play_sound = adw_switch_row_get_active (_data2_->sound_toggle);
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "sound", play_sound);
	_tmp1_ = self->priv->view;
	game_view_set_mute (_tmp1_, !play_sound);
}

static void
___lambda8__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda8_ (self);
}

static void
__lambda9_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	gboolean preview_enabled = FALSE;
	GSettings* _tmp0_;
	Preview* _tmp1_;
	self = _data2_->self;
	preview_enabled = adw_switch_row_get_active (_data2_->do_preview_toggle);
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "do-preview", preview_enabled);
	_tmp1_ = self->priv->preview;
	preview_set_enabled (_tmp1_, preview_enabled);
}

static void
___lambda9__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda9_ (self);
}

static void
__lambda10_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "rotate-counter-clock-wise", adw_switch_row_get_active (_data2_->rotate_counter_clock_wise_toggle));
}

static void
___lambda10__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda10_ (self);
}

static void
__lambda11_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	gboolean show_shadow = FALSE;
	GSettings* _tmp0_;
	GameView* _tmp1_;
	self = _data2_->self;
	show_shadow = adw_switch_row_get_active (_data2_->show_shadow_toggle);
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "show-shadow", show_shadow);
	_tmp1_ = self->priv->view;
	game_view_set_show_shadow (_tmp1_, show_shadow);
}

static void
___lambda11__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda11_ (self);
}

static guint
uint_parse (const gchar* str,
            guint _base)
{
	guint result;
	g_return_val_if_fail (str != NULL, 0U);
	result = (guint) strtoul (str, NULL, (gint) _base);
	return result;
}

static void
__lambda12_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	GSettings* _tmp0_;
	const gchar* _tmp1_;
	self = _data2_->self;
	_tmp0_ = self->priv->settings;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _data2_->game_seed);
	g_settings_set_uint (_tmp0_, "seed", uint_parse (_tmp1_, (guint) 0));
}

static void
___lambda12__gtk_editable_changed (GtkEditable* _sender,
                                   gpointer self)
{
	__lambda12_ (self);
}

static void
__lambda13_ (Block2Data* _data2_)
{
	Quadrapassel* self;
	gboolean active = FALSE;
	GSettings* _tmp0_;
	self = _data2_->self;
	active = adw_switch_row_get_active (_data2_->use_seed_toggle);
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "use-seed", active);
	gtk_widget_set_sensitive ((GtkWidget*) _data2_->game_seed, active);
}

static void
___lambda13__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda13_ (self);
}

static void
quadrapassel_preferences_cb (Quadrapassel* self)
{
	Block2Data* _data2_;
	AdwPreferencesDialog* preferences_dialog = NULL;
	AdwPreferencesDialog* _tmp0_;
	AdwPreferencesPage* game_page = NULL;
	AdwPreferencesPage* _tmp1_;
	AdwPreferencesGroup* difficulty_group = NULL;
	AdwPreferencesGroup* _tmp2_;
	MoreInfoButton* more_info = NULL;
	MoreInfoButton* _tmp3_;
	MoreInfoButton* _tmp4_;
	MoreInfoButton* _tmp5_;
	GtkAdjustment* adj = NULL;
	GSettings* _tmp6_;
	GtkAdjustment* _tmp7_;
	AdwSpinRow* _tmp8_;
	AdwSwitchRow* _tmp9_;
	GSettings* _tmp10_;
	AdwPreferencesGroup* in_game_group = NULL;
	AdwPreferencesGroup* _tmp11_;
	AdwSwitchRow* _tmp12_;
	GSettings* _tmp13_;
	AdwSwitchRow* _tmp14_;
	GSettings* _tmp15_;
	AdwSwitchRow* _tmp16_;
	GSettings* _tmp17_;
	AdwSwitchRow* _tmp18_;
	GSettings* _tmp19_;
	AdwEntryRow* _tmp20_;
	GSettings* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	GSettings* _tmp24_;
	MoreInfoButton* _tmp25_;
	MoreInfoButton* _tmp26_;
	MoreInfoButton* _tmp27_;
	AdwSwitchRow* _tmp28_;
	GSettings* _tmp29_;
	AdwApplicationWindow* _tmp30_;
	g_return_if_fail (self != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = (AdwPreferencesDialog*) adw_preferences_dialog_new ();
	g_object_ref_sink (_tmp0_);
	preferences_dialog = _tmp0_;
	adw_dialog_set_title ((AdwDialog*) preferences_dialog, _ ("Preferences"));
	_tmp1_ = (AdwPreferencesPage*) adw_preferences_page_new ();
	g_object_ref_sink (_tmp1_);
	game_page = _tmp1_;
	adw_preferences_page_set_title (game_page, _ ("Game"));
	_tmp2_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	g_object_ref_sink (_tmp2_);
	difficulty_group = _tmp2_;
	adw_preferences_group_set_title (difficulty_group, _ ("Game Difficulty"));
	adw_preferences_group_set_description (difficulty_group, _ ("Change how difficult the game is"));
	_tmp3_ = more_info_button_new ();
	g_object_ref_sink (_tmp3_);
	more_info = _tmp3_;
	_tmp4_ = more_info;
	more_info_button_set_text (_tmp4_, _ ("The Difficulty affects the level you start at and how many rows are pr" \
"e-filled."));
	_tmp5_ = more_info;
	adw_preferences_group_set_header_suffix (difficulty_group, (GtkWidget*) _tmp5_);
	_tmp6_ = self->priv->settings;
	_tmp7_ = gtk_adjustment_new ((gdouble) g_settings_get_int (_tmp6_, "difficulty"), (gdouble) 0, (gdouble) 15, (gdouble) 1, (gdouble) 5, (gdouble) 0);
	g_object_ref_sink (_tmp7_);
	adj = _tmp7_;
	_tmp8_ = (AdwSpinRow*) adw_spin_row_new (adj, (gdouble) 10, (guint) 0);
	g_object_ref_sink (_tmp8_);
	_data2_->difficulty_row = _tmp8_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->difficulty_row, _ ("_Difficulty"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->difficulty_row, TRUE);
	adw_spin_row_set_update_policy (_data2_->difficulty_row, GTK_UPDATE_ALWAYS);
	adw_spin_row_set_snap_to_ticks (_data2_->difficulty_row, TRUE);
	g_signal_connect_data ((GtkEditable*) _data2_->difficulty_row, "changed", (GCallback) ___lambda6__gtk_editable_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (difficulty_group, (GtkWidget*) _data2_->difficulty_row);
	_tmp9_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp9_);
	_data2_->difficult_blocks_toggle = _tmp9_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->difficult_blocks_toggle, _ ("Choose difficult _blocks"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->difficult_blocks_toggle, TRUE);
	_tmp10_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->difficult_blocks_toggle, g_settings_get_boolean (_tmp10_, "pick-difficult-blocks"));
	g_signal_connect_data ((GObject*) _data2_->difficult_blocks_toggle, "notify::active", (GCallback) ___lambda7__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (difficulty_group, (GtkWidget*) _data2_->difficult_blocks_toggle);
	adw_preferences_page_add (game_page, difficulty_group);
	_tmp11_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	g_object_ref_sink (_tmp11_);
	in_game_group = _tmp11_;
	adw_preferences_group_set_title (in_game_group, _ ("In-Game"));
	adw_preferences_group_set_description (in_game_group, _ ("Change the experience of playing a game"));
	_tmp12_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp12_);
	_data2_->sound_toggle = _tmp12_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->sound_toggle, _ ("_Enable sounds"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->sound_toggle, TRUE);
	_tmp13_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->sound_toggle, g_settings_get_boolean (_tmp13_, "sound"));
	g_signal_connect_data ((GObject*) _data2_->sound_toggle, "notify::active", (GCallback) ___lambda8__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->sound_toggle);
	_tmp14_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp14_);
	_data2_->do_preview_toggle = _tmp14_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->do_preview_toggle, _ ("_Preview next block"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->do_preview_toggle, TRUE);
	_tmp15_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->do_preview_toggle, g_settings_get_boolean (_tmp15_, "do-preview"));
	g_signal_connect_data ((GObject*) _data2_->do_preview_toggle, "notify::active", (GCallback) ___lambda9__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->do_preview_toggle);
	_tmp16_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp16_);
	_data2_->rotate_counter_clock_wise_toggle = _tmp16_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->rotate_counter_clock_wise_toggle, _ ("_Rotate blocks counterclockwise"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->rotate_counter_clock_wise_toggle, TRUE);
	_tmp17_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->rotate_counter_clock_wise_toggle, g_settings_get_boolean (_tmp17_, "rotate-counter-clock-wise"));
	g_signal_connect_data ((GObject*) _data2_->rotate_counter_clock_wise_toggle, "notify::active", (GCallback) ___lambda10__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->rotate_counter_clock_wise_toggle);
	_tmp18_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp18_);
	_data2_->show_shadow_toggle = _tmp18_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->show_shadow_toggle, _ ("Show _where the block will land"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->show_shadow_toggle, TRUE);
	_tmp19_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->show_shadow_toggle, g_settings_get_boolean (_tmp19_, "show-shadow"));
	g_signal_connect_data ((GObject*) _data2_->show_shadow_toggle, "notify::active", (GCallback) ___lambda11__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->show_shadow_toggle);
	_tmp20_ = (AdwEntryRow*) adw_entry_row_new ();
	g_object_ref_sink (_tmp20_);
	_data2_->game_seed = _tmp20_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->game_seed, _ ("Game _seed"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->game_seed, TRUE);
	_tmp21_ = self->priv->settings;
	_tmp22_ = g_strdup_printf ("%u", g_settings_get_uint (_tmp21_, "seed"));
	_tmp23_ = _tmp22_;
	gtk_editable_set_text ((GtkEditable*) _data2_->game_seed, _tmp23_);
	_g_free0 (_tmp23_);
	_tmp24_ = self->priv->settings;
	gtk_widget_set_sensitive ((GtkWidget*) _data2_->game_seed, g_settings_get_boolean (_tmp24_, "use-seed"));
	g_signal_connect_data ((GtkEditable*) _data2_->game_seed, "changed", (GCallback) ___lambda12__gtk_editable_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp25_ = more_info_button_new ();
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (more_info);
	more_info = _tmp25_;
	_tmp26_ = more_info;
	more_info_button_set_text (_tmp26_, _ ("The seed is used to determine which blocks you get. While a seed is se" \
"t, the game will be the same every time."));
	_tmp27_ = more_info;
	adw_entry_row_add_suffix (_data2_->game_seed, (GtkWidget*) _tmp27_);
	_tmp28_ = (AdwSwitchRow*) adw_switch_row_new ();
	g_object_ref_sink (_tmp28_);
	_data2_->use_seed_toggle = _tmp28_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data2_->use_seed_toggle, _ ("_Use a custom seed for the game"));
	adw_preferences_row_set_use_underline ((AdwPreferencesRow*) _data2_->use_seed_toggle, TRUE);
	_tmp29_ = self->priv->settings;
	adw_switch_row_set_active (_data2_->use_seed_toggle, g_settings_get_boolean (_tmp29_, "use-seed"));
	g_signal_connect_data ((GObject*) _data2_->use_seed_toggle, "notify::active", (GCallback) ___lambda13__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->use_seed_toggle);
	adw_preferences_group_add (in_game_group, (GtkWidget*) _data2_->game_seed);
	adw_preferences_page_add (game_page, in_game_group);
	adw_preferences_dialog_add (preferences_dialog, game_page);
	_tmp30_ = self->priv->window;
	adw_dialog_present ((AdwDialog*) preferences_dialog, (GtkWidget*) _tmp30_);
	_g_object_unref0 (in_game_group);
	_g_object_unref0 (adj);
	_g_object_unref0 (more_info);
	_g_object_unref0 (difficulty_group);
	_g_object_unref0 (game_page);
	_g_object_unref0 (preferences_dialog);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}

static GtkWidget*
quadrapassel_theme_update (Quadrapassel* self,
                           const gchar* theme_name,
                           GtkWidget* theme_preview_widget)
{
	GamesGridFrame* theme_preview_frame = NULL;
	GamesGridFrame* _tmp0_;
	Preview* theme_preview = NULL;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	Preview* _tmp3_;
	GameView* _tmp4_;
	Preview* _tmp5_;
	GSettings* _tmp6_;
	GtkWidget* _tmp7_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (theme_name != NULL, NULL);
	g_return_val_if_fail (theme_preview_widget != NULL, NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (theme_preview_widget, GAMES_TYPE_GRID_FRAME) ? ((GamesGridFrame*) theme_preview_widget) : NULL);
	theme_preview_frame = _tmp0_;
	_tmp1_ = games_grid_frame_get_child (theme_preview_frame);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (IS_PREVIEW (_tmp2_) ? ((Preview*) _tmp2_) : NULL);
	theme_preview = _tmp3_;
	_tmp4_ = self->priv->view;
	game_view_set_theme (_tmp4_, theme_name);
	_tmp5_ = self->priv->preview;
	preview_set_theme (_tmp5_, theme_name);
	preview_set_theme (theme_preview, theme_name);
	_tmp6_ = self->priv->settings;
	g_settings_set_string (_tmp6_, "theme", theme_name);
	_tmp7_ = _g_object_ref0 (theme_preview_widget);
	result = _tmp7_;
	_g_object_unref0 (theme_preview);
	_g_object_unref0 (theme_preview_frame);
	return result;
}

static GtkWidget*
_quadrapassel_theme_update_games_theme_selector_dialog_change_theme (GamesThemeSelectorDialog* _sender,
                                                                     const gchar* theme_name,
                                                                     GtkWidget* old_theme_preview,
                                                                     gpointer self)
{
	GtkWidget* result;
	result = quadrapassel_theme_update ((Quadrapassel*) self, theme_name, old_theme_preview);
	return result;
}

static void
quadrapassel_theme_cb (Quadrapassel* self)
{
	GamesGridFrame* theme_preview_frame = NULL;
	GamesGridFrame* _tmp0_;
	Preview* theme_preview = NULL;
	Preview* _tmp1_;
	GSettings* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	Game* _tmp5_;
	Game* _tmp6_;
	Shape* _tmp7_;
	GamesThemeSelectorDialog* dialog = NULL;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	GSettings* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	GamesThemeSelectorDialog* _tmp18_;
	GamesThemeSelectorDialog* _tmp19_;
	AdwApplicationWindow* _tmp20_;
	g_return_if_fail (self != NULL);
	_tmp0_ = games_grid_frame_new (5, 5);
	g_object_ref_sink (_tmp0_);
	theme_preview_frame = _tmp0_;
	gtk_widget_set_hexpand ((GtkWidget*) theme_preview_frame, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) theme_preview_frame, TRUE);
	gtk_widget_set_size_request ((GtkWidget*) theme_preview_frame, 150, 150);
	gtk_widget_set_margin_top ((GtkWidget*) theme_preview_frame, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) theme_preview_frame, 12);
	_tmp1_ = preview_new ();
	g_object_ref_sink (_tmp1_);
	theme_preview = _tmp1_;
	_tmp2_ = self->priv->settings;
	_tmp3_ = g_settings_get_string (_tmp2_, "theme");
	_tmp4_ = _tmp3_;
	preview_set_theme (theme_preview, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = game_new (20, 10, 0, 0, 5, FALSE);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_->next_shape;
	preview_update_block (theme_preview, _tmp7_);
	_g_object_unref0 (_tmp6_);
	games_grid_frame_set_child (theme_preview_frame, (GtkWidget*) theme_preview);
	_tmp8_ = g_strdup ("plain");
	_tmp9_ = g_strdup ("tangoflat");
	_tmp10_ = g_strdup ("tangoshaded");
	_tmp11_ = g_strdup ("clean");
	_tmp12_ = g_strdup ("modern");
	_tmp13_ = g_new0 (gchar*, 5 + 1);
	_tmp13_[0] = _tmp8_;
	_tmp13_[1] = _tmp9_;
	_tmp13_[2] = _tmp10_;
	_tmp13_[3] = _tmp11_;
	_tmp13_[4] = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = 5;
	_tmp15_ = self->priv->settings;
	_tmp16_ = g_settings_get_string (_tmp15_, "theme");
	_tmp17_ = _tmp16_;
	_tmp18_ = games_theme_selector_dialog_new (_tmp14_, 5, _tmp17_, (GtkWidget*) theme_preview_frame);
	g_object_ref_sink (_tmp18_);
	_tmp19_ = _tmp18_;
	_g_free0 (_tmp17_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	dialog = _tmp19_;
	g_signal_connect_object (dialog, "change-theme", (GCallback) _quadrapassel_theme_update_games_theme_selector_dialog_change_theme, self, 0);
	_tmp20_ = self->priv->window;
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) _tmp20_);
	_g_object_unref0 (dialog);
	_g_object_unref0 (theme_preview);
	_g_object_unref0 (theme_preview_frame);
}

static void
quadrapassel_pause_cb (Quadrapassel* self)
{
	Game* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	if (_tmp0_ != NULL) {
		quadrapassel_user_pause (self);
	}
}

static void
quadrapassel_quit_cb (Quadrapassel* self)
{
	AdwApplicationWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	if (_tmp0_ != NULL) {
		AdwApplicationWindow* _tmp1_;
		_tmp1_ = self->priv->window;
		gtk_window_close ((GtkWindow*) _tmp1_);
	}
	g_application_quit ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
}

static void
_quadrapassel_manette_button_press_event_cb_manette_device_button_press_event (ManetteDevice* _sender,
                                                                               ManetteEvent* event,
                                                                               gpointer self)
{
	quadrapassel_manette_button_press_event_cb ((Quadrapassel*) self, event);
}

static void
_quadrapassel_manette_button_release_event_cb_manette_device_button_release_event (ManetteDevice* _sender,
                                                                                   ManetteEvent* event,
                                                                                   gpointer self)
{
	quadrapassel_manette_button_release_event_cb ((Quadrapassel*) self, event);
}

static void
_quadrapassel_manette_absolute_axis_event_cb_manette_device_absolute_axis_event (ManetteDevice* _sender,
                                                                                 ManetteEvent* event,
                                                                                 gpointer self)
{
	quadrapassel_manette_absolute_axis_event_cb ((Quadrapassel*) self, event);
}

static void
quadrapassel_manette_device_connected_cb (Quadrapassel* self,
                                          ManetteDevice* manette_device)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (manette_device != NULL);
	g_signal_connect_object (manette_device, "button-press-event", (GCallback) _quadrapassel_manette_button_press_event_cb_manette_device_button_press_event, self, 0);
	g_signal_connect_object (manette_device, "button-release-event", (GCallback) _quadrapassel_manette_button_release_event_cb_manette_device_button_release_event, self, 0);
	g_signal_connect_object (manette_device, "absolute-axis-event", (GCallback) _quadrapassel_manette_absolute_axis_event_cb_manette_device_absolute_axis_event, self, 0);
}

static void
quadrapassel_manette_button_press_event_cb (Quadrapassel* self,
                                            ManetteEvent* event)
{
	guint16 button = 0U;
	guint16 _tmp0_ = 0U;
	gboolean _tmp1_;
	GHashTable* _tmp2_;
	gconstpointer _tmp3_;
	GHashTable* _tmp4_;
	Game* _tmp13_;
	Game* _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp1_ = manette_event_get_button (event, &_tmp0_);
	button = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	_tmp2_ = self->priv->buttons_state;
	_tmp3_ = g_hash_table_lookup (_tmp2_, (gpointer) ((guintptr) button));
	if ((gboolean) ((gintptr) _tmp3_)) {
		return;
	}
	_tmp4_ = self->priv->buttons_state;
	g_hash_table_insert (_tmp4_, (gpointer) ((guintptr) button), (gpointer) ((gintptr) TRUE));
	if (button == BTN_SELECT) {
		GamesGridFrame* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = self->priv->game_aspect;
		g_object_get ((GtkWidget*) _tmp5_, "has-focus", &_tmp6_, NULL);
		_tmp7_ = _tmp6_;
		if (_tmp7_) {
			quadrapassel_new_game (self);
		}
		return;
	}
	if (button == BTN_START) {
		GamesGridFrame* _tmp8_;
		gboolean _tmp9_;
		gboolean _tmp10_;
		Game* _tmp11_;
		_tmp8_ = self->priv->game_aspect;
		g_object_get ((GtkWidget*) _tmp8_, "has-focus", &_tmp9_, NULL);
		_tmp10_ = _tmp9_;
		if (!_tmp10_) {
			return;
		}
		_tmp11_ = self->priv->game;
		if (_tmp11_ == NULL) {
			quadrapassel_new_game (self);
		} else {
			Game* _tmp12_;
			_tmp12_ = self->priv->game;
			if (!_tmp12_->game_over) {
				quadrapassel_user_pause (self);
			} else {
				quadrapassel_new_game (self);
			}
		}
		return;
	}
	_tmp13_ = self->priv->game;
	if (_tmp13_ == NULL) {
		return;
	}
	_tmp14_ = self->priv->game;
	_tmp15_ = game_get_paused (_tmp14_);
	_tmp16_ = _tmp15_;
	if (_tmp16_) {
		return;
	}
	if (button == BTN_DPAD_LEFT) {
		Game* _tmp17_;
		_tmp17_ = self->priv->game;
		game_move_left (_tmp17_);
		return;
	} else {
		if (button == BTN_DPAD_RIGHT) {
			Game* _tmp18_;
			_tmp18_ = self->priv->game;
			game_move_right (_tmp18_);
			return;
		} else {
			gboolean _tmp19_ = FALSE;
			if (button == BTN_TL2) {
				_tmp19_ = TRUE;
			} else {
				_tmp19_ = button == BTN_TL;
			}
			if (_tmp19_) {
				Game* _tmp20_;
				_tmp20_ = self->priv->game;
				game_rotate_left (_tmp20_);
				return;
			} else {
				gboolean _tmp21_ = FALSE;
				if (button == BTN_TR2) {
					_tmp21_ = TRUE;
				} else {
					_tmp21_ = button == BTN_TR;
				}
				if (_tmp21_) {
					Game* _tmp22_;
					_tmp22_ = self->priv->game;
					game_rotate_right (_tmp22_);
					return;
				} else {
					gboolean _tmp23_ = FALSE;
					if (button == BTN_B) {
						_tmp23_ = TRUE;
					} else {
						_tmp23_ = button == BTN_A;
					}
					if (_tmp23_) {
						Game* _tmp24_;
						_tmp24_ = self->priv->game;
						game_set_fast_forward (_tmp24_, TRUE);
						return;
					} else {
						if (button == BTN_X) {
							Game* _tmp25_;
							_tmp25_ = self->priv->game;
							game_hold (_tmp25_);
							return;
						} else {
							if (button == BTN_DPAD_DOWN) {
								Game* _tmp26_;
								_tmp26_ = self->priv->game;
								game_drop (_tmp26_);
								return;
							} else {
								if (button == BTN_DPAD_UP) {
									GSettings* _tmp27_;
									_tmp27_ = self->priv->settings;
									if (g_settings_get_boolean (_tmp27_, "rotate-counter-clock-wise")) {
										Game* _tmp28_;
										_tmp28_ = self->priv->game;
										game_rotate_left (_tmp28_);
									} else {
										Game* _tmp29_;
										_tmp29_ = self->priv->game;
										game_rotate_right (_tmp29_);
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

static void
quadrapassel_manette_button_release_event_cb (Quadrapassel* self,
                                              ManetteEvent* event)
{
	guint16 button = 0U;
	guint16 _tmp0_ = 0U;
	gboolean _tmp1_;
	GHashTable* _tmp2_;
	gconstpointer _tmp3_;
	GHashTable* _tmp4_;
	Game* _tmp5_;
	gboolean _tmp6_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp1_ = manette_event_get_button (event, &_tmp0_);
	button = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	_tmp2_ = self->priv->buttons_state;
	_tmp3_ = g_hash_table_lookup (_tmp2_, (gpointer) ((guintptr) button));
	if (!((gboolean) ((gintptr) _tmp3_))) {
		return;
	}
	_tmp4_ = self->priv->buttons_state;
	g_hash_table_insert (_tmp4_, (gpointer) ((guintptr) button), (gpointer) ((gintptr) FALSE));
	_tmp5_ = self->priv->game;
	if (_tmp5_ == NULL) {
		return;
	}
	if (button == BTN_DPAD_LEFT) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = button == BTN_DPAD_RIGHT;
	}
	if (_tmp6_) {
		Game* _tmp7_;
		_tmp7_ = self->priv->game;
		game_stop_moving (_tmp7_);
		return;
	} else {
		gboolean _tmp8_ = FALSE;
		if (button == BTN_B) {
			_tmp8_ = TRUE;
		} else {
			_tmp8_ = button == BTN_A;
		}
		if (_tmp8_) {
			Game* _tmp9_;
			_tmp9_ = self->priv->game;
			game_set_fast_forward (_tmp9_, FALSE);
			return;
		}
	}
}

static void
quadrapassel_manette_absolute_axis_event_cb (Quadrapassel* self,
                                             ManetteEvent* event)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	guint16 axis = 0U;
	gdouble val = 0.0;
	guint16 _tmp5_ = 0U;
	gdouble _tmp6_ = 0.0;
	gdouble abs = 0.0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp1_ = self->priv->game;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		Game* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->game;
		_tmp3_ = game_get_paused (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	}
	if (_tmp0_) {
		return;
	}
	manette_event_get_absolute (event, &_tmp5_, &_tmp6_);
	axis = _tmp5_;
	val = _tmp6_;
	if (axis != ABS_X) {
		return;
	}
	abs = fabs (val);
	if (abs < 0.5) {
		Game* _tmp7_;
		_tmp7_ = self->priv->game;
		game_stop_moving (_tmp7_);
		return;
	}
	if (val > ((gdouble) 0)) {
		Game* _tmp8_;
		_tmp8_ = self->priv->game;
		game_move_right (_tmp8_);
	} else {
		if (val < ((gdouble) 0)) {
			Game* _tmp9_;
			_tmp9_ = self->priv->game;
			game_move_left (_tmp9_);
		}
	}
}

static gboolean
quadrapassel_key_press_event_cb (Quadrapassel* self,
                                 GtkEventControllerKey* controller,
                                 guint keyval,
                                 guint keycode,
                                 GdkModifierType state)
{
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	GHashTable* _tmp2_;
	Game* _tmp3_;
	gboolean _tmp6_ = FALSE;
	Game* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (controller != NULL, FALSE);
	_tmp0_ = self->priv->keys_state;
	_tmp1_ = g_hash_table_lookup (_tmp0_, (gpointer) ((guintptr) keyval));
	if ((gboolean) ((gintptr) _tmp1_)) {
		result = TRUE;
		return result;
	}
	_tmp2_ = self->priv->keys_state;
	g_hash_table_insert (_tmp2_, (gpointer) ((guintptr) keyval), (gpointer) ((gintptr) TRUE));
	_tmp3_ = self->priv->game;
	if (_tmp3_ != NULL) {
		gboolean _tmp4_ = FALSE;
		Game* _tmp5_;
		_tmp5_ = self->priv->game;
		if (_tmp5_->game_over) {
			_tmp4_ = keyval == GDK_KEY_Return;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			quadrapassel_new_game (self);
			result = TRUE;
			return result;
		}
	} else {
		if (keyval == GDK_KEY_Return) {
			quadrapassel_new_game (self);
			result = TRUE;
			return result;
		}
		result = FALSE;
		return result;
	}
	if (keyval == GDK_KEY_Pause) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = keyval == GDK_KEY_p;
	}
	if (_tmp6_) {
		Game* _tmp7_;
		_tmp7_ = self->priv->game;
		if (!_tmp7_->game_over) {
			quadrapassel_user_pause (self);
		}
		result = TRUE;
		return result;
	}
	_tmp8_ = self->priv->game;
	_tmp9_ = game_get_paused (_tmp8_);
	_tmp10_ = _tmp9_;
	if (_tmp10_) {
		result = FALSE;
		return result;
	}
	if (keyval == GDK_KEY_Left) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = keyval == GDK_KEY_a;
	}
	if (_tmp11_) {
		Game* _tmp12_;
		_tmp12_ = self->priv->game;
		game_move_left (_tmp12_);
		result = TRUE;
		return result;
	} else {
		gboolean _tmp13_ = FALSE;
		if (keyval == GDK_KEY_Right) {
			_tmp13_ = TRUE;
		} else {
			_tmp13_ = keyval == GDK_KEY_d;
		}
		if (_tmp13_) {
			Game* _tmp14_;
			_tmp14_ = self->priv->game;
			game_move_right (_tmp14_);
			result = TRUE;
			return result;
		} else {
			gboolean _tmp15_ = FALSE;
			if (keyval == GDK_KEY_Up) {
				_tmp15_ = TRUE;
			} else {
				_tmp15_ = keyval == GDK_KEY_w;
			}
			if (_tmp15_) {
				GSettings* _tmp16_;
				_tmp16_ = self->priv->settings;
				if (g_settings_get_boolean (_tmp16_, "rotate-counter-clock-wise")) {
					Game* _tmp17_;
					_tmp17_ = self->priv->game;
					game_rotate_left (_tmp17_);
				} else {
					Game* _tmp18_;
					_tmp18_ = self->priv->game;
					game_rotate_right (_tmp18_);
				}
				result = TRUE;
				return result;
			} else {
				gboolean _tmp19_ = FALSE;
				if (keyval == GDK_KEY_Down) {
					_tmp19_ = TRUE;
				} else {
					_tmp19_ = keyval == GDK_KEY_s;
				}
				if (_tmp19_) {
					Game* _tmp20_;
					_tmp20_ = self->priv->game;
					game_set_fast_forward (_tmp20_, TRUE);
					result = TRUE;
					return result;
				} else {
					if (keyval == GDK_KEY_q) {
						Game* _tmp21_;
						_tmp21_ = self->priv->game;
						game_rotate_left (_tmp21_);
						result = TRUE;
						return result;
					} else {
						if (keyval == GDK_KEY_e) {
							Game* _tmp22_;
							_tmp22_ = self->priv->game;
							game_rotate_right (_tmp22_);
							result = TRUE;
							return result;
						} else {
							if (keyval == GDK_KEY_space) {
								Game* _tmp23_;
								_tmp23_ = self->priv->game;
								game_drop (_tmp23_);
								result = TRUE;
								return result;
							} else {
								if (keyval == GDK_KEY_h) {
									Game* _tmp24_;
									_tmp24_ = self->priv->game;
									game_hold (_tmp24_);
									result = TRUE;
									return result;
								}
							}
						}
					}
				}
			}
		}
	}
	result = FALSE;
	return result;
}

static void
quadrapassel_key_release_event_cb (Quadrapassel* self,
                                   GtkEventControllerKey* controller,
                                   guint keyval,
                                   guint keycode,
                                   GdkModifierType state)
{
	Game* _tmp0_;
	GHashTable* _tmp1_;
	gconstpointer _tmp2_;
	GHashTable* _tmp3_;
	gboolean _tmp4_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (controller != NULL);
	_tmp0_ = self->priv->game;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->keys_state;
	_tmp2_ = g_hash_table_lookup (_tmp1_, (gpointer) ((guintptr) keyval));
	if (!((gboolean) ((gintptr) _tmp2_))) {
		return;
	}
	_tmp3_ = self->priv->keys_state;
	g_hash_table_insert (_tmp3_, (gpointer) ((guintptr) keyval), (gpointer) ((gintptr) FALSE));
	if (keyval == GDK_KEY_Left) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = keyval == GDK_KEY_a;
	}
	if (_tmp4_) {
		Game* _tmp5_;
		gboolean _tmp6_ = FALSE;
		GHashTable* _tmp7_;
		gconstpointer _tmp8_;
		_tmp5_ = self->priv->game;
		game_stop_moving (_tmp5_);
		_tmp7_ = self->priv->keys_state;
		_tmp8_ = g_hash_table_lookup (_tmp7_, (gpointer) ((guintptr) GDK_KEY_Right));
		if ((gboolean) ((gintptr) _tmp8_)) {
			_tmp6_ = TRUE;
		} else {
			GHashTable* _tmp9_;
			gconstpointer _tmp10_;
			_tmp9_ = self->priv->keys_state;
			_tmp10_ = g_hash_table_lookup (_tmp9_, (gpointer) ((guintptr) GDK_KEY_d));
			_tmp6_ = (gboolean) ((gintptr) _tmp10_);
		}
		if (_tmp6_) {
			Game* _tmp11_;
			_tmp11_ = self->priv->game;
			game_move_right (_tmp11_);
		}
		return;
	} else {
		gboolean _tmp12_ = FALSE;
		if (keyval == GDK_KEY_Right) {
			_tmp12_ = TRUE;
		} else {
			_tmp12_ = keyval == GDK_KEY_d;
		}
		if (_tmp12_) {
			Game* _tmp13_;
			gboolean _tmp14_ = FALSE;
			GHashTable* _tmp15_;
			gconstpointer _tmp16_;
			_tmp13_ = self->priv->game;
			game_stop_moving (_tmp13_);
			_tmp15_ = self->priv->keys_state;
			_tmp16_ = g_hash_table_lookup (_tmp15_, (gpointer) ((guintptr) GDK_KEY_Left));
			if ((gboolean) ((gintptr) _tmp16_)) {
				_tmp14_ = TRUE;
			} else {
				GHashTable* _tmp17_;
				gconstpointer _tmp18_;
				_tmp17_ = self->priv->keys_state;
				_tmp18_ = g_hash_table_lookup (_tmp17_, (gpointer) ((guintptr) GDK_KEY_a));
				_tmp14_ = (gboolean) ((gintptr) _tmp18_);
			}
			if (_tmp14_) {
				Game* _tmp19_;
				_tmp19_ = self->priv->game;
				game_move_left (_tmp19_);
			}
			return;
		} else {
			gboolean _tmp20_ = FALSE;
			if (keyval == GDK_KEY_Down) {
				_tmp20_ = TRUE;
			} else {
				_tmp20_ = keyval == GDK_KEY_s;
			}
			if (_tmp20_) {
				Game* _tmp21_;
				_tmp21_ = self->priv->game;
				game_set_fast_forward (_tmp21_, FALSE);
				return;
			}
		}
	}
}

static void
quadrapassel_swipe_cb (Quadrapassel* self,
                       gdouble velocity_x,
                       gdouble velocity_y)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	gboolean _tmp5_ = FALSE;
	gdouble direction = 0.0;
	gboolean _tmp11_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->game;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		Game* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->game;
		_tmp3_ = game_get_paused (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	}
	if (_tmp0_) {
		return;
	}
	if (velocity_x == ((gdouble) 0)) {
		_tmp5_ = velocity_y == ((gdouble) 0);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		Game* _tmp6_;
		_tmp6_ = self->priv->game;
		if (game_get_fast_forward (_tmp6_)) {
			Game* _tmp7_;
			_tmp7_ = self->priv->game;
			game_set_fast_forward (_tmp7_, FALSE);
		} else {
			GSettings* _tmp8_;
			_tmp8_ = self->priv->settings;
			if (g_settings_get_boolean (_tmp8_, "rotate-counter-clock-wise")) {
				Game* _tmp9_;
				_tmp9_ = self->priv->game;
				game_rotate_left (_tmp9_);
			} else {
				Game* _tmp10_;
				_tmp10_ = self->priv->game;
				game_rotate_right (_tmp10_);
			}
		}
		return;
	}
	direction = (atan2 (velocity_y, velocity_x) * 180) / G_PI;
	if (direction < ((gdouble) 0)) {
		direction += 360.0;
	}
	if (direction >= ((gdouble) 135)) {
		_tmp11_ = direction < ((gdouble) 225);
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		Game* _tmp12_;
		Game* _tmp13_;
		_tmp12_ = self->priv->game;
		game_move_left (_tmp12_);
		_tmp13_ = self->priv->game;
		game_stop_moving (_tmp13_);
	} else {
		gboolean _tmp14_ = FALSE;
		if (direction >= ((gdouble) 315)) {
			_tmp14_ = TRUE;
		} else {
			_tmp14_ = direction < ((gdouble) 45);
		}
		if (_tmp14_) {
			Game* _tmp15_;
			Game* _tmp16_;
			_tmp15_ = self->priv->game;
			game_move_right (_tmp15_);
			_tmp16_ = self->priv->game;
			game_stop_moving (_tmp16_);
		} else {
			gboolean _tmp17_ = FALSE;
			if (direction >= ((gdouble) 225)) {
				_tmp17_ = direction < ((gdouble) 315);
			} else {
				_tmp17_ = FALSE;
			}
			if (_tmp17_) {
				GSettings* _tmp18_;
				_tmp18_ = self->priv->settings;
				if (g_settings_get_boolean (_tmp18_, "rotate-counter-clock-wise")) {
					Game* _tmp19_;
					_tmp19_ = self->priv->game;
					game_rotate_right (_tmp19_);
				} else {
					Game* _tmp20_;
					_tmp20_ = self->priv->game;
					game_rotate_left (_tmp20_);
				}
			} else {
				Game* _tmp21_;
				_tmp21_ = self->priv->game;
				game_drop (_tmp21_);
			}
		}
	}
}

static void
quadrapassel_long_press_cb (Quadrapassel* self,
                            gdouble x,
                            gdouble y)
{
	Game* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	if (_tmp0_ != NULL) {
		Game* _tmp1_;
		_tmp1_ = self->priv->game;
		game_set_fast_forward (_tmp1_, TRUE);
	}
}

static void
quadrapassel_new_game_cb (Quadrapassel* self)
{
	g_return_if_fail (self != NULL);
	quadrapassel_new_game (self);
}

static void
_quadrapassel_pause_changed_cb_game_pause_changed (Game* _sender,
                                                   gpointer self)
{
	quadrapassel_pause_changed_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_shape_landed_cb_game_shape_landed (Game* _sender,
                                                 gint* lines,
                                                 gint lines_length1,
                                                 GList* line_blocks,
                                                 gpointer self)
{
	quadrapassel_shape_landed_cb ((Quadrapassel*) self, lines, lines_length1, line_blocks);
}

static void
_quadrapassel_shape_added_cb_game_shape_added (Game* _sender,
                                               gpointer self)
{
	quadrapassel_shape_added_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_shape_held_cb_game_shape_held (Game* _sender,
                                             gpointer self)
{
	quadrapassel_shape_held_cb ((Quadrapassel*) self);
}

static void
_quadrapassel_complete_cb_game_complete (Game* _sender,
                                         gpointer self)
{
	quadrapassel_complete_cb ((Quadrapassel*) self);
}

static void
quadrapassel_new_game (Quadrapassel* self)
{
	Game* _tmp0_;
	GSettings* _tmp3_;
	GSettings* _tmp5_;
	GSettings* _tmp6_;
	GSettings* _tmp7_;
	Game* _tmp8_;
	Game* _tmp9_;
	Game* _tmp10_;
	Game* _tmp11_;
	Game* _tmp12_;
	Game* _tmp13_;
	GamesGridFrame* _tmp14_;
	GameView* _tmp15_;
	Game* _tmp16_;
	Game* _tmp17_;
	GSimpleAction* _tmp18_;
	GtkButton* _tmp19_;
	GtkButton* _tmp20_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	if (_tmp0_ != NULL) {
		Game* _tmp1_;
		Game* _tmp2_;
		_tmp1_ = self->priv->game;
		game_stop (_tmp1_);
		_tmp2_ = self->priv->game;
		g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_DATA, (guint) 0, (GQuark) 0, NULL, NULL, self);
	}
	self->priv->pause_requested = FALSE;
	_tmp3_ = self->priv->settings;
	if (g_settings_get_boolean (_tmp3_, "use-seed")) {
		GSettings* _tmp4_;
		_tmp4_ = self->priv->settings;
		g_random_set_seed ((guint32) g_settings_get_uint (_tmp4_, "seed"));
	}
	_tmp5_ = self->priv->settings;
	_tmp6_ = self->priv->settings;
	_tmp7_ = self->priv->settings;
	_tmp8_ = game_new (20, 10, g_settings_get_int (_tmp5_, "difficulty"), g_settings_get_int (_tmp6_, "difficulty"), 5, g_settings_get_boolean (_tmp7_, "pick-difficult-blocks"));
	_g_object_unref0 (self->priv->game);
	self->priv->game = _tmp8_;
	_tmp9_ = self->priv->game;
	g_signal_connect_object (_tmp9_, "pause-changed", (GCallback) _quadrapassel_pause_changed_cb_game_pause_changed, self, 0);
	_tmp10_ = self->priv->game;
	g_signal_connect_object (_tmp10_, "shape-landed", (GCallback) _quadrapassel_shape_landed_cb_game_shape_landed, self, 0);
	_tmp11_ = self->priv->game;
	g_signal_connect_object (_tmp11_, "shape-added", (GCallback) _quadrapassel_shape_added_cb_game_shape_added, self, 0);
	_tmp12_ = self->priv->game;
	g_signal_connect_object (_tmp12_, "shape-held", (GCallback) _quadrapassel_shape_held_cb_game_shape_held, self, 0);
	_tmp13_ = self->priv->game;
	g_signal_connect_object (_tmp13_, "complete", (GCallback) _quadrapassel_complete_cb_game_complete, self, 0);
	_tmp14_ = self->priv->game_aspect;
	gtk_widget_grab_focus ((GtkWidget*) _tmp14_);
	_tmp15_ = self->priv->view;
	_tmp16_ = self->priv->game;
	game_view_set_game (_tmp15_, _tmp16_);
	_tmp17_ = self->priv->game;
	game_start (_tmp17_);
	quadrapassel_update_score (self);
	_tmp18_ = self->priv->pause_action;
	g_simple_action_set_enabled (_tmp18_, TRUE);
	_tmp19_ = self->priv->new_game_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp19_, TRUE);
	_tmp20_ = self->priv->pause_play_button;
	gtk_actionable_set_action_name ((GtkActionable*) _tmp20_, "app.pause");
}

static void
quadrapassel_pause_changed_cb (Quadrapassel* self)
{
	Game* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	_tmp1_ = game_get_paused (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GtkButton* _tmp3_;
		GtkButton* _tmp4_;
		Preview* _tmp5_;
		_tmp3_ = self->priv->pause_play_button;
		gtk_button_set_icon_name (_tmp3_, "media-playback-start-symbolic");
		_tmp4_ = self->priv->pause_play_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp4_, _ ("Unpause the game"));
		_tmp5_ = self->priv->preview;
		preview_set_hidden (_tmp5_, TRUE);
	} else {
		GtkButton* _tmp6_;
		GtkButton* _tmp7_;
		Preview* _tmp8_;
		GamesGridFrame* _tmp9_;
		_tmp6_ = self->priv->pause_play_button;
		gtk_button_set_icon_name (_tmp6_, "media-playback-pause-symbolic");
		_tmp7_ = self->priv->pause_play_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp7_, _ ("Pause the game"));
		_tmp8_ = self->priv->preview;
		preview_set_hidden (_tmp8_, FALSE);
		_tmp9_ = self->priv->game_aspect;
		gtk_widget_grab_focus ((GtkWidget*) _tmp9_);
	}
}

static void
quadrapassel_shape_landed_cb (Quadrapassel* self,
                              gint* lines,
                              gint lines_length1,
                              GList* line_blocks)
{
	g_return_if_fail (self != NULL);
	quadrapassel_update_score (self);
}

static void
quadrapassel_shape_added_cb (Quadrapassel* self)
{
	gboolean _tmp0_ = FALSE;
	Game* _tmp1_;
	Shape* _tmp2_;
	GtkLabel* _tmp5_;
	const gchar* _tmp6_;
	Preview* _tmp7_;
	Game* _tmp8_;
	Shape* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->game;
	_tmp2_ = _tmp1_->shape;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		Game* _tmp3_;
		Shape* _tmp4_;
		_tmp3_ = self->priv->game;
		_tmp4_ = _tmp3_->held_shape;
		_tmp0_ = _tmp4_ != NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp5_ = self->priv->preview_label;
	_tmp6_ = self->priv->next_markup;
	gtk_label_set_label (_tmp5_, _tmp6_);
	_tmp7_ = self->priv->preview;
	_tmp8_ = self->priv->game;
	_tmp9_ = _tmp8_->next_shape;
	preview_update_block (_tmp7_, _tmp9_);
}

static void
quadrapassel_shape_held_cb (Quadrapassel* self)
{
	Game* _tmp0_;
	Shape* _tmp1_;
	GtkLabel* _tmp2_;
	const gchar* _tmp3_;
	Preview* _tmp4_;
	Game* _tmp5_;
	Shape* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game;
	_tmp1_ = _tmp0_->held_shape;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = self->priv->preview_label;
	_tmp3_ = self->priv->hold_markup;
	gtk_label_set_label (_tmp2_, _tmp3_);
	_tmp4_ = self->priv->preview;
	_tmp5_ = self->priv->game;
	_tmp6_ = _tmp5_->held_shape;
	preview_update_block (_tmp4_, _tmp6_);
}

static gchar*
quadrapassel_get_game_extra_info (Quadrapassel* self)
{
	Game* _tmp0_;
	Game* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->game;
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_level (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup_printf ("%s: %i\n%s: %i\n", _ ("Rows"), _tmp0_->n_lines_destroyed, _ ("Level"), _tmp3_);
	result = _tmp4_;
	return result;
}

static void
___lambda5_ (Quadrapassel* self,
             GObject* object,
             GAsyncResult* _result_)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (_result_ != NULL);
	{
		GamesScoresAddScoreResult _tmp0_ = (GamesScoresAddScoreResult) ((GamesScoresAddScoreResult) {.action = 0, .high_score_added = false});
		GamesScoresContext* _tmp1_;
		GamesScoresAddScoreAction score_result = 0;
		_tmp1_ = self->priv->context;
		_tmp0_ = games_scores_context_add_score_full_finish (_tmp1_, _result_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		score_result = _tmp0_.action;
		if (score_result == GAMES_SCORES_ADD_SCORE_ACTION_NEW_GAME) {
			quadrapassel_new_game (self);
		} else {
			if (score_result == GAMES_SCORES_ADD_SCORE_ACTION_QUIT) {
				quadrapassel_quit_cb (self);
			}
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("quadrapassel.vala:1038: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
____lambda5__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	___lambda5_ ((Quadrapassel*) self, source_object, res);
	g_object_unref (self);
}

static void
quadrapassel_complete_cb (Quadrapassel* self)
{
	GSimpleAction* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	Game* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->pause_action;
	g_simple_action_set_enabled (_tmp0_, FALSE);
	_tmp1_ = self->priv->pause_play_button;
	gtk_button_set_icon_name (_tmp1_, "media-playback-start-symbolic");
	_tmp2_ = self->priv->pause_play_button;
	gtk_actionable_set_action_name ((GtkActionable*) _tmp2_, "app.new-game");
	_tmp3_ = self->priv->pause_play_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, _ ("Start the game"));
	_tmp4_ = self->priv->new_game_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = self->priv->game;
	if (_tmp5_->score > 0) {
		gchar* category_key = NULL;
		Game* _tmp6_;
		gchar* _tmp7_;
		Game* _tmp8_;
		GamesScoresContext* _tmp11_;
		Game* _tmp12_;
		const gchar* _tmp13_;
		GamesScoresCategory* _tmp14_;
		GamesScoresCategory* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		AdwApplicationWindow* _tmp18_;
		_tmp6_ = self->priv->game;
		_tmp7_ = g_strdup_printf ("%i", _tmp6_->difficulty);
		category_key = _tmp7_;
		_tmp8_ = self->priv->game;
		if (_tmp8_->pick_difficult_blocks) {
			const gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = category_key;
			_tmp10_ = g_strconcat (_tmp9_, "-difficult", NULL);
			_g_free0 (category_key);
			category_key = _tmp10_;
		}
		_tmp11_ = self->priv->context;
		_tmp12_ = self->priv->game;
		_tmp13_ = category_key;
		_tmp14_ = quadrapassel_create_category_from_key (self, _tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = quadrapassel_get_game_extra_info (self);
		_tmp17_ = _tmp16_;
		_tmp18_ = self->priv->window;
		games_scores_context_add_score_full (_tmp11_, (glong) _tmp12_->score, _tmp15_, _tmp17_, (GtkWindow*) _tmp18_, TRUE, NULL, ____lambda5__gasync_ready_callback, g_object_ref (self));
		_g_free0 (_tmp17_);
		_g_object_unref0 (_tmp15_);
		_g_free0 (category_key);
	}
}

static GamesScoresCategory*
quadrapassel_create_category_from_key (Quadrapassel* self,
                                       const gchar* key)
{
	gchar** tokens = NULL;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint tokens_length1;
	gint _tokens_size_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	GamesScoresCategory* _tmp12_;
	GamesScoresCategory* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	if (g_strcmp0 (key, "old-scores") == 0) {
		GamesScoresCategory* _tmp0_;
		_tmp0_ = games_scores_category_new (key, _ ("Old Scores"));
		result = _tmp0_;
		return result;
	}
	_tmp2_ = _tmp1_ = g_strsplit (key, "-", 0);
	tokens = _tmp2_;
	tokens_length1 = _vala_array_length (_tmp1_);
	_tokens_size_ = tokens_length1;
	_tmp3_ = tokens;
	_tmp3__length1 = tokens_length1;
	if (_tmp3__length1 != 1) {
		gchar** _tmp4_;
		gint _tmp4__length1;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GamesScoresCategory* _tmp10_;
		GamesScoresCategory* _tmp11_;
		_tmp4_ = tokens;
		_tmp4__length1 = tokens_length1;
		_tmp5_ = _tmp4_[0];
		_tmp6_ = g_strconcat (_tmp5_, "-", NULL);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_strconcat (_tmp7_, _ ("Difficult"), NULL);
		_tmp9_ = _tmp8_;
		_tmp10_ = games_scores_category_new (key, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_g_free0 (_tmp7_);
		result = _tmp11_;
		tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp12_ = games_scores_category_new (key, key);
	result = _tmp12_;
	tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static GTimeZone*
vala_g_time_zone_new_identifier (const gchar* identifier,
                                 GError** error)
{
	GTimeZone* self;
	GError* _inner_error0_ = NULL;
	self = (GTimeZone*) g_time_zone_new_identifier (identifier);
	if (((GTimeZone*) self) == NULL) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Invalid identifier argument");
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		_g_time_zone_unref0 (self);
		return NULL;
	}
	return self;
}

static gint64
quadrapassel_parse_date (Quadrapassel* self,
                         const gchar* date)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gint _tmp5_;
	gint _tmp6_;
	gint year = 0;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gint _tmp9_;
	gint month = 0;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gint _tmp12_;
	gint day = 0;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gint _tmp15_;
	gint hour = 0;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gint _tmp18_;
	gint minute = 0;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gint _tmp21_;
	gint seconds = 0;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gint _tmp24_;
	gint64 _tmp32_ = -1LL;
	GError* _inner_error0_ = NULL;
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	g_return_val_if_fail (date != NULL, -1LL);
	_tmp5_ = strlen (date);
	_tmp6_ = _tmp5_;
	if (_tmp6_ < 19) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = string_get (date, (glong) 4) != '-';
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = string_get (date, (glong) 7) != '-';
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = string_get (date, (glong) 10) != 'T';
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = string_get (date, (glong) 13) != ':';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = string_get (date, (glong) 16) != ':';
	}
	if (_tmp0_) {
		g_warning ("quadrapassel.vala:1061: Failed to parse date: %s", date);
	}
	_tmp7_ = string_substring (date, (glong) 0, (glong) 4);
	_tmp8_ = _tmp7_;
	_tmp9_ = atoi (_tmp8_);
	_g_free0 (_tmp8_);
	year = _tmp9_;
	_tmp10_ = string_substring (date, (glong) 5, (glong) 2);
	_tmp11_ = _tmp10_;
	_tmp12_ = atoi (_tmp11_);
	_g_free0 (_tmp11_);
	month = _tmp12_;
	_tmp13_ = string_substring (date, (glong) 8, (glong) 2);
	_tmp14_ = _tmp13_;
	_tmp15_ = atoi (_tmp14_);
	_g_free0 (_tmp14_);
	day = _tmp15_;
	_tmp16_ = string_substring (date, (glong) 11, (glong) 2);
	_tmp17_ = _tmp16_;
	_tmp18_ = atoi (_tmp17_);
	_g_free0 (_tmp17_);
	hour = _tmp18_;
	_tmp19_ = string_substring (date, (glong) 14, (glong) 2);
	_tmp20_ = _tmp19_;
	_tmp21_ = atoi (_tmp20_);
	_g_free0 (_tmp20_);
	minute = _tmp21_;
	_tmp22_ = string_substring (date, (glong) 17, (glong) 2);
	_tmp23_ = _tmp22_;
	_tmp24_ = atoi (_tmp23_);
	_g_free0 (_tmp23_);
	seconds = _tmp24_;
	{
		GTimeZone* timezone = NULL;
		gchar* _tmp25_;
		gchar* _tmp26_;
		GTimeZone* _tmp27_;
		GTimeZone* _tmp28_;
		GDateTime* _tmp29_;
		GDateTime* _tmp30_;
		gint64 _tmp31_;
		_tmp25_ = string_substring (date, (glong) 19, (glong) -1);
		_tmp26_ = _tmp25_;
		_tmp27_ = vala_g_time_zone_new_identifier (_tmp26_, &_inner_error0_);
		_tmp28_ = _tmp27_;
		_g_free0 (_tmp26_);
		timezone = _tmp28_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp29_ = g_date_time_new (timezone, year, month, day, hour, minute, (gdouble) seconds);
		_tmp30_ = _tmp29_;
		_tmp31_ = g_date_time_to_unix (_tmp30_);
		_g_date_time_unref0 (_tmp30_);
		result = _tmp31_;
		_g_time_zone_unref0 (timezone);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_warning ("quadrapassel.vala:1073: Failed to parse date: %s", date);
		result = (gint64) 0;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp32_;
}

static void
quadrapassel_parse_old_score (Quadrapassel* self,
                              const gchar* line,
                              GamesScoresScore** score,
                              GamesScoresCategory** category)
{
	GamesScoresScore* _vala_score = NULL;
	GamesScoresCategory* _vala_category = NULL;
	gchar** tokens = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint tokens_length1;
	gint _tokens_size_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gint64 date = 0LL;
	gchar** _tmp3_;
	gint _tmp3__length1;
	const gchar* _tmp4_;
	gint points = 0;
	gchar** _tmp5_;
	gint _tmp5__length1;
	const gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GamesScoresScore* _tmp8_;
	GamesScoresCategory* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (line != NULL);
	_g_object_unref0 (_vala_score);
	_vala_score = NULL;
	_g_object_unref0 (_vala_category);
	_vala_category = NULL;
	_tmp1_ = _tmp0_ = g_strsplit (line, " ", 0);
	tokens = _tmp1_;
	tokens_length1 = _vala_array_length (_tmp0_);
	_tokens_size_ = tokens_length1;
	_tmp2_ = tokens;
	_tmp2__length1 = tokens_length1;
	if (_tmp2__length1 != 2) {
		tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		if (score) {
			*score = _vala_score;
		} else {
			_g_object_unref0 (_vala_score);
		}
		if (category) {
			*category = _vala_category;
		} else {
			_g_object_unref0 (_vala_category);
		}
		return;
	}
	_tmp3_ = tokens;
	_tmp3__length1 = tokens_length1;
	_tmp4_ = _tmp3_[0];
	date = quadrapassel_parse_date (self, _tmp4_);
	_tmp5_ = tokens;
	_tmp5__length1 = tokens_length1;
	_tmp6_ = _tmp5_[1];
	points = atoi (_tmp6_);
	if (date <= ((gint64) 0)) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = points < 0;
	}
	if (_tmp7_) {
		tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		if (score) {
			*score = _vala_score;
		} else {
			_g_object_unref0 (_vala_score);
		}
		if (category) {
			*category = _vala_category;
		} else {
			_g_object_unref0 (_vala_category);
		}
		return;
	}
	_tmp8_ = games_scores_score_new ((glong) points, date, NULL);
	_g_object_unref0 (_vala_score);
	_vala_score = _tmp8_;
	_tmp9_ = quadrapassel_create_category_from_key (self, "old-scores");
	_g_object_unref0 (_vala_category);
	_vala_category = _tmp9_;
	tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
	if (score) {
		*score = _vala_score;
	} else {
		_g_object_unref0 (_vala_score);
	}
	if (category) {
		*category = _vala_category;
	} else {
		_g_object_unref0 (_vala_category);
	}
}

static void
quadrapassel_update_score (Quadrapassel* self)
{
	gint score = 0;
	gint level = 0;
	gint n_lines_destroyed = 0;
	Game* _tmp0_;
	GtkLabel* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkLabel* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkLabel* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	g_return_if_fail (self != NULL);
	score = 0;
	level = 0;
	n_lines_destroyed = 0;
	_tmp0_ = self->priv->game;
	if (_tmp0_ != NULL) {
		Game* _tmp1_;
		Game* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		Game* _tmp5_;
		_tmp1_ = self->priv->game;
		score = _tmp1_->score;
		_tmp2_ = self->priv->game;
		_tmp3_ = game_get_level (_tmp2_);
		_tmp4_ = _tmp3_;
		level = _tmp4_;
		_tmp5_ = self->priv->game;
		n_lines_destroyed = _tmp5_->n_lines_destroyed;
	}
	_tmp6_ = self->priv->score_label;
	_tmp7_ = g_strdup_printf ("<big>%d</big>", score);
	_tmp8_ = _tmp7_;
	gtk_label_set_markup (_tmp6_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->priv->level_label;
	_tmp10_ = g_strdup_printf ("<big>%d</big>", level);
	_tmp11_ = _tmp10_;
	gtk_label_set_markup (_tmp9_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = self->priv->n_destroyed_label;
	_tmp13_ = g_strdup_printf ("<big>%d</big>", n_lines_destroyed);
	_tmp14_ = _tmp13_;
	gtk_label_set_markup (_tmp12_, _tmp14_);
	_g_free0 (_tmp14_);
}

static void
quadrapassel_rules_cb (Quadrapassel* self)
{
	GtkBuilder* dialog_builder = NULL;
	GtkBuilder* _tmp0_;
	AdwDialog* rules_dialog = NULL;
	GObject* _tmp3_;
	AdwDialog* _tmp4_;
	GtkImage* game_symbolic = NULL;
	GObject* _tmp5_;
	GtkImage* _tmp6_;
	AdwActionRow* points_row = NULL;
	GObject* _tmp7_;
	AdwActionRow* _tmp8_;
	GtkGrid* points_info = NULL;
	GObject* _tmp9_;
	GtkGrid* _tmp10_;
	MoreInfoButton* more_info = NULL;
	MoreInfoButton* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	AdwApplicationWindow* _tmp14_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_builder_new ();
	dialog_builder = _tmp0_;
	{
		gtk_builder_add_from_resource (dialog_builder, "/org/gnome/Quadrapassel/rules-dialog.ui", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_critical ("quadrapassel.vala:1124: Could not load rules dialog: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (dialog_builder);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp3_ = gtk_builder_get_object (dialog_builder, "rules_dialog");
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, adw_dialog_get_type (), AdwDialog));
	rules_dialog = _tmp4_;
	_tmp5_ = gtk_builder_get_object (dialog_builder, "game_symbolic");
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_image_get_type (), GtkImage));
	game_symbolic = _tmp6_;
	_tmp7_ = gtk_builder_get_object (dialog_builder, "points_row");
	_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, adw_action_row_get_type (), AdwActionRow));
	points_row = _tmp8_;
	_tmp9_ = gtk_builder_get_object (dialog_builder, "points_info");
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_grid_get_type (), GtkGrid));
	points_info = _tmp10_;
	_tmp11_ = more_info_button_new ();
	g_object_ref_sink (_tmp11_);
	more_info = _tmp11_;
	more_info_button_set_text (more_info, C_ ("game rules", "Points are calculated based on how many rows are destroyed."));
	more_info_button_set_extra_child (more_info, (GtkWidget*) points_info);
	adw_action_row_add_suffix (points_row, (GtkWidget*) more_info);
	_tmp12_ = g_strdup_printf ("%s-symbolic", APP_ID);
	_tmp13_ = _tmp12_;
	gtk_image_set_from_icon_name (game_symbolic, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp14_ = self->priv->window;
	adw_dialog_present (rules_dialog, (GtkWidget*) _tmp14_);
	_g_object_unref0 (more_info);
	_g_object_unref0 (points_info);
	_g_object_unref0 (points_row);
	_g_object_unref0 (game_symbolic);
	_g_object_unref0 (rules_dialog);
	_g_object_unref0 (dialog_builder);
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
_vala_array_dup2 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
quadrapassel_about_cb (Quadrapassel* self)
{
	gchar** authors = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint authors_length1;
	gint _authors_size_;
	gchar** documenters = NULL;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gint documenters_length1;
	gint _documenters_size_;
	AdwAboutDialog* about = NULL;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	AdwAboutDialog* _tmp15_ = NULL;
	GtkWindow* _tmp16_;
	GtkWindow* _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("J. Marcin Gorycki");
	_tmp1_ = g_strdup ("Robert Ancell");
	_tmp2_ = g_strdup ("John Ward");
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	authors = _tmp3_;
	authors_length1 = 3;
	_authors_size_ = authors_length1;
	_tmp4_ = g_strdup ("Angela Boyle");
	_tmp5_ = g_new0 (gchar*, 1 + 1);
	_tmp5_[0] = _tmp4_;
	documenters = _tmp5_;
	documenters_length1 = 1;
	_documenters_size_ = documenters_length1;
	_tmp6_ = g_strdup (_ ("Quadrapassel"));
	_tmp7_ = g_strdup (APP_ID);
	_tmp8_ = (authors != NULL) ? _vala_array_dup1 (authors, authors_length1) : authors;
	_tmp8__length1 = authors_length1;
	_tmp9_ = g_strdup (_ ("A classic game where you rotate blocks to make complete rows, but don'" \
"t pile your blocks too high or it's game over!"));
	_tmp10_ = g_strdup ("Copyright © 1999 J. Marcin Gorycki, 2000–2015 Others");
	_tmp11_ = (documenters != NULL) ? _vala_array_dup2 (documenters, documenters_length1) : documenters;
	_tmp11__length1 = documenters_length1;
	_tmp12_ = g_strdup (_ ("translator-credits"));
	_tmp13_ = g_strdup (VERSION);
	_tmp14_ = g_strdup ("https://wiki.gnome.org/Apps/Quadrapassel");
	_tmp15_ = (AdwAboutDialog*) adw_about_dialog_new ();
	adw_about_dialog_set_application_name (_tmp15_, _tmp6_);
	_g_free0 (_tmp6_);
	adw_about_dialog_set_application_icon (_tmp15_, _tmp7_);
	_g_free0 (_tmp7_);
	adw_about_dialog_set_developers (_tmp15_, _tmp8_);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_comments (_tmp15_, _tmp9_);
	_g_free0 (_tmp9_);
	adw_about_dialog_set_copyright (_tmp15_, _tmp10_);
	_g_free0 (_tmp10_);
	adw_about_dialog_set_license_type (_tmp15_, GTK_LICENSE_GPL_3_0);
	adw_about_dialog_set_documenters (_tmp15_, _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_translator_credits (_tmp15_, _tmp12_);
	_g_free0 (_tmp12_);
	adw_about_dialog_set_version (_tmp15_, _tmp13_);
	_g_free0 (_tmp13_);
	adw_about_dialog_set_website (_tmp15_, _tmp14_);
	_g_free0 (_tmp14_);
	g_object_ref_sink (_tmp15_);
	about = _tmp15_;
	_tmp16_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp17_ = _tmp16_;
	adw_dialog_present ((AdwDialog*) about, (GtkWidget*) _tmp17_);
	_g_object_unref0 (about);
	documenters = (_vala_array_free (documenters, documenters_length1, (GDestroyNotify) g_free), NULL);
	authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
}

static void
quadrapassel_menu_cb (Quadrapassel* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->menu_button;
	g_signal_emit_by_name (_tmp0_, "activate");
}

static void
quadrapassel_scores_cb (Quadrapassel* self)
{
	gchar* category_key = NULL;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	GSettings* _tmp2_;
	GamesScoresContext* _tmp5_;
	AdwApplicationWindow* _tmp6_;
	const gchar* _tmp7_;
	GamesScoresCategory* _tmp8_;
	GamesScoresCategory* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = g_strdup_printf ("%i", g_settings_get_int (_tmp0_, "difficulty"));
	category_key = _tmp1_;
	_tmp2_ = self->priv->settings;
	if (g_settings_get_boolean (_tmp2_, "pick-difficult-blocks")) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = category_key;
		_tmp4_ = g_strconcat (_tmp3_, "-difficult", NULL);
		_g_free0 (category_key);
		category_key = _tmp4_;
	}
	_tmp5_ = self->priv->context;
	_tmp6_ = self->priv->window;
	_tmp7_ = category_key;
	_tmp8_ = quadrapassel_create_category_from_key (self, _tmp7_);
	_tmp9_ = _tmp8_;
	games_scores_context_present_dialog (_tmp5_, (GtkWindow*) _tmp6_, _tmp9_);
	_g_object_unref0 (_tmp9_);
	_g_free0 (category_key);
}

static gint
quadrapassel_main (gchar** args,
                   gint args_length1)
{
	Quadrapassel* app = NULL;
	Quadrapassel* _tmp0_;
	gint result;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = quadrapassel_new ();
	app = _tmp0_;
	result = g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
	return result;
}

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

static void
quadrapassel_class_init (QuadrapasselClass * klass,
                         gpointer klass_data)
{
	quadrapassel_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Quadrapassel_private_offset);
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) quadrapassel_real_startup;
	((GApplicationClass *) klass)->shutdown = (void (*) (GApplication*)) quadrapassel_real_shutdown;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) quadrapassel_real_activate;
	G_OBJECT_CLASS (klass)->finalize = quadrapassel_finalize;
}

static void
quadrapassel_instance_init (Quadrapassel * self,
                            gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	GHashFunc _tmp5_;
	GEqualFunc _tmp6_;
	GHashTable* _tmp7_;
	self->priv = quadrapassel_get_instance_private (self);
	self->priv->game = NULL;
	_tmp0_ = g_strdup_printf ("<span color='gray'>%s</span>", _ ("Next"));
	self->priv->next_markup = _tmp0_;
	_tmp1_ = g_strdup_printf ("<span color='gray'>%s</span>", _ ("Hold"));
	self->priv->hold_markup = _tmp1_;
	_tmp2_ = g_direct_hash;
	_tmp3_ = g_direct_equal;
	_tmp4_ = g_hash_table_new_full (_tmp2_, _tmp3_, NULL, NULL);
	self->priv->buttons_state = _tmp4_;
	self->priv->pause_requested = FALSE;
	_tmp5_ = g_direct_hash;
	_tmp6_ = g_direct_equal;
	_tmp7_ = g_hash_table_new_full (_tmp5_, _tmp6_, NULL, NULL);
	self->priv->keys_state = _tmp7_;
}

static void
quadrapassel_finalize (GObject * obj)
{
	Quadrapassel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_QUADRAPASSEL, Quadrapassel);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->headerbar);
	_g_object_unref0 (self->priv->event_controller_key);
	_g_object_unref0 (self->priv->swipe_gesture);
	_g_object_unref0 (self->priv->long_press_gesture);
	_g_object_unref0 (self->priv->menu_button);
	_g_object_unref0 (self->priv->context);
	_g_object_unref0 (self->priv->game_aspect);
	_g_object_unref0 (self->priv->game);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->game_grid);
	_g_object_unref0 (self->priv->preview);
	_g_object_unref0 (self->priv->preview_frame);
	_g_free0 (self->priv->next_markup);
	_g_free0 (self->priv->hold_markup);
	_g_object_unref0 (self->priv->preview_label);
	_g_object_unref0 (self->priv->score_label);
	_g_object_unref0 (self->priv->score_descriptor_label);
	_g_object_unref0 (self->priv->n_destroyed_label);
	_g_object_unref0 (self->priv->destroyed_descriptor_label);
	_g_object_unref0 (self->priv->level_label);
	_g_object_unref0 (self->priv->level_descriptor_label);
	_g_object_unref0 (self->priv->pause_action);
	_g_object_unref0 (self->priv->pause_play_button);
	_g_object_unref0 (self->priv->new_game_button);
	_g_object_unref0 (self->priv->manette_monitor);
	_g_hash_table_unref0 (self->priv->buttons_state);
	_g_hash_table_unref0 (self->priv->keys_state);
	G_OBJECT_CLASS (quadrapassel_parent_class)->finalize (obj);
}

static GType
quadrapassel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QuadrapasselClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) quadrapassel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Quadrapassel), 0, (GInstanceInitFunc) quadrapassel_instance_init, NULL };
	GType quadrapassel_type_id;
	quadrapassel_type_id = g_type_register_static (adw_application_get_type (), "Quadrapassel", &g_define_type_info, 0);
	Quadrapassel_private_offset = g_type_add_instance_private (quadrapassel_type_id, sizeof (QuadrapasselPrivate));
	return quadrapassel_type_id;
}

GType
quadrapassel_get_type (void)
{
	static volatile gsize quadrapassel_type_id__once = 0;
	if (g_once_init_enter (&quadrapassel_type_id__once)) {
		GType quadrapassel_type_id;
		quadrapassel_type_id = quadrapassel_get_type_once ();
		g_once_init_leave (&quadrapassel_type_id__once, quadrapassel_type_id);
	}
	return quadrapassel_type_id__once;
}

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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

