/* gitg-color.c generated by valac 0.34.7, the Vala compiler
 * generated from gitg-color.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 <float.h>
#include <math.h>
#include <string.h>


#define GITG_TYPE_COLOR (gitg_color_get_type ())
#define GITG_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_COLOR, GitgColor))
#define GITG_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_COLOR, GitgColorClass))
#define GITG_IS_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_COLOR))
#define GITG_IS_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_COLOR))
#define GITG_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_COLOR, GitgColorClass))

typedef struct _GitgColor GitgColor;
typedef struct _GitgColorClass GitgColorClass;
typedef struct _GitgColorPrivate GitgColorPrivate;

#define GITG_COLOR_TYPE_RGB (gitg_color_rgb_get_type ())
typedef struct _GitgColorRgb GitgColorRgb;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GitgColor {
	GObject parent_instance;
	GitgColorPrivate * priv;
	guint idx;
};

struct _GitgColorClass {
	GObjectClass parent_class;
};

struct _GitgColorRgb {
	gushort r;
	gushort g;
	gushort b;
};


static gpointer gitg_color_parent_class = NULL;
static guint gitg_color_current_index;
static guint gitg_color_current_index = 0U;

GType gitg_color_get_type (void) G_GNUC_CONST;
enum  {
	GITG_COLOR_DUMMY_PROPERTY,
	GITG_COLOR_R,
	GITG_COLOR_G,
	GITG_COLOR_B
};
static GType gitg_color_rgb_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static GitgColorRgb* gitg_color_rgb_dup (const GitgColorRgb* self);
static void gitg_color_rgb_free (GitgColorRgb* self);
void gitg_color_reset (void);
void gitg_color_components (GitgColor* self, gdouble* r, gdouble* g, gdouble* b);
gdouble gitg_color_get_r (GitgColor* self);
gdouble gitg_color_get_g (GitgColor* self);
gdouble gitg_color_get_b (GitgColor* self);
static guint gitg_color_inc_index (void);
GitgColor* gitg_color_next (void);
GitgColor* gitg_color_new (void);
GitgColor* gitg_color_construct (GType object_type);
GitgColor* gitg_color_next_index (GitgColor* self);
GitgColor* gitg_color_copy (GitgColor* self);
static void gitg_color_finalize (GObject* obj);
static void _vala_gitg_color_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);

static const GitgColorRgb GITG_COLOR_palette[14] = {{(gushort) 196, (gushort) 160, (gushort) 0}, {(gushort) 78, (gushort) 154, (gushort) 6}, {(gushort) 206, (gushort) 92, (gushort) 0}, {(gushort) 32, (gushort) 74, (gushort) 135}, {(gushort) 108, (gushort) 53, (gushort) 102}, {(gushort) 164, (gushort) 0, (gushort) 0}, {(gushort) 138, (gushort) 226, (gushort) 52}, {(gushort) 252, (gushort) 175, (gushort) 62}, {(gushort) 114, (gushort) 159, (gushort) 207}, {(gushort) 252, (gushort) 233, (gushort) 79}, {(gushort) 136, (gushort) 138, (gushort) 133}, {(gushort) 173, (gushort) 127, (gushort) 168}, {(gushort) 233, (gushort) 185, (gushort) 110}, {(gushort) 239, (gushort) 41, (gushort) 41}};

void gitg_color_reset (void) {
#line 56 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	gitg_color_current_index = (guint) 0;
#line 96 "gitg-color.c"
}


void gitg_color_components (GitgColor* self, gdouble* r, gdouble* g, gdouble* b) {
	gdouble _vala_r = 0.0;
	gdouble _vala_g = 0.0;
	gdouble _vala_b = 0.0;
	gdouble _tmp0_ = 0.0;
	gdouble _tmp1_ = 0.0;
	gdouble _tmp2_ = 0.0;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_ = 0.0;
	gdouble _tmp5_ = 0.0;
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_if_fail (self != NULL);
#line 76 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = gitg_color_get_r (self);
#line 76 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = _tmp0_;
#line 76 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_vala_r = _tmp1_;
#line 77 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp2_ = gitg_color_get_g (self);
#line 77 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp3_ = _tmp2_;
#line 77 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_vala_g = _tmp3_;
#line 78 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp4_ = gitg_color_get_b (self);
#line 78 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp5_ = _tmp4_;
#line 78 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_vala_b = _tmp5_;
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	if (r) {
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		*r = _vala_r;
#line 134 "gitg-color.c"
	}
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	if (g) {
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		*g = _vala_g;
#line 140 "gitg-color.c"
	}
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	if (b) {
#line 74 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		*b = _vala_b;
#line 146 "gitg-color.c"
	}
}


static guint gitg_color_inc_index (void) {
	guint result = 0U;
	guint next = 0U;
	guint _tmp0_ = 0U;
	guint _tmp1_ = 0U;
#line 83 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = gitg_color_current_index;
#line 83 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	gitg_color_current_index = _tmp0_ + 1;
#line 83 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	next = _tmp0_;
#line 85 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = gitg_color_current_index;
#line 85 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	if (_tmp1_ == ((guint) G_N_ELEMENTS (GITG_COLOR_palette))) {
#line 87 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		gitg_color_current_index = (guint) 0;
#line 168 "gitg-color.c"
	}
#line 90 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = next;
#line 90 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 174 "gitg-color.c"
}


GitgColor* gitg_color_next (void) {
	GitgColor* result = NULL;
	GitgColor* ret = NULL;
	GitgColor* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
#line 95 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = gitg_color_new ();
#line 95 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	ret = _tmp0_;
#line 96 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = gitg_color_inc_index ();
#line 96 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	ret->idx = _tmp1_;
#line 98 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = ret;
#line 98 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 195 "gitg-color.c"
}


static gpointer _g_object_ref0 (gpointer self) {
#line 104 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return self ? g_object_ref (self) : NULL;
#line 202 "gitg-color.c"
}


GitgColor* gitg_color_next_index (GitgColor* self) {
	GitgColor* result = NULL;
	guint _tmp0_ = 0U;
	GitgColor* _tmp1_ = NULL;
#line 101 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 103 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = gitg_color_inc_index ();
#line 103 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	self->idx = _tmp0_;
#line 104 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = _g_object_ref0 (self);
#line 104 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = _tmp1_;
#line 104 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 222 "gitg-color.c"
}


GitgColor* gitg_color_copy (GitgColor* self) {
	GitgColor* result = NULL;
	GitgColor* ret = NULL;
	GitgColor* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
#line 107 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 109 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = gitg_color_new ();
#line 109 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	ret = _tmp0_;
#line 110 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = self->idx;
#line 110 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	ret->idx = _tmp1_;
#line 112 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = ret;
#line 112 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 245 "gitg-color.c"
}


GitgColor* gitg_color_construct (GType object_type) {
	GitgColor * self = NULL;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	self = (GitgColor*) g_object_new (object_type, NULL);
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return self;
#line 255 "gitg-color.c"
}


GitgColor* gitg_color_new (void) {
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return gitg_color_construct (GITG_TYPE_COLOR);
#line 262 "gitg-color.c"
}


gdouble gitg_color_get_r (GitgColor* self) {
	gdouble result;
	guint _tmp0_ = 0U;
	GitgColorRgb _tmp1_ = {0};
	gushort _tmp2_ = 0U;
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_val_if_fail (self != NULL, 0.0);
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = self->idx;
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = GITG_COLOR_palette[_tmp0_];
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp2_ = _tmp1_.r;
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = _tmp2_ / 255.0;
#line 61 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 283 "gitg-color.c"
}


gdouble gitg_color_get_g (GitgColor* self) {
	gdouble result;
	guint _tmp0_ = 0U;
	GitgColorRgb _tmp1_ = {0};
	gushort _tmp2_ = 0U;
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_val_if_fail (self != NULL, 0.0);
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = self->idx;
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = GITG_COLOR_palette[_tmp0_];
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp2_ = _tmp1_.g;
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = _tmp2_ / 255.0;
#line 66 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 304 "gitg-color.c"
}


gdouble gitg_color_get_b (GitgColor* self) {
	gdouble result;
	guint _tmp0_ = 0U;
	GitgColorRgb _tmp1_ = {0};
	gushort _tmp2_ = 0U;
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_return_val_if_fail (self != NULL, 0.0);
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp0_ = self->idx;
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp1_ = GITG_COLOR_palette[_tmp0_];
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	_tmp2_ = _tmp1_.b;
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	result = _tmp2_ / 255.0;
#line 71 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return result;
#line 325 "gitg-color.c"
}


static GitgColorRgb* gitg_color_rgb_dup (const GitgColorRgb* self) {
	GitgColorRgb* dup;
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	dup = g_new0 (GitgColorRgb, 1);
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	memcpy (dup, self, sizeof (GitgColorRgb));
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	return dup;
#line 337 "gitg-color.c"
}


static void gitg_color_rgb_free (GitgColorRgb* self) {
#line 25 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_free (self);
#line 344 "gitg-color.c"
}


static GType gitg_color_rgb_get_type (void) {
	static volatile gsize gitg_color_rgb_type_id__volatile = 0;
	if (g_once_init_enter (&gitg_color_rgb_type_id__volatile)) {
		GType gitg_color_rgb_type_id;
		gitg_color_rgb_type_id = g_boxed_type_register_static ("GitgColorRgb", (GBoxedCopyFunc) gitg_color_rgb_dup, (GBoxedFreeFunc) gitg_color_rgb_free);
		g_once_init_leave (&gitg_color_rgb_type_id__volatile, gitg_color_rgb_type_id);
	}
	return gitg_color_rgb_type_id__volatile;
}


static void gitg_color_class_init (GitgColorClass * klass) {
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	gitg_color_parent_class = g_type_class_peek_parent (klass);
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_color_get_property;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	G_OBJECT_CLASS (klass)->finalize = gitg_color_finalize;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COLOR_R, g_param_spec_double ("r", "r", "r", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COLOR_G, g_param_spec_double ("g", "g", "g", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COLOR_B, g_param_spec_double ("b", "b", "b", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
#line 372 "gitg-color.c"
}


static void gitg_color_instance_init (GitgColor * self) {
#line 52 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	self->idx = (guint) 0;
#line 379 "gitg-color.c"
}


static void gitg_color_finalize (GObject* obj) {
	GitgColor * self;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_COLOR, GitgColor);
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	G_OBJECT_CLASS (gitg_color_parent_class)->finalize (obj);
#line 389 "gitg-color.c"
}


GType gitg_color_get_type (void) {
	static volatile gsize gitg_color_type_id__volatile = 0;
	if (g_once_init_enter (&gitg_color_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GitgColorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_color_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgColor), 0, (GInstanceInitFunc) gitg_color_instance_init, NULL };
		GType gitg_color_type_id;
		gitg_color_type_id = g_type_register_static (G_TYPE_OBJECT, "GitgColor", &g_define_type_info, 0);
		g_once_init_leave (&gitg_color_type_id__volatile, gitg_color_type_id);
	}
	return gitg_color_type_id__volatile;
}


static void _vala_gitg_color_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GitgColor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_COLOR, GitgColor);
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
	switch (property_id) {
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		case GITG_COLOR_R:
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		g_value_set_double (value, gitg_color_get_r (self));
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		break;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		case GITG_COLOR_G:
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		g_value_set_double (value, gitg_color_get_g (self));
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		break;
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		case GITG_COLOR_B:
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		g_value_set_double (value, gitg_color_get_b (self));
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		break;
#line 428 "gitg-color.c"
		default:
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 23 "/home/jesse/dev/gitg/libgitg/gitg-color.vala"
		break;
#line 434 "gitg-color.c"
	}
}



