summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 70b66ca690afdbf1de9b9bbc259c8ec515ef8064 (plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/* main.c generated by valac, the Vala compiler
 * generated from main.vala, do not modify */

/*
 * Copyright 2010 Joakim Sindholt <opensource@zhasha.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * on the rights to use, copy, modify, merge, publish, distribute, sub
 * license, and/or sell copies of the Software, and to permit persons to whom
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE. */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdk.h>


#define GUI_TYPE_MAIN_WINDOW (gui_main_window_get_type ())
#define GUI_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_MAIN_WINDOW, GUIMainWindow))
#define GUI_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GUI_TYPE_MAIN_WINDOW, GUIMainWindowClass))
#define GUI_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GUI_TYPE_MAIN_WINDOW))
#define GUI_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GUI_TYPE_MAIN_WINDOW))
#define GUI_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GUI_TYPE_MAIN_WINDOW, GUIMainWindowClass))

typedef struct _GUIMainWindow GUIMainWindow;
typedef struct _GUIMainWindowClass GUIMainWindowClass;
typedef struct _GUIMainWindowPrivate GUIMainWindowPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define EMULATION_TYPE_CS (emulation_cs_get_type ())
#define EMULATION_CS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_CS, EmulationCS))
#define EMULATION_CS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_CS, EmulationCSClass))
#define EMULATION_IS_CS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_CS))
#define EMULATION_IS_CS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_CS))
#define EMULATION_CS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_CS, EmulationCSClass))

typedef struct _EmulationCS EmulationCS;
typedef struct _EmulationCSClass EmulationCSClass;

#define GUI_TYPE_CS_VIEW (gui_cs_view_get_type ())
#define GUI_CS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_CS_VIEW, GUICSView))
#define GUI_CS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GUI_TYPE_CS_VIEW, GUICSViewClass))
#define GUI_IS_CS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GUI_TYPE_CS_VIEW))
#define GUI_IS_CS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GUI_TYPE_CS_VIEW))
#define GUI_CS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GUI_TYPE_CS_VIEW, GUICSViewClass))

typedef struct _GUICSView GUICSView;
typedef struct _GUICSViewClass GUICSViewClass;

#define GUI_TYPE_CS_EXPORT (gui_cs_export_get_type ())
#define GUI_CS_EXPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_CS_EXPORT, GUICSExport))
#define GUI_CS_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GUI_TYPE_CS_EXPORT, GUICSExportClass))
#define GUI_IS_CS_EXPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GUI_TYPE_CS_EXPORT))
#define GUI_IS_CS_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GUI_TYPE_CS_EXPORT))
#define GUI_CS_EXPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GUI_TYPE_CS_EXPORT, GUICSExportClass))

typedef struct _GUICSExport GUICSExport;
typedef struct _GUICSExportClass GUICSExportClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define GUI_TYPE_CS_IMPORT (gui_cs_import_get_type ())
#define GUI_CS_IMPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_CS_IMPORT, GUICSImport))
#define GUI_CS_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GUI_TYPE_CS_IMPORT, GUICSImportClass))
#define GUI_IS_CS_IMPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GUI_TYPE_CS_IMPORT))
#define GUI_IS_CS_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GUI_TYPE_CS_IMPORT))
#define GUI_CS_IMPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GUI_TYPE_CS_IMPORT, GUICSImportClass))

typedef struct _GUICSImport GUICSImport;
typedef struct _GUICSImportClass GUICSImportClass;

#define EMULATION_TYPE_SPEC_ENTRY (emulation_spec_entry_get_type ())

#define EMULATION_TYPE_SPEC (emulation_spec_get_type ())
#define EMULATION_SPEC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMULATION_TYPE_SPEC, EmulationSpec))
#define EMULATION_SPEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMULATION_TYPE_SPEC, EmulationSpecClass))
#define EMULATION_IS_SPEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMULATION_TYPE_SPEC))
#define EMULATION_IS_SPEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMULATION_TYPE_SPEC))
#define EMULATION_SPEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMULATION_TYPE_SPEC, EmulationSpecClass))

typedef struct _EmulationSpec EmulationSpec;
typedef struct _EmulationSpecClass EmulationSpecClass;
typedef struct _EmulationSpecEntry EmulationSpecEntry;

struct _GUIMainWindow {
	GtkWindow parent_instance;
	GUIMainWindowPrivate * priv;
};

struct _GUIMainWindowClass {
	GtkWindowClass parent_class;
};

struct _GUIMainWindowPrivate {
	GtkListStore* cs_store;
	GtkTreeView* cs_list;
	GtkMenu* edit_menu;
	GtkAction* action_exportcs;
	GtkAction* action_removecs;
};

struct _EmulationSpecEntry {
	EmulationSpec* spec;
	char* name;
};


static char* gui_main_window_xml_ui;
static char* gui_main_window_xml_ui = NULL;
static gpointer gui_main_window_parent_class = NULL;
extern GUIMainWindow* gui_main;
GUIMainWindow* gui_main = NULL;
extern EmulationSpecEntry* emulation_specs;
extern gint emulation_specs_length1;
EmulationSpecEntry* emulation_specs = NULL;
gint emulation_specs_length1 = 0;
extern guint emulation_spec_default;
guint emulation_spec_default = (guint) 1;

GType gui_main_window_get_type (void);
#define GUI_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GUI_TYPE_MAIN_WINDOW, GUIMainWindowPrivate))
enum  {
	GUI_MAIN_WINDOW_DUMMY_PROPERTY
};
static void gui_main_window_edit_set_sensitive (GUIMainWindow* self, gboolean setting);
GType emulation_cs_get_type (void);
static EmulationCS* gui_main_window_get_selected_cs (GUIMainWindow* self);
void gui_main_window_add_cs (GUIMainWindow* self, const char* name, EmulationCS* cs);
void gui_main_window_remove_cs (GUIMainWindow* self);
GUICSView* gui_cs_view_new (EmulationCS* cs);
GUICSView* gui_cs_view_construct (GType object_type, EmulationCS* cs);
GType gui_cs_view_get_type (void);
static void gui_main_window_open_csview (GUIMainWindow* self);
GUICSExport* gui_cs_export_new (EmulationCS* cs);
GUICSExport* gui_cs_export_construct (GType object_type, EmulationCS* cs);
GType gui_cs_export_get_type (void);
static void gui_main_window_open_csexport (GUIMainWindow* self);
GUIMainWindow* gui_main_window_new (void);
GUIMainWindow* gui_main_window_construct (GType object_type);
guint emulation_cs_get_length (EmulationCS* self);
static void _lambda10_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self);
static void __lambda10__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self);
GUICSImport* gui_cs_import_new (void);
GUICSImport* gui_cs_import_construct (GType object_type);
GType gui_cs_import_get_type (void);
static void _lambda11_ (GtkAction* source, GUIMainWindow* self);
static void __lambda11__gtk_action_activate (GtkAction* _sender, gpointer self);
static void _lambda12_ (GtkAction* source, GUIMainWindow* self);
static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self);
static void _lambda13_ (GtkAction* source, GUIMainWindow* self);
static void __lambda13__gtk_action_activate (GtkAction* _sender, gpointer self);
static void _lambda14_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self);
static void __lambda14__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
static gboolean _lambda15_ (GdkEventButton* event, GUIMainWindow* self);
static gboolean __lambda15__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static void _lambda16_ (GtkTreeView* source, GUIMainWindow* self);
static void __lambda16__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self);
static void _gtk_main_quit_gtk_object_destroy (GtkObject* _sender, gpointer self);
static GObject * gui_main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void gui_main_window_finalize (GObject* obj);
GType emulation_spec_entry_get_type (void);
GType emulation_spec_get_type (void);
EmulationSpecEntry* emulation_spec_entry_dup (const EmulationSpecEntry* self);
void emulation_spec_entry_free (EmulationSpecEntry* self);
void emulation_spec_entry_copy (const EmulationSpecEntry* self, EmulationSpecEntry* dest);
void emulation_spec_entry_destroy (EmulationSpecEntry* self);
static void _vala_EmulationSpecEntry_array_free (EmulationSpecEntry* array, gint array_length);
EmulationSpec* emulation_spec_new (const char* filename, const char* variant);
EmulationSpec* emulation_spec_construct (GType object_type, const char* filename, const char* variant);
void gui_init (char*** args, int* args_length1);
gint _main (char** args, int args_length1);



static void gui_main_window_edit_set_sensitive (GUIMainWindow* self, gboolean setting) {
	g_return_if_fail (self != NULL);
	gtk_action_set_sensitive (self->priv->action_exportcs, setting);
	gtk_action_set_sensitive (self->priv->action_removecs, setting);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static EmulationCS* gui_main_window_get_selected_cs (GUIMainWindow* self) {
	EmulationCS* result;
	GtkTreeIter iter = {0};
	EmulationCS* cs;
	GtkTreeSelection* selection;
	g_return_val_if_fail (self != NULL, NULL);
	cs = NULL;
	selection = _g_object_ref0 (gtk_tree_view_get_selection (self->priv->cs_list));
	if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
		result = NULL;
		_g_object_unref0 (cs);
		_g_object_unref0 (selection);
		return result;
	}
	gtk_tree_model_get ((GtkTreeModel*) self->priv->cs_store, &iter, 1, &cs, -1, -1);
	result = cs;
	_g_object_unref0 (selection);
	return result;
}


void gui_main_window_add_cs (GUIMainWindow* self, const char* name, EmulationCS* cs) {
	GtkTreeIter iter = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (cs != NULL);
	gtk_list_store_append (self->priv->cs_store, &iter);
	gtk_list_store_set (self->priv->cs_store, &iter, 0, name, 1, cs, -1, -1);
}


void gui_main_window_remove_cs (GUIMainWindow* self) {
	GtkTreeIter iter = {0};
	GtkTreeSelection* selection;
	g_return_if_fail (self != NULL);
	selection = _g_object_ref0 (gtk_tree_view_get_selection (self->priv->cs_list));
	if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
		_g_object_unref0 (selection);
		return;
	}
	gtk_list_store_remove (self->priv->cs_store, &iter);
	_g_object_unref0 (selection);
}


static void gui_main_window_open_csview (GUIMainWindow* self) {
	EmulationCS* cs;
	g_return_if_fail (self != NULL);
	cs = gui_main_window_get_selected_cs (self);
	if (cs != NULL) {
		GUICSView* csv;
		csv = g_object_ref_sink (gui_cs_view_new (cs));
		gtk_widget_show_all ((GtkWidget*) csv);
		_g_object_unref0 (csv);
	}
	_g_object_unref0 (cs);
}


static void gui_main_window_open_csexport (GUIMainWindow* self) {
	EmulationCS* cs;
	g_return_if_fail (self != NULL);
	cs = gui_main_window_get_selected_cs (self);
	if (cs != NULL) {
		GUICSExport* d;
		d = g_object_ref_sink (gui_cs_export_new (cs));
		gtk_dialog_run ((GtkDialog*) d);
		_g_object_unref0 (d);
	}
	_g_object_unref0 (cs);
}


GUIMainWindow* gui_main_window_construct (GType object_type) {
	GUIMainWindow * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


GUIMainWindow* gui_main_window_new (void) {
	return gui_main_window_construct (GUI_TYPE_MAIN_WINDOW);
}


static glong string_get_length (const char* self) {
	glong result;
	g_return_val_if_fail (self != NULL, 0L);
	result = g_utf8_strlen (self, -1);
	return result;
}


static void _lambda10_ (GtkCellLayout* col, GtkCellRenderer* cell, GtkTreeModel* model, GtkTreeIter* iter, GUIMainWindow* self) {
	EmulationCS* cs;
	char* _tmp0_;
	GtkCellRenderer* _tmp1_;
	g_return_if_fail (col != NULL);
	g_return_if_fail (cell != NULL);
	g_return_if_fail (model != NULL);
	cs = NULL;
	gtk_tree_model_get (model, iter, 1, &cs, -1, -1);
	g_assert (cs != NULL);
	g_object_set ((_tmp1_ = cell, GTK_IS_CELL_RENDERER_TEXT (_tmp1_) ? ((GtkCellRendererText*) _tmp1_) : NULL), "text", _tmp0_ = g_strdup_printf ("%u", emulation_cs_get_length (cs)), NULL);
	_g_free0 (_tmp0_);
	_g_object_unref0 (cs);
}


static void __lambda10__gtk_cell_layout_data_func (GtkCellLayout* cell_layout, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer self) {
	_lambda10_ (cell_layout, cell, tree_model, iter, self);
}


static void _lambda11_ (GtkAction* source, GUIMainWindow* self) {
	GUICSImport* d;
	g_return_if_fail (source != NULL);
	d = g_object_ref_sink (gui_cs_import_new ());
	gtk_dialog_run ((GtkDialog*) d);
	_g_object_unref0 (d);
}


static void __lambda11__gtk_action_activate (GtkAction* _sender, gpointer self) {
	_lambda11_ (_sender, self);
}


static void _lambda12_ (GtkAction* source, GUIMainWindow* self) {
	g_return_if_fail (source != NULL);
	gui_main_window_open_csexport (self);
}


static void __lambda12__gtk_action_activate (GtkAction* _sender, gpointer self) {
	_lambda12_ (_sender, self);
}


static void _lambda13_ (GtkAction* source, GUIMainWindow* self) {
	g_return_if_fail (source != NULL);
	gui_main_window_remove_cs (self);
}


static void __lambda13__gtk_action_activate (GtkAction* _sender, gpointer self) {
	_lambda13_ (_sender, self);
}


static void _lambda14_ (GtkTreePath* path, GtkTreeViewColumn* column, GUIMainWindow* self) {
	g_return_if_fail (path != NULL);
	g_return_if_fail (column != NULL);
	gui_main_window_open_csview (self);
}


static void __lambda14__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
	_lambda14_ (path, column, self);
}


static gboolean _lambda15_ (GdkEventButton* event, GUIMainWindow* self) {
	gboolean result;
	EmulationCS* cs;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	cs = gui_main_window_get_selected_cs (self);
	if (cs != NULL) {
		_tmp1_ = (*event).type == GDK_BUTTON_PRESS;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = (*event).button == 3;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gtk_menu_popup (self->priv->edit_menu, NULL, NULL, NULL, NULL, (*event).button, (*event).time);
	}
	_g_object_unref0 (cs);
}


static gboolean __lambda15__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	return _lambda15_ (event, self);
}


static void _lambda16_ (GtkTreeView* source, GUIMainWindow* self) {
	g_return_if_fail (source != NULL);
	gui_main_window_edit_set_sensitive (self, gtk_tree_selection_get_selected (gtk_tree_view_get_selection (self->priv->cs_list), NULL, NULL));
}


static void __lambda16__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) {
	_lambda16_ (_sender, self);
}


static void _gtk_main_quit_gtk_object_destroy (GtkObject* _sender, gpointer self) {
	gtk_main_quit ();
}


static GObject * gui_main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GUIMainWindow * self;
	GError * _inner_error_;
	parent_class = G_OBJECT_CLASS (gui_main_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = GUI_MAIN_WINDOW (obj);
	_inner_error_ = NULL;
	{
		GtkBuilder* builder;
		GObject* _tmp0_;
		GtkTreeViewColumn* col;
		GObject* _tmp1_;
		GtkCellRendererText* cell;
		GtkAction* _tmp3_;
		GObject* _tmp2_;
		GtkAction* _tmp5_;
		GObject* _tmp4_;
		GObject* _tmp6_;
		GtkAction* action_importcs;
		GtkListStore* _tmp8_;
		GObject* _tmp7_;
		GtkTreeView* _tmp10_;
		GObject* _tmp9_;
		GtkMenu* _tmp12_;
		GObject* _tmp11_;
		GObject* _tmp13_;
		builder = gtk_builder_new ();
		{
			gtk_builder_add_from_string (builder, gui_main_window_xml_ui, (gsize) string_get_length (gui_main_window_xml_ui), &_inner_error_);
			if (_inner_error_ != NULL) {
				goto __catch3_g_error;
			}
		}
		goto __finally3;
		__catch3_g_error:
		{
			GError * e;
			e = _inner_error_;
			_inner_error_ = NULL;
			{
				fprintf (stderr, "Unable to construct main window: %s.\n", e->message);
				g_assert (FALSE);
				_g_error_free0 (e);
			}
		}
		__finally3:
		if (_inner_error_ != NULL) {
			_g_object_unref0 (builder);
			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_);
		}
		gtk_widget_set_size_request ((GtkWidget*) self, 400, 200);
		gtk_window_set_title ((GtkWindow*) self, "Radeon Simulator");
		col = _g_object_ref0 ((_tmp0_ = gtk_builder_get_object (builder, "pkts_column"), GTK_IS_TREE_VIEW_COLUMN (_tmp0_) ? ((GtkTreeViewColumn*) _tmp0_) : NULL));
		cell = _g_object_ref0 ((_tmp1_ = gtk_builder_get_object (builder, "pkts_cell"), GTK_IS_CELL_RENDERER_TEXT (_tmp1_) ? ((GtkCellRendererText*) _tmp1_) : NULL));
		gtk_cell_layout_set_cell_data_func ((GtkCellLayout*) col, (GtkCellRenderer*) cell, __lambda10__gtk_cell_layout_data_func, g_object_ref (self), g_object_unref);
		self->priv->action_exportcs = (_tmp3_ = _g_object_ref0 ((_tmp2_ = gtk_builder_get_object (builder, "ExportCS"), GTK_IS_ACTION (_tmp2_) ? ((GtkAction*) _tmp2_) : NULL)), _g_object_unref0 (self->priv->action_exportcs), _tmp3_);
		self->priv->action_removecs = (_tmp5_ = _g_object_ref0 ((_tmp4_ = gtk_builder_get_object (builder, "RemoveCS"), GTK_IS_ACTION (_tmp4_) ? ((GtkAction*) _tmp4_) : NULL)), _g_object_unref0 (self->priv->action_removecs), _tmp5_);
		action_importcs = _g_object_ref0 ((_tmp6_ = gtk_builder_get_object (builder, "ImportCS"), GTK_IS_ACTION (_tmp6_) ? ((GtkAction*) _tmp6_) : NULL));
		g_signal_connect_object (action_importcs, "activate", (GCallback) __lambda11__gtk_action_activate, self, 0);
		g_signal_connect_object (self->priv->action_exportcs, "activate", (GCallback) __lambda12__gtk_action_activate, self, 0);
		g_signal_connect_object (self->priv->action_removecs, "activate", (GCallback) __lambda13__gtk_action_activate, self, 0);
		self->priv->cs_store = (_tmp8_ = _g_object_ref0 ((_tmp7_ = gtk_builder_get_object (builder, "cs_store"), GTK_IS_LIST_STORE (_tmp7_) ? ((GtkListStore*) _tmp7_) : NULL)), _g_object_unref0 (self->priv->cs_store), _tmp8_);
		self->priv->cs_list = (_tmp10_ = _g_object_ref0 ((_tmp9_ = gtk_builder_get_object (builder, "cs_list"), GTK_IS_TREE_VIEW (_tmp9_) ? ((GtkTreeView*) _tmp9_) : NULL)), _g_object_unref0 (self->priv->cs_list), _tmp10_);
		self->priv->edit_menu = (_tmp12_ = _g_object_ref0 ((_tmp11_ = gtk_builder_get_object (builder, "popup1"), GTK_IS_MENU (_tmp11_) ? ((GtkMenu*) _tmp11_) : NULL)), _g_object_unref0 (self->priv->edit_menu), _tmp12_);
		g_signal_connect_object (self->priv->cs_list, "row-activated", (GCallback) __lambda14__gtk_tree_view_row_activated, self, 0);
		g_signal_connect_object ((GtkWidget*) self->priv->cs_list, "button-press-event", (GCallback) __lambda15__gtk_widget_button_press_event, self, 0);
		g_signal_connect_object (self->priv->cs_list, "cursor-changed", (GCallback) __lambda16__gtk_tree_view_cursor_changed, self, 0);
		gui_main_window_edit_set_sensitive (self, FALSE);
		gtk_container_add ((GtkContainer*) self, (_tmp13_ = gtk_builder_get_object (builder, "mainbox"), GTK_IS_WIDGET (_tmp13_) ? ((GtkWidget*) _tmp13_) : NULL));
		g_signal_connect ((GtkObject*) self, "destroy", (GCallback) _gtk_main_quit_gtk_object_destroy, NULL);
		{
			gtk_window_set_icon_from_file ((GtkWindow*) self, "/usr/share/pixmaps/rsim.png", &_inner_error_);
			if (_inner_error_ != NULL) {
				goto __catch4_g_error;
			}
		}
		goto __finally4;
		__catch4_g_error:
		{
			GError * e;
			e = _inner_error_;
			_inner_error_ = NULL;
			{
				_g_error_free0 (e);
			}
		}
		__finally4:
		if (_inner_error_ != NULL) {
			_g_object_unref0 (builder);
			_g_object_unref0 (col);
			_g_object_unref0 (cell);
			_g_object_unref0 (action_importcs);
			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_);
		}
		_g_object_unref0 (builder);
		_g_object_unref0 (col);
		_g_object_unref0 (cell);
		_g_object_unref0 (action_importcs);
	}
	return obj;
}


static void gui_main_window_class_init (GUIMainWindowClass * klass) {
	gui_main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GUIMainWindowPrivate));
	G_OBJECT_CLASS (klass)->constructor = gui_main_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = gui_main_window_finalize;
	gui_main_window_xml_ui = g_strdup ("\n        <?xml version=\"1.0\"?>\n        <interface>\n          <requires lib=\"gtk+\" version=\"2.16\"/>\n          <!-- interface-naming-policy project-wide -->\n          <object class=\"GtkUIManager\" id=\"uimanager1\">\n            <child>\n              <object class=\"GtkActionGroup\" id=\"actiongroup1\">\n                <child>\n                  <object class=\"GtkAction\" id=\"New\">\n                    <property name=\"name\">New</property>\n                    <property name=\"stock_id\">gtk-new</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"Open\">\n                    <property name=\"name\">Open</property>\n                    <property name=\"stock_id\">gtk-open</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"Save\">\n                    <property name=\"name\">Save</property>\n                    <property name=\"stock_id\">gtk-save</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"SaveAs\">\n                    <property name=\"name\">SaveAs</property>\n                    <property name=\"stock_id\">gtk-save-as</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"Quit\">\n                    <property name=\"name\">Quit</property>\n                    <property name=\"stock_id\">gtk-quit</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"RemoveCS\">\n                    <property name=\"name\">RemoveCS</property>\n                    <property name=\"label\">Remove CS</property>\n                    <property name=\"tooltip\">Remove the selected command stream from the current project.</property>\n                    <property name=\"stock_id\">gtk-delete</property>\n                  </object>\n                  <accelerator key=\"Delete\"/>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"ImportCS\">\n                    <property name=\"name\">ImportCS</property>\n                    <property name=\"label\">Import CS</property>\n                    <property name=\"tooltip\">Import a new command stream to the current project.</property>\n                    <property name=\"stock_id\">gtk-add</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"ExportCS\">\n                    <property name=\"name\">ExportCS</property>\n                    <property name=\"label\">Export CS</property>\n                    <property name=\"tooltip\">Export the selected command stream to a file.</property>\n                    <property name=\"stock_id\">gtk-convert</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"About\">\n                    <property name=\"name\">About</property>\n                    <property name=\"stock_id\">gtk-about</property>\n                  </object>\n                  <accelerator key=\"F1\"/>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"FileMenu\">\n                    <property name=\"name\">FileMenu</property>\n                    <property name=\"label\" translatable=\"yes\">_File</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"EditMenu\">\n                    <property name=\"name\">EditMenu</property>\n                    <property name=\"label\" translatable=\"yes\">_Edit</property>\n                  </object>\n                </child>\n                <child>\n                  <object class=\"GtkAction\" id=\"HelpMenu\">\n                    <property name=\"name\">HelpMenu</property>\n                    <property name=\"label\" translatable=\"yes\">_Help</property>\n                  </object>\n                </child>\n              </object>\n            </child>\n            <ui>\n              <menubar name=\"menubar1\">\n                <menu action=\"FileMenu\" name=\"FileMenu\">\n                  <menuitem action=\"New\" name=\"New\"/>\n                  <menuitem action=\"Open\" name=\"Open\"/>\n                  <menuitem action=\"Save\" name=\"Save\"/>\n                  <menuitem action=\"SaveAs\" name=\"SaveAs\"/>\n                  <separator/>\n                  <menuitem action=\"Quit\" name=\"Quit\"/>\n                </menu>\n                <menu action=\"EditMenu\" name=\"EditMenu\">\n                  <menuitem action=\"ImportCS\" name=\"ImportCS\"/>\n                  <menuitem action=\"ExportCS\" name=\"ExportCS\"/>\n                  <separator/>\n                  <menuitem action=\"RemoveCS\" name=\"RemoveCS\"/>\n                </menu>\n                <menu action=\"HelpMenu\" name=\"HelpMenu\">\n                  <menuitem action=\"About\" name=\"About\"/>\n                </menu>\n              </menubar>\n              <toolbar name=\"toolbar1\">\n                <toolitem action=\"New\" name=\"New\"/>\n                <toolitem action=\"Open\" name=\"Open\"/>\n                <toolitem action=\"Save\" name=\"Save\"/>\n                <separator/>\n                <toolitem action=\"ImportCS\" name=\"ImportCS\"/>\n                <toolitem action=\"ExportCS\" name=\"ExportCS\"/>\n                <separator/>\n                <toolitem action=\"RemoveCS\" name=\"RemoveCS\"/>\n              </toolbar>\n              <popup name=\"popup1\">\n                <menuitem action=\"ExportCS\" name=\"ExportCS\"/>\n                <menuitem action=\"RemoveCS\" name=\"RemoveCS\"/>\n              </popup>\n            </ui>\n          </object>\n          <object class=\"GtkVBox\" id=\"mainbox\">\n            <property name=\"visible\">True</property>\n            <property name=\"orientation\">vertical</property>\n            <child>\n              <object constructor=\"uimanager1\" class=\"GtkMenuBar\" id=\"menubar1\">\n                <property name=\"visible\">True</property>\n                <child internal-child=\"accessible\">\n                  <object class=\"AtkObject\" id=\"a11y-menubar\">\n                    <property name=\"AtkObject::accessible-name\">The menubar</property>\n                  </object>\n                </child>\n              </object>\n              <packing>\n                <property name=\"expand\">False</property>\n              </packing>\n            </child>\n            <child>\n              <object constructor=\"uimanager1\" class=\"GtkToolbar\" id=\"toolbar1\">\n                  <property name=\"visible\">True</property>\n                  <child internal-child=\"accessible\">\n                      <object class=\"AtkObject\" id=\"a11y-toolbar\">\n                          <property name=\"AtkObject::accessible-name\">The toolbar</property>\n                      </object>\n                  </child>\n              </object>\n              <packing>\n                  <property name=\"expand\">False</property>\n                  <property name=\"position\">1</property>\n              </packing>\n            </child>\n            <child>\n              <object class=\"GtkScrolledWindow\" id=\"scrolledwindow1\">\n                <property name=\"visible\">True</property>\n                <property name=\"can_focus\">True</property>\n                <property name=\"hscrollbar_policy\">automatic</property>\n                <property name=\"vscrollbar_policy\">automatic</property>\n                <child>\n                  <object class=\"GtkTreeView\" id=\"cs_list\">\n                    <property name=\"visible\">True</property>\n                    <property name=\"can_focus\">True</property>\n                    <property name=\"model\">cs_store</property>\n                    <child>\n                      <object class=\"GtkTreeViewColumn\" id=\"pkts_column\">\n                        <property name=\"title\">Packets</property>\n                        <child>\n                          <object class=\"GtkCellRendererText\" id=\"pkts_cell\"/>\n                        </child>\n                      </object>\n                    </child>\n                    <child>\n                      <object class=\"GtkTreeViewColumn\" id=\"treeviewcolumn1\">\n                        <property name=\"title\">Name</property>\n                        <child>\n                          <object class=\"GtkCellRendererText\" id=\"cellrenderertext1\"/>\n                          <attributes>\n                            <attribute name=\"text\">0</attribute>\n                          </attributes>\n                        </child>\n                      </object>\n                    </child>\n                  </object>\n                </child>\n              </object>\n              <packing>\n                <property name=\"position\">2</property>\n              </packing>\n            </child>\n          </object>\n          <object class=\"GtkListStore\" id=\"cs_store\">\n            <columns>\n              <!-- column-name Name -->\n              <column type=\"gchararray\"/>\n              <!-- column-name CS -->\n              <column type=\"GObject\"/>\n            </columns>\n          </object>\n          <object constructor=\"uimanager1\" class=\"GtkMenu\" id=\"popup1\">\n            <child internal-child=\"accessible\">\n              <object class=\"AtkObject\" id=\"a11y-popup\">\n                <property name=\"AtkObject::accessible-name\">The popup menu</property>\n              </object>\n            </child>\n          </object>\n        </interface>\n        ");
}


static void gui_main_window_instance_init (GUIMainWindow * self) {
	self->priv = GUI_MAIN_WINDOW_GET_PRIVATE (self);
}


static void gui_main_window_finalize (GObject* obj) {
	GUIMainWindow * self;
	self = GUI_MAIN_WINDOW (obj);
	_g_object_unref0 (self->priv->cs_store);
	_g_object_unref0 (self->priv->cs_list);
	_g_object_unref0 (self->priv->edit_menu);
	_g_object_unref0 (self->priv->action_exportcs);
	_g_object_unref0 (self->priv->action_removecs);
	G_OBJECT_CLASS (gui_main_window_parent_class)->finalize (obj);
}


GType gui_main_window_get_type (void) {
	static GType gui_main_window_type_id = 0;
	if (gui_main_window_type_id == 0) {
		static const GTypeInfo g_define_type_info = { sizeof (GUIMainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gui_main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GUIMainWindow), 0, (GInstanceInitFunc) gui_main_window_instance_init, NULL };
		gui_main_window_type_id = g_type_register_static (GTK_TYPE_WINDOW, "GUIMainWindow", &g_define_type_info, 0);
	}
	return gui_main_window_type_id;
}


static void _vala_EmulationSpecEntry_array_free (EmulationSpecEntry* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			emulation_spec_entry_destroy (&array[i]);
		}
	}
	g_free (array);
}


void gui_init (char*** args, int* args_length1) {
	EmulationSpecEntry* _tmp0_;
	EmulationSpec* _tmp1_;
	char* _tmp2_;
	EmulationSpec* _tmp3_;
	char* _tmp4_;
	GUIMainWindow* _tmp5_;
	gtk_init (args_length1, args);
	emulation_specs = (_tmp0_ = g_new0 (EmulationSpecEntry, 2), emulation_specs = (_vala_EmulationSpecEntry_array_free (emulation_specs, emulation_specs_length1), NULL), emulation_specs_length1 = 2, _tmp0_);
	emulation_specs[0].spec = (_tmp1_ = emulation_spec_new ("/usr/share/rsim/r300reg.xml", "r300"), _g_object_unref0 (emulation_specs[0].spec), _tmp1_);
	emulation_specs[0].name = (_tmp2_ = g_strdup ("r300"), _g_free0 (emulation_specs[0].name), _tmp2_);
	emulation_specs[1].spec = (_tmp3_ = emulation_spec_new ("/usr/share/rsim/r300reg.xml", "r500"), _g_object_unref0 (emulation_specs[1].spec), _tmp3_);
	emulation_specs[1].name = (_tmp4_ = g_strdup ("r500"), _g_free0 (emulation_specs[1].name), _tmp4_);
	gui_main = (_tmp5_ = g_object_ref_sink (gui_main_window_new ()), _g_object_unref0 (gui_main), _tmp5_);
	gtk_widget_show_all ((GtkWidget*) gui_main);
	gtk_main ();
}


void emulation_spec_entry_copy (const EmulationSpecEntry* self, EmulationSpecEntry* dest) {
	dest->spec = _g_object_ref0 (self->spec);
	dest->name = g_strdup (self->name);
}


void emulation_spec_entry_destroy (EmulationSpecEntry* self) {
	_g_object_unref0 (self->spec);
	_g_free0 (self->name);
}


EmulationSpecEntry* emulation_spec_entry_dup (const EmulationSpecEntry* self) {
	EmulationSpecEntry* dup;
	dup = g_new0 (EmulationSpecEntry, 1);
	emulation_spec_entry_copy (self, dup);
	return dup;
}


void emulation_spec_entry_free (EmulationSpecEntry* self) {
	emulation_spec_entry_destroy (self);
	g_free (self);
}


GType emulation_spec_entry_get_type (void) {
	static GType emulation_spec_entry_type_id = 0;
	if (emulation_spec_entry_type_id == 0) {
		emulation_spec_entry_type_id = g_boxed_type_register_static ("EmulationSpecEntry", (GBoxedCopyFunc) emulation_spec_entry_dup, (GBoxedFreeFunc) emulation_spec_entry_free);
	}
	return emulation_spec_entry_type_id;
}


gint _main (char** args, int args_length1) {
	gint result;
	if (!g_thread_supported ()) {
		fprintf (stderr, "Cannot run without threads.\n");
		result = 1;
		return result;
	}
	gui_init (&args, &args_length1);
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				if (!_tmp0_) {
					i++;
				}
				_tmp0_ = FALSE;
				if (!(i < emulation_specs_length1)) {
					break;
				}
				g_object_unref ((GObject*) emulation_specs[i].spec);
			}
		}
	}
	g_object_unref ((GObject*) gui_main);
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
	g_thread_init (NULL);
	g_type_init ();
	return _main (argv, argc);
}