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

/*
 * Copyright 2012 Tom Beckmann, Rico Tzschichholz
 * Copyright 2018 elementary LLC. (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 3 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, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <stdio.h>
#include <meta/main.h>
#include <meta/meta-context.h>
#include <stdlib.h>
#include <glib-object.h>
#include <meta/meta-plugin.h>

#define CONSTANTS_VERSION "8.1.1"
#define CONSTANTS_GETTEXT_PACKAGE "io.elementary.greeter"
#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 _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER (greeter_compositor_window_manager_get_type ())
#define GREETER_COMPOSITOR_WINDOW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManager))
#define GREETER_COMPOSITOR_WINDOW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManagerClass))
#define GREETER_COMPOSITOR_IS_WINDOW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER))
#define GREETER_COMPOSITOR_IS_WINDOW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER))
#define GREETER_COMPOSITOR_WINDOW_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManagerClass))

typedef struct _GreeterCompositorWindowManager GreeterCompositorWindowManager;
typedef struct _GreeterCompositorWindowManagerClass GreeterCompositorWindowManagerClass;

#define GREETER_COMPOSITOR_TYPE_UTILS (greeter_compositor_utils_get_type ())
#define GREETER_COMPOSITOR_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtils))
#define GREETER_COMPOSITOR_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtilsClass))
#define GREETER_COMPOSITOR_IS_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_UTILS))
#define GREETER_COMPOSITOR_IS_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_UTILS))
#define GREETER_COMPOSITOR_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtilsClass))

typedef struct _GreeterCompositorUtils GreeterCompositorUtils;
typedef struct _GreeterCompositorUtilsClass GreeterCompositorUtilsClass;
#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL)))

VALA_EXTERN void greeter_compositor_print_version (void);
static gint greeter_compositor_main (gchar** args,
                              gint args_length1);
VALA_EXTERN GType greeter_compositor_window_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorWindowManager, g_object_unref)
VALA_EXTERN gpointer greeter_compositor_utils_ref (gpointer instance);
VALA_EXTERN void greeter_compositor_utils_unref (gpointer instance);
VALA_EXTERN GParamSpec* greeter_compositor_param_spec_utils (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void greeter_compositor_value_set_utils (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void greeter_compositor_value_take_utils (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer greeter_compositor_value_get_utils (const GValue* value);
VALA_EXTERN GType greeter_compositor_utils_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorUtils, greeter_compositor_utils_unref)

const GOptionEntry GREETER_COMPOSITOR_OPTIONS[2] = {{"version", (gchar) 0, (gint) G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (void*) greeter_compositor_print_version, "Print version", NULL}, {NULL}};

void
greeter_compositor_print_version (void)
{
	FILE* _tmp0_;
	_tmp0_ = stdout;
	fprintf (_tmp0_, "GreeterCompositor %s\n", CONSTANTS_VERSION);
	meta_exit (META_EXIT_SUCCESS);
}

static gint
greeter_compositor_main (gchar** args,
                         gint args_length1)
{
	const gchar* _tmp0_;
	MetaContext* ctx = NULL;
	MetaContext* _tmp1_;
	MetaContext* _tmp2_;
	MetaContext* _tmp8_;
	GTypeClass* _tmp14_;
	GTypeClass* _tmp15_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = g_getenv ("DESKTOP_SESSION");
	if (g_strcmp0 (_tmp0_, "installer") != 0) {
		g_setenv ("XDG_CURRENT_DESKTOP", "Pantheon", TRUE);
	}
	_tmp1_ = meta_create_context ("Mutter(GreeterCompositor)");
	ctx = _tmp1_;
	_tmp2_ = ctx;
	meta_context_add_option_entries (_tmp2_, GREETER_COMPOSITOR_OPTIONS, CONSTANTS_GETTEXT_PACKAGE);
	{
		MetaContext* _tmp3_;
		_tmp3_ = ctx;
		meta_context_configure (_tmp3_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		FILE* _tmp4_;
		GError* _tmp5_;
		const gchar* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = stderr;
		_tmp5_ = e;
		_tmp6_ = _tmp5_->message;
		fprintf (_tmp4_, "Error initializing: %s\n", _tmp6_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp7_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp7_;
	}
	_tmp8_ = ctx;
	meta_context_set_plugin_gtype (_tmp8_, GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER);
	{
		MetaContext* _tmp9_;
		_tmp9_ = ctx;
		meta_context_setup (_tmp9_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		FILE* _tmp10_;
		GError* _tmp11_;
		const gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = stderr;
		_tmp11_ = e;
		_tmp12_ = _tmp11_->message;
		fprintf (_tmp10_, "Failed to setup: %s\n", _tmp12_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp13_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp13_;
	}
	_tmp14_ = g_type_class_ref (GREETER_COMPOSITOR_TYPE_UTILS);
	_tmp15_ = _tmp14_;
	_g_type_class_unref0 (_tmp15_);
	{
		MetaContext* _tmp16_;
		_tmp16_ = ctx;
		meta_context_start (_tmp16_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* e = NULL;
		FILE* _tmp17_;
		GError* _tmp18_;
		const gchar* _tmp19_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp17_ = stderr;
		_tmp18_ = e;
		_tmp19_ = _tmp18_->message;
		fprintf (_tmp17_, "Failed to start: %s\n", _tmp19_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp20_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp20_;
	}
	{
		MetaContext* _tmp21_;
		_tmp21_ = ctx;
		meta_context_run_main_loop (_tmp21_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* e = NULL;
		FILE* _tmp22_;
		GError* _tmp23_;
		const gchar* _tmp24_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp22_ = stderr;
		_tmp23_ = e;
		_tmp24_ = _tmp23_->message;
		fprintf (_tmp22_, "Greeter Compositor terminated with a failure: %s\n", _tmp24_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally3:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp25_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp25_;
	}
	result = EXIT_SUCCESS;
	_g_object_unref0 (ctx);
	return result;
}

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

