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

/*
 * This file is part of gitg
 *
 * Copyright (C) 2012 - Jesse van den Kieboom
 *
 * gitg 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.
 *
 * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include "libgitg.h"
#include <glib.h>
#include <libgit2-glib/ggit.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.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

#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)))

VALA_EXTERN gboolean gitg_gitg_inited;
gboolean gitg_gitg_inited = FALSE;
VALA_EXTERN GError* gitg_gitg_initerr;
GError* gitg_gitg_initerr = NULL;

GQuark
gitg_init_error_quark (void)
{
	return g_quark_from_static_string ("gitg-init-error-quark");
}

 G_GNUC_NO_INLINE static GType
gitg_init_error_get_type_once (void)
{
	static const GEnumValue values[] = {{GITG_INIT_ERROR_THREADS_UNSAFE, "GITG_INIT_ERROR_THREADS_UNSAFE", "threads-unsafe"}, {0, NULL, NULL}};
	GType gitg_init_error_type_id;
	gitg_init_error_type_id = g_enum_register_static ("GitgInitError", values);
	return gitg_init_error_type_id;
}

GType
gitg_init_error_get_type (void)
{
	static gsize gitg_init_error_type_id__once = 0;
	if (g_once_init_enter (&gitg_init_error_type_id__once)) {
		GType gitg_init_error_type_id;
		gitg_init_error_type_id = gitg_init_error_get_type_once ();
		g_once_init_leave (&gitg_init_error_type_id__once, gitg_init_error_type_id);
	}
	return gitg_init_error_type_id__once;
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

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

void
gitg_init (GError** error)
{
	GgitObjectFactory* factory = NULL;
	GgitObjectFactory* _tmp6_;
	GgitObjectFactory* _tmp7_;
	GgitObjectFactory* _tmp8_;
	GgitObjectFactory* _tmp9_;
	GgitObjectFactory* _tmp10_;
	GgitObjectFactory* _tmp11_;
	GgitObjectFactory* _tmp12_;
	GtkCssProvider* provider = NULL;
	GtkCssProvider* _tmp13_;
	GtkCssProvider* _tmp14_;
	GError* _inner_error0_ = NULL;
	if (gitg_gitg_inited) {
		GError* _tmp0_;
		_tmp0_ = gitg_gitg_initerr;
		if (_tmp0_ != NULL) {
			GError* _tmp1_;
			GError* _tmp2_;
			_tmp1_ = gitg_gitg_initerr;
			_tmp2_ = _g_error_copy0 (_tmp1_);
			_inner_error0_ = _tmp2_;
			g_propagate_error (error, _inner_error0_);
			return;
		}
		return;
	}
	gitg_gitg_inited = TRUE;
	if ((ggit_get_features () & GGIT_FEATURE_THREADS) == 0) {
		GError* _tmp3_;
		GError* _tmp4_;
		GError* _tmp5_;
		_tmp3_ = g_error_new_literal (GITG_INIT_ERROR, GITG_INIT_ERROR_THREADS_UNSAFE, "no thread support");
		_g_error_free0 (gitg_gitg_initerr);
		gitg_gitg_initerr = _tmp3_;
		g_warning ("gitg-init.vala:49: libgit2 must be built with threading support in ord" \
"er to run gitg");
		_tmp4_ = gitg_gitg_initerr;
		_tmp5_ = _g_error_copy0 (_tmp4_);
		_inner_error0_ = _tmp5_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	ggit_init ();
	_tmp6_ = ggit_object_factory_get_default ();
	_tmp7_ = _g_object_ref0 (_tmp6_);
	factory = _tmp7_;
	_tmp8_ = factory;
	ggit_object_factory_register (_tmp8_, ggit_repository_get_type (), GITG_TYPE_REPOSITORY);
	_tmp9_ = factory;
	ggit_object_factory_register (_tmp9_, ggit_ref_get_type (), GITG_TYPE_REF_BASE);
	_tmp10_ = factory;
	ggit_object_factory_register (_tmp10_, ggit_branch_get_type (), GITG_TYPE_BRANCH_BASE);
	_tmp11_ = factory;
	ggit_object_factory_register (_tmp11_, ggit_commit_get_type (), GITG_TYPE_COMMIT);
	_tmp12_ = factory;
	ggit_object_factory_register (_tmp12_, ggit_remote_get_type (), GITG_TYPE_REMOTE);
	_tmp13_ = gitg_resource_load_css ("libgitg-style.css");
	provider = _tmp13_;
	_tmp14_ = provider;
	if (_tmp14_ != NULL) {
		GdkScreen* _tmp15_;
		GtkCssProvider* _tmp16_;
		_tmp15_ = gdk_screen_get_default ();
		_tmp16_ = provider;
		gtk_style_context_add_provider_for_screen (_tmp15_, (GtkStyleProvider*) _tmp16_, (guint) 600);
	}
	_g_object_unref0 (provider);
	_g_object_unref0 (factory);
}

