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

#include <glib-object.h>
#include <cairo-gobject.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>
#include <string.h>

#define TOOTLE_TYPE_DRAWING (tootle_drawing_get_type ())
#define TOOTLE_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_DRAWING, TootleDrawing))
#define TOOTLE_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_DRAWING, TootleDrawingClass))
#define TOOTLE_IS_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_DRAWING))
#define TOOTLE_IS_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_DRAWING))
#define TOOTLE_DRAWING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_DRAWING, TootleDrawingClass))

typedef struct _TootleDrawing TootleDrawing;
typedef struct _TootleDrawingClass TootleDrawingClass;
typedef struct _TootleDrawingPrivate TootleDrawingPrivate;
typedef struct _TootleParamSpecDrawing TootleParamSpecDrawing;

struct _TootleDrawing {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TootleDrawingPrivate * priv;
};

struct _TootleDrawingClass {
	GTypeClass parent_class;
	void (*finalize) (TootleDrawing *self);
};

struct _TootleParamSpecDrawing {
	GParamSpec parent_instance;
};

static gpointer tootle_drawing_parent_class = NULL;

gpointer tootle_drawing_ref (gpointer instance);
void tootle_drawing_unref (gpointer instance);
GParamSpec* tootle_param_spec_drawing (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
void tootle_value_set_drawing (GValue* value,
                               gpointer v_object);
void tootle_value_take_drawing (GValue* value,
                                gpointer v_object);
gpointer tootle_value_get_drawing (const GValue* value);
GType tootle_drawing_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleDrawing, tootle_drawing_unref)
void tootle_drawing_draw_rounded_rect (cairo_t* ctx,
                                       gdouble x,
                                       gdouble y,
                                       gdouble w,
                                       gdouble h,
                                       gdouble r);
TootleDrawing* tootle_drawing_new (void);
TootleDrawing* tootle_drawing_construct (GType object_type);
static void tootle_drawing_finalize (TootleDrawing * obj);
static GType tootle_drawing_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
tootle_drawing_draw_rounded_rect (cairo_t* ctx,
                                  gdouble x,
                                  gdouble y,
                                  gdouble w,
                                  gdouble h,
                                  gdouble r)
{
	gdouble degr = 0.0;
	g_return_if_fail (ctx != NULL);
	degr = G_PI / 180.0;
	cairo_new_sub_path (ctx);
	cairo_arc (ctx, (x + w) - r, y + r, r, -90 * degr, 0 * degr);
	cairo_arc (ctx, (x + w) - r, (y + h) - r, r, 0 * degr, 90 * degr);
	cairo_arc (ctx, x + r, (y + h) - r, r, 90 * degr, 180 * degr);
	cairo_arc (ctx, x + r, y + r, r, 180 * degr, 270 * degr);
	cairo_close_path (ctx);
}

TootleDrawing*
tootle_drawing_construct (GType object_type)
{
	TootleDrawing* self = NULL;
	self = (TootleDrawing*) g_type_create_instance (object_type);
	return self;
}

TootleDrawing*
tootle_drawing_new (void)
{
	return tootle_drawing_construct (TOOTLE_TYPE_DRAWING);
}

static void
tootle_value_drawing_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
tootle_value_drawing_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		tootle_drawing_unref (value->data[0].v_pointer);
	}
}

static void
tootle_value_drawing_copy_value (const GValue* src_value,
                                 GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = tootle_drawing_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
tootle_value_drawing_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
tootle_value_drawing_collect_value (GValue* value,
                                    guint n_collect_values,
                                    GTypeCValue* collect_values,
                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		TootleDrawing * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = tootle_drawing_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
tootle_value_drawing_lcopy_value (const GValue* value,
                                  guint n_collect_values,
                                  GTypeCValue* collect_values,
                                  guint collect_flags)
{
	TootleDrawing ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = tootle_drawing_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
tootle_param_spec_drawing (const gchar* name,
                           const gchar* nick,
                           const gchar* blurb,
                           GType object_type,
                           GParamFlags flags)
{
	TootleParamSpecDrawing* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TOOTLE_TYPE_DRAWING), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
tootle_value_get_drawing (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TOOTLE_TYPE_DRAWING), NULL);
	return value->data[0].v_pointer;
}

void
tootle_value_set_drawing (GValue* value,
                          gpointer v_object)
{
	TootleDrawing * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TOOTLE_TYPE_DRAWING));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TOOTLE_TYPE_DRAWING));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		tootle_drawing_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tootle_drawing_unref (old);
	}
}

void
tootle_value_take_drawing (GValue* value,
                           gpointer v_object)
{
	TootleDrawing * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TOOTLE_TYPE_DRAWING));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TOOTLE_TYPE_DRAWING));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tootle_drawing_unref (old);
	}
}

static void
tootle_drawing_class_init (TootleDrawingClass * klass,
                           gpointer klass_data)
{
	tootle_drawing_parent_class = g_type_class_peek_parent (klass);
	((TootleDrawingClass *) klass)->finalize = tootle_drawing_finalize;
}

static void
tootle_drawing_instance_init (TootleDrawing * self,
                              gpointer klass)
{
	self->ref_count = 1;
}

static void
tootle_drawing_finalize (TootleDrawing * obj)
{
	TootleDrawing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_TYPE_DRAWING, TootleDrawing);
	g_signal_handlers_destroy (self);
}

static GType
tootle_drawing_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { tootle_value_drawing_init, tootle_value_drawing_free_value, tootle_value_drawing_copy_value, tootle_value_drawing_peek_pointer, "p", tootle_value_drawing_collect_value, "p", tootle_value_drawing_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TootleDrawingClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_drawing_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleDrawing), 0, (GInstanceInitFunc) tootle_drawing_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 tootle_drawing_type_id;
	tootle_drawing_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TootleDrawing", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return tootle_drawing_type_id;
}

GType
tootle_drawing_get_type (void)
{
	static volatile gsize tootle_drawing_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_drawing_type_id__volatile)) {
		GType tootle_drawing_type_id;
		tootle_drawing_type_id = tootle_drawing_get_type_once ();
		g_once_init_leave (&tootle_drawing_type_id__volatile, tootle_drawing_type_id);
	}
	return tootle_drawing_type_id__volatile;
}

gpointer
tootle_drawing_ref (gpointer instance)
{
	TootleDrawing * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
tootle_drawing_unref (gpointer instance)
{
	TootleDrawing * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TOOTLE_DRAWING_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

