1 /* scannable-group.c generated by valac 0.32.0.49-00a57, the Vala compiler
2  * generated from scannable-group.vala, do not modify */
3 
4 
5 #include <glib.h>
6 #include <glib-object.h>
7 #include <gee.h>
8 
9 
10 #define CARIBOU_TYPE_ISCANNABLE_GROUP (caribou_iscannable_group_get_type ())
11 #define CARIBOU_ISCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup))
12 #define CARIBOU_IS_ISCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP))
13 #define CARIBOU_ISCANNABLE_GROUP_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroupIface))
14 
15 typedef struct _CaribouIScannableGroup CaribouIScannableGroup;
16 typedef struct _CaribouIScannableGroupIface CaribouIScannableGroupIface;
17 
18 #define CARIBOU_TYPE_ISCANNABLE_ITEM (caribou_iscannable_item_get_type ())
19 #define CARIBOU_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItem))
20 #define CARIBOU_IS_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM))
21 #define CARIBOU_ISCANNABLE_ITEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItemIface))
22 
23 typedef struct _CaribouIScannableItem CaribouIScannableItem;
24 typedef struct _CaribouIScannableItemIface CaribouIScannableItemIface;
25 
26 #define CARIBOU_TYPE_SCAN_GROUPING (caribou_scan_grouping_get_type ())
27 
28 #define CARIBOU_TYPE_SCANNABLE_GROUP (caribou_scannable_group_get_type ())
29 #define CARIBOU_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup))
30 #define CARIBOU_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))
31 #define CARIBOU_IS_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_SCANNABLE_GROUP))
32 #define CARIBOU_IS_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_SCANNABLE_GROUP))
33 #define CARIBOU_SCANNABLE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))
34 
35 typedef struct _CaribouScannableGroup CaribouScannableGroup;
36 typedef struct _CaribouScannableGroupClass CaribouScannableGroupClass;
37 typedef struct _CaribouScannableGroupPrivate CaribouScannableGroupPrivate;
38 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
39 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
40 #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
41 #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
42 #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
43 
44 struct _CaribouIScannableItemIface {
45 	GTypeInterface parent_iface;
46 	gboolean (*get_scan_stepping) (CaribouIScannableItem* self);
47 	void (*set_scan_stepping) (CaribouIScannableItem* self, gboolean value);
48 	gboolean (*get_scan_selected) (CaribouIScannableItem* self);
49 	void (*set_scan_selected) (CaribouIScannableItem* self, gboolean value);
50 };
51 
52 typedef enum  {
53 	CARIBOU_SCAN_GROUPING_NONE,
54 	CARIBOU_SCAN_GROUPING_SUBGROUPS,
55 	CARIBOU_SCAN_GROUPING_ROWS,
56 	CARIBOU_SCAN_GROUPING_LINEAR
57 } CaribouScanGrouping;
58 
59 struct _CaribouIScannableGroupIface {
60 	GTypeInterface parent_iface;
61 	CaribouIScannableItem* (*child_select) (CaribouIScannableGroup* self);
62 	void (*scan_reset) (CaribouIScannableGroup* self);
63 	CaribouIScannableItem** (*get_scan_children) (CaribouIScannableGroup* self, int* result_length1);
64 	CaribouIScannableItem* (*child_step) (CaribouIScannableGroup* self, gint cycles);
65 	CaribouIScannableItem** (*get_step_path) (CaribouIScannableGroup* self, int* result_length1);
66 	CaribouIScannableItem** (*get_selected_path) (CaribouIScannableGroup* self, int* result_length1);
67 	CaribouScanGrouping (*get_scan_grouping) (CaribouIScannableGroup* self);
68 	void (*set_scan_grouping) (CaribouIScannableGroup* self, CaribouScanGrouping value);
69 };
70 
71 struct _CaribouScannableGroup {
72 	GObject parent_instance;
73 	CaribouScannableGroupPrivate * priv;
74 };
75 
76 struct _CaribouScannableGroupClass {
77 	GObjectClass parent_class;
78 	CaribouIScannableItem** (*get_scan_children) (CaribouScannableGroup* self, int* result_length1);
79 	CaribouIScannableItem* (*child_select) (CaribouScannableGroup* self);
80 };
81 
82 struct _CaribouScannableGroupPrivate {
83 	GeeLinkedList* _step_path;
84 	GeeLinkedList* _selected_path;
85 	gint _cycle_count;
86 	CaribouScanGrouping _scan_grouping;
87 	gint _scan_child_index;
88 };
89 
90 
91 static gpointer caribou_scannable_group_parent_class = NULL;
92 static CaribouIScannableGroupIface* caribou_scannable_group_caribou_iscannable_group_parent_iface = NULL;
93 
94 GType caribou_iscannable_item_get_type (void) G_GNUC_CONST;
95 GType caribou_scan_grouping_get_type (void) G_GNUC_CONST;
96 GType caribou_iscannable_group_get_type (void) G_GNUC_CONST;
97 GType caribou_scannable_group_get_type (void) G_GNUC_CONST;
98 #define CARIBOU_SCANNABLE_GROUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupPrivate))
99 enum  {
100 	CARIBOU_SCANNABLE_GROUP_DUMMY_PROPERTY,
101 	CARIBOU_SCANNABLE_GROUP_SCAN_GROUPING
102 };
103 CaribouIScannableItem** caribou_scannable_group_get_scan_children (CaribouScannableGroup* self, int* result_length1);
104 static CaribouIScannableItem** caribou_scannable_group_real_get_scan_children (CaribouScannableGroup* self, int* result_length1);
105 static CaribouIScannableItem** caribou_scannable_group_real_get_step_path (CaribouIScannableGroup* base, int* result_length1);
106 static CaribouIScannableItem** caribou_scannable_group_real_get_selected_path (CaribouIScannableGroup* base, int* result_length1);
107 static void caribou_scannable_group_add_to_step_path (CaribouScannableGroup* self, CaribouIScannableItem* item);
108 static void caribou_scannable_group_add_to_selected_path (CaribouScannableGroup* self, CaribouIScannableItem* item);
109 static CaribouIScannableItem* caribou_scannable_group_get_stepping_child (CaribouScannableGroup* self);
110 static gint caribou_scannable_group_get_scan_child_index (CaribouScannableGroup* self);
111 static CaribouIScannableItem* caribou_scannable_group_get_single_child (CaribouScannableGroup* self, CaribouIScannableItem* item);
112 CaribouIScannableItem* caribou_scannable_group_child_select (CaribouScannableGroup* self);
113 static CaribouIScannableItem* caribou_scannable_group_real_child_select (CaribouScannableGroup* self);
114 CaribouIScannableItem* caribou_iscannable_group_child_select (CaribouIScannableGroup* self);
115 void caribou_iscannable_item_set_scan_selected (CaribouIScannableItem* self, gboolean value);
116 static void caribou_scannable_group_set_scan_child_index (CaribouScannableGroup* self, gint value);
117 static void caribou_scannable_group_real_scan_reset (CaribouIScannableGroup* base);
118 void caribou_iscannable_item_set_scan_stepping (CaribouIScannableItem* self, gboolean value);
119 void caribou_iscannable_group_scan_reset (CaribouIScannableGroup* self);
120 static CaribouIScannableItem* caribou_scannable_group_real_child_step (CaribouIScannableGroup* base, gint cycles);
121 CaribouIScannableItem* caribou_iscannable_group_child_step (CaribouIScannableGroup* self, gint cycles);
122 CaribouScannableGroup* caribou_scannable_group_construct (GType object_type);
123 void caribou_iscannable_group_set_scan_grouping (CaribouIScannableGroup* self, CaribouScanGrouping value);
124 static GObject * caribou_scannable_group_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
125 static void caribou_scannable_group_finalize (GObject* obj);
126 CaribouScanGrouping caribou_iscannable_group_get_scan_grouping (CaribouIScannableGroup* self);
127 static void _vala_caribou_scannable_group_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
128 static void _vala_caribou_scannable_group_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
129 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
130 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
131 
132 
caribou_scannable_group_real_get_scan_children(CaribouScannableGroup * self,int * result_length1)133 static CaribouIScannableItem** caribou_scannable_group_real_get_scan_children (CaribouScannableGroup* self, int* result_length1) {
134 	g_critical ("Type `%s' does not implement abstract method `caribou_scannable_group_get_scan_children'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
135 	return NULL;
136 }
137 
138 
caribou_scannable_group_get_scan_children(CaribouScannableGroup * self,int * result_length1)139 CaribouIScannableItem** caribou_scannable_group_get_scan_children (CaribouScannableGroup* self, int* result_length1) {
140 	g_return_val_if_fail (self != NULL, NULL);
141 	return CARIBOU_SCANNABLE_GROUP_GET_CLASS (self)->get_scan_children (self, result_length1);
142 }
143 
144 
caribou_scannable_group_real_get_step_path(CaribouIScannableGroup * base,int * result_length1)145 static CaribouIScannableItem** caribou_scannable_group_real_get_step_path (CaribouIScannableGroup* base, int* result_length1) {
146 	CaribouScannableGroup * self;
147 	CaribouIScannableItem** result = NULL;
148 	GeeLinkedList* _tmp0_ = NULL;
149 	gint _tmp1_ = 0;
150 	gpointer* _tmp2_ = NULL;
151 	CaribouIScannableItem** _tmp3_ = NULL;
152 	gint _tmp3__length1 = 0;
153 	self = (CaribouScannableGroup*) base;
154 	_tmp0_ = self->priv->_step_path;
155 	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
156 	_tmp3_ = (CaribouIScannableItem**) _tmp2_;
157 	_tmp3__length1 = (_tmp1_ * sizeof (CaribouIScannableItem*)) / sizeof (CaribouIScannableItem*);
158 	if (result_length1) {
159 		*result_length1 = _tmp3__length1;
160 	}
161 	result = _tmp3_;
162 	return result;
163 }
164 
165 
caribou_scannable_group_real_get_selected_path(CaribouIScannableGroup * base,int * result_length1)166 static CaribouIScannableItem** caribou_scannable_group_real_get_selected_path (CaribouIScannableGroup* base, int* result_length1) {
167 	CaribouScannableGroup * self;
168 	CaribouIScannableItem** result = NULL;
169 	GeeLinkedList* _tmp0_ = NULL;
170 	gint _tmp1_ = 0;
171 	gpointer* _tmp2_ = NULL;
172 	CaribouIScannableItem** _tmp3_ = NULL;
173 	gint _tmp3__length1 = 0;
174 	self = (CaribouScannableGroup*) base;
175 	_tmp0_ = self->priv->_selected_path;
176 	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
177 	_tmp3_ = (CaribouIScannableItem**) _tmp2_;
178 	_tmp3__length1 = (_tmp1_ * sizeof (CaribouIScannableItem*)) / sizeof (CaribouIScannableItem*);
179 	if (result_length1) {
180 		*result_length1 = _tmp3__length1;
181 	}
182 	result = _tmp3_;
183 	return result;
184 }
185 
186 
caribou_scannable_group_add_to_step_path(CaribouScannableGroup * self,CaribouIScannableItem * item)187 static void caribou_scannable_group_add_to_step_path (CaribouScannableGroup* self, CaribouIScannableItem* item) {
188 	GeeLinkedList* _tmp0_ = NULL;
189 	CaribouIScannableItem* _tmp1_ = NULL;
190 	GeeLinkedList* _tmp2_ = NULL;
191 	gpointer _tmp3_ = NULL;
192 	CaribouIScannableItem* _tmp4_ = NULL;
193 	g_return_if_fail (self != NULL);
194 	g_return_if_fail (item != NULL);
195 	_tmp0_ = self->priv->_step_path;
196 	_tmp1_ = item;
197 	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, _tmp1_);
198 	_tmp2_ = self->priv->_step_path;
199 	_tmp3_ = gee_deque_peek_tail ((GeeDeque*) _tmp2_);
200 	_tmp4_ = (CaribouIScannableItem*) _tmp3_;
201 	g_signal_emit_by_name ((CaribouIScannableGroup*) self, "step-item-changed", _tmp4_);
202 	_g_object_unref0 (_tmp4_);
203 }
204 
205 
caribou_scannable_group_add_to_selected_path(CaribouScannableGroup * self,CaribouIScannableItem * item)206 static void caribou_scannable_group_add_to_selected_path (CaribouScannableGroup* self, CaribouIScannableItem* item) {
207 	GeeLinkedList* _tmp0_ = NULL;
208 	CaribouIScannableItem* _tmp1_ = NULL;
209 	GeeLinkedList* _tmp2_ = NULL;
210 	gpointer _tmp3_ = NULL;
211 	CaribouIScannableItem* _tmp4_ = NULL;
212 	g_return_if_fail (self != NULL);
213 	g_return_if_fail (item != NULL);
214 	_tmp0_ = self->priv->_selected_path;
215 	_tmp1_ = item;
216 	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, _tmp1_);
217 	_tmp2_ = self->priv->_selected_path;
218 	_tmp3_ = gee_deque_peek_tail ((GeeDeque*) _tmp2_);
219 	_tmp4_ = (CaribouIScannableItem*) _tmp3_;
220 	g_signal_emit_by_name ((CaribouIScannableGroup*) self, "selected-item-changed", _tmp4_);
221 	_g_object_unref0 (_tmp4_);
222 }
223 
224 
_g_object_ref0(gpointer self)225 static gpointer _g_object_ref0 (gpointer self) {
226 	return self ? g_object_ref (self) : NULL;
227 }
228 
229 
caribou_scannable_group_get_stepping_child(CaribouScannableGroup * self)230 static CaribouIScannableItem* caribou_scannable_group_get_stepping_child (CaribouScannableGroup* self) {
231 	CaribouIScannableItem* result = NULL;
232 	gint _tmp0_ = 0;
233 	gint _tmp1_ = 0;
234 	CaribouIScannableItem** _tmp2_ = NULL;
235 	CaribouIScannableItem** _tmp3_ = NULL;
236 	gint _tmp3__length1 = 0;
237 	gint _tmp4_ = 0;
238 	CaribouIScannableItem* _tmp5_ = NULL;
239 	CaribouIScannableItem* _tmp6_ = NULL;
240 	CaribouIScannableItem* _tmp7_ = NULL;
241 	g_return_val_if_fail (self != NULL, NULL);
242 	_tmp0_ = self->priv->_scan_child_index;
243 	if (_tmp0_ < 0) {
244 		result = NULL;
245 		return result;
246 	}
247 	_tmp2_ = caribou_scannable_group_get_scan_children (self, &_tmp1_);
248 	_tmp3_ = _tmp2_;
249 	_tmp3__length1 = _tmp1_;
250 	_tmp4_ = self->priv->_scan_child_index;
251 	_tmp5_ = _tmp3_[_tmp4_];
252 	_tmp6_ = _g_object_ref0 (_tmp5_);
253 	_tmp7_ = _tmp6_;
254 	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_object_unref), NULL);
255 	result = _tmp7_;
256 	return result;
257 }
258 
259 
caribou_scannable_group_get_single_child(CaribouScannableGroup * self,CaribouIScannableItem * item)260 static CaribouIScannableItem* caribou_scannable_group_get_single_child (CaribouScannableGroup* self, CaribouIScannableItem* item) {
261 	CaribouIScannableItem* result = NULL;
262 	CaribouIScannableItem* _tmp0_ = NULL;
263 	g_return_val_if_fail (self != NULL, NULL);
264 	g_return_val_if_fail (item != NULL, NULL);
265 	_tmp0_ = item;
266 	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, CARIBOU_TYPE_SCANNABLE_GROUP)) {
267 		CaribouIScannableItem** children = NULL;
268 		CaribouIScannableItem* _tmp1_ = NULL;
269 		gint _tmp2_ = 0;
270 		CaribouIScannableItem** _tmp3_ = NULL;
271 		gint children_length1 = 0;
272 		gint _children_size_ = 0;
273 		CaribouIScannableItem** _tmp4_ = NULL;
274 		gint _tmp4__length1 = 0;
275 		_tmp1_ = item;
276 		_tmp3_ = caribou_scannable_group_get_scan_children (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, CARIBOU_TYPE_SCANNABLE_GROUP) ? ((CaribouScannableGroup*) _tmp1_) : NULL, &_tmp2_);
277 		children = _tmp3_;
278 		children_length1 = _tmp2_;
279 		_children_size_ = children_length1;
280 		_tmp4_ = children;
281 		_tmp4__length1 = children_length1;
282 		if (_tmp4__length1 == 1) {
283 			CaribouIScannableItem** _tmp5_ = NULL;
284 			gint _tmp5__length1 = 0;
285 			CaribouIScannableItem* _tmp6_ = NULL;
286 			CaribouIScannableItem* _tmp7_ = NULL;
287 			_tmp5_ = children;
288 			_tmp5__length1 = children_length1;
289 			_tmp6_ = _tmp5_[0];
290 			_tmp7_ = _g_object_ref0 (_tmp6_);
291 			result = _tmp7_;
292 			children = (_vala_array_free (children, children_length1, (GDestroyNotify) g_object_unref), NULL);
293 			return result;
294 		}
295 		children = (_vala_array_free (children, children_length1, (GDestroyNotify) g_object_unref), NULL);
296 	}
297 	result = NULL;
298 	return result;
299 }
300 
301 
caribou_scannable_group_real_child_select(CaribouScannableGroup * self)302 static CaribouIScannableItem* caribou_scannable_group_real_child_select (CaribouScannableGroup* self) {
303 	CaribouIScannableItem* result = NULL;
304 	CaribouIScannableItem* step_child = NULL;
305 	CaribouIScannableItem* _tmp0_ = NULL;
306 	CaribouIScannableItem* selected_leaf = NULL;
307 	GeeLinkedList* _tmp1_ = NULL;
308 	gpointer _tmp2_ = NULL;
309 	CaribouIScannableItem* _tmp3_ = NULL;
310 	GeeLinkedList* _tmp19_ = NULL;
311 	gpointer _tmp20_ = NULL;
312 	_tmp0_ = caribou_scannable_group_get_stepping_child (self);
313 	step_child = _tmp0_;
314 	_tmp1_ = self->priv->_selected_path;
315 	_tmp2_ = gee_deque_peek_tail ((GeeDeque*) _tmp1_);
316 	selected_leaf = (CaribouIScannableItem*) _tmp2_;
317 	_tmp3_ = selected_leaf;
318 	if (_tmp3_ != NULL) {
319 		CaribouIScannableItem* _tmp4_ = NULL;
320 		CaribouIScannableItem* _tmp5_ = NULL;
321 		CaribouIScannableItem* _tmp6_ = NULL;
322 		CaribouIScannableItem* _tmp7_ = NULL;
323 		_tmp4_ = selected_leaf;
324 		_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, CARIBOU_TYPE_ISCANNABLE_GROUP), "selected_leaf is IScannableGroup");
325 		_tmp5_ = selected_leaf;
326 		_tmp6_ = caribou_iscannable_group_child_select (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup));
327 		_tmp7_ = _tmp6_;
328 		caribou_scannable_group_add_to_selected_path (self, _tmp7_);
329 		_g_object_unref0 (_tmp7_);
330 	} else {
331 		CaribouIScannableItem* _tmp8_ = NULL;
332 		_tmp8_ = step_child;
333 		if (_tmp8_ != NULL) {
334 			CaribouIScannableItem* _tmp9_ = NULL;
335 			CaribouIScannableItem* _tmp10_ = NULL;
336 			_tmp9_ = step_child;
337 			caribou_iscannable_item_set_scan_selected (_tmp9_, TRUE);
338 			_tmp10_ = step_child;
339 			caribou_scannable_group_add_to_selected_path (self, _tmp10_);
340 			caribou_scannable_group_set_scan_child_index (self, -1);
341 			{
342 				CaribouIScannableItem* child = NULL;
343 				CaribouIScannableItem* _tmp11_ = NULL;
344 				CaribouIScannableItem* _tmp12_ = NULL;
345 				_tmp11_ = step_child;
346 				_tmp12_ = caribou_scannable_group_get_single_child (self, _tmp11_);
347 				child = _tmp12_;
348 				{
349 					gboolean _tmp13_ = FALSE;
350 					_tmp13_ = TRUE;
351 					while (TRUE) {
352 						CaribouIScannableItem* _tmp16_ = NULL;
353 						CaribouIScannableItem* _tmp17_ = NULL;
354 						CaribouIScannableItem* _tmp18_ = NULL;
355 						if (!_tmp13_) {
356 							CaribouIScannableItem* _tmp14_ = NULL;
357 							CaribouIScannableItem* _tmp15_ = NULL;
358 							_tmp14_ = child;
359 							_tmp15_ = caribou_scannable_group_get_single_child (self, _tmp14_);
360 							_g_object_unref0 (child);
361 							child = _tmp15_;
362 						}
363 						_tmp13_ = FALSE;
364 						_tmp16_ = child;
365 						if (!(_tmp16_ != NULL)) {
366 							break;
367 						}
368 						_tmp17_ = child;
369 						caribou_iscannable_item_set_scan_selected (_tmp17_, TRUE);
370 						_tmp18_ = child;
371 						caribou_scannable_group_add_to_selected_path (self, _tmp18_);
372 					}
373 				}
374 				_g_object_unref0 (child);
375 			}
376 		}
377 	}
378 	_tmp19_ = self->priv->_selected_path;
379 	_tmp20_ = gee_deque_peek_tail ((GeeDeque*) _tmp19_);
380 	result = (CaribouIScannableItem*) _tmp20_;
381 	_g_object_unref0 (selected_leaf);
382 	_g_object_unref0 (step_child);
383 	return result;
384 }
385 
386 
caribou_scannable_group_child_select(CaribouScannableGroup * self)387 CaribouIScannableItem* caribou_scannable_group_child_select (CaribouScannableGroup* self) {
388 	g_return_val_if_fail (self != NULL, NULL);
389 	return CARIBOU_SCANNABLE_GROUP_GET_CLASS (self)->child_select (self);
390 }
391 
392 
caribou_scannable_group_real_scan_reset(CaribouIScannableGroup * base)393 static void caribou_scannable_group_real_scan_reset (CaribouIScannableGroup* base) {
394 	CaribouScannableGroup * self;
395 	GeeLinkedList* _tmp0_ = NULL;
396 	GeeLinkedList* _tmp1_ = NULL;
397 	gint _tmp2_ = 0;
398 	CaribouIScannableItem** _tmp3_ = NULL;
399 	self = (CaribouScannableGroup*) base;
400 	_tmp0_ = self->priv->_selected_path;
401 	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
402 	_tmp1_ = self->priv->_step_path;
403 	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp1_);
404 	caribou_scannable_group_set_scan_child_index (self, -1);
405 	_tmp3_ = caribou_scannable_group_get_scan_children (self, &_tmp2_);
406 	{
407 		CaribouIScannableItem** item_collection = NULL;
408 		gint item_collection_length1 = 0;
409 		gint _item_collection_size_ = 0;
410 		gint item_it = 0;
411 		item_collection = _tmp3_;
412 		item_collection_length1 = _tmp2_;
413 		for (item_it = 0; item_it < _tmp2_; item_it = item_it + 1) {
414 			CaribouIScannableItem* _tmp4_ = NULL;
415 			CaribouIScannableItem* item = NULL;
416 			_tmp4_ = _g_object_ref0 (item_collection[item_it]);
417 			item = _tmp4_;
418 			{
419 				CaribouIScannableItem* _tmp5_ = NULL;
420 				CaribouIScannableItem* _tmp6_ = NULL;
421 				CaribouIScannableItem* _tmp7_ = NULL;
422 				_tmp5_ = item;
423 				caribou_iscannable_item_set_scan_stepping (_tmp5_, FALSE);
424 				_tmp6_ = item;
425 				caribou_iscannable_item_set_scan_selected (_tmp6_, FALSE);
426 				_tmp7_ = item;
427 				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, CARIBOU_TYPE_ISCANNABLE_GROUP)) {
428 					CaribouIScannableItem* _tmp8_ = NULL;
429 					_tmp8_ = item;
430 					caribou_iscannable_group_scan_reset (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup));
431 				}
432 				_g_object_unref0 (item);
433 			}
434 		}
435 		item_collection = (_vala_array_free (item_collection, item_collection_length1, (GDestroyNotify) g_object_unref), NULL);
436 	}
437 	g_signal_emit_by_name ((CaribouIScannableGroup*) self, "scan-cleared");
438 }
439 
440 
caribou_scannable_group_real_child_step(CaribouIScannableGroup * base,gint cycles)441 static CaribouIScannableItem* caribou_scannable_group_real_child_step (CaribouIScannableGroup* base, gint cycles) {
442 	CaribouScannableGroup * self;
443 	CaribouIScannableItem* result = NULL;
444 	CaribouIScannableItem* step_child = NULL;
445 	CaribouIScannableItem* _tmp0_ = NULL;
446 	CaribouIScannableItem* selected_leaf = NULL;
447 	GeeLinkedList* _tmp1_ = NULL;
448 	gpointer _tmp2_ = NULL;
449 	CaribouIScannableItem* _tmp3_ = NULL;
450 	GeeLinkedList* _tmp33_ = NULL;
451 	gpointer _tmp34_ = NULL;
452 	self = (CaribouScannableGroup*) base;
453 	_tmp0_ = caribou_scannable_group_get_stepping_child (self);
454 	step_child = _tmp0_;
455 	_tmp1_ = self->priv->_selected_path;
456 	_tmp2_ = gee_deque_peek_tail ((GeeDeque*) _tmp1_);
457 	selected_leaf = (CaribouIScannableItem*) _tmp2_;
458 	_tmp3_ = selected_leaf;
459 	if (_tmp3_ != NULL) {
460 		CaribouIScannableItem* _tmp4_ = NULL;
461 		CaribouIScannableItem* _tmp5_ = NULL;
462 		CaribouIScannableItem* _tmp9_ = NULL;
463 		_tmp4_ = step_child;
464 		_vala_assert (_tmp4_ == NULL, "step_child == null");
465 		_tmp5_ = selected_leaf;
466 		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, CARIBOU_TYPE_ISCANNABLE_GROUP)) {
467 			CaribouIScannableItem* _tmp6_ = NULL;
468 			gint _tmp7_ = 0;
469 			CaribouIScannableItem* _tmp8_ = NULL;
470 			_tmp6_ = selected_leaf;
471 			_tmp7_ = cycles;
472 			_tmp8_ = caribou_iscannable_group_child_step (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup), _tmp7_);
473 			_g_object_unref0 (step_child);
474 			step_child = _tmp8_;
475 		}
476 		_tmp9_ = step_child;
477 		if (_tmp9_ != NULL) {
478 			CaribouIScannableItem* _tmp10_ = NULL;
479 			_tmp10_ = step_child;
480 			caribou_scannable_group_add_to_step_path (self, _tmp10_);
481 		} else {
482 			GeeLinkedList* _tmp11_ = NULL;
483 			_tmp11_ = self->priv->_step_path;
484 			gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp11_);
485 		}
486 	} else {
487 		gboolean _tmp12_ = FALSE;
488 		CaribouIScannableItem* _tmp13_ = NULL;
489 		_tmp13_ = step_child;
490 		if (_tmp13_ != NULL) {
491 			_tmp12_ = TRUE;
492 		} else {
493 			gint _tmp14_ = 0;
494 			_tmp14_ = self->priv->_scan_child_index;
495 			_tmp12_ = _tmp14_ == -1;
496 		}
497 		if (_tmp12_) {
498 			CaribouIScannableItem* _tmp15_ = NULL;
499 			CaribouIScannableItem** children = NULL;
500 			gint _tmp16_ = 0;
501 			CaribouIScannableItem** _tmp17_ = NULL;
502 			gint children_length1 = 0;
503 			gint _children_size_ = 0;
504 			gint _tmp18_ = 0;
505 			gint _tmp19_ = 0;
506 			CaribouIScannableItem** _tmp20_ = NULL;
507 			gint _tmp20__length1 = 0;
508 			gint _tmp22_ = 0;
509 			gint _tmp23_ = 0;
510 			_tmp15_ = selected_leaf;
511 			_vala_assert (_tmp15_ == NULL, "selected_leaf == null");
512 			_tmp17_ = caribou_scannable_group_get_scan_children (self, &_tmp16_);
513 			children = _tmp17_;
514 			children_length1 = _tmp16_;
515 			_children_size_ = children_length1;
516 			_tmp18_ = self->priv->_scan_child_index;
517 			if (_tmp18_ == -1) {
518 				self->priv->_cycle_count = 0;
519 			}
520 			_tmp19_ = self->priv->_scan_child_index;
521 			_tmp20_ = children;
522 			_tmp20__length1 = children_length1;
523 			if (_tmp19_ == (_tmp20__length1 - 1)) {
524 				gint _tmp21_ = 0;
525 				caribou_scannable_group_set_scan_child_index (self, -1);
526 				_tmp21_ = self->priv->_cycle_count;
527 				self->priv->_cycle_count = _tmp21_ + 1;
528 			}
529 			_tmp22_ = self->priv->_cycle_count;
530 			_tmp23_ = cycles;
531 			if (_tmp22_ < _tmp23_) {
532 				CaribouIScannableItem* _tmp24_ = NULL;
533 				CaribouIScannableItem** _tmp26_ = NULL;
534 				gint _tmp26__length1 = 0;
535 				gint _tmp27_ = 0;
536 				CaribouIScannableItem* _tmp28_ = NULL;
537 				CaribouIScannableItem* _tmp29_ = NULL;
538 				CaribouIScannableItem* _tmp30_ = NULL;
539 				CaribouIScannableItem* _tmp31_ = NULL;
540 				_tmp24_ = step_child;
541 				if (_tmp24_ != NULL) {
542 					CaribouIScannableItem* _tmp25_ = NULL;
543 					_tmp25_ = step_child;
544 					caribou_iscannable_item_set_scan_stepping (_tmp25_, FALSE);
545 				}
546 				_tmp26_ = children;
547 				_tmp26__length1 = children_length1;
548 				_tmp27_ = self->priv->_scan_child_index;
549 				caribou_scannable_group_set_scan_child_index (self, _tmp27_ + 1);
550 				_tmp28_ = _tmp26_[_tmp27_ + 1];
551 				_tmp29_ = _g_object_ref0 (_tmp28_);
552 				_g_object_unref0 (step_child);
553 				step_child = _tmp29_;
554 				_tmp30_ = step_child;
555 				caribou_iscannable_item_set_scan_stepping (_tmp30_, TRUE);
556 				_tmp31_ = step_child;
557 				caribou_scannable_group_add_to_step_path (self, _tmp31_);
558 			} else {
559 				GeeLinkedList* _tmp32_ = NULL;
560 				_tmp32_ = self->priv->_step_path;
561 				gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp32_);
562 			}
563 			children = (_vala_array_free (children, children_length1, (GDestroyNotify) g_object_unref), NULL);
564 		} else {
565 			g_warn_if_reached ();
566 		}
567 	}
568 	_tmp33_ = self->priv->_step_path;
569 	_tmp34_ = gee_deque_peek_tail ((GeeDeque*) _tmp33_);
570 	result = (CaribouIScannableItem*) _tmp34_;
571 	_g_object_unref0 (selected_leaf);
572 	_g_object_unref0 (step_child);
573 	return result;
574 }
575 
576 
caribou_scannable_group_construct(GType object_type)577 CaribouScannableGroup* caribou_scannable_group_construct (GType object_type) {
578 	CaribouScannableGroup * self = NULL;
579 	self = (CaribouScannableGroup*) g_object_new (object_type, NULL);
580 	return self;
581 }
582 
583 
caribou_scannable_group_real_get_scan_grouping(CaribouIScannableGroup * base)584 static CaribouScanGrouping caribou_scannable_group_real_get_scan_grouping (CaribouIScannableGroup* base) {
585 	CaribouScanGrouping result;
586 	CaribouScannableGroup* self;
587 	CaribouScanGrouping _tmp0_ = 0;
588 	self = (CaribouScannableGroup*) base;
589 	_tmp0_ = self->priv->_scan_grouping;
590 	result = _tmp0_;
591 	return result;
592 }
593 
594 
caribou_scannable_group_real_set_scan_grouping(CaribouIScannableGroup * base,CaribouScanGrouping value)595 static void caribou_scannable_group_real_set_scan_grouping (CaribouIScannableGroup* base, CaribouScanGrouping value) {
596 	CaribouScannableGroup* self;
597 	CaribouScanGrouping _tmp0_ = 0;
598 	gint _tmp1_ = 0;
599 	CaribouIScannableItem** _tmp2_ = NULL;
600 	self = (CaribouScannableGroup*) base;
601 	_tmp0_ = value;
602 	self->priv->_scan_grouping = _tmp0_;
603 	_tmp2_ = caribou_scannable_group_get_scan_children (self, &_tmp1_);
604 	{
605 		CaribouIScannableItem** item_collection = NULL;
606 		gint item_collection_length1 = 0;
607 		gint _item_collection_size_ = 0;
608 		gint item_it = 0;
609 		item_collection = _tmp2_;
610 		item_collection_length1 = _tmp1_;
611 		for (item_it = 0; item_it < _tmp1_; item_it = item_it + 1) {
612 			CaribouIScannableItem* _tmp3_ = NULL;
613 			CaribouIScannableItem* item = NULL;
614 			_tmp3_ = _g_object_ref0 (item_collection[item_it]);
615 			item = _tmp3_;
616 			{
617 				CaribouIScannableItem* _tmp4_ = NULL;
618 				_tmp4_ = item;
619 				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, CARIBOU_TYPE_ISCANNABLE_GROUP)) {
620 					CaribouIScannableItem* _tmp5_ = NULL;
621 					CaribouScanGrouping _tmp6_ = 0;
622 					_tmp5_ = item;
623 					_tmp6_ = value;
624 					caribou_iscannable_group_set_scan_grouping (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, CARIBOU_TYPE_ISCANNABLE_GROUP, CaribouIScannableGroup), _tmp6_);
625 				}
626 				_g_object_unref0 (item);
627 			}
628 		}
629 		item_collection = (_vala_array_free (item_collection, item_collection_length1, (GDestroyNotify) g_object_unref), NULL);
630 	}
631 	g_object_notify ((GObject *) self, "scan-grouping");
632 }
633 
634 
caribou_scannable_group_get_scan_child_index(CaribouScannableGroup * self)635 static gint caribou_scannable_group_get_scan_child_index (CaribouScannableGroup* self) {
636 	gint result;
637 	gint _tmp0_ = 0;
638 	g_return_val_if_fail (self != NULL, 0);
639 	_tmp0_ = self->priv->_scan_child_index;
640 	result = _tmp0_;
641 	return result;
642 }
643 
644 
caribou_scannable_group_set_scan_child_index(CaribouScannableGroup * self,gint value)645 static void caribou_scannable_group_set_scan_child_index (CaribouScannableGroup* self, gint value) {
646 	gint _tmp0_ = 0;
647 	g_return_if_fail (self != NULL);
648 	_tmp0_ = value;
649 	self->priv->_scan_child_index = _tmp0_;
650 }
651 
652 
caribou_scannable_group_constructor(GType type,guint n_construct_properties,GObjectConstructParam * construct_properties)653 static GObject * caribou_scannable_group_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
654 	GObject * obj;
655 	GObjectClass * parent_class;
656 	CaribouScannableGroup * self;
657 	GeeLinkedList* _tmp0_ = NULL;
658 	GeeLinkedList* _tmp1_ = NULL;
659 	parent_class = G_OBJECT_CLASS (caribou_scannable_group_parent_class);
660 	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
661 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup);
662 	_tmp0_ = gee_linked_list_new (CARIBOU_TYPE_ISCANNABLE_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
663 	_g_object_unref0 (self->priv->_step_path);
664 	self->priv->_step_path = _tmp0_;
665 	_tmp1_ = gee_linked_list_new (CARIBOU_TYPE_ISCANNABLE_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
666 	_g_object_unref0 (self->priv->_selected_path);
667 	self->priv->_selected_path = _tmp1_;
668 	return obj;
669 }
670 
671 
caribou_scannable_group_class_init(CaribouScannableGroupClass * klass)672 static void caribou_scannable_group_class_init (CaribouScannableGroupClass * klass) {
673 	caribou_scannable_group_parent_class = g_type_class_peek_parent (klass);
674 	g_type_class_add_private (klass, sizeof (CaribouScannableGroupPrivate));
675 	((CaribouScannableGroupClass *) klass)->get_scan_children = caribou_scannable_group_real_get_scan_children;
676 	((CaribouScannableGroupClass *) klass)->child_select = caribou_scannable_group_real_child_select;
677 	G_OBJECT_CLASS (klass)->get_property = _vala_caribou_scannable_group_get_property;
678 	G_OBJECT_CLASS (klass)->set_property = _vala_caribou_scannable_group_set_property;
679 	G_OBJECT_CLASS (klass)->constructor = caribou_scannable_group_constructor;
680 	G_OBJECT_CLASS (klass)->finalize = caribou_scannable_group_finalize;
681 	g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_SCANNABLE_GROUP_SCAN_GROUPING, g_param_spec_enum ("scan-grouping", "scan-grouping", "scan-grouping", CARIBOU_TYPE_SCAN_GROUPING, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
682 }
683 
684 
caribou_scannable_group_caribou_iscannable_group_interface_init(CaribouIScannableGroupIface * iface)685 static void caribou_scannable_group_caribou_iscannable_group_interface_init (CaribouIScannableGroupIface * iface) {
686 	caribou_scannable_group_caribou_iscannable_group_parent_iface = g_type_interface_peek_parent (iface);
687 	iface->get_scan_children = (CaribouIScannableItem** (*)(CaribouIScannableGroup*, int*)) caribou_scannable_group_get_scan_children;
688 	iface->get_step_path = (CaribouIScannableItem** (*)(CaribouIScannableGroup*, int*)) caribou_scannable_group_real_get_step_path;
689 	iface->get_selected_path = (CaribouIScannableItem** (*)(CaribouIScannableGroup*, int*)) caribou_scannable_group_real_get_selected_path;
690 	iface->child_select = (CaribouIScannableItem* (*)(CaribouIScannableGroup*)) caribou_scannable_group_child_select;
691 	iface->scan_reset = (void (*)(CaribouIScannableGroup*)) caribou_scannable_group_real_scan_reset;
692 	iface->child_step = (CaribouIScannableItem* (*)(CaribouIScannableGroup*, gint)) caribou_scannable_group_real_child_step;
693 	iface->get_scan_grouping = caribou_scannable_group_real_get_scan_grouping;
694 	iface->set_scan_grouping = caribou_scannable_group_real_set_scan_grouping;
695 }
696 
697 
caribou_scannable_group_instance_init(CaribouScannableGroup * self)698 static void caribou_scannable_group_instance_init (CaribouScannableGroup * self) {
699 	self->priv = CARIBOU_SCANNABLE_GROUP_GET_PRIVATE (self);
700 	self->priv->_scan_child_index = -1;
701 }
702 
703 
caribou_scannable_group_finalize(GObject * obj)704 static void caribou_scannable_group_finalize (GObject* obj) {
705 	CaribouScannableGroup * self;
706 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup);
707 	_g_object_unref0 (self->priv->_step_path);
708 	_g_object_unref0 (self->priv->_selected_path);
709 	G_OBJECT_CLASS (caribou_scannable_group_parent_class)->finalize (obj);
710 }
711 
712 
713 /**
714      * Base abstract class that implements scanning mode containers.
715      */
caribou_scannable_group_get_type(void)716 GType caribou_scannable_group_get_type (void) {
717 	static volatile gsize caribou_scannable_group_type_id__volatile = 0;
718 	if (g_once_init_enter (&caribou_scannable_group_type_id__volatile)) {
719 		static const GTypeInfo g_define_type_info = { sizeof (CaribouScannableGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_scannable_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouScannableGroup), 0, (GInstanceInitFunc) caribou_scannable_group_instance_init, NULL };
720 		static const GInterfaceInfo caribou_iscannable_group_info = { (GInterfaceInitFunc) caribou_scannable_group_caribou_iscannable_group_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
721 		GType caribou_scannable_group_type_id;
722 		caribou_scannable_group_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouScannableGroup", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
723 		g_type_add_interface_static (caribou_scannable_group_type_id, CARIBOU_TYPE_ISCANNABLE_GROUP, &caribou_iscannable_group_info);
724 		g_once_init_leave (&caribou_scannable_group_type_id__volatile, caribou_scannable_group_type_id);
725 	}
726 	return caribou_scannable_group_type_id__volatile;
727 }
728 
729 
_vala_caribou_scannable_group_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)730 static void _vala_caribou_scannable_group_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
731 	CaribouScannableGroup * self;
732 	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup);
733 	switch (property_id) {
734 		case CARIBOU_SCANNABLE_GROUP_SCAN_GROUPING:
735 		g_value_set_enum (value, caribou_iscannable_group_get_scan_grouping ((CaribouIScannableGroup*) self));
736 		break;
737 		default:
738 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
739 		break;
740 	}
741 }
742 
743 
_vala_caribou_scannable_group_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)744 static void _vala_caribou_scannable_group_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
745 	CaribouScannableGroup * self;
746 	self = G_TYPE_CHECK_INSTANCE_CAST (object, CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup);
747 	switch (property_id) {
748 		case CARIBOU_SCANNABLE_GROUP_SCAN_GROUPING:
749 		caribou_iscannable_group_set_scan_grouping ((CaribouIScannableGroup*) self, g_value_get_enum (value));
750 		break;
751 		default:
752 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
753 		break;
754 	}
755 }
756 
757 
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)758 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
759 	if ((array != NULL) && (destroy_func != NULL)) {
760 		int i;
761 		for (i = 0; i < array_length; i = i + 1) {
762 			if (((gpointer*) array)[i] != NULL) {
763 				destroy_func (((gpointer*) array)[i]);
764 			}
765 		}
766 	}
767 }
768 
769 
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)770 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
771 	_vala_array_destroy (array, array_length, destroy_func);
772 	g_free (array);
773 }
774 
775 
776 
777