/* Application.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from Application.vala, do not modify */

/*
* Copyright 2016-2021 elementary, Inc. (https://elementary.io)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <granite-7.h>
#include <adwaita.h>
#include <glib/gi18n-lib.h>
#include <locale.h>

#define GETTEXT_PACKAGE "io.elementary.capnet-assist"
#define LOCALEDIR "/usr/share/locale"
#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 CAPTIVE_TYPE_APPLICATION (captive_application_get_type ())
#define CAPTIVE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAPTIVE_TYPE_APPLICATION, CaptiveApplication))
#define CAPTIVE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAPTIVE_TYPE_APPLICATION, CaptiveApplicationClass))
#define CAPTIVE_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAPTIVE_TYPE_APPLICATION))
#define CAPTIVE_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAPTIVE_TYPE_APPLICATION))
#define CAPTIVE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAPTIVE_TYPE_APPLICATION, CaptiveApplicationClass))

typedef struct _CaptiveApplication CaptiveApplication;
typedef struct _CaptiveApplicationClass CaptiveApplicationClass;
typedef struct _CaptiveApplicationPrivate CaptiveApplicationPrivate;
enum  {
	CAPTIVE_APPLICATION_0_PROPERTY,
	CAPTIVE_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* captive_application_properties[CAPTIVE_APPLICATION_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define CAPTIVE_TYPE_MAIN_WINDOW (captive_main_window_get_type ())
#define CAPTIVE_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAPTIVE_TYPE_MAIN_WINDOW, CaptiveMainWindow))
#define CAPTIVE_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAPTIVE_TYPE_MAIN_WINDOW, CaptiveMainWindowClass))
#define CAPTIVE_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAPTIVE_TYPE_MAIN_WINDOW))
#define CAPTIVE_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAPTIVE_TYPE_MAIN_WINDOW))
#define CAPTIVE_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAPTIVE_TYPE_MAIN_WINDOW, CaptiveMainWindowClass))

typedef struct _CaptiveMainWindow CaptiveMainWindow;
typedef struct _CaptiveMainWindowClass CaptiveMainWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _CaptiveApplication {
	GtkApplication parent_instance;
	CaptiveApplicationPrivate * priv;
};

struct _CaptiveApplicationClass {
	GtkApplicationClass parent_class;
};

struct _CaptiveApplicationPrivate {
	gchar* debug_url;
};

struct _Block1Data {
	int _ref_count_;
	CaptiveApplication* self;
	GraniteSettings* granite_settings;
	GtkSettings* gtk_settings;
};

static gint CaptiveApplication_private_offset;
static gpointer captive_application_parent_class = NULL;
VALA_EXTERN GSettings* captive_application_settings;
GSettings* captive_application_settings = NULL;

VALA_EXTERN GType captive_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CaptiveApplication, g_object_unref)
VALA_EXTERN CaptiveApplication* captive_application_new (void);
VALA_EXTERN CaptiveApplication* captive_application_construct (GType object_type);
static void captive_application_real_activate (GApplication* base);
VALA_EXTERN GType captive_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CaptiveMainWindow, g_object_unref)
VALA_EXTERN CaptiveMainWindow* captive_main_window_new (GtkApplication* app);
VALA_EXTERN CaptiveMainWindow* captive_main_window_construct (GType object_type,
                                                  GtkApplication* app);
VALA_EXTERN void captive_main_window_start (CaptiveMainWindow* self,
                                const gchar* browser_url);
static void captive_application_real_startup (GApplication* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda13_ (Block1Data* _data1_);
static void ___lambda13__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda14_ (CaptiveApplication* self);
static void ___lambda14__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static gint captive_application_real_command_line (GApplication* base,
                                            GApplicationCommandLine* command_line);
static gint captive_application_main (gchar** args,
                               gint args_length1);
static GObject * captive_application_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static void captive_application_finalize (GObject * obj);
static GType captive_application_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 inline gpointer
captive_application_get_instance_private (CaptiveApplication* self)
{
	return G_STRUCT_MEMBER_P (self, CaptiveApplication_private_offset);
}

CaptiveApplication*
captive_application_construct (GType object_type)
{
	CaptiveApplication * self = NULL;
	self = (CaptiveApplication*) g_object_new (object_type, "application-id", "io.elementary.capnet-assist", "flags", G_APPLICATION_HANDLES_COMMAND_LINE, NULL);
	return self;
}

CaptiveApplication*
captive_application_new (void)
{
	return captive_application_construct (CAPTIVE_TYPE_APPLICATION);
}

static void
captive_application_real_activate (GApplication* base)
{
	CaptiveApplication * self;
	GSettings* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	self = (CaptiveApplication*) base;
	_tmp0_ = captive_application_settings;
	if (!g_settings_get_boolean (_tmp0_, "enabled")) {
		g_application_quit ((GApplication*) self);
		return;
	}
	_tmp1_ = g_application_get_is_busy ((GApplication*) self);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		CaptiveMainWindow* main_window = NULL;
		CaptiveMainWindow* _tmp3_;
		GSettings* _tmp4_;
		CaptiveMainWindow* _tmp5_;
		GSettings* _tmp6_;
		CaptiveMainWindow* _tmp7_;
		GSettings* _tmp8_;
		GSettings* _tmp10_;
		CaptiveMainWindow* _tmp11_;
		CaptiveMainWindow* _tmp12_;
		const gchar* _tmp13_;
		g_application_mark_busy ((GApplication*) self);
		_tmp3_ = captive_main_window_new ((GtkApplication*) self);
		g_object_ref_sink (_tmp3_);
		main_window = _tmp3_;
		_tmp4_ = captive_application_settings;
		_tmp5_ = main_window;
		g_settings_bind (_tmp4_, "window-height", (GObject*) _tmp5_, "default-height", G_SETTINGS_BIND_DEFAULT);
		_tmp6_ = captive_application_settings;
		_tmp7_ = main_window;
		g_settings_bind (_tmp6_, "window-width", (GObject*) _tmp7_, "default-width", G_SETTINGS_BIND_DEFAULT);
		_tmp8_ = captive_application_settings;
		if (g_settings_get_boolean (_tmp8_, "is-maximized")) {
			CaptiveMainWindow* _tmp9_;
			_tmp9_ = main_window;
			gtk_window_maximize ((GtkWindow*) _tmp9_);
		}
		_tmp10_ = captive_application_settings;
		_tmp11_ = main_window;
		g_settings_bind (_tmp10_, "is-maximized", (GObject*) _tmp11_, "maximized", G_SETTINGS_BIND_SET);
		_tmp12_ = main_window;
		_tmp13_ = self->priv->debug_url;
		captive_main_window_start (_tmp12_, _tmp13_);
		_g_object_unref0 (main_window);
	}
}

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

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

static void
__lambda13_ (Block1Data* _data1_)
{
	CaptiveApplication* self;
	GraniteSettingsColorScheme _tmp0_;
	GraniteSettingsColorScheme _tmp1_;
	self = _data1_->self;
	_tmp0_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp1_ = _tmp0_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp1_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
}

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

static void
__lambda14_ (CaptiveApplication* self)
{
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		GtkWindow* _tmp2_;
		GtkWindow* _tmp3_;
		_tmp2_ = gtk_application_get_active_window ((GtkApplication*) self);
		_tmp3_ = _tmp2_;
		gtk_window_destroy (_tmp3_);
	}
}

static void
___lambda14__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda14_ ((CaptiveApplication*) self);
}

static void
captive_application_real_startup (GApplication* base)
{
	CaptiveApplication * self;
	Block1Data* _data1_;
	GraniteSettings* _tmp0_;
	GraniteSettings* _tmp1_;
	GtkSettings* _tmp2_;
	GtkSettings* _tmp3_;
	GraniteSettingsColorScheme _tmp4_;
	GraniteSettingsColorScheme _tmp5_;
	GSimpleAction* quit_action = NULL;
	GSimpleAction* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	self = (CaptiveApplication*) base;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	G_APPLICATION_CLASS (captive_application_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	granite_init ();
	adw_init ();
	_tmp0_ = granite_settings_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_data1_->granite_settings = _tmp1_;
	_tmp2_ = gtk_settings_get_default ();
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_data1_->gtk_settings = _tmp3_;
	_tmp4_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp5_ = _tmp4_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp5_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
	g_signal_connect_data ((GObject*) _data1_->granite_settings, "notify::prefers-color-scheme", (GCallback) ___lambda13__g_object_notify, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp6_ = g_simple_action_new ("quit", NULL);
	quit_action = _tmp6_;
	g_signal_connect_object (quit_action, "activate", (GCallback) ___lambda14__g_simple_action_activate, self, 0);
	g_action_map_add_action ((GActionMap*) self, (GAction*) quit_action);
	_tmp7_ = g_strdup ("<Control>q");
	_tmp8_ = g_new0 (gchar*, 1 + 1);
	_tmp8_[0] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp9_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (quit_action);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static gint
captive_application_real_command_line (GApplication* base,
                                       GApplicationCommandLine* command_line)
{
	CaptiveApplication * self;
	GOptionEntry* options = NULL;
	GOptionEntry* _tmp0_;
	gint options_length1;
	gint _options_size_;
	GOptionEntry* _tmp1_;
	gint _tmp1__length1;
	GOptionEntry _tmp2_ = {0};
	gchar** args = NULL;
	gint _tmp3_ = 0;
	gchar** _tmp4_;
	gint args_length1;
	gint _args_size_;
	GError* _inner_error0_ = NULL;
	gint result;
	self = (CaptiveApplication*) base;
	g_return_val_if_fail (command_line != NULL, 0);
	_tmp0_ = g_new0 (GOptionEntry, 1);
	options = _tmp0_;
	options_length1 = 1;
	_options_size_ = options_length1;
	_tmp1_ = options;
	_tmp1__length1 = options_length1;
	_tmp2_.long_name = "url";
	_tmp2_.short_name = 'u';
	_tmp2_.flags = (gint) 0;
	_tmp2_.arg = G_OPTION_ARG_STRING;
	_tmp2_.arg_data = &self->priv->debug_url;
	_tmp2_.description = _ ("Load this address in the browser window");
	_tmp2_.arg_description = _ ("URL");
	_tmp1_[0] = _tmp2_;
	_tmp4_ = g_application_command_line_get_arguments (command_line, &_tmp3_);
	args = _tmp4_;
	args_length1 = _tmp3_;
	_args_size_ = args_length1;
	{
		GOptionContext* opt_context = NULL;
		GOptionContext* _tmp5_;
		GOptionContext* _tmp6_;
		GOptionContext* _tmp7_;
		GOptionEntry* _tmp8_;
		gint _tmp8__length1;
		gchar** tmp = NULL;
		gchar** _tmp9_;
		gint _tmp9__length1;
		gint tmp_length1;
		gint _tmp_size_;
		GOptionContext* _tmp10_;
		_tmp5_ = g_option_context_new ("- OptionContext example");
		opt_context = _tmp5_;
		_tmp6_ = opt_context;
		g_option_context_set_help_enabled (_tmp6_, TRUE);
		_tmp7_ = opt_context;
		_tmp8_ = options;
		_tmp8__length1 = options_length1;
		g_option_context_add_main_entries (_tmp7_, _tmp8_, NULL);
		_tmp9_ = args;
		_tmp9__length1 = args_length1;
		tmp = _tmp9_;
		tmp_length1 = _tmp9__length1;
		_tmp_size_ = tmp_length1;
		_tmp10_ = opt_context;
		g_option_context_parse (_tmp10_, (gint*) (&tmp_length1), &tmp, &_inner_error0_);
		_tmp_size_ = tmp_length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp11_ = -1;
			_g_option_context_free0 (opt_context);
			if (_inner_error0_->domain == G_OPTION_ERROR) {
				goto __catch0_g_option_error;
			}
			args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
			options = (g_free (options), NULL);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp11_;
		}
		_g_option_context_free0 (opt_context);
	}
	goto __finally0;
	__catch0_g_option_error:
	{
		GError* e = NULL;
		GError* _tmp12_;
		const gchar* _tmp13_;
		gchar** _tmp14_;
		gint _tmp14__length1;
		const gchar* _tmp15_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp12_ = e;
		_tmp13_ = _tmp12_->message;
		g_application_command_line_print (command_line, "error: %s\n", _tmp13_);
		_tmp14_ = args;
		_tmp14__length1 = args_length1;
		_tmp15_ = _tmp14_[0];
		g_application_command_line_print (command_line, "Run '%s --help' to see a full list of available command line options.\n", _tmp15_);
		result = -1;
		_g_error_free0 (e);
		args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
		options = (g_free (options), NULL);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp16_ = -1;
		args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
		options = (g_free (options), NULL);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp16_;
	}
	g_application_activate ((GApplication*) self);
	result = 0;
	args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
	options = (g_free (options), NULL);
	return result;
}

static gint
captive_application_main (gchar** args,
                          gint args_length1)
{
	CaptiveApplication* application = NULL;
	CaptiveApplication* _tmp0_;
	gint result;
	g_set_application_name ("captive-login");
	g_set_prgname ("captive-login");
	_tmp0_ = captive_application_new ();
	application = _tmp0_;
	result = g_application_run ((GApplication*) application, (gint) args_length1, args);
	_g_object_unref0 (application);
	return result;
}

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

static GObject *
captive_application_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CaptiveApplication * self;
	parent_class = G_OBJECT_CLASS (captive_application_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAPTIVE_TYPE_APPLICATION, CaptiveApplication);
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	return obj;
}

static void
captive_application_class_init (CaptiveApplicationClass * klass,
                                gpointer klass_data)
{
	GSettings* _tmp0_;
	captive_application_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CaptiveApplication_private_offset);
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) captive_application_real_activate;
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) captive_application_real_startup;
	((GApplicationClass *) klass)->command_line = (gint (*) (GApplication*, GApplicationCommandLine*)) captive_application_real_command_line;
	G_OBJECT_CLASS (klass)->constructor = captive_application_constructor;
	G_OBJECT_CLASS (klass)->finalize = captive_application_finalize;
	_tmp0_ = g_settings_new ("io.elementary.desktop.capnet-assist");
	_g_object_unref0 (captive_application_settings);
	captive_application_settings = _tmp0_;
}

static void
captive_application_instance_init (CaptiveApplication * self,
                                   gpointer klass)
{
	self->priv = captive_application_get_instance_private (self);
	self->priv->debug_url = NULL;
}

static void
captive_application_finalize (GObject * obj)
{
	CaptiveApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAPTIVE_TYPE_APPLICATION, CaptiveApplication);
	_g_free0 (self->priv->debug_url);
	G_OBJECT_CLASS (captive_application_parent_class)->finalize (obj);
}

static GType
captive_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CaptiveApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) captive_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaptiveApplication), 0, (GInstanceInitFunc) captive_application_instance_init, NULL };
	GType captive_application_type_id;
	captive_application_type_id = g_type_register_static (gtk_application_get_type (), "CaptiveApplication", &g_define_type_info, 0);
	CaptiveApplication_private_offset = g_type_add_instance_private (captive_application_type_id, sizeof (CaptiveApplicationPrivate));
	return captive_application_type_id;
}

GType
captive_application_get_type (void)
{
	static volatile gsize captive_application_type_id__once = 0;
	if (g_once_init_enter (&captive_application_type_id__once)) {
		GType captive_application_type_id;
		captive_application_type_id = captive_application_get_type_once ();
		g_once_init_leave (&captive_application_type_id__once, captive_application_type_id);
	}
	return captive_application_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);
}

