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

#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <string.h>
#include <cairo-gobject.h>
#include <gobject/gvaluecollector.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 PDFPC_DRAWINGS_TYPE_DRAWING_TOOL (pdfpc_drawings_drawing_tool_get_type ())
#define PDFPC_DRAWINGS_DRAWING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingTool))
#define PDFPC_DRAWINGS_DRAWING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingToolClass))
#define PDFPC_DRAWINGS_IS_DRAWING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL))
#define PDFPC_DRAWINGS_IS_DRAWING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL))
#define PDFPC_DRAWINGS_DRAWING_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingToolClass))

typedef struct _pdfpcDrawingsDrawingTool pdfpcDrawingsDrawingTool;
typedef struct _pdfpcDrawingsDrawingToolClass pdfpcDrawingsDrawingToolClass;
typedef struct _pdfpcDrawingsDrawingToolPrivate pdfpcDrawingsDrawingToolPrivate;
typedef struct _pdfpcDrawingsParamSpecDrawingTool pdfpcDrawingsParamSpecDrawingTool;

#define PDFPC_DRAWINGS_TYPE_DRAWING (pdfpc_drawings_drawing_get_type ())
#define PDFPC_DRAWINGS_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawing))
#define PDFPC_DRAWINGS_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawingClass))
#define PDFPC_DRAWINGS_IS_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_TYPE_DRAWING))
#define PDFPC_DRAWINGS_IS_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_TYPE_DRAWING))
#define PDFPC_DRAWINGS_DRAWING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawingClass))

typedef struct _pdfpcDrawingsDrawing pdfpcDrawingsDrawing;
typedef struct _pdfpcDrawingsDrawingClass pdfpcDrawingsDrawingClass;
typedef struct _pdfpcDrawingsDrawingPrivate pdfpcDrawingsDrawingPrivate;

#define PDFPC_DRAWINGS_STORAGE_TYPE_BASE (pdfpc_drawings_storage_base_get_type ())
#define PDFPC_DRAWINGS_STORAGE_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBase))
#define PDFPC_DRAWINGS_STORAGE_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBaseClass))
#define PDFPC_DRAWINGS_STORAGE_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE))
#define PDFPC_DRAWINGS_STORAGE_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_BASE))
#define PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBaseClass))

typedef struct _pdfpcDrawingsStorageBase pdfpcDrawingsStorageBase;
typedef struct _pdfpcDrawingsStorageBaseClass pdfpcDrawingsStorageBaseClass;

#define PDFPC_TYPE_DRAWING_COMMAND_LIST (pdfpc_drawing_command_list_get_type ())
#define PDFPC_DRAWING_COMMAND_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandList))
#define PDFPC_DRAWING_COMMAND_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandListClass))
#define PDFPC_IS_DRAWING_COMMAND_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST))
#define PDFPC_IS_DRAWING_COMMAND_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_DRAWING_COMMAND_LIST))
#define PDFPC_DRAWING_COMMAND_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandListClass))

typedef struct _pdfpcDrawingCommandList pdfpcDrawingCommandList;
typedef struct _pdfpcDrawingCommandListClass pdfpcDrawingCommandListClass;
enum  {
	PDFPC_DRAWINGS_DRAWING_0_PROPERTY,
	PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY,
	PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY,
	PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY,
	PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY,
	PDFPC_DRAWINGS_DRAWING_NUM_PROPERTIES
};
static GParamSpec* pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_NUM_PROPERTIES];
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
#define _pdfpc_drawings_drawing_tool_unref0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawings_drawing_tool_unref (var), NULL)))
#define _pdfpc_drawings_storage_base_unref0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawings_storage_base_unref (var), NULL)))
#define _pdfpc_drawing_command_list_unref0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawing_command_list_unref (var), NULL)))

#define PDFPC_METADATA_TYPE_PDF (pdfpc_metadata_pdf_get_type ())
#define PDFPC_METADATA_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdf))
#define PDFPC_METADATA_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))
#define PDFPC_METADATA_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))

typedef struct _pdfpcMetadataPdf pdfpcMetadataPdf;
typedef struct _pdfpcMetadataPdfClass pdfpcMetadataPdfClass;

struct _pdfpcDrawingsDrawingTool {
	GTypeInstance parent_instance;
	volatile int ref_count;
	pdfpcDrawingsDrawingToolPrivate * priv;
};

struct _pdfpcDrawingsDrawingToolClass {
	GTypeClass parent_class;
	void (*finalize) (pdfpcDrawingsDrawingTool *self);
};

struct _pdfpcDrawingsDrawingToolPrivate {
	gdouble _red;
	gdouble _green;
	gdouble _blue;
	gdouble _alpha;
	gdouble _width;
	gdouble _pressure;
	gboolean _is_eraser;
};

struct _pdfpcDrawingsParamSpecDrawingTool {
	GParamSpec parent_instance;
};

struct _pdfpcDrawingsDrawing {
	GObject parent_instance;
	pdfpcDrawingsDrawingPrivate * priv;
};

struct _pdfpcDrawingsDrawingClass {
	GObjectClass parent_class;
};

struct _pdfpcDrawingsDrawingPrivate {
	gint _width;
	gint _height;
	cairo_surface_t* surface;
	cairo_t* _context;
	pdfpcDrawingsDrawingTool* _pen;
	pdfpcDrawingsDrawingTool* _eraser;
	gint _current_slide;
	pdfpcDrawingsStorageBase* _storage;
	pdfpcDrawingCommandList* drawing_command_list;
};

static gint pdfpcDrawingsDrawingTool_private_offset;
static gpointer pdfpc_drawings_drawing_tool_parent_class = NULL;
static gint pdfpcDrawingsDrawing_private_offset;
static gpointer pdfpc_drawings_drawing_parent_class = NULL;

VALA_EXTERN gpointer pdfpc_drawings_drawing_tool_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawings_drawing_tool_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_drawings_param_spec_drawing_tool (const gchar* name,
                                                    const gchar* nick,
                                                    const gchar* blurb,
                                                    GType object_type,
                                                    GParamFlags flags);
VALA_EXTERN void pdfpc_drawings_value_set_drawing_tool (GValue* value,
                                            gpointer v_object);
VALA_EXTERN void pdfpc_drawings_value_take_drawing_tool (GValue* value,
                                             gpointer v_object);
VALA_EXTERN gpointer pdfpc_drawings_value_get_drawing_tool (const GValue* value);
VALA_EXTERN GType pdfpc_drawings_drawing_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsDrawingTool, pdfpc_drawings_drawing_tool_unref)
VALA_EXTERN void pdfpc_drawings_drawing_tool_get_rgba (pdfpcDrawingsDrawingTool* self,
                                           GdkRGBA* result);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_red (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_green (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_blue (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_alpha (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_rgba (pdfpcDrawingsDrawingTool* self,
                                           GdkRGBA* color);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_red (pdfpcDrawingsDrawingTool* self,
                                          gdouble value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_green (pdfpcDrawingsDrawingTool* self,
                                            gdouble value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_blue (pdfpcDrawingsDrawingTool* self,
                                           gdouble value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_alpha (pdfpcDrawingsDrawingTool* self,
                                            gdouble value);
VALA_EXTERN pdfpcDrawingsDrawingTool* pdfpc_drawings_drawing_tool_new (void);
VALA_EXTERN pdfpcDrawingsDrawingTool* pdfpc_drawings_drawing_tool_construct (GType object_type);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_width (pdfpcDrawingsDrawingTool* self,
                                            gdouble value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_pressure (pdfpcDrawingsDrawingTool* self,
                                               gdouble value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_set_is_eraser (pdfpcDrawingsDrawingTool* self,
                                                gboolean value);
VALA_EXTERN void pdfpc_drawings_drawing_tool_add_line (pdfpcDrawingsDrawingTool* self,
                                           cairo_t* context,
                                           gdouble x1,
                                           gdouble y1,
                                           gdouble x2,
                                           gdouble y2);
VALA_EXTERN gboolean pdfpc_drawings_drawing_tool_get_is_eraser (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_width (pdfpcDrawingsDrawingTool* self);
VALA_EXTERN gdouble pdfpc_drawings_drawing_tool_get_pressure (pdfpcDrawingsDrawingTool* self);
static void pdfpc_drawings_drawing_tool_finalize (pdfpcDrawingsDrawingTool * obj);
static GType pdfpc_drawings_drawing_tool_get_type_once (void);
VALA_EXTERN GType pdfpc_drawings_drawing_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsDrawing, g_object_unref)
VALA_EXTERN gpointer pdfpc_drawings_storage_base_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawings_storage_base_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_drawings_storage_param_spec_base (const gchar* name,
                                                    const gchar* nick,
                                                    const gchar* blurb,
                                                    GType object_type,
                                                    GParamFlags flags);
VALA_EXTERN void pdfpc_drawings_storage_value_set_base (GValue* value,
                                            gpointer v_object);
VALA_EXTERN void pdfpc_drawings_storage_value_take_base (GValue* value,
                                             gpointer v_object);
VALA_EXTERN gpointer pdfpc_drawings_storage_value_get_base (const GValue* value);
VALA_EXTERN GType pdfpc_drawings_storage_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsStorageBase, pdfpc_drawings_storage_base_unref)
VALA_EXTERN gpointer pdfpc_drawing_command_list_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawing_command_list_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_param_spec_drawing_command_list (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags);
VALA_EXTERN void pdfpc_value_set_drawing_command_list (GValue* value,
                                           gpointer v_object);
VALA_EXTERN void pdfpc_value_take_drawing_command_list (GValue* value,
                                            gpointer v_object);
VALA_EXTERN gpointer pdfpc_value_get_drawing_command_list (const GValue* value);
VALA_EXTERN GType pdfpc_drawing_command_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingCommandList, pdfpc_drawing_command_list_unref)
VALA_EXTERN void pdfpc_drawings_drawing_set_surface (pdfpcDrawingsDrawing* self,
                                         cairo_surface_t* surface);
static void pdfpc_drawings_drawing_set_context (pdfpcDrawingsDrawing* self,
                                         cairo_t* value);
static void pdfpc_drawings_drawing_set_new_surface (pdfpcDrawingsDrawing* self);
VALA_EXTERN gint pdfpc_drawings_drawing_get_width (pdfpcDrawingsDrawing* self);
VALA_EXTERN gint pdfpc_drawings_drawing_get_height (pdfpcDrawingsDrawing* self);
VALA_EXTERN pdfpcDrawingsDrawing* pdfpc_drawings_drawing_new (pdfpcDrawingsStorageBase* storage,
                                                  gint width,
                                                  gint height);
VALA_EXTERN pdfpcDrawingsDrawing* pdfpc_drawings_drawing_construct (GType object_type,
                                                        pdfpcDrawingsStorageBase* storage,
                                                        gint width,
                                                        gint height);
static void pdfpc_drawings_drawing_set_storage (pdfpcDrawingsDrawing* self,
                                         pdfpcDrawingsStorageBase* value);
VALA_EXTERN void pdfpc_drawings_drawing_set_width (pdfpcDrawingsDrawing* self,
                                       gint value);
VALA_EXTERN void pdfpc_drawings_drawing_set_height (pdfpcDrawingsDrawing* self,
                                        gint value);
VALA_EXTERN void pdfpc_drawings_drawing_set_pen (pdfpcDrawingsDrawing* self,
                                     pdfpcDrawingsDrawingTool* value);
VALA_EXTERN pdfpcDrawingsDrawingTool* pdfpc_drawings_drawing_get_pen (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawings_drawing_set_eraser (pdfpcDrawingsDrawing* self,
                                        pdfpcDrawingsDrawingTool* value);
VALA_EXTERN pdfpcDrawingsDrawingTool* pdfpc_drawings_drawing_get_eraser (pdfpcDrawingsDrawing* self);
static gint pdfpc_drawings_drawing_get_current_slide (pdfpcDrawingsDrawing* self);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawing_command_list_new (void);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawing_command_list_construct (GType object_type);
VALA_EXTERN cairo_surface_t* pdfpc_drawings_drawing_render_to_surface (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawings_drawing_add_line (pdfpcDrawingsDrawing* self,
                                      pdfpcDrawingsDrawingTool* tool,
                                      gdouble x1,
                                      gdouble y1,
                                      gdouble x2,
                                      gdouble y2);
static cairo_t* pdfpc_drawings_drawing_get_context (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawing_command_list_add_line (pdfpcDrawingCommandList* self,
                                          gboolean is_eraser,
                                          gdouble x1,
                                          gdouble y1,
                                          gdouble x2,
                                          gdouble y2,
                                          gdouble lwidth,
                                          gdouble red,
                                          gdouble green,
                                          gdouble blue,
                                          gdouble alpha);
VALA_EXTERN void pdfpc_drawings_drawing_clear (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawing_command_list_clear (pdfpcDrawingCommandList* self);
VALA_EXTERN void pdfpc_drawings_drawing_undo (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawing_command_list_undo (pdfpcDrawingCommandList* self);
VALA_EXTERN void pdfpc_drawing_command_list_paint_in_surface (pdfpcDrawingCommandList* self,
                                                  cairo_surface_t* surface);
VALA_EXTERN void pdfpc_drawings_drawing_redo (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawing_command_list_redo (pdfpcDrawingCommandList* self);
VALA_EXTERN void pdfpc_drawings_drawing_switch_to_slide (pdfpcDrawingsDrawing* self,
                                             gint slide_number);
static pdfpcDrawingsStorageBase* pdfpc_drawings_drawing_get_storage (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawings_storage_base_store (pdfpcDrawingsStorageBase* self,
                                        guint index,
                                        pdfpcDrawingCommandList* drawing_commands);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawings_storage_base_retrieve (pdfpcDrawingsStorageBase* self,
                                                               guint index);
static void pdfpc_drawings_drawing_set_current_slide (pdfpcDrawingsDrawing* self,
                                               gint value);
VALA_EXTERN void pdfpc_drawings_drawing_clear_storage (pdfpcDrawingsDrawing* self);
VALA_EXTERN void pdfpc_drawings_storage_base_clear (pdfpcDrawingsStorageBase* self);
static void pdfpc_drawings_drawing_finalize (GObject * obj);
static GType pdfpc_drawings_drawing_get_type_once (void);
static void _vala_pdfpc_drawings_drawing_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_pdfpc_drawings_drawing_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
VALA_EXTERN GType pdfpc_metadata_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcMetadataPdf, g_object_unref)
VALA_EXTERN pdfpcDrawingsDrawing* pdfpc_drawings_create (pdfpcMetadataPdf* metadata);
VALA_EXTERN gdouble pdfpc_metadata_pdf_get_page_width (pdfpcMetadataPdf* self);
VALA_EXTERN gdouble pdfpc_metadata_pdf_get_page_height (pdfpcMetadataPdf* self);
VALA_EXTERN pdfpcDrawingsStorageBase* pdfpc_drawings_storage_create (pdfpcMetadataPdf* metadata);

static inline gpointer
pdfpc_drawings_drawing_tool_get_instance_private (pdfpcDrawingsDrawingTool* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcDrawingsDrawingTool_private_offset);
}

void
pdfpc_drawings_drawing_tool_get_rgba (pdfpcDrawingsDrawingTool* self,
                                      GdkRGBA* result)
{
	GdkRGBA _result_ = {0};
	gdouble _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	g_return_if_fail (self != NULL);
	memset (&_result_, 0, sizeof (GdkRGBA));
	_tmp0_ = self->priv->_red;
	_result_.red = _tmp0_;
	_tmp1_ = self->priv->_green;
	_result_.green = _tmp1_;
	_tmp2_ = self->priv->_blue;
	_result_.blue = _tmp2_;
	_tmp3_ = self->priv->_alpha;
	_result_.alpha = _tmp3_;
	*result = _result_;
	return;
}

void
pdfpc_drawings_drawing_tool_set_rgba (pdfpcDrawingsDrawingTool* self,
                                      GdkRGBA* color)
{
	GdkRGBA _tmp0_;
	GdkRGBA _tmp1_;
	GdkRGBA _tmp2_;
	GdkRGBA _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = *color;
	pdfpc_drawings_drawing_tool_set_red (self, _tmp0_.red);
	_tmp1_ = *color;
	pdfpc_drawings_drawing_tool_set_green (self, _tmp1_.green);
	_tmp2_ = *color;
	pdfpc_drawings_drawing_tool_set_blue (self, _tmp2_.blue);
	_tmp3_ = *color;
	pdfpc_drawings_drawing_tool_set_alpha (self, _tmp3_.alpha);
}

pdfpcDrawingsDrawingTool*
pdfpc_drawings_drawing_tool_construct (GType object_type)
{
	pdfpcDrawingsDrawingTool* self = NULL;
	self = (pdfpcDrawingsDrawingTool*) g_type_create_instance (object_type);
	pdfpc_drawings_drawing_tool_set_red (self, 1.0);
	pdfpc_drawings_drawing_tool_set_green (self, 0.0);
	pdfpc_drawings_drawing_tool_set_blue (self, 0.0);
	pdfpc_drawings_drawing_tool_set_alpha (self, 1.0);
	pdfpc_drawings_drawing_tool_set_width (self, 1.0);
	pdfpc_drawings_drawing_tool_set_pressure (self, -1.0);
	pdfpc_drawings_drawing_tool_set_is_eraser (self, FALSE);
	return self;
}

pdfpcDrawingsDrawingTool*
pdfpc_drawings_drawing_tool_new (void)
{
	return pdfpc_drawings_drawing_tool_construct (PDFPC_DRAWINGS_TYPE_DRAWING_TOOL);
}

void
pdfpc_drawings_drawing_tool_add_line (pdfpcDrawingsDrawingTool* self,
                                      cairo_t* context,
                                      gdouble x1,
                                      gdouble y1,
                                      gdouble x2,
                                      gdouble y2)
{
	gboolean _tmp0_;
	gdouble lwidth = 0.0;
	gdouble _tmp5_;
	gdouble _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (context != NULL);
	_tmp0_ = self->priv->_is_eraser;
	if (_tmp0_) {
		cairo_set_operator (context, CAIRO_OPERATOR_CLEAR);
	} else {
		gdouble _tmp1_;
		gdouble _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		cairo_set_operator (context, CAIRO_OPERATOR_OVER);
		_tmp1_ = self->priv->_red;
		_tmp2_ = self->priv->_green;
		_tmp3_ = self->priv->_blue;
		_tmp4_ = self->priv->_alpha;
		cairo_set_source_rgba (context, _tmp1_, _tmp2_, _tmp3_, _tmp4_);
	}
	_tmp5_ = self->priv->_width;
	lwidth = _tmp5_;
	_tmp6_ = self->priv->_pressure;
	if (_tmp6_ >= 0.0) {
		gdouble _tmp7_;
		_tmp7_ = self->priv->_pressure;
		lwidth *= _tmp7_ / 0.5;
	}
	cairo_set_line_width (context, lwidth);
	cairo_set_line_cap (context, CAIRO_LINE_CAP_ROUND);
	cairo_move_to (context, x1, y1);
	cairo_line_to (context, x2, y2);
	cairo_stroke (context);
}

gdouble
pdfpc_drawings_drawing_tool_get_red (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_red;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_red (pdfpcDrawingsDrawingTool* self,
                                     gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_red = value;
}

gdouble
pdfpc_drawings_drawing_tool_get_green (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_green;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_green (pdfpcDrawingsDrawingTool* self,
                                       gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_green = value;
}

gdouble
pdfpc_drawings_drawing_tool_get_blue (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_blue;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_blue (pdfpcDrawingsDrawingTool* self,
                                      gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_blue = value;
}

gdouble
pdfpc_drawings_drawing_tool_get_alpha (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_alpha;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_alpha (pdfpcDrawingsDrawingTool* self,
                                       gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_alpha = value;
}

gdouble
pdfpc_drawings_drawing_tool_get_width (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_width;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_width (pdfpcDrawingsDrawingTool* self,
                                       gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_width = value;
}

gdouble
pdfpc_drawings_drawing_tool_get_pressure (pdfpcDrawingsDrawingTool* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_pressure;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_pressure (pdfpcDrawingsDrawingTool* self,
                                          gdouble value)
{
	g_return_if_fail (self != NULL);
	self->priv->_pressure = value;
}

gboolean
pdfpc_drawings_drawing_tool_get_is_eraser (pdfpcDrawingsDrawingTool* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_eraser;
	return result;
}

void
pdfpc_drawings_drawing_tool_set_is_eraser (pdfpcDrawingsDrawingTool* self,
                                           gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_is_eraser = value;
}

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

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

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

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

static gchar*
pdfpc_drawings_value_drawing_tool_collect_value (GValue* value,
                                                 guint n_collect_values,
                                                 GTypeCValue* collect_values,
                                                 guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		pdfpcDrawingsDrawingTool * 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 = pdfpc_drawings_drawing_tool_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
pdfpc_drawings_value_drawing_tool_lcopy_value (const GValue* value,
                                               guint n_collect_values,
                                               GTypeCValue* collect_values,
                                               guint collect_flags)
{
	pdfpcDrawingsDrawingTool ** 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 = pdfpc_drawings_drawing_tool_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
pdfpc_drawings_param_spec_drawing_tool (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags)
{
	pdfpcDrawingsParamSpecDrawingTool* spec;
	g_return_val_if_fail (g_type_is_a (object_type, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL), 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
pdfpc_drawings_value_get_drawing_tool (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL), NULL);
	return value->data[0].v_pointer;
}

void
pdfpc_drawings_value_set_drawing_tool (GValue* value,
                                       gpointer v_object)
{
	pdfpcDrawingsDrawingTool * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL));
		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;
		pdfpc_drawings_drawing_tool_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		pdfpc_drawings_drawing_tool_unref (old);
	}
}

void
pdfpc_drawings_value_take_drawing_tool (GValue* value,
                                        gpointer v_object)
{
	pdfpcDrawingsDrawingTool * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL));
		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) {
		pdfpc_drawings_drawing_tool_unref (old);
	}
}

static void
pdfpc_drawings_drawing_tool_class_init (pdfpcDrawingsDrawingToolClass * klass,
                                        gpointer klass_data)
{
	pdfpc_drawings_drawing_tool_parent_class = g_type_class_peek_parent (klass);
	((pdfpcDrawingsDrawingToolClass *) klass)->finalize = pdfpc_drawings_drawing_tool_finalize;
	g_type_class_adjust_private_offset (klass, &pdfpcDrawingsDrawingTool_private_offset);
}

static void
pdfpc_drawings_drawing_tool_instance_init (pdfpcDrawingsDrawingTool * self,
                                           gpointer klass)
{
	self->priv = pdfpc_drawings_drawing_tool_get_instance_private (self);
	self->ref_count = 1;
}

static void
pdfpc_drawings_drawing_tool_finalize (pdfpcDrawingsDrawingTool * obj)
{
	pdfpcDrawingsDrawingTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingTool);
	g_signal_handlers_destroy (self);
}

static GType
pdfpc_drawings_drawing_tool_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { pdfpc_drawings_value_drawing_tool_init, pdfpc_drawings_value_drawing_tool_free_value, pdfpc_drawings_value_drawing_tool_copy_value, pdfpc_drawings_value_drawing_tool_peek_pointer, "p", pdfpc_drawings_value_drawing_tool_collect_value, "p", pdfpc_drawings_value_drawing_tool_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDrawingsDrawingToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_drawings_drawing_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDrawingsDrawingTool), 0, (GInstanceInitFunc) pdfpc_drawings_drawing_tool_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 pdfpc_drawings_drawing_tool_type_id;
	pdfpc_drawings_drawing_tool_type_id = g_type_register_fundamental (g_type_fundamental_next (), "pdfpcDrawingsDrawingTool", &g_define_type_info, &g_define_type_fundamental_info, 0);
	pdfpcDrawingsDrawingTool_private_offset = g_type_add_instance_private (pdfpc_drawings_drawing_tool_type_id, sizeof (pdfpcDrawingsDrawingToolPrivate));
	return pdfpc_drawings_drawing_tool_type_id;
}

GType
pdfpc_drawings_drawing_tool_get_type (void)
{
	static volatile gsize pdfpc_drawings_drawing_tool_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawings_drawing_tool_type_id__once)) {
		GType pdfpc_drawings_drawing_tool_type_id;
		pdfpc_drawings_drawing_tool_type_id = pdfpc_drawings_drawing_tool_get_type_once ();
		g_once_init_leave (&pdfpc_drawings_drawing_tool_type_id__once, pdfpc_drawings_drawing_tool_type_id);
	}
	return pdfpc_drawings_drawing_tool_type_id__once;
}

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

void
pdfpc_drawings_drawing_tool_unref (gpointer instance)
{
	pdfpcDrawingsDrawingTool * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PDFPC_DRAWINGS_DRAWING_TOOL_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
pdfpc_drawings_drawing_get_instance_private (pdfpcDrawingsDrawing* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcDrawingsDrawing_private_offset);
}

static gpointer
_cairo_surface_reference0 (gpointer self)
{
	return self ? cairo_surface_reference (self) : NULL;
}

void
pdfpc_drawings_drawing_set_surface (pdfpcDrawingsDrawing* self,
                                    cairo_surface_t* surface)
{
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_t* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (surface != NULL);
	_tmp0_ = _cairo_surface_reference0 (surface);
	_cairo_surface_destroy0 (self->priv->surface);
	self->priv->surface = _tmp0_;
	_tmp1_ = self->priv->surface;
	_tmp2_ = cairo_create (_tmp1_);
	_tmp3_ = _tmp2_;
	pdfpc_drawings_drawing_set_context (self, _tmp3_);
	_cairo_destroy0 (_tmp3_);
}

static void
pdfpc_drawings_drawing_set_new_surface (pdfpcDrawingsDrawing* self)
{
	gint _tmp0_;
	gint _tmp1_;
	cairo_surface_t* _tmp2_;
	cairo_surface_t* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_width;
	_tmp1_ = self->priv->_height;
	_tmp2_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp0_, _tmp1_);
	_tmp3_ = _tmp2_;
	pdfpc_drawings_drawing_set_surface (self, _tmp3_);
	_cairo_surface_destroy0 (_tmp3_);
}

pdfpcDrawingsDrawing*
pdfpc_drawings_drawing_construct (GType object_type,
                                  pdfpcDrawingsStorageBase* storage,
                                  gint width,
                                  gint height)
{
	pdfpcDrawingsDrawing * self = NULL;
	pdfpcDrawingsDrawingTool* _tmp0_;
	pdfpcDrawingsDrawingTool* _tmp1_;
	pdfpcDrawingsDrawingTool* _tmp2_;
	gint _tmp3_;
	pdfpcDrawingsDrawingTool* _tmp4_;
	pdfpcDrawingsDrawingTool* _tmp5_;
	pdfpcDrawingsDrawingTool* _tmp6_;
	pdfpcDrawingsDrawingTool* _tmp7_;
	pdfpcDrawingsDrawingTool* _tmp8_;
	pdfpcDrawingsDrawingTool* _tmp9_;
	pdfpcDrawingsDrawingTool* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	pdfpcDrawingCommandList* _tmp13_;
	g_return_val_if_fail (storage != NULL, NULL);
	self = (pdfpcDrawingsDrawing*) g_object_new (object_type, NULL);
	pdfpc_drawings_drawing_set_storage (self, storage);
	pdfpc_drawings_drawing_set_width (self, width);
	pdfpc_drawings_drawing_set_height (self, height);
	_tmp0_ = pdfpc_drawings_drawing_tool_new ();
	_tmp1_ = _tmp0_;
	pdfpc_drawings_drawing_set_pen (self, _tmp1_);
	_pdfpc_drawings_drawing_tool_unref0 (_tmp1_);
	_tmp2_ = self->priv->_pen;
	_tmp3_ = self->priv->_width;
	pdfpc_drawings_drawing_tool_set_width (_tmp2_, _tmp3_ / 640.0);
	_tmp4_ = pdfpc_drawings_drawing_tool_new ();
	_tmp5_ = _tmp4_;
	pdfpc_drawings_drawing_set_eraser (self, _tmp5_);
	_pdfpc_drawings_drawing_tool_unref0 (_tmp5_);
	_tmp6_ = self->priv->_eraser;
	pdfpc_drawings_drawing_tool_set_is_eraser (_tmp6_, TRUE);
	_tmp7_ = self->priv->_eraser;
	_tmp8_ = self->priv->_eraser;
	_tmp9_ = self->priv->_eraser;
	pdfpc_drawings_drawing_tool_set_green (_tmp9_, (gdouble) 0);
	pdfpc_drawings_drawing_tool_set_blue (_tmp8_, (gdouble) 0);
	pdfpc_drawings_drawing_tool_set_red (_tmp7_, (gdouble) 0);
	_tmp10_ = self->priv->_eraser;
	_tmp11_ = self->priv->_width;
	pdfpc_drawings_drawing_tool_set_width (_tmp10_, _tmp11_ / 64.0);
	_tmp12_ = self->priv->_current_slide;
	pdfpc_drawings_drawing_set_new_surface (self);
	_tmp13_ = pdfpc_drawing_command_list_new ();
	_pdfpc_drawing_command_list_unref0 (self->priv->drawing_command_list);
	self->priv->drawing_command_list = _tmp13_;
	return self;
}

pdfpcDrawingsDrawing*
pdfpc_drawings_drawing_new (pdfpcDrawingsStorageBase* storage,
                            gint width,
                            gint height)
{
	return pdfpc_drawings_drawing_construct (PDFPC_DRAWINGS_TYPE_DRAWING, storage, width, height);
}

cairo_surface_t*
pdfpc_drawings_drawing_render_to_surface (pdfpcDrawingsDrawing* self)
{
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	cairo_surface_t* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->surface;
	_tmp1_ = _cairo_surface_reference0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
pdfpc_drawings_drawing_add_line (pdfpcDrawingsDrawing* self,
                                 pdfpcDrawingsDrawingTool* tool,
                                 gdouble x1,
                                 gdouble y1,
                                 gdouble x2,
                                 gdouble y2)
{
	cairo_t* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gdouble lwidth = 0.0;
	gdouble _tmp5_;
	gdouble _tmp6_;
	gint _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	pdfpcDrawingCommandList* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	gdouble _tmp15_;
	gdouble _tmp16_;
	gdouble _tmp17_;
	gdouble _tmp18_;
	gdouble _tmp19_;
	gdouble _tmp20_;
	gdouble _tmp21_;
	gdouble _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tool != NULL);
	_tmp0_ = self->priv->_context;
	_tmp1_ = self->priv->_width;
	_tmp2_ = self->priv->_height;
	_tmp3_ = self->priv->_width;
	_tmp4_ = self->priv->_height;
	pdfpc_drawings_drawing_tool_add_line (tool, _tmp0_, x1 * _tmp1_, y1 * _tmp2_, x2 * _tmp3_, y2 * _tmp4_);
	_tmp5_ = pdfpc_drawings_drawing_tool_get_width (tool);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_width;
	lwidth = _tmp6_ / _tmp7_;
	_tmp8_ = pdfpc_drawings_drawing_tool_get_pressure (tool);
	_tmp9_ = _tmp8_;
	if (_tmp9_ >= 0.0) {
		gdouble _tmp10_;
		gdouble _tmp11_;
		_tmp10_ = pdfpc_drawings_drawing_tool_get_pressure (tool);
		_tmp11_ = _tmp10_;
		lwidth *= _tmp11_ / 0.5;
	}
	_tmp12_ = self->priv->drawing_command_list;
	_tmp13_ = pdfpc_drawings_drawing_tool_get_is_eraser (tool);
	_tmp14_ = _tmp13_;
	_tmp15_ = pdfpc_drawings_drawing_tool_get_red (tool);
	_tmp16_ = _tmp15_;
	_tmp17_ = pdfpc_drawings_drawing_tool_get_green (tool);
	_tmp18_ = _tmp17_;
	_tmp19_ = pdfpc_drawings_drawing_tool_get_blue (tool);
	_tmp20_ = _tmp19_;
	_tmp21_ = pdfpc_drawings_drawing_tool_get_alpha (tool);
	_tmp22_ = _tmp21_;
	pdfpc_drawing_command_list_add_line (_tmp12_, _tmp14_, x1, y1, x2, y2, lwidth, _tmp16_, _tmp18_, _tmp20_, _tmp22_);
}

void
pdfpc_drawings_drawing_clear (pdfpcDrawingsDrawing* self)
{
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	pdfpcDrawingCommandList* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_context;
	cairo_set_operator (_tmp0_, CAIRO_OPERATOR_CLEAR);
	_tmp1_ = self->priv->_context;
	cairo_paint (_tmp1_);
	_tmp2_ = self->priv->_context;
	cairo_set_operator (_tmp2_, CAIRO_OPERATOR_OVER);
	_tmp3_ = self->priv->drawing_command_list;
	pdfpc_drawing_command_list_clear (_tmp3_);
}

void
pdfpc_drawings_drawing_undo (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingCommandList* _tmp0_;
	pdfpcDrawingCommandList* _tmp1_;
	cairo_surface_t* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->drawing_command_list;
	pdfpc_drawing_command_list_undo (_tmp0_);
	_tmp1_ = self->priv->drawing_command_list;
	_tmp2_ = self->priv->surface;
	pdfpc_drawing_command_list_paint_in_surface (_tmp1_, _tmp2_);
}

void
pdfpc_drawings_drawing_redo (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingCommandList* _tmp0_;
	pdfpcDrawingCommandList* _tmp1_;
	cairo_surface_t* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->drawing_command_list;
	pdfpc_drawing_command_list_redo (_tmp0_);
	_tmp1_ = self->priv->drawing_command_list;
	_tmp2_ = self->priv->surface;
	pdfpc_drawing_command_list_paint_in_surface (_tmp1_, _tmp2_);
}

void
pdfpc_drawings_drawing_switch_to_slide (pdfpcDrawingsDrawing* self,
                                        gint slide_number)
{
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_slide;
	if (slide_number != _tmp0_) {
		cairo_surface_t* _tmp1_;
		pdfpcDrawingsStorageBase* _tmp5_;
		pdfpcDrawingCommandList* _tmp6_;
		pdfpcDrawingCommandList* _tmp7_;
		pdfpcDrawingCommandList* _tmp9_;
		cairo_surface_t* _tmp10_;
		_tmp1_ = self->priv->surface;
		if (_tmp1_ != NULL) {
			pdfpcDrawingsStorageBase* _tmp2_;
			gint _tmp3_;
			pdfpcDrawingCommandList* _tmp4_;
			_tmp2_ = self->priv->_storage;
			_tmp3_ = self->priv->_current_slide;
			_tmp4_ = self->priv->drawing_command_list;
			pdfpc_drawings_storage_base_store (_tmp2_, (guint) _tmp3_, _tmp4_);
		}
		_tmp5_ = self->priv->_storage;
		_tmp6_ = pdfpc_drawings_storage_base_retrieve (_tmp5_, (guint) slide_number);
		_pdfpc_drawing_command_list_unref0 (self->priv->drawing_command_list);
		self->priv->drawing_command_list = _tmp6_;
		_tmp7_ = self->priv->drawing_command_list;
		if (_tmp7_ == NULL) {
			pdfpcDrawingCommandList* _tmp8_;
			_tmp8_ = pdfpc_drawing_command_list_new ();
			_pdfpc_drawing_command_list_unref0 (self->priv->drawing_command_list);
			self->priv->drawing_command_list = _tmp8_;
		}
		pdfpc_drawings_drawing_set_new_surface (self);
		_tmp9_ = self->priv->drawing_command_list;
		_tmp10_ = self->priv->surface;
		pdfpc_drawing_command_list_paint_in_surface (_tmp9_, _tmp10_);
		pdfpc_drawings_drawing_set_current_slide (self, slide_number);
	}
}

void
pdfpc_drawings_drawing_clear_storage (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingsStorageBase* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_storage;
	pdfpc_drawings_storage_base_clear (_tmp0_);
}

gint
pdfpc_drawings_drawing_get_width (pdfpcDrawingsDrawing* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_width;
	return result;
}

void
pdfpc_drawings_drawing_set_width (pdfpcDrawingsDrawing* self,
                                  gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_drawings_drawing_get_width (self);
	if (old_value != value) {
		self->priv->_width = value;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY]);
	}
}

gint
pdfpc_drawings_drawing_get_height (pdfpcDrawingsDrawing* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_height;
	return result;
}

void
pdfpc_drawings_drawing_set_height (pdfpcDrawingsDrawing* self,
                                   gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_drawings_drawing_get_height (self);
	if (old_value != value) {
		self->priv->_height = value;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY]);
	}
}

static cairo_t*
pdfpc_drawings_drawing_get_context (pdfpcDrawingsDrawing* self)
{
	cairo_t* result;
	cairo_t* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_context;
	result = _tmp0_;
	return result;
}

static gpointer
_cairo_reference0 (gpointer self)
{
	return self ? cairo_reference (self) : NULL;
}

static void
pdfpc_drawings_drawing_set_context (pdfpcDrawingsDrawing* self,
                                    cairo_t* value)
{
	cairo_t* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _cairo_reference0 (value);
	_cairo_destroy0 (self->priv->_context);
	self->priv->_context = _tmp0_;
}

pdfpcDrawingsDrawingTool*
pdfpc_drawings_drawing_get_pen (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingsDrawingTool* result;
	pdfpcDrawingsDrawingTool* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pen;
	result = _tmp0_;
	return result;
}

static gpointer
_pdfpc_drawings_drawing_tool_ref0 (gpointer self)
{
	return self ? pdfpc_drawings_drawing_tool_ref (self) : NULL;
}

void
pdfpc_drawings_drawing_set_pen (pdfpcDrawingsDrawing* self,
                                pdfpcDrawingsDrawingTool* value)
{
	pdfpcDrawingsDrawingTool* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_drawings_drawing_get_pen (self);
	if (old_value != value) {
		pdfpcDrawingsDrawingTool* _tmp0_;
		_tmp0_ = _pdfpc_drawings_drawing_tool_ref0 (value);
		_pdfpc_drawings_drawing_tool_unref0 (self->priv->_pen);
		self->priv->_pen = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY]);
	}
}

pdfpcDrawingsDrawingTool*
pdfpc_drawings_drawing_get_eraser (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingsDrawingTool* result;
	pdfpcDrawingsDrawingTool* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_eraser;
	result = _tmp0_;
	return result;
}

void
pdfpc_drawings_drawing_set_eraser (pdfpcDrawingsDrawing* self,
                                   pdfpcDrawingsDrawingTool* value)
{
	pdfpcDrawingsDrawingTool* old_value;
	g_return_if_fail (self != NULL);
	old_value = pdfpc_drawings_drawing_get_eraser (self);
	if (old_value != value) {
		pdfpcDrawingsDrawingTool* _tmp0_;
		_tmp0_ = _pdfpc_drawings_drawing_tool_ref0 (value);
		_pdfpc_drawings_drawing_tool_unref0 (self->priv->_eraser);
		self->priv->_eraser = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY]);
	}
}

static gint
pdfpc_drawings_drawing_get_current_slide (pdfpcDrawingsDrawing* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_current_slide;
	return result;
}

static void
pdfpc_drawings_drawing_set_current_slide (pdfpcDrawingsDrawing* self,
                                          gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_current_slide = value;
}

static pdfpcDrawingsStorageBase*
pdfpc_drawings_drawing_get_storage (pdfpcDrawingsDrawing* self)
{
	pdfpcDrawingsStorageBase* result;
	pdfpcDrawingsStorageBase* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_storage;
	result = _tmp0_;
	return result;
}

static gpointer
_pdfpc_drawings_storage_base_ref0 (gpointer self)
{
	return self ? pdfpc_drawings_storage_base_ref (self) : NULL;
}

static void
pdfpc_drawings_drawing_set_storage (pdfpcDrawingsDrawing* self,
                                    pdfpcDrawingsStorageBase* value)
{
	pdfpcDrawingsStorageBase* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _pdfpc_drawings_storage_base_ref0 (value);
	_pdfpc_drawings_storage_base_unref0 (self->priv->_storage);
	self->priv->_storage = _tmp0_;
}

static void
pdfpc_drawings_drawing_class_init (pdfpcDrawingsDrawingClass * klass,
                                   gpointer klass_data)
{
	pdfpc_drawings_drawing_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdfpcDrawingsDrawing_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pdfpc_drawings_drawing_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pdfpc_drawings_drawing_set_property;
	G_OBJECT_CLASS (klass)->finalize = pdfpc_drawings_drawing_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY] = g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY] = g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY] = pdfpc_drawings_param_spec_drawing_tool ("pen", "pen", "pen", PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY, pdfpc_drawings_drawing_properties[PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY] = pdfpc_drawings_param_spec_drawing_tool ("eraser", "eraser", "eraser", PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
pdfpc_drawings_drawing_instance_init (pdfpcDrawingsDrawing * self,
                                      gpointer klass)
{
	self->priv = pdfpc_drawings_drawing_get_instance_private (self);
}

static void
pdfpc_drawings_drawing_finalize (GObject * obj)
{
	pdfpcDrawingsDrawing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawing);
	_cairo_surface_destroy0 (self->priv->surface);
	_cairo_destroy0 (self->priv->_context);
	_pdfpc_drawings_drawing_tool_unref0 (self->priv->_pen);
	_pdfpc_drawings_drawing_tool_unref0 (self->priv->_eraser);
	_pdfpc_drawings_storage_base_unref0 (self->priv->_storage);
	_pdfpc_drawing_command_list_unref0 (self->priv->drawing_command_list);
	G_OBJECT_CLASS (pdfpc_drawings_drawing_parent_class)->finalize (obj);
}

static GType
pdfpc_drawings_drawing_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDrawingsDrawingClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_drawings_drawing_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDrawingsDrawing), 0, (GInstanceInitFunc) pdfpc_drawings_drawing_instance_init, NULL };
	GType pdfpc_drawings_drawing_type_id;
	pdfpc_drawings_drawing_type_id = g_type_register_static (G_TYPE_OBJECT, "pdfpcDrawingsDrawing", &g_define_type_info, 0);
	pdfpcDrawingsDrawing_private_offset = g_type_add_instance_private (pdfpc_drawings_drawing_type_id, sizeof (pdfpcDrawingsDrawingPrivate));
	return pdfpc_drawings_drawing_type_id;
}

GType
pdfpc_drawings_drawing_get_type (void)
{
	static volatile gsize pdfpc_drawings_drawing_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawings_drawing_type_id__once)) {
		GType pdfpc_drawings_drawing_type_id;
		pdfpc_drawings_drawing_type_id = pdfpc_drawings_drawing_get_type_once ();
		g_once_init_leave (&pdfpc_drawings_drawing_type_id__once, pdfpc_drawings_drawing_type_id);
	}
	return pdfpc_drawings_drawing_type_id__once;
}

static void
_vala_pdfpc_drawings_drawing_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	pdfpcDrawingsDrawing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawing);
	switch (property_id) {
		case PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY:
		g_value_set_int (value, pdfpc_drawings_drawing_get_width (self));
		break;
		case PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY:
		g_value_set_int (value, pdfpc_drawings_drawing_get_height (self));
		break;
		case PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY:
		pdfpc_drawings_value_set_drawing_tool (value, pdfpc_drawings_drawing_get_pen (self));
		break;
		case PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY:
		pdfpc_drawings_value_set_drawing_tool (value, pdfpc_drawings_drawing_get_eraser (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pdfpc_drawings_drawing_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	pdfpcDrawingsDrawing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawing);
	switch (property_id) {
		case PDFPC_DRAWINGS_DRAWING_WIDTH_PROPERTY:
		pdfpc_drawings_drawing_set_width (self, g_value_get_int (value));
		break;
		case PDFPC_DRAWINGS_DRAWING_HEIGHT_PROPERTY:
		pdfpc_drawings_drawing_set_height (self, g_value_get_int (value));
		break;
		case PDFPC_DRAWINGS_DRAWING_PEN_PROPERTY:
		pdfpc_drawings_drawing_set_pen (self, pdfpc_drawings_value_get_drawing_tool (value));
		break;
		case PDFPC_DRAWINGS_DRAWING_ERASER_PROPERTY:
		pdfpc_drawings_drawing_set_eraser (self, pdfpc_drawings_value_get_drawing_tool (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

pdfpcDrawingsDrawing*
pdfpc_drawings_create (pdfpcMetadataPdf* metadata)
{
	static const gdouble desired_width = (gdouble) 1280;
	gdouble page_width = 0.0;
	gdouble page_height = 0.0;
	gboolean _tmp0_ = FALSE;
	pdfpcDrawingsStorageBase* storage = NULL;
	pdfpcDrawingsStorageBase* _tmp1_;
	pdfpcDrawingsDrawing* _tmp2_;
	pdfpcDrawingsDrawing* result;
	g_return_val_if_fail (metadata != NULL, NULL);
	page_width = pdfpc_metadata_pdf_get_page_width (metadata);
	page_height = pdfpc_metadata_pdf_get_page_height (metadata);
	if (page_width <= 0.0) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = page_height <= 0.0;
	}
	if (_tmp0_) {
		page_height = desired_width;
	} else {
		page_height = (desired_width / page_width) * page_height;
	}
	page_width = desired_width;
	_tmp1_ = pdfpc_drawings_storage_create (metadata);
	storage = _tmp1_;
	_tmp2_ = pdfpc_drawings_drawing_new (storage, (gint) page_width, (gint) page_height);
	result = _tmp2_;
	_pdfpc_drawings_storage_base_unref0 (storage);
	return result;
}

