/* gitg-resource.c generated by valac 0.34.0.108-f56ac, the Vala compiler
 * generated from gitg-resource.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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gobject/gvaluecollector.h>


#define GITG_TYPE_RESOURCE (gitg_resource_get_type ())
#define GITG_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_RESOURCE, GitgResource))
#define GITG_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_RESOURCE, GitgResourceClass))
#define GITG_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_RESOURCE))
#define GITG_IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_RESOURCE))
#define GITG_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_RESOURCE, GitgResourceClass))

typedef struct _GitgResource GitgResource;
typedef struct _GitgResourceClass GitgResourceClass;
typedef struct _GitgResourcePrivate GitgResourcePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#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)))
typedef struct _GitgParamSpecResource GitgParamSpecResource;

struct _GitgResource {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GitgResourcePrivate * priv;
};

struct _GitgResourceClass {
	GTypeClass parent_class;
	void (*finalize) (GitgResource *self);
};

struct _GitgParamSpecResource {
	GParamSpec parent_instance;
};


static gpointer gitg_resource_parent_class = NULL;

gpointer gitg_resource_ref (gpointer instance);
void gitg_resource_unref (gpointer instance);
GParamSpec* gitg_param_spec_resource (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gitg_value_set_resource (GValue* value, gpointer v_object);
void gitg_value_take_resource (GValue* value, gpointer v_object);
gpointer gitg_value_get_resource (const GValue* value);
GType gitg_resource_get_type (void) G_GNUC_CONST;
enum  {
	GITG_RESOURCE_DUMMY_PROPERTY
};
GtkCssProvider* gitg_resource_load_css (const gchar* id);
GitgResource* gitg_resource_new (void);
GitgResource* gitg_resource_construct (GType object_type);
static void gitg_resource_finalize (GitgResource * obj);


GtkCssProvider* gitg_resource_load_css (const gchar* id) {
	GtkCssProvider* result = NULL;
	GtkCssProvider* provider = NULL;
	GtkCssProvider* _tmp0_ = NULL;
	GFile* f = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	GFile* _tmp5_ = NULL;
	GError * _inner_error_ = NULL;
#line 22 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_return_val_if_fail (id != NULL, NULL);
#line 24 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp0_ = gtk_css_provider_new ();
#line 24 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	provider = _tmp0_;
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp1_ = id;
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp2_ = g_strconcat ("resource:///org/gnome/gitg/ui/", _tmp1_, NULL);
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp3_ = _tmp2_;
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp4_ = g_file_new_for_uri (_tmp3_);
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_tmp5_ = _tmp4_;
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_g_free0 (_tmp3_);
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	f = _tmp5_;
#line 113 "gitg-resource.c"
	{
		GtkCssProvider* _tmp6_ = NULL;
		GFile* _tmp7_ = NULL;
#line 29 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_tmp6_ = provider;
#line 29 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_tmp7_ = f;
#line 29 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		gtk_css_provider_load_from_file (_tmp6_, _tmp7_, &_inner_error_);
#line 29 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 125 "gitg-resource.c"
			goto __catch79_g_error;
		}
	}
	goto __finally79;
	__catch79_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		e = _inner_error_;
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_inner_error_ = NULL;
#line 33 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_tmp8_ = e;
#line 33 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_tmp9_ = _tmp8_->message;
#line 33 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_warning ("gitg-resource.vala:33: Error while loading resource: %s", _tmp9_);
#line 34 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		result = NULL;
#line 34 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_g_error_free0 (e);
#line 34 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_g_object_unref0 (f);
#line 34 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_g_object_unref0 (provider);
#line 34 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		return result;
#line 155 "gitg-resource.c"
	}
	__finally79:
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_g_object_unref0 (f);
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		_g_object_unref0 (provider);
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_clear_error (&_inner_error_);
#line 27 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		return NULL;
#line 170 "gitg-resource.c"
	}
#line 37 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	result = provider;
#line 37 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	_g_object_unref0 (f);
#line 37 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return result;
#line 178 "gitg-resource.c"
}


GitgResource* gitg_resource_construct (GType object_type) {
	GitgResource* self = NULL;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	self = (GitgResource*) g_type_create_instance (object_type);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return self;
#line 188 "gitg-resource.c"
}


GitgResource* gitg_resource_new (void) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return gitg_resource_construct (GITG_TYPE_RESOURCE);
#line 195 "gitg-resource.c"
}


static void gitg_value_resource_init (GValue* value) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	value->data[0].v_pointer = NULL;
#line 202 "gitg-resource.c"
}


static void gitg_value_resource_free_value (GValue* value) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		gitg_resource_unref (value->data[0].v_pointer);
#line 211 "gitg-resource.c"
	}
}


static void gitg_value_resource_copy_value (const GValue* src_value, GValue* dest_value) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (src_value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		dest_value->data[0].v_pointer = gitg_resource_ref (src_value->data[0].v_pointer);
#line 221 "gitg-resource.c"
	} else {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		dest_value->data[0].v_pointer = NULL;
#line 225 "gitg-resource.c"
	}
}


static gpointer gitg_value_resource_peek_pointer (const GValue* value) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return value->data[0].v_pointer;
#line 233 "gitg-resource.c"
}


static gchar* gitg_value_resource_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (collect_values[0].v_pointer) {
#line 240 "gitg-resource.c"
		GitgResource * object;
		object = collect_values[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		if (object->parent_instance.g_class == NULL) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 247 "gitg-resource.c"
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 251 "gitg-resource.c"
		}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = gitg_resource_ref (object);
#line 255 "gitg-resource.c"
	} else {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = NULL;
#line 259 "gitg-resource.c"
	}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return NULL;
#line 263 "gitg-resource.c"
}


static gchar* gitg_value_resource_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	GitgResource ** object_p;
	object_p = collect_values[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (!object_p) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
#line 274 "gitg-resource.c"
	}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (!value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		*object_p = NULL;
#line 280 "gitg-resource.c"
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		*object_p = value->data[0].v_pointer;
#line 284 "gitg-resource.c"
	} else {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		*object_p = gitg_resource_ref (value->data[0].v_pointer);
#line 288 "gitg-resource.c"
	}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return NULL;
#line 292 "gitg-resource.c"
}


GParamSpec* gitg_param_spec_resource (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	GitgParamSpecResource* spec;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_return_val_if_fail (g_type_is_a (object_type, GITG_TYPE_RESOURCE), NULL);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	G_PARAM_SPEC (spec)->value_type = object_type;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return G_PARAM_SPEC (spec);
#line 306 "gitg-resource.c"
}


gpointer gitg_value_get_resource (const GValue* value) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_RESOURCE), NULL);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return value->data[0].v_pointer;
#line 315 "gitg-resource.c"
}


void gitg_value_set_resource (GValue* value, gpointer v_object) {
	GitgResource * old;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_RESOURCE));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	old = value->data[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (v_object) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GITG_TYPE_RESOURCE));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = v_object;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		gitg_resource_ref (value->data[0].v_pointer);
#line 335 "gitg-resource.c"
	} else {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = NULL;
#line 339 "gitg-resource.c"
	}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (old) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		gitg_resource_unref (old);
#line 345 "gitg-resource.c"
	}
}


void gitg_value_take_resource (GValue* value, gpointer v_object) {
	GitgResource * old;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_RESOURCE));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	old = value->data[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (v_object) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GITG_TYPE_RESOURCE));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = v_object;
#line 364 "gitg-resource.c"
	} else {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		value->data[0].v_pointer = NULL;
#line 368 "gitg-resource.c"
	}
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (old) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		gitg_resource_unref (old);
#line 374 "gitg-resource.c"
	}
}


static void gitg_resource_class_init (GitgResourceClass * klass) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	gitg_resource_parent_class = g_type_class_peek_parent (klass);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	((GitgResourceClass *) klass)->finalize = gitg_resource_finalize;
#line 384 "gitg-resource.c"
}


static void gitg_resource_instance_init (GitgResource * self) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	self->ref_count = 1;
#line 391 "gitg-resource.c"
}


static void gitg_resource_finalize (GitgResource * obj) {
	GitgResource * self;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_RESOURCE, GitgResource);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_signal_handlers_destroy (self);
#line 401 "gitg-resource.c"
}


GType gitg_resource_get_type (void) {
	static volatile gsize gitg_resource_type_id__volatile = 0;
	if (g_once_init_enter (&gitg_resource_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { gitg_value_resource_init, gitg_value_resource_free_value, gitg_value_resource_copy_value, gitg_value_resource_peek_pointer, "p", gitg_value_resource_collect_value, "p", gitg_value_resource_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (GitgResourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_resource_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgResource), 0, (GInstanceInitFunc) gitg_resource_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType gitg_resource_type_id;
		gitg_resource_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GitgResource", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&gitg_resource_type_id__volatile, gitg_resource_type_id);
	}
	return gitg_resource_type_id__volatile;
}


gpointer gitg_resource_ref (gpointer instance) {
	GitgResource * self;
	self = instance;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	g_atomic_int_inc (&self->ref_count);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	return instance;
#line 426 "gitg-resource.c"
}


void gitg_resource_unref (gpointer instance) {
	GitgResource * self;
	self = instance;
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		GITG_RESOURCE_GET_CLASS (self)->finalize (self);
#line 20 "/home/jesse/dev/gitg/libgitg/gitg-resource.vala"
		g_type_free_instance ((GTypeInstance *) self);
#line 439 "gitg-resource.c"
	}
}



