/* gnome-tetravex.c generated by valac 0.25.4.4-19ea, the Vala compiler
 * generated from gnome-tetravex.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * Copyright (C) 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 2 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

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


#define TYPE_TETRAVEX (tetravex_get_type ())
#define TETRAVEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TETRAVEX, Tetravex))
#define TETRAVEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TETRAVEX, TetravexClass))
#define IS_TETRAVEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TETRAVEX))
#define IS_TETRAVEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TETRAVEX))
#define TETRAVEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TETRAVEX, TetravexClass))

typedef struct _Tetravex Tetravex;
typedef struct _TetravexClass TetravexClass;
typedef struct _TetravexPrivate TetravexPrivate;

#define TYPE_PUZZLE (puzzle_get_type ())
#define PUZZLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PUZZLE, Puzzle))
#define PUZZLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PUZZLE, PuzzleClass))
#define IS_PUZZLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PUZZLE))
#define IS_PUZZLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PUZZLE))
#define PUZZLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PUZZLE, PuzzleClass))

typedef struct _Puzzle Puzzle;
typedef struct _PuzzleClass PuzzleClass;

#define TYPE_HISTORY (history_get_type ())
#define HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY, History))
#define HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY, HistoryClass))
#define IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY))
#define IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY))
#define HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY, HistoryClass))

typedef struct _History History;
typedef struct _HistoryClass HistoryClass;

#define TYPE_PUZZLE_VIEW (puzzle_view_get_type ())
#define PUZZLE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PUZZLE_VIEW, PuzzleView))
#define PUZZLE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PUZZLE_VIEW, PuzzleViewClass))
#define IS_PUZZLE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PUZZLE_VIEW))
#define IS_PUZZLE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PUZZLE_VIEW))
#define PUZZLE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PUZZLE_VIEW, PuzzleViewClass))

typedef struct _PuzzleView PuzzleView;
typedef struct _PuzzleViewClass PuzzleViewClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

#define TYPE_HISTORY_ENTRY (history_entry_get_type ())
#define HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY_ENTRY, HistoryEntry))
#define HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY_ENTRY, HistoryEntryClass))
#define IS_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY_ENTRY))
#define IS_HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY_ENTRY))
#define HISTORY_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY_ENTRY, HistoryEntryClass))

typedef struct _HistoryEntry HistoryEntry;
typedef struct _HistoryEntryClass HistoryEntryClass;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define TYPE_SCORE_DIALOG (score_dialog_get_type ())
#define SCORE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SCORE_DIALOG, ScoreDialog))
#define SCORE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SCORE_DIALOG, ScoreDialogClass))
#define IS_SCORE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SCORE_DIALOG))
#define IS_SCORE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SCORE_DIALOG))
#define SCORE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SCORE_DIALOG, ScoreDialogClass))

typedef struct _ScoreDialog ScoreDialog;
typedef struct _ScoreDialogClass ScoreDialogClass;

struct _Tetravex {
	GtkApplication parent_instance;
	TetravexPrivate * priv;
};

struct _TetravexClass {
	GtkApplicationClass parent_class;
};

struct _TetravexPrivate {
	GSettings* settings;
	Puzzle* puzzle;
	GtkLabel* clock_label;
	History* history;
	PuzzleView* view;
	GtkApplicationWindow* window;
	gint window_width;
	gint window_height;
	gboolean is_maximized;
	GtkStack* new_game_solve_stack;
	GtkStack* play_pause_stack;
};


static gpointer tetravex_parent_class = NULL;
static gboolean tetravex_start_paused;
static gboolean tetravex_start_paused = FALSE;
static gint tetravex_game_size;
static gint tetravex_game_size = 0;

GType tetravex_get_type (void) G_GNUC_CONST;
GType puzzle_get_type (void) G_GNUC_CONST;
GType history_get_type (void) G_GNUC_CONST;
GType puzzle_view_get_type (void) G_GNUC_CONST;
#define TETRAVEX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TETRAVEX, TetravexPrivate))
enum  {
	TETRAVEX_DUMMY_PROPERTY
};
#define TETRAVEX_KEY_GRID_SIZE "grid-size"
static void tetravex_new_game_cb (Tetravex* self);
static void _tetravex_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_pause_cb (Tetravex* self, GSimpleAction* action, GVariant* parameter);
static void _tetravex_pause_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_solve_cb (Tetravex* self);
static void _tetravex_solve_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_scores_cb (Tetravex* self);
static void _tetravex_scores_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_quit_cb (Tetravex* self);
static void _tetravex_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_move_up_cb (Tetravex* self);
static void _tetravex_move_up_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_move_down_cb (Tetravex* self);
static void _tetravex_move_down_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_move_left_cb (Tetravex* self);
static void _tetravex_move_left_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_move_right_cb (Tetravex* self);
static void _tetravex_move_right_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_radio_cb (Tetravex* self, GSimpleAction* action, GVariant* parameter);
static void _tetravex_radio_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_size_changed (Tetravex* self, GSimpleAction* action, GVariant* value);
static void _tetravex_size_changed_gsimple_action_change_state_callback (GSimpleAction* action, GVariant* value, gpointer self);
static void tetravex_help_cb (Tetravex* self);
static void _tetravex_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void tetravex_about_cb (Tetravex* self);
static void _tetravex_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
Tetravex* tetravex_new (void);
Tetravex* tetravex_construct (GType object_type);
static void tetravex_real_startup (GApplication* base);
History* history_new (const gchar* filename);
History* history_construct (GType object_type, const gchar* filename);
void history_load (History* self);
static gboolean tetravex_window_configure_event_cb (Tetravex* self, GdkEventConfigure* event);
static gboolean _tetravex_window_configure_event_cb_gtk_widget_configure_event (GtkWidget* _sender, GdkEventConfigure* event, gpointer self);
static gboolean tetravex_window_state_event_cb (Tetravex* self, GdkEventWindowState* event);
static gboolean _tetravex_window_state_event_cb_gtk_widget_window_state_event (GtkWidget* _sender, GdkEventWindowState* event, gpointer self);
static GVariant* _variant_new1 (gchar* value);
PuzzleView* puzzle_view_new (void);
PuzzleView* puzzle_view_construct (GType object_type);
static gboolean tetravex_view_button_press_event (Tetravex* self, GtkWidget* widget, GdkEventButton* event);
static gboolean _tetravex_view_button_press_event_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static void tetravex_tick_cb (Tetravex* self);
static void tetravex_new_game (Tetravex* self);
static void tetravex_real_shutdown (GApplication* base);
static gint tetravex_real_handle_local_options (GApplication* base, GVariantDict* options);
static gint _variant_get2 (GVariant* value);
static void tetravex_real_activate (GApplication* base);
static GVariant* _variant_new3 (gboolean value);
Puzzle* puzzle_new (guint size);
Puzzle* puzzle_construct (GType object_type, guint size);
static void _tetravex_tick_cb_puzzle_tick (Puzzle* _sender, gpointer self);
static void tetravex_solved_cb (Tetravex* self, Puzzle* puzzle);
static void _tetravex_solved_cb_puzzle_solved (Puzzle* _sender, gpointer self);
void puzzle_view_set_puzzle (PuzzleView* self, Puzzle* value);
void puzzle_set_paused (Puzzle* self, gboolean value);
static void tetravex_update_button_states (Tetravex* self);
gdouble puzzle_get_elapsed (Puzzle* self);
GType history_entry_get_type (void) G_GNUC_CONST;
guint puzzle_get_size (Puzzle* self);
HistoryEntry* history_entry_new (GDateTime* date, guint size, guint duration);
HistoryEntry* history_entry_construct (GType object_type, GDateTime* date, guint size, guint duration);
void history_add (History* self, HistoryEntry* entry);
void history_save (History* self);
static gint tetravex_show_scores (Tetravex* self, HistoryEntry* selected_entry, gboolean show_quit);
GType score_dialog_get_type (void) G_GNUC_CONST;
ScoreDialog* score_dialog_new (History* history, HistoryEntry* selected_entry, gboolean show_quit);
ScoreDialog* score_dialog_construct (GType object_type, History* history, HistoryEntry* selected_entry, gboolean show_quit);
gboolean puzzle_get_paused (Puzzle* self);
void puzzle_solve (Puzzle* self);
static gchar* _variant_get4 (GVariant* value);
void puzzle_move_up (Puzzle* self);
void puzzle_move_left (Puzzle* self);
void puzzle_move_right (Puzzle* self);
void puzzle_move_down (Puzzle* self);
gint tetravex_main (gchar** args, int args_length1);
static void tetravex_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);

static const GOptionEntry TETRAVEX_option_entries[4] = {{"version", 'v', 0, G_OPTION_ARG_NONE, NULL, "Print release version and exit", NULL}, {"paused", 'p', 0, G_OPTION_ARG_NONE, NULL, "Start the game paused", NULL}, {"size", 's', 0, G_OPTION_ARG_INT, NULL, "Set size of board (2-6)", NULL}, {NULL}};
static const GActionEntry TETRAVEX_action_entries[12] = {{"new-game", _tetravex_new_game_cb_gsimple_action_activate_callback}, {"pause", _tetravex_pause_cb_gsimple_action_activate_callback}, {"solve", _tetravex_solve_cb_gsimple_action_activate_callback}, {"scores", _tetravex_scores_cb_gsimple_action_activate_callback}, {"quit", _tetravex_quit_cb_gsimple_action_activate_callback}, {"move-up", _tetravex_move_up_cb_gsimple_action_activate_callback}, {"move-down", _tetravex_move_down_cb_gsimple_action_activate_callback}, {"move-left", _tetravex_move_left_cb_gsimple_action_activate_callback}, {"move-right", _tetravex_move_right_cb_gsimple_action_activate_callback}, {"size", _tetravex_radio_cb_gsimple_action_activate_callback, "s", "'2'", _tetravex_size_changed_gsimple_action_change_state_callback}, {"help", _tetravex_help_cb_gsimple_action_activate_callback}, {"about", _tetravex_about_cb_gsimple_action_activate_callback}};

static void _tetravex_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_new_game_cb ((Tetravex*) self);
}


static void _tetravex_pause_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_pause_cb ((Tetravex*) self, action, parameter);
}


static void _tetravex_solve_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_solve_cb ((Tetravex*) self);
}


static void _tetravex_scores_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_scores_cb ((Tetravex*) self);
}


static void _tetravex_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_quit_cb ((Tetravex*) self);
}


static void _tetravex_move_up_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_move_up_cb ((Tetravex*) self);
}


static void _tetravex_move_down_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_move_down_cb ((Tetravex*) self);
}


static void _tetravex_move_left_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_move_left_cb ((Tetravex*) self);
}


static void _tetravex_move_right_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_move_right_cb ((Tetravex*) self);
}


static void _tetravex_radio_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_radio_cb ((Tetravex*) self, action, parameter);
}


static void _tetravex_size_changed_gsimple_action_change_state_callback (GSimpleAction* action, GVariant* value, gpointer self) {
	tetravex_size_changed ((Tetravex*) self, action, value);
}


static void _tetravex_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_help_cb ((Tetravex*) self);
}


static void _tetravex_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	tetravex_about_cb ((Tetravex*) self);
}


Tetravex* tetravex_construct (GType object_type) {
	Tetravex * self = NULL;
	self = (Tetravex*) g_object_new (object_type, "application-id", "org.gnome.tetravex", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	g_application_add_main_option_entries ((GApplication*) self, TETRAVEX_option_entries);
	return self;
}


Tetravex* tetravex_new (void) {
	return tetravex_construct (TYPE_TETRAVEX);
}


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


static gboolean _tetravex_window_configure_event_cb_gtk_widget_configure_event (GtkWidget* _sender, GdkEventConfigure* event, gpointer self) {
	gboolean result;
	result = tetravex_window_configure_event_cb ((Tetravex*) self, event);
	return result;
}


static gboolean _tetravex_window_state_event_cb_gtk_widget_window_state_event (GtkWidget* _sender, GdkEventWindowState* event, gpointer self) {
	gboolean result;
	result = tetravex_window_state_event_cb ((Tetravex*) self, event);
	return result;
}


static GVariant* _variant_new1 (gchar* value) {
	return g_variant_ref_sink (g_variant_new_string (value));
}


static gboolean _tetravex_view_button_press_event_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = tetravex_view_button_press_event ((Tetravex*) self, _sender, event);
	return result;
}


static void tetravex_real_startup (GApplication* base) {
	Tetravex * self;
	const gchar* _tmp0_ = NULL;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp1_ = NULL;
	GtkBuilder* _tmp5_ = NULL;
	GObject* _tmp6_ = NULL;
	GSettings* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	History* _tmp11_ = NULL;
	History* _tmp12_ = NULL;
	GtkBuilder* _tmp13_ = NULL;
	GObject* _tmp14_ = NULL;
	GtkApplicationWindow* _tmp15_ = NULL;
	GtkApplicationWindow* _tmp16_ = NULL;
	GtkApplicationWindow* _tmp17_ = NULL;
	GtkApplicationWindow* _tmp18_ = NULL;
	GtkApplicationWindow* _tmp19_ = NULL;
	GSettings* _tmp20_ = NULL;
	gint _tmp21_ = 0;
	GSettings* _tmp22_ = NULL;
	gint _tmp23_ = 0;
	GSettings* _tmp24_ = NULL;
	gboolean _tmp25_ = FALSE;
	gint _tmp27_ = 0;
	GAction* _tmp32_ = NULL;
	gint _tmp33_ = 0;
	gchar* _tmp34_ = NULL;
	gchar* _tmp35_ = NULL;
	GVariant* _tmp36_ = NULL;
	GtkHeaderBar* headerbar = NULL;
	GtkHeaderBar* _tmp37_ = NULL;
	const gchar* _tmp38_ = NULL;
	GtkApplicationWindow* _tmp39_ = NULL;
	GtkGrid* grid = NULL;
	GtkBuilder* _tmp40_ = NULL;
	GObject* _tmp41_ = NULL;
	GtkGrid* _tmp42_ = NULL;
	PuzzleView* _tmp43_ = NULL;
	PuzzleView* _tmp44_ = NULL;
	PuzzleView* _tmp45_ = NULL;
	PuzzleView* _tmp46_ = NULL;
	PuzzleView* _tmp47_ = NULL;
	GtkSizeGroup* sizegroup = NULL;
	GtkSizeGroup* _tmp48_ = NULL;
	GtkButton* play_button = NULL;
	GtkButton* _tmp49_ = NULL;
	GtkStyleContext* _tmp50_ = NULL;
	GtkImage* image = NULL;
	GtkImage* _tmp51_ = NULL;
	GtkImage* _tmp52_ = NULL;
	GtkImage* _tmp53_ = NULL;
	const gchar* _tmp54_ = NULL;
	GtkButton* pause_button = NULL;
	GtkButton* _tmp55_ = NULL;
	GtkStyleContext* _tmp56_ = NULL;
	GtkImage* _tmp57_ = NULL;
	GtkImage* _tmp58_ = NULL;
	GtkImage* _tmp59_ = NULL;
	const gchar* _tmp60_ = NULL;
	GtkStack* _tmp61_ = NULL;
	GtkStack* _tmp62_ = NULL;
	GtkStack* _tmp63_ = NULL;
	GtkStack* _tmp64_ = NULL;
	GtkButton* new_game_button = NULL;
	GtkButton* _tmp65_ = NULL;
	GtkStyleContext* _tmp66_ = NULL;
	GtkImage* _tmp67_ = NULL;
	GtkImage* _tmp68_ = NULL;
	GtkImage* _tmp69_ = NULL;
	const gchar* _tmp70_ = NULL;
	GtkButton* solve_button = NULL;
	GtkButton* _tmp71_ = NULL;
	GtkStyleContext* _tmp72_ = NULL;
	GtkImage* _tmp73_ = NULL;
	GtkImage* _tmp74_ = NULL;
	GtkImage* _tmp75_ = NULL;
	const gchar* _tmp76_ = NULL;
	GtkStack* _tmp77_ = NULL;
	GtkStack* _tmp78_ = NULL;
	GtkStack* _tmp79_ = NULL;
	GtkStack* _tmp80_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp81_ = NULL;
	GtkImage* _tmp82_ = NULL;
	GtkImage* _tmp83_ = NULL;
	GtkLabel* _tmp84_ = NULL;
	GtkLabel* _tmp85_ = NULL;
	GtkApplicationWindow* _tmp86_ = NULL;
	GError * _inner_error_ = NULL;
	self = (Tetravex*) base;
	G_APPLICATION_CLASS (tetravex_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	_tmp0_ = _ ("Tetravex");
	g_set_application_name (_tmp0_);
	gtk_window_set_default_icon_name ("gnome-tetravex");
	g_action_map_add_action_entries ((GActionMap*) self, TETRAVEX_action_entries, G_N_ELEMENTS (TETRAVEX_action_entries), self);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>n", "app.new-game", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "Pause", "app.pause", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "F1", "app.help", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>q", "app.quit", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>Up", "app.move-up", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>Down", "app.move-down", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>Left", "app.move-left", NULL);
	gtk_application_add_accelerator ((GtkApplication*) self, "<Primary>Right", "app.move-right", NULL);
	_tmp1_ = gtk_builder_new ();
	builder = _tmp1_;
	{
		GtkBuilder* _tmp2_ = NULL;
		GtkBuilder* _tmp3_ = NULL;
		_tmp2_ = builder;
		gtk_builder_add_from_resource (_tmp2_, "/org/gnome/tetravex/gnome-tetravex.ui", &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = builder;
		gtk_builder_add_from_resource (_tmp3_, "/org/gnome/tetravex/app-menu.ui", &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp4_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = e->message;
		g_error ("gnome-tetravex.vala:91: Unable to build menus: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (builder);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp5_ = builder;
	_tmp6_ = gtk_builder_get_object (_tmp5_, "gnome-tetravex-menu");
	gtk_application_set_app_menu ((GtkApplication*) self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, g_menu_model_get_type ()) ? ((GMenuModel*) _tmp6_) : NULL);
	_tmp7_ = g_settings_new ("org.gnome.tetravex");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp7_;
	_tmp8_ = g_get_user_data_dir ();
	_tmp9_ = g_build_filename (_tmp8_, "gnome-tetravex", "history", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = history_new (_tmp10_);
	_g_object_unref0 (self->priv->history);
	self->priv->history = _tmp11_;
	_g_free0 (_tmp10_);
	_tmp12_ = self->priv->history;
	history_load (_tmp12_);
	_tmp13_ = builder;
	_tmp14_ = gtk_builder_get_object (_tmp13_, "gnome-tetravex-window");
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp14_, gtk_application_window_get_type ()) ? ((GtkApplicationWindow*) _tmp14_) : NULL);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp15_;
	_tmp16_ = self->priv->window;
	gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) _tmp16_);
	_tmp17_ = self->priv->window;
	g_signal_connect_object ((GtkWidget*) _tmp17_, "configure-event", (GCallback) _tetravex_window_configure_event_cb_gtk_widget_configure_event, self, 0);
	_tmp18_ = self->priv->window;
	g_signal_connect_object ((GtkWidget*) _tmp18_, "window-state-event", (GCallback) _tetravex_window_state_event_cb_gtk_widget_window_state_event, self, 0);
	_tmp19_ = self->priv->window;
	_tmp20_ = self->priv->settings;
	_tmp21_ = g_settings_get_int (_tmp20_, "window-width");
	_tmp22_ = self->priv->settings;
	_tmp23_ = g_settings_get_int (_tmp22_, "window-height");
	gtk_window_set_default_size ((GtkWindow*) _tmp19_, _tmp21_, _tmp23_);
	_tmp24_ = self->priv->settings;
	_tmp25_ = g_settings_get_boolean (_tmp24_, "window-is-maximized");
	if (_tmp25_) {
		GtkApplicationWindow* _tmp26_ = NULL;
		_tmp26_ = self->priv->window;
		gtk_window_maximize ((GtkWindow*) _tmp26_);
	}
	_tmp27_ = tetravex_game_size;
	if (_tmp27_ != 0) {
		GSettings* _tmp28_ = NULL;
		gint _tmp29_ = 0;
		_tmp28_ = self->priv->settings;
		_tmp29_ = tetravex_game_size;
		g_settings_set_int (_tmp28_, TETRAVEX_KEY_GRID_SIZE, _tmp29_);
	} else {
		GSettings* _tmp30_ = NULL;
		gint _tmp31_ = 0;
		_tmp30_ = self->priv->settings;
		_tmp31_ = g_settings_get_int (_tmp30_, TETRAVEX_KEY_GRID_SIZE);
		tetravex_game_size = _tmp31_;
	}
	_tmp32_ = g_action_map_lookup_action ((GActionMap*) self, "size");
	_tmp33_ = tetravex_game_size;
	_tmp34_ = g_strdup_printf ("%d", _tmp33_);
	_tmp35_ = _tmp34_;
	_tmp36_ = _variant_new1 (_tmp35_);
	g_simple_action_set_state (G_TYPE_CHECK_INSTANCE_TYPE (_tmp32_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp32_) : NULL, _tmp36_);
	_g_variant_unref0 (_tmp36_);
	_g_free0 (_tmp35_);
	_tmp37_ = (GtkHeaderBar*) gtk_header_bar_new ();
	g_object_ref_sink (_tmp37_);
	headerbar = _tmp37_;
	_tmp38_ = _ ("Tetravex");
	gtk_header_bar_set_title (headerbar, _tmp38_);
	gtk_header_bar_set_show_close_button (headerbar, TRUE);
	_tmp39_ = self->priv->window;
	gtk_window_set_titlebar ((GtkWindow*) _tmp39_, (GtkWidget*) headerbar);
	_tmp40_ = builder;
	_tmp41_ = gtk_builder_get_object (_tmp40_, "grid");
	_tmp42_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp41_, gtk_grid_get_type ()) ? ((GtkGrid*) _tmp41_) : NULL);
	grid = _tmp42_;
	_tmp43_ = puzzle_view_new ();
	g_object_ref_sink (_tmp43_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp43_;
	_tmp44_ = self->priv->view;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp44_, TRUE);
	_tmp45_ = self->priv->view;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp45_, TRUE);
	_tmp46_ = self->priv->view;
	g_signal_connect_object ((GtkWidget*) _tmp46_, "button-press-event", (GCallback) _tetravex_view_button_press_event_gtk_widget_button_press_event, self, 0);
	_tmp47_ = self->priv->view;
	gtk_grid_attach (grid, (GtkWidget*) _tmp47_, 0, 0, 3, 1);
	_tmp48_ = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
	sizegroup = _tmp48_;
	_tmp49_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp49_);
	play_button = _tmp49_;
	_tmp50_ = gtk_widget_get_style_context ((GtkWidget*) play_button);
	gtk_style_context_add_class (_tmp50_, "image-button");
	_tmp51_ = (GtkImage*) gtk_image_new_from_icon_name ("media-playback-start-symbolic", GTK_ICON_SIZE_DND);
	g_object_ref_sink (_tmp51_);
	image = _tmp51_;
	_tmp52_ = image;
	g_object_set ((GtkWidget*) _tmp52_, "margin", 10, NULL);
	_tmp53_ = image;
	gtk_container_add ((GtkContainer*) play_button, (GtkWidget*) _tmp53_);
	gtk_widget_set_valign ((GtkWidget*) play_button, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) play_button, GTK_ALIGN_START);
	gtk_widget_set_margin_start ((GtkWidget*) play_button, 35);
	gtk_actionable_set_action_name ((GtkActionable*) play_button, "app.pause");
	_tmp54_ = _ ("Resume the game");
	gtk_widget_set_tooltip_text ((GtkWidget*) play_button, _tmp54_);
	gtk_size_group_add_widget (sizegroup, (GtkWidget*) play_button);
	_tmp55_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp55_);
	pause_button = _tmp55_;
	_tmp56_ = gtk_widget_get_style_context ((GtkWidget*) pause_button);
	gtk_style_context_add_class (_tmp56_, "image-button");
	_tmp57_ = (GtkImage*) gtk_image_new_from_icon_name ("media-playback-pause-symbolic", GTK_ICON_SIZE_DND);
	g_object_ref_sink (_tmp57_);
	_g_object_unref0 (image);
	image = _tmp57_;
	_tmp58_ = image;
	g_object_set ((GtkWidget*) _tmp58_, "margin", 10, NULL);
	_tmp59_ = image;
	gtk_container_add ((GtkContainer*) pause_button, (GtkWidget*) _tmp59_);
	gtk_widget_set_valign ((GtkWidget*) pause_button, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) pause_button, GTK_ALIGN_START);
	gtk_widget_set_margin_start ((GtkWidget*) pause_button, 35);
	gtk_actionable_set_action_name ((GtkActionable*) pause_button, "app.pause");
	_tmp60_ = _ ("Pause the game");
	gtk_widget_set_tooltip_text ((GtkWidget*) pause_button, _tmp60_);
	gtk_size_group_add_widget (sizegroup, (GtkWidget*) pause_button);
	_tmp61_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp61_);
	_g_object_unref0 (self->priv->play_pause_stack);
	self->priv->play_pause_stack = _tmp61_;
	_tmp62_ = self->priv->play_pause_stack;
	gtk_stack_add_named (_tmp62_, (GtkWidget*) play_button, "play");
	_tmp63_ = self->priv->play_pause_stack;
	gtk_stack_add_named (_tmp63_, (GtkWidget*) pause_button, "pause");
	_tmp64_ = self->priv->play_pause_stack;
	gtk_grid_attach (grid, (GtkWidget*) _tmp64_, 0, 1, 1, 1);
	_tmp65_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp65_);
	new_game_button = _tmp65_;
	_tmp66_ = gtk_widget_get_style_context ((GtkWidget*) new_game_button);
	gtk_style_context_add_class (_tmp66_, "image-button");
	_tmp67_ = (GtkImage*) gtk_image_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_DND);
	g_object_ref_sink (_tmp67_);
	_g_object_unref0 (image);
	image = _tmp67_;
	_tmp68_ = image;
	g_object_set ((GtkWidget*) _tmp68_, "margin", 10, NULL);
	_tmp69_ = image;
	gtk_container_add ((GtkContainer*) new_game_button, (GtkWidget*) _tmp69_);
	gtk_widget_set_valign ((GtkWidget*) new_game_button, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) new_game_button, GTK_ALIGN_END);
	gtk_widget_set_margin_end ((GtkWidget*) new_game_button, 35);
	gtk_actionable_set_action_name ((GtkActionable*) new_game_button, "app.new-game");
	_tmp70_ = _ ("Start a new game");
	gtk_widget_set_tooltip_text ((GtkWidget*) new_game_button, _tmp70_);
	gtk_size_group_add_widget (sizegroup, (GtkWidget*) new_game_button);
	_tmp71_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp71_);
	solve_button = _tmp71_;
	_tmp72_ = gtk_widget_get_style_context ((GtkWidget*) solve_button);
	gtk_style_context_add_class (_tmp72_, "image-button");
	_tmp73_ = (GtkImage*) gtk_image_new_from_icon_name ("dialog-question-symbolic", GTK_ICON_SIZE_DND);
	g_object_ref_sink (_tmp73_);
	_g_object_unref0 (image);
	image = _tmp73_;
	_tmp74_ = image;
	g_object_set ((GtkWidget*) _tmp74_, "margin", 10, NULL);
	_tmp75_ = image;
	gtk_container_add ((GtkContainer*) solve_button, (GtkWidget*) _tmp75_);
	gtk_widget_set_valign ((GtkWidget*) solve_button, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) solve_button, GTK_ALIGN_END);
	gtk_widget_set_margin_end ((GtkWidget*) solve_button, 35);
	gtk_actionable_set_action_name ((GtkActionable*) solve_button, "app.solve");
	_tmp76_ = _ ("Give up and view the solution");
	gtk_widget_set_tooltip_text ((GtkWidget*) solve_button, _tmp76_);
	gtk_size_group_add_widget (sizegroup, (GtkWidget*) solve_button);
	_tmp77_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp77_);
	_g_object_unref0 (self->priv->new_game_solve_stack);
	self->priv->new_game_solve_stack = _tmp77_;
	_tmp78_ = self->priv->new_game_solve_stack;
	gtk_stack_add_named (_tmp78_, (GtkWidget*) solve_button, "solve");
	_tmp79_ = self->priv->new_game_solve_stack;
	gtk_stack_add_named (_tmp79_, (GtkWidget*) new_game_button, "new-game");
	_tmp80_ = self->priv->new_game_solve_stack;
	gtk_grid_attach (grid, (GtkWidget*) _tmp80_, 2, 1, 1, 1);
	_tmp81_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp81_);
	box = _tmp81_;
	_tmp82_ = (GtkImage*) gtk_image_new_from_icon_name ("preferences-system-time-symbolic", GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp82_);
	_g_object_unref0 (image);
	image = _tmp82_;
	_tmp83_ = image;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) _tmp83_);
	_tmp84_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp84_);
	_g_object_unref0 (self->priv->clock_label);
	self->priv->clock_label = _tmp84_;
	_tmp85_ = self->priv->clock_label;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) _tmp85_);
	gtk_widget_set_halign ((GtkWidget*) box, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) box, GTK_ALIGN_BASELINE);
	gtk_widget_set_margin_top ((GtkWidget*) box, 20);
	gtk_widget_set_margin_bottom ((GtkWidget*) box, 20);
	gtk_grid_attach (grid, (GtkWidget*) box, 1, 1, 1, 1);
	_tmp86_ = self->priv->window;
	gtk_widget_show_all ((GtkWidget*) _tmp86_);
	tetravex_tick_cb (self);
	tetravex_new_game (self);
	_g_object_unref0 (box);
	_g_object_unref0 (solve_button);
	_g_object_unref0 (new_game_button);
	_g_object_unref0 (pause_button);
	_g_object_unref0 (image);
	_g_object_unref0 (play_button);
	_g_object_unref0 (sizegroup);
	_g_object_unref0 (grid);
	_g_object_unref0 (headerbar);
	_g_object_unref0 (builder);
}


static gboolean tetravex_window_configure_event_cb (Tetravex* self, GdkEventConfigure* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->is_maximized;
	if (!_tmp0_) {
		GdkEventConfigure* _tmp1_ = NULL;
		gint _tmp2_ = 0;
		GdkEventConfigure* _tmp3_ = NULL;
		gint _tmp4_ = 0;
		_tmp1_ = event;
		_tmp2_ = _tmp1_->width;
		self->priv->window_width = _tmp2_;
		_tmp3_ = event;
		_tmp4_ = _tmp3_->height;
		self->priv->window_height = _tmp4_;
	}
	result = FALSE;
	return result;
}


static gboolean tetravex_window_state_event_cb (Tetravex* self, GdkEventWindowState* event) {
	gboolean result = FALSE;
	GdkEventWindowState* _tmp0_ = NULL;
	GdkWindowState _tmp1_ = 0;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = event;
	_tmp1_ = _tmp0_->changed_mask;
	if ((_tmp1_ & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
		GdkEventWindowState* _tmp2_ = NULL;
		GdkWindowState _tmp3_ = 0;
		_tmp2_ = event;
		_tmp3_ = _tmp2_->new_window_state;
		self->priv->is_maximized = (_tmp3_ & GDK_WINDOW_STATE_MAXIMIZED) != 0;
	}
	result = FALSE;
	return result;
}


static void tetravex_real_shutdown (GApplication* base) {
	Tetravex * self;
	GSettings* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	GSettings* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	GSettings* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	self = (Tetravex*) base;
	G_APPLICATION_CLASS (tetravex_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	_tmp0_ = self->priv->settings;
	_tmp1_ = self->priv->window_width;
	g_settings_set_int (_tmp0_, "window-width", _tmp1_);
	_tmp2_ = self->priv->settings;
	_tmp3_ = self->priv->window_height;
	g_settings_set_int (_tmp2_, "window-height", _tmp3_);
	_tmp4_ = self->priv->settings;
	_tmp5_ = self->priv->is_maximized;
	g_settings_set_boolean (_tmp4_, "window-is-maximized", _tmp5_);
}


static gint _variant_get2 (GVariant* value) {
	return g_variant_get_int32 (value);
}


static gint tetravex_real_handle_local_options (GApplication* base, GVariantDict* options) {
	Tetravex * self;
	gint result = 0;
	GVariantDict* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	GVariantDict* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	GVariantDict* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	self = (Tetravex*) base;
	g_return_val_if_fail (options != NULL, 0);
	_tmp0_ = options;
	_tmp1_ = g_variant_dict_contains (_tmp0_, "version");
	if (_tmp1_) {
		FILE* _tmp2_ = NULL;
		_tmp2_ = stderr;
		fprintf (_tmp2_, "%1$s %2$s\n", "gnome-tetravex", VERSION);
		result = EXIT_SUCCESS;
		return result;
	}
	_tmp3_ = options;
	_tmp4_ = g_variant_dict_contains (_tmp3_, "paused");
	if (_tmp4_) {
		tetravex_start_paused = TRUE;
	}
	_tmp5_ = options;
	_tmp6_ = g_variant_dict_contains (_tmp5_, "size");
	if (_tmp6_) {
		GVariantDict* _tmp7_ = NULL;
		const GVariantType* _tmp8_ = NULL;
		GVariant* _tmp9_ = NULL;
		GVariant* _tmp10_ = NULL;
		gint _tmp11_ = 0;
		gboolean _tmp12_ = FALSE;
		gint _tmp13_ = 0;
		_tmp7_ = options;
		_tmp8_ = G_VARIANT_TYPE_INT32;
		_tmp9_ = g_variant_dict_lookup_value (_tmp7_, "size", _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = _variant_get2 (_tmp10_);
		tetravex_game_size = _tmp11_;
		_g_variant_unref0 (_tmp10_);
		_tmp13_ = tetravex_game_size;
		if (_tmp13_ < 2) {
			_tmp12_ = TRUE;
		} else {
			gint _tmp14_ = 0;
			_tmp14_ = tetravex_game_size;
			_tmp12_ = _tmp14_ > 6;
		}
		if (_tmp12_) {
			FILE* _tmp15_ = NULL;
			_tmp15_ = stderr;
			fprintf (_tmp15_, "%s", "Size could only be from 2 to 6.\n");
			result = EXIT_FAILURE;
			return result;
		}
	}
	result = -1;
	return result;
}


static void tetravex_real_activate (GApplication* base) {
	Tetravex * self;
	GtkApplicationWindow* _tmp0_ = NULL;
	self = (Tetravex*) base;
	_tmp0_ = self->priv->window;
	gtk_window_present ((GtkWindow*) _tmp0_);
}


static GVariant* _variant_new3 (gboolean value) {
	return g_variant_ref_sink (g_variant_new_boolean (value));
}


static void _tetravex_tick_cb_puzzle_tick (Puzzle* _sender, gpointer self) {
	tetravex_tick_cb ((Tetravex*) self);
}


static void _tetravex_solved_cb_puzzle_solved (Puzzle* _sender, gpointer self) {
	tetravex_solved_cb ((Tetravex*) self, _sender);
}


static void tetravex_new_game (Tetravex* self) {
	GSimpleAction* pause = NULL;
	GAction* _tmp0_ = NULL;
	GSimpleAction* _tmp1_ = NULL;
	GSimpleAction* _tmp2_ = NULL;
	GVariant* _tmp3_ = NULL;
	GSimpleAction* _tmp4_ = NULL;
	GtkStack* _tmp5_ = NULL;
	Puzzle* _tmp6_ = NULL;
	gint size = 0;
	GSettings* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	Puzzle* _tmp11_ = NULL;
	Puzzle* _tmp12_ = NULL;
	Puzzle* _tmp13_ = NULL;
	PuzzleView* _tmp14_ = NULL;
	Puzzle* _tmp15_ = NULL;
	gboolean _tmp16_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_action_map_lookup_action ((GActionMap*) self, "pause");
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp0_) : NULL);
	pause = _tmp1_;
	_tmp2_ = pause;
	_tmp3_ = _variant_new3 (FALSE);
	g_signal_emit_by_name (_tmp2_, "change-state", _tmp3_);
	_g_variant_unref0 (_tmp3_);
	_tmp4_ = pause;
	g_simple_action_set_enabled (_tmp4_, TRUE);
	_tmp5_ = self->priv->new_game_solve_stack;
	gtk_stack_set_visible_child_name (_tmp5_, "solve");
	_tmp6_ = self->priv->puzzle;
	if (_tmp6_ != NULL) {
		Puzzle* _tmp7_ = NULL;
		_tmp7_ = self->priv->puzzle;
		g_signal_handlers_disconnect_by_func (_tmp7_, NULL, self);
	}
	_tmp8_ = self->priv->settings;
	_tmp9_ = g_settings_get_int (_tmp8_, TETRAVEX_KEY_GRID_SIZE);
	size = _tmp9_;
	_tmp10_ = size;
	_tmp11_ = puzzle_new ((guint) _tmp10_);
	_g_object_unref0 (self->priv->puzzle);
	self->priv->puzzle = _tmp11_;
	_tmp12_ = self->priv->puzzle;
	g_signal_connect_object (_tmp12_, "tick", (GCallback) _tetravex_tick_cb_puzzle_tick, self, 0);
	_tmp13_ = self->priv->puzzle;
	g_signal_connect_object (_tmp13_, "solved", (GCallback) _tetravex_solved_cb_puzzle_solved, self, 0);
	_tmp14_ = self->priv->view;
	_tmp15_ = self->priv->puzzle;
	puzzle_view_set_puzzle (_tmp14_, _tmp15_);
	tetravex_tick_cb (self);
	_tmp16_ = tetravex_start_paused;
	if (_tmp16_) {
		Puzzle* _tmp17_ = NULL;
		_tmp17_ = self->priv->puzzle;
		puzzle_set_paused (_tmp17_, TRUE);
		tetravex_start_paused = FALSE;
	}
	tetravex_update_button_states (self);
	_g_object_unref0 (pause);
}


static void tetravex_tick_cb (Tetravex* self) {
	gint elapsed = 0;
	Puzzle* _tmp0_ = NULL;
	gint hours = 0;
	gint _tmp4_ = 0;
	gint minutes = 0;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	gint seconds = 0;
	gint _tmp7_ = 0;
	gint _tmp8_ = 0;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	g_return_if_fail (self != NULL);
	elapsed = 0;
	_tmp0_ = self->priv->puzzle;
	if (_tmp0_ != NULL) {
		Puzzle* _tmp1_ = NULL;
		gdouble _tmp2_ = 0.0;
		gdouble _tmp3_ = 0.0;
		_tmp1_ = self->priv->puzzle;
		_tmp2_ = puzzle_get_elapsed (_tmp1_);
		_tmp3_ = _tmp2_;
		elapsed = (gint) (_tmp3_ + 0.5);
	}
	_tmp4_ = elapsed;
	hours = _tmp4_ / 3600;
	_tmp5_ = elapsed;
	_tmp6_ = hours;
	minutes = (_tmp5_ - (_tmp6_ * 3600)) / 60;
	_tmp7_ = elapsed;
	_tmp8_ = hours;
	_tmp9_ = minutes;
	seconds = (_tmp7_ - (_tmp8_ * 3600)) - (_tmp9_ * 60);
	_tmp10_ = hours;
	if (_tmp10_ > 0) {
		GtkLabel* _tmp11_ = NULL;
		gint _tmp12_ = 0;
		gint _tmp13_ = 0;
		gint _tmp14_ = 0;
		gchar* _tmp15_ = NULL;
		gchar* _tmp16_ = NULL;
		_tmp11_ = self->priv->clock_label;
		_tmp12_ = hours;
		_tmp13_ = minutes;
		_tmp14_ = seconds;
		_tmp15_ = g_strdup_printf ("%02d∶\xE2\x80\x8E%02d∶\xE2\x80\x8E%02d", _tmp12_, _tmp13_, _tmp14_);
		_tmp16_ = _tmp15_;
		gtk_label_set_text (_tmp11_, _tmp16_);
		_g_free0 (_tmp16_);
	} else {
		GtkLabel* _tmp17_ = NULL;
		gint _tmp18_ = 0;
		gint _tmp19_ = 0;
		gchar* _tmp20_ = NULL;
		gchar* _tmp21_ = NULL;
		_tmp17_ = self->priv->clock_label;
		_tmp18_ = minutes;
		_tmp19_ = seconds;
		_tmp20_ = g_strdup_printf ("%02d∶\xE2\x80\x8E%02d", _tmp18_, _tmp19_);
		_tmp21_ = _tmp20_;
		gtk_label_set_text (_tmp17_, _tmp21_);
		_g_free0 (_tmp21_);
	}
}


static void tetravex_solved_cb (Tetravex* self, Puzzle* puzzle) {
	GDateTime* date = NULL;
	GDateTime* _tmp0_ = NULL;
	guint duration = 0U;
	Puzzle* _tmp1_ = NULL;
	gdouble _tmp2_ = 0.0;
	gdouble _tmp3_ = 0.0;
	HistoryEntry* entry = NULL;
	GDateTime* _tmp4_ = NULL;
	Puzzle* _tmp5_ = NULL;
	guint _tmp6_ = 0U;
	guint _tmp7_ = 0U;
	guint _tmp8_ = 0U;
	HistoryEntry* _tmp9_ = NULL;
	History* _tmp10_ = NULL;
	HistoryEntry* _tmp11_ = NULL;
	History* _tmp12_ = NULL;
	HistoryEntry* _tmp13_ = NULL;
	gint _tmp14_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (puzzle != NULL);
	_tmp0_ = g_date_time_new_now_local ();
	date = _tmp0_;
	_tmp1_ = puzzle;
	_tmp2_ = puzzle_get_elapsed (_tmp1_);
	_tmp3_ = _tmp2_;
	duration = (guint) (_tmp3_ + 0.5);
	_tmp4_ = date;
	_tmp5_ = puzzle;
	_tmp6_ = puzzle_get_size (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = duration;
	_tmp9_ = history_entry_new (_tmp4_, _tmp7_, _tmp8_);
	entry = _tmp9_;
	_tmp10_ = self->priv->history;
	_tmp11_ = entry;
	history_add (_tmp10_, _tmp11_);
	_tmp12_ = self->priv->history;
	history_save (_tmp12_);
	_tmp13_ = entry;
	_tmp14_ = tetravex_show_scores (self, _tmp13_, TRUE);
	if (_tmp14_ == ((gint) GTK_RESPONSE_CLOSE)) {
		GtkApplicationWindow* _tmp15_ = NULL;
		_tmp15_ = self->priv->window;
		gtk_widget_destroy ((GtkWidget*) _tmp15_);
	} else {
		tetravex_new_game (self);
	}
	_g_object_unref0 (entry);
	_g_date_time_unref0 (date);
}


static gint tetravex_show_scores (Tetravex* self, HistoryEntry* selected_entry, gboolean show_quit) {
	gint result = 0;
	ScoreDialog* dialog = NULL;
	History* _tmp0_ = NULL;
	HistoryEntry* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	ScoreDialog* _tmp3_ = NULL;
	GtkApplicationWindow* _tmp4_ = NULL;
	gint _result_ = 0;
	gint _tmp5_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->history;
	_tmp1_ = selected_entry;
	_tmp2_ = show_quit;
	_tmp3_ = score_dialog_new (_tmp0_, _tmp1_, _tmp2_);
	g_object_ref_sink (_tmp3_);
	dialog = _tmp3_;
	gtk_window_set_modal ((GtkWindow*) dialog, TRUE);
	_tmp4_ = self->priv->window;
	gtk_window_set_transient_for ((GtkWindow*) dialog, (GtkWindow*) _tmp4_);
	_tmp5_ = gtk_dialog_run ((GtkDialog*) dialog);
	_result_ = _tmp5_;
	gtk_widget_destroy ((GtkWidget*) dialog);
	result = _result_;
	_g_object_unref0 (dialog);
	return result;
}


static void tetravex_new_game_cb (Tetravex* self) {
	g_return_if_fail (self != NULL);
	tetravex_new_game (self);
}


static void tetravex_quit_cb (Tetravex* self) {
	GtkApplicationWindow* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	gtk_widget_destroy ((GtkWidget*) _tmp0_);
}


static void tetravex_scores_cb (Tetravex* self) {
	g_return_if_fail (self != NULL);
	tetravex_show_scores (self, NULL, FALSE);
}


static gboolean tetravex_view_button_press_event (Tetravex* self, GtkWidget* widget, GdkEventButton* event) {
	gboolean result = FALSE;
	Puzzle* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->puzzle;
	_tmp1_ = puzzle_get_paused (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		Puzzle* _tmp3_ = NULL;
		_tmp3_ = self->priv->puzzle;
		puzzle_set_paused (_tmp3_, FALSE);
		tetravex_update_button_states (self);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static void tetravex_solve_cb (Tetravex* self) {
	GtkMessageDialog* dialog = NULL;
	GtkApplicationWindow* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkMessageDialog* _tmp2_ = NULL;
	GtkMessageDialog* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gint response = 0;
	GtkMessageDialog* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	GtkMessageDialog* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	_tmp1_ = _ ("Are you sure you want to give up and view the solution?");
	_tmp2_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) _tmp0_, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _tmp1_);
	g_object_ref_sink (_tmp2_);
	dialog = _tmp2_;
	_tmp3_ = dialog;
	_tmp4_ = _ ("_Keep Playing");
	_tmp5_ = _ ("_Give Up");
	gtk_dialog_add_buttons ((GtkDialog*) _tmp3_, _tmp4_, GTK_RESPONSE_REJECT, _tmp5_, GTK_RESPONSE_ACCEPT, NULL, NULL);
	_tmp6_ = dialog;
	_tmp7_ = gtk_dialog_run ((GtkDialog*) _tmp6_);
	response = _tmp7_;
	_tmp8_ = dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp8_);
	_tmp9_ = response;
	if (_tmp9_ == ((gint) GTK_RESPONSE_ACCEPT)) {
		Puzzle* _tmp10_ = NULL;
		GtkStack* _tmp11_ = NULL;
		GAction* _tmp12_ = NULL;
		_tmp10_ = self->priv->puzzle;
		puzzle_solve (_tmp10_);
		_tmp11_ = self->priv->new_game_solve_stack;
		gtk_stack_set_visible_child_name (_tmp11_, "new-game");
		_tmp12_ = g_action_map_lookup_action ((GActionMap*) self, "pause");
		g_simple_action_set_enabled (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, g_simple_action_get_type (), GSimpleAction), FALSE);
	}
	_g_object_unref0 (dialog);
}


static void tetravex_help_cb (Tetravex* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		GtkApplicationWindow* _tmp0_ = NULL;
		GdkScreen* _tmp1_ = NULL;
		guint32 _tmp2_ = 0U;
		_tmp0_ = self->priv->window;
		_tmp1_ = gtk_window_get_screen ((GtkWindow*) _tmp0_);
		_tmp2_ = gtk_get_current_event_time ();
		gtk_show_uri (_tmp1_, "help:gnome-tetravex", _tmp2_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_ = NULL;
		const gchar* _tmp4_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("gnome-tetravex.vala:389: Failed to show help: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void tetravex_about_cb (Tetravex* self) {
	gchar** authors = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gint authors_length1 = 0;
	gint _authors_size_ = 0;
	gchar** documenters = NULL;
	gchar* _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint documenters_length1 = 0;
	gint _documenters_size_ = 0;
	GtkApplicationWindow* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("Lars Rydlinge");
	_tmp1_ = g_strdup ("Robert Ancell");
	_tmp2_ = g_new0 (gchar*, 3 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	_tmp2_[2] = NULL;
	authors = _tmp2_;
	authors_length1 = 3;
	_authors_size_ = authors_length1;
	_tmp3_ = g_strdup ("Rob Bradford");
	_tmp4_ = g_new0 (gchar*, 2 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp4_[1] = NULL;
	documenters = _tmp4_;
	documenters_length1 = 2;
	_documenters_size_ = documenters_length1;
	_tmp5_ = self->priv->window;
	_tmp6_ = _ ("Tetravex");
	_tmp7_ = _ ("Position pieces so that the same numbers are touching each other\n" \
"\n" \
"Tetravex is a part of GNOME Games.");
	_tmp8_ = _ ("translator-credits");
	gtk_show_about_dialog ((GtkWindow*) _tmp5_, "program-name", _tmp6_, "version", VERSION, "comments", _tmp7_, "copyright", "Copyright © 1999–2008 Lars Rydlinge", "license-type", GTK_LICENSE_GPL_2_0, "wrap-license", TRUE, "authors", authors, "documenters", documenters, "translator-credits", _tmp8_, "logo-icon-name", "gnome-tetravex", "website", "https://wiki.gnome.org/Apps/Tetravex", NULL, NULL);
	documenters = (_vala_array_free (documenters, documenters_length1, (GDestroyNotify) g_free), NULL);
	authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
}


static gchar* _variant_get4 (GVariant* value) {
	return g_variant_dup_string (value, NULL);
}


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


static void tetravex_size_changed (Tetravex* self, GSimpleAction* action, GVariant* value) {
	gchar size = '\0';
	GVariant* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar _tmp3_ = '\0';
	gchar _tmp4_ = '\0';
	gchar _tmp5_ = '\0';
	GSettings* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	GSettings* _tmp8_ = NULL;
	gchar _tmp9_ = '\0';
	gchar _tmp10_ = '\0';
	GSimpleAction* _tmp11_ = NULL;
	GVariant* _tmp12_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = value;
	_tmp1_ = _variant_get4 (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_get (_tmp2_, (glong) 0);
	_tmp4_ = _tmp3_ - '0';
	_g_free0 (_tmp2_);
	size = _tmp4_;
	_tmp5_ = size;
	_tmp6_ = self->priv->settings;
	_tmp7_ = g_settings_get_int (_tmp6_, TETRAVEX_KEY_GRID_SIZE);
	if (((gint) _tmp5_) == _tmp7_) {
		return;
	}
	_tmp8_ = self->priv->settings;
	_tmp9_ = size;
	g_settings_set_int (_tmp8_, TETRAVEX_KEY_GRID_SIZE, (gint) _tmp9_);
	_tmp10_ = size;
	tetravex_game_size = (gint) _tmp10_;
	_tmp11_ = action;
	_tmp12_ = value;
	g_simple_action_set_state (_tmp11_, _tmp12_);
	tetravex_new_game (self);
}


static void tetravex_move_up_cb (Tetravex* self) {
	Puzzle* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->puzzle;
	puzzle_move_up (_tmp0_);
}


static void tetravex_move_left_cb (Tetravex* self) {
	Puzzle* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->puzzle;
	puzzle_move_left (_tmp0_);
}


static void tetravex_move_right_cb (Tetravex* self) {
	Puzzle* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->puzzle;
	puzzle_move_right (_tmp0_);
}


static void tetravex_move_down_cb (Tetravex* self) {
	Puzzle* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->puzzle;
	puzzle_move_down (_tmp0_);
}


static void tetravex_pause_cb (Tetravex* self, GSimpleAction* action, GVariant* parameter) {
	Puzzle* _tmp0_ = NULL;
	Puzzle* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = self->priv->puzzle;
	_tmp1_ = self->priv->puzzle;
	_tmp2_ = puzzle_get_paused (_tmp1_);
	_tmp3_ = _tmp2_;
	puzzle_set_paused (_tmp0_, !_tmp3_);
	tetravex_update_button_states (self);
}


static void tetravex_update_button_states (Tetravex* self) {
	GAction* _tmp0_ = NULL;
	Puzzle* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp4_ = NULL;
	Puzzle* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	GtkStack* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_action_map_lookup_action ((GActionMap*) self, "solve");
	_tmp1_ = self->priv->puzzle;
	_tmp2_ = puzzle_get_paused (_tmp1_);
	_tmp3_ = _tmp2_;
	g_simple_action_set_enabled (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, g_simple_action_get_type (), GSimpleAction), !_tmp3_);
	_tmp5_ = self->priv->puzzle;
	_tmp6_ = puzzle_get_paused (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_) {
		_tmp4_ = "play";
	} else {
		_tmp4_ = "pause";
	}
	_tmp8_ = self->priv->play_pause_stack;
	gtk_stack_set_visible_child_name (_tmp8_, _tmp4_);
}


static void tetravex_radio_cb (Tetravex* self, GSimpleAction* action, GVariant* parameter) {
	GSimpleAction* _tmp0_ = NULL;
	GVariant* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = action;
	_tmp1_ = parameter;
	g_signal_emit_by_name (_tmp0_, "change-state", _tmp1_);
}


gint tetravex_main (gchar** args, int args_length1) {
	gint result = 0;
	Tetravex* app = NULL;
	Tetravex* _tmp0_ = NULL;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gint _tmp2_ = 0;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = tetravex_new ();
	app = _tmp0_;
	_tmp1_ = args;
	_tmp1__length1 = args_length1;
	_tmp2_ = g_application_run ((GApplication*) app, _tmp1__length1, _tmp1_);
	result = _tmp2_;
	_g_object_unref0 (app);
	return result;
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	return tetravex_main (argv, argc);
}


static void tetravex_class_init (TetravexClass * klass) {
	tetravex_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (TetravexPrivate));
	((GApplicationClass *) klass)->startup = tetravex_real_startup;
	((GApplicationClass *) klass)->shutdown = tetravex_real_shutdown;
	((GApplicationClass *) klass)->handle_local_options = tetravex_real_handle_local_options;
	((GApplicationClass *) klass)->activate = tetravex_real_activate;
	G_OBJECT_CLASS (klass)->finalize = tetravex_finalize;
}


static void tetravex_instance_init (Tetravex * self) {
	self->priv = TETRAVEX_GET_PRIVATE (self);
}


static void tetravex_finalize (GObject* obj) {
	Tetravex * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TETRAVEX, Tetravex);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->puzzle);
	_g_object_unref0 (self->priv->clock_label);
	_g_object_unref0 (self->priv->history);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->new_game_solve_stack);
	_g_object_unref0 (self->priv->play_pause_stack);
	G_OBJECT_CLASS (tetravex_parent_class)->finalize (obj);
}


GType tetravex_get_type (void) {
	static volatile gsize tetravex_type_id__volatile = 0;
	if (g_once_init_enter (&tetravex_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TetravexClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tetravex_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Tetravex), 0, (GInstanceInitFunc) tetravex_instance_init, NULL };
		GType tetravex_type_id;
		tetravex_type_id = g_type_register_static (gtk_application_get_type (), "Tetravex", &g_define_type_info, 0);
		g_once_init_leave (&tetravex_type_id__volatile, tetravex_type_id);
	}
	return tetravex_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



