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


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>


#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_BASE (pdfpc_view_base_get_type ())
#define PDFPC_VIEW_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_VIEW_TYPE_BASE, pdfpcViewBase))
#define PDFPC_VIEW_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_VIEW_TYPE_BASE, pdfpcViewBaseClass))
#define PDFPC_VIEW_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_VIEW_TYPE_BASE))
#define PDFPC_VIEW_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_VIEW_TYPE_BASE))
#define PDFPC_VIEW_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_VIEW_TYPE_BASE, pdfpcViewBaseClass))

typedef struct _pdfpcViewBase pdfpcViewBase;
typedef struct _pdfpcViewBaseClass pdfpcViewBaseClass;
#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;
	pdfpcViewBase* target;
};

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

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

static gpointer pdfpc_view_behaviour_base_parent_class = NULL;

GType pdfpc_view_behaviour_base_get_type (void) G_GNUC_CONST;
GType pdfpc_view_base_get_type (void) G_GNUC_CONST;
GQuark pdfpc_view_behaviour_association_error_quark (void);
enum  {
	PDFPC_VIEW_BEHAVIOUR_BASE_DUMMY_PROPERTY
};
pdfpcViewBehaviourBase* pdfpc_view_behaviour_base_construct (GType object_type);
pdfpcViewBase* pdfpc_view_behaviour_base_get_target (pdfpcViewBehaviourBase* self);
void pdfpc_view_behaviour_base_enforce_exclusive_association (pdfpcViewBehaviourBase* self, pdfpcViewBase* target, GError** error);
gboolean pdfpc_view_behaviour_base_is_supported (pdfpcViewBehaviourBase* self, pdfpcViewBase* target);
void pdfpc_view_behaviour_base_associate (pdfpcViewBehaviourBase* self, pdfpcViewBase* target, GError** error);
static void pdfpc_view_behaviour_base_real_associate (pdfpcViewBehaviourBase* self, pdfpcViewBase* target, GError** error);
static void pdfpc_view_behaviour_base_finalize (GObject* obj);


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


pdfpcViewBase* pdfpc_view_behaviour_base_get_target (pdfpcViewBehaviourBase* self) {
	pdfpcViewBase* result = NULL;
	pdfpcViewBase* _tmp0_;
	pdfpcViewBase* _tmp1_;
	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, pdfpcViewBase* target, GError** error) {
	pdfpcViewBase* _tmp0_;
	pdfpcViewBase* _tmp1_;
	pdfpcViewBase* _tmp2_;
	pdfpcViewBase* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = self->target;
	_tmp1_ = target;
	if (_tmp0_ == _tmp1_) {
		return;
	}
	_tmp2_ = self->target;
	if (_tmp2_ != NULL) {
		GError* _tmp3_;
		_tmp3_ = 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_error_ = _tmp3_;
		if (_inner_error_->domain == PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp4_ = target;
	_tmp5_ = pdfpc_view_behaviour_base_is_supported (self, _tmp4_);
	if (!_tmp5_) {
		GError* _tmp6_;
		_tmp6_ = 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_error_ = _tmp6_;
		if (_inner_error_->domain == PDFPC_VIEW_BEHAVIOUR_ASSOCIATION_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


/**
         * Associate the implementing Behaviour with the given View
         */
static void pdfpc_view_behaviour_base_real_associate (pdfpcViewBehaviourBase* self, pdfpcViewBase* 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, pdfpcViewBase* target, GError** error) {
	g_return_if_fail (self != NULL);
	PDFPC_VIEW_BEHAVIOUR_BASE_GET_CLASS (self)->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, pdfpcViewBase* target) {
	gboolean result = FALSE;
	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) {
	pdfpc_view_behaviour_base_parent_class = g_type_class_peek_parent (klass);
	PDFPC_VIEW_BEHAVIOUR_BASE_CLASS (klass)->associate = 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) {
	self->target = NULL;
}


static void pdfpc_view_behaviour_base_finalize (GObject* obj) {
	pdfpcViewBehaviourBase * self;
	self = PDFPC_VIEW_BEHAVIOUR_BASE (obj);
	_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.
     */
GType pdfpc_view_behaviour_base_get_type (void) {
	static volatile gsize pdfpc_view_behaviour_base_type_id__volatile = 0;
	if (g_once_init_enter (&pdfpc_view_behaviour_base_type_id__volatile)) {
		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);
		g_once_init_leave (&pdfpc_view_behaviour_base_type_id__volatile, pdfpc_view_behaviour_base_type_id);
	}
	return pdfpc_view_behaviour_base_type_id__volatile;
}


GQuark pdfpc_view_behaviour_association_error_quark (void) {
	return g_quark_from_static_string ("pdfpc_view_behaviour_association_error-quark");
}



