File: base.c

package info (click to toggle)
pdf-presenter-console 3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,660 kB
  • sloc: ansic: 18,202; makefile: 6
file content (223 lines) | stat: -rw-r--r-- 9,153 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* 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");
}