/* swell-foop.c generated by valac 0.34.2, the Vala compiler
 * generated from swell-foop.vala, do not modify */

/*
 * 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 <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <clutter/clutter.h>
#include <clutter-gtk/clutter-gtk.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <locale.h>
#include <stdio.h>


#define TYPE_SWELL_FOOP (swell_foop_get_type ())
#define SWELL_FOOP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SWELL_FOOP, SwellFoop))
#define SWELL_FOOP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SWELL_FOOP, SwellFoopClass))
#define IS_SWELL_FOOP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SWELL_FOOP))
#define IS_SWELL_FOOP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SWELL_FOOP))
#define SWELL_FOOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SWELL_FOOP, SwellFoopClass))

typedef struct _SwellFoop SwellFoop;
typedef struct _SwellFoopClass SwellFoopClass;
typedef struct _SwellFoopPrivate SwellFoopPrivate;

#define TYPE_SIZE (size_get_type ())
typedef struct _Size Size;

#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_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 _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))
typedef struct _Block1Data Block1Data;
typedef struct _GameViewPrivate GameViewPrivate;

#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;
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))

struct _Size {
	gchar* id;
	gchar* name;
	gint columns;
	gint rows;
};

struct _SwellFoop {
	GtkApplication parent_instance;
	SwellFoopPrivate * priv;
	Size* sizes;
	gint sizes_length1;
};

struct _SwellFoopClass {
	GtkApplicationClass parent_class;
};

struct _SwellFoopPrivate {
	GSettings* settings;
	GtkWindow* window;
	History* history;
	Game* game;
	GameView* view;
	ClutterStage* stage;
	GtkClutterEmbed* clutter_embed;
	GtkDialog* preferences_dialog;
	GtkHeaderBar* headerbar;
	gboolean game_in_progress;
};

struct _Block1Data {
	int _ref_count_;
	SwellFoop* self;
	GtkStack* stack;
};

struct _GameView {
	ClutterGroup parent_instance;
	GameViewPrivate * priv;
	gboolean is_zealous;
};

struct _GameViewClass {
	ClutterGroupClass parent_class;
};


static gpointer swell_foop_parent_class = NULL;

GType swell_foop_get_type (void) G_GNUC_CONST;
GType size_get_type (void) G_GNUC_CONST;
Size* size_dup (const Size* self);
void size_free (Size* self);
void size_copy (const Size* self, Size* dest);
void size_destroy (Size* self);
GType history_get_type (void) G_GNUC_CONST;
GType game_get_type (void) G_GNUC_CONST;
GType game_view_get_type (void) G_GNUC_CONST;
#define SWELL_FOOP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SWELL_FOOP, SwellFoopPrivate))
enum  {
	SWELL_FOOP_DUMMY_PROPERTY
};
static void _vala_Size_array_free (Size* array, gint array_length);
static void swell_foop_new_game_cb (SwellFoop* self);
static void _swell_foop_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void swell_foop_scores_cb (SwellFoop* self);
static void _swell_foop_scores_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
void swell_foop_preferences_cb (SwellFoop* self);
static void _swell_foop_preferences_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void swell_foop_help_cb (SwellFoop* self);
static void _swell_foop_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void swell_foop_about_cb (SwellFoop* self);
static void _swell_foop_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void swell_foop_quit_cb (SwellFoop* self);
static void _swell_foop_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
SwellFoop* swell_foop_new (void);
SwellFoop* swell_foop_construct (GType object_type);
static void swell_foop_load_css (SwellFoop* self);
static GtkStack* swell_foop_build_first_run_stack (SwellFoop* self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda5_ (Block1Data* _data1_);
static void ___lambda5__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void swell_foop_real_startup (GApplication* base);
static void swell_foop_update_score_cb (SwellFoop* self, gint points_awarded);
static void swell_foop_get_size (SwellFoop* self, Size* result);
Game* game_new (gint rows, gint columns, gint color_num);
Game* game_construct (GType object_type, gint rows, gint columns, gint color_num);
static void _swell_foop_update_score_cb_game_update_score (Game* _sender, gint points_awarded, gpointer self);
static void swell_foop_complete_cb (SwellFoop* self);
static void _swell_foop_complete_cb_game_complete (Game* _sender, gpointer self);
GameView* game_view_new (void);
GameView* game_view_construct (GType object_type);
void game_view_set_theme_name (GameView* self, const gchar* value);
void game_view_set_game (GameView* self, Game* value);
gboolean game_view_board_left_cb (GameView* self);
static gboolean _game_view_board_left_cb_gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self);
History* history_new (const gchar* filename);
History* history_construct (GType object_type, const gchar* filename);
void history_load (History* self);
static gboolean swell_foop_key_press_event_cb (SwellFoop* self, GtkWidget* widget, GdkEventKey* event);
static gboolean _swell_foop_key_press_event_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
void swell_foop_new_game (SwellFoop* self);
void game_view_cursor_move (GameView* self, gint x, gint y);
void game_view_cursor_click (GameView* self);
gint game_get_score (Game* self);
GType history_entry_get_type (void) G_GNUC_CONST;
gint game_get_columns (Game* self);
gint game_get_rows (Game* self);
gint game_get_color_num (Game* self);
HistoryEntry* history_entry_new (GDateTime* date, guint width, guint height, guint n_colors, guint score);
HistoryEntry* history_entry_construct (GType object_type, GDateTime* date, guint width, guint height, guint n_colors, guint score);
void history_add (History* self, HistoryEntry* entry);
void history_save (History* self);
static void swell_foop_started_cb (SwellFoop* self);
static void swell_foop_real_shutdown (GApplication* base);
gboolean game_has_completed (Game* self);
static void swell_foop_real_activate (GApplication* base);
static void swell_foop_preferences_response_cb (SwellFoop* self);
static void _swell_foop_preferences_response_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
void G_MODULE_EXPORT select_theme (GtkComboBox* theme_combo, SwellFoop* self);
void G_MODULE_EXPORT set_zealous_animation (GtkCheckButton* button, SwellFoop* self);
void G_MODULE_EXPORT update_size (GtkComboBox* size_combo, SwellFoop* self);
void G_MODULE_EXPORT update_colors (GtkSpinButton* button, SwellFoop* self);
void swell_foop_show (SwellFoop* self);
static void swell_foop_show_new_game_confirmation_dialog (SwellFoop* self);
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);
static void _swell_foop_started_cb_game_started (Game* _sender, gpointer self);
gint swell_foop_main (gchar** args, int args_length1);
static void swell_foop_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 GActionEntry SWELL_FOOP_action_entries[6] = {{"new-game", _swell_foop_new_game_cb_gsimple_action_activate_callback}, {"scores", _swell_foop_scores_cb_gsimple_action_activate_callback}, {"preferences", _swell_foop_preferences_cb_gsimple_action_activate_callback}, {"help", _swell_foop_help_cb_gsimple_action_activate_callback}, {"about", _swell_foop_about_cb_gsimple_action_activate_callback}, {"quit", _swell_foop_quit_cb_gsimple_action_activate_callback}};

static void _vala_Size_array_free (Size* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			size_destroy (&array[i]);
		}
	}
	g_free (array);
}


static void _swell_foop_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_new_game_cb ((SwellFoop*) self);
}


static void _swell_foop_scores_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_scores_cb ((SwellFoop*) self);
}


static void _swell_foop_preferences_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_preferences_cb ((SwellFoop*) self);
}


static void _swell_foop_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_help_cb ((SwellFoop*) self);
}


static void _swell_foop_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_about_cb ((SwellFoop*) self);
}


static void _swell_foop_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	swell_foop_quit_cb ((SwellFoop*) self);
}


SwellFoop* swell_foop_construct (GType object_type) {
	SwellFoop * self = NULL;
	self = (SwellFoop*) g_object_new (object_type, "application-id", "org.gnome.SwellFoop", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	return self;
}


SwellFoop* swell_foop_new (void) {
	return swell_foop_construct (TYPE_SWELL_FOOP);
}


static void swell_foop_load_css (SwellFoop* self) {
	GtkCssProvider* css_provider = NULL;
	GtkCssProvider* _tmp0_ = NULL;
	gchar* css_path = NULL;
	gchar* _tmp1_ = NULL;
	GdkScreen* _tmp4_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_css_provider_new ();
	css_provider = _tmp0_;
	_tmp1_ = g_build_filename (DATADIR, "swell-foop.css", NULL);
	css_path = _tmp1_;
	{
		gtk_css_provider_load_from_path (css_provider, css_path, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_ = NULL;
		const gchar* _tmp3_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("swell-foop.vala:66: Error loading css styles from %s: %s", css_path, _tmp3_);
		_g_error_free0 (e);
	}
	__finally3:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (css_path);
		_g_object_unref0 (css_provider);
		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;
	}
	_tmp4_ = gdk_screen_get_default ();
	gtk_style_context_add_provider_for_screen (_tmp4_, (GtkStyleProvider*) css_provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_g_free0 (css_path);
	_g_object_unref0 (css_provider);
}


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_)) {
		SwellFoop* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->stack);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}


static void __lambda5_ (Block1Data* _data1_) {
	SwellFoop* self;
	GSettings* _tmp0_ = NULL;
	self = _data1_->self;
	gtk_stack_set_visible_child_name (_data1_->stack, "game");
	_tmp0_ = self->priv->settings;
	g_settings_set_boolean (_tmp0_, "first-run", FALSE);
}


static void ___lambda5__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda5_ (self);
}


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


static GtkStack* swell_foop_build_first_run_stack (SwellFoop* self) {
	GtkStack* result = NULL;
	Block1Data* _data1_;
	GtkStack* _tmp0_ = NULL;
	GtkBox* first_vbox = NULL;
	GtkBox* _tmp1_ = NULL;
	GtkImage* logo = NULL;
	GtkImage* _tmp2_ = NULL;
	GtkLabel* label = NULL;
	const gchar* _tmp3_ = NULL;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* _tmp5_ = NULL;
	GtkStyleContext* _tmp6_ = NULL;
	GtkLabel* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	GtkLabel* _tmp9_ = NULL;
	GtkLabel* _tmp10_ = NULL;
	GtkStyleContext* _tmp11_ = NULL;
	GtkLabel* _tmp12_ = NULL;
	GtkButton* play_button = NULL;
	const gchar* _tmp13_ = NULL;
	GtkButton* _tmp14_ = NULL;
	GtkStyleContext* _tmp15_ = NULL;
	GtkStyleContext* _tmp16_ = NULL;
	GtkStack* _tmp17_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp0_);
	_data1_->stack = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp1_);
	first_vbox = _tmp1_;
	swell_foop_load_css (self);
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name ("swell-foop", GTK_ICON_SIZE_DIALOG);
	g_object_ref_sink (_tmp2_);
	logo = _tmp2_;
	gtk_image_set_pixel_size (logo, 96);
	gtk_box_pack_start (first_vbox, (GtkWidget*) logo, FALSE, TRUE, (guint) 0);
	_tmp3_ = _ ("Welcome to Swell Foop");
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	label = _tmp4_;
	_tmp5_ = label;
	_tmp6_ = gtk_widget_get_style_context ((GtkWidget*) _tmp5_);
	gtk_style_context_add_class (_tmp6_, "welcome");
	_tmp7_ = label;
	gtk_box_pack_start (first_vbox, (GtkWidget*) _tmp7_, FALSE, TRUE, (guint) 0);
	_tmp8_ = _ ("Clear as many blocks as you can.\nFewer clicks means more points.");
	_tmp9_ = (GtkLabel*) gtk_label_new (_tmp8_);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (label);
	label = _tmp9_;
	_tmp10_ = label;
	_tmp11_ = gtk_widget_get_style_context ((GtkWidget*) _tmp10_);
	gtk_style_context_add_class (_tmp11_, "tip");
	_tmp12_ = label;
	gtk_box_pack_start (first_vbox, (GtkWidget*) _tmp12_, FALSE, TRUE, (guint) 0);
	_tmp13_ = _ ("Let's _Play");
	_tmp14_ = (GtkButton*) gtk_button_new_with_mnemonic (_tmp13_);
	g_object_ref_sink (_tmp14_);
	play_button = _tmp14_;
	_tmp15_ = gtk_widget_get_style_context ((GtkWidget*) play_button);
	gtk_style_context_add_class (_tmp15_, "play");
	_tmp16_ = gtk_widget_get_style_context ((GtkWidget*) play_button);
	gtk_style_context_add_class (_tmp16_, "suggested-action");
	gtk_widget_set_valign ((GtkWidget*) play_button, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) play_button, GTK_ALIGN_CENTER);
	g_signal_connect_data (play_button, "clicked", (GCallback) ___lambda5__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	gtk_box_pack_start (first_vbox, (GtkWidget*) play_button, FALSE, TRUE, (guint) 0);
	gtk_widget_set_halign ((GtkWidget*) first_vbox, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) first_vbox, GTK_ALIGN_CENTER);
	gtk_stack_add_named (_data1_->stack, (GtkWidget*) first_vbox, "first-run");
	gtk_stack_set_visible_child_name (_data1_->stack, "first-run");
	gtk_widget_show_all ((GtkWidget*) _data1_->stack);
	_tmp17_ = _g_object_ref0 (_data1_->stack);
	result = _tmp17_;
	_g_object_unref0 (play_button);
	_g_object_unref0 (label);
	_g_object_unref0 (logo);
	_g_object_unref0 (first_vbox);
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}


static void _swell_foop_update_score_cb_game_update_score (Game* _sender, gint points_awarded, gpointer self) {
	swell_foop_update_score_cb ((SwellFoop*) self, points_awarded);
}


static void _swell_foop_complete_cb_game_complete (Game* _sender, gpointer self) {
	swell_foop_complete_cb ((SwellFoop*) self);
}


static gboolean _game_view_board_left_cb_gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self) {
	gboolean result;
	result = game_view_board_left_cb ((GameView*) self);
	return result;
}


static gboolean _swell_foop_key_press_event_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = swell_foop_key_press_event_cb ((SwellFoop*) self, _sender, event);
	return result;
}


static void swell_foop_real_startup (GApplication* base) {
	SwellFoop * self;
	GtkSettings* _tmp0_ = NULL;
	GSettings* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	gchar* _tmp5_ = NULL;
	gchar** _tmp6_ = NULL;
	gchar** _tmp7_ = NULL;
	gint _tmp7__length1 = 0;
	gchar* _tmp8_ = NULL;
	gchar** _tmp9_ = NULL;
	gchar** _tmp10_ = NULL;
	gint _tmp10__length1 = 0;
	GtkApplicationWindow* _tmp11_ = NULL;
	GtkWindow* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	GtkWindow* _tmp14_ = NULL;
	GtkWindow* _tmp15_ = NULL;
	GtkWindow* _tmp16_ = NULL;
	GtkWindow* _tmp17_ = NULL;
	gint _tmp18_ = 0;
	GtkBox* vbox = NULL;
	GtkBox* _tmp19_ = NULL;
	GtkBox* _tmp20_ = NULL;
	GtkWindow* _tmp21_ = NULL;
	GtkBox* _tmp22_ = NULL;
	GMenu* menu = NULL;
	GMenu* _tmp23_ = NULL;
	GMenu* section = NULL;
	GMenu* _tmp24_ = NULL;
	GMenu* _tmp25_ = NULL;
	GMenu* _tmp26_ = NULL;
	GMenu* _tmp27_ = NULL;
	const gchar* _tmp28_ = NULL;
	GMenu* _tmp29_ = NULL;
	const gchar* _tmp30_ = NULL;
	GMenu* _tmp31_ = NULL;
	GMenu* _tmp32_ = NULL;
	GMenu* _tmp33_ = NULL;
	GMenu* _tmp34_ = NULL;
	const gchar* _tmp35_ = NULL;
	GMenu* _tmp36_ = NULL;
	const gchar* _tmp37_ = NULL;
	GMenu* _tmp38_ = NULL;
	const gchar* _tmp39_ = NULL;
	GMenu* _tmp40_ = NULL;
	GtkHeaderBar* _tmp41_ = NULL;
	GtkHeaderBar* _tmp42_ = NULL;
	GtkHeaderBar* _tmp43_ = NULL;
	const gchar* _tmp44_ = NULL;
	GtkHeaderBar* _tmp45_ = NULL;
	GtkWindow* _tmp46_ = NULL;
	GtkHeaderBar* _tmp47_ = NULL;
	GtkButton* new_game_button = NULL;
	GtkButton* _tmp48_ = NULL;
	GtkButton* _tmp49_ = NULL;
	GtkButton* _tmp50_ = NULL;
	GtkButton* _tmp51_ = NULL;
	const gchar* _tmp52_ = NULL;
	GtkButton* _tmp53_ = NULL;
	GtkHeaderBar* _tmp54_ = NULL;
	GtkButton* _tmp55_ = NULL;
	GtkClutterEmbed* _tmp56_ = NULL;
	GtkClutterEmbed* _tmp57_ = NULL;
	gboolean first_run = FALSE;
	GSettings* _tmp58_ = NULL;
	gboolean _tmp59_ = FALSE;
	gboolean _tmp60_ = FALSE;
	GtkClutterEmbed* _tmp68_ = NULL;
	ClutterActor* _tmp69_ = NULL;
	ClutterStage* _tmp70_ = NULL;
	ClutterStage* _tmp71_ = NULL;
	ClutterColor _tmp72_ = {0};
	Size* _tmp73_ = NULL;
	Size* _tmp74_ = NULL;
	gint _tmp74__length1 = 0;
	gchar* _tmp75_ = NULL;
	const gchar* _tmp76_ = NULL;
	gchar* _tmp77_ = NULL;
	Size _tmp78_ = {0};
	Size _tmp79_ = {0};
	Size* _tmp80_ = NULL;
	gint _tmp80__length1 = 0;
	gchar* _tmp81_ = NULL;
	const gchar* _tmp82_ = NULL;
	gchar* _tmp83_ = NULL;
	Size _tmp84_ = {0};
	Size _tmp85_ = {0};
	Size* _tmp86_ = NULL;
	gint _tmp86__length1 = 0;
	gchar* _tmp87_ = NULL;
	const gchar* _tmp88_ = NULL;
	gchar* _tmp89_ = NULL;
	Size _tmp90_ = {0};
	Size _tmp91_ = {0};
	Size _tmp92_ = {0};
	Size _tmp93_ = {0};
	gint _tmp94_ = 0;
	Size _tmp95_ = {0};
	Size _tmp96_ = {0};
	gint _tmp97_ = 0;
	GSettings* _tmp98_ = NULL;
	gint _tmp99_ = 0;
	Game* _tmp100_ = NULL;
	Game* _tmp101_ = NULL;
	Game* _tmp102_ = NULL;
	GameView* _tmp103_ = NULL;
	GameView* _tmp104_ = NULL;
	GSettings* _tmp105_ = NULL;
	gchar* _tmp106_ = NULL;
	gchar* _tmp107_ = NULL;
	GameView* _tmp108_ = NULL;
	GSettings* _tmp109_ = NULL;
	gboolean _tmp110_ = FALSE;
	GameView* _tmp111_ = NULL;
	Game* _tmp112_ = NULL;
	ClutterStage* _tmp113_ = NULL;
	GameView* _tmp114_ = NULL;
	ClutterStage* _tmp115_ = NULL;
	GameView* _tmp116_ = NULL;
	gfloat _tmp117_ = 0.0F;
	gfloat _tmp118_ = 0.0F;
	GameView* _tmp119_ = NULL;
	gfloat _tmp120_ = 0.0F;
	gfloat _tmp121_ = 0.0F;
	GtkClutterEmbed* _tmp122_ = NULL;
	ClutterStage* _tmp123_ = NULL;
	gfloat _tmp124_ = 0.0F;
	gfloat _tmp125_ = 0.0F;
	ClutterStage* _tmp126_ = NULL;
	gfloat _tmp127_ = 0.0F;
	gfloat _tmp128_ = 0.0F;
	GtkClutterEmbed* _tmp129_ = NULL;
	GameView* _tmp130_ = NULL;
	const gchar* _tmp131_ = NULL;
	gchar* _tmp132_ = NULL;
	gchar* _tmp133_ = NULL;
	History* _tmp134_ = NULL;
	History* _tmp135_ = NULL;
	GtkWindow* _tmp136_ = NULL;
	self = (SwellFoop*) base;
	G_APPLICATION_CLASS (swell_foop_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	_tmp0_ = gtk_settings_get_default ();
	g_object_set ((GObject*) _tmp0_, "gtk-application-prefer-dark-theme", TRUE, NULL);
	_tmp1_ = g_settings_new ("org.gnome.swell-foop");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	g_action_map_add_action_entries ((GActionMap*) self, SWELL_FOOP_action_entries, G_N_ELEMENTS (SWELL_FOOP_action_entries), self);
	_tmp2_ = g_strdup ("<Primary>n");
	_tmp3_ = g_new0 (gchar*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.new-game", _tmp4_);
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = g_strdup ("F1");
	_tmp6_ = g_new0 (gchar*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.help", _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = g_strdup ("<Primary>q");
	_tmp9_ = g_new0 (gchar*, 1 + 1);
	_tmp9_[0] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp10_);
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	_tmp11_ = (GtkApplicationWindow*) gtk_application_window_new ((GtkApplication*) self);
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = (GtkWindow*) _tmp11_;
	_tmp12_ = self->priv->window;
	_tmp13_ = _ ("Swell Foop");
	gtk_window_set_title (_tmp12_, _tmp13_);
	_tmp14_ = self->priv->window;
	gtk_window_set_icon_name (_tmp14_, "swell-foop");
	_tmp15_ = self->priv->window;
	gtk_window_set_resizable (_tmp15_, FALSE);
	_tmp16_ = self->priv->window;
	_tmp17_ = self->priv->window;
	_tmp18_ = gtk_widget_get_events ((GtkWidget*) _tmp17_);
	gtk_widget_set_events ((GtkWidget*) _tmp16_, (_tmp18_ | GDK_KEY_PRESS_MASK) | GDK_KEY_RELEASE_MASK);
	_tmp19_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp19_);
	vbox = _tmp19_;
	_tmp20_ = vbox;
	gtk_widget_show ((GtkWidget*) _tmp20_);
	_tmp21_ = self->priv->window;
	_tmp22_ = vbox;
	gtk_container_add ((GtkContainer*) _tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = g_menu_new ();
	menu = _tmp23_;
	_tmp24_ = g_menu_new ();
	section = _tmp24_;
	_tmp25_ = menu;
	_tmp26_ = section;
	g_menu_append_section (_tmp25_, NULL, (GMenuModel*) _tmp26_);
	_tmp27_ = section;
	_tmp28_ = _ ("_Scores");
	g_menu_append (_tmp27_, _tmp28_, "app.scores");
	_tmp29_ = section;
	_tmp30_ = _ ("_Preferences");
	g_menu_append (_tmp29_, _tmp30_, "app.preferences");
	_tmp31_ = g_menu_new ();
	_g_object_unref0 (section);
	section = _tmp31_;
	_tmp32_ = menu;
	_tmp33_ = section;
	g_menu_append_section (_tmp32_, NULL, (GMenuModel*) _tmp33_);
	_tmp34_ = section;
	_tmp35_ = _ ("_Help");
	g_menu_append (_tmp34_, _tmp35_, "app.help");
	_tmp36_ = section;
	_tmp37_ = _ ("_About");
	g_menu_append (_tmp36_, _tmp37_, "app.about");
	_tmp38_ = section;
	_tmp39_ = _ ("_Quit");
	g_menu_append (_tmp38_, _tmp39_, "app.quit");
	_tmp40_ = menu;
	gtk_application_set_app_menu ((GtkApplication*) self, (GMenuModel*) _tmp40_);
	_tmp41_ = (GtkHeaderBar*) gtk_header_bar_new ();
	g_object_ref_sink (_tmp41_);
	_g_object_unref0 (self->priv->headerbar);
	self->priv->headerbar = _tmp41_;
	_tmp42_ = self->priv->headerbar;
	gtk_widget_show ((GtkWidget*) _tmp42_);
	_tmp43_ = self->priv->headerbar;
	_tmp44_ = _ ("Swell Foop");
	gtk_header_bar_set_title (_tmp43_, _tmp44_);
	_tmp45_ = self->priv->headerbar;
	gtk_header_bar_set_show_close_button (_tmp45_, TRUE);
	_tmp46_ = self->priv->window;
	_tmp47_ = self->priv->headerbar;
	gtk_window_set_titlebar (_tmp46_, (GtkWidget*) _tmp47_);
	_tmp48_ = (GtkButton*) gtk_button_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp48_);
	new_game_button = _tmp48_;
	_tmp49_ = new_game_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp49_, GTK_ALIGN_CENTER);
	_tmp50_ = new_game_button;
	gtk_actionable_set_action_name ((GtkActionable*) _tmp50_, "app.new-game");
	_tmp51_ = new_game_button;
	_tmp52_ = _ ("Start a new game");
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp51_, _tmp52_);
	_tmp53_ = new_game_button;
	gtk_widget_show ((GtkWidget*) _tmp53_);
	_tmp54_ = self->priv->headerbar;
	_tmp55_ = new_game_button;
	gtk_header_bar_pack_start (_tmp54_, (GtkWidget*) _tmp55_);
	swell_foop_update_score_cb (self, 0);
	_tmp56_ = (GtkClutterEmbed*) gtk_clutter_embed_new ();
	g_object_ref_sink (_tmp56_);
	_g_object_unref0 (self->priv->clutter_embed);
	self->priv->clutter_embed = _tmp56_;
	_tmp57_ = self->priv->clutter_embed;
	gtk_widget_show ((GtkWidget*) _tmp57_);
	_tmp58_ = self->priv->settings;
	_tmp59_ = g_settings_get_boolean (_tmp58_, "first-run");
	first_run = _tmp59_;
	_tmp60_ = first_run;
	if (_tmp60_) {
		GtkStack* stack = NULL;
		GtkStack* _tmp61_ = NULL;
		GtkStack* _tmp62_ = NULL;
		GtkClutterEmbed* _tmp63_ = NULL;
		GtkBox* _tmp64_ = NULL;
		GtkStack* _tmp65_ = NULL;
		_tmp61_ = swell_foop_build_first_run_stack (self);
		stack = _tmp61_;
		_tmp62_ = stack;
		_tmp63_ = self->priv->clutter_embed;
		gtk_stack_add_named (_tmp62_, (GtkWidget*) _tmp63_, "game");
		_tmp64_ = vbox;
		_tmp65_ = stack;
		gtk_box_pack_start (_tmp64_, (GtkWidget*) _tmp65_, TRUE, TRUE, (guint) 0);
		_g_object_unref0 (stack);
	} else {
		GtkBox* _tmp66_ = NULL;
		GtkClutterEmbed* _tmp67_ = NULL;
		_tmp66_ = vbox;
		_tmp67_ = self->priv->clutter_embed;
		gtk_box_pack_start (_tmp66_, (GtkWidget*) _tmp67_, TRUE, TRUE, (guint) 0);
	}
	_tmp68_ = self->priv->clutter_embed;
	_tmp69_ = gtk_clutter_embed_get_stage (_tmp68_);
	_tmp70_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp69_, clutter_stage_get_type (), ClutterStage));
	_g_object_unref0 (self->priv->stage);
	self->priv->stage = _tmp70_;
	_tmp71_ = self->priv->stage;
	clutter_color_from_string (&_tmp72_, "#000000");
	clutter_actor_set_background_color ((ClutterActor*) _tmp71_, &_tmp72_);
	_tmp73_ = g_new0 (Size, 3);
	self->sizes = (_vala_Size_array_free (self->sizes, self->sizes_length1), NULL);
	self->sizes = _tmp73_;
	self->sizes_length1 = 3;
	_tmp74_ = self->sizes;
	_tmp74__length1 = self->sizes_length1;
	_tmp75_ = g_strdup ("small");
	_tmp76_ = _ ("Small");
	_tmp77_ = g_strdup (_tmp76_);
	_g_free0 (_tmp78_.id);
	_tmp78_.id = _tmp75_;
	_g_free0 (_tmp78_.name);
	_tmp78_.name = _tmp77_;
	_tmp78_.columns = 6;
	_tmp78_.rows = 5;
	size_destroy (&_tmp74_[0]);
	_tmp74_[0] = _tmp78_;
	_tmp79_ = _tmp74_[0];
	_tmp80_ = self->sizes;
	_tmp80__length1 = self->sizes_length1;
	_tmp81_ = g_strdup ("normal");
	_tmp82_ = _ ("Normal");
	_tmp83_ = g_strdup (_tmp82_);
	_g_free0 (_tmp84_.id);
	_tmp84_.id = _tmp81_;
	_g_free0 (_tmp84_.name);
	_tmp84_.name = _tmp83_;
	_tmp84_.columns = 15;
	_tmp84_.rows = 10;
	size_destroy (&_tmp80_[1]);
	_tmp80_[1] = _tmp84_;
	_tmp85_ = _tmp80_[1];
	_tmp86_ = self->sizes;
	_tmp86__length1 = self->sizes_length1;
	_tmp87_ = g_strdup ("large");
	_tmp88_ = _ ("Large");
	_tmp89_ = g_strdup (_tmp88_);
	_g_free0 (_tmp90_.id);
	_tmp90_.id = _tmp87_;
	_g_free0 (_tmp90_.name);
	_tmp90_.name = _tmp89_;
	_tmp90_.columns = 20;
	_tmp90_.rows = 15;
	size_destroy (&_tmp86_[2]);
	_tmp86_[2] = _tmp90_;
	_tmp91_ = _tmp86_[2];
	swell_foop_get_size (self, &_tmp92_);
	_tmp93_ = _tmp92_;
	_tmp94_ = _tmp93_.rows;
	swell_foop_get_size (self, &_tmp95_);
	_tmp96_ = _tmp95_;
	_tmp97_ = _tmp96_.columns;
	_tmp98_ = self->priv->settings;
	_tmp99_ = g_settings_get_int (_tmp98_, "colors");
	_tmp100_ = game_new (_tmp94_, _tmp97_, _tmp99_);
	_g_object_unref0 (self->priv->game);
	self->priv->game = _tmp100_;
	size_destroy (&_tmp96_);
	size_destroy (&_tmp93_);
	_tmp101_ = self->priv->game;
	g_signal_connect_object (_tmp101_, "update-score", (GCallback) _swell_foop_update_score_cb_game_update_score, self, 0);
	_tmp102_ = self->priv->game;
	g_signal_connect_object (_tmp102_, "complete", (GCallback) _swell_foop_complete_cb_game_complete, self, 0);
	_tmp103_ = game_view_new ();
	g_object_ref_sink (_tmp103_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp103_;
	_tmp104_ = self->priv->view;
	_tmp105_ = self->priv->settings;
	_tmp106_ = g_settings_get_string (_tmp105_, "theme");
	_tmp107_ = _tmp106_;
	game_view_set_theme_name (_tmp104_, _tmp107_);
	_g_free0 (_tmp107_);
	_tmp108_ = self->priv->view;
	_tmp109_ = self->priv->settings;
	_tmp110_ = g_settings_get_boolean (_tmp109_, "zealous");
	_tmp108_->is_zealous = _tmp110_;
	_tmp111_ = self->priv->view;
	_tmp112_ = self->priv->game;
	game_view_set_game (_tmp111_, _tmp112_);
	_tmp113_ = self->priv->stage;
	_tmp114_ = self->priv->view;
	clutter_actor_add_child ((ClutterActor*) _tmp113_, (ClutterActor*) _tmp114_);
	_tmp115_ = self->priv->stage;
	_tmp116_ = self->priv->view;
	_tmp117_ = clutter_actor_get_width ((ClutterActor*) _tmp116_);
	_tmp118_ = _tmp117_;
	_tmp119_ = self->priv->view;
	_tmp120_ = clutter_actor_get_height ((ClutterActor*) _tmp119_);
	_tmp121_ = _tmp120_;
	clutter_actor_set_size ((ClutterActor*) _tmp115_, _tmp118_, _tmp121_);
	_tmp122_ = self->priv->clutter_embed;
	_tmp123_ = self->priv->stage;
	_tmp124_ = clutter_actor_get_width ((ClutterActor*) _tmp123_);
	_tmp125_ = _tmp124_;
	_tmp126_ = self->priv->stage;
	_tmp127_ = clutter_actor_get_height ((ClutterActor*) _tmp126_);
	_tmp128_ = _tmp127_;
	gtk_widget_set_size_request ((GtkWidget*) _tmp122_, (gint) _tmp125_, (gint) _tmp128_);
	_tmp129_ = self->priv->clutter_embed;
	_tmp130_ = self->priv->view;
	g_signal_connect_object ((GtkWidget*) _tmp129_, "leave-notify-event", (GCallback) _game_view_board_left_cb_gtk_widget_leave_notify_event, _tmp130_, 0);
	_tmp131_ = g_get_user_data_dir ();
	_tmp132_ = g_build_filename (_tmp131_, "swell-foop", "history", NULL);
	_tmp133_ = _tmp132_;
	_tmp134_ = history_new (_tmp133_);
	_g_object_unref0 (self->priv->history);
	self->priv->history = _tmp134_;
	_g_free0 (_tmp133_);
	_tmp135_ = self->priv->history;
	history_load (_tmp135_);
	_tmp136_ = self->priv->window;
	g_signal_connect_object ((GtkWidget*) _tmp136_, "key-press-event", (GCallback) _swell_foop_key_press_event_cb_gtk_widget_key_press_event, self, 0);
	_g_object_unref0 (new_game_button);
	_g_object_unref0 (section);
	_g_object_unref0 (menu);
	_g_object_unref0 (vbox);
}


static gboolean swell_foop_key_press_event_cb (SwellFoop* self, GtkWidget* widget, GdkEventKey* event) {
	gboolean result = FALSE;
	GdkEventKey* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	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_ = event;
	_tmp1_ = _tmp0_->keyval;
	switch (_tmp1_) {
		case GDK_KEY_F2:
		{
			swell_foop_new_game (self);
			break;
		}
		case GDK_KEY_Up:
		{
			GameView* _tmp2_ = NULL;
			_tmp2_ = self->priv->view;
			game_view_cursor_move (_tmp2_, 0, 1);
			break;
		}
		case GDK_KEY_Down:
		{
			GameView* _tmp3_ = NULL;
			_tmp3_ = self->priv->view;
			game_view_cursor_move (_tmp3_, 0, -1);
			break;
		}
		case GDK_KEY_Left:
		{
			GameView* _tmp4_ = NULL;
			_tmp4_ = self->priv->view;
			game_view_cursor_move (_tmp4_, -1, 0);
			break;
		}
		case GDK_KEY_Right:
		{
			GameView* _tmp5_ = NULL;
			_tmp5_ = self->priv->view;
			game_view_cursor_move (_tmp5_, 1, 0);
			break;
		}
		case GDK_KEY_space:
		case GDK_KEY_Return:
		{
			GameView* _tmp6_ = NULL;
			_tmp6_ = self->priv->view;
			game_view_cursor_click (_tmp6_);
			result = TRUE;
			return result;
		}
		default:
		{
			break;
		}
	}
	result = FALSE;
	return result;
}


static void swell_foop_get_size (SwellFoop* self, Size* result) {
	Size* _tmp16_ = NULL;
	gint _tmp16__length1 = 0;
	Size _tmp17_ = {0};
	Size _tmp18_ = {0};
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_ = 0;
				Size* _tmp3_ = NULL;
				gint _tmp3__length1 = 0;
				Size* _tmp4_ = NULL;
				gint _tmp4__length1 = 0;
				gint _tmp5_ = 0;
				Size _tmp6_ = {0};
				const gchar* _tmp7_ = NULL;
				GSettings* _tmp8_ = NULL;
				gchar* _tmp9_ = NULL;
				gchar* _tmp10_ = NULL;
				gboolean _tmp11_ = FALSE;
				if (!_tmp0_) {
					gint _tmp1_ = 0;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = i;
				_tmp3_ = self->sizes;
				_tmp3__length1 = self->sizes_length1;
				if (!(_tmp2_ < _tmp3__length1)) {
					break;
				}
				_tmp4_ = self->sizes;
				_tmp4__length1 = self->sizes_length1;
				_tmp5_ = i;
				_tmp6_ = _tmp4_[_tmp5_];
				_tmp7_ = _tmp6_.id;
				_tmp8_ = self->priv->settings;
				_tmp9_ = g_settings_get_string (_tmp8_, "size");
				_tmp10_ = _tmp9_;
				_tmp11_ = g_strcmp0 (_tmp7_, _tmp10_) == 0;
				_g_free0 (_tmp10_);
				if (_tmp11_) {
					Size* _tmp12_ = NULL;
					gint _tmp12__length1 = 0;
					gint _tmp13_ = 0;
					Size _tmp14_ = {0};
					Size _tmp15_ = {0};
					_tmp12_ = self->sizes;
					_tmp12__length1 = self->sizes_length1;
					_tmp13_ = i;
					_tmp14_ = _tmp12_[_tmp13_];
					size_copy (&_tmp14_, &_tmp15_);
					*result = _tmp15_;
					return;
				}
			}
		}
	}
	_tmp16_ = self->sizes;
	_tmp16__length1 = self->sizes_length1;
	_tmp17_ = _tmp16_[0];
	size_copy (&_tmp17_, &_tmp18_);
	*result = _tmp18_;
	return;
}


static void swell_foop_update_score_cb (SwellFoop* self, gint points_awarded) {
	gint score = 0;
	Game* _tmp0_ = NULL;
	GtkHeaderBar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	score = 0;
	_tmp0_ = self->priv->game;
	if (_tmp0_ != NULL) {
		Game* _tmp1_ = NULL;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		_tmp1_ = self->priv->game;
		_tmp2_ = game_get_score (_tmp1_);
		_tmp3_ = _tmp2_;
		score = _tmp3_;
	}
	_tmp4_ = self->priv->headerbar;
	_tmp5_ = _ ("Score: %u");
	_tmp6_ = score;
	_tmp7_ = g_strdup_printf (_tmp5_, _tmp6_);
	_tmp8_ = _tmp7_;
	gtk_header_bar_set_subtitle (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
}


static void swell_foop_complete_cb (SwellFoop* self) {
	GDateTime* date = NULL;
	GDateTime* _tmp0_ = NULL;
	HistoryEntry* entry = NULL;
	Game* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	Game* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	Game* _tmp7_ = NULL;
	gint _tmp8_ = 0;
	gint _tmp9_ = 0;
	Game* _tmp10_ = NULL;
	gint _tmp11_ = 0;
	gint _tmp12_ = 0;
	HistoryEntry* _tmp13_ = NULL;
	History* _tmp14_ = NULL;
	History* _tmp15_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_time_new_now_local ();
	date = _tmp0_;
	_tmp1_ = self->priv->game;
	_tmp2_ = game_get_columns (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->game;
	_tmp5_ = game_get_rows (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->game;
	_tmp8_ = game_get_color_num (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = self->priv->game;
	_tmp11_ = game_get_score (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = history_entry_new (date, (guint) _tmp3_, (guint) _tmp6_, (guint) _tmp9_, (guint) _tmp12_);
	entry = _tmp13_;
	_tmp14_ = self->priv->history;
	history_add (_tmp14_, entry);
	_tmp15_ = self->priv->history;
	history_save (_tmp15_);
	self->priv->game_in_progress = FALSE;
	_g_object_unref0 (entry);
	_g_date_time_unref0 (date);
}


static void swell_foop_started_cb (SwellFoop* self) {
	g_return_if_fail (self != NULL);
	self->priv->game_in_progress = TRUE;
}


static void swell_foop_real_shutdown (GApplication* base) {
	SwellFoop * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	Game* _tmp2_ = NULL;
	self = (SwellFoop*) base;
	G_APPLICATION_CLASS (swell_foop_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	_tmp2_ = self->priv->game;
	if (_tmp2_ != NULL) {
		Game* _tmp3_ = NULL;
		gboolean _tmp4_ = FALSE;
		_tmp3_ = self->priv->game;
		_tmp4_ = game_has_completed (_tmp3_);
		_tmp1_ = !_tmp4_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		Game* _tmp5_ = NULL;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp5_ = self->priv->game;
		_tmp6_ = game_get_score (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp0_ = _tmp7_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		swell_foop_complete_cb (self);
	}
}


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


static void _swell_foop_preferences_response_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
	swell_foop_preferences_response_cb ((SwellFoop*) self);
}


void swell_foop_preferences_cb (SwellFoop* self) {
	GtkDialog* _tmp0_ = NULL;
	GtkBuilder* preferences_builder = NULL;
	GtkBuilder* _tmp2_ = NULL;
	GtkBuilder* _tmp8_ = NULL;
	GObject* _tmp9_ = NULL;
	GtkDialog* _tmp10_ = NULL;
	GtkDialog* _tmp11_ = NULL;
	GtkWindow* _tmp12_ = NULL;
	GtkDialog* _tmp13_ = NULL;
	GtkComboBox* theme_combo = NULL;
	GtkBuilder* _tmp14_ = NULL;
	GObject* _tmp15_ = NULL;
	GtkComboBox* _tmp16_ = NULL;
	GtkListStore* model = NULL;
	GtkComboBox* _tmp17_ = NULL;
	GtkTreeModel* _tmp18_ = NULL;
	GtkTreeModel* _tmp19_ = NULL;
	GtkListStore* _tmp20_ = NULL;
	GtkTreeIter iter = {0};
	GtkListStore* _tmp21_ = NULL;
	GtkTreeIter _tmp22_ = {0};
	GtkListStore* _tmp23_ = NULL;
	GtkTreeIter _tmp24_ = {0};
	const gchar* _tmp25_ = NULL;
	GSettings* _tmp26_ = NULL;
	gchar* _tmp27_ = NULL;
	gchar* _tmp28_ = NULL;
	gboolean _tmp29_ = FALSE;
	GtkListStore* _tmp32_ = NULL;
	GtkTreeIter _tmp33_ = {0};
	GtkListStore* _tmp34_ = NULL;
	GtkTreeIter _tmp35_ = {0};
	const gchar* _tmp36_ = NULL;
	GSettings* _tmp37_ = NULL;
	gchar* _tmp38_ = NULL;
	gchar* _tmp39_ = NULL;
	gboolean _tmp40_ = FALSE;
	GtkComboBox* size_combo = NULL;
	GtkBuilder* _tmp43_ = NULL;
	GObject* _tmp44_ = NULL;
	GtkComboBox* _tmp45_ = NULL;
	GtkComboBox* _tmp46_ = NULL;
	GtkTreeModel* _tmp47_ = NULL;
	GtkTreeModel* _tmp48_ = NULL;
	GtkListStore* _tmp49_ = NULL;
	GtkBuilder* _tmp76_ = NULL;
	GObject* _tmp77_ = NULL;
	GSettings* _tmp78_ = NULL;
	gint _tmp79_ = 0;
	GtkBuilder* _tmp80_ = NULL;
	GObject* _tmp81_ = NULL;
	GSettings* _tmp82_ = NULL;
	gboolean _tmp83_ = FALSE;
	GtkBuilder* _tmp84_ = NULL;
	GtkDialog* _tmp85_ = NULL;
	GtkDialog* _tmp86_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->preferences_dialog;
	if (_tmp0_ != NULL) {
		GtkDialog* _tmp1_ = NULL;
		_tmp1_ = self->priv->preferences_dialog;
		gtk_window_present ((GtkWindow*) _tmp1_);
		return;
	}
	_tmp2_ = gtk_builder_new ();
	preferences_builder = _tmp2_;
	{
		GtkBuilder* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		_tmp3_ = preferences_builder;
		_tmp4_ = g_build_filename (DATADIR, "preferences.ui", NULL, NULL);
		_tmp5_ = _tmp4_;
		gtk_builder_add_from_file (_tmp3_, _tmp5_, &_inner_error_);
		_g_free0 (_tmp5_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch4_g_error;
		}
	}
	goto __finally4;
	__catch4_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("swell-foop.vala:310: Could not load preferences UI: %s", _tmp7_);
		_g_error_free0 (e);
	}
	__finally4:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (preferences_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;
	}
	_tmp8_ = preferences_builder;
	_tmp9_ = gtk_builder_get_object (_tmp8_, "preferences");
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_dialog_get_type (), GtkDialog));
	_g_object_unref0 (self->priv->preferences_dialog);
	self->priv->preferences_dialog = _tmp10_;
	_tmp11_ = self->priv->preferences_dialog;
	_tmp12_ = self->priv->window;
	gtk_window_set_transient_for ((GtkWindow*) _tmp11_, _tmp12_);
	_tmp13_ = self->priv->preferences_dialog;
	gtk_window_set_modal ((GtkWindow*) _tmp13_, TRUE);
	_tmp14_ = preferences_builder;
	_tmp15_ = gtk_builder_get_object (_tmp14_, "theme-selector");
	_tmp16_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, gtk_combo_box_get_type ()) ? ((GtkComboBox*) _tmp15_) : NULL);
	theme_combo = _tmp16_;
	_tmp17_ = theme_combo;
	_tmp18_ = gtk_combo_box_get_model (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_list_store_get_type (), GtkListStore));
	model = _tmp20_;
	_tmp21_ = model;
	gtk_list_store_append (_tmp21_, &_tmp22_);
	iter = _tmp22_;
	_tmp23_ = model;
	_tmp24_ = iter;
	_tmp25_ = _ ("Colors");
	gtk_list_store_set (_tmp23_, &_tmp24_, 0, _tmp25_, 1, "colors", -1, -1);
	_tmp26_ = self->priv->settings;
	_tmp27_ = g_settings_get_string (_tmp26_, "theme");
	_tmp28_ = _tmp27_;
	_tmp29_ = g_strcmp0 (_tmp28_, "colors") == 0;
	_g_free0 (_tmp28_);
	if (_tmp29_) {
		GtkComboBox* _tmp30_ = NULL;
		GtkTreeIter _tmp31_ = {0};
		_tmp30_ = theme_combo;
		_tmp31_ = iter;
		gtk_combo_box_set_active_iter (_tmp30_, &_tmp31_);
	}
	_tmp32_ = model;
	gtk_list_store_append (_tmp32_, &_tmp33_);
	iter = _tmp33_;
	_tmp34_ = model;
	_tmp35_ = iter;
	_tmp36_ = _ ("Shapes and Colors");
	gtk_list_store_set (_tmp34_, &_tmp35_, 0, _tmp36_, 1, "shapesandcolors", -1, -1);
	_tmp37_ = self->priv->settings;
	_tmp38_ = g_settings_get_string (_tmp37_, "theme");
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strcmp0 (_tmp39_, "shapesandcolors") == 0;
	_g_free0 (_tmp39_);
	if (_tmp40_) {
		GtkComboBox* _tmp41_ = NULL;
		GtkTreeIter _tmp42_ = {0};
		_tmp41_ = theme_combo;
		_tmp42_ = iter;
		gtk_combo_box_set_active_iter (_tmp41_, &_tmp42_);
	}
	_tmp43_ = preferences_builder;
	_tmp44_ = gtk_builder_get_object (_tmp43_, "size-selector");
	_tmp45_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp44_, gtk_combo_box_get_type ()) ? ((GtkComboBox*) _tmp44_) : NULL);
	size_combo = _tmp45_;
	_tmp46_ = size_combo;
	_tmp47_ = gtk_combo_box_get_model (_tmp46_);
	_tmp48_ = _tmp47_;
	_tmp49_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp48_, gtk_list_store_get_type (), GtkListStore));
	_g_object_unref0 (model);
	model = _tmp49_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp50_ = FALSE;
			_tmp50_ = TRUE;
			while (TRUE) {
				gint _tmp52_ = 0;
				Size* _tmp53_ = NULL;
				gint _tmp53__length1 = 0;
				GtkListStore* _tmp54_ = NULL;
				GtkTreeIter _tmp55_ = {0};
				GtkListStore* _tmp56_ = NULL;
				GtkTreeIter _tmp57_ = {0};
				Size* _tmp58_ = NULL;
				gint _tmp58__length1 = 0;
				gint _tmp59_ = 0;
				Size _tmp60_ = {0};
				const gchar* _tmp61_ = NULL;
				Size* _tmp62_ = NULL;
				gint _tmp62__length1 = 0;
				gint _tmp63_ = 0;
				Size _tmp64_ = {0};
				const gchar* _tmp65_ = NULL;
				GSettings* _tmp66_ = NULL;
				gchar* _tmp67_ = NULL;
				gchar* _tmp68_ = NULL;
				Size* _tmp69_ = NULL;
				gint _tmp69__length1 = 0;
				gint _tmp70_ = 0;
				Size _tmp71_ = {0};
				const gchar* _tmp72_ = NULL;
				gboolean _tmp73_ = FALSE;
				if (!_tmp50_) {
					gint _tmp51_ = 0;
					_tmp51_ = i;
					i = _tmp51_ + 1;
				}
				_tmp50_ = FALSE;
				_tmp52_ = i;
				_tmp53_ = self->sizes;
				_tmp53__length1 = self->sizes_length1;
				if (!(_tmp52_ < _tmp53__length1)) {
					break;
				}
				_tmp54_ = model;
				gtk_list_store_append (_tmp54_, &_tmp55_);
				iter = _tmp55_;
				_tmp56_ = model;
				_tmp57_ = iter;
				_tmp58_ = self->sizes;
				_tmp58__length1 = self->sizes_length1;
				_tmp59_ = i;
				_tmp60_ = _tmp58_[_tmp59_];
				_tmp61_ = _tmp60_.name;
				_tmp62_ = self->sizes;
				_tmp62__length1 = self->sizes_length1;
				_tmp63_ = i;
				_tmp64_ = _tmp62_[_tmp63_];
				_tmp65_ = _tmp64_.id;
				gtk_list_store_set (_tmp56_, &_tmp57_, 0, _tmp61_, 1, _tmp65_, -1, -1);
				_tmp66_ = self->priv->settings;
				_tmp67_ = g_settings_get_string (_tmp66_, "size");
				_tmp68_ = _tmp67_;
				_tmp69_ = self->sizes;
				_tmp69__length1 = self->sizes_length1;
				_tmp70_ = i;
				_tmp71_ = _tmp69_[_tmp70_];
				_tmp72_ = _tmp71_.id;
				_tmp73_ = g_strcmp0 (_tmp68_, _tmp72_) == 0;
				_g_free0 (_tmp68_);
				if (_tmp73_) {
					GtkComboBox* _tmp74_ = NULL;
					GtkTreeIter _tmp75_ = {0};
					_tmp74_ = size_combo;
					_tmp75_ = iter;
					gtk_combo_box_set_active_iter (_tmp74_, &_tmp75_);
				}
			}
		}
	}
	_tmp76_ = preferences_builder;
	_tmp77_ = gtk_builder_get_object (_tmp76_, "colors-spinner");
	_tmp78_ = self->priv->settings;
	_tmp79_ = g_settings_get_int (_tmp78_, "colors");
	gtk_spin_button_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp77_, gtk_spin_button_get_type (), GtkSpinButton), (gdouble) _tmp79_);
	_tmp80_ = preferences_builder;
	_tmp81_ = gtk_builder_get_object (_tmp80_, "zealous-checkbox");
	_tmp82_ = self->priv->settings;
	_tmp83_ = g_settings_get_boolean (_tmp82_, "zealous");
	gtk_toggle_button_set_active ((GtkToggleButton*) G_TYPE_CHECK_INSTANCE_CAST (_tmp81_, gtk_check_button_get_type (), GtkCheckButton), _tmp83_);
	_tmp84_ = preferences_builder;
	gtk_builder_connect_signals (_tmp84_, self);
	_tmp85_ = self->priv->preferences_dialog;
	g_signal_connect_object (_tmp85_, "response", (GCallback) _swell_foop_preferences_response_cb_gtk_dialog_response, self, 0);
	_tmp86_ = self->priv->preferences_dialog;
	gtk_window_present ((GtkWindow*) _tmp86_);
	_g_object_unref0 (size_combo);
	_g_object_unref0 (model);
	_g_object_unref0 (theme_combo);
	_g_object_unref0 (preferences_builder);
}


void G_MODULE_EXPORT select_theme (GtkComboBox* theme_combo, SwellFoop* self) {
	GtkTreeIter iter = {0};
	GtkComboBox* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	gboolean _tmp2_ = FALSE;
	gchar* new_theme = NULL;
	GtkComboBox* _tmp3_ = NULL;
	GtkTreeModel* _tmp4_ = NULL;
	GtkTreeModel* _tmp5_ = NULL;
	GtkTreeIter _tmp6_ = {0};
	const gchar* _tmp7_ = NULL;
	GSettings* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gboolean _tmp11_ = FALSE;
	GSettings* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	GameView* _tmp14_ = NULL;
	const gchar* _tmp15_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (theme_combo != NULL);
	_tmp0_ = theme_combo;
	_tmp2_ = gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
	iter = _tmp1_;
	if (!_tmp2_) {
		return;
	}
	_tmp3_ = theme_combo;
	_tmp4_ = gtk_combo_box_get_model (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = iter;
	gtk_tree_model_get (_tmp5_, &_tmp6_, 1, &new_theme, -1, -1);
	_tmp7_ = new_theme;
	_tmp8_ = self->priv->settings;
	_tmp9_ = g_settings_get_string (_tmp8_, "theme");
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strcmp0 (_tmp7_, _tmp10_) == 0;
	_g_free0 (_tmp10_);
	if (_tmp11_) {
		_g_free0 (new_theme);
		return;
	}
	_tmp12_ = self->priv->settings;
	_tmp13_ = new_theme;
	g_settings_set_string (_tmp12_, "theme", _tmp13_);
	_tmp14_ = self->priv->view;
	_tmp15_ = new_theme;
	game_view_set_theme_name (_tmp14_, _tmp15_);
	_g_free0 (new_theme);
}


void G_MODULE_EXPORT set_zealous_animation (GtkCheckButton* button, SwellFoop* self) {
	GSettings* _tmp0_ = NULL;
	GtkCheckButton* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	GameView* _tmp4_ = NULL;
	GSettings* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = button;
	_tmp2_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp1_);
	_tmp3_ = _tmp2_;
	g_settings_set_boolean (_tmp0_, "zealous", _tmp3_);
	_tmp4_ = self->priv->view;
	_tmp5_ = self->priv->settings;
	_tmp6_ = g_settings_get_boolean (_tmp5_, "zealous");
	_tmp4_->is_zealous = _tmp6_;
}


void G_MODULE_EXPORT update_size (GtkComboBox* size_combo, SwellFoop* self) {
	GtkTreeIter iter = {0};
	GtkComboBox* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	gboolean _tmp2_ = FALSE;
	gchar* new_size = NULL;
	GtkComboBox* _tmp3_ = NULL;
	GtkTreeModel* _tmp4_ = NULL;
	GtkTreeModel* _tmp5_ = NULL;
	GtkTreeIter _tmp6_ = {0};
	const gchar* _tmp7_ = NULL;
	GSettings* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gboolean _tmp11_ = FALSE;
	GSettings* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (size_combo != NULL);
	_tmp0_ = size_combo;
	_tmp2_ = gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
	iter = _tmp1_;
	if (!_tmp2_) {
		return;
	}
	_tmp3_ = size_combo;
	_tmp4_ = gtk_combo_box_get_model (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = iter;
	gtk_tree_model_get (_tmp5_, &_tmp6_, 1, &new_size, -1, -1);
	_tmp7_ = new_size;
	_tmp8_ = self->priv->settings;
	_tmp9_ = g_settings_get_string (_tmp8_, "size");
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strcmp0 (_tmp7_, _tmp10_) == 0;
	_g_free0 (_tmp10_);
	if (_tmp11_) {
		_g_free0 (new_size);
		return;
	}
	_tmp12_ = self->priv->settings;
	_tmp13_ = new_size;
	g_settings_set_string (_tmp12_, "size", _tmp13_);
	swell_foop_new_game (self);
	_g_free0 (new_size);
}


void G_MODULE_EXPORT update_colors (GtkSpinButton* button, SwellFoop* self) {
	gint new_colors = 0;
	GtkSpinButton* _tmp0_ = NULL;
	gdouble _tmp1_ = 0.0;
	gint _tmp2_ = 0;
	GSettings* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	GSettings* _tmp5_ = NULL;
	gint _tmp6_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = button;
	_tmp1_ = gtk_spin_button_get_value (_tmp0_);
	new_colors = (gint) _tmp1_;
	_tmp2_ = new_colors;
	_tmp3_ = self->priv->settings;
	_tmp4_ = g_settings_get_int (_tmp3_, "colors");
	if (_tmp2_ == _tmp4_) {
		return;
	}
	_tmp5_ = self->priv->settings;
	_tmp6_ = new_colors;
	g_settings_set_int (_tmp5_, "colors", _tmp6_);
	swell_foop_new_game (self);
}


static void swell_foop_preferences_response_cb (SwellFoop* self) {
	GtkDialog* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->preferences_dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp0_);
	_g_object_unref0 (self->priv->preferences_dialog);
	self->priv->preferences_dialog = NULL;
}


void swell_foop_show (SwellFoop* self) {
	GtkWindow* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	gtk_widget_show ((GtkWidget*) _tmp0_);
}


static void swell_foop_new_game_cb (SwellFoop* self) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game_in_progress;
	if (_tmp0_) {
		swell_foop_show_new_game_confirmation_dialog (self);
	} else {
		swell_foop_new_game (self);
	}
}


static void swell_foop_scores_cb (SwellFoop* self) {
	ScoreDialog* dialog = NULL;
	History* _tmp0_ = NULL;
	ScoreDialog* _tmp1_ = NULL;
	GtkWindow* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->history;
	_tmp1_ = score_dialog_new (_tmp0_, NULL, FALSE);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	gtk_window_set_modal ((GtkWindow*) dialog, TRUE);
	_tmp2_ = self->priv->window;
	gtk_window_set_transient_for ((GtkWindow*) dialog, _tmp2_);
	gtk_dialog_run ((GtkDialog*) dialog);
	gtk_widget_destroy ((GtkWidget*) dialog);
	_g_object_unref0 (dialog);
}


static void swell_foop_quit_cb (SwellFoop* self) {
	GtkWindow* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	gtk_widget_destroy ((GtkWidget*) _tmp0_);
}


static void swell_foop_help_cb (SwellFoop* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		GtkWindow* _tmp0_ = NULL;
		GdkScreen* _tmp1_ = NULL;
		guint32 _tmp2_ = 0U;
		_tmp0_ = self->priv->window;
		_tmp1_ = gtk_window_get_screen (_tmp0_);
		_tmp2_ = gtk_get_current_event_time ();
		gtk_show_uri (_tmp1_, "help:swell-foop", _tmp2_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
	}
	goto __finally5;
	__catch5_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 ("swell-foop.vala:446: Failed to show help: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally5:
	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 swell_foop_about_cb (SwellFoop* self) {
	gchar** authors = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gint authors_length1 = 0;
	gint _authors_size_ = 0;
	gchar** artists = NULL;
	gchar* _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint artists_length1 = 0;
	gint _artists_size_ = 0;
	gchar** documenters = NULL;
	gchar** _tmp5_ = NULL;
	gint documenters_length1 = 0;
	gint _documenters_size_ = 0;
	GtkWindow* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("Tim Horton");
	_tmp1_ = g_strdup ("Sophia Yu");
	_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 ("Tim Horton");
	_tmp4_ = g_new0 (gchar*, 2 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp4_[1] = NULL;
	artists = _tmp4_;
	artists_length1 = 2;
	_artists_size_ = artists_length1;
	_tmp5_ = g_new0 (gchar*, 1 + 1);
	_tmp5_[0] = NULL;
	documenters = _tmp5_;
	documenters_length1 = 1;
	_documenters_size_ = documenters_length1;
	_tmp6_ = self->priv->window;
	_tmp7_ = _ ("Swell Foop");
	_tmp8_ = _ ("I want to play that game!\n" \
"You know, they all light-up and you click on them and they vanish!");
	_tmp9_ = _ ("Copyright \xc2\xa9 2009 Tim Horton");
	_tmp10_ = _ ("translator-credits");
	gtk_show_about_dialog (_tmp6_, "program-name", _tmp7_, "version", VERSION, "comments", _tmp8_, "copyright", _tmp9_, "license-type", GTK_LICENSE_GPL_2_0, "authors", authors, "artists", artists, "documenters", documenters, "translator-credits", _tmp10_, "logo-icon-name", "swell-foop", "website", "https://wiki.gnome.org/Apps/Swell%20Foop", NULL, NULL);
	documenters = (_vala_array_free (documenters, documenters_length1, (GDestroyNotify) g_free), NULL);
	artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
	authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
}


static void _swell_foop_started_cb_game_started (Game* _sender, gpointer self) {
	swell_foop_started_cb ((SwellFoop*) self);
}


void swell_foop_new_game (SwellFoop* self) {
	Size _tmp0_ = {0};
	Size _tmp1_ = {0};
	gint _tmp2_ = 0;
	Size _tmp3_ = {0};
	Size _tmp4_ = {0};
	gint _tmp5_ = 0;
	GSettings* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	Game* _tmp8_ = NULL;
	Game* _tmp9_ = NULL;
	Game* _tmp10_ = NULL;
	Game* _tmp11_ = NULL;
	GameView* _tmp12_ = NULL;
	GSettings* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	GameView* _tmp16_ = NULL;
	Game* _tmp17_ = NULL;
	GameView* _tmp18_ = NULL;
	GSettings* _tmp19_ = NULL;
	gboolean _tmp20_ = FALSE;
	ClutterStage* _tmp21_ = NULL;
	GameView* _tmp22_ = NULL;
	gfloat _tmp23_ = 0.0F;
	gfloat _tmp24_ = 0.0F;
	GameView* _tmp25_ = NULL;
	gfloat _tmp26_ = 0.0F;
	gfloat _tmp27_ = 0.0F;
	GtkClutterEmbed* _tmp28_ = NULL;
	ClutterStage* _tmp29_ = NULL;
	gfloat _tmp30_ = 0.0F;
	gfloat _tmp31_ = 0.0F;
	ClutterStage* _tmp32_ = NULL;
	gfloat _tmp33_ = 0.0F;
	gfloat _tmp34_ = 0.0F;
	g_return_if_fail (self != NULL);
	swell_foop_get_size (self, &_tmp0_);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_.rows;
	swell_foop_get_size (self, &_tmp3_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_.columns;
	_tmp6_ = self->priv->settings;
	_tmp7_ = g_settings_get_int (_tmp6_, "colors");
	_tmp8_ = game_new (_tmp2_, _tmp5_, _tmp7_);
	_g_object_unref0 (self->priv->game);
	self->priv->game = _tmp8_;
	size_destroy (&_tmp4_);
	size_destroy (&_tmp1_);
	_tmp9_ = self->priv->game;
	g_signal_connect_object (_tmp9_, "update-score", (GCallback) _swell_foop_update_score_cb_game_update_score, self, 0);
	_tmp10_ = self->priv->game;
	g_signal_connect_object (_tmp10_, "complete", (GCallback) _swell_foop_complete_cb_game_complete, self, 0);
	_tmp11_ = self->priv->game;
	g_signal_connect_object (_tmp11_, "started", (GCallback) _swell_foop_started_cb_game_started, self, 0);
	_tmp12_ = self->priv->view;
	_tmp13_ = self->priv->settings;
	_tmp14_ = g_settings_get_string (_tmp13_, "theme");
	_tmp15_ = _tmp14_;
	game_view_set_theme_name (_tmp12_, _tmp15_);
	_g_free0 (_tmp15_);
	_tmp16_ = self->priv->view;
	_tmp17_ = self->priv->game;
	game_view_set_game (_tmp16_, _tmp17_);
	_tmp18_ = self->priv->view;
	_tmp19_ = self->priv->settings;
	_tmp20_ = g_settings_get_boolean (_tmp19_, "zealous");
	_tmp18_->is_zealous = _tmp20_;
	_tmp21_ = self->priv->stage;
	_tmp22_ = self->priv->view;
	_tmp23_ = clutter_actor_get_width ((ClutterActor*) _tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = self->priv->view;
	_tmp26_ = clutter_actor_get_height ((ClutterActor*) _tmp25_);
	_tmp27_ = _tmp26_;
	clutter_actor_set_size ((ClutterActor*) _tmp21_, _tmp24_, _tmp27_);
	_tmp28_ = self->priv->clutter_embed;
	_tmp29_ = self->priv->stage;
	_tmp30_ = clutter_actor_get_width ((ClutterActor*) _tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = self->priv->stage;
	_tmp33_ = clutter_actor_get_height ((ClutterActor*) _tmp32_);
	_tmp34_ = _tmp33_;
	gtk_widget_set_size_request ((GtkWidget*) _tmp28_, (gint) _tmp31_, (gint) _tmp34_);
	self->priv->game_in_progress = FALSE;
	swell_foop_update_score_cb (self, 0);
}


static void swell_foop_show_new_game_confirmation_dialog (SwellFoop* self) {
	GtkMessageDialog* dialog = NULL;
	GtkWindow* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkMessageDialog* _tmp2_ = NULL;
	GtkMessageDialog* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GtkMessageDialog* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gint _result_ = 0;
	GtkMessageDialog* _tmp7_ = NULL;
	gint _tmp8_ = 0;
	GtkMessageDialog* _tmp9_ = NULL;
	gint _tmp10_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	_tmp1_ = _ ("Abandon this game to start a new one?");
	_tmp2_ = (GtkMessageDialog*) gtk_message_dialog_new_with_markup (_tmp0_, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "<span weight=\"bold\" size=\"larger\">%s</span>", _tmp1_);
	g_object_ref_sink (_tmp2_);
	dialog = _tmp2_;
	_tmp3_ = dialog;
	_tmp4_ = _ ("_Cancel");
	gtk_dialog_add_button ((GtkDialog*) _tmp3_, _tmp4_, (gint) GTK_RESPONSE_CANCEL);
	_tmp5_ = dialog;
	_tmp6_ = _ ("_New Game");
	gtk_dialog_add_button ((GtkDialog*) _tmp5_, _tmp6_, (gint) GTK_RESPONSE_YES);
	_tmp7_ = dialog;
	_tmp8_ = gtk_dialog_run ((GtkDialog*) _tmp7_);
	_result_ = _tmp8_;
	_tmp9_ = dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp9_);
	_tmp10_ = _result_;
	if (_tmp10_ == ((gint) GTK_RESPONSE_YES)) {
		swell_foop_new_game (self);
	}
	_g_object_unref0 (dialog);
}


gint swell_foop_main (gchar** args, int args_length1) {
	gint result = 0;
	ClutterInitError _tmp0_ = 0;
	GOptionContext* context = NULL;
	GOptionContext* _tmp1_ = NULL;
	GOptionContext* _tmp2_ = NULL;
	GOptionContext* _tmp3_ = NULL;
	GOptionGroup* _tmp4_ = NULL;
	GOptionContext* _tmp5_ = NULL;
	GOptionGroup* _tmp6_ = NULL;
	const gchar* _tmp11_ = NULL;
	SwellFoop* app = NULL;
	SwellFoop* _tmp12_ = NULL;
	SwellFoop* _tmp13_ = NULL;
	gchar** _tmp14_ = NULL;
	gint _tmp14__length1 = 0;
	gint _tmp15_ = 0;
	GError * _inner_error_ = NULL;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = gtk_clutter_init (&args_length1, &args);
	if (_tmp0_ != CLUTTER_INIT_SUCCESS) {
		g_warning ("swell-foop.vala:519: Failed to initialise Clutter");
		result = EXIT_FAILURE;
		return result;
	}
	_tmp1_ = g_option_context_new (NULL);
	context = _tmp1_;
	_tmp2_ = context;
	g_option_context_set_translation_domain (_tmp2_, GETTEXT_PACKAGE);
	_tmp3_ = context;
	_tmp4_ = gtk_get_option_group (TRUE);
	g_option_context_add_group (_tmp3_, _tmp4_);
	_tmp5_ = context;
	_tmp6_ = clutter_get_option_group_without_init ();
	g_option_context_add_group (_tmp5_, _tmp6_);
	{
		GOptionContext* _tmp7_ = NULL;
		_tmp7_ = context;
		g_option_context_parse (_tmp7_, &args_length1, &args, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch6_g_error;
		}
	}
	goto __finally6;
	__catch6_g_error:
	{
		GError* e = NULL;
		FILE* _tmp8_ = NULL;
		GError* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = stderr;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		fprintf (_tmp8_, "%s\n", _tmp10_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_option_context_free0 (context);
		return result;
	}
	__finally6:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_option_context_free0 (context);
		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 0;
	}
	_tmp11_ = _ ("Swell Foop");
	g_set_application_name (_tmp11_);
	gtk_window_set_default_icon_name ("swellfoop");
	_tmp12_ = swell_foop_new ();
	app = _tmp12_;
	_tmp13_ = app;
	_tmp14_ = args;
	_tmp14__length1 = args_length1;
	_tmp15_ = g_application_run ((GApplication*) _tmp13_, _tmp14__length1, _tmp14_);
	result = _tmp15_;
	_g_object_unref0 (app);
	_g_option_context_free0 (context);
	return result;
}


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


static void swell_foop_class_init (SwellFoopClass * klass) {
	swell_foop_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SwellFoopPrivate));
	((GApplicationClass *) klass)->startup = swell_foop_real_startup;
	((GApplicationClass *) klass)->shutdown = swell_foop_real_shutdown;
	((GApplicationClass *) klass)->activate = swell_foop_real_activate;
	G_OBJECT_CLASS (klass)->finalize = swell_foop_finalize;
}


static void swell_foop_instance_init (SwellFoop * self) {
	self->priv = SWELL_FOOP_GET_PRIVATE (self);
	self->priv->game = NULL;
	self->priv->preferences_dialog = NULL;
	self->priv->game_in_progress = FALSE;
}


static void swell_foop_finalize (GObject* obj) {
	SwellFoop * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SWELL_FOOP, SwellFoop);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->history);
	_g_object_unref0 (self->priv->game);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->stage);
	_g_object_unref0 (self->priv->clutter_embed);
	_g_object_unref0 (self->priv->preferences_dialog);
	_g_object_unref0 (self->priv->headerbar);
	self->sizes = (_vala_Size_array_free (self->sizes, self->sizes_length1), NULL);
	G_OBJECT_CLASS (swell_foop_parent_class)->finalize (obj);
}


GType swell_foop_get_type (void) {
	static volatile gsize swell_foop_type_id__volatile = 0;
	if (g_once_init_enter (&swell_foop_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SwellFoopClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) swell_foop_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwellFoop), 0, (GInstanceInitFunc) swell_foop_instance_init, NULL };
		GType swell_foop_type_id;
		swell_foop_type_id = g_type_register_static (gtk_application_get_type (), "SwellFoop", &g_define_type_info, 0);
		g_once_init_leave (&swell_foop_type_id__volatile, swell_foop_type_id);
	}
	return swell_foop_type_id__volatile;
}


void size_copy (const Size* self, Size* dest) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	_tmp0_ = (*self).id;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).id);
	(*dest).id = _tmp1_;
	_tmp2_ = (*self).name;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).name);
	(*dest).name = _tmp3_;
	_tmp4_ = (*self).columns;
	(*dest).columns = _tmp4_;
	_tmp5_ = (*self).rows;
	(*dest).rows = _tmp5_;
}


void size_destroy (Size* self) {
	_g_free0 ((*self).id);
	_g_free0 ((*self).name);
}


Size* size_dup (const Size* self) {
	Size* dup;
	dup = g_new0 (Size, 1);
	size_copy (self, dup);
	return dup;
}


void size_free (Size* self) {
	size_destroy (self);
	g_free (self);
}


GType size_get_type (void) {
	static volatile gsize size_type_id__volatile = 0;
	if (g_once_init_enter (&size_type_id__volatile)) {
		GType size_type_id;
		size_type_id = g_boxed_type_register_static ("Size", (GBoxedCopyFunc) size_dup, (GBoxedFreeFunc) size_free);
		g_once_init_leave (&size_type_id__volatile, size_type_id);
	}
	return size_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);
}



