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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <string.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_VIEW_BEHAVIOUR_TYPE_BASE (pdfpc_view_behaviour_base_get_type ())
#define PDFPC_VIEW_BEHAVIOUR_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_VIEW_BEHAVIOUR_TYPE_BASE, pdfpcViewBehaviourBase))
#define PDFPC_VIEW_BEHAVIOUR_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_VIEW_BEHAVIOUR_TYPE_BASE, pdfpcViewBehaviourBaseClass))
#define PDFPC_VIEW_BEHAVIOUR_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_VIEW_BEHAVIOUR_TYPE_BASE))
#define PDFPC_VIEW_BEHAVIOUR_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_VIEW_BEHAVIOUR_TYPE_BASE))
#define PDFPC_VIEW_BEHAVIOUR_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_VIEW_BEHAVIOUR_TYPE_BASE, pdfpcViewBehaviourBaseClass))

typedef struct _pdfpcViewBehaviourBase pdfpcViewBehaviourBase;
typedef struct _pdfpcViewBehaviourBaseClass pdfpcViewBehaviourBaseClass;
typedef struct _pdfpcViewBehaviourBasePrivate pdfpcViewBehaviourBasePrivate;

#define PDFPC_VIEW_TYPE_PDF (pdfpc_view_pdf_get_type ())
#define PDFPC_VIEW_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdf))
#define PDFPC_VIEW_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdfClass))
#define PDFPC_VIEW_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_VIEW_TYPE_PDF))
#define PDFPC_VIEW_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_VIEW_TYPE_PDF))
#define PDFPC_VIEW_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdfClass))

typedef struct _pdfpcViewPdf pdfpcViewPdf;
typedef struct _pdfpcViewPdfClass pdfpcViewPdfClass;

#define PDFPC_VIEW_BEHAVIOUR_TYPE_ASSOCIATION_ERROR (pdfpc_view_behaviour_association_error_get_type ())
enum  {
	PDFPC_VIEW_BEHAVIOUR_BASE_0_PROPERTY,
	PDFPC_VIEW_BEHAVIOUR_BASE_NUM_PROPERTIES
};
static GParamSpec* pdfpc_view_behaviour_base_properties[PDFPC_VIEW_BEHAVIOUR_BASE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

typedef enum  {
	PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_BEHAVIOUR_ALREADY_ASSOCIATED,
	PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_VIEW_NOT_SUPPORTED
} pdfpcViewBehaviourAssociationError;
#define PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR pdfpc_view_behaviour_association_error_quark ()

struct _pdfpcViewBehaviourBase {
	GObject parent_instance;
	pdfpcViewBehaviourBasePrivate * priv;
	pdfpcViewPdf* target;
};

struct _pdfpcViewBehaviourBaseClass {
	GObjectClass parent_class;
	void (*associate) (pdfpcViewBehaviourBase* self, pdfpcViewPdf* target, GError** error);
};

/**
     * Error domain used for association errors
     */

static gpointer pdfpc_view_behaviour_base_parent_class = NULL;

VALA_EXTERN GType pdfpc_view_behaviour_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcViewBehaviourBase, g_object_unref)
VALA_EXTERN GType pdfpc_view_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcViewPdf, g_object_unref)
VALA_EXTERN GQuark pdfpc_view_behaviour_association_error_quark (void);
VALA_EXTERN GType pdfpc_view_behaviour_association_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void pdfpc_view_behaviour_base_associate (pdfpcViewBehaviourBase* self,
                                          pdfpcViewPdf* target,
                                          GError** error);
VALA_EXTERN pdfpcViewBehaviourBase* pdfpc_view_behaviour_base_construct (GType object_type);
VALA_EXTERN pdfpcViewPdf* pdfpc_view_behaviour_base_get_target (pdfpcViewBehaviourBase* self);
VALA_EXTERN void pdfpc_view_behaviour_base_enforce_exclusive_association (pdfpcViewBehaviourBase* self,
                                                              pdfpcViewPdf* target,
                                                              GError** error);
VALA_EXTERN gboolean pdfpc_view_behaviour_base_is_supported (pdfpcViewBehaviourBase* self,
                                                 pdfpcViewPdf* target);
static void pdfpc_view_behaviour_base_real_associate (pdfpcViewBehaviourBase* self,
                                               pdfpcViewPdf* target,
                                               GError** error);
static void pdfpc_view_behaviour_base_finalize (GObject * obj);
static GType pdfpc_view_behaviour_base_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
         * Base constructor not taking any arguments
         */
pdfpcViewBehaviourBase*
pdfpc_view_behaviour_base_construct (GType object_type)
{
	pdfpcViewBehaviourBase * self = NULL;
	self = (pdfpcViewBehaviourBase*) g_object_new (object_type, NULL);
	return self;
}

/**
         * Return the associated View object
         *
         * If no View has been associated yet null is returned
         */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

pdfpcViewPdf*
pdfpc_view_behaviour_base_get_target (pdfpcViewBehaviourBase* self)
{
	pdfpcViewPdf* _tmp0_;
	pdfpcViewPdf* _tmp1_;
	pdfpcViewPdf* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->target;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

/**
         * Enfore the fact that a Behaviour may only be associated to one View
         */
void
pdfpc_view_behaviour_base_enforce_exclusive_association (pdfpcViewBehaviourBase* self,
                                                         pdfpcViewPdf* target,
                                                         GError** error)
{
	pdfpcViewPdf* _tmp0_;
	pdfpcViewPdf* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = self->target;
	if (_tmp0_ == target) {
		return;
	}
	_tmp1_ = self->target;
	if (_tmp1_ != NULL) {
		GError* _tmp2_;
		_tmp2_ = g_error_new_literal (PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR, PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_BEHAVIOUR_ALREADY_ASSOCIATED, "A behaviour has been associated with two different Views.");
		_inner_error0_ = _tmp2_;
		if (_inner_error0_->domain == PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	if (!pdfpc_view_behaviour_base_is_supported (self, target)) {
		GError* _tmp3_;
		_tmp3_ = g_error_new_literal (PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR, PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_VIEW_NOT_SUPPORTED, "The View which should be associated is incompatible to the given Behav" \
"iour");
		_inner_error0_ = _tmp3_;
		if (_inner_error0_->domain == PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

/**
         * Associate the implementing Behaviour with the given View
         */
static void
pdfpc_view_behaviour_base_real_associate (pdfpcViewBehaviourBase* self,
                                          pdfpcViewPdf* target,
                                          GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `pdfpc_view_behaviour_base_associate'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
pdfpc_view_behaviour_base_associate (pdfpcViewBehaviourBase* self,
                                     pdfpcViewPdf* target,
                                     GError** error)
{
	pdfpcViewBehaviourBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = PDFPC_VIEW_BEHAVIOUR_BASE_GET_CLASS (self);
	if (_klass_->associate) {
		_klass_->associate (self, target, error);
	}
}

/**
         * Check wheter the given target is supported by this Behaviour
         *
         * By default every View is supported.
         */
gboolean
pdfpc_view_behaviour_base_is_supported (pdfpcViewBehaviourBase* self,
                                        pdfpcViewPdf* target)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (target != NULL, FALSE);
	result = TRUE;
	return result;
}

static void
pdfpc_view_behaviour_base_class_init (pdfpcViewBehaviourBaseClass * klass,
                                      gpointer klass_data)
{
	pdfpc_view_behaviour_base_parent_class = g_type_class_peek_parent (klass);
	((pdfpcViewBehaviourBaseClass *) klass)->associate = (void (*) (pdfpcViewBehaviourBase*, pdfpcViewPdf*, GError**)) pdfpc_view_behaviour_base_real_associate;
	G_OBJECT_CLASS (klass)->finalize = pdfpc_view_behaviour_base_finalize;
}

static void
pdfpc_view_behaviour_base_instance_init (pdfpcViewBehaviourBase * self,
                                         gpointer klass)
{
	self->target = NULL;
}

static void
pdfpc_view_behaviour_base_finalize (GObject * obj)
{
	pdfpcViewBehaviourBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_VIEW_BEHAVIOUR_TYPE_BASE, pdfpcViewBehaviourBase);
	_g_object_unref0 (self->target);
	G_OBJECT_CLASS (pdfpc_view_behaviour_base_parent_class)->finalize (obj);
}

/**
     * Abstract base every View Behaviour implementation has to extend.
     *
     * A Behaviour is a certain characteristic which is added to an existing
     * View on demand.
     */
static GType
pdfpc_view_behaviour_base_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcViewBehaviourBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_view_behaviour_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcViewBehaviourBase), 0, (GInstanceInitFunc) pdfpc_view_behaviour_base_instance_init, NULL };
	GType pdfpc_view_behaviour_base_type_id;
	pdfpc_view_behaviour_base_type_id = g_type_register_static (G_TYPE_OBJECT, "pdfpcViewBehaviourBase", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return pdfpc_view_behaviour_base_type_id;
}

GType
pdfpc_view_behaviour_base_get_type (void)
{
	static volatile gsize pdfpc_view_behaviour_base_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_view_behaviour_base_type_id__once)) {
		GType pdfpc_view_behaviour_base_type_id;
		pdfpc_view_behaviour_base_type_id = pdfpc_view_behaviour_base_get_type_once ();
		g_once_init_leave (&pdfpc_view_behaviour_base_type_id__once, pdfpc_view_behaviour_base_type_id);
	}
	return pdfpc_view_behaviour_base_type_id__once;
}

GQuark
pdfpc_view_behaviour_association_error_quark (void)
{
	return g_quark_from_static_string ("pdfpc-view-behaviour-association-error-quark");
}

static GType
pdfpc_view_behaviour_association_error_get_type_once (void)
{
	static const GEnumValue values[] = {{PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_BEHAVIOUR_ALREADY_ASSOCIATED, "PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_BEHAVIOUR_ALREADY_ASSOCIATED", "behaviour-already-associated"}, {PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_VIEW_NOT_SUPPORTED, "PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR_VIEW_NOT_SUPPORTED", "view-not-supported"}, {0, NULL, NULL}};
	GType pdfpc_view_behaviour_association_error_type_id;
	pdfpc_view_behaviour_association_error_type_id = g_enum_register_static ("pdfpcViewBehaviourAssociationError", values);
	return pdfpc_view_behaviour_association_error_type_id;
}

GType
pdfpc_view_behaviour_association_error_get_type (void)
{
	static volatile gsize pdfpc_view_behaviour_association_error_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_view_behaviour_association_error_type_id__once)) {
		GType pdfpc_view_behaviour_association_error_type_id;
		pdfpc_view_behaviour_association_error_type_id = pdfpc_view_behaviour_association_error_get_type_once ();
		g_once_init_leave (&pdfpc_view_behaviour_association_error_type_id__once, pdfpc_view_behaviour_association_error_type_id);
	}
	return pdfpc_view_behaviour_association_error_type_id__once;
}

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;
}

