/* swell-foop.c generated by valac 0.56.18-dirty, 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 <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include "config.h"
#include <gdk/gdk.h>
#include <locale.h>

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

#define TYPE_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_SWELL_FOOP_WINDOW (swell_foop_window_get_type ())
#define SWELL_FOOP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SWELL_FOOP_WINDOW, SwellFoopWindow))
#define SWELL_FOOP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SWELL_FOOP_WINDOW, SwellFoopWindowClass))
#define IS_SWELL_FOOP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SWELL_FOOP_WINDOW))
#define IS_SWELL_FOOP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SWELL_FOOP_WINDOW))
#define SWELL_FOOP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SWELL_FOOP_WINDOW, SwellFoopWindowClass))

typedef struct _SwellFoopWindow SwellFoopWindow;
typedef struct _SwellFoopWindowClass SwellFoopWindowClass;
enum  {
	SWELL_FOOP_0_PROPERTY,
	SWELL_FOOP_NUM_PROPERTIES
};
static GParamSpec* swell_foop_properties[SWELL_FOOP_NUM_PROPERTIES];
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _SwellFoop {
	AdwApplication parent_instance;
	SwellFoopPrivate * priv;
};

struct _SwellFoopClass {
	AdwApplicationClass parent_class;
};

struct _SwellFoopPrivate {
	SwellFoopWindow* window;
};

static gint SwellFoop_private_offset;
static gpointer swell_foop_parent_class = NULL;

VALA_EXTERN GType swell_foop_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwellFoop, g_object_unref)
VALA_EXTERN GType swell_foop_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwellFoopWindow, g_object_unref)
static inline void swell_foop_help_cb (SwellFoop* self);
static void _swell_foop_help_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self);
static inline void swell_foop_about_cb (SwellFoop* self);
static void _swell_foop_about_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                            GVariant* parameter,
                                                            gpointer self);
static inline void swell_foop_quit_cb (SwellFoop* self);
static void _swell_foop_quit_cb_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self);
VALA_EXTERN SwellFoop* swell_foop_new (void);
VALA_EXTERN SwellFoop* swell_foop_construct (GType object_type);
static void swell_foop_real_startup (GApplication* base);
static gint swell_foop_real_handle_local_options (GApplication* base,
                                           GVariantDict* options);
static void swell_foop_real_shutdown (GApplication* base);
static void swell_foop_real_activate (GApplication* base);
VALA_EXTERN SwellFoopWindow* swell_foop_window_new (GtkApplication* application);
VALA_EXTERN SwellFoopWindow* swell_foop_window_construct (GType object_type,
                                              GtkApplication* application);
static gint swell_foop_main (gchar** args,
                      gint args_length1);
static void swell_foop_finalize (GObject * obj);
static GType swell_foop_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static const GOptionEntry SWELL_FOOP_option_entries[2] = {{"version", 'v', (gint) G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, N_ ("Print release version and exit"), NULL}, {0}};
static const GActionEntry SWELL_FOOP_action_entries[3] = {{"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 inline gpointer
swell_foop_get_instance_private (SwellFoop* self)
{
	return G_STRUCT_MEMBER_P (self, SwellFoop_private_offset);
}

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);
	g_application_add_main_option_entries ((GApplication*) self, SWELL_FOOP_option_entries);
	return self;
}

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

static void
swell_foop_real_startup (GApplication* base)
{
	SwellFoop * self;
	AdwStyleManager* _tmp0_;
	AdwStyleManager* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar* _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar* _tmp18_;
	gchar** _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	self = (SwellFoop*) base;
	G_APPLICATION_CLASS (swell_foop_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
	_tmp0_ = adw_application_get_style_manager ((AdwApplication*) self);
	_tmp1_ = _tmp0_;
	adw_style_manager_set_color_scheme (_tmp1_, ADW_COLOR_SCHEME_FORCE_DARK);
	g_action_map_add_action_entries ((GActionMap*) self, SWELL_FOOP_action_entries, (gint) G_N_ELEMENTS (SWELL_FOOP_action_entries), self);
	_tmp2_ = g_strdup ("F1");
	_tmp3_ = g_new0 (gchar*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.help", _tmp4_);
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = g_strdup ("F10");
	_tmp6_ = g_new0 (gchar*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "win.toggle-hamburger", _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = g_strdup ("<Primary>n");
	_tmp9_ = g_strdup ("F2");
	_tmp10_ = g_new0 (gchar*, 2 + 1);
	_tmp10_[0] = _tmp8_;
	_tmp10_[1] = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp11__length1 = 2;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "win.new-game", _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	_tmp12_ = g_strdup ("<Primary>q");
	_tmp13_ = g_new0 (gchar*, 1 + 1);
	_tmp13_[0] = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp14_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	_tmp15_ = g_strdup ("<Primary>z");
	_tmp16_ = g_new0 (gchar*, 1 + 1);
	_tmp16_[0] = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp17__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "win.undo", _tmp17_);
	_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
	_tmp18_ = g_strdup ("<Shift><Primary>z");
	_tmp19_ = g_new0 (gchar*, 1 + 1);
	_tmp19_[0] = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp20__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "win.redo", _tmp20_);
	_tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
}

static gint
swell_foop_real_handle_local_options (GApplication* base,
                                      GVariantDict* options)
{
	SwellFoop * self;
	gint result;
	self = (SwellFoop*) base;
	g_return_val_if_fail (options != NULL, 0);
	if (g_variant_dict_contains (options, "version")) {
		FILE* _tmp0_;
		_tmp0_ = stderr;
		fprintf (_tmp0_, "%1$s %2$s\n", SWELL_FOOP_PROGRAM_NAME, VERSION);
		result = EXIT_SUCCESS;
		return result;
	}
	result = -1;
	return result;
}

static void
swell_foop_real_shutdown (GApplication* base)
{
	SwellFoop * self;
	SwellFoopWindow* _tmp0_;
	self = (SwellFoop*) base;
	_tmp0_ = self->priv->window;
	if (_tmp0_ != NULL) {
		SwellFoopWindow* _tmp1_;
		_tmp1_ = self->priv->window;
		gtk_window_close ((GtkWindow*) _tmp1_);
	}
	G_APPLICATION_CLASS (swell_foop_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_get_type (), AdwApplication));
}

static void
swell_foop_real_activate (GApplication* base)
{
	SwellFoop * self;
	SwellFoopWindow* _tmp0_;
	SwellFoopWindow* _tmp2_;
	self = (SwellFoop*) base;
	_tmp0_ = self->priv->window;
	if (_tmp0_ == NULL) {
		SwellFoopWindow* _tmp1_;
		_tmp1_ = swell_foop_window_new ((GtkApplication*) self);
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->window);
		self->priv->window = _tmp1_;
	}
	_tmp2_ = self->priv->window;
	gtk_window_present ((GtkWindow*) _tmp2_);
}

static inline void
swell_foop_quit_cb (SwellFoop* self)
{
	SwellFoopWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	if (_tmp0_ != NULL) {
		SwellFoopWindow* _tmp1_;
		_tmp1_ = self->priv->window;
		gtk_window_close ((GtkWindow*) _tmp1_);
	}
}

static inline void
swell_foop_help_cb (SwellFoop* self)
{
	SwellFoopWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	gtk_show_uri ((GtkWindow*) _tmp0_, "help:swell-foop", (guint32) GDK_CURRENT_TIME);
}

static inline void
swell_foop_about_cb (SwellFoop* self)
{
	gchar** developers = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gint developers_length1;
	gint _developers_size_;
	gchar** artists = NULL;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gint artists_length1;
	gint _artists_size_;
	gchar** documenters = NULL;
	gchar** _tmp5_;
	gint documenters_length1;
	gint _documenters_size_;
	SwellFoopWindow* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (_ ("Tim Horton"));
	_tmp1_ = g_strdup (_ ("Sophia Yu"));
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	developers = _tmp2_;
	developers_length1 = 2;
	_developers_size_ = developers_length1;
	_tmp3_ = g_strdup (_ ("Tim Horton"));
	_tmp4_ = g_new0 (gchar*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	artists = _tmp4_;
	artists_length1 = 1;
	_artists_size_ = artists_length1;
	_tmp5_ = g_new0 (gchar*, 0 + 1);
	documenters = _tmp5_;
	documenters_length1 = 0;
	_documenters_size_ = documenters_length1;
	_tmp6_ = self->priv->window;
	adw_show_about_dialog ((GtkWidget*) _tmp6_, "application-icon", "org.gnome.SwellFoop", "application-name", SWELL_FOOP_PROGRAM_NAME, "developer-name", _ ("Swell Foop developers"), "version", VERSION, "license-type", GTK_LICENSE_GPL_2_0, "developers", developers, "copyright", _ ("Copyright \xc2\xa9 2009 Tim Horton"), "artists", artists, "documenters", documenters, "translator-credits", _ ("translator-credits"), "website", PACKAGE_URL, NULL);
	documenters = (_vala_array_free (documenters, documenters_length1, (GDestroyNotify) g_free), NULL);
	artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
	developers = (_vala_array_free (developers, developers_length1, (GDestroyNotify) g_free), NULL);
}

static gint
swell_foop_main (gchar** args,
                 gint args_length1)
{
	SwellFoop* app = NULL;
	SwellFoop* _tmp0_;
	gint result;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	g_set_application_name (SWELL_FOOP_PROGRAM_NAME);
	gtk_window_set_default_icon_name ("org.gnome.SwellFoop");
	_tmp0_ = swell_foop_new ();
	app = _tmp0_;
	result = g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
	return result;
}

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

static void
swell_foop_class_init (SwellFoopClass * klass,
                       gpointer klass_data)
{
	swell_foop_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwellFoop_private_offset);
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) swell_foop_real_startup;
	((GApplicationClass *) klass)->handle_local_options = (gint (*) (GApplication*, GVariantDict*)) swell_foop_real_handle_local_options;
	((GApplicationClass *) klass)->shutdown = (void (*) (GApplication*)) swell_foop_real_shutdown;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) swell_foop_real_activate;
	G_OBJECT_CLASS (klass)->finalize = swell_foop_finalize;
}

static void
swell_foop_instance_init (SwellFoop * self,
                          gpointer klass)
{
	self->priv = swell_foop_get_instance_private (self);
}

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->window);
	G_OBJECT_CLASS (swell_foop_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
swell_foop_get_type_once (void)
{
	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 (adw_application_get_type (), "SwellFoop", &g_define_type_info, 0);
	SwellFoop_private_offset = g_type_add_instance_private (swell_foop_type_id, sizeof (SwellFoopPrivate));
	return swell_foop_type_id;
}

GType
swell_foop_get_type (void)
{
	static gsize swell_foop_type_id__once = 0;
	if (g_once_init_enter (&swell_foop_type_id__once)) {
		GType swell_foop_type_id;
		swell_foop_type_id = swell_foop_get_type_once ();
		g_once_init_leave (&swell_foop_type_id__once, swell_foop_type_id);
	}
	return swell_foop_type_id__once;
}

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

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

