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

/*
 * Copyright (C) 2010-2013 Robert Ancell
 * Copyright (C) 2014 Michael Catanzaro
 *
 * 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 <clutter/clutter.h>
#include <clutter-gtk/clutter-gtk.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>


#define TYPE_LIGHTS_OFF (lights_off_get_type ())
#define LIGHTS_OFF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LIGHTS_OFF, LightsOff))
#define LIGHTS_OFF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LIGHTS_OFF, LightsOffClass))
#define IS_LIGHTS_OFF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LIGHTS_OFF))
#define IS_LIGHTS_OFF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LIGHTS_OFF))
#define LIGHTS_OFF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LIGHTS_OFF, LightsOffClass))

typedef struct _LightsOff LightsOff;
typedef struct _LightsOffClass LightsOffClass;
typedef struct _LightsOffPrivate LightsOffPrivate;

#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_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _LightsOff {
	GtkApplication parent_instance;
	LightsOffPrivate * priv;
};

struct _LightsOffClass {
	GtkApplicationClass parent_class;
};

struct _LightsOffPrivate {
	GSettings* settings;
	GtkApplicationWindow* window;
	GtkHeaderBar* headerbar;
	GameView* game_view;
	GSimpleAction* previous_level;
};


static gpointer lights_off_parent_class = NULL;

GType lights_off_get_type (void) G_GNUC_CONST;
GType game_view_get_type (void) G_GNUC_CONST;
#define LIGHTS_OFF_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_LIGHTS_OFF, LightsOffPrivate))
enum  {
	LIGHTS_OFF_DUMMY_PROPERTY
};
static void lights_off_quit_cb (LightsOff* self);
static void _lights_off_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void lights_off_help_cb (LightsOff* self);
static void _lights_off_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void lights_off_about_cb (LightsOff* self);
static void _lights_off_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void lights_off_new_game_cb (LightsOff* self);
static void _lights_off_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void lights_off_previous_level_cb (LightsOff* self);
static void _lights_off_previous_level_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static void lights_off_next_level_cb (LightsOff* self);
static void _lights_off_next_level_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
static LightsOff* lights_off_new (void);
static LightsOff* lights_off_construct (GType object_type);
static void lights_off_real_startup (GApplication* base);
static void lights_off_level_changed_cb (LightsOff* self, gint level);
static gboolean lights_off_key_release_event_cb (LightsOff* self, ClutterActor* actor, ClutterKeyEvent* event);
static gboolean _lights_off_key_release_event_cb_clutter_actor_key_release_event (ClutterActor* _sender, ClutterKeyEvent* event, gpointer self);
GameView* game_view_new (gint level);
GameView* game_view_construct (GType object_type, gint level);
static void _lights_off_level_changed_cb_game_view_level_changed (GameView* _sender, gint level, gpointer self);
static void lights_off_update_subtitle (LightsOff* self, gint moves);
static void _lights_off_update_subtitle_game_view_moves_changed (GameView* _sender, gint moves, gpointer self);
static void lights_off_update_title (LightsOff* self, gint level);
void game_view_swap_board (GameView* self, gint direction);
void game_view_hide_cursor (GameView* self);
void game_view_move_cursor (GameView* self, gint x_step, gint y_step);
void game_view_activate_cursor (GameView* self);
static void lights_off_real_activate (GApplication* base);
void game_view_reset_game (GameView* self);
gint lights_off_main (gchar** args, int args_length1);
static void lights_off_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 LIGHTS_OFF_action_entries[3] = {{"quit", _lights_off_quit_cb_gsimple_action_activate_callback}, {"help", _lights_off_help_cb_gsimple_action_activate_callback}, {"about", _lights_off_about_cb_gsimple_action_activate_callback}};
static const GActionEntry LIGHTS_OFF_window_actions[3] = {{"new-game", _lights_off_new_game_cb_gsimple_action_activate_callback}, {"previous-level", _lights_off_previous_level_cb_gsimple_action_activate_callback}, {"next-level", _lights_off_next_level_cb_gsimple_action_activate_callback}};

static void _lights_off_quit_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_quit_cb ((LightsOff*) self);
}


static void _lights_off_help_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_help_cb ((LightsOff*) self);
}


static void _lights_off_about_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_about_cb ((LightsOff*) self);
}


static void _lights_off_new_game_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_new_game_cb ((LightsOff*) self);
}


static void _lights_off_previous_level_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_previous_level_cb ((LightsOff*) self);
}


static void _lights_off_next_level_cb_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
	lights_off_next_level_cb ((LightsOff*) self);
}


static LightsOff* lights_off_construct (GType object_type) {
	LightsOff * self = NULL;
	self = (LightsOff*) g_object_new (object_type, "application-id", "org.gnome.lightsoff", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	return self;
}


static LightsOff* lights_off_new (void) {
	return lights_off_construct (TYPE_LIGHTS_OFF);
}


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


static gboolean _lights_off_key_release_event_cb_clutter_actor_key_release_event (ClutterActor* _sender, ClutterKeyEvent* event, gpointer self) {
	gboolean result;
	result = lights_off_key_release_event_cb ((LightsOff*) self, _sender, event);
	return result;
}


static void _lights_off_level_changed_cb_game_view_level_changed (GameView* _sender, gint level, gpointer self) {
	lights_off_level_changed_cb ((LightsOff*) self, level);
}


static void _lights_off_update_subtitle_game_view_moves_changed (GameView* _sender, gint moves, gpointer self) {
	lights_off_update_subtitle ((LightsOff*) self, moves);
}


static void lights_off_real_startup (GApplication* base) {
	LightsOff * self;
	GtkSettings* _tmp0_ = NULL;
	GSettings* _tmp1_ = NULL;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GtkApplicationWindow* _tmp4_ = NULL;
	GObject* _tmp5_ = NULL;
	GtkHeaderBar* _tmp6_ = NULL;
	GtkApplicationWindow* _tmp7_ = NULL;
	GtkApplicationWindow* _tmp8_ = NULL;
	GAction* _tmp9_ = NULL;
	GSimpleAction* _tmp10_ = NULL;
	GSettings* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	GtkClutterEmbed* clutter_embed = NULL;
	GtkClutterEmbed* _tmp13_ = NULL;
	GtkApplicationWindow* _tmp14_ = NULL;
	ClutterStage* stage = NULL;
	ClutterActor* _tmp15_ = NULL;
	ClutterStage* _tmp16_ = NULL;
	ClutterColor _tmp17_ = {0};
	GSettings* _tmp18_ = NULL;
	gint _tmp19_ = 0;
	GameView* _tmp20_ = NULL;
	GameView* _tmp21_ = NULL;
	GameView* _tmp22_ = NULL;
	GameView* _tmp23_ = NULL;
	GameView* _tmp24_ = NULL;
	GameView* _tmp25_ = NULL;
	gfloat _tmp26_ = 0.0F;
	gfloat _tmp27_ = 0.0F;
	GameView* _tmp28_ = NULL;
	gfloat _tmp29_ = 0.0F;
	gfloat _tmp30_ = 0.0F;
	gfloat _tmp31_ = 0.0F;
	gfloat _tmp32_ = 0.0F;
	gfloat _tmp33_ = 0.0F;
	gfloat _tmp34_ = 0.0F;
	GtkApplicationWindow* _tmp35_ = NULL;
	self = (LightsOff*) base;
	G_APPLICATION_CLASS (lights_off_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	gtk_window_set_default_icon_name ("lightsoff");
	_tmp0_ = gtk_settings_get_default ();
	g_object_set ((GObject*) _tmp0_, "gtk-application-prefer-dark-theme", TRUE, NULL);
	g_action_map_add_action_entries ((GActionMap*) self, LIGHTS_OFF_action_entries, G_N_ELEMENTS (LIGHTS_OFF_action_entries), self);
	_tmp1_ = g_settings_new ("org.gnome.lightsoff");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = gtk_builder_new_from_resource ("/org/gnome/lightsoff/ui/lightsoff.ui");
	builder = _tmp2_;
	_tmp3_ = gtk_builder_get_object (builder, "window");
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_application_window_get_type (), GtkApplicationWindow));
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp4_;
	_tmp5_ = gtk_builder_get_object (builder, "headerbar");
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_header_bar_get_type (), GtkHeaderBar));
	_g_object_unref0 (self->priv->headerbar);
	self->priv->headerbar = _tmp6_;
	_tmp7_ = self->priv->window;
	g_action_map_add_action_entries ((GActionMap*) _tmp7_, LIGHTS_OFF_window_actions, G_N_ELEMENTS (LIGHTS_OFF_window_actions), self);
	_tmp8_ = self->priv->window;
	_tmp9_ = g_action_map_lookup_action ((GActionMap*) _tmp8_, "previous-level");
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, g_simple_action_get_type (), GSimpleAction));
	_g_object_unref0 (self->priv->previous_level);
	self->priv->previous_level = _tmp10_;
	_tmp11_ = self->priv->settings;
	_tmp12_ = g_settings_get_int (_tmp11_, "level");
	lights_off_level_changed_cb (self, _tmp12_);
	_tmp13_ = (GtkClutterEmbed*) gtk_clutter_embed_new ();
	g_object_ref_sink (_tmp13_);
	clutter_embed = _tmp13_;
	gtk_widget_show ((GtkWidget*) clutter_embed);
	_tmp14_ = self->priv->window;
	gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) clutter_embed);
	_tmp15_ = gtk_clutter_embed_get_stage (clutter_embed);
	_tmp16_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, clutter_stage_get_type (), ClutterStage));
	stage = _tmp16_;
	g_signal_connect_object ((ClutterActor*) stage, "key-release-event", (GCallback) _lights_off_key_release_event_cb_clutter_actor_key_release_event, self, 0);
	clutter_color_from_string (&_tmp17_, "#000000");
	clutter_actor_set_background_color ((ClutterActor*) stage, &_tmp17_);
	_tmp18_ = self->priv->settings;
	_tmp19_ = g_settings_get_int (_tmp18_, "level");
	_tmp20_ = game_view_new (_tmp19_);
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->game_view);
	self->priv->game_view = _tmp20_;
	_tmp21_ = self->priv->game_view;
	g_signal_connect_object (_tmp21_, "level-changed", (GCallback) _lights_off_level_changed_cb_game_view_level_changed, self, 0);
	_tmp22_ = self->priv->game_view;
	g_signal_connect_object (_tmp22_, "moves-changed", (GCallback) _lights_off_update_subtitle_game_view_moves_changed, self, 0);
	_tmp23_ = self->priv->game_view;
	clutter_actor_show ((ClutterActor*) _tmp23_);
	_tmp24_ = self->priv->game_view;
	clutter_actor_add_child ((ClutterActor*) stage, (ClutterActor*) _tmp24_);
	_tmp25_ = self->priv->game_view;
	_tmp26_ = clutter_actor_get_width ((ClutterActor*) _tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = self->priv->game_view;
	_tmp29_ = clutter_actor_get_height ((ClutterActor*) _tmp28_);
	_tmp30_ = _tmp29_;
	clutter_actor_set_size ((ClutterActor*) stage, _tmp27_, _tmp30_);
	_tmp31_ = clutter_actor_get_width ((ClutterActor*) stage);
	_tmp32_ = _tmp31_;
	_tmp33_ = clutter_actor_get_height ((ClutterActor*) stage);
	_tmp34_ = _tmp33_;
	gtk_widget_set_size_request ((GtkWidget*) clutter_embed, (gint) _tmp32_, (gint) _tmp34_);
	_tmp35_ = self->priv->window;
	gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) _tmp35_);
	_g_object_unref0 (stage);
	_g_object_unref0 (clutter_embed);
	_g_object_unref0 (builder);
}


static void lights_off_update_subtitle (LightsOff* self, gint moves) {
	GtkHeaderBar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	const gchar* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->headerbar;
	_tmp1_ = moves;
	_tmp2_ = ngettext ("%d move", "%d moves", (gulong) _tmp1_);
	_tmp3_ = moves;
	_tmp4_ = g_strdup_printf (_tmp2_, _tmp3_);
	_tmp5_ = _tmp4_;
	gtk_header_bar_set_subtitle (_tmp0_, _tmp5_);
	_g_free0 (_tmp5_);
}


static void lights_off_update_title (LightsOff* self, gint level) {
	GtkHeaderBar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->headerbar;
	_tmp1_ = _ ("Level %d");
	_tmp2_ = level;
	_tmp3_ = g_strdup_printf (_tmp1_, _tmp2_);
	_tmp4_ = _tmp3_;
	gtk_header_bar_set_title (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = level;
	if (_tmp5_ == 1) {
		GtkHeaderBar* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		_tmp6_ = self->priv->headerbar;
		_tmp7_ = _ ("Turn off all the lights!");
		gtk_header_bar_set_subtitle (_tmp6_, _tmp7_);
	} else {
		lights_off_update_subtitle (self, 0);
	}
}


static void lights_off_previous_level_cb (LightsOff* self) {
	GameView* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game_view;
	game_view_swap_board (_tmp0_, -1);
}


static void lights_off_next_level_cb (LightsOff* self) {
	GameView* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game_view;
	game_view_swap_board (_tmp0_, 1);
}


static void lights_off_level_changed_cb (LightsOff* self, gint level) {
	GSimpleAction* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GSettings* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->previous_level;
	_tmp1_ = level;
	g_simple_action_set_enabled (_tmp0_, _tmp1_ > 1);
	_tmp2_ = level;
	lights_off_update_title (self, _tmp2_);
	_tmp3_ = level;
	_tmp4_ = self->priv->settings;
	_tmp5_ = g_settings_get_int (_tmp4_, "level");
	if (_tmp3_ != _tmp5_) {
		GSettings* _tmp6_ = NULL;
		gint _tmp7_ = 0;
		_tmp6_ = self->priv->settings;
		_tmp7_ = level;
		g_settings_set_int (_tmp6_, "level", _tmp7_);
	}
}


static gboolean lights_off_key_release_event_cb (LightsOff* self, ClutterActor* actor, ClutterKeyEvent* event) {
	gboolean result = FALSE;
	ClutterKeyEvent _tmp0_ = {0};
	guint _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (actor != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.keyval;
	switch (_tmp1_) {
		case CLUTTER_KEY_Escape:
		{
			GameView* _tmp2_ = NULL;
			_tmp2_ = self->priv->game_view;
			game_view_hide_cursor (_tmp2_);
			result = TRUE;
			return result;
		}
		case CLUTTER_KEY_Down:
		{
			GameView* _tmp3_ = NULL;
			_tmp3_ = self->priv->game_view;
			game_view_move_cursor (_tmp3_, 0, 1);
			result = TRUE;
			return result;
		}
		case CLUTTER_KEY_Up:
		{
			GameView* _tmp4_ = NULL;
			_tmp4_ = self->priv->game_view;
			game_view_move_cursor (_tmp4_, 0, -1);
			result = TRUE;
			return result;
		}
		case CLUTTER_KEY_Left:
		{
			GameView* _tmp5_ = NULL;
			_tmp5_ = self->priv->game_view;
			game_view_move_cursor (_tmp5_, -1, 0);
			result = TRUE;
			return result;
		}
		case CLUTTER_KEY_Right:
		{
			GameView* _tmp6_ = NULL;
			_tmp6_ = self->priv->game_view;
			game_view_move_cursor (_tmp6_, 1, 0);
			result = TRUE;
			return result;
		}
		case CLUTTER_KEY_Return:
		{
			GameView* _tmp7_ = NULL;
			_tmp7_ = self->priv->game_view;
			game_view_activate_cursor (_tmp7_);
			result = TRUE;
			return result;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
}


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


static void lights_off_new_game_cb (LightsOff* self) {
	GameView* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->game_view;
	game_view_reset_game (_tmp0_);
}


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


static void lights_off_help_cb (LightsOff* 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:lightsoff", _tmp2_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_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 ("lightsoff.vala:164: Failed to show help: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	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 lights_off_about_cb (LightsOff* 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;
	gchar** _tmp5_ = NULL;
	gint artists_length1 = 0;
	gint _artists_size_ = 0;
	gchar** documenters = NULL;
	gchar* _tmp6_ = NULL;
	gchar** _tmp7_ = NULL;
	gint documenters_length1 = 0;
	gint _documenters_size_ = 0;
	GtkApplicationWindow* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("Tim Horton");
	_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 ("Tim Horton");
	_tmp4_ = g_strdup ("Ulisse Perusin");
	_tmp5_ = g_new0 (gchar*, 3 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	_tmp5_[2] = NULL;
	artists = _tmp5_;
	artists_length1 = 3;
	_artists_size_ = artists_length1;
	_tmp6_ = g_strdup ("Eric Baudais");
	_tmp7_ = g_new0 (gchar*, 2 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp7_[1] = NULL;
	documenters = _tmp7_;
	documenters_length1 = 2;
	_documenters_size_ = documenters_length1;
	_tmp8_ = self->priv->window;
	_tmp9_ = _ ("Lights Off");
	_tmp10_ = _ ("Turn off all the lights");
	_tmp11_ = _ ("translator-credits");
	gtk_show_about_dialog ((GtkWindow*) _tmp8_, "program-name", _tmp9_, "version", VERSION, "comments", _tmp10_, "copyright", "Copyright © 2009 Tim Horton", "license-type", GTK_LICENSE_GPL_2_0, "authors", authors, "artists", artists, "documenters", documenters, "translator-credits", _tmp11_, "logo-icon-name", "lightsoff", "website", "https://wiki.gnome.org/Apps/Lightsoff", 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);
}


gint lights_off_main (gchar** args, int args_length1) {
	gint result = 0;
	const gchar* _tmp0_ = NULL;
	ClutterInitError _tmp1_ = 0;
	LightsOff* app = NULL;
	LightsOff* _tmp2_ = NULL;
	LightsOff* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = _ ("Lights Off");
	g_set_application_name (_tmp0_);
	_tmp1_ = gtk_clutter_init (&args_length1, &args);
	if (_tmp1_ != CLUTTER_INIT_SUCCESS) {
		g_warning ("lightsoff.vala:217: Failed to initialise Clutter");
		result = EXIT_FAILURE;
		return result;
	}
	_tmp2_ = lights_off_new ();
	app = _tmp2_;
	_tmp3_ = app;
	_tmp4_ = g_application_run ((GApplication*) _tmp3_, 0, NULL);
	result = _tmp4_;
	_g_object_unref0 (app);
	return result;
}


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


static void lights_off_class_init (LightsOffClass * klass) {
	lights_off_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (LightsOffPrivate));
	((GApplicationClass *) klass)->startup = lights_off_real_startup;
	((GApplicationClass *) klass)->activate = lights_off_real_activate;
	G_OBJECT_CLASS (klass)->finalize = lights_off_finalize;
}


static void lights_off_instance_init (LightsOff * self) {
	self->priv = LIGHTS_OFF_GET_PRIVATE (self);
}


static void lights_off_finalize (GObject* obj) {
	LightsOff * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_LIGHTS_OFF, LightsOff);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->headerbar);
	_g_object_unref0 (self->priv->game_view);
	_g_object_unref0 (self->priv->previous_level);
	G_OBJECT_CLASS (lights_off_parent_class)->finalize (obj);
}


GType lights_off_get_type (void) {
	static volatile gsize lights_off_type_id__volatile = 0;
	if (g_once_init_enter (&lights_off_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (LightsOffClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) lights_off_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LightsOff), 0, (GInstanceInitFunc) lights_off_instance_init, NULL };
		GType lights_off_type_id;
		lights_off_type_id = g_type_register_static (gtk_application_get_type (), "LightsOff", &g_define_type_info, 0);
		g_once_init_leave (&lights_off_type_id__volatile, lights_off_type_id);
	}
	return lights_off_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);
}



