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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "libdino.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>

#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_free0(var) (var = (g_free (var), NULL))

#define DINO_UI_TYPE_APPLICATION (dino_ui_application_get_type ())
#define DINO_UI_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_APPLICATION, DinoUiApplication))
#define DINO_UI_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_APPLICATION, DinoUiApplicationClass))
#define DINO_UI_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_APPLICATION))
#define DINO_UI_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_APPLICATION))
#define DINO_UI_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_APPLICATION, DinoUiApplicationClass))

typedef struct _DinoUiApplication DinoUiApplication;
typedef struct _DinoUiApplicationClass DinoUiApplicationClass;
#define _dino_search_path_generator_unref0(var) ((var == NULL) ? NULL : (var = (dino_search_path_generator_unref (var), NULL)))
#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)))

static void dino_main (gchar** args,
                gint args_length1);
VALA_EXTERN GType dino_ui_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiApplication, g_object_unref)
VALA_EXTERN DinoUiApplication* dino_ui_application_new (GError** error);
VALA_EXTERN DinoUiApplication* dino_ui_application_construct (GType object_type,
                                                  GError** error);

static gpointer
_dino_search_path_generator_ref0 (gpointer self)
{
	return self ? dino_search_path_generator_ref (self) : NULL;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
dino_main (gchar** args,
           gint args_length1)
{
	GError* _inner_error0_ = NULL;
	{
		const gchar* _tmp0_ = NULL;
		gchar* exec_path = NULL;
		gchar* _tmp2_;
		DinoSearchPathGenerator* search_path_generator = NULL;
		const gchar* _tmp3_;
		DinoSearchPathGenerator* _tmp4_;
		DinoSearchPathGenerator* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		DinoUiApplication* app = NULL;
		DinoSearchPathGenerator* _tmp8_;
		DinoSearchPathGenerator* _tmp9_;
		DinoUiApplication* _tmp10_ = NULL;
		DinoPluginsLoader* loader = NULL;
		DinoUiApplication* _tmp11_;
		DinoPluginsLoader* _tmp12_;
		DinoPluginsLoader* _tmp13_;
		DinoUiApplication* _tmp14_;
		DinoPluginsLoader* _tmp15_;
		if (args_length1 > 0) {
			const gchar* _tmp1_;
			_tmp1_ = args[0];
			_tmp0_ = _tmp1_;
		} else {
			_tmp0_ = NULL;
		}
		_tmp2_ = g_strdup (_tmp0_);
		exec_path = _tmp2_;
		_tmp3_ = exec_path;
		_tmp4_ = dino_search_path_generator_new (_tmp3_);
		search_path_generator = _tmp4_;
		textdomain (GETTEXT_PACKAGE);
		_tmp5_ = search_path_generator;
		_tmp6_ = dino_search_path_generator_get_locale_path (_tmp5_, GETTEXT_PACKAGE, LOCALE_INSTALL_DIR);
		_tmp7_ = _tmp6_;
		dino_internationalize (GETTEXT_PACKAGE, _tmp7_);
		_g_free0 (_tmp7_);
		gtk_init ();
		_tmp8_ = search_path_generator;
		_tmp9_ = _dino_search_path_generator_ref0 (_tmp8_);
		_tmp10_ = dino_ui_application_new (&_inner_error0_);
		dino_application_set_search_path_generator ((DinoApplication*) _tmp10_, _tmp9_);
		_dino_search_path_generator_unref0 (_tmp9_);
		app = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_dino_search_path_generator_unref0 (search_path_generator);
			_g_free0 (exec_path);
			goto __catch0_g_error;
		}
		_tmp11_ = app;
		_tmp12_ = dino_plugins_loader_new ((DinoApplication*) _tmp11_);
		loader = _tmp12_;
		_tmp13_ = loader;
		dino_plugins_loader_load_all (_tmp13_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (loader);
			_g_object_unref0 (app);
			_dino_search_path_generator_unref0 (search_path_generator);
			_g_free0 (exec_path);
			goto __catch0_g_error;
		}
		_tmp14_ = app;
		g_application_run ((GApplication*) _tmp14_, (gint) args_length1, args);
		_tmp15_ = loader;
		dino_plugins_loader_shutdown (_tmp15_);
		_g_object_unref0 (loader);
		_g_object_unref0 (app);
		_dino_search_path_generator_unref0 (search_path_generator);
		_g_free0 (exec_path);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		_tmp18_ = string_to_string (_tmp17_);
		_tmp19_ = g_strconcat ("Fatal error: ", _tmp18_, NULL);
		_tmp20_ = _tmp19_;
		g_warning ("main.vala:25: %s", _tmp20_);
		_g_free0 (_tmp20_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != 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;
	}
}

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

