~ubuntu-branches/debian/sid/gnome-klotski/sid

« back to all changes in this revision

Viewing changes to src/score-dialog.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Jeremy Bicha, Luca Falavigna
  • Date: 2013-06-28 18:43:39 UTC
  • mfrom: (4.1.1)
  • Revision ID: package-import@ubuntu.com-20130628184339-ssxskjm8sphch96e
Tags: 1:3.12.2-1
* Team upload.

[ Jeremy Bicha ]
* Update homepage

[ Luca Falavigna ]
* New upstream release.
* debian/control.in:
  - Bump Standards-Version to 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* score-dialog.c generated by valac 0.22.1, the Vala compiler
 
2
 * generated from score-dialog.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2010-2013 Robert Ancell
 
6
 *
 
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
 
11
 * license.
 
12
 */
 
13
 
 
14
#include <glib.h>
 
15
#include <glib-object.h>
 
16
#include <gtk/gtk.h>
 
17
#include <glib/gi18n-lib.h>
 
18
#include <stdlib.h>
 
19
#include <string.h>
 
20
#include <pango/pango.h>
 
21
#include <float.h>
 
22
#include <math.h>
 
23
 
 
24
 
 
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))
 
31
 
 
32
typedef struct _ScoreDialog ScoreDialog;
 
33
typedef struct _ScoreDialogClass ScoreDialogClass;
 
34
typedef struct _ScoreDialogPrivate ScoreDialogPrivate;
 
35
 
 
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))
 
42
 
 
43
typedef struct _History History;
 
44
typedef struct _HistoryClass HistoryClass;
 
45
 
 
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))
 
52
 
 
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)))
 
63
 
 
64
#define TYPE_LEVEL_INFO (level_info_get_type ())
 
65
typedef struct _LevelInfo LevelInfo;
 
66
 
 
67
struct _ScoreDialog {
 
68
        GtkDialog parent_instance;
 
69
        ScoreDialogPrivate * priv;
 
70
};
 
71
 
 
72
struct _ScoreDialogClass {
 
73
        GtkDialogClass parent_class;
 
74
};
 
75
 
 
76
struct _ScoreDialogPrivate {
 
77
        History* history;
 
78
        HistoryEntry* selected_entry;
 
79
        GtkListStore* level_model;
 
80
        GtkListStore* score_model;
 
81
        GtkComboBox* level_combo;
 
82
        GtkTreeView* scores;
 
83
};
 
84
 
 
85
struct _History {
 
86
        GTypeInstance parent_instance;
 
87
        volatile int ref_count;
 
88
        HistoryPrivate * priv;
 
89
        gchar* filename;
 
90
        GList* entries;
 
91
};
 
92
 
 
93
struct _HistoryClass {
 
94
        GTypeClass parent_class;
 
95
        void (*finalize) (History *self);
 
96
};
 
97
 
 
98
struct _HistoryEntry {
 
99
        GTypeInstance parent_instance;
 
100
        volatile int ref_count;
 
101
        HistoryEntryPrivate * priv;
 
102
        GDateTime* date;
 
103
        guint level;
 
104
        guint moves;
 
105
};
 
106
 
 
107
struct _HistoryEntryClass {
 
108
        GTypeClass parent_class;
 
109
        void (*finalize) (HistoryEntry *self);
 
110
};
 
111
 
 
112
struct _LevelInfo {
 
113
        gchar* name;
 
114
        gint group;
 
115
        gint width;
 
116
        gint height;
 
117
        gchar* data;
 
118
};
 
119
 
 
120
 
 
121
static gpointer score_dialog_parent_class = NULL;
 
122
 
 
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))
 
139
enum  {
 
140
        SCORE_DIALOG_DUMMY_PROPERTY
 
141
};
 
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);
 
157
 
 
158
extern const LevelInfo KLOTSKI_level[28];
 
159
 
 
160
static gpointer _history_ref0 (gpointer self) {
 
161
        return self ? history_ref (self) : NULL;
 
162
}
 
163
 
 
164
 
 
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);
 
167
}
 
168
 
 
169
 
 
170
static gpointer _history_entry_ref0 (gpointer self) {
 
171
        return self ? history_entry_ref (self) : NULL;
 
172
}
 
173
 
 
174
 
 
175
static void _score_dialog_level_changed_cb_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
 
176
        score_dialog_level_changed_cb (self, _sender);
 
177
}
 
178
 
 
179
 
 
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;
 
188
        GtkBox* vbox = NULL;
 
189
        GtkBox* _tmp9_ = NULL;
 
190
        GtkBox* _tmp10_ = NULL;
 
191
        GtkBox* _tmp11_ = NULL;
 
192
        GtkBox* _tmp12_ = NULL;
 
193
        GtkBox* _tmp13_ = NULL;
 
194
        GtkBox* hbox = 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);
 
246
        _tmp0_ = history;
 
247
        _tmp1_ = _history_ref0 (_tmp0_);
 
248
        _history_unref0 (self->priv->history);
 
249
        self->priv->history = _tmp1_;
 
250
        _tmp2_ = history;
 
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_;
 
256
        _tmp5_ = show_close;
 
257
        if (_tmp5_) {
 
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);
 
264
        } else {
 
265
                const gchar* _tmp8_ = NULL;
 
266
                _tmp8_ = _ ("_OK");
 
267
                gtk_dialog_add_button ((GtkDialog*) self, _tmp8_, (gint) GTK_RESPONSE_DELETE_EVENT);
 
268
        }
 
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_);
 
272
        vbox = _tmp9_;
 
273
        _tmp10_ = vbox;
 
274
        gtk_container_set_border_width ((GtkContainer*) _tmp10_, (guint) 6);
 
275
        _tmp11_ = vbox;
 
276
        gtk_widget_show ((GtkWidget*) _tmp11_);
 
277
        _tmp12_ = (GtkBox*) gtk_dialog_get_content_area ((GtkDialog*) self);
 
278
        _tmp13_ = vbox;
 
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_);
 
282
        hbox = _tmp14_;
 
283
        _tmp15_ = hbox;
 
284
        gtk_widget_show ((GtkWidget*) _tmp15_);
 
285
        _tmp16_ = vbox;
 
286
        _tmp17_ = hbox;
 
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_);
 
291
        label = _tmp19_;
 
292
        _tmp20_ = label;
 
293
        gtk_widget_show ((GtkWidget*) _tmp20_);
 
294
        _tmp21_ = hbox;
 
295
        _tmp22_ = label;
 
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_);
 
311
        renderer = _tmp28_;
 
312
        _tmp29_ = self->priv->level_combo;
 
313
        _tmp30_ = renderer;
 
314
        gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp29_, (GtkCellRenderer*) _tmp30_, TRUE);
 
315
        _tmp31_ = self->priv->level_combo;
 
316
        _tmp32_ = renderer;
 
317
        gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp31_, (GtkCellRenderer*) _tmp32_, "text", 0);
 
318
        _tmp33_ = self->priv->level_combo;
 
319
        gtk_widget_show ((GtkWidget*) _tmp33_);
 
320
        _tmp34_ = hbox;
 
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_);
 
325
        scroll = _tmp36_;
 
326
        _tmp37_ = scroll;
 
327
        gtk_scrolled_window_set_shadow_type (_tmp37_, GTK_SHADOW_ETCHED_IN);
 
328
        _tmp38_ = scroll;
 
329
        gtk_scrolled_window_set_policy (_tmp38_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
330
        _tmp39_ = scroll;
 
331
        gtk_widget_show ((GtkWidget*) _tmp39_);
 
332
        _tmp40_ = vbox;
 
333
        _tmp41_ = scroll;
 
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);
 
345
        renderer = _tmp44_;
 
346
        _tmp45_ = self->priv->scores;
 
347
        _tmp46_ = _ ("Date");
 
348
        _tmp47_ = renderer;
 
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);
 
353
        renderer = _tmp48_;
 
354
        _tmp49_ = renderer;
 
355
        g_object_set ((GtkCellRenderer*) _tmp49_, "xalign", 1.0f, NULL);
 
356
        _tmp50_ = self->priv->scores;
 
357
        _tmp51_ = _ ("Moves");
 
358
        _tmp52_ = renderer;
 
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_);
 
365
        _tmp56_ = scroll;
 
366
        _tmp57_ = self->priv->scores;
 
367
        gtk_container_add ((GtkContainer*) _tmp56_, (GtkWidget*) _tmp57_);
 
368
        _tmp58_ = history;
 
369
        _tmp59_ = _tmp58_->entries;
 
370
        {
 
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);
 
378
                        entry = _tmp60_;
 
379
                        {
 
380
                                HistoryEntry* _tmp61_ = NULL;
 
381
                                _tmp61_ = entry;
 
382
                                score_dialog_entry_added_cb (self, _tmp61_);
 
383
                                _history_entry_unref0 (entry);
 
384
                        }
 
385
                }
 
386
        }
 
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);
 
392
        return self;
 
393
}
 
394
 
 
395
 
 
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);
 
398
}
 
399
 
 
400
 
 
401
static gint _score_dialog_compare_entries_gcompare_func (gconstpointer a, gconstpointer b) {
 
402
        gint result;
 
403
        result = score_dialog_compare_entries (a, b);
 
404
        return result;
 
405
}
 
406
 
 
407
 
 
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_);
 
421
        entries = _tmp3_;
 
422
        entries = g_list_sort (entries, _score_dialog_compare_entries_gcompare_func);
 
423
        _tmp4_ = entries;
 
424
        {
 
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;
 
431
                        {
 
432
                                HistoryEntry* _tmp5_ = NULL;
 
433
                                guint _tmp6_ = 0U;
 
434
                                guint _tmp7_ = 0U;
 
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;
 
441
                                guint _tmp12_ = 0U;
 
442
                                gchar* _tmp13_ = NULL;
 
443
                                gint weight = 0;
 
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;
 
453
                                gint _tmp22_ = 0;
 
454
                                HistoryEntry* _tmp23_ = NULL;
 
455
                                HistoryEntry* _tmp24_ = NULL;
 
456
                                _tmp5_ = entry;
 
457
                                _tmp6_ = _tmp5_->level;
 
458
                                _tmp7_ = level;
 
459
                                if (_tmp6_ != _tmp7_) {
 
460
                                        continue;
 
461
                                }
 
462
                                _tmp8_ = entry;
 
463
                                _tmp9_ = _tmp8_->date;
 
464
                                _tmp10_ = g_date_time_format (_tmp9_, "%d/%m/%Y");
 
465
                                date_label = _tmp10_;
 
466
                                _tmp11_ = entry;
 
467
                                _tmp12_ = _tmp11_->moves;
 
468
                                _tmp13_ = g_strdup_printf ("%u", _tmp12_);
 
469
                                moves_label = _tmp13_;
 
470
                                weight = (gint) PANGO_WEIGHT_NORMAL;
 
471
                                _tmp14_ = entry;
 
472
                                _tmp15_ = self->priv->selected_entry;
 
473
                                if (_tmp14_ == _tmp15_) {
 
474
                                        weight = (gint) PANGO_WEIGHT_BOLD;
 
475
                                }
 
476
                                _tmp16_ = self->priv->score_model;
 
477
                                gtk_list_store_append (_tmp16_, &_tmp17_);
 
478
                                iter = _tmp17_;
 
479
                                _tmp18_ = self->priv->score_model;
 
480
                                _tmp19_ = iter;
 
481
                                _tmp20_ = date_label;
 
482
                                _tmp21_ = moves_label;
 
483
                                _tmp22_ = weight;
 
484
                                gtk_list_store_set (_tmp18_, &_tmp19_, 0, _tmp20_, 1, _tmp21_, 2, _tmp22_, -1);
 
485
                                _tmp23_ = entry;
 
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;
 
497
                                        _tmp25_ = iter;
 
498
                                        piter = _tmp25_;
 
499
                                        _tmp26_ = self->priv->score_model;
 
500
                                        _tmp27_ = gtk_tree_model_iter_previous ((GtkTreeModel*) _tmp26_, &piter);
 
501
                                        if (_tmp27_) {
 
502
                                                GtkTreeIter ppiter = {0};
 
503
                                                GtkTreeIter _tmp28_ = {0};
 
504
                                                GtkListStore* _tmp29_ = NULL;
 
505
                                                gboolean _tmp30_ = FALSE;
 
506
                                                _tmp28_ = piter;
 
507
                                                ppiter = _tmp28_;
 
508
                                                _tmp29_ = self->priv->score_model;
 
509
                                                _tmp30_ = gtk_tree_model_iter_previous ((GtkTreeModel*) _tmp29_, &ppiter);
 
510
                                                if (_tmp30_) {
 
511
                                                        GtkTreeIter _tmp31_ = {0};
 
512
                                                        _tmp31_ = ppiter;
 
513
                                                        piter = _tmp31_;
 
514
                                                }
 
515
                                        } else {
 
516
                                                GtkTreeIter _tmp32_ = {0};
 
517
                                                _tmp32_ = iter;
 
518
                                                piter = _tmp32_;
 
519
                                        }
 
520
                                        _tmp33_ = self->priv->scores;
 
521
                                        _tmp34_ = self->priv->score_model;
 
522
                                        _tmp35_ = piter;
 
523
                                        _tmp36_ = gtk_tree_model_get_path ((GtkTreeModel*) _tmp34_, &_tmp35_);
 
524
                                        _tmp37_ = _tmp36_;
 
525
                                        gtk_tree_view_scroll_to_cell (_tmp33_, _tmp37_, NULL, FALSE, (gfloat) 0, (gfloat) 0);
 
526
                                        _gtk_tree_path_free0 (_tmp37_);
 
527
                                }
 
528
                                _g_free0 (moves_label);
 
529
                                _g_free0 (date_label);
 
530
                        }
 
531
                }
 
532
        }
 
533
        _g_list_free0 (entries);
 
534
}
 
535
 
 
536
 
 
537
static gint score_dialog_compare_entries (HistoryEntry* a, HistoryEntry* b) {
 
538
        gint result = 0;
 
539
        HistoryEntry* _tmp0_ = NULL;
 
540
        guint _tmp1_ = 0U;
 
541
        HistoryEntry* _tmp2_ = NULL;
 
542
        guint _tmp3_ = 0U;
 
543
        HistoryEntry* _tmp8_ = NULL;
 
544
        guint _tmp9_ = 0U;
 
545
        HistoryEntry* _tmp10_ = NULL;
 
546
        guint _tmp11_ = 0U;
 
547
        HistoryEntry* _tmp16_ = NULL;
 
548
        GDateTime* _tmp17_ = NULL;
 
549
        HistoryEntry* _tmp18_ = NULL;
 
550
        GDateTime* _tmp19_ = NULL;
 
551
        gint _tmp20_ = 0;
 
552
        g_return_val_if_fail (a != NULL, 0);
 
553
        g_return_val_if_fail (b != NULL, 0);
 
554
        _tmp0_ = a;
 
555
        _tmp1_ = _tmp0_->level;
 
556
        _tmp2_ = b;
 
557
        _tmp3_ = _tmp2_->level;
 
558
        if (_tmp1_ != _tmp3_) {
 
559
                HistoryEntry* _tmp4_ = NULL;
 
560
                guint _tmp5_ = 0U;
 
561
                HistoryEntry* _tmp6_ = NULL;
 
562
                guint _tmp7_ = 0U;
 
563
                _tmp4_ = a;
 
564
                _tmp5_ = _tmp4_->level;
 
565
                _tmp6_ = b;
 
566
                _tmp7_ = _tmp6_->level;
 
567
                result = ((gint) _tmp5_) - ((gint) _tmp7_);
 
568
                return result;
 
569
        }
 
570
        _tmp8_ = a;
 
571
        _tmp9_ = _tmp8_->moves;
 
572
        _tmp10_ = b;
 
573
        _tmp11_ = _tmp10_->moves;
 
574
        if (_tmp9_ != _tmp11_) {
 
575
                HistoryEntry* _tmp12_ = NULL;
 
576
                guint _tmp13_ = 0U;
 
577
                HistoryEntry* _tmp14_ = NULL;
 
578
                guint _tmp15_ = 0U;
 
579
                _tmp12_ = a;
 
580
                _tmp13_ = _tmp12_->moves;
 
581
                _tmp14_ = b;
 
582
                _tmp15_ = _tmp14_->moves;
 
583
                result = ((gint) _tmp13_) - ((gint) _tmp15_);
 
584
                return result;
 
585
        }
 
586
        _tmp16_ = a;
 
587
        _tmp17_ = _tmp16_->date;
 
588
        _tmp18_ = b;
 
589
        _tmp19_ = _tmp18_->date;
 
590
        _tmp20_ = g_date_time_compare (_tmp17_, _tmp19_);
 
591
        result = _tmp20_;
 
592
        return result;
 
593
}
 
594
 
 
595
 
 
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;
 
601
        gint level = 0;
 
602
        GtkComboBox* _tmp3_ = NULL;
 
603
        GtkTreeModel* _tmp4_ = NULL;
 
604
        GtkTreeModel* _tmp5_ = NULL;
 
605
        GtkTreeIter _tmp6_ = {0};
 
606
        gint _tmp7_ = 0;
 
607
        g_return_if_fail (self != NULL);
 
608
        g_return_if_fail (combo != NULL);
 
609
        _tmp0_ = combo;
 
610
        _tmp2_ = gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
 
611
        iter = _tmp1_;
 
612
        if (!_tmp2_) {
 
613
                return;
 
614
        }
 
615
        _tmp3_ = combo;
 
616
        _tmp4_ = gtk_combo_box_get_model (_tmp3_);
 
617
        _tmp5_ = _tmp4_;
 
618
        _tmp6_ = iter;
 
619
        gtk_tree_model_get (_tmp5_, &_tmp6_, 1, &level, -1);
 
620
        _tmp7_ = level;
 
621
        score_dialog_set_level (self, (guint) _tmp7_);
 
622
}
 
623
 
 
624
 
 
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_);
 
637
        iter = _tmp1_;
 
638
        if (_tmp2_) {
 
639
                {
 
640
                        gboolean _tmp3_ = FALSE;
 
641
                        _tmp3_ = TRUE;
 
642
                        while (TRUE) {
 
643
                                gboolean _tmp4_ = FALSE;
 
644
                                guint level = 0U;
 
645
                                GtkListStore* _tmp7_ = NULL;
 
646
                                GtkTreeIter _tmp8_ = {0};
 
647
                                guint _tmp9_ = 0U;
 
648
                                HistoryEntry* _tmp10_ = NULL;
 
649
                                guint _tmp11_ = 0U;
 
650
                                _tmp4_ = _tmp3_;
 
651
                                if (!_tmp4_) {
 
652
                                        GtkListStore* _tmp5_ = NULL;
 
653
                                        gboolean _tmp6_ = FALSE;
 
654
                                        _tmp5_ = self->priv->level_model;
 
655
                                        _tmp6_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp5_, &iter);
 
656
                                        if (!_tmp6_) {
 
657
                                                break;
 
658
                                        }
 
659
                                }
 
660
                                _tmp3_ = FALSE;
 
661
                                _tmp7_ = self->priv->level_model;
 
662
                                _tmp8_ = iter;
 
663
                                gtk_tree_model_get ((GtkTreeModel*) _tmp7_, &_tmp8_, 1, &level, -1);
 
664
                                _tmp9_ = level;
 
665
                                _tmp10_ = entry;
 
666
                                _tmp11_ = _tmp10_->level;
 
667
                                if (_tmp9_ == _tmp11_) {
 
668
                                        have_level_entry = TRUE;
 
669
                                        break;
 
670
                                }
 
671
                        }
 
672
                }
 
673
        }
 
674
        _tmp12_ = have_level_entry;
 
675
        if (!_tmp12_) {
 
676
                gchar* label = NULL;
 
677
                HistoryEntry* _tmp13_ = NULL;
 
678
                guint _tmp14_ = 0U;
 
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;
 
689
                guint _tmp25_ = 0U;
 
690
                GtkComboBox* _tmp26_ = NULL;
 
691
                gint _tmp27_ = 0;
 
692
                gboolean _tmp30_ = FALSE;
 
693
                HistoryEntry* _tmp31_ = NULL;
 
694
                gboolean _tmp36_ = FALSE;
 
695
                _tmp13_ = entry;
 
696
                _tmp14_ = _tmp13_->level;
 
697
                _tmp15_ = KLOTSKI_level[_tmp14_];
 
698
                _tmp16_ = _tmp15_.name;
 
699
                _tmp17_ = _ (_tmp16_);
 
700
                _tmp18_ = g_strdup (_tmp17_);
 
701
                label = _tmp18_;
 
702
                _tmp19_ = self->priv->level_model;
 
703
                gtk_list_store_append (_tmp19_, &_tmp20_);
 
704
                iter = _tmp20_;
 
705
                _tmp21_ = self->priv->level_model;
 
706
                _tmp22_ = iter;
 
707
                _tmp23_ = label;
 
708
                _tmp24_ = entry;
 
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;
 
717
                        _tmp29_ = iter;
 
718
                        gtk_combo_box_set_active_iter (_tmp28_, &_tmp29_);
 
719
                }
 
720
                _tmp31_ = self->priv->selected_entry;
 
721
                if (_tmp31_ != NULL) {
 
722
                        HistoryEntry* _tmp32_ = NULL;
 
723
                        guint _tmp33_ = 0U;
 
724
                        HistoryEntry* _tmp34_ = NULL;
 
725
                        guint _tmp35_ = 0U;
 
726
                        _tmp32_ = entry;
 
727
                        _tmp33_ = _tmp32_->level;
 
728
                        _tmp34_ = self->priv->selected_entry;
 
729
                        _tmp35_ = _tmp34_->level;
 
730
                        _tmp30_ = _tmp33_ == _tmp35_;
 
731
                } else {
 
732
                        _tmp30_ = FALSE;
 
733
                }
 
734
                _tmp36_ = _tmp30_;
 
735
                if (_tmp36_) {
 
736
                        GtkComboBox* _tmp37_ = NULL;
 
737
                        GtkTreeIter _tmp38_ = {0};
 
738
                        _tmp37_ = self->priv->level_combo;
 
739
                        _tmp38_ = iter;
 
740
                        gtk_combo_box_set_active_iter (_tmp37_, &_tmp38_);
 
741
                }
 
742
                _g_free0 (label);
 
743
        }
 
744
}
 
745
 
 
746
 
 
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;
 
751
}
 
752
 
 
753
 
 
754
static void score_dialog_instance_init (ScoreDialog * self) {
 
755
        self->priv = SCORE_DIALOG_GET_PRIVATE (self);
 
756
        self->priv->selected_entry = NULL;
 
757
}
 
758
 
 
759
 
 
760
static void score_dialog_finalize (GObject* obj) {
 
761
        ScoreDialog * self;
 
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);
 
770
}
 
771
 
 
772
 
 
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);
 
780
        }
 
781
        return score_dialog_type_id__volatile;
 
782
}
 
783
 
 
784
 
 
785