1
/* score-dialog.c generated by valac 0.22.1, the Vala compiler
2
* generated from score-dialog.vala, do not modify */
5
* Copyright (C) 2010-2013 Robert Ancell
7
* This program is free software: you can redistribute it and/or modify it under
8
* the terms of the GNU General Public License as published by the Free Software
9
* Foundation, either version 2 of the License, or (at your option) any later
10
* version. See http://www.gnu.org/copyleft/gpl.html the full text of the
15
#include <glib-object.h>
17
#include <glib/gi18n-lib.h>
20
#include <pango/pango.h>
25
#define TYPE_SCORE_DIALOG (score_dialog_get_type ())
26
#define SCORE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SCORE_DIALOG, ScoreDialog))
27
#define SCORE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SCORE_DIALOG, ScoreDialogClass))
28
#define IS_SCORE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SCORE_DIALOG))
29
#define IS_SCORE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SCORE_DIALOG))
30
#define SCORE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SCORE_DIALOG, ScoreDialogClass))
32
typedef struct _ScoreDialog ScoreDialog;
33
typedef struct _ScoreDialogClass ScoreDialogClass;
34
typedef struct _ScoreDialogPrivate ScoreDialogPrivate;
36
#define TYPE_HISTORY (history_get_type ())
37
#define HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY, History))
38
#define HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY, HistoryClass))
39
#define IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY))
40
#define IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY))
41
#define HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY, HistoryClass))
43
typedef struct _History History;
44
typedef struct _HistoryClass HistoryClass;
46
#define TYPE_HISTORY_ENTRY (history_entry_get_type ())
47
#define HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY_ENTRY, HistoryEntry))
48
#define HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY_ENTRY, HistoryEntryClass))
49
#define IS_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY_ENTRY))
50
#define IS_HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY_ENTRY))
51
#define HISTORY_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY_ENTRY, HistoryEntryClass))
53
typedef struct _HistoryEntry HistoryEntry;
54
typedef struct _HistoryEntryClass HistoryEntryClass;
55
#define _history_unref0(var) ((var == NULL) ? NULL : (var = (history_unref (var), NULL)))
56
#define _history_entry_unref0(var) ((var == NULL) ? NULL : (var = (history_entry_unref (var), NULL)))
57
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
58
typedef struct _HistoryPrivate HistoryPrivate;
59
typedef struct _HistoryEntryPrivate HistoryEntryPrivate;
60
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
61
#define _g_free0(var) (var = (g_free (var), NULL))
62
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
64
#define TYPE_LEVEL_INFO (level_info_get_type ())
65
typedef struct _LevelInfo LevelInfo;
68
GtkDialog parent_instance;
69
ScoreDialogPrivate * priv;
72
struct _ScoreDialogClass {
73
GtkDialogClass parent_class;
76
struct _ScoreDialogPrivate {
78
HistoryEntry* selected_entry;
79
GtkListStore* level_model;
80
GtkListStore* score_model;
81
GtkComboBox* level_combo;
86
GTypeInstance parent_instance;
87
volatile int ref_count;
88
HistoryPrivate * priv;
93
struct _HistoryClass {
94
GTypeClass parent_class;
95
void (*finalize) (History *self);
98
struct _HistoryEntry {
99
GTypeInstance parent_instance;
100
volatile int ref_count;
101
HistoryEntryPrivate * priv;
107
struct _HistoryEntryClass {
108
GTypeClass parent_class;
109
void (*finalize) (HistoryEntry *self);
121
static gpointer score_dialog_parent_class = NULL;
123
GType score_dialog_get_type (void) G_GNUC_CONST;
124
gpointer history_ref (gpointer instance);
125
void history_unref (gpointer instance);
126
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
127
void value_set_history (GValue* value, gpointer v_object);
128
void value_take_history (GValue* value, gpointer v_object);
129
gpointer value_get_history (const GValue* value);
130
GType history_get_type (void) G_GNUC_CONST;
131
gpointer history_entry_ref (gpointer instance);
132
void history_entry_unref (gpointer instance);
133
GParamSpec* param_spec_history_entry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
134
void value_set_history_entry (GValue* value, gpointer v_object);
135
void value_take_history_entry (GValue* value, gpointer v_object);
136
gpointer value_get_history_entry (const GValue* value);
137
GType history_entry_get_type (void) G_GNUC_CONST;
138
#define SCORE_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SCORE_DIALOG, ScoreDialogPrivate))
140
SCORE_DIALOG_DUMMY_PROPERTY
142
ScoreDialog* score_dialog_new (History* history, HistoryEntry* selected_entry, gboolean show_close);
143
ScoreDialog* score_dialog_construct (GType object_type, History* history, HistoryEntry* selected_entry, gboolean show_close);
144
static void score_dialog_entry_added_cb (ScoreDialog* self, HistoryEntry* entry);
145
static void _score_dialog_entry_added_cb_history_entry_added (History* _sender, HistoryEntry* entry, gpointer self);
146
static void score_dialog_level_changed_cb (ScoreDialog* self, GtkComboBox* combo);
147
static void _score_dialog_level_changed_cb_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
148
void score_dialog_set_level (ScoreDialog* self, guint level);
149
static gint score_dialog_compare_entries (HistoryEntry* a, HistoryEntry* b);
150
static gint _score_dialog_compare_entries_gcompare_func (gconstpointer a, gconstpointer b);
151
GType level_info_get_type (void) G_GNUC_CONST;
152
LevelInfo* level_info_dup (const LevelInfo* self);
153
void level_info_free (LevelInfo* self);
154
void level_info_copy (const LevelInfo* self, LevelInfo* dest);
155
void level_info_destroy (LevelInfo* self);
156
static void score_dialog_finalize (GObject* obj);
158
extern const LevelInfo KLOTSKI_level[28];
160
static gpointer _history_ref0 (gpointer self) {
161
return self ? history_ref (self) : NULL;
165
static void _score_dialog_entry_added_cb_history_entry_added (History* _sender, HistoryEntry* entry, gpointer self) {
166
score_dialog_entry_added_cb (self, entry);
170
static gpointer _history_entry_ref0 (gpointer self) {
171
return self ? history_entry_ref (self) : NULL;
175
static void _score_dialog_level_changed_cb_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
176
score_dialog_level_changed_cb (self, _sender);
180
ScoreDialog* score_dialog_construct (GType object_type, History* history, HistoryEntry* selected_entry, gboolean show_close) {
181
ScoreDialog * self = NULL;
182
History* _tmp0_ = NULL;
183
History* _tmp1_ = NULL;
184
History* _tmp2_ = NULL;
185
HistoryEntry* _tmp3_ = NULL;
186
HistoryEntry* _tmp4_ = NULL;
187
gboolean _tmp5_ = FALSE;
189
GtkBox* _tmp9_ = NULL;
190
GtkBox* _tmp10_ = NULL;
191
GtkBox* _tmp11_ = NULL;
192
GtkBox* _tmp12_ = NULL;
193
GtkBox* _tmp13_ = NULL;
195
GtkBox* _tmp14_ = NULL;
196
GtkBox* _tmp15_ = NULL;
197
GtkBox* _tmp16_ = NULL;
198
GtkBox* _tmp17_ = NULL;
199
GtkLabel* label = NULL;
200
const gchar* _tmp18_ = NULL;
201
GtkLabel* _tmp19_ = NULL;
202
GtkLabel* _tmp20_ = NULL;
203
GtkBox* _tmp21_ = NULL;
204
GtkLabel* _tmp22_ = NULL;
205
GtkListStore* _tmp23_ = NULL;
206
GtkComboBox* _tmp24_ = NULL;
207
GtkComboBox* _tmp25_ = NULL;
208
GtkComboBox* _tmp26_ = NULL;
209
GtkListStore* _tmp27_ = NULL;
210
GtkCellRendererText* renderer = NULL;
211
GtkCellRendererText* _tmp28_ = NULL;
212
GtkComboBox* _tmp29_ = NULL;
213
GtkCellRendererText* _tmp30_ = NULL;
214
GtkComboBox* _tmp31_ = NULL;
215
GtkCellRendererText* _tmp32_ = NULL;
216
GtkComboBox* _tmp33_ = NULL;
217
GtkBox* _tmp34_ = NULL;
218
GtkComboBox* _tmp35_ = NULL;
219
GtkScrolledWindow* scroll = NULL;
220
GtkScrolledWindow* _tmp36_ = NULL;
221
GtkScrolledWindow* _tmp37_ = NULL;
222
GtkScrolledWindow* _tmp38_ = NULL;
223
GtkScrolledWindow* _tmp39_ = NULL;
224
GtkBox* _tmp40_ = NULL;
225
GtkScrolledWindow* _tmp41_ = NULL;
226
GtkListStore* _tmp42_ = NULL;
227
GtkTreeView* _tmp43_ = NULL;
228
GtkCellRendererText* _tmp44_ = NULL;
229
GtkTreeView* _tmp45_ = NULL;
230
const gchar* _tmp46_ = NULL;
231
GtkCellRendererText* _tmp47_ = NULL;
232
GtkCellRendererText* _tmp48_ = NULL;
233
GtkCellRendererText* _tmp49_ = NULL;
234
GtkTreeView* _tmp50_ = NULL;
235
const gchar* _tmp51_ = NULL;
236
GtkCellRendererText* _tmp52_ = NULL;
237
GtkTreeView* _tmp53_ = NULL;
238
GtkListStore* _tmp54_ = NULL;
239
GtkTreeView* _tmp55_ = NULL;
240
GtkScrolledWindow* _tmp56_ = NULL;
241
GtkTreeView* _tmp57_ = NULL;
242
History* _tmp58_ = NULL;
243
GList* _tmp59_ = NULL;
244
g_return_val_if_fail (history != NULL, NULL);
245
self = (ScoreDialog*) g_object_new (object_type, NULL);
247
_tmp1_ = _history_ref0 (_tmp0_);
248
_history_unref0 (self->priv->history);
249
self->priv->history = _tmp1_;
251
g_signal_connect_object (_tmp2_, "entry-added", (GCallback) _score_dialog_entry_added_cb_history_entry_added, self, 0);
252
_tmp3_ = selected_entry;
253
_tmp4_ = _history_entry_ref0 (_tmp3_);
254
_history_entry_unref0 (self->priv->selected_entry);
255
self->priv->selected_entry = _tmp4_;
258
const gchar* _tmp6_ = NULL;
259
const gchar* _tmp7_ = NULL;
260
_tmp6_ = _ ("_Close");
261
gtk_dialog_add_button ((GtkDialog*) self, _tmp6_, (gint) GTK_RESPONSE_CLOSE);
262
_tmp7_ = _ ("New Game");
263
gtk_dialog_add_button ((GtkDialog*) self, _tmp7_, (gint) GTK_RESPONSE_OK);
265
const gchar* _tmp8_ = NULL;
267
gtk_dialog_add_button ((GtkDialog*) self, _tmp8_, (gint) GTK_RESPONSE_DELETE_EVENT);
269
gtk_widget_set_size_request ((GtkWidget*) self, 200, 300);
270
_tmp9_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
271
g_object_ref_sink (_tmp9_);
274
gtk_container_set_border_width ((GtkContainer*) _tmp10_, (guint) 6);
276
gtk_widget_show ((GtkWidget*) _tmp11_);
277
_tmp12_ = (GtkBox*) gtk_dialog_get_content_area ((GtkDialog*) self);
279
gtk_box_pack_start (_tmp12_, (GtkWidget*) _tmp13_, TRUE, TRUE, (guint) 0);
280
_tmp14_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
281
g_object_ref_sink (_tmp14_);
284
gtk_widget_show ((GtkWidget*) _tmp15_);
287
gtk_box_pack_start (_tmp16_, (GtkWidget*) _tmp17_, FALSE, FALSE, (guint) 0);
288
_tmp18_ = _ ("Puzzle:");
289
_tmp19_ = (GtkLabel*) gtk_label_new (_tmp18_);
290
g_object_ref_sink (_tmp19_);
293
gtk_widget_show ((GtkWidget*) _tmp20_);
296
gtk_box_pack_start (_tmp21_, (GtkWidget*) _tmp22_, FALSE, FALSE, (guint) 0);
297
_tmp23_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
298
_g_object_unref0 (self->priv->level_model);
299
self->priv->level_model = _tmp23_;
300
_tmp24_ = (GtkComboBox*) gtk_combo_box_new ();
301
g_object_ref_sink (_tmp24_);
302
_g_object_unref0 (self->priv->level_combo);
303
self->priv->level_combo = _tmp24_;
304
_tmp25_ = self->priv->level_combo;
305
g_signal_connect_object (_tmp25_, "changed", (GCallback) _score_dialog_level_changed_cb_gtk_combo_box_changed, self, 0);
306
_tmp26_ = self->priv->level_combo;
307
_tmp27_ = self->priv->level_model;
308
gtk_combo_box_set_model (_tmp26_, (GtkTreeModel*) _tmp27_);
309
_tmp28_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
310
g_object_ref_sink (_tmp28_);
312
_tmp29_ = self->priv->level_combo;
314
gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp29_, (GtkCellRenderer*) _tmp30_, TRUE);
315
_tmp31_ = self->priv->level_combo;
317
gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp31_, (GtkCellRenderer*) _tmp32_, "text", 0);
318
_tmp33_ = self->priv->level_combo;
319
gtk_widget_show ((GtkWidget*) _tmp33_);
321
_tmp35_ = self->priv->level_combo;
322
gtk_box_pack_start (_tmp34_, (GtkWidget*) _tmp35_, TRUE, TRUE, (guint) 0);
323
_tmp36_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
324
g_object_ref_sink (_tmp36_);
327
gtk_scrolled_window_set_shadow_type (_tmp37_, GTK_SHADOW_ETCHED_IN);
329
gtk_scrolled_window_set_policy (_tmp38_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
331
gtk_widget_show ((GtkWidget*) _tmp39_);
334
gtk_box_pack_start (_tmp40_, (GtkWidget*) _tmp41_, TRUE, TRUE, (guint) 0);
335
_tmp42_ = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
336
_g_object_unref0 (self->priv->score_model);
337
self->priv->score_model = _tmp42_;
338
_tmp43_ = (GtkTreeView*) gtk_tree_view_new ();
339
g_object_ref_sink (_tmp43_);
340
_g_object_unref0 (self->priv->scores);
341
self->priv->scores = _tmp43_;
342
_tmp44_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
343
g_object_ref_sink (_tmp44_);
344
_g_object_unref0 (renderer);
346
_tmp45_ = self->priv->scores;
347
_tmp46_ = _ ("Date");
349
gtk_tree_view_insert_column_with_attributes (_tmp45_, -1, _tmp46_, (GtkCellRenderer*) _tmp47_, "text", 0, "weight", 2, NULL);
350
_tmp48_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
351
g_object_ref_sink (_tmp48_);
352
_g_object_unref0 (renderer);
355
g_object_set ((GtkCellRenderer*) _tmp49_, "xalign", 1.0f, NULL);
356
_tmp50_ = self->priv->scores;
357
_tmp51_ = _ ("Moves");
359
gtk_tree_view_insert_column_with_attributes (_tmp50_, -1, _tmp51_, (GtkCellRenderer*) _tmp52_, "text", 1, "weight", 2, NULL);
360
_tmp53_ = self->priv->scores;
361
_tmp54_ = self->priv->score_model;
362
gtk_tree_view_set_model (_tmp53_, (GtkTreeModel*) _tmp54_);
363
_tmp55_ = self->priv->scores;
364
gtk_widget_show ((GtkWidget*) _tmp55_);
366
_tmp57_ = self->priv->scores;
367
gtk_container_add ((GtkContainer*) _tmp56_, (GtkWidget*) _tmp57_);
369
_tmp59_ = _tmp58_->entries;
371
GList* entry_collection = NULL;
372
GList* entry_it = NULL;
373
entry_collection = _tmp59_;
374
for (entry_it = entry_collection; entry_it != NULL; entry_it = entry_it->next) {
375
HistoryEntry* _tmp60_ = NULL;
376
HistoryEntry* entry = NULL;
377
_tmp60_ = _history_entry_ref0 ((HistoryEntry*) entry_it->data);
380
HistoryEntry* _tmp61_ = NULL;
382
score_dialog_entry_added_cb (self, _tmp61_);
383
_history_entry_unref0 (entry);
387
_g_object_unref0 (scroll);
388
_g_object_unref0 (renderer);
389
_g_object_unref0 (label);
390
_g_object_unref0 (hbox);
391
_g_object_unref0 (vbox);
396
ScoreDialog* score_dialog_new (History* history, HistoryEntry* selected_entry, gboolean show_close) {
397
return score_dialog_construct (TYPE_SCORE_DIALOG, history, selected_entry, show_close);
401
static gint _score_dialog_compare_entries_gcompare_func (gconstpointer a, gconstpointer b) {
403
result = score_dialog_compare_entries (a, b);
408
void score_dialog_set_level (ScoreDialog* self, guint level) {
409
GtkListStore* _tmp0_ = NULL;
410
GList* entries = NULL;
411
History* _tmp1_ = NULL;
412
GList* _tmp2_ = NULL;
413
GList* _tmp3_ = NULL;
414
GList* _tmp4_ = NULL;
415
g_return_if_fail (self != NULL);
416
_tmp0_ = self->priv->score_model;
417
gtk_list_store_clear (_tmp0_);
418
_tmp1_ = self->priv->history;
419
_tmp2_ = _tmp1_->entries;
420
_tmp3_ = g_list_copy (_tmp2_);
422
entries = g_list_sort (entries, _score_dialog_compare_entries_gcompare_func);
425
GList* entry_collection = NULL;
426
GList* entry_it = NULL;
427
entry_collection = _tmp4_;
428
for (entry_it = entry_collection; entry_it != NULL; entry_it = entry_it->next) {
429
HistoryEntry* entry = NULL;
430
entry = (HistoryEntry*) entry_it->data;
432
HistoryEntry* _tmp5_ = NULL;
435
gchar* date_label = NULL;
436
HistoryEntry* _tmp8_ = NULL;
437
GDateTime* _tmp9_ = NULL;
438
gchar* _tmp10_ = NULL;
439
gchar* moves_label = NULL;
440
HistoryEntry* _tmp11_ = NULL;
442
gchar* _tmp13_ = NULL;
444
HistoryEntry* _tmp14_ = NULL;
445
HistoryEntry* _tmp15_ = NULL;
446
GtkTreeIter iter = {0};
447
GtkListStore* _tmp16_ = NULL;
448
GtkTreeIter _tmp17_ = {0};
449
GtkListStore* _tmp18_ = NULL;
450
GtkTreeIter _tmp19_ = {0};
451
const gchar* _tmp20_ = NULL;
452
const gchar* _tmp21_ = NULL;
454
HistoryEntry* _tmp23_ = NULL;
455
HistoryEntry* _tmp24_ = NULL;
457
_tmp6_ = _tmp5_->level;
459
if (_tmp6_ != _tmp7_) {
463
_tmp9_ = _tmp8_->date;
464
_tmp10_ = g_date_time_format (_tmp9_, "%d/%m/%Y");
465
date_label = _tmp10_;
467
_tmp12_ = _tmp11_->moves;
468
_tmp13_ = g_strdup_printf ("%u", _tmp12_);
469
moves_label = _tmp13_;
470
weight = (gint) PANGO_WEIGHT_NORMAL;
472
_tmp15_ = self->priv->selected_entry;
473
if (_tmp14_ == _tmp15_) {
474
weight = (gint) PANGO_WEIGHT_BOLD;
476
_tmp16_ = self->priv->score_model;
477
gtk_list_store_append (_tmp16_, &_tmp17_);
479
_tmp18_ = self->priv->score_model;
481
_tmp20_ = date_label;
482
_tmp21_ = moves_label;
484
gtk_list_store_set (_tmp18_, &_tmp19_, 0, _tmp20_, 1, _tmp21_, 2, _tmp22_, -1);
486
_tmp24_ = self->priv->selected_entry;
487
if (_tmp23_ == _tmp24_) {
488
GtkTreeIter piter = {0};
489
GtkTreeIter _tmp25_ = {0};
490
GtkListStore* _tmp26_ = NULL;
491
gboolean _tmp27_ = FALSE;
492
GtkTreeView* _tmp33_ = NULL;
493
GtkListStore* _tmp34_ = NULL;
494
GtkTreeIter _tmp35_ = {0};
495
GtkTreePath* _tmp36_ = NULL;
496
GtkTreePath* _tmp37_ = NULL;
499
_tmp26_ = self->priv->score_model;
500
_tmp27_ = gtk_tree_model_iter_previous ((GtkTreeModel*) _tmp26_, &piter);
502
GtkTreeIter ppiter = {0};
503
GtkTreeIter _tmp28_ = {0};
504
GtkListStore* _tmp29_ = NULL;
505
gboolean _tmp30_ = FALSE;
508
_tmp29_ = self->priv->score_model;
509
_tmp30_ = gtk_tree_model_iter_previous ((GtkTreeModel*) _tmp29_, &ppiter);
511
GtkTreeIter _tmp31_ = {0};
516
GtkTreeIter _tmp32_ = {0};
520
_tmp33_ = self->priv->scores;
521
_tmp34_ = self->priv->score_model;
523
_tmp36_ = gtk_tree_model_get_path ((GtkTreeModel*) _tmp34_, &_tmp35_);
525
gtk_tree_view_scroll_to_cell (_tmp33_, _tmp37_, NULL, FALSE, (gfloat) 0, (gfloat) 0);
526
_gtk_tree_path_free0 (_tmp37_);
528
_g_free0 (moves_label);
529
_g_free0 (date_label);
533
_g_list_free0 (entries);
537
static gint score_dialog_compare_entries (HistoryEntry* a, HistoryEntry* b) {
539
HistoryEntry* _tmp0_ = NULL;
541
HistoryEntry* _tmp2_ = NULL;
543
HistoryEntry* _tmp8_ = NULL;
545
HistoryEntry* _tmp10_ = NULL;
547
HistoryEntry* _tmp16_ = NULL;
548
GDateTime* _tmp17_ = NULL;
549
HistoryEntry* _tmp18_ = NULL;
550
GDateTime* _tmp19_ = NULL;
552
g_return_val_if_fail (a != NULL, 0);
553
g_return_val_if_fail (b != NULL, 0);
555
_tmp1_ = _tmp0_->level;
557
_tmp3_ = _tmp2_->level;
558
if (_tmp1_ != _tmp3_) {
559
HistoryEntry* _tmp4_ = NULL;
561
HistoryEntry* _tmp6_ = NULL;
564
_tmp5_ = _tmp4_->level;
566
_tmp7_ = _tmp6_->level;
567
result = ((gint) _tmp5_) - ((gint) _tmp7_);
571
_tmp9_ = _tmp8_->moves;
573
_tmp11_ = _tmp10_->moves;
574
if (_tmp9_ != _tmp11_) {
575
HistoryEntry* _tmp12_ = NULL;
577
HistoryEntry* _tmp14_ = NULL;
580
_tmp13_ = _tmp12_->moves;
582
_tmp15_ = _tmp14_->moves;
583
result = ((gint) _tmp13_) - ((gint) _tmp15_);
587
_tmp17_ = _tmp16_->date;
589
_tmp19_ = _tmp18_->date;
590
_tmp20_ = g_date_time_compare (_tmp17_, _tmp19_);
596
static void score_dialog_level_changed_cb (ScoreDialog* self, GtkComboBox* combo) {
597
GtkTreeIter iter = {0};
598
GtkComboBox* _tmp0_ = NULL;
599
GtkTreeIter _tmp1_ = {0};
600
gboolean _tmp2_ = FALSE;
602
GtkComboBox* _tmp3_ = NULL;
603
GtkTreeModel* _tmp4_ = NULL;
604
GtkTreeModel* _tmp5_ = NULL;
605
GtkTreeIter _tmp6_ = {0};
607
g_return_if_fail (self != NULL);
608
g_return_if_fail (combo != NULL);
610
_tmp2_ = gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
616
_tmp4_ = gtk_combo_box_get_model (_tmp3_);
619
gtk_tree_model_get (_tmp5_, &_tmp6_, 1, &level, -1);
621
score_dialog_set_level (self, (guint) _tmp7_);
625
static void score_dialog_entry_added_cb (ScoreDialog* self, HistoryEntry* entry) {
626
GtkTreeIter iter = {0};
627
gboolean have_level_entry = FALSE;
628
GtkListStore* _tmp0_ = NULL;
629
GtkTreeIter _tmp1_ = {0};
630
gboolean _tmp2_ = FALSE;
631
gboolean _tmp12_ = FALSE;
632
g_return_if_fail (self != NULL);
633
g_return_if_fail (entry != NULL);
634
have_level_entry = FALSE;
635
_tmp0_ = self->priv->level_model;
636
_tmp2_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp0_, &_tmp1_);
640
gboolean _tmp3_ = FALSE;
643
gboolean _tmp4_ = FALSE;
645
GtkListStore* _tmp7_ = NULL;
646
GtkTreeIter _tmp8_ = {0};
648
HistoryEntry* _tmp10_ = NULL;
652
GtkListStore* _tmp5_ = NULL;
653
gboolean _tmp6_ = FALSE;
654
_tmp5_ = self->priv->level_model;
655
_tmp6_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp5_, &iter);
661
_tmp7_ = self->priv->level_model;
663
gtk_tree_model_get ((GtkTreeModel*) _tmp7_, &_tmp8_, 1, &level, -1);
666
_tmp11_ = _tmp10_->level;
667
if (_tmp9_ == _tmp11_) {
668
have_level_entry = TRUE;
674
_tmp12_ = have_level_entry;
677
HistoryEntry* _tmp13_ = NULL;
679
LevelInfo _tmp15_ = {0};
680
const gchar* _tmp16_ = NULL;
681
const gchar* _tmp17_ = NULL;
682
gchar* _tmp18_ = NULL;
683
GtkListStore* _tmp19_ = NULL;
684
GtkTreeIter _tmp20_ = {0};
685
GtkListStore* _tmp21_ = NULL;
686
GtkTreeIter _tmp22_ = {0};
687
const gchar* _tmp23_ = NULL;
688
HistoryEntry* _tmp24_ = NULL;
690
GtkComboBox* _tmp26_ = NULL;
692
gboolean _tmp30_ = FALSE;
693
HistoryEntry* _tmp31_ = NULL;
694
gboolean _tmp36_ = FALSE;
696
_tmp14_ = _tmp13_->level;
697
_tmp15_ = KLOTSKI_level[_tmp14_];
698
_tmp16_ = _tmp15_.name;
699
_tmp17_ = _ (_tmp16_);
700
_tmp18_ = g_strdup (_tmp17_);
702
_tmp19_ = self->priv->level_model;
703
gtk_list_store_append (_tmp19_, &_tmp20_);
705
_tmp21_ = self->priv->level_model;
709
_tmp25_ = _tmp24_->level;
710
gtk_list_store_set (_tmp21_, &_tmp22_, 0, _tmp23_, 1, _tmp25_, -1, -1);
711
_tmp26_ = self->priv->level_combo;
712
_tmp27_ = gtk_combo_box_get_active (_tmp26_);
713
if (_tmp27_ == (-1)) {
714
GtkComboBox* _tmp28_ = NULL;
715
GtkTreeIter _tmp29_ = {0};
716
_tmp28_ = self->priv->level_combo;
718
gtk_combo_box_set_active_iter (_tmp28_, &_tmp29_);
720
_tmp31_ = self->priv->selected_entry;
721
if (_tmp31_ != NULL) {
722
HistoryEntry* _tmp32_ = NULL;
724
HistoryEntry* _tmp34_ = NULL;
727
_tmp33_ = _tmp32_->level;
728
_tmp34_ = self->priv->selected_entry;
729
_tmp35_ = _tmp34_->level;
730
_tmp30_ = _tmp33_ == _tmp35_;
736
GtkComboBox* _tmp37_ = NULL;
737
GtkTreeIter _tmp38_ = {0};
738
_tmp37_ = self->priv->level_combo;
740
gtk_combo_box_set_active_iter (_tmp37_, &_tmp38_);
747
static void score_dialog_class_init (ScoreDialogClass * klass) {
748
score_dialog_parent_class = g_type_class_peek_parent (klass);
749
g_type_class_add_private (klass, sizeof (ScoreDialogPrivate));
750
G_OBJECT_CLASS (klass)->finalize = score_dialog_finalize;
754
static void score_dialog_instance_init (ScoreDialog * self) {
755
self->priv = SCORE_DIALOG_GET_PRIVATE (self);
756
self->priv->selected_entry = NULL;
760
static void score_dialog_finalize (GObject* obj) {
762
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SCORE_DIALOG, ScoreDialog);
763
_history_unref0 (self->priv->history);
764
_history_entry_unref0 (self->priv->selected_entry);
765
_g_object_unref0 (self->priv->level_model);
766
_g_object_unref0 (self->priv->score_model);
767
_g_object_unref0 (self->priv->level_combo);
768
_g_object_unref0 (self->priv->scores);
769
G_OBJECT_CLASS (score_dialog_parent_class)->finalize (obj);
773
GType score_dialog_get_type (void) {
774
static volatile gsize score_dialog_type_id__volatile = 0;
775
if (g_once_init_enter (&score_dialog_type_id__volatile)) {
776
static const GTypeInfo g_define_type_info = { sizeof (ScoreDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) score_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScoreDialog), 0, (GInstanceInitFunc) score_dialog_instance_init, NULL };
777
GType score_dialog_type_id;
778
score_dialog_type_id = g_type_register_static (GTK_TYPE_DIALOG, "ScoreDialog", &g_define_type_info, 0);
779
g_once_init_leave (&score_dialog_type_id__volatile, score_dialog_type_id);
781
return score_dialog_type_id__volatile;