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

/*
 * Copyright 2018 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.
 *
 * Authors: Corentin Noël <corentin@elementary.io>
 */

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

#define CONSTANTS_GETTEXT_PACKAGE "io.elementary.greeter"
#define CONSTANTS_LOCALE_DIR "/usr/share/locale"
#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 GREETER_TYPE_SETTINGS_DAEMON (greeter_settings_daemon_get_type ())
#define GREETER_SETTINGS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_SETTINGS_DAEMON, GreeterSettingsDaemon))
#define GREETER_SETTINGS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_SETTINGS_DAEMON, GreeterSettingsDaemonClass))
#define GREETER_IS_SETTINGS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_SETTINGS_DAEMON))
#define GREETER_IS_SETTINGS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_SETTINGS_DAEMON))
#define GREETER_SETTINGS_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_SETTINGS_DAEMON, GreeterSettingsDaemonClass))

typedef struct _GreeterSettingsDaemon GreeterSettingsDaemon;
typedef struct _GreeterSettingsDaemonClass GreeterSettingsDaemonClass;

#define GREETER_TYPE_SUBPROCESS_SUPERVISOR (greeter_subprocess_supervisor_get_type ())
#define GREETER_SUBPROCESS_SUPERVISOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_SUBPROCESS_SUPERVISOR, GreeterSubprocessSupervisor))
#define GREETER_SUBPROCESS_SUPERVISOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_SUBPROCESS_SUPERVISOR, GreeterSubprocessSupervisorClass))
#define GREETER_IS_SUBPROCESS_SUPERVISOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_SUBPROCESS_SUPERVISOR))
#define GREETER_IS_SUBPROCESS_SUPERVISOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_SUBPROCESS_SUPERVISOR))
#define GREETER_SUBPROCESS_SUPERVISOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_SUBPROCESS_SUPERVISOR, GreeterSubprocessSupervisorClass))

typedef struct _GreeterSubprocessSupervisor GreeterSubprocessSupervisor;
typedef struct _GreeterSubprocessSupervisorClass GreeterSubprocessSupervisorClass;
#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 GREETER_TYPE_MAIN_WINDOW (greeter_main_window_get_type ())
#define GREETER_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_MAIN_WINDOW, GreeterMainWindow))
#define GREETER_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_MAIN_WINDOW, GreeterMainWindowClass))
#define GREETER_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_MAIN_WINDOW))
#define GREETER_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_MAIN_WINDOW))
#define GREETER_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_MAIN_WINDOW, GreeterMainWindowClass))

typedef struct _GreeterMainWindow GreeterMainWindow;
typedef struct _GreeterMainWindowClass GreeterMainWindowClass;

static gint _vala_main (gchar** args,
                 gint args_length1);
VALA_EXTERN GType greeter_settings_daemon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterSettingsDaemon, g_object_unref)
VALA_EXTERN GreeterSettingsDaemon* greeter_settings_daemon_new (void);
VALA_EXTERN GreeterSettingsDaemon* greeter_settings_daemon_construct (GType object_type);
VALA_EXTERN void greeter_settings_daemon_start (GreeterSettingsDaemon* self);
VALA_EXTERN GType greeter_subprocess_supervisor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterSubprocessSupervisor, g_object_unref)
VALA_EXTERN GreeterSubprocessSupervisor* greeter_subprocess_supervisor_new (gchar** exec,
                                                                gint exec_length1,
                                                                GError** error);
VALA_EXTERN GreeterSubprocessSupervisor* greeter_subprocess_supervisor_construct (GType object_type,
                                                                      gchar** exec,
                                                                      gint exec_length1,
                                                                      GError** error);
VALA_EXTERN GType greeter_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterMainWindow, g_object_unref)
VALA_EXTERN GreeterMainWindow* greeter_main_window_new (void);
VALA_EXTERN GreeterMainWindow* greeter_main_window_construct (GType object_type);
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 gint
_vala_main (gchar** args,
            gint args_length1)
{
	GreeterSettingsDaemon* settings_daemon = NULL;
	GreeterSettingsDaemon* _tmp0_;
	GreeterSubprocessSupervisor* compositor = NULL;
	GreeterSubprocessSupervisor* wingpanel = NULL;
	GreeterMainWindow* window = NULL;
	GreeterMainWindow* _tmp11_;
	GError* _inner_error0_ = NULL;
	gint result;
	setlocale (LC_ALL, "");
	bind_textdomain_codeset (CONSTANTS_GETTEXT_PACKAGE, "UTF-8");
	textdomain (CONSTANTS_GETTEXT_PACKAGE);
	bindtextdomain (CONSTANTS_GETTEXT_PACKAGE, CONSTANTS_LOCALE_DIR);
	g_setenv ("XDG_CURRENT_DESKTOP", "Pantheon", TRUE);
	_tmp0_ = greeter_settings_daemon_new ();
	settings_daemon = _tmp0_;
	greeter_settings_daemon_start (settings_daemon);
	gtk_init ((gint*) (&args_length1), &args);
	{
		GreeterSubprocessSupervisor* _tmp1_ = NULL;
		gchar* _tmp2_;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gint _tmp4__length1;
		GreeterSubprocessSupervisor* _tmp5_;
		GreeterSubprocessSupervisor* _tmp6_;
		GreeterSubprocessSupervisor* _tmp7_;
		_tmp2_ = g_strdup ("io.elementary.greeter-compositor");
		_tmp3_ = g_new0 (gchar*, 1 + 1);
		_tmp3_[0] = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp4__length1 = 1;
		_tmp5_ = greeter_subprocess_supervisor_new (_tmp4_, 1, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
		_tmp1_ = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp7_ = _tmp1_;
		_tmp1_ = NULL;
		_g_object_unref0 (compositor);
		compositor = _tmp7_;
		_g_object_unref0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		g_critical ("Application.vala:43: %s", _tmp9_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp10_ = -1;
		_g_object_unref0 (wingpanel);
		_g_object_unref0 (compositor);
		_g_object_unref0 (settings_daemon);
		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 _tmp10_;
	}
	_tmp11_ = greeter_main_window_new ();
	g_object_ref_sink (_tmp11_);
	window = _tmp11_;
	gtk_widget_show_all ((GtkWidget*) window);
	{
		GreeterSubprocessSupervisor* _tmp12_ = NULL;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar** _tmp15_;
		gchar** _tmp16_;
		gint _tmp16__length1;
		GreeterSubprocessSupervisor* _tmp17_;
		GreeterSubprocessSupervisor* _tmp18_;
		GreeterSubprocessSupervisor* _tmp19_;
		_tmp13_ = g_strdup ("io.elementary.wingpanel");
		_tmp14_ = g_strdup ("-g");
		_tmp15_ = g_new0 (gchar*, 2 + 1);
		_tmp15_[0] = _tmp13_;
		_tmp15_[1] = _tmp14_;
		_tmp16_ = _tmp15_;
		_tmp16__length1 = 2;
		_tmp17_ = greeter_subprocess_supervisor_new (_tmp16_, 2, &_inner_error0_);
		_tmp18_ = _tmp17_;
		_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
		_tmp12_ = _tmp18_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp19_ = _tmp12_;
		_tmp12_ = NULL;
		_g_object_unref0 (wingpanel);
		wingpanel = _tmp19_;
		_g_object_unref0 (_tmp12_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp20_;
		const gchar* _tmp21_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp20_ = e;
		_tmp21_ = _tmp20_->message;
		g_critical ("Application.vala:52: %s", _tmp21_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp22_ = -1;
		_g_object_unref0 (window);
		_g_object_unref0 (wingpanel);
		_g_object_unref0 (compositor);
		_g_object_unref0 (settings_daemon);
		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 _tmp22_;
	}
	gtk_main ();
	result = 0;
	_g_object_unref0 (window);
	_g_object_unref0 (wingpanel);
	_g_object_unref0 (compositor);
	_g_object_unref0 (settings_daemon);
	return result;
}

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

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);
}

