1
/* glchess.c generated by valac 0.12.0, the Vala compiler
2
* generated from glchess.vala, do not modify */
4
/* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=647122 */
7
#include <glib-object.h>
13
#include <glib/gi18n-lib.h>
20
#include <gobject/gvaluecollector.h>
23
#define TYPE_APPLICATION (application_get_type ())
24
#define APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APPLICATION, Application))
25
#define APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APPLICATION, ApplicationClass))
26
#define IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APPLICATION))
27
#define IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APPLICATION))
28
#define APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APPLICATION, ApplicationClass))
30
typedef struct _Application Application;
31
typedef struct _ApplicationClass ApplicationClass;
32
typedef struct _ApplicationPrivate ApplicationPrivate;
34
#define TYPE_HISTORY (history_get_type ())
35
#define HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY, History))
36
#define HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY, HistoryClass))
37
#define IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY))
38
#define IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY))
39
#define HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY, HistoryClass))
41
typedef struct _History History;
42
typedef struct _HistoryClass HistoryClass;
44
#define TYPE_CHESS_SCENE (chess_scene_get_type ())
45
#define CHESS_SCENE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_SCENE, ChessScene))
46
#define CHESS_SCENE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_SCENE, ChessSceneClass))
47
#define IS_CHESS_SCENE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_SCENE))
48
#define IS_CHESS_SCENE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_SCENE))
49
#define CHESS_SCENE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_SCENE, ChessSceneClass))
51
typedef struct _ChessScene ChessScene;
52
typedef struct _ChessSceneClass ChessSceneClass;
54
#define TYPE_CHESS_VIEW (chess_view_get_type ())
55
#define CHESS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_VIEW, ChessView))
56
#define CHESS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_VIEW, ChessViewClass))
57
#define IS_CHESS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_VIEW))
58
#define IS_CHESS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_VIEW))
59
#define CHESS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_VIEW, ChessViewClass))
61
typedef struct _ChessView ChessView;
62
typedef struct _ChessViewClass ChessViewClass;
64
#define TYPE_PGN_GAME (pgn_game_get_type ())
65
#define PGN_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PGN_GAME, PGNGame))
66
#define PGN_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PGN_GAME, PGNGameClass))
67
#define IS_PGN_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PGN_GAME))
68
#define IS_PGN_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PGN_GAME))
69
#define PGN_GAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PGN_GAME, PGNGameClass))
71
typedef struct _PGNGame PGNGame;
72
typedef struct _PGNGameClass PGNGameClass;
74
#define TYPE_CHESS_GAME (chess_game_get_type ())
75
#define CHESS_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_GAME, ChessGame))
76
#define CHESS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_GAME, ChessGameClass))
77
#define IS_CHESS_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_GAME))
78
#define IS_CHESS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_GAME))
79
#define CHESS_GAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_GAME, ChessGameClass))
81
typedef struct _ChessGame ChessGame;
82
typedef struct _ChessGameClass ChessGameClass;
84
#define TYPE_AI_PROFILE (ai_profile_get_type ())
85
#define AI_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AI_PROFILE, AIProfile))
86
#define AI_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AI_PROFILE, AIProfileClass))
87
#define IS_AI_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AI_PROFILE))
88
#define IS_AI_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AI_PROFILE))
89
#define AI_PROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AI_PROFILE, AIProfileClass))
91
typedef struct _AIProfile AIProfile;
92
typedef struct _AIProfileClass AIProfileClass;
94
#define TYPE_CHESS_PLAYER (chess_player_get_type ())
95
#define CHESS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_PLAYER, ChessPlayer))
96
#define CHESS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_PLAYER, ChessPlayerClass))
97
#define IS_CHESS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_PLAYER))
98
#define IS_CHESS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_PLAYER))
99
#define CHESS_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_PLAYER, ChessPlayerClass))
101
typedef struct _ChessPlayer ChessPlayer;
102
typedef struct _ChessPlayerClass ChessPlayerClass;
104
#define TYPE_CHESS_ENGINE (chess_engine_get_type ())
105
#define CHESS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_ENGINE, ChessEngine))
106
#define CHESS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_ENGINE, ChessEngineClass))
107
#define IS_CHESS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_ENGINE))
108
#define IS_CHESS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_ENGINE))
109
#define CHESS_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_ENGINE, ChessEngineClass))
111
typedef struct _ChessEngine ChessEngine;
112
typedef struct _ChessEngineClass ChessEngineClass;
113
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
114
#define _history_unref0(var) ((var == NULL) ? NULL : (var = (history_unref (var), NULL)))
115
#define _pgn_game_unref0(var) ((var == NULL) ? NULL : (var = (pgn_game_unref (var), NULL)))
116
#define _chess_game_unref0(var) ((var == NULL) ? NULL : (var = (chess_game_unref (var), NULL)))
117
#define __g_list_free__ai_profile_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__ai_profile_unref0_ (var), NULL)))
118
#define _g_free0(var) (var = (g_free (var), NULL))
119
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
121
#define TYPE_CHESS_VIEW3_D (chess_view3_d_get_type ())
122
#define CHESS_VIEW3_D(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_VIEW3_D, ChessView3D))
123
#define CHESS_VIEW3_D_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_VIEW3_D, ChessView3DClass))
124
#define IS_CHESS_VIEW3_D(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_VIEW3_D))
125
#define IS_CHESS_VIEW3_D_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_VIEW3_D))
126
#define CHESS_VIEW3_D_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_VIEW3_D, ChessView3DClass))
128
typedef struct _ChessView3D ChessView3D;
129
typedef struct _ChessView3DClass ChessView3DClass;
131
#define TYPE_CHESS_VIEW2_D (chess_view2_d_get_type ())
132
#define CHESS_VIEW2_D(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_VIEW2_D, ChessView2D))
133
#define CHESS_VIEW2_D_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_VIEW2_D, ChessView2DClass))
134
#define IS_CHESS_VIEW2_D(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_VIEW2_D))
135
#define IS_CHESS_VIEW2_D_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_VIEW2_D))
136
#define CHESS_VIEW2_D_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_VIEW2_D, ChessView2DClass))
138
typedef struct _ChessView2D ChessView2D;
139
typedef struct _ChessView2DClass ChessView2DClass;
140
typedef struct _ChessGamePrivate ChessGamePrivate;
142
#define TYPE_CHESS_RESULT (chess_result_get_type ())
144
#define TYPE_CHESS_RULE (chess_rule_get_type ())
146
#define TYPE_CHESS_STATE (chess_state_get_type ())
147
#define CHESS_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_STATE, ChessState))
148
#define CHESS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_STATE, ChessStateClass))
149
#define IS_CHESS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_STATE))
150
#define IS_CHESS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_STATE))
151
#define CHESS_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_STATE, ChessStateClass))
153
typedef struct _ChessState ChessState;
154
typedef struct _ChessStateClass ChessStateClass;
155
typedef struct _ChessStatePrivate ChessStatePrivate;
157
#define TYPE_CHECK_STATE (check_state_get_type ())
159
#define TYPE_CHESS_PIECE (chess_piece_get_type ())
160
#define CHESS_PIECE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_PIECE, ChessPiece))
161
#define CHESS_PIECE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_PIECE, ChessPieceClass))
162
#define IS_CHESS_PIECE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_PIECE))
163
#define IS_CHESS_PIECE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_PIECE))
164
#define CHESS_PIECE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_PIECE, ChessPieceClass))
166
typedef struct _ChessPiece ChessPiece;
167
typedef struct _ChessPieceClass ChessPieceClass;
169
#define TYPE_CHESS_MOVE (chess_move_get_type ())
170
#define CHESS_MOVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_MOVE, ChessMove))
171
#define CHESS_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_MOVE, ChessMoveClass))
172
#define IS_CHESS_MOVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_MOVE))
173
#define IS_CHESS_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_MOVE))
174
#define CHESS_MOVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_MOVE, ChessMoveClass))
176
typedef struct _ChessMove ChessMove;
177
typedef struct _ChessMoveClass ChessMoveClass;
178
#define _chess_state_unref0(var) ((var == NULL) ? NULL : (var = (chess_state_unref (var), NULL)))
179
typedef struct _PGNGamePrivate PGNGamePrivate;
181
#define TYPE_CHESS_CLOCK (chess_clock_get_type ())
182
#define CHESS_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_CLOCK, ChessClock))
183
#define CHESS_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_CLOCK, ChessClockClass))
184
#define IS_CHESS_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_CLOCK))
185
#define IS_CHESS_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_CLOCK))
186
#define CHESS_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_CLOCK, ChessClockClass))
188
typedef struct _ChessClock ChessClock;
189
typedef struct _ChessClockClass ChessClockClass;
190
#define _ai_profile_unref0(var) ((var == NULL) ? NULL : (var = (ai_profile_unref (var), NULL)))
191
typedef struct _AIProfilePrivate AIProfilePrivate;
193
#define TYPE_CHESS_ENGINE_CECP (chess_engine_cecp_get_type ())
194
#define CHESS_ENGINE_CECP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_ENGINE_CECP, ChessEngineCECP))
195
#define CHESS_ENGINE_CECP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_ENGINE_CECP, ChessEngineCECPClass))
196
#define IS_CHESS_ENGINE_CECP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_ENGINE_CECP))
197
#define IS_CHESS_ENGINE_CECP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_ENGINE_CECP))
198
#define CHESS_ENGINE_CECP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_ENGINE_CECP, ChessEngineCECPClass))
200
typedef struct _ChessEngineCECP ChessEngineCECP;
201
typedef struct _ChessEngineCECPClass ChessEngineCECPClass;
203
#define TYPE_CHESS_ENGINE_UCI (chess_engine_uci_get_type ())
204
#define CHESS_ENGINE_UCI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_ENGINE_UCI, ChessEngineUCI))
205
#define CHESS_ENGINE_UCI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_ENGINE_UCI, ChessEngineUCIClass))
206
#define IS_CHESS_ENGINE_UCI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_ENGINE_UCI))
207
#define IS_CHESS_ENGINE_UCI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_ENGINE_UCI))
208
#define CHESS_ENGINE_UCI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_ENGINE_UCI, ChessEngineUCIClass))
210
typedef struct _ChessEngineUCI ChessEngineUCI;
211
typedef struct _ChessEngineUCIClass ChessEngineUCIClass;
212
typedef struct _ChessEnginePrivate ChessEnginePrivate;
213
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
214
typedef struct _ChessMovePrivate ChessMovePrivate;
215
typedef struct _ChessPiecePrivate ChessPiecePrivate;
217
#define TYPE_PIECE_TYPE (piece_type_get_type ())
218
typedef struct _ChessPlayerPrivate ChessPlayerPrivate;
220
#define TYPE_COLOR (color_get_type ())
221
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
223
#define TYPE_PGN (pgn_get_type ())
224
#define PGN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PGN, PGN))
225
#define PGN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PGN, PGNClass))
226
#define IS_PGN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PGN))
227
#define IS_PGN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PGN))
228
#define PGN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PGN, PGNClass))
230
typedef struct _PGN PGN;
231
typedef struct _PGNClass PGNClass;
232
typedef struct _PGNPrivate PGNPrivate;
233
#define _pgn_unref0(var) ((var == NULL) ? NULL : (var = (pgn_unref (var), NULL)))
234
typedef struct _ParamSpecApplication ParamSpecApplication;
236
#define TYPE_GL_CHESS (gl_chess_get_type ())
237
#define GL_CHESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GL_CHESS, GlChess))
238
#define GL_CHESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GL_CHESS, GlChessClass))
239
#define IS_GL_CHESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GL_CHESS))
240
#define IS_GL_CHESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GL_CHESS))
241
#define GL_CHESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GL_CHESS, GlChessClass))
243
typedef struct _GlChess GlChess;
244
typedef struct _GlChessClass GlChessClass;
245
typedef struct _GlChessPrivate GlChessPrivate;
246
#define _application_unref0(var) ((var == NULL) ? NULL : (var = (application_unref (var), NULL)))
247
typedef struct _ParamSpecGlChess ParamSpecGlChess;
249
struct _Application {
250
GTypeInstance parent_instance;
251
volatile int ref_count;
252
ApplicationPrivate * priv;
255
struct _ApplicationClass {
256
GTypeClass parent_class;
257
void (*finalize) (Application *self);
260
struct _ApplicationPrivate {
264
GtkBuilder* preferences_builder;
266
GtkWidget* save_menu;
267
GtkWidget* save_as_menu;
268
GtkMenuItem* fullscreen_menu;
269
GtkInfoBar* info_bar;
270
GtkLabel* info_title_label;
271
GtkLabel* info_label;
272
GtkContainer* view_container;
275
GtkWidget* undo_menu;
276
GtkWidget* undo_button;
277
GtkWidget* resign_menu;
278
GtkWidget* resign_button;
279
GtkWidget* first_move_button;
280
GtkWidget* prev_move_button;
281
GtkWidget* next_move_button;
282
GtkWidget* last_move_button;
283
GtkComboBox* history_combo;
284
GtkWidget* white_time_label;
285
GtkWidget* black_time_label;
286
GtkDialog* preferences_dialog;
287
GtkComboBox* duration_combo;
288
GtkAdjustment* duration_adjustment;
289
GtkContainer* custom_duration_box;
290
GtkComboBox* custom_duration_units_combo;
291
guint save_duration_timeout;
292
GtkFileChooserDialog* open_dialog;
293
GtkInfoBar* open_dialog_info_bar;
294
GtkLabel* open_dialog_error_label;
295
GtkFileChooserDialog* save_dialog;
296
GtkInfoBar* save_dialog_info_bar;
297
GtkLabel* save_dialog_error_label;
298
GtkAboutDialog* about_dialog;
303
gboolean game_needs_saving;
305
ChessPlayer* opponent;
306
ChessPlayer* human_player;
307
ChessEngine* opponent_engine;
311
CHESS_RESULT_IN_PROGRESS,
312
CHESS_RESULT_WHITE_WON,
313
CHESS_RESULT_BLACK_WON,
318
CHESS_RULE_CHECKMATE,
319
CHESS_RULE_STALEMATE,
320
CHESS_RULE_FIFTY_MOVES,
322
CHESS_RULE_THREE_FOLD_REPETITION,
323
CHESS_RULE_INSUFFICIENT_MATERIAL,
325
CHESS_RULE_ABANDONMENT,
330
GTypeInstance parent_instance;
331
volatile int ref_count;
332
ChessGamePrivate * priv;
339
struct _ChessGameClass {
340
GTypeClass parent_class;
341
void (*finalize) (ChessGame *self);
347
CHECK_STATE_CHECKMATE
351
GTypeInstance parent_instance;
352
volatile int ref_count;
353
ChessStatePrivate * priv;
355
ChessPlayer* players[2];
356
ChessPlayer* current_player;
357
gboolean can_castle_kingside[2];
358
gboolean can_castle_queenside[2];
359
gint en_passant_index;
360
CheckState check_state;
362
ChessPiece* board[64];
363
ChessMove* last_move;
366
struct _ChessStateClass {
367
GTypeClass parent_class;
368
void (*finalize) (ChessState *self);
372
GTypeInstance parent_instance;
373
volatile int ref_count;
374
PGNGamePrivate * priv;
379
struct _PGNGameClass {
380
GTypeClass parent_class;
381
void (*finalize) (PGNGame *self);
385
GTypeInstance parent_instance;
386
volatile int ref_count;
387
AIProfilePrivate * priv;
393
gchar** easy_options;
394
gint easy_options_length1;
395
gchar** normal_options;
396
gint normal_options_length1;
397
gchar** hard_options;
398
gint hard_options_length1;
401
struct _AIProfileClass {
402
GTypeClass parent_class;
403
void (*finalize) (AIProfile *self);
406
struct _ChessEngine {
407
GObject parent_instance;
408
ChessEnginePrivate * priv;
412
struct _ChessEngineClass {
413
GObjectClass parent_class;
414
void (*process_input) (ChessEngine* self, gchar* data, int data_length1);
415
void (*start_game) (ChessEngine* self);
416
void (*request_move) (ChessEngine* self);
417
void (*report_move) (ChessEngine* self, ChessMove* move);
418
void (*undo) (ChessEngine* self);
422
GTypeInstance parent_instance;
423
volatile int ref_count;
424
ChessMovePrivate * priv;
427
ChessPiece* promotion_piece;
428
ChessPiece* moved_rook;
434
gboolean ambiguous_rank;
435
gboolean ambiguous_file;
436
CheckState check_state;
439
struct _ChessMoveClass {
440
GTypeClass parent_class;
441
void (*finalize) (ChessMove *self);
454
GTypeInstance parent_instance;
455
volatile int ref_count;
456
ChessPiecePrivate * priv;
461
struct _ChessPieceClass {
462
GTypeClass parent_class;
463
void (*finalize) (ChessPiece *self);
471
struct _ChessPlayer {
472
GObject parent_instance;
473
ChessPlayerPrivate * priv;
477
struct _ChessPlayerClass {
478
GObjectClass parent_class;
482
GTypeInstance parent_instance;
483
volatile int ref_count;
489
GTypeClass parent_class;
490
void (*finalize) (PGN *self);
493
struct _ParamSpecApplication {
494
GParamSpec parent_instance;
498
GTypeInstance parent_instance;
499
volatile int ref_count;
500
GlChessPrivate * priv;
503
struct _GlChessClass {
504
GTypeClass parent_class;
505
void (*finalize) (GlChess *self);
508
struct _ParamSpecGlChess {
509
GParamSpec parent_instance;
513
static gpointer application_parent_class = NULL;
514
extern gchar* pgn_game_RESULT_WHITE;
515
extern gchar* pgn_game_RESULT_BLACK;
516
extern gchar* pgn_game_RESULT_DRAW;
517
extern gchar* pgn_game_TERMINATE_ABANDONED;
518
extern gchar* pgn_game_TERMINATE_DEATH;
519
static gpointer gl_chess_parent_class = NULL;
521
void gtk_file_filter_set_name (GtkFileFilter* filter, const gchar* name);
522
gpointer application_ref (gpointer instance);
523
void application_unref (gpointer instance);
524
GParamSpec* param_spec_application (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
525
void value_set_application (GValue* value, gpointer v_object);
526
void value_take_application (GValue* value, gpointer v_object);
527
gpointer value_get_application (const GValue* value);
528
GType application_get_type (void) G_GNUC_CONST;
529
gpointer history_ref (gpointer instance);
530
void history_unref (gpointer instance);
531
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
532
void value_set_history (GValue* value, gpointer v_object);
533
void value_take_history (GValue* value, gpointer v_object);
534
gpointer value_get_history (const GValue* value);
535
GType history_get_type (void) G_GNUC_CONST;
536
GType chess_scene_get_type (void) G_GNUC_CONST;
537
GType chess_view_get_type (void) G_GNUC_CONST;
538
gpointer pgn_game_ref (gpointer instance);
539
void pgn_game_unref (gpointer instance);
540
GParamSpec* param_spec_pgn_game (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
541
void value_set_pgn_game (GValue* value, gpointer v_object);
542
void value_take_pgn_game (GValue* value, gpointer v_object);
543
gpointer value_get_pgn_game (const GValue* value);
544
GType pgn_game_get_type (void) G_GNUC_CONST;
545
gpointer chess_game_ref (gpointer instance);
546
void chess_game_unref (gpointer instance);
547
GParamSpec* param_spec_chess_game (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
548
void value_set_chess_game (GValue* value, gpointer v_object);
549
void value_take_chess_game (GValue* value, gpointer v_object);
550
gpointer value_get_chess_game (const GValue* value);
551
GType chess_game_get_type (void) G_GNUC_CONST;
552
gpointer ai_profile_ref (gpointer instance);
553
void ai_profile_unref (gpointer instance);
554
GParamSpec* param_spec_ai_profile (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
555
void value_set_ai_profile (GValue* value, gpointer v_object);
556
void value_take_ai_profile (GValue* value, gpointer v_object);
557
gpointer value_get_ai_profile (const GValue* value);
558
GType ai_profile_get_type (void) G_GNUC_CONST;
559
GType chess_player_get_type (void) G_GNUC_CONST;
560
GType chess_engine_get_type (void) G_GNUC_CONST;
561
#define APPLICATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_APPLICATION, ApplicationPrivate))
563
APPLICATION_DUMMY_PROPERTY
565
static void _ai_profile_unref0_ (gpointer var);
566
static void _g_list_free__ai_profile_unref0_ (GList* self);
567
Application* application_new (void);
568
Application* application_construct (GType object_type);
569
History* history_new (GFile* data_dir);
570
History* history_construct (GType object_type, GFile* data_dir);
571
ChessScene* chess_scene_new (void);
572
ChessScene* chess_scene_construct (GType object_type);
573
static void application_scene_changed_cb (Application* self, ChessScene* scene);
574
static void _application_scene_changed_cb_chess_scene_changed (ChessScene* _sender, gpointer self);
575
static void application_settings_changed_cb (Application* self, GSettings* settings, const gchar* key);
576
static void _application_settings_changed_cb_g_settings_changed (GSettings* _sender, const gchar* key, gpointer self);
577
void application_quit (Application* self);
578
static gboolean application_save_duration_cb (Application* self);
579
static void application_autosave (Application* self);
580
void history_remove (History* self, GFile* file);
581
void history_update (History* self, GFile* file, const gchar* fen, const gchar* _result_);
582
const gchar* pgn_game_get_result (PGNGame* self);
583
GFile* history_add (History* self, const gchar* date, const gchar* _result_, GError** error);
584
const gchar* pgn_game_get_date (PGNGame* self);
585
void pgn_game_write (PGNGame* self, GFile* file, GError** error);
586
ChessView3D* chess_view3_d_new (void);
587
ChessView3D* chess_view3_d_construct (GType object_type);
588
GType chess_view3_d_get_type (void) G_GNUC_CONST;
589
ChessView2D* chess_view2_d_new (void);
590
ChessView2D* chess_view2_d_construct (GType object_type);
591
GType chess_view2_d_get_type (void) G_GNUC_CONST;
592
void chess_view_set_scene (ChessView* self, ChessScene* value);
593
static void application_update_history_panel (Application* self);
594
gint chess_scene_get_move_number (ChessScene* self);
595
guint chess_game_get_n_moves (ChessGame* self);
596
GType chess_result_get_type (void) G_GNUC_CONST;
597
GType chess_rule_get_type (void) G_GNUC_CONST;
598
gpointer chess_state_ref (gpointer instance);
599
void chess_state_unref (gpointer instance);
600
GParamSpec* param_spec_chess_state (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
601
void value_set_chess_state (GValue* value, gpointer v_object);
602
void value_take_chess_state (GValue* value, gpointer v_object);
603
gpointer value_get_chess_state (const GValue* value);
604
GType chess_state_get_type (void) G_GNUC_CONST;
605
GType check_state_get_type (void) G_GNUC_CONST;
606
gpointer chess_piece_ref (gpointer instance);
607
void chess_piece_unref (gpointer instance);
608
GParamSpec* param_spec_chess_piece (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
609
void value_set_chess_piece (GValue* value, gpointer v_object);
610
void value_take_chess_piece (GValue* value, gpointer v_object);
611
gpointer value_get_chess_piece (const GValue* value);
612
GType chess_piece_get_type (void) G_GNUC_CONST;
613
gpointer chess_move_ref (gpointer instance);
614
void chess_move_unref (gpointer instance);
615
GParamSpec* param_spec_chess_move (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
616
void value_set_chess_move (GValue* value, gpointer v_object);
617
void value_take_chess_move (GValue* value, gpointer v_object);
618
gpointer value_get_chess_move (const GValue* value);
619
GType chess_move_get_type (void) G_GNUC_CONST;
620
static void application_set_move_text (Application* self, GtkTreeIter* iter, ChessMove* move);
621
static void application_start_game (Application* self);
622
#define CHESS_GAME_STANDARD_SETUP "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
623
gboolean pgn_game_get_set_up (PGNGame* self);
624
const gchar* pgn_game_get_fen (PGNGame* self);
625
ChessGame* chess_game_new (const gchar* fen, gchar** moves, int moves_length1);
626
ChessGame* chess_game_construct (GType object_type, const gchar* fen, gchar** moves, int moves_length1);
627
const gchar* pgn_game_get_time_control (PGNGame* self);
628
ChessClock* chess_clock_new (guint white_duration, guint black_duration, guint white_used, guint black_used);
629
ChessClock* chess_clock_construct (GType object_type, guint white_duration, guint black_duration, guint white_used, guint black_used);
630
GType chess_clock_get_type (void) G_GNUC_CONST;
631
void chess_game_set_clock (ChessGame* self, ChessClock* value);
632
static void application_game_start_cb (Application* self, ChessGame* game);
633
static void _application_game_start_cb_chess_game_started (ChessGame* _sender, gpointer self);
634
static void application_game_turn_cb (Application* self, ChessGame* game, ChessPlayer* player);
635
static void _application_game_turn_cb_chess_game_turn_started (ChessGame* _sender, ChessPlayer* player, gpointer self);
636
static void application_game_move_cb (Application* self, ChessGame* game, ChessMove* move);
637
static void _application_game_move_cb_chess_game_moved (ChessGame* _sender, ChessMove* move, gpointer self);
638
static void application_game_undo_cb (Application* self, ChessGame* game);
639
static void _application_game_undo_cb_chess_game_undo (ChessGame* _sender, gpointer self);
640
static void application_game_end_cb (Application* self, ChessGame* game);
641
static void _application_game_end_cb_chess_game_ended (ChessGame* _sender, gpointer self);
642
ChessClock* chess_game_get_clock (ChessGame* self);
643
static void application_game_clock_tick_cb (Application* self, ChessClock* clock);
644
static void _application_game_clock_tick_cb_chess_clock_tick (ChessClock* _sender, gpointer self);
645
void chess_scene_set_game (ChessScene* self, ChessGame* value);
646
static void application_update_control_buttons (Application* self);
647
ChessPlayer* chess_game_get_white (ChessGame* self);
648
ChessPlayer* chess_game_get_black (ChessGame* self);
649
static ChessEngine* application_get_engine (Application* self, const gchar* name, const gchar* difficulty);
650
static void application_engine_ready_cb (Application* self, ChessEngine* engine);
651
static void _application_engine_ready_cb_chess_engine_ready_changed (ChessEngine* _sender, gpointer self);
652
static void application_engine_move_cb (Application* self, ChessEngine* engine, const gchar* move);
653
static void _application_engine_move_cb_chess_engine_moved (ChessEngine* _sender, const gchar* move, gpointer self);
654
gboolean chess_engine_start (ChessEngine* self);
655
void chess_game_start (ChessGame* self);
656
static gchar** _vala_array_dup2 (gchar** self, int length);
657
static gchar** _vala_array_dup3 (gchar** self, int length);
658
static gchar** _vala_array_dup4 (gchar** self, int length);
659
ChessEngineCECP* chess_engine_cecp_new (gchar** options, int options_length1);
660
ChessEngineCECP* chess_engine_cecp_construct (GType object_type, gchar** options, int options_length1);
661
GType chess_engine_cecp_get_type (void) G_GNUC_CONST;
662
ChessEngineUCI* chess_engine_uci_new (gchar** options, int options_length1);
663
ChessEngineUCI* chess_engine_uci_construct (GType object_type, gchar** options, int options_length1);
664
GType chess_engine_uci_get_type (void) G_GNUC_CONST;
665
void application_start (Application* self, GFile* game, GError** error);
666
GList* load_ai_profiles (const gchar* filename);
667
GList* history_get_unfinished (History* self);
668
static void application_load_game (Application* self, GFile* file, gboolean from_history, GError** error);
669
static void _g_object_unref0_ (gpointer var);
670
static void _g_list_free__g_object_unref0_ (GList* self);
671
static void application_start_new_game (Application* self);
672
void application_show (Application* self);
673
gboolean chess_engine_get_ready (ChessEngine* self);
674
gboolean chess_player_move (ChessPlayer* self, const gchar* move, gboolean apply);
675
void chess_engine_start_game (ChessEngine* self);
676
void chess_engine_request_move (ChessEngine* self);
677
const gchar* chess_scene_get_move_format (ChessScene* self);
678
GType piece_type_get_type (void) G_GNUC_CONST;
679
GType color_get_type (void) G_GNUC_CONST;
680
gchar* chess_move_get_san (ChessMove* self);
681
gchar* chess_move_get_fan (ChessMove* self);
682
gchar* chess_move_get_lan (ChessMove* self);
683
void chess_engine_report_move (ChessEngine* self, ChessMove* move);
684
void chess_engine_undo (ChessEngine* self);
685
void pgn_game_set_result (PGNGame* self, const gchar* value);
686
void pgn_game_set_termination (PGNGame* self, const gchar* value);
687
gboolean G_MODULE_EXPORT glchess_app_delete_event_cb (GtkWidget* widget, GdkEvent* event, Application* self);
688
gboolean G_MODULE_EXPORT glchess_app_configure_event_cb (GtkWidget* widget, GdkEventConfigure* event, Application* self);
689
gboolean G_MODULE_EXPORT glchess_app_window_state_event_cb (GtkWidget* widget, GdkEventWindowState* event, Application* self);
690
void G_MODULE_EXPORT new_game_cb (GtkWidget* widget, Application* self);
691
void G_MODULE_EXPORT resign_cb (GtkWidget* widget, Application* self);
692
ChessPlayer* chess_game_get_current_player (ChessGame* self);
693
gboolean chess_player_resign (ChessPlayer* self);
694
void G_MODULE_EXPORT claim_draw_cb (GtkWidget* widget, Application* self);
695
gboolean chess_player_claim_draw (ChessPlayer* self);
696
void G_MODULE_EXPORT undo_move_cb (GtkWidget* widget, Application* self);
697
void chess_player_undo (ChessPlayer* self);
698
ChessPlayer* chess_game_get_opponent (ChessGame* self);
699
void G_MODULE_EXPORT quit_cb (GtkWidget* widget, Application* self);
700
gboolean G_MODULE_EXPORT white_time_draw_cb (GtkWidget* widget, cairo_t* c, Application* self);
701
static void application_draw_time (Application* self, GtkWidget* widget, cairo_t* c, const gchar* text, gdouble* fg, int fg_length1, gdouble* bg, int bg_length1);
702
static gchar* application_make_clock_text (Application* self, ChessClock* clock, Color color);
703
gboolean G_MODULE_EXPORT black_time_draw_cb (GtkWidget* widget, cairo_t* c, Application* self);
704
guint chess_clock_get_white_duration (ChessClock* self);
705
guint chess_clock_get_white_used_in_seconds (ChessClock* self);
706
guint chess_clock_get_black_duration (ChessClock* self);
707
guint chess_clock_get_black_used_in_seconds (ChessClock* self);
708
void G_MODULE_EXPORT history_combo_changed_cb (GtkComboBox* combo, Application* self);
709
void chess_scene_set_move_number (ChessScene* self, gint value);
710
void G_MODULE_EXPORT history_latest_clicked_cb (GtkWidget* widget, Application* self);
711
void G_MODULE_EXPORT history_next_clicked_cb (GtkWidget* widget, Application* self);
712
void G_MODULE_EXPORT history_previous_clicked_cb (GtkWidget* widget, Application* self);
713
void G_MODULE_EXPORT history_start_clicked_cb (GtkWidget* widget, Application* self);
714
void G_MODULE_EXPORT toggle_fullscreen_cb (GtkWidget* widget, Application* self);
715
void G_MODULE_EXPORT preferences_cb (GtkWidget* widget, Application* self);
716
static void application_set_combo (Application* self, GtkComboBox* combo, gint value_index, const gchar* value);
717
static void application_set_duration (Application* self, gint duration, gboolean simplify);
718
static gchar* application_get_combo (Application* self, GtkComboBox* combo, gint value_index);
719
void G_MODULE_EXPORT side_combo_changed_cb (GtkComboBox* combo, Application* self);
720
void G_MODULE_EXPORT opponent_combo_changed_cb (GtkComboBox* combo, Application* self);
721
void G_MODULE_EXPORT difficulty_combo_changed_cb (GtkComboBox* combo, Application* self);
722
static gint application_get_duration (Application* self);
723
void G_MODULE_EXPORT duration_changed_cb (GtkAdjustment* adjustment, Application* self);
724
static void application_save_duration (Application* self);
725
void G_MODULE_EXPORT duration_units_changed_cb (GtkWidget* widget, Application* self);
726
static gboolean _application_save_duration_cb_gsource_func (gpointer self);
727
void G_MODULE_EXPORT duration_combo_changed_cb (GtkComboBox* combo, Application* self);
728
void G_MODULE_EXPORT preferences_response_cb (GtkWidget* widget, gint response_id, Application* self);
729
gboolean G_MODULE_EXPORT preferences_delete_event_cb (GtkWidget* widget, GdkEvent* event, Application* self);
730
void G_MODULE_EXPORT piece_style_combo_changed_cb (GtkComboBox* combo, Application* self);
731
void G_MODULE_EXPORT show_3d_toggle_cb (GtkToggleButton* widget, Application* self);
732
void G_MODULE_EXPORT promotion_type_combo_changed_cb (GtkComboBox* combo, Application* self);
733
void G_MODULE_EXPORT move_format_combo_changed_cb (GtkComboBox* combo, Application* self);
734
void G_MODULE_EXPORT orientation_combo_changed_cb (GtkComboBox* combo, Application* self);
735
void G_MODULE_EXPORT help_cb (GtkWidget* widget, Application* self);
736
void G_MODULE_EXPORT about_cb (GtkWidget* widget, Application* self);
737
static void application_about_response_cb (Application* self, gint response_id);
738
static void _application_about_response_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
739
void G_MODULE_EXPORT save_game_as_cb (GtkWidget* widget, Application* self);
740
static void application_save_game (Application* self);
741
void G_MODULE_EXPORT save_game_cb (GtkWidget* widget, Application* self);
742
static void application_add_info_bar_to_dialog (Application* self, GtkDialog* dialog, GtkInfoBar** info_bar, GtkLabel** label);
743
static void application_save_file_cb (Application* self);
744
static void _application_save_file_cb_gtk_file_chooser_file_activated (GtkFileChooser* _sender, gpointer self);
745
static void application_save_cb (Application* self, gint response_id);
746
static void _application_save_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
747
void G_MODULE_EXPORT open_game_cb (GtkWidget* widget, Application* self);
748
static void application_open_file_cb (Application* self);
749
static void _application_open_file_cb_gtk_file_chooser_file_activated (GtkFileChooser* _sender, gpointer self);
750
static void application_open_cb (Application* self, gint response_id);
751
static void _application_open_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
752
PGNGame* pgn_game_new (void);
753
PGNGame* pgn_game_construct (GType object_type);
754
void pgn_game_set_date (PGNGame* self, const gchar* value);
755
void pgn_game_set_time (PGNGame* self, const gchar* value);
756
void pgn_game_set_time_control (PGNGame* self, const gchar* value);
757
PGN* pgn_new_from_file (GFile* file, GError** error);
758
PGN* pgn_construct_from_file (GType object_type, GFile* file, GError** error);
759
gpointer pgn_ref (gpointer instance);
760
void pgn_unref (gpointer instance);
761
GParamSpec* param_spec_pgn (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
762
void value_set_pgn (GValue* value, gpointer v_object);
763
void value_take_pgn (GValue* value, gpointer v_object);
764
gpointer value_get_pgn (const GValue* value);
765
GType pgn_get_type (void) G_GNUC_CONST;
766
static void application_finalize (Application* obj);
767
gpointer gl_chess_ref (gpointer instance);
768
void gl_chess_unref (gpointer instance);
769
GParamSpec* param_spec_gl_chess (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
770
void value_set_gl_chess (GValue* value, gpointer v_object);
771
void value_take_gl_chess (GValue* value, gpointer v_object);
772
gpointer value_get_gl_chess (const GValue* value);
773
GType gl_chess_get_type (void) G_GNUC_CONST;
775
GL_CHESS_DUMMY_PROPERTY
777
gint gl_chess_main (gchar** args, int args_length1);
778
void gl_chess_usage (const gchar* appname, gboolean show_gtk, gboolean show_application);
779
GlChess* gl_chess_new (void);
780
GlChess* gl_chess_construct (GType object_type);
781
static void gl_chess_finalize (GlChess* obj);
782
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
783
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
784
static gint _vala_array_length (gpointer array);
786
static const gchar* APPLICATION_authors[1] = {"Robert Ancell <robert.ancell@gmail.com>"};
787
static const gchar* APPLICATION_artists[3] = {"John-Paul Gignac (3D Models)", "Max Froumentin (2D Models)", "Hylke Bons <h.bons@student.rug.nl> (icon)"};
789
static void _ai_profile_unref0_ (gpointer var) {
790
(var == NULL) ? NULL : (var = (ai_profile_unref (var), NULL));
794
static void _g_list_free__ai_profile_unref0_ (GList* self) {
795
g_list_foreach (self, (GFunc) _ai_profile_unref0_, NULL);
800
static gpointer _g_object_ref0 (gpointer self) {
801
return self ? g_object_ref (self) : NULL;
805
static void _application_scene_changed_cb_chess_scene_changed (ChessScene* _sender, gpointer self) {
806
application_scene_changed_cb (self, _sender);
810
static void _application_settings_changed_cb_g_settings_changed (GSettings* _sender, const gchar* key, gpointer self) {
811
application_settings_changed_cb (self, _sender, key);
815
Application* application_construct (GType object_type) {
816
Application* self = NULL;
817
GSettings* _tmp0_ = NULL;
818
const gchar* _tmp1_ = NULL;
819
gchar* _tmp2_ = NULL;
821
GFile* _tmp4_ = NULL;
824
gchar* _tmp6_ = NULL;
826
History* _tmp8_ = NULL;
827
GtkBuilder* _tmp9_ = NULL;
828
gchar* _tmp10_ = NULL;
830
GObject* _tmp12_ = NULL;
832
GObject* _tmp14_ = NULL;
834
GObject* _tmp16_ = NULL;
836
GObject* _tmp18_ = NULL;
837
GtkMenuItem* _tmp19_;
838
GObject* _tmp20_ = NULL;
840
GObject* _tmp22_ = NULL;
842
GObject* _tmp24_ = NULL;
844
GObject* _tmp26_ = NULL;
846
GObject* _tmp28_ = NULL;
848
GObject* _tmp30_ = NULL;
850
GObject* _tmp32_ = NULL;
852
GObject* _tmp34_ = NULL;
854
GObject* _tmp36_ = NULL;
855
GtkComboBox* _tmp37_;
856
GObject* _tmp38_ = NULL;
858
GObject* _tmp40_ = NULL;
860
GObject* _tmp42_ = NULL;
861
GObject* _tmp43_ = NULL;
862
GObject* _tmp44_ = NULL;
865
GObject* _tmp46_ = NULL;
866
GtkContainer* _tmp47_;
867
GtkInfoBar* _tmp48_ = NULL;
868
GtkWidget* _tmp49_ = NULL;
869
GtkContainer* _tmp50_;
870
GtkContainer* content_area;
871
GtkVBox* _tmp51_ = NULL;
873
GtkLabel* _tmp52_ = NULL;
874
GtkLabel* _tmp53_ = NULL;
875
ChessScene* _tmp54_ = NULL;
876
GError * _inner_error_ = NULL;
877
self = (Application*) g_type_create_instance (object_type);
878
_tmp0_ = g_settings_new ("org.gnome.glchess.Settings");
879
_g_object_unref0 (self->priv->settings);
880
self->priv->settings = _tmp0_;
881
_tmp1_ = g_get_user_data_dir ();
882
_tmp2_ = g_build_filename (_tmp1_, "glchess", NULL, NULL);
884
_tmp4_ = g_file_new_for_path (_tmp3_);
888
_tmp6_ = g_file_get_path (data_dir);
890
g_mkdir_with_parents (_tmp7_, 0755);
892
_tmp8_ = history_new (data_dir);
893
_history_unref0 (self->priv->history);
894
self->priv->history = _tmp8_;
895
_tmp9_ = gtk_builder_new ();
896
_g_object_unref0 (self->priv->builder);
897
self->priv->builder = _tmp9_;
898
_tmp10_ = g_build_filename (PKGDATADIR, "glchess.ui", NULL, NULL);
900
gtk_builder_add_from_file (self->priv->builder, _tmp11_, &_inner_error_);
902
if (_inner_error_ != NULL) {
903
goto __catch0_g_error;
910
_inner_error_ = NULL;
911
g_warning ("glchess.vala:72: Could not load UI: %s", e->message);
915
if (_inner_error_ != NULL) {
916
_g_object_unref0 (data_dir);
917
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);
918
g_clear_error (&_inner_error_);
921
_tmp12_ = gtk_builder_get_object (self->priv->builder, "glchess_app");
922
_tmp13_ = _g_object_ref0 (GTK_WINDOW (_tmp12_));
923
_g_object_unref0 (self->priv->window);
924
self->priv->window = _tmp13_;
925
_tmp14_ = gtk_builder_get_object (self->priv->builder, "menu_save_item");
926
_tmp15_ = _g_object_ref0 (GTK_WIDGET (_tmp14_));
927
_g_object_unref0 (self->priv->save_menu);
928
self->priv->save_menu = _tmp15_;
929
_tmp16_ = gtk_builder_get_object (self->priv->builder, "menu_save_as_item");
930
_tmp17_ = _g_object_ref0 (GTK_WIDGET (_tmp16_));
931
_g_object_unref0 (self->priv->save_as_menu);
932
self->priv->save_as_menu = _tmp17_;
933
_tmp18_ = gtk_builder_get_object (self->priv->builder, "fullscreen_item");
934
_tmp19_ = _g_object_ref0 (GTK_MENU_ITEM (_tmp18_));
935
_g_object_unref0 (self->priv->fullscreen_menu);
936
self->priv->fullscreen_menu = _tmp19_;
937
_tmp20_ = gtk_builder_get_object (self->priv->builder, "undo_move_item");
938
_tmp21_ = _g_object_ref0 (GTK_WIDGET (_tmp20_));
939
_g_object_unref0 (self->priv->undo_menu);
940
self->priv->undo_menu = _tmp21_;
941
_tmp22_ = gtk_builder_get_object (self->priv->builder, "undo_move_button");
942
_tmp23_ = _g_object_ref0 (GTK_WIDGET (_tmp22_));
943
_g_object_unref0 (self->priv->undo_button);
944
self->priv->undo_button = _tmp23_;
945
_tmp24_ = gtk_builder_get_object (self->priv->builder, "resign_item");
946
_tmp25_ = _g_object_ref0 (GTK_WIDGET (_tmp24_));
947
_g_object_unref0 (self->priv->resign_menu);
948
self->priv->resign_menu = _tmp25_;
949
_tmp26_ = gtk_builder_get_object (self->priv->builder, "resign_button");
950
_tmp27_ = _g_object_ref0 (GTK_WIDGET (_tmp26_));
951
_g_object_unref0 (self->priv->resign_button);
952
self->priv->resign_button = _tmp27_;
953
_tmp28_ = gtk_builder_get_object (self->priv->builder, "first_move_button");
954
_tmp29_ = _g_object_ref0 (GTK_WIDGET (_tmp28_));
955
_g_object_unref0 (self->priv->first_move_button);
956
self->priv->first_move_button = _tmp29_;
957
_tmp30_ = gtk_builder_get_object (self->priv->builder, "prev_move_button");
958
_tmp31_ = _g_object_ref0 (GTK_WIDGET (_tmp30_));
959
_g_object_unref0 (self->priv->prev_move_button);
960
self->priv->prev_move_button = _tmp31_;
961
_tmp32_ = gtk_builder_get_object (self->priv->builder, "next_move_button");
962
_tmp33_ = _g_object_ref0 (GTK_WIDGET (_tmp32_));
963
_g_object_unref0 (self->priv->next_move_button);
964
self->priv->next_move_button = _tmp33_;
965
_tmp34_ = gtk_builder_get_object (self->priv->builder, "last_move_button");
966
_tmp35_ = _g_object_ref0 (GTK_WIDGET (_tmp34_));
967
_g_object_unref0 (self->priv->last_move_button);
968
self->priv->last_move_button = _tmp35_;
969
_tmp36_ = gtk_builder_get_object (self->priv->builder, "history_combo");
970
_tmp37_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp36_));
971
_g_object_unref0 (self->priv->history_combo);
972
self->priv->history_combo = _tmp37_;
973
_tmp38_ = gtk_builder_get_object (self->priv->builder, "white_time_label");
974
_tmp39_ = _g_object_ref0 (GTK_WIDGET (_tmp38_));
975
_g_object_unref0 (self->priv->white_time_label);
976
self->priv->white_time_label = _tmp39_;
977
_tmp40_ = gtk_builder_get_object (self->priv->builder, "black_time_label");
978
_tmp41_ = _g_object_ref0 (GTK_WIDGET (_tmp40_));
979
_g_object_unref0 (self->priv->black_time_label);
980
self->priv->black_time_label = _tmp41_;
981
_tmp42_ = gtk_builder_get_object (self->priv->builder, "toolbar");
982
g_settings_bind (self->priv->settings, "show-toolbar", _tmp42_, "visible", G_SETTINGS_BIND_DEFAULT);
983
_tmp43_ = gtk_builder_get_object (self->priv->builder, "navigation_box");
984
g_settings_bind (self->priv->settings, "show-history", _tmp43_, "visible", G_SETTINGS_BIND_DEFAULT);
985
_tmp44_ = gtk_builder_get_object (self->priv->builder, "view_box");
986
_tmp45_ = _g_object_ref0 (GTK_VBOX (_tmp44_));
988
_tmp46_ = gtk_builder_get_object (self->priv->builder, "view_container");
989
_tmp47_ = _g_object_ref0 (GTK_CONTAINER (_tmp46_));
990
_g_object_unref0 (self->priv->view_container);
991
self->priv->view_container = _tmp47_;
992
gtk_builder_connect_signals (self->priv->builder, self);
993
_tmp48_ = (GtkInfoBar*) gtk_info_bar_new ();
994
_g_object_unref0 (self->priv->info_bar);
995
self->priv->info_bar = g_object_ref_sink (_tmp48_);
996
_tmp49_ = gtk_info_bar_get_content_area (self->priv->info_bar);
997
_tmp50_ = _g_object_ref0 (GTK_CONTAINER (_tmp49_));
998
content_area = _tmp50_;
999
gtk_box_pack_start ((GtkBox*) view_box, (GtkWidget*) self->priv->info_bar, FALSE, TRUE, (guint) 0);
1000
_tmp51_ = (GtkVBox*) gtk_vbox_new (FALSE, 6);
1001
vbox = g_object_ref_sink (_tmp51_);
1002
gtk_widget_show ((GtkWidget*) vbox);
1003
gtk_container_add (content_area, (GtkWidget*) vbox);
1004
_tmp52_ = (GtkLabel*) gtk_label_new ("");
1005
_g_object_unref0 (self->priv->info_title_label);
1006
self->priv->info_title_label = g_object_ref_sink (_tmp52_);
1007
gtk_widget_show ((GtkWidget*) self->priv->info_title_label);
1008
gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) self->priv->info_title_label, FALSE, TRUE, (guint) 0);
1009
_tmp53_ = (GtkLabel*) gtk_label_new ("");
1010
_g_object_unref0 (self->priv->info_label);
1011
self->priv->info_label = g_object_ref_sink (_tmp53_);
1012
gtk_widget_show ((GtkWidget*) self->priv->info_label);
1013
gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) self->priv->info_label, TRUE, TRUE, (guint) 0);
1014
_tmp54_ = chess_scene_new ();
1015
_g_object_unref0 (self->priv->scene);
1016
self->priv->scene = _tmp54_;
1017
g_signal_connect (self->priv->scene, "changed", (GCallback) _application_scene_changed_cb_chess_scene_changed, self);
1018
g_settings_bind (self->priv->settings, "show-move-hints", self->priv->scene, "show-move-hints", G_SETTINGS_BIND_GET);
1019
g_settings_bind (self->priv->settings, "show-numbering", self->priv->scene, "show-numbering", G_SETTINGS_BIND_GET);
1020
g_settings_bind (self->priv->settings, "piece-theme", self->priv->scene, "theme-name", G_SETTINGS_BIND_GET);
1021
g_settings_bind (self->priv->settings, "show-3d-smooth", self->priv->scene, "show-3d-smooth", G_SETTINGS_BIND_GET);
1022
g_settings_bind (self->priv->settings, "move-format", self->priv->scene, "move-format", G_SETTINGS_BIND_GET);
1023
g_settings_bind (self->priv->settings, "board-side", self->priv->scene, "board-side", G_SETTINGS_BIND_GET);
1024
g_signal_connect (self->priv->settings, "changed", (GCallback) _application_settings_changed_cb_g_settings_changed, self);
1025
application_settings_changed_cb (self, self->priv->settings, "show-3d");
1026
_g_object_unref0 (vbox);
1027
_g_object_unref0 (content_area);
1028
_g_object_unref0 (view_box);
1029
_g_object_unref0 (data_dir);
1034
Application* application_new (void) {
1035
return application_construct (TYPE_APPLICATION);
1039
void application_quit (Application* self) {
1040
g_return_if_fail (self != NULL);
1041
if (self->priv->save_duration_timeout != 0) {
1042
application_save_duration_cb (self);
1044
application_autosave (self);
1050
static void application_autosave (Application* self) {
1051
gchar* _tmp5_ = NULL;
1053
GError * _inner_error_ = NULL;
1054
g_return_if_fail (self != NULL);
1055
if (!self->priv->in_history) {
1058
if (!self->priv->game_needs_saving) {
1059
if (self->priv->game_file != NULL) {
1060
history_remove (self->priv->history, self->priv->game_file);
1064
if (self->priv->game_file != NULL) {
1065
const gchar* _tmp0_ = NULL;
1066
_tmp0_ = pgn_game_get_result (self->priv->pgn_game);
1067
history_update (self->priv->history, self->priv->game_file, "", _tmp0_);
1069
const gchar* _tmp1_ = NULL;
1070
const gchar* _tmp2_ = NULL;
1071
GFile* _tmp3_ = NULL;
1073
_tmp1_ = pgn_game_get_date (self->priv->pgn_game);
1074
_tmp2_ = pgn_game_get_result (self->priv->pgn_game);
1075
_tmp3_ = history_add (self->priv->history, _tmp1_, _tmp2_, &_inner_error_);
1077
if (_inner_error_ != NULL) {
1078
goto __catch1_g_error;
1080
_g_object_unref0 (self->priv->game_file);
1081
self->priv->game_file = _tmp4_;
1083
_tmp5_ = g_file_get_path (self->priv->game_file);
1085
g_debug ("glchess.vala:151: Writing current game to %s", _tmp6_);
1087
pgn_game_write (self->priv->pgn_game, self->priv->game_file, &_inner_error_);
1088
if (_inner_error_ != NULL) {
1089
goto __catch1_g_error;
1096
_inner_error_ = NULL;
1097
g_warning ("glchess.vala:156: Failed to autosave: %s", e->message);
1101
if (_inner_error_ != NULL) {
1102
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);
1103
g_clear_error (&_inner_error_);
1109
static void application_settings_changed_cb (Application* self, GSettings* settings, const gchar* key) {
1110
g_return_if_fail (self != NULL);
1111
g_return_if_fail (settings != NULL);
1112
g_return_if_fail (key != NULL);
1113
if (g_strcmp0 (key, "show-3d") == 0) {
1115
if (self->priv->view != NULL) {
1116
gtk_container_remove (self->priv->view_container, (GtkWidget*) self->priv->view);
1117
gtk_widget_destroy ((GtkWidget*) self->priv->view);
1119
_tmp0_ = g_settings_get_boolean (settings, "show-3d");
1121
ChessView3D* _tmp1_ = NULL;
1122
_tmp1_ = chess_view3_d_new ();
1123
_g_object_unref0 (self->priv->view);
1124
self->priv->view = (ChessView*) g_object_ref_sink (_tmp1_);
1126
ChessView2D* _tmp2_ = NULL;
1127
_tmp2_ = chess_view2_d_new ();
1128
_g_object_unref0 (self->priv->view);
1129
self->priv->view = (ChessView*) g_object_ref_sink (_tmp2_);
1131
gtk_widget_set_size_request ((GtkWidget*) self->priv->view, 300, 300);
1132
chess_view_set_scene (self->priv->view, self->priv->scene);
1133
gtk_container_add (self->priv->view_container, (GtkWidget*) self->priv->view);
1134
gtk_widget_show ((GtkWidget*) self->priv->view);
1139
static gpointer _chess_state_ref0 (gpointer self) {
1140
return self ? chess_state_ref (self) : NULL;
1144
static void application_update_history_panel (Application* self) {
1149
gboolean _tmp2_ = FALSE;
1150
gboolean _tmp3_ = FALSE;
1152
g_return_if_fail (self != NULL);
1153
if (self->priv->game == NULL) {
1156
_tmp0_ = chess_scene_get_move_number (self->priv->scene);
1157
move_number = _tmp0_;
1158
_tmp1_ = chess_game_get_n_moves (self->priv->game);
1159
n_moves = (gint) _tmp1_;
1160
if (move_number < 0) {
1161
move_number = move_number + (1 + n_moves);
1164
_tmp2_ = move_number != 0;
1168
gtk_widget_set_sensitive (self->priv->first_move_button, _tmp2_);
1169
gtk_widget_set_sensitive (self->priv->prev_move_button, move_number > 0);
1170
gtk_widget_set_sensitive (self->priv->next_move_button, move_number < n_moves);
1172
_tmp3_ = move_number != n_moves;
1176
gtk_widget_set_sensitive (self->priv->last_move_button, _tmp3_);
1179
GList* state_collection;
1181
state_collection = self->priv->game->move_stack;
1182
for (state_it = state_collection; state_it != NULL; state_it = state_it->next) {
1185
_tmp4_ = _chess_state_ref0 ((ChessState*) state_it->data);
1188
if (state->last_move != NULL) {
1189
GtkTreeIter iter = {0};
1190
GtkTreeModel* _tmp5_ = NULL;
1191
GtkTreeIter _tmp6_ = {0};
1193
_tmp5_ = gtk_combo_box_get_model (self->priv->history_combo);
1194
_tmp7_ = gtk_tree_model_iter_nth_child (_tmp5_, &_tmp6_, NULL, i);
1197
application_set_move_text (self, &iter, state->last_move);
1201
_chess_state_unref0 (state);
1205
gtk_combo_box_set_active (self->priv->history_combo, move_number);
1209
static void application_scene_changed_cb (Application* self, ChessScene* scene) {
1210
g_return_if_fail (self != NULL);
1211
g_return_if_fail (scene != NULL);
1212
application_update_history_panel (self);
1216
static void _application_game_start_cb_chess_game_started (ChessGame* _sender, gpointer self) {
1217
application_game_start_cb (self, _sender);
1221
static void _application_game_turn_cb_chess_game_turn_started (ChessGame* _sender, ChessPlayer* player, gpointer self) {
1222
application_game_turn_cb (self, _sender, player);
1226
static void _application_game_move_cb_chess_game_moved (ChessGame* _sender, ChessMove* move, gpointer self) {
1227
application_game_move_cb (self, _sender, move);
1231
static void _application_game_undo_cb_chess_game_undo (ChessGame* _sender, gpointer self) {
1232
application_game_undo_cb (self, _sender);
1236
static void _application_game_end_cb_chess_game_ended (ChessGame* _sender, gpointer self) {
1237
application_game_end_cb (self, _sender);
1241
static void _application_game_clock_tick_cb_chess_clock_tick (ChessClock* _sender, gpointer self) {
1242
application_game_clock_tick_cb (self, _sender);
1246
static void _application_engine_ready_cb_chess_engine_ready_changed (ChessEngine* _sender, gpointer self) {
1247
application_engine_ready_cb (self, _sender);
1251
static void _application_engine_move_cb_chess_engine_moved (ChessEngine* _sender, const gchar* move, gpointer self) {
1252
application_engine_move_cb (self, _sender, move);
1256
static void application_start_game (Application* self) {
1257
GtkTreeModel* _tmp9_ = NULL;
1258
GtkListStore* _tmp10_;
1259
GtkListStore* model;
1260
GtkTreeIter iter = {0};
1261
GtkTreeIter _tmp11_ = {0};
1262
const gchar* _tmp12_ = NULL;
1266
gchar** _tmp15_ = NULL;
1272
ChessGame* _tmp24_ = NULL;
1273
const gchar* _tmp25_ = NULL;
1274
ChessClock* _tmp33_ = NULL;
1275
gconstpointer _tmp35_ = NULL;
1277
gchar* white_engine;
1278
gconstpointer _tmp37_ = NULL;
1281
gconstpointer _tmp40_ = NULL;
1283
gchar* black_engine;
1284
gconstpointer _tmp42_ = NULL;
1287
g_return_if_fail (self != NULL);
1288
if (self->priv->in_history) {
1289
const gchar* _tmp0_ = NULL;
1290
_tmp0_ = _ ("Chess");
1291
gtk_window_set_title (self->priv->window, _tmp0_);
1293
gchar* _tmp1_ = NULL;
1295
const gchar* _tmp2_ = NULL;
1296
gchar* _tmp3_ = NULL;
1298
gchar* _tmp5_ = NULL;
1300
gchar* _tmp7_ = NULL;
1302
_tmp1_ = g_file_get_path (self->priv->game_file);
1304
_tmp2_ = _ ("%1$s (%2$s) - Chess");
1305
_tmp3_ = g_path_get_basename (path);
1307
_tmp5_ = g_path_get_dirname (path);
1309
_tmp7_ = g_strdup_printf (_tmp2_, _tmp4_, _tmp6_);
1311
gtk_window_set_title (self->priv->window, _tmp8_);
1317
_tmp9_ = gtk_combo_box_get_model (self->priv->history_combo);
1318
_tmp10_ = _g_object_ref0 (GTK_LIST_STORE (_tmp9_));
1320
gtk_list_store_clear (model);
1321
gtk_list_store_append (model, &_tmp11_);
1323
_tmp12_ = _ ("Game Start");
1324
gtk_list_store_set (model, &iter, 0, _tmp12_, 1, 0, -1, -1);
1325
gtk_combo_box_set_active_iter (self->priv->history_combo, &iter);
1326
_tmp13_ = g_strdup (CHESS_GAME_STANDARD_SETUP);
1328
_tmp14_ = g_list_length (self->priv->pgn_game->moves);
1329
_tmp15_ = g_new0 (gchar*, _tmp14_ + 1);
1331
moves_length1 = _tmp14_;
1332
_moves_size_ = _tmp14_;
1335
GList* move_collection;
1337
move_collection = self->priv->pgn_game->moves;
1338
for (move_it = move_collection; move_it != NULL; move_it = move_it->next) {
1341
_tmp16_ = g_strdup ((const gchar*) move_it->data);
1349
_tmp18_ = g_strdup (move);
1351
_g_free0 (moves[_tmp17_]);
1352
moves[_tmp17_] = _tmp19_;
1357
_tmp20_ = pgn_game_get_set_up (self->priv->pgn_game);
1359
const gchar* _tmp21_ = NULL;
1360
_tmp21_ = pgn_game_get_fen (self->priv->pgn_game);
1361
if (_tmp21_ != NULL) {
1362
const gchar* _tmp22_ = NULL;
1364
_tmp22_ = pgn_game_get_fen (self->priv->pgn_game);
1365
_tmp23_ = g_strdup (_tmp22_);
1369
g_warning ("glchess.vala:252: Chess game has SetUp tag but no FEN tag");
1372
_tmp24_ = chess_game_new (fen, moves, moves_length1);
1373
_chess_game_unref0 (self->priv->game);
1374
self->priv->game = _tmp24_;
1375
_tmp25_ = pgn_game_get_time_control (self->priv->pgn_game);
1376
if (_tmp25_ != NULL) {
1377
const gchar* _tmp26_ = NULL;
1379
gchar** _tmp28_ = NULL;
1381
gint controls_length1;
1382
gint _controls_size_;
1383
_tmp26_ = pgn_game_get_time_control (self->priv->pgn_game);
1384
_tmp28_ = _tmp27_ = g_strsplit (_tmp26_, ":", 0);
1386
controls_length1 = _vala_array_length (_tmp27_);
1387
_controls_size_ = _vala_array_length (_tmp27_);
1389
gchar** control_collection;
1390
int control_collection_length1;
1392
control_collection = controls;
1393
control_collection_length1 = controls_length1;
1394
for (control_it = 0; control_it < controls_length1; control_it = control_it + 1) {
1397
_tmp29_ = g_strdup (control_collection[control_it]);
1402
_tmp30_ = atoi (control);
1405
ChessClock* _tmp31_ = NULL;
1406
ChessClock* _tmp32_;
1407
_tmp31_ = chess_clock_new ((guint) duration, (guint) duration, (guint) 0, (guint) 0);
1409
chess_game_set_clock (self->priv->game, _tmp32_);
1410
_g_object_unref0 (_tmp32_);
1416
controls = (_vala_array_free (controls, controls_length1, (GDestroyNotify) g_free), NULL);
1418
g_signal_connect (self->priv->game, "started", (GCallback) _application_game_start_cb_chess_game_started, self);
1419
g_signal_connect (self->priv->game, "turn-started", (GCallback) _application_game_turn_cb_chess_game_turn_started, self);
1420
g_signal_connect (self->priv->game, "moved", (GCallback) _application_game_move_cb_chess_game_moved, self);
1421
g_signal_connect (self->priv->game, "undo", (GCallback) _application_game_undo_cb_chess_game_undo, self);
1422
g_signal_connect (self->priv->game, "ended", (GCallback) _application_game_end_cb_chess_game_ended, self);
1423
_tmp33_ = chess_game_get_clock (self->priv->game);
1424
if (_tmp33_ != NULL) {
1425
ChessClock* _tmp34_ = NULL;
1426
_tmp34_ = chess_game_get_clock (self->priv->game);
1427
g_signal_connect (_tmp34_, "tick", (GCallback) _application_game_clock_tick_cb_chess_clock_tick, self);
1429
chess_scene_set_game (self->priv->scene, self->priv->game);
1430
gtk_widget_hide ((GtkWidget*) self->priv->info_bar);
1431
gtk_widget_set_sensitive (self->priv->save_menu, FALSE);
1432
gtk_widget_set_sensitive (self->priv->save_as_menu, FALSE);
1433
application_update_history_panel (self);
1434
application_update_control_buttons (self);
1435
_tmp35_ = g_hash_table_lookup (self->priv->pgn_game->tags, "WhiteAI");
1436
_tmp36_ = g_strdup ((const gchar*) _tmp35_);
1437
white_engine = _tmp36_;
1438
_tmp37_ = g_hash_table_lookup (self->priv->pgn_game->tags, "WhiteLevel");
1439
_tmp38_ = g_strdup ((const gchar*) _tmp37_);
1440
white_level = _tmp38_;
1441
if (white_level == NULL) {
1443
_tmp39_ = g_strdup ("normal");
1444
_g_free0 (white_level);
1445
white_level = _tmp39_;
1447
_tmp40_ = g_hash_table_lookup (self->priv->pgn_game->tags, "BlackAI");
1448
_tmp41_ = g_strdup ((const gchar*) _tmp40_);
1449
black_engine = _tmp41_;
1450
_tmp42_ = g_hash_table_lookup (self->priv->pgn_game->tags, "BlackLevel");
1451
_tmp43_ = g_strdup ((const gchar*) _tmp42_);
1452
black_level = _tmp43_;
1453
if (black_level == NULL) {
1455
_tmp44_ = g_strdup ("normal");
1456
_g_free0 (black_level);
1457
black_level = _tmp44_;
1459
_g_object_unref0 (self->priv->opponent);
1460
self->priv->opponent = NULL;
1461
_g_object_unref0 (self->priv->opponent_engine);
1462
self->priv->opponent_engine = NULL;
1463
if (white_engine != NULL) {
1464
ChessPlayer* _tmp45_ = NULL;
1465
ChessPlayer* _tmp46_;
1466
ChessPlayer* _tmp47_ = NULL;
1467
ChessPlayer* _tmp48_;
1468
ChessEngine* _tmp49_ = NULL;
1469
_tmp45_ = chess_game_get_white (self->priv->game);
1470
_tmp46_ = _g_object_ref0 (_tmp45_);
1471
_g_object_unref0 (self->priv->opponent);
1472
self->priv->opponent = _tmp46_;
1473
_tmp47_ = chess_game_get_black (self->priv->game);
1474
_tmp48_ = _g_object_ref0 (_tmp47_);
1475
_g_object_unref0 (self->priv->human_player);
1476
self->priv->human_player = _tmp48_;
1477
_tmp49_ = application_get_engine (self, white_engine, white_level);
1478
_g_object_unref0 (self->priv->opponent_engine);
1479
self->priv->opponent_engine = _tmp49_;
1481
if (black_engine != NULL) {
1482
ChessPlayer* _tmp50_ = NULL;
1483
ChessPlayer* _tmp51_;
1484
ChessPlayer* _tmp52_ = NULL;
1485
ChessPlayer* _tmp53_;
1486
ChessEngine* _tmp54_ = NULL;
1487
_tmp50_ = chess_game_get_black (self->priv->game);
1488
_tmp51_ = _g_object_ref0 (_tmp50_);
1489
_g_object_unref0 (self->priv->opponent);
1490
self->priv->opponent = _tmp51_;
1491
_tmp52_ = chess_game_get_white (self->priv->game);
1492
_tmp53_ = _g_object_ref0 (_tmp52_);
1493
_g_object_unref0 (self->priv->human_player);
1494
self->priv->human_player = _tmp53_;
1495
_tmp54_ = application_get_engine (self, black_engine, black_level);
1496
_g_object_unref0 (self->priv->opponent_engine);
1497
self->priv->opponent_engine = _tmp54_;
1500
if (self->priv->opponent_engine != NULL) {
1501
g_signal_connect (self->priv->opponent_engine, "ready-changed", (GCallback) _application_engine_ready_cb_chess_engine_ready_changed, self);
1502
g_signal_connect (self->priv->opponent_engine, "moved", (GCallback) _application_engine_move_cb_chess_engine_moved, self);
1503
chess_engine_start (self->priv->opponent_engine);
1508
_tmp55_ = g_list_length (self->priv->game->move_stack);
1509
j = ((gint) _tmp55_) - 2;
1514
gconstpointer _tmp57_ = NULL;
1515
ChessState* _tmp58_;
1524
_tmp57_ = g_list_nth_data (self->priv->game->move_stack, (guint) j);
1525
_tmp58_ = _chess_state_ref0 ((ChessState*) _tmp57_);
1527
application_game_move_cb (self, self->priv->game, state->last_move);
1528
_chess_state_unref0 (state);
1532
self->priv->game_needs_saving = FALSE;
1533
chess_game_start (self->priv->game);
1534
if (self->priv->game->result != CHESS_RESULT_IN_PROGRESS) {
1535
application_game_end_cb (self, self->priv->game);
1537
gtk_widget_queue_draw (self->priv->white_time_label);
1538
gtk_widget_queue_draw (self->priv->black_time_label);
1539
_g_free0 (black_level);
1540
_g_free0 (black_engine);
1541
_g_free0 (white_level);
1542
_g_free0 (white_engine);
1543
moves = (_vala_array_free (moves, moves_length1, (GDestroyNotify) g_free), NULL);
1545
_g_object_unref0 (model);
1549
static gpointer _ai_profile_ref0 (gpointer self) {
1550
return self ? ai_profile_ref (self) : NULL;
1554
static gchar** _vala_array_dup2 (gchar** self, int length) {
1557
result = g_new0 (gchar*, length + 1);
1558
for (i = 0; i < length; i++) {
1559
result[i] = g_strdup (self[i]);
1565
static gchar** _vala_array_dup3 (gchar** self, int length) {
1568
result = g_new0 (gchar*, length + 1);
1569
for (i = 0; i < length; i++) {
1570
result[i] = g_strdup (self[i]);
1576
static gchar** _vala_array_dup4 (gchar** self, int length) {
1579
result = g_new0 (gchar*, length + 1);
1580
for (i = 0; i < length; i++) {
1581
result[i] = g_strdup (self[i]);
1587
static ChessEngine* application_get_engine (Application* self, const gchar* name, const gchar* difficulty) {
1588
ChessEngine* result = NULL;
1589
ChessEngine* engine = NULL;
1591
gchar** options = NULL;
1592
gint options_length1 = 0;
1593
gint _options_size_ = 0;
1594
const gchar* _tmp4_;
1596
static GQuark _tmp5__label0 = 0;
1597
static GQuark _tmp5__label1 = 0;
1599
g_return_val_if_fail (self != NULL, NULL);
1600
g_return_val_if_fail (name != NULL, NULL);
1601
g_return_val_if_fail (difficulty != NULL, NULL);
1603
if (g_strcmp0 (name, "human") == 0) {
1605
_ai_profile_unref0 (profile);
1606
_g_object_unref0 (engine);
1610
GList* p_collection;
1612
p_collection = self->priv->ai_profiles;
1613
for (p_it = p_collection; p_it != NULL; p_it = p_it->next) {
1616
_tmp0_ = _ai_profile_ref0 ((AIProfile*) p_it->data);
1619
gboolean _tmp1_ = FALSE;
1620
if (g_strcmp0 (name, "") == 0) {
1623
_tmp1_ = g_strcmp0 (p->name, name) == 0;
1627
_tmp2_ = _ai_profile_ref0 (p);
1628
_ai_profile_unref0 (profile);
1630
_ai_profile_unref0 (p);
1633
_ai_profile_unref0 (p);
1637
if (profile == NULL) {
1639
g_warning ("glchess.vala:351: Unknown AI profile %s", name);
1640
if (self->priv->ai_profiles == NULL) {
1642
_ai_profile_unref0 (profile);
1643
_g_object_unref0 (engine);
1646
_tmp3_ = _ai_profile_ref0 ((AIProfile*) self->priv->ai_profiles->data);
1647
_ai_profile_unref0 (profile);
1650
_tmp4_ = difficulty;
1651
_tmp5_ = (NULL == _tmp4_) ? 0 : g_quark_from_string (_tmp4_);
1652
if (_tmp5_ == ((0 != _tmp5__label0) ? _tmp5__label0 : (_tmp5__label0 = g_quark_from_static_string ("easy")))) {
1658
_tmp6_ = (_tmp7_ = profile->easy_options, (_tmp7_ == NULL) ? ((gpointer) _tmp7_) : _vala_array_dup2 (_tmp7_, profile->easy_options_length1));
1659
options = (_vala_array_free (options, options_length1, (GDestroyNotify) g_free), NULL);
1661
options_length1 = profile->easy_options_length1;
1662
_options_size_ = profile->easy_options_length1;
1666
} else if (_tmp5_ == ((0 != _tmp5__label1) ? _tmp5__label1 : (_tmp5__label1 = g_quark_from_static_string ("hard")))) {
1672
_tmp8_ = (_tmp9_ = profile->hard_options, (_tmp9_ == NULL) ? ((gpointer) _tmp9_) : _vala_array_dup3 (_tmp9_, profile->hard_options_length1));
1673
options = (_vala_array_free (options, options_length1, (GDestroyNotify) g_free), NULL);
1675
options_length1 = profile->hard_options_length1;
1676
_options_size_ = profile->hard_options_length1;
1686
_tmp10_ = (_tmp11_ = profile->normal_options, (_tmp11_ == NULL) ? ((gpointer) _tmp11_) : _vala_array_dup4 (_tmp11_, profile->normal_options_length1));
1687
options = (_vala_array_free (options, options_length1, (GDestroyNotify) g_free), NULL);
1689
options_length1 = profile->normal_options_length1;
1690
_options_size_ = profile->normal_options_length1;
1695
if (g_strcmp0 (profile->protocol, "cecp") == 0) {
1696
ChessEngineCECP* _tmp12_ = NULL;
1697
_tmp12_ = chess_engine_cecp_new (options, options_length1);
1698
_g_object_unref0 (engine);
1699
engine = (ChessEngine*) _tmp12_;
1701
if (g_strcmp0 (profile->protocol, "uci") == 0) {
1702
ChessEngineUCI* _tmp13_ = NULL;
1703
_tmp13_ = chess_engine_uci_new (options, options_length1);
1704
_g_object_unref0 (engine);
1705
engine = (ChessEngine*) _tmp13_;
1707
g_warning ("glchess.vala:378: Unknown AI protocol %s", profile->protocol);
1709
options = (_vala_array_free (options, options_length1, (GDestroyNotify) g_free), NULL);
1710
_ai_profile_unref0 (profile);
1711
_g_object_unref0 (engine);
1715
_tmp14_ = g_strdup (profile->binary);
1716
_g_free0 (engine->binary);
1717
engine->binary = _tmp14_;
1719
options = (_vala_array_free (options, options_length1, (GDestroyNotify) g_free), NULL);
1720
_ai_profile_unref0 (profile);
1725
static void _g_object_unref0_ (gpointer var) {
1726
(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
1730
static void _g_list_free__g_object_unref0_ (GList* self) {
1731
g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
1736
void application_start (Application* self, GFile* game, GError** error) {
1737
gchar* _tmp0_ = NULL;
1739
GList* _tmp2_ = NULL;
1743
GError * _inner_error_ = NULL;
1744
g_return_if_fail (self != NULL);
1745
_tmp0_ = g_build_filename (PKGDATADIR, "engines.conf", NULL, NULL);
1747
_tmp2_ = load_ai_profiles (_tmp1_);
1748
__g_list_free__ai_profile_unref0_0 (self->priv->ai_profiles);
1749
self->priv->ai_profiles = _tmp2_;
1752
GList* profile_collection;
1754
profile_collection = self->priv->ai_profiles;
1755
for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
1758
_tmp3_ = _ai_profile_ref0 ((AIProfile*) profile_it->data);
1761
g_message ("glchess.vala:390: Detected AI profile %s in %s", profile->name, profile->path);
1762
_ai_profile_unref0 (profile);
1767
GList* _tmp4_ = NULL;
1769
_tmp4_ = history_get_unfinished (self->priv->history);
1770
unfinished = _tmp4_;
1771
if (unfinished != NULL) {
1774
_tmp5_ = _g_object_ref0 ((GFile*) unfinished->data);
1776
application_load_game (self, file, TRUE, &_inner_error_);
1777
if (_inner_error_ != NULL) {
1778
g_propagate_error (error, _inner_error_);
1779
_g_object_unref0 (file);
1780
__g_list_free__g_object_unref0_0 (unfinished);
1783
_g_object_unref0 (file);
1785
application_start_new_game (self);
1787
__g_list_free__g_object_unref0_0 (unfinished);
1789
application_load_game (self, game, FALSE, &_inner_error_);
1790
if (_inner_error_ != NULL) {
1791
g_propagate_error (error, _inner_error_);
1795
_tmp6_ = g_settings_get_int (self->priv->settings, "width");
1796
_tmp7_ = g_settings_get_int (self->priv->settings, "height");
1797
gtk_window_set_default_size (self->priv->window, _tmp6_, _tmp7_);
1798
_tmp8_ = g_settings_get_boolean (self->priv->settings, "fullscreen");
1800
gtk_window_fullscreen (self->priv->window);
1803
_tmp9_ = g_settings_get_boolean (self->priv->settings, "maximized");
1805
gtk_window_maximize (self->priv->window);
1808
application_show (self);
1812
static void application_engine_ready_cb (Application* self, ChessEngine* engine) {
1814
g_return_if_fail (self != NULL);
1815
g_return_if_fail (engine != NULL);
1816
_tmp0_ = chess_engine_get_ready (self->priv->opponent_engine);
1818
chess_game_start (self->priv->game);
1819
gtk_widget_queue_draw ((GtkWidget*) self->priv->view);
1824
static void application_engine_move_cb (Application* self, ChessEngine* engine, const gchar* move) {
1825
g_return_if_fail (self != NULL);
1826
g_return_if_fail (engine != NULL);
1827
g_return_if_fail (move != NULL);
1828
chess_player_move (self->priv->opponent, move, TRUE);
1832
static void application_game_start_cb (Application* self, ChessGame* game) {
1833
g_return_if_fail (self != NULL);
1834
g_return_if_fail (game != NULL);
1835
if (self->priv->opponent_engine != NULL) {
1836
chess_engine_start_game (self->priv->opponent_engine);
1841
static void application_game_clock_tick_cb (Application* self, ChessClock* clock) {
1842
g_return_if_fail (self != NULL);
1843
g_return_if_fail (clock != NULL);
1844
gtk_widget_queue_draw (self->priv->white_time_label);
1845
gtk_widget_queue_draw (self->priv->black_time_label);
1849
static void application_game_turn_cb (Application* self, ChessGame* game, ChessPlayer* player) {
1850
gboolean _tmp0_ = FALSE;
1851
g_return_if_fail (self != NULL);
1852
g_return_if_fail (game != NULL);
1853
g_return_if_fail (player != NULL);
1854
if (self->priv->opponent_engine != NULL) {
1855
_tmp0_ = player == self->priv->opponent;
1860
chess_engine_request_move (self->priv->opponent_engine);
1865
static void application_set_move_text (Application* self, GtkTreeIter* iter, ChessMove* move) {
1866
static const gchar* human_descriptions[] = {"White pawn moves from %1$s to %2$s", "White pawn at %1$s takes the black pawn at %2$s", "White pawn at %1$s takes the black rook at %2$s", "White pawn at %1$s takes the black knight at %2$s", "White pawn at %1$s takes the black bishop at %2$s", "White pawn at %1$s takes the black queen at %2$s", "White rook moves from %1$s to %2$s", "White rook at %1$s takes the black pawn at %2$s", "White rook at %1$s takes the black rook at %2$s", "White rook at %1$s takes the black knight at %2$s", "White rook at %1$s takes the black bishop at %2$s", "White rook at %1$s takes the black queen at %2$s", "White knight moves from %1$s to %2$s", "White knight at %1$s takes the black pawn at %2$s", "White knight at %1$s takes the black rook at %2$s", "White knight at %1$s takes the black knight at %2$s", "White knight at %1$s takes the black bishop at %2$s", "White knight at %1$s takes the black queen at %2$s", "White bishop moves from %1$s to %2$s", "White bishop at %1$s takes the black pawn at %2$s", "White bishop at %1$s takes the black rook at %2$s", "White bishop at %1$s takes the black knight at %2$s", "White bishop at %1$s takes the black bishop at %2$s", "White bishop at %1$s takes the black queen at %2$s", "White queen moves from %1$s to %2$s", "White queen at %1$s takes the black pawn at %2$s", "White queen at %1$s takes the black rook at %2$s", "White queen at %1$s takes the black knight at %2$s", "White queen at %1$s takes the black bishop at %2$s", "White queen at %1$s takes the black queen at %2$s", "White king moves from %1$s to %2$s", "White king at %1$s takes the black pawn at %2$s", "White king at %1$s takes the black rook at %2$s", "White king at %1$s takes the black knight at %2$s", "White king at %1$s takes the black bishop at %2$s", "White king at %1$s takes the black queen at %2$s", "Black pawn moves from %1$s to %2$s", "Black pawn at %1$s takes the white pawn at %2$s", "Black pawn at %1$s takes the white rook at %2$s", "Black pawn at %1$s takes the white knight at %2$s", "Black pawn at %1$s takes the white bishop at %2$s", "Black pawn at %1$s takes the white queen at %2$s", "Black rook moves from %1$s to %2$s", "Black rook at %1$s takes the white pawn at %2$s", "Black rook at %1$s takes the white rook at %2$s", "Black rook at %1$s takes the white knight at %2$s", "Black rook at %1$s takes the white bishop at %2$s", "Black rook at %1$s takes the white queen at %2$s", "Black knight moves from %1$s to %2$s", "Black knight at %1$s takes the white pawn at %2$s", "Black knight at %1$s takes the white rook at %2$s", "Black knight at %1$s takes the white knight at %2$s", "Black knight at %1$s takes the white bishop at %2$s", "Black knight at %1$s takes the white queen at %2$s", "Black bishop moves from %1$s to %2$s", "Black bishop at %1$s takes the white pawn at %2$s", "Black bishop at %1$s takes the white rook at %2$s", "Black bishop at %1$s takes the white knight at %2$s", "Black bishop at %1$s takes the white bishop at %2$s", "Black bishop at %1$s takes the white queen at %2$s", "Black queen moves from %1$s to %2$s", "Black queen at %1$s takes the white pawn at %2$s", "Black queen at %1$s takes the white rook at %2$s", "Black queen at %1$s takes the white knight at %2$s", "Black queen at %1$s takes the white bishop at %2$s", "Black queen at %1$s takes the white queen at %2$s", "Black king moves from %1$s to %2$s", "Black king at %1$s takes the white pawn at %2$s", "Black king at %1$s takes the white rook at %2$s", "Black king at %1$s takes the white knight at %2$s", "Black king at %1$s takes the white bishop at %2$s", "Black king at %1$s takes the white queen at %2$s"};
1869
const gchar* _tmp1_ = NULL;
1870
const gchar* _tmp2_;
1872
static GQuark _tmp3__label0 = 0;
1873
static GQuark _tmp3__label1 = 0;
1874
static GQuark _tmp3__label2 = 0;
1875
GtkTreeModel* _tmp11_ = NULL;
1876
GtkListStore* _tmp12_;
1877
GtkListStore* model;
1878
gchar _tmp13_ = '\0';
1879
gchar* _tmp14_ = NULL;
1881
g_return_if_fail (self != NULL);
1882
g_return_if_fail (move != NULL);
1883
_tmp0_ = g_strdup ("");
1885
_tmp1_ = chess_scene_get_move_format (self->priv->scene);
1887
_tmp3_ = (NULL == _tmp2_) ? 0 : g_quark_from_string (_tmp2_);
1888
if (_tmp3_ == ((0 != _tmp3__label0) ? _tmp3__label0 : (_tmp3__label0 = g_quark_from_static_string ("human")))) {
1893
gchar* _tmp4_ = NULL;
1895
gchar* _tmp5_ = NULL;
1897
const gchar* _tmp6_ = NULL;
1898
gchar* _tmp7_ = NULL;
1899
if (move->victim == NULL) {
1902
index = (gint) (move->victim->type + 1);
1904
index = index + ((gint) (move->piece->type * 6));
1905
if (move->piece->player->color == COLOR_BLACK) {
1908
_tmp4_ = g_strdup_printf ("%c%d", 'a' + move->f0, move->r0 + 1);
1910
_tmp5_ = g_strdup_printf ("%c%d", 'a' + move->f1, move->r1 + 1);
1912
_tmp6_ = _ (human_descriptions[index]);
1913
_tmp7_ = g_strdup_printf (_tmp6_, start, end);
1914
_g_free0 (move_text);
1921
} else if (_tmp3_ == ((0 != _tmp3__label1) ? _tmp3__label1 : (_tmp3__label1 = g_quark_from_static_string ("san")))) {
1925
gchar* _tmp8_ = NULL;
1926
_tmp8_ = chess_move_get_san (move);
1927
_g_free0 (move_text);
1932
} else if (_tmp3_ == ((0 != _tmp3__label2) ? _tmp3__label2 : (_tmp3__label2 = g_quark_from_static_string ("fan")))) {
1936
gchar* _tmp9_ = NULL;
1937
_tmp9_ = chess_move_get_fan (move);
1938
_g_free0 (move_text);
1947
gchar* _tmp10_ = NULL;
1948
_tmp10_ = chess_move_get_lan (move);
1949
_g_free0 (move_text);
1950
move_text = _tmp10_;
1955
_tmp11_ = gtk_combo_box_get_model (self->priv->history_combo);
1956
_tmp12_ = _g_object_ref0 (GTK_LIST_STORE (_tmp11_));
1958
if ((move->number % 2) == 0) {
1963
_tmp14_ = g_strdup_printf ("%u%c. %s", (guint) ((move->number + 1) / 2), (gint) _tmp13_, move_text);
1965
gtk_list_store_set (model, iter, 0, label, -1, -1);
1967
_g_object_unref0 (model);
1968
_g_free0 (move_text);
1972
static void application_game_move_cb (Application* self, ChessGame* game, ChessMove* move) {
1973
gboolean _tmp0_ = FALSE;
1974
gboolean _tmp1_ = FALSE;
1976
GtkTreeModel* _tmp4_ = NULL;
1977
GtkListStore* _tmp5_;
1978
GtkListStore* model;
1979
GtkTreeIter iter = {0};
1980
GtkTreeIter _tmp6_ = {0};
1981
gboolean _tmp7_ = FALSE;
1983
g_return_if_fail (self != NULL);
1984
g_return_if_fail (game != NULL);
1985
g_return_if_fail (move != NULL);
1986
self->priv->game_needs_saving = TRUE;
1987
if (move->number == 1) {
1988
_tmp1_ = self->priv->opponent != NULL;
1993
_tmp0_ = self->priv->opponent->color == COLOR_WHITE;
1998
self->priv->game_needs_saving = FALSE;
2000
_tmp2_ = g_list_length (self->priv->pgn_game->moves);
2001
if (move->number > _tmp2_) {
2002
gchar* _tmp3_ = NULL;
2003
_tmp3_ = chess_move_get_san (move);
2004
self->priv->pgn_game->moves = g_list_append (self->priv->pgn_game->moves, _tmp3_);
2006
_tmp4_ = gtk_combo_box_get_model (self->priv->history_combo);
2007
_tmp5_ = _g_object_ref0 (GTK_LIST_STORE (_tmp4_));
2009
gtk_list_store_append (model, &_tmp6_);
2011
gtk_list_store_set (model, &iter, 1, move->number, -1, -1);
2012
application_set_move_text (self, &iter, move);
2013
_tmp8_ = chess_game_get_n_moves (game);
2014
if (move->number == _tmp8_) {
2016
_tmp9_ = chess_scene_get_move_number (self->priv->scene);
2017
_tmp7_ = _tmp9_ == (-1);
2022
gtk_combo_box_set_active_iter (self->priv->history_combo, &iter);
2024
gtk_widget_set_sensitive (self->priv->save_menu, TRUE);
2025
gtk_widget_set_sensitive (self->priv->save_as_menu, TRUE);
2026
application_update_history_panel (self);
2027
application_update_control_buttons (self);
2028
if (self->priv->opponent_engine != NULL) {
2029
chess_engine_report_move (self->priv->opponent_engine, move);
2031
gtk_widget_queue_draw ((GtkWidget*) self->priv->view);
2032
_g_object_unref0 (model);
2036
static void application_game_undo_cb (Application* self, ChessGame* game) {
2037
GList* _tmp0_ = NULL;
2038
GtkTreeModel* _tmp1_ = NULL;
2039
GtkListStore* _tmp2_;
2040
GtkListStore* model;
2041
GtkTreeIter iter = {0};
2043
GtkTreeIter _tmp4_ = {0};
2044
gboolean _tmp5_ = FALSE;
2047
g_return_if_fail (self != NULL);
2048
g_return_if_fail (game != NULL);
2049
if (self->priv->opponent_engine != NULL) {
2050
chess_engine_undo (self->priv->opponent_engine);
2052
_tmp0_ = g_list_last (self->priv->pgn_game->moves);
2053
self->priv->pgn_game->moves = g_list_remove_link (self->priv->pgn_game->moves, _tmp0_);
2054
_tmp1_ = gtk_combo_box_get_model (self->priv->history_combo);
2055
_tmp2_ = _g_object_ref0 (GTK_LIST_STORE (_tmp1_));
2057
_tmp3_ = gtk_tree_model_iter_n_children ((GtkTreeModel*) model, NULL);
2058
gtk_tree_model_iter_nth_child ((GtkTreeModel*) model, &_tmp4_, NULL, _tmp3_ - 1);
2060
gtk_list_store_remove (model, &iter);
2061
_tmp6_ = chess_scene_get_move_number (self->priv->scene);
2062
_tmp7_ = chess_game_get_n_moves (game);
2063
if (_tmp6_ > _tmp7_) {
2067
_tmp8_ = chess_scene_get_move_number (self->priv->scene);
2068
_tmp5_ = _tmp8_ == (-1);
2072
GtkTreeIter _tmp10_ = {0};
2073
_tmp9_ = gtk_tree_model_iter_n_children ((GtkTreeModel*) model, NULL);
2074
gtk_tree_model_iter_nth_child ((GtkTreeModel*) model, &_tmp10_, NULL, _tmp9_ - 1);
2076
gtk_combo_box_set_active_iter (self->priv->history_combo, &iter);
2077
gtk_widget_queue_draw ((GtkWidget*) self->priv->view);
2079
application_update_history_panel (self);
2080
application_update_control_buttons (self);
2081
_g_object_unref0 (model);
2085
static void application_update_control_buttons (Application* self) {
2087
gboolean can_resign;
2091
gboolean _tmp3_ = FALSE;
2093
g_return_if_fail (self != NULL);
2094
_tmp0_ = chess_game_get_n_moves (self->priv->game);
2095
can_resign = _tmp0_ > 0;
2096
_tmp1_ = can_resign;
2097
gtk_widget_set_sensitive (self->priv->resign_button, _tmp1_);
2098
gtk_widget_set_sensitive (self->priv->resign_menu, _tmp1_);
2099
_tmp2_ = chess_game_get_n_moves (self->priv->game);
2100
can_undo = _tmp2_ > 0;
2101
if (self->priv->opponent != NULL) {
2102
_tmp3_ = self->priv->opponent->color == COLOR_WHITE;
2108
_tmp4_ = chess_game_get_n_moves (self->priv->game);
2109
can_undo = _tmp4_ > 1;
2112
gtk_widget_set_sensitive (self->priv->undo_button, _tmp5_);
2113
gtk_widget_set_sensitive (self->priv->undo_menu, _tmp5_);
2117
static void application_game_end_cb (Application* self, ChessGame* game) {
2122
gchar* _tmp28_ = NULL;
2124
g_return_if_fail (self != NULL);
2125
g_return_if_fail (game != NULL);
2126
_tmp0_ = g_strdup ("");
2128
switch (game->result) {
2129
case CHESS_RESULT_WHITE_WON:
2131
const gchar* _tmp1_ = NULL;
2133
_tmp1_ = _ ("White wins");
2134
_tmp2_ = g_strdup (_tmp1_);
2137
pgn_game_set_result (self->priv->pgn_game, pgn_game_RESULT_WHITE);
2140
case CHESS_RESULT_BLACK_WON:
2142
const gchar* _tmp3_ = NULL;
2144
_tmp3_ = _ ("Black wins");
2145
_tmp4_ = g_strdup (_tmp3_);
2148
pgn_game_set_result (self->priv->pgn_game, pgn_game_RESULT_BLACK);
2151
case CHESS_RESULT_DRAW:
2153
const gchar* _tmp5_ = NULL;
2155
_tmp5_ = _ ("Game is drawn");
2156
_tmp6_ = g_strdup (_tmp5_);
2159
pgn_game_set_result (self->priv->pgn_game, pgn_game_RESULT_DRAW);
2167
_tmp7_ = g_strdup ("");
2169
switch (game->rule) {
2170
case CHESS_RULE_CHECKMATE:
2172
const gchar* _tmp8_ = NULL;
2174
_tmp8_ = _ ("Opponent is in check and cannot move (checkmate)");
2175
_tmp9_ = g_strdup (_tmp8_);
2180
case CHESS_RULE_STALEMATE:
2182
const gchar* _tmp10_ = NULL;
2184
_tmp10_ = _ ("Opponent cannot move (stalemate)");
2185
_tmp11_ = g_strdup (_tmp10_);
2190
case CHESS_RULE_FIFTY_MOVES:
2192
const gchar* _tmp12_ = NULL;
2194
_tmp12_ = _ ("No piece has been taken or pawn moved in the last fifty moves");
2195
_tmp13_ = g_strdup (_tmp12_);
2200
case CHESS_RULE_TIMEOUT:
2202
const gchar* _tmp14_ = NULL;
2204
_tmp14_ = _ ("Opponent has run out of time");
2205
_tmp15_ = g_strdup (_tmp14_);
2210
case CHESS_RULE_THREE_FOLD_REPETITION:
2212
const gchar* _tmp16_ = NULL;
2214
_tmp16_ = _ ("The same board state has occurred three times (three fold repetition)");
2215
_tmp17_ = g_strdup (_tmp16_);
2220
case CHESS_RULE_INSUFFICIENT_MATERIAL:
2222
const gchar* _tmp18_ = NULL;
2224
_tmp18_ = _ ("Neither player can cause checkmate (insufficient material)");
2225
_tmp19_ = g_strdup (_tmp18_);
2230
case CHESS_RULE_RESIGN:
2232
if (game->result == CHESS_RESULT_WHITE_WON) {
2233
const gchar* _tmp20_ = NULL;
2235
_tmp20_ = _ ("The black player has resigned");
2236
_tmp21_ = g_strdup (_tmp20_);
2240
const gchar* _tmp22_ = NULL;
2242
_tmp22_ = _ ("The white player has resigned");
2243
_tmp23_ = g_strdup (_tmp22_);
2249
case CHESS_RULE_ABANDONMENT:
2251
const gchar* _tmp24_ = NULL;
2253
_tmp24_ = _ ("The game has been abandoned");
2254
_tmp25_ = g_strdup (_tmp24_);
2257
pgn_game_set_termination (self->priv->pgn_game, pgn_game_TERMINATE_ABANDONED);
2260
case CHESS_RULE_DEATH:
2262
const gchar* _tmp26_ = NULL;
2264
_tmp26_ = _ ("One of the players has died");
2265
_tmp27_ = g_strdup (_tmp26_);
2268
pgn_game_set_termination (self->priv->pgn_game, pgn_game_TERMINATE_DEATH);
2274
_tmp28_ = g_strdup_printf ("<big><b>%s</b></big>", title);
2276
gtk_label_set_markup (self->priv->info_title_label, _tmp29_);
2278
gtk_label_set_text (self->priv->info_label, reason);
2279
gtk_widget_show ((GtkWidget*) self->priv->info_bar);
2280
gtk_widget_queue_draw (self->priv->white_time_label);
2281
gtk_widget_queue_draw (self->priv->black_time_label);
2287
void application_show (Application* self) {
2288
g_return_if_fail (self != NULL);
2289
gtk_widget_show ((GtkWidget*) self->priv->window);
2293
gboolean G_MODULE_EXPORT glchess_app_delete_event_cb (GtkWidget* widget, GdkEvent* event, Application* self) {
2294
gboolean result = FALSE;
2295
g_return_val_if_fail (self != NULL, FALSE);
2296
g_return_val_if_fail (widget != NULL, FALSE);
2297
g_return_val_if_fail (event != NULL, FALSE);
2298
application_quit (self);
2304
gboolean G_MODULE_EXPORT glchess_app_configure_event_cb (GtkWidget* widget, GdkEventConfigure* event, Application* self) {
2305
gboolean result = FALSE;
2306
gboolean _tmp0_ = FALSE;
2308
g_return_val_if_fail (self != NULL, FALSE);
2309
g_return_val_if_fail (widget != NULL, FALSE);
2310
_tmp1_ = g_settings_get_boolean (self->priv->settings, "maximized");
2313
_tmp2_ = g_settings_get_boolean (self->priv->settings, "fullscreen");
2319
g_settings_set_int (self->priv->settings, "width", (*event).width);
2320
g_settings_set_int (self->priv->settings, "height", (*event).height);
2327
gboolean G_MODULE_EXPORT glchess_app_window_state_event_cb (GtkWidget* widget, GdkEventWindowState* event, Application* self) {
2328
gboolean result = FALSE;
2329
g_return_val_if_fail (self != NULL, FALSE);
2330
g_return_val_if_fail (widget != NULL, FALSE);
2331
if (((*event).changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
2332
gboolean is_maximized;
2333
is_maximized = ((*event).new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
2334
g_settings_set_boolean (self->priv->settings, "maximized", is_maximized);
2336
if (((*event).changed_mask & GDK_WINDOW_STATE_FULLSCREEN) != 0) {
2337
gboolean is_fullscreen;
2338
const gchar* _tmp0_ = NULL;
2339
is_fullscreen = ((*event).new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
2340
g_settings_set_boolean (self->priv->settings, "fullscreen", is_fullscreen);
2341
if (is_fullscreen) {
2342
_tmp0_ = GTK_STOCK_LEAVE_FULLSCREEN;
2344
_tmp0_ = GTK_STOCK_FULLSCREEN;
2346
gtk_menu_item_set_label (self->priv->fullscreen_menu, _tmp0_);
2353
void G_MODULE_EXPORT new_game_cb (GtkWidget* widget, Application* self) {
2354
gboolean _tmp0_ = FALSE;
2355
g_return_if_fail (self != NULL);
2356
g_return_if_fail (widget != NULL);
2357
if (self->priv->game_needs_saving) {
2360
gboolean _tmp1_ = FALSE;
2361
if (self->priv->in_history) {
2362
_tmp1_ = self->priv->game_file != NULL;
2369
const gchar* _tmp2_ = NULL;
2370
GtkMessageDialog* _tmp3_ = NULL;
2371
GtkMessageDialog* dialog;
2372
const gchar* _tmp4_ = NULL;
2373
const gchar* _tmp5_ = NULL;
2376
_tmp2_ = _ ("Save this game before starting a new one?");
2377
_tmp3_ = (GtkMessageDialog*) gtk_message_dialog_new_with_markup (self->priv->window, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "<span weight=\"bold\" size=\"larger\">%s</span>", _tmp2_, NULL);
2378
dialog = g_object_ref_sink (_tmp3_);
2379
gtk_dialog_add_button ((GtkDialog*) dialog, GTK_STOCK_CANCEL, (gint) GTK_RESPONSE_CANCEL);
2380
_tmp4_ = _ ("_Abandon game");
2381
gtk_dialog_add_button ((GtkDialog*) dialog, _tmp4_, (gint) GTK_RESPONSE_NO);
2382
_tmp5_ = _ ("_Save game for later");
2383
gtk_dialog_add_button ((GtkDialog*) dialog, _tmp5_, (gint) GTK_RESPONSE_YES);
2384
_tmp6_ = gtk_dialog_run ((GtkDialog*) dialog);
2386
gtk_widget_destroy ((GtkWidget*) dialog);
2387
if (_result_ == GTK_RESPONSE_CANCEL) {
2388
_g_object_unref0 (dialog);
2391
if (_result_ == GTK_RESPONSE_NO) {
2392
self->priv->in_history = FALSE;
2393
self->priv->game_needs_saving = FALSE;
2395
_g_object_unref0 (dialog);
2397
application_autosave (self);
2398
application_start_new_game (self);
2402
void G_MODULE_EXPORT resign_cb (GtkWidget* widget, Application* self) {
2403
ChessPlayer* _tmp0_ = NULL;
2404
g_return_if_fail (self != NULL);
2405
g_return_if_fail (widget != NULL);
2406
_tmp0_ = chess_game_get_current_player (self->priv->game);
2407
chess_player_resign (_tmp0_);
2411
void G_MODULE_EXPORT claim_draw_cb (GtkWidget* widget, Application* self) {
2412
ChessPlayer* _tmp0_ = NULL;
2413
g_return_if_fail (self != NULL);
2414
g_return_if_fail (widget != NULL);
2415
_tmp0_ = chess_game_get_current_player (self->priv->game);
2416
chess_player_claim_draw (_tmp0_);
2420
void G_MODULE_EXPORT undo_move_cb (GtkWidget* widget, Application* self) {
2421
g_return_if_fail (self != NULL);
2422
g_return_if_fail (widget != NULL);
2423
if (self->priv->opponent != NULL) {
2424
chess_player_undo (self->priv->human_player);
2426
ChessPlayer* _tmp0_ = NULL;
2427
_tmp0_ = chess_game_get_opponent (self->priv->game);
2428
chess_player_undo (_tmp0_);
2433
void G_MODULE_EXPORT quit_cb (GtkWidget* widget, Application* self) {
2434
g_return_if_fail (self != NULL);
2435
g_return_if_fail (widget != NULL);
2436
application_quit (self);
2440
gboolean G_MODULE_EXPORT white_time_draw_cb (GtkWidget* widget, cairo_t* c, Application* self) {
2441
gboolean result = FALSE;
2442
static const gdouble fg[] = {0.0, 0.0, 0.0};
2443
static const gdouble bg[] = {1.0, 1.0, 1.0};
2444
ChessClock* _tmp0_ = NULL;
2445
gchar* _tmp1_ = NULL;
2447
g_return_val_if_fail (self != NULL, FALSE);
2448
g_return_val_if_fail (widget != NULL, FALSE);
2449
g_return_val_if_fail (c != NULL, FALSE);
2450
_tmp0_ = chess_game_get_clock (self->priv->game);
2451
_tmp1_ = application_make_clock_text (self, _tmp0_, COLOR_WHITE);
2453
application_draw_time (self, widget, c, _tmp2_, fg, 3, bg, 3);
2460
gboolean G_MODULE_EXPORT black_time_draw_cb (GtkWidget* widget, cairo_t* c, Application* self) {
2461
gboolean result = FALSE;
2462
static const gdouble fg[] = {1.0, 1.0, 1.0};
2463
static const gdouble bg[] = {0.0, 0.0, 0.0};
2464
ChessClock* _tmp0_ = NULL;
2465
gchar* _tmp1_ = NULL;
2467
g_return_val_if_fail (self != NULL, FALSE);
2468
g_return_val_if_fail (widget != NULL, FALSE);
2469
g_return_val_if_fail (c != NULL, FALSE);
2470
_tmp0_ = chess_game_get_clock (self->priv->game);
2471
_tmp1_ = application_make_clock_text (self, _tmp0_, COLOR_BLACK);
2473
application_draw_time (self, widget, c, _tmp2_, fg, 3, bg, 3);
2480
static gchar* application_make_clock_text (Application* self, ChessClock* clock, Color color) {
2481
gchar* result = NULL;
2483
g_return_val_if_fail (self != NULL, NULL);
2484
if (clock == NULL) {
2486
_tmp0_ = g_strdup ("ā");
2490
if (color == COLOR_WHITE) {
2491
ChessClock* _tmp1_ = NULL;
2493
ChessClock* _tmp3_ = NULL;
2495
_tmp1_ = chess_game_get_clock (self->priv->game);
2496
_tmp2_ = chess_clock_get_white_duration (_tmp1_);
2497
_tmp3_ = chess_game_get_clock (self->priv->game);
2498
_tmp4_ = chess_clock_get_white_used_in_seconds (_tmp3_);
2499
used = (gint) ((_tmp2_ / 1000) - _tmp4_);
2501
ChessClock* _tmp5_ = NULL;
2503
ChessClock* _tmp7_ = NULL;
2505
_tmp5_ = chess_game_get_clock (self->priv->game);
2506
_tmp6_ = chess_clock_get_black_duration (_tmp5_);
2507
_tmp7_ = chess_game_get_clock (self->priv->game);
2508
_tmp8_ = chess_clock_get_black_used_in_seconds (_tmp7_);
2509
used = (gint) ((_tmp6_ / 1000) - _tmp8_);
2512
gchar* _tmp9_ = NULL;
2513
_tmp9_ = g_strdup_printf ("%d:%02d", used / 60, used % 60);
2517
gchar* _tmp10_ = NULL;
2518
_tmp10_ = g_strdup_printf (":%02d", used);
2525
static void application_draw_time (Application* self, GtkWidget* widget, cairo_t* c, const gchar* text, gdouble* fg, int fg_length1, gdouble* bg, int bg_length1) {
2527
GtkStateType _tmp0_;
2529
cairo_text_extents_t extents = {0};
2530
cairo_text_extents_t _tmp2_ = {0};
2533
g_return_if_fail (self != NULL);
2534
g_return_if_fail (widget != NULL);
2535
g_return_if_fail (c != NULL);
2536
g_return_if_fail (text != NULL);
2538
_tmp0_ = gtk_widget_get_state (widget);
2539
if (_tmp0_ == GTK_STATE_INSENSITIVE) {
2542
cairo_set_source_rgba (c, bg[0], bg[1], bg[2], alpha);
2544
cairo_set_source_rgba (c, fg[0], fg[1], fg[2], alpha);
2545
cairo_select_font_face (c, "fixed", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
2546
_tmp1_ = gtk_widget_get_allocated_height (widget);
2547
cairo_set_font_size (c, 0.6 * _tmp1_);
2548
cairo_text_extents (c, text, &_tmp2_);
2550
_tmp3_ = gtk_widget_get_allocated_width (widget);
2551
_tmp4_ = gtk_widget_get_allocated_height (widget);
2552
cairo_move_to (c, ((_tmp3_ - extents.width) / 2) - extents.x_bearing, ((_tmp4_ - extents.height) / 2) - extents.y_bearing);
2553
cairo_show_text (c, text);
2554
gtk_widget_set_size_request (widget, ((gint) extents.width) + 6, -1);
2558
void G_MODULE_EXPORT history_combo_changed_cb (GtkComboBox* combo, Application* self) {
2559
GtkTreeIter iter = {0};
2560
GtkTreeIter _tmp0_ = {0};
2562
gint move_number = 0;
2563
GtkTreeModel* _tmp2_ = NULL;
2564
gboolean _tmp3_ = FALSE;
2565
g_return_if_fail (self != NULL);
2566
g_return_if_fail (combo != NULL);
2567
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
2572
_tmp2_ = gtk_combo_box_get_model (combo);
2573
gtk_tree_model_get (_tmp2_, &iter, 1, &move_number, -1, -1);
2574
if (self->priv->game == NULL) {
2578
_tmp4_ = chess_game_get_n_moves (self->priv->game);
2579
_tmp3_ = move_number == _tmp4_;
2584
chess_scene_set_move_number (self->priv->scene, move_number);
2588
void G_MODULE_EXPORT history_latest_clicked_cb (GtkWidget* widget, Application* self) {
2589
g_return_if_fail (self != NULL);
2590
g_return_if_fail (widget != NULL);
2591
chess_scene_set_move_number (self->priv->scene, -1);
2595
void G_MODULE_EXPORT history_next_clicked_cb (GtkWidget* widget, Application* self) {
2600
g_return_if_fail (self != NULL);
2601
g_return_if_fail (widget != NULL);
2602
_tmp0_ = chess_scene_get_move_number (self->priv->scene);
2603
if (_tmp0_ == (-1)) {
2606
_tmp1_ = chess_scene_get_move_number (self->priv->scene);
2607
move_number = _tmp1_ + 1;
2608
_tmp2_ = chess_game_get_n_moves (self->priv->game);
2609
if (move_number >= _tmp2_) {
2610
chess_scene_set_move_number (self->priv->scene, -1);
2612
chess_scene_set_move_number (self->priv->scene, move_number);
2617
void G_MODULE_EXPORT history_previous_clicked_cb (GtkWidget* widget, Application* self) {
2620
g_return_if_fail (self != NULL);
2621
g_return_if_fail (widget != NULL);
2622
_tmp0_ = chess_scene_get_move_number (self->priv->scene);
2626
_tmp1_ = chess_scene_get_move_number (self->priv->scene);
2627
if (_tmp1_ == (-1)) {
2629
_tmp2_ = chess_game_get_n_moves (self->priv->game);
2630
chess_scene_set_move_number (self->priv->scene, ((gint) _tmp2_) - 1);
2633
_tmp3_ = chess_scene_get_move_number (self->priv->scene);
2634
chess_scene_set_move_number (self->priv->scene, _tmp3_ - 1);
2639
void G_MODULE_EXPORT history_start_clicked_cb (GtkWidget* widget, Application* self) {
2640
g_return_if_fail (self != NULL);
2641
g_return_if_fail (widget != NULL);
2642
chess_scene_set_move_number (self->priv->scene, 0);
2646
void G_MODULE_EXPORT toggle_fullscreen_cb (GtkWidget* widget, Application* self) {
2647
const gchar* _tmp0_ = NULL;
2648
g_return_if_fail (self != NULL);
2649
g_return_if_fail (widget != NULL);
2650
_tmp0_ = gtk_menu_item_get_label (self->priv->fullscreen_menu);
2651
if (g_strcmp0 (_tmp0_, GTK_STOCK_FULLSCREEN) == 0) {
2652
gtk_window_fullscreen (self->priv->window);
2654
gtk_window_unfullscreen (self->priv->window);
2659
void G_MODULE_EXPORT preferences_cb (GtkWidget* widget, Application* self) {
2660
GtkBuilder* _tmp0_ = NULL;
2661
gchar* _tmp1_ = NULL;
2663
GObject* _tmp3_ = NULL;
2665
GObject* _tmp5_ = NULL;
2666
GObject* _tmp6_ = NULL;
2667
GObject* _tmp7_ = NULL;
2668
GObject* _tmp8_ = NULL;
2669
GObject* _tmp9_ = NULL;
2670
GObject* _tmp10_ = NULL;
2671
GObject* _tmp11_ = NULL;
2672
GtkComboBox* _tmp12_;
2673
GtkComboBox* side_combo;
2676
GObject* _tmp15_ = NULL;
2677
GtkComboBox* _tmp16_;
2678
GtkComboBox* ai_combo;
2679
GtkTreeModel* _tmp17_ = NULL;
2680
GtkListStore* _tmp18_;
2681
GtkListStore* ai_model;
2682
gchar* _tmp19_ = NULL;
2683
gchar* opponent_name;
2684
GObject* _tmp25_ = NULL;
2685
GtkComboBox* _tmp26_;
2686
GtkComboBox* difficulty_combo;
2687
gchar* _tmp27_ = NULL;
2689
GObject* _tmp29_ = NULL;
2690
GtkComboBox* _tmp30_;
2691
GObject* _tmp31_ = NULL;
2692
GtkAdjustment* _tmp32_;
2693
GObject* _tmp33_ = NULL;
2694
GtkContainer* _tmp34_;
2695
GObject* _tmp35_ = NULL;
2696
GtkComboBox* _tmp36_;
2698
GObject* _tmp38_ = NULL;
2699
GtkComboBox* _tmp39_;
2700
GtkComboBox* orientation_combo;
2701
gchar* _tmp40_ = NULL;
2703
GObject* _tmp42_ = NULL;
2704
GtkComboBox* _tmp43_;
2705
GtkComboBox* move_combo;
2706
gchar* _tmp44_ = NULL;
2708
GObject* _tmp46_ = NULL;
2709
GtkComboBox* _tmp47_;
2710
GtkComboBox* promotion_combo;
2711
gchar* _tmp48_ = NULL;
2713
GObject* _tmp50_ = NULL;
2714
GtkComboBox* _tmp51_;
2715
GtkComboBox* theme_combo;
2716
gchar* _tmp52_ = NULL;
2718
GError * _inner_error_ = NULL;
2719
g_return_if_fail (self != NULL);
2720
g_return_if_fail (widget != NULL);
2721
if (self->priv->preferences_dialog != NULL) {
2722
gtk_window_present ((GtkWindow*) self->priv->preferences_dialog);
2725
_tmp0_ = gtk_builder_new ();
2726
_g_object_unref0 (self->priv->preferences_builder);
2727
self->priv->preferences_builder = _tmp0_;
2728
_tmp1_ = g_build_filename (PKGDATADIR, "preferences.ui", NULL, NULL);
2730
gtk_builder_add_from_file (self->priv->preferences_builder, _tmp2_, &_inner_error_);
2732
if (_inner_error_ != NULL) {
2733
goto __catch2_g_error;
2740
_inner_error_ = NULL;
2741
g_warning ("glchess.vala:1021: Could not load preferences UI: %s", e->message);
2745
if (_inner_error_ != NULL) {
2746
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);
2747
g_clear_error (&_inner_error_);
2750
_tmp3_ = gtk_builder_get_object (self->priv->preferences_builder, "preferences");
2751
_tmp4_ = _g_object_ref0 (GTK_DIALOG (_tmp3_));
2752
_g_object_unref0 (self->priv->preferences_dialog);
2753
self->priv->preferences_dialog = _tmp4_;
2754
_tmp5_ = gtk_builder_get_object (self->priv->preferences_builder, "show_numbering_check");
2755
g_settings_bind (self->priv->settings, "show-numbering", _tmp5_, "active", G_SETTINGS_BIND_DEFAULT);
2756
_tmp6_ = gtk_builder_get_object (self->priv->preferences_builder, "show_move_hints_check");
2757
g_settings_bind (self->priv->settings, "show-move-hints", _tmp6_, "active", G_SETTINGS_BIND_DEFAULT);
2758
_tmp7_ = gtk_builder_get_object (self->priv->preferences_builder, "show_toolbar_check");
2759
g_settings_bind (self->priv->settings, "show-toolbar", _tmp7_, "active", G_SETTINGS_BIND_DEFAULT);
2760
_tmp8_ = gtk_builder_get_object (self->priv->preferences_builder, "show_history_check");
2761
g_settings_bind (self->priv->settings, "show-history", _tmp8_, "active", G_SETTINGS_BIND_DEFAULT);
2762
_tmp9_ = gtk_builder_get_object (self->priv->preferences_builder, "show_3d_check");
2763
g_settings_bind (self->priv->settings, "show-3d", _tmp9_, "active", G_SETTINGS_BIND_DEFAULT);
2764
_tmp10_ = gtk_builder_get_object (self->priv->preferences_builder, "show_3d_smooth_check");
2765
g_settings_bind (self->priv->settings, "show-3d-smooth", _tmp10_, "active", G_SETTINGS_BIND_DEFAULT);
2766
_tmp11_ = gtk_builder_get_object (self->priv->preferences_builder, "side_combo");
2767
_tmp12_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp11_));
2768
side_combo = _tmp12_;
2769
_tmp14_ = g_settings_get_boolean (self->priv->settings, "play-as-white");
2775
gtk_combo_box_set_active (side_combo, _tmp13_);
2776
_tmp15_ = gtk_builder_get_object (self->priv->preferences_builder, "opponent_combo");
2777
_tmp16_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp15_));
2779
_tmp17_ = gtk_combo_box_get_model (ai_combo);
2780
_tmp18_ = _g_object_ref0 (GTK_LIST_STORE (_tmp17_));
2782
_tmp19_ = g_settings_get_string (self->priv->settings, "opponent");
2783
opponent_name = _tmp19_;
2784
if (g_strcmp0 (opponent_name, "human") == 0) {
2785
gtk_combo_box_set_active (ai_combo, 0);
2788
GList* p_collection;
2790
p_collection = self->priv->ai_profiles;
2791
for (p_it = p_collection; p_it != NULL; p_it = p_it->next) {
2794
_tmp20_ = _ai_profile_ref0 ((AIProfile*) p_it->data);
2797
GtkTreeIter iter = {0};
2798
GtkTreeIter _tmp21_ = {0};
2799
gboolean _tmp22_ = FALSE;
2800
gtk_list_store_append (ai_model, &_tmp21_);
2802
gtk_list_store_set (ai_model, &iter, 0, p->name, 1, p->name, -1, -1);
2803
if (g_strcmp0 (p->name, opponent_name) == 0) {
2806
gboolean _tmp23_ = FALSE;
2807
if (g_strcmp0 (opponent_name, "") == 0) {
2809
_tmp24_ = gtk_combo_box_get_active (ai_combo);
2810
_tmp23_ = _tmp24_ == (-1);
2817
gtk_combo_box_set_active_iter (ai_combo, &iter);
2819
_ai_profile_unref0 (p);
2823
g_settings_bind (self->priv->settings, "show-history", ai_combo, "visible", G_SETTINGS_BIND_SET);
2824
_tmp25_ = gtk_builder_get_object (self->priv->preferences_builder, "difficulty_combo");
2825
_tmp26_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp25_));
2826
difficulty_combo = _tmp26_;
2827
_tmp27_ = g_settings_get_string (self->priv->settings, "difficulty");
2829
application_set_combo (self, difficulty_combo, 1, _tmp28_);
2831
_tmp29_ = gtk_builder_get_object (self->priv->preferences_builder, "duration_combo");
2832
_tmp30_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp29_));
2833
_g_object_unref0 (self->priv->duration_combo);
2834
self->priv->duration_combo = _tmp30_;
2835
_tmp31_ = gtk_builder_get_object (self->priv->preferences_builder, "duration_adjustment");
2836
_tmp32_ = _g_object_ref0 (GTK_ADJUSTMENT (_tmp31_));
2837
_g_object_unref0 (self->priv->duration_adjustment);
2838
self->priv->duration_adjustment = _tmp32_;
2839
_tmp33_ = gtk_builder_get_object (self->priv->preferences_builder, "custom_duration_box");
2840
_tmp34_ = _g_object_ref0 (GTK_CONTAINER (_tmp33_));
2841
_g_object_unref0 (self->priv->custom_duration_box);
2842
self->priv->custom_duration_box = _tmp34_;
2843
_tmp35_ = gtk_builder_get_object (self->priv->preferences_builder, "custom_duration_units_combo");
2844
_tmp36_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp35_));
2845
_g_object_unref0 (self->priv->custom_duration_units_combo);
2846
self->priv->custom_duration_units_combo = _tmp36_;
2847
_tmp37_ = g_settings_get_int (self->priv->settings, "duration");
2848
application_set_duration (self, _tmp37_, TRUE);
2849
_tmp38_ = gtk_builder_get_object (self->priv->preferences_builder, "orientation_combo");
2850
_tmp39_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp38_));
2851
orientation_combo = _tmp39_;
2852
_tmp40_ = g_settings_get_string (self->priv->settings, "board-side");
2854
application_set_combo (self, orientation_combo, 1, _tmp41_);
2856
_tmp42_ = gtk_builder_get_object (self->priv->preferences_builder, "move_format_combo");
2857
_tmp43_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp42_));
2858
move_combo = _tmp43_;
2859
_tmp44_ = g_settings_get_string (self->priv->settings, "move-format");
2861
application_set_combo (self, move_combo, 1, _tmp45_);
2863
_tmp46_ = gtk_builder_get_object (self->priv->preferences_builder, "promotion_type_combo");
2864
_tmp47_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp46_));
2865
promotion_combo = _tmp47_;
2866
_tmp48_ = g_settings_get_string (self->priv->settings, "promotion-type");
2868
application_set_combo (self, promotion_combo, 1, _tmp49_);
2870
_tmp50_ = gtk_builder_get_object (self->priv->preferences_builder, "piece_style_combo");
2871
_tmp51_ = _g_object_ref0 (GTK_COMBO_BOX (_tmp50_));
2872
theme_combo = _tmp51_;
2873
_tmp52_ = g_settings_get_string (self->priv->settings, "piece-theme");
2875
application_set_combo (self, theme_combo, 1, _tmp53_);
2877
gtk_builder_connect_signals (self->priv->preferences_builder, self);
2878
gtk_window_present ((GtkWindow*) self->priv->preferences_dialog);
2879
_g_object_unref0 (theme_combo);
2880
_g_object_unref0 (promotion_combo);
2881
_g_object_unref0 (move_combo);
2882
_g_object_unref0 (orientation_combo);
2883
_g_object_unref0 (difficulty_combo);
2884
_g_free0 (opponent_name);
2885
_g_object_unref0 (ai_model);
2886
_g_object_unref0 (ai_combo);
2887
_g_object_unref0 (side_combo);
2891
static void application_set_combo (Application* self, GtkComboBox* combo, gint value_index, const gchar* value) {
2892
GtkTreeIter iter = {0};
2893
GtkTreeModel* _tmp0_ = NULL;
2894
GtkTreeModel* _tmp1_;
2895
GtkTreeModel* model;
2896
GtkTreeIter _tmp2_ = {0};
2898
g_return_if_fail (self != NULL);
2899
g_return_if_fail (combo != NULL);
2900
g_return_if_fail (value != NULL);
2901
_tmp0_ = gtk_combo_box_get_model (combo);
2902
_tmp1_ = _g_object_ref0 (_tmp0_);
2904
_tmp3_ = gtk_tree_model_get_iter_first (model, &_tmp2_);
2907
_g_object_unref0 (model);
2917
_tmp5_ = gtk_tree_model_iter_next (model, &iter);
2923
gtk_tree_model_get (model, &iter, value_index, &v, -1, -1);
2924
if (g_strcmp0 (v, value) == 0) {
2925
gtk_combo_box_set_active_iter (combo, &iter);
2927
_g_object_unref0 (model);
2933
_g_object_unref0 (model);
2937
static gchar* application_get_combo (Application* self, GtkComboBox* combo, gint value_index) {
2938
gchar* result = NULL;
2939
gchar* value = NULL;
2940
GtkTreeIter iter = {0};
2941
GtkTreeIter _tmp0_ = {0};
2943
GtkTreeModel* _tmp2_ = NULL;
2944
g_return_val_if_fail (self != NULL, NULL);
2945
g_return_val_if_fail (combo != NULL, NULL);
2946
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
2953
_tmp2_ = gtk_combo_box_get_model (combo);
2954
gtk_tree_model_get (_tmp2_, &iter, value_index, &value, -1, -1);
2960
void G_MODULE_EXPORT side_combo_changed_cb (GtkComboBox* combo, Application* self) {
2961
GtkTreeIter iter = {0};
2962
GtkTreeIter _tmp0_ = {0};
2964
gboolean play_as_white = FALSE;
2965
GtkTreeModel* _tmp2_ = NULL;
2966
g_return_if_fail (self != NULL);
2967
g_return_if_fail (combo != NULL);
2968
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
2973
_tmp2_ = gtk_combo_box_get_model (combo);
2974
gtk_tree_model_get (_tmp2_, &iter, 1, &play_as_white, -1, -1);
2975
g_settings_set_boolean (self->priv->settings, "play-as-white", play_as_white);
2979
void G_MODULE_EXPORT opponent_combo_changed_cb (GtkComboBox* combo, Application* self) {
2980
GtkTreeIter iter = {0};
2981
GtkTreeIter _tmp0_ = {0};
2983
gchar* opponent = NULL;
2984
GtkTreeModel* _tmp2_ = NULL;
2985
g_return_if_fail (self != NULL);
2986
g_return_if_fail (combo != NULL);
2987
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
2992
_tmp2_ = gtk_combo_box_get_model (combo);
2993
gtk_tree_model_get (_tmp2_, &iter, 1, &opponent, -1, -1);
2994
g_settings_set_string (self->priv->settings, "opponent", opponent);
2995
_g_free0 (opponent);
2999
void G_MODULE_EXPORT difficulty_combo_changed_cb (GtkComboBox* combo, Application* self) {
3000
GtkTreeIter iter = {0};
3001
GtkTreeIter _tmp0_ = {0};
3003
gchar* difficulty = NULL;
3004
GtkTreeModel* _tmp2_ = NULL;
3005
g_return_if_fail (self != NULL);
3006
g_return_if_fail (combo != NULL);
3007
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
3012
_tmp2_ = gtk_combo_box_get_model (combo);
3013
gtk_tree_model_get (_tmp2_, &iter, 1, &difficulty, -1, -1);
3014
g_settings_set_string (self->priv->settings, "difficulty", difficulty);
3015
_g_free0 (difficulty);
3019
static void application_set_duration (Application* self, gint duration, gboolean simplify) {
3020
GtkTreeModel* _tmp0_ = NULL;
3021
GtkTreeModel* _tmp1_;
3022
GtkTreeModel* model;
3023
GtkTreeIter iter = {0};
3024
GtkTreeIter _tmp2_ = {0};
3025
GtkTreeIter max_iter;
3026
gint max_multiplier;
3027
GtkTreeIter _tmp3_ = {0};
3030
GtkTreeModel* _tmp8_ = NULL;
3031
GtkTreeModel* _tmp9_;
3032
GtkTreeIter _tmp10_ = {0};
3034
g_return_if_fail (self != NULL);
3035
_tmp0_ = gtk_combo_box_get_model (self->priv->custom_duration_units_combo);
3036
_tmp1_ = _g_object_ref0 (_tmp0_);
3040
_tmp4_ = gtk_tree_model_get_iter_first (model, &_tmp3_);
3047
gint multiplier = 0;
3048
gboolean _tmp7_ = FALSE;
3051
_tmp6_ = gtk_tree_model_iter_next (model, &iter);
3057
gtk_tree_model_get (model, &iter, 1, &multiplier, -1, -1);
3058
if (multiplier > max_multiplier) {
3059
_tmp7_ = (duration % multiplier) == 0;
3064
max_multiplier = multiplier;
3071
if (max_multiplier > 0) {
3072
value = duration / max_multiplier;
3073
gtk_adjustment_set_value (self->priv->duration_adjustment, (gdouble) value);
3074
gtk_combo_box_set_active_iter (self->priv->custom_duration_units_combo, &max_iter);
3077
_g_object_unref0 (model);
3080
_tmp8_ = gtk_combo_box_get_model (self->priv->duration_combo);
3081
_tmp9_ = _g_object_ref0 (_tmp8_);
3082
_g_object_unref0 (model);
3084
_tmp11_ = gtk_tree_model_get_iter_first (model, &_tmp10_);
3087
_g_object_unref0 (model);
3095
gboolean _tmp14_ = FALSE;
3098
_tmp13_ = gtk_tree_model_iter_next (model, &iter);
3104
gtk_tree_model_get (model, &iter, 1, &v, -1, -1);
3105
if (v == duration) {
3108
_tmp14_ = v == (-1);
3111
gtk_combo_box_set_active_iter (self->priv->duration_combo, &iter);
3112
gtk_widget_set_visible ((GtkWidget*) self->priv->custom_duration_box, v == (-1));
3113
_g_object_unref0 (model);
3118
_g_object_unref0 (model);
3122
static gint application_get_duration (Application* self) {
3124
GtkTreeIter iter = {0};
3125
GtkTreeIter _tmp0_ = {0};
3130
GtkTreeIter _tmp4_ = {0};
3132
g_return_val_if_fail (self != NULL, 0);
3133
_tmp1_ = gtk_combo_box_get_active_iter (self->priv->duration_combo, &_tmp0_);
3137
GtkTreeModel* _tmp2_ = NULL;
3138
_tmp2_ = gtk_combo_box_get_model (self->priv->duration_combo);
3139
gtk_tree_model_get (_tmp2_, &iter, 1, &duration, -1, -1);
3140
if (duration >= 0) {
3145
_tmp3_ = gtk_adjustment_get_value (self->priv->duration_adjustment);
3146
magnitude = (gint) _tmp3_;
3148
_tmp5_ = gtk_combo_box_get_active_iter (self->priv->custom_duration_units_combo, &_tmp4_);
3151
GtkTreeModel* _tmp6_ = NULL;
3152
_tmp6_ = gtk_combo_box_get_model (self->priv->custom_duration_units_combo);
3153
gtk_tree_model_get (_tmp6_, &iter, 1, &multiplier, -1, -1);
3155
result = magnitude * multiplier;
3160
static gboolean application_save_duration_cb (Application* self) {
3161
gboolean result = FALSE;
3163
g_return_val_if_fail (self != NULL, FALSE);
3164
_tmp0_ = application_get_duration (self);
3165
g_settings_set_int (self->priv->settings, "duration", _tmp0_);
3166
g_source_remove (self->priv->save_duration_timeout);
3167
self->priv->save_duration_timeout = (guint) 0;
3173
void G_MODULE_EXPORT duration_changed_cb (GtkAdjustment* adjustment, Application* self) {
3174
GtkTreeModel* _tmp0_ = NULL;
3175
GtkListStore* _tmp1_;
3176
GtkListStore* model;
3177
GtkTreeIter iter = {0};
3178
GtkTreeIter _tmp2_ = {0};
3180
g_return_if_fail (self != NULL);
3181
g_return_if_fail (adjustment != NULL);
3182
_tmp0_ = gtk_combo_box_get_model (self->priv->custom_duration_units_combo);
3183
_tmp1_ = _g_object_ref0 (GTK_LIST_STORE (_tmp0_));
3185
_tmp3_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) model, &_tmp2_);
3192
gint multiplier = 0;
3195
_tmp5_ = gtk_tree_model_iter_next ((GtkTreeModel*) model, &iter);
3201
gtk_tree_model_get ((GtkTreeModel*) model, &iter, 1, &multiplier, -1, -1);
3202
switch (multiplier) {
3206
const gchar* _tmp7_ = NULL;
3207
_tmp6_ = gtk_adjustment_get_value (adjustment);
3208
_tmp7_ = ngettext ("second", "seconds", (gulong) _tmp6_);
3209
gtk_list_store_set (model, &iter, 0, _tmp7_, -1, -1);
3215
const gchar* _tmp9_ = NULL;
3216
_tmp8_ = gtk_adjustment_get_value (adjustment);
3217
_tmp9_ = ngettext ("minute", "minutes", (gulong) _tmp8_);
3218
gtk_list_store_set (model, &iter, 0, _tmp9_, -1, -1);
3224
const gchar* _tmp11_ = NULL;
3225
_tmp10_ = gtk_adjustment_get_value (adjustment);
3226
_tmp11_ = ngettext ("hour", "hours", (gulong) _tmp10_);
3227
gtk_list_store_set (model, &iter, 0, _tmp11_, -1, -1);
3236
application_save_duration (self);
3237
_g_object_unref0 (model);
3241
void G_MODULE_EXPORT duration_units_changed_cb (GtkWidget* widget, Application* self) {
3242
g_return_if_fail (self != NULL);
3243
g_return_if_fail (widget != NULL);
3244
application_save_duration (self);
3248
static gboolean _application_save_duration_cb_gsource_func (gpointer self) {
3250
result = application_save_duration_cb (self);
3255
static void application_save_duration (Application* self) {
3257
g_return_if_fail (self != NULL);
3258
if (self->priv->save_duration_timeout != 0) {
3259
g_source_remove (self->priv->save_duration_timeout);
3261
_tmp0_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, _application_save_duration_cb_gsource_func, application_ref (self), application_unref);
3262
self->priv->save_duration_timeout = _tmp0_;
3266
void G_MODULE_EXPORT duration_combo_changed_cb (GtkComboBox* combo, Application* self) {
3267
GtkTreeIter iter = {0};
3268
GtkTreeIter _tmp0_ = {0};
3271
GtkTreeModel* _tmp2_ = NULL;
3272
g_return_if_fail (self != NULL);
3273
g_return_if_fail (combo != NULL);
3274
_tmp1_ = gtk_combo_box_get_active_iter (combo, &_tmp0_);
3279
_tmp2_ = gtk_combo_box_get_model (combo);
3280
gtk_tree_model_get (_tmp2_, &iter, 1, &duration, -1, -1);
3281
gtk_widget_set_visible ((GtkWidget*) self->priv->custom_duration_box, duration < 0);
3282
if (duration >= 0) {
3283
application_set_duration (self, duration, FALSE);
3286
_tmp3_ = application_get_duration (self);
3288
application_set_duration (self, 5 * 60, FALSE);
3291
application_save_duration (self);
3295
void G_MODULE_EXPORT preferences_response_cb (GtkWidget* widget, gint response_id, Application* self) {
3296
g_return_if_fail (self != NULL);
3297
g_return_if_fail (widget != NULL);
3298
gtk_widget_hide ((GtkWidget*) self->priv->preferences_dialog);
3302
gboolean G_MODULE_EXPORT preferences_delete_event_cb (GtkWidget* widget, GdkEvent* event, Application* self) {
3303
gboolean result = FALSE;
3304
g_return_val_if_fail (self != NULL, FALSE);
3305
g_return_val_if_fail (widget != NULL, FALSE);
3306
g_return_val_if_fail (event != NULL, FALSE);
3307
G_MODULE_EXPORT preferences_response_cb (widget, (gint) GTK_RESPONSE_CANCEL, self);
3313
void G_MODULE_EXPORT piece_style_combo_changed_cb (GtkComboBox* combo, Application* self) {
3314
gchar* _tmp0_ = NULL;
3316
g_return_if_fail (self != NULL);
3317
g_return_if_fail (combo != NULL);
3318
_tmp0_ = application_get_combo (self, combo, 1);
3320
g_settings_set_string (self->priv->settings, "piece-theme", _tmp1_);
3325
void G_MODULE_EXPORT show_3d_toggle_cb (GtkToggleButton* widget, Application* self) {
3326
GObject* _tmp0_ = NULL;
3330
GObject* _tmp3_ = NULL;
3333
g_return_if_fail (self != NULL);
3334
g_return_if_fail (widget != NULL);
3335
_tmp0_ = gtk_builder_get_object (self->priv->preferences_builder, "show_3d_smooth_check");
3336
_tmp1_ = _g_object_ref0 (GTK_WIDGET (_tmp0_));
3338
_tmp2_ = gtk_toggle_button_get_active (widget);
3339
gtk_widget_set_sensitive (w, _tmp2_);
3340
_tmp3_ = gtk_builder_get_object (self->priv->preferences_builder, "piece_style_combo");
3341
_tmp4_ = _g_object_ref0 (GTK_WIDGET (_tmp3_));
3342
_g_object_unref0 (w);
3344
_tmp5_ = gtk_toggle_button_get_active (widget);
3345
gtk_widget_set_sensitive (w, !_tmp5_);
3346
_g_object_unref0 (w);
3350
void G_MODULE_EXPORT promotion_type_combo_changed_cb (GtkComboBox* combo, Application* self) {
3351
gchar* _tmp0_ = NULL;
3353
g_return_if_fail (self != NULL);
3354
g_return_if_fail (combo != NULL);
3355
_tmp0_ = application_get_combo (self, combo, 1);
3357
g_settings_set_string (self->priv->settings, "promotion-type", _tmp1_);
3362
void G_MODULE_EXPORT move_format_combo_changed_cb (GtkComboBox* combo, Application* self) {
3363
gchar* _tmp0_ = NULL;
3365
g_return_if_fail (self != NULL);
3366
g_return_if_fail (combo != NULL);
3367
_tmp0_ = application_get_combo (self, combo, 1);
3369
g_settings_set_string (self->priv->settings, "move-format", _tmp1_);
3374
void G_MODULE_EXPORT orientation_combo_changed_cb (GtkComboBox* combo, Application* self) {
3375
gchar* _tmp0_ = NULL;
3377
g_return_if_fail (self != NULL);
3378
g_return_if_fail (combo != NULL);
3379
_tmp0_ = application_get_combo (self, combo, 1);
3381
g_settings_set_string (self->priv->settings, "board-side", _tmp1_);
3386
void G_MODULE_EXPORT help_cb (GtkWidget* widget, Application* self) {
3387
GdkScreen* _tmp0_ = NULL;
3389
GError * _inner_error_ = NULL;
3390
g_return_if_fail (self != NULL);
3391
g_return_if_fail (widget != NULL);
3392
_tmp0_ = gtk_window_get_screen (self->priv->window);
3393
_tmp1_ = gtk_get_current_event_time ();
3394
gtk_show_uri (_tmp0_, "ghelp:glchess", _tmp1_, &_inner_error_);
3395
if (_inner_error_ != NULL) {
3396
goto __catch3_g_error;
3403
_inner_error_ = NULL;
3404
g_warning ("glchess.vala:1340: Unable to open help: %s", e->message);
3408
if (_inner_error_ != NULL) {
3409
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);
3410
g_clear_error (&_inner_error_);
3416
static void _application_about_response_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
3417
application_about_response_cb (self, response_id);
3421
void G_MODULE_EXPORT about_cb (GtkWidget* widget, Application* self) {
3422
GtkAboutDialog* _tmp0_ = NULL;
3423
const gchar* _tmp1_ = NULL;
3424
const gchar* _tmp2_ = NULL;
3425
g_return_if_fail (self != NULL);
3426
g_return_if_fail (widget != NULL);
3427
if (self->priv->about_dialog != NULL) {
3428
gtk_window_present ((GtkWindow*) self->priv->about_dialog);
3431
_tmp0_ = (GtkAboutDialog*) gtk_about_dialog_new ();
3432
_g_object_unref0 (self->priv->about_dialog);
3433
self->priv->about_dialog = g_object_ref_sink (_tmp0_);
3434
gtk_window_set_transient_for ((GtkWindow*) self->priv->about_dialog, self->priv->window);
3435
gtk_widget_set_name ((GtkWidget*) self->priv->about_dialog, "glchess");
3436
gtk_about_dialog_set_version (self->priv->about_dialog, VERSION);
3437
gtk_about_dialog_set_copyright (self->priv->about_dialog, "Copyright 2010 Robert Ancell <robert.ancell@gmail.com>");
3438
gtk_about_dialog_set_license_type (self->priv->about_dialog, GTK_LICENSE_GPL_2_0);
3439
gtk_about_dialog_set_wrap_license (self->priv->about_dialog, TRUE);
3440
_tmp1_ = _ ("The 2D/3D chess game for GNOME. \n" \
3442
"glChess is a part of GNOME Games.");
3443
gtk_about_dialog_set_comments (self->priv->about_dialog, _tmp1_);
3444
gtk_about_dialog_set_authors (self->priv->about_dialog, APPLICATION_authors);
3445
gtk_about_dialog_set_artists (self->priv->about_dialog, APPLICATION_artists);
3446
gtk_about_dialog_set_translator_credits (self->priv->about_dialog, "translator-credits");
3447
gtk_about_dialog_set_website (self->priv->about_dialog, "http://www.gnome.org/projects/gnome-games/");
3448
_tmp2_ = _ ("GNOME Games web site");
3449
gtk_about_dialog_set_website_label (self->priv->about_dialog, _tmp2_);
3450
gtk_about_dialog_set_logo_icon_name (self->priv->about_dialog, "glchess");
3451
g_signal_connect ((GtkDialog*) self->priv->about_dialog, "response", (GCallback) _application_about_response_cb_gtk_dialog_response, self);
3452
gtk_widget_show ((GtkWidget*) self->priv->about_dialog);
3456
static void application_about_response_cb (Application* self, gint response_id) {
3457
g_return_if_fail (self != NULL);
3458
gtk_widget_destroy ((GtkWidget*) self->priv->about_dialog);
3459
_g_object_unref0 (self->priv->about_dialog);
3460
self->priv->about_dialog = NULL;
3464
void G_MODULE_EXPORT save_game_as_cb (GtkWidget* widget, Application* self) {
3465
g_return_if_fail (self != NULL);
3466
g_return_if_fail (widget != NULL);
3467
application_save_game (self);
3471
void G_MODULE_EXPORT save_game_cb (GtkWidget* widget, Application* self) {
3472
g_return_if_fail (self != NULL);
3473
g_return_if_fail (widget != NULL);
3474
application_save_game (self);
3478
static void application_add_info_bar_to_dialog (Application* self, GtkDialog* dialog, GtkInfoBar** info_bar, GtkLabel** label) {
3479
GtkInfoBar* _info_bar = NULL;
3480
GtkLabel* _label = NULL;
3481
GtkVBox* _tmp0_ = NULL;
3483
GtkInfoBar* _tmp1_ = NULL;
3484
GtkWidget* _tmp2_ = NULL;
3485
GtkContainer* _tmp3_;
3486
GtkContainer* content_area;
3487
GtkLabel* _tmp4_ = NULL;
3488
GtkWidget* _tmp5_ = NULL;
3489
GtkContainer* _tmp6_;
3490
GtkContainer* child;
3492
g_return_if_fail (self != NULL);
3493
g_return_if_fail (dialog != NULL);
3494
_tmp0_ = (GtkVBox*) gtk_vbox_new (FALSE, 0);
3495
vbox = g_object_ref_sink (_tmp0_);
3496
gtk_widget_show ((GtkWidget*) vbox);
3497
_tmp1_ = (GtkInfoBar*) gtk_info_bar_new ();
3498
_g_object_unref0 (_info_bar);
3499
_info_bar = g_object_ref_sink (_tmp1_);
3500
_tmp2_ = gtk_info_bar_get_content_area (_info_bar);
3501
_tmp3_ = _g_object_ref0 (GTK_CONTAINER (_tmp2_));
3502
content_area = _tmp3_;
3503
gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) _info_bar, FALSE, TRUE, (guint) 0);
3504
_tmp4_ = (GtkLabel*) gtk_label_new ("");
3505
_g_object_unref0 (_label);
3506
_label = g_object_ref_sink (_tmp4_);
3507
gtk_container_add (content_area, (GtkWidget*) _label);
3508
gtk_widget_show ((GtkWidget*) _label);
3509
_tmp5_ = gtk_bin_get_child ((GtkBin*) dialog);
3510
_tmp6_ = _g_object_ref0 (GTK_CONTAINER (_tmp5_));
3512
gtk_widget_reparent ((GtkWidget*) child, (GtkWidget*) vbox);
3513
_tmp7_ = gtk_container_get_border_width ((GtkContainer*) dialog);
3514
gtk_container_set_border_width (child, _tmp7_);
3515
gtk_container_set_border_width ((GtkContainer*) dialog, (guint) 0);
3516
gtk_container_add ((GtkContainer*) dialog, (GtkWidget*) vbox);
3517
_g_object_unref0 (child);
3518
_g_object_unref0 (content_area);
3519
_g_object_unref0 (vbox);
3521
*info_bar = _info_bar;
3523
_g_object_unref0 (_info_bar);
3528
_g_object_unref0 (_label);
3533
static void _application_save_file_cb_gtk_file_chooser_file_activated (GtkFileChooser* _sender, gpointer self) {
3534
application_save_file_cb (self);
3538
static void _application_save_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
3539
application_save_cb (self, response_id);
3543
static void application_save_game (Application* self) {
3544
const gchar* _tmp0_ = NULL;
3545
GtkFileChooserDialog* _tmp1_ = NULL;
3546
GtkInfoBar* _tmp2_ = NULL;
3547
GtkLabel* _tmp3_ = NULL;
3548
GtkFileFilter* _tmp4_ = NULL;
3549
GtkFileFilter* pgn_filter;
3550
const gchar* _tmp5_ = NULL;
3551
GtkFileFilter* _tmp6_ = NULL;
3552
GtkFileFilter* all_filter;
3553
const gchar* _tmp7_ = NULL;
3554
g_return_if_fail (self != NULL);
3555
if (self->priv->save_dialog != NULL) {
3556
gtk_window_present ((GtkWindow*) self->priv->save_dialog);
3559
_tmp0_ = _ ("Save Chess Game");
3560
_tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp0_, self->priv->window, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL, NULL);
3561
_g_object_unref0 (self->priv->save_dialog);
3562
self->priv->save_dialog = g_object_ref_sink (_tmp1_);
3563
application_add_info_bar_to_dialog (self, (GtkDialog*) self->priv->save_dialog, &_tmp2_, &_tmp3_);
3564
_g_object_unref0 (self->priv->save_dialog_info_bar);
3565
self->priv->save_dialog_info_bar = _tmp2_;
3566
_g_object_unref0 (self->priv->save_dialog_error_label);
3567
self->priv->save_dialog_error_label = _tmp3_;
3568
g_signal_connect ((GtkFileChooser*) self->priv->save_dialog, "file-activated", (GCallback) _application_save_file_cb_gtk_file_chooser_file_activated, self);
3569
g_signal_connect ((GtkDialog*) self->priv->save_dialog, "response", (GCallback) _application_save_cb_gtk_dialog_response, self);
3570
_tmp4_ = gtk_file_filter_new ();
3571
pgn_filter = g_object_ref_sink (_tmp4_);
3572
_tmp5_ = _ ("PGN files");
3573
gtk_file_filter_set_name (pgn_filter, _tmp5_);
3574
gtk_file_filter_add_pattern (pgn_filter, "*.pgn");
3575
gtk_file_chooser_add_filter ((GtkFileChooser*) self->priv->save_dialog, pgn_filter);
3576
_tmp6_ = gtk_file_filter_new ();
3577
all_filter = g_object_ref_sink (_tmp6_);
3578
_tmp7_ = _ ("All files");
3579
gtk_file_filter_set_name (all_filter, _tmp7_);
3580
gtk_file_filter_add_pattern (all_filter, "*");
3581
gtk_file_chooser_add_filter ((GtkFileChooser*) self->priv->save_dialog, all_filter);
3582
gtk_window_present ((GtkWindow*) self->priv->save_dialog);
3583
_g_object_unref0 (all_filter);
3584
_g_object_unref0 (pgn_filter);
3588
static void application_save_file_cb (Application* self) {
3589
g_return_if_fail (self != NULL);
3590
application_save_cb (self, (gint) GTK_RESPONSE_OK);
3594
static void application_save_cb (Application* self, gint response_id) {
3595
GError * _inner_error_ = NULL;
3596
g_return_if_fail (self != NULL);
3597
if (response_id == GTK_RESPONSE_OK) {
3598
GFile* _tmp0_ = NULL;
3599
gtk_widget_set_sensitive (self->priv->save_menu, FALSE);
3600
_tmp0_ = gtk_file_chooser_get_file ((GtkFileChooser*) self->priv->save_dialog);
3601
pgn_game_write (self->priv->pgn_game, _tmp0_, &_inner_error_);
3602
if (_inner_error_ != NULL) {
3603
goto __catch4_g_error;
3609
const gchar* _tmp1_ = NULL;
3610
gchar* _tmp2_ = NULL;
3613
_inner_error_ = NULL;
3614
_tmp1_ = _ ("Failed to save game: %s");
3615
_tmp2_ = g_strdup_printf (_tmp1_, e->message);
3617
gtk_label_set_text (self->priv->save_dialog_error_label, _tmp3_);
3619
gtk_info_bar_set_message_type (self->priv->save_dialog_info_bar, GTK_MESSAGE_ERROR);
3620
gtk_widget_show ((GtkWidget*) self->priv->save_dialog_info_bar);
3625
if (_inner_error_ != NULL) {
3626
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);
3627
g_clear_error (&_inner_error_);
3631
gtk_widget_destroy ((GtkWidget*) self->priv->save_dialog);
3632
_g_object_unref0 (self->priv->save_dialog);
3633
self->priv->save_dialog = NULL;
3634
_g_object_unref0 (self->priv->save_dialog_info_bar);
3635
self->priv->save_dialog_info_bar = NULL;
3636
_g_object_unref0 (self->priv->save_dialog_error_label);
3637
self->priv->save_dialog_error_label = NULL;
3641
static void _application_open_file_cb_gtk_file_chooser_file_activated (GtkFileChooser* _sender, gpointer self) {
3642
application_open_file_cb (self);
3646
static void _application_open_cb_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
3647
application_open_cb (self, response_id);
3651
void G_MODULE_EXPORT open_game_cb (GtkWidget* widget, Application* self) {
3652
const gchar* _tmp0_ = NULL;
3653
GtkFileChooserDialog* _tmp1_ = NULL;
3654
GtkInfoBar* _tmp2_ = NULL;
3655
GtkLabel* _tmp3_ = NULL;
3656
GtkFileFilter* _tmp4_ = NULL;
3657
GtkFileFilter* pgn_filter;
3658
const gchar* _tmp5_ = NULL;
3659
GtkFileFilter* _tmp6_ = NULL;
3660
GtkFileFilter* all_filter;
3661
const gchar* _tmp7_ = NULL;
3662
g_return_if_fail (self != NULL);
3663
g_return_if_fail (widget != NULL);
3664
if (self->priv->open_dialog != NULL) {
3665
gtk_window_present ((GtkWindow*) self->priv->open_dialog);
3668
_tmp0_ = _ ("Load Chess Game");
3669
_tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp0_, self->priv->window, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL, NULL);
3670
_g_object_unref0 (self->priv->open_dialog);
3671
self->priv->open_dialog = g_object_ref_sink (_tmp1_);
3672
application_add_info_bar_to_dialog (self, (GtkDialog*) self->priv->open_dialog, &_tmp2_, &_tmp3_);
3673
_g_object_unref0 (self->priv->open_dialog_info_bar);
3674
self->priv->open_dialog_info_bar = _tmp2_;
3675
_g_object_unref0 (self->priv->open_dialog_error_label);
3676
self->priv->open_dialog_error_label = _tmp3_;
3677
g_signal_connect ((GtkFileChooser*) self->priv->open_dialog, "file-activated", (GCallback) _application_open_file_cb_gtk_file_chooser_file_activated, self);
3678
g_signal_connect ((GtkDialog*) self->priv->open_dialog, "response", (GCallback) _application_open_cb_gtk_dialog_response, self);
3679
_tmp4_ = gtk_file_filter_new ();
3680
pgn_filter = g_object_ref_sink (_tmp4_);
3681
_tmp5_ = _ ("PGN files");
3682
gtk_file_filter_set_name (pgn_filter, _tmp5_);
3683
gtk_file_filter_add_pattern (pgn_filter, "*.pgn");
3684
gtk_file_chooser_add_filter ((GtkFileChooser*) self->priv->open_dialog, pgn_filter);
3685
_tmp6_ = gtk_file_filter_new ();
3686
all_filter = g_object_ref_sink (_tmp6_);
3687
_tmp7_ = _ ("All files");
3688
gtk_file_filter_set_name (all_filter, _tmp7_);
3689
gtk_file_filter_add_pattern (all_filter, "*");
3690
gtk_file_chooser_add_filter ((GtkFileChooser*) self->priv->open_dialog, all_filter);
3691
gtk_window_present ((GtkWindow*) self->priv->open_dialog);
3692
_g_object_unref0 (all_filter);
3693
_g_object_unref0 (pgn_filter);
3697
static void application_open_file_cb (Application* self) {
3698
g_return_if_fail (self != NULL);
3699
application_open_cb (self, (gint) GTK_RESPONSE_OK);
3703
static void application_open_cb (Application* self, gint response_id) {
3704
GError * _inner_error_ = NULL;
3705
g_return_if_fail (self != NULL);
3706
if (response_id == GTK_RESPONSE_OK) {
3707
GFile* _tmp0_ = NULL;
3708
_tmp0_ = gtk_file_chooser_get_file ((GtkFileChooser*) self->priv->open_dialog);
3709
application_load_game (self, _tmp0_, FALSE, &_inner_error_);
3710
if (_inner_error_ != NULL) {
3711
goto __catch5_g_error;
3717
const gchar* _tmp1_ = NULL;
3718
gchar* _tmp2_ = NULL;
3721
_inner_error_ = NULL;
3722
_tmp1_ = _ ("Failed to open game: %s");
3723
_tmp2_ = g_strdup_printf (_tmp1_, e->message);
3725
gtk_label_set_text (self->priv->open_dialog_error_label, _tmp3_);
3727
gtk_info_bar_set_message_type (self->priv->open_dialog_info_bar, GTK_MESSAGE_ERROR);
3728
gtk_widget_show ((GtkWidget*) self->priv->open_dialog_info_bar);
3733
if (_inner_error_ != NULL) {
3734
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);
3735
g_clear_error (&_inner_error_);
3739
gtk_widget_destroy ((GtkWidget*) self->priv->open_dialog);
3740
_g_object_unref0 (self->priv->open_dialog);
3741
self->priv->open_dialog = NULL;
3742
_g_object_unref0 (self->priv->open_dialog_info_bar);
3743
self->priv->open_dialog_info_bar = NULL;
3744
_g_object_unref0 (self->priv->open_dialog_error_label);
3745
self->priv->open_dialog_error_label = NULL;
3749
static void application_start_new_game (Application* self) {
3750
PGNGame* _tmp0_ = NULL;
3751
GDateTime* _tmp1_ = NULL;
3753
gchar* _tmp2_ = NULL;
3755
gchar* _tmp4_ = NULL;
3759
gchar* _tmp9_ = NULL;
3761
gchar* _tmp10_ = NULL;
3762
gchar* engine_level;
3763
gboolean _tmp11_ = FALSE;
3764
g_return_if_fail (self != NULL);
3765
self->priv->in_history = TRUE;
3766
_g_object_unref0 (self->priv->game_file);
3767
self->priv->game_file = NULL;
3768
_tmp0_ = pgn_game_new ();
3769
_pgn_game_unref0 (self->priv->pgn_game);
3770
self->priv->pgn_game = _tmp0_;
3771
_tmp1_ = g_date_time_new_now_local ();
3773
_tmp2_ = g_date_time_format (now, "%Y.%m.%d");
3775
pgn_game_set_date (self->priv->pgn_game, _tmp3_);
3777
_tmp4_ = g_date_time_format (now, "%H:%M:%S");
3779
pgn_game_set_time (self->priv->pgn_game, _tmp5_);
3781
_tmp6_ = g_settings_get_int (self->priv->settings, "duration");
3784
gchar* _tmp7_ = NULL;
3786
_tmp7_ = g_strdup_printf ("%d", duration);
3788
pgn_game_set_time_control (self->priv->pgn_game, _tmp8_);
3791
_tmp9_ = g_settings_get_string (self->priv->settings, "opponent");
3792
engine_name = _tmp9_;
3793
_tmp10_ = g_settings_get_string (self->priv->settings, "difficulty");
3794
engine_level = _tmp10_;
3795
if (engine_name != NULL) {
3796
_tmp11_ = g_strcmp0 (engine_name, "human") != 0;
3802
_tmp12_ = g_settings_get_boolean (self->priv->settings, "play-as-white");
3808
_tmp13_ = g_strdup ("BlackAI");
3809
_tmp14_ = g_strdup (engine_name);
3810
g_hash_table_insert (self->priv->pgn_game->tags, _tmp13_, _tmp14_);
3811
_tmp15_ = g_strdup ("BlackLevel");
3812
_tmp16_ = g_strdup (engine_level);
3813
g_hash_table_insert (self->priv->pgn_game->tags, _tmp15_, _tmp16_);
3819
_tmp17_ = g_strdup ("WhiteAI");
3820
_tmp18_ = g_strdup (engine_name);
3821
g_hash_table_insert (self->priv->pgn_game->tags, _tmp17_, _tmp18_);
3822
_tmp19_ = g_strdup ("WhiteLevel");
3823
_tmp20_ = g_strdup (engine_level);
3824
g_hash_table_insert (self->priv->pgn_game->tags, _tmp19_, _tmp20_);
3827
application_start_game (self);
3828
_g_free0 (engine_level);
3829
_g_free0 (engine_name);
3830
_g_date_time_unref0 (now);
3834
static gpointer _pgn_game_ref0 (gpointer self) {
3835
return self ? pgn_game_ref (self) : NULL;
3839
static void application_load_game (Application* self, GFile* file, gboolean from_history, GError** error) {
3842
gconstpointer _tmp1_ = NULL;
3845
GError * _inner_error_ = NULL;
3846
g_return_if_fail (self != NULL);
3847
g_return_if_fail (file != NULL);
3848
_tmp0_ = pgn_new_from_file (file, &_inner_error_);
3850
if (_inner_error_ != NULL) {
3851
g_propagate_error (error, _inner_error_);
3854
_tmp1_ = g_list_nth_data (pgn->games, (guint) 0);
3855
_tmp2_ = _pgn_game_ref0 ((PGNGame*) _tmp1_);
3856
_pgn_game_unref0 (self->priv->pgn_game);
3857
self->priv->pgn_game = _tmp2_;
3858
_tmp3_ = _g_object_ref0 (file);
3859
_g_object_unref0 (self->priv->game_file);
3860
self->priv->game_file = _tmp3_;
3861
self->priv->in_history = from_history;
3862
application_start_game (self);
3867
static void value_application_init (GValue* value) {
3868
value->data[0].v_pointer = NULL;
3872
static void value_application_free_value (GValue* value) {
3873
if (value->data[0].v_pointer) {
3874
application_unref (value->data[0].v_pointer);
3879
static void value_application_copy_value (const GValue* src_value, GValue* dest_value) {
3880
if (src_value->data[0].v_pointer) {
3881
dest_value->data[0].v_pointer = application_ref (src_value->data[0].v_pointer);
3883
dest_value->data[0].v_pointer = NULL;
3888
static gpointer value_application_peek_pointer (const GValue* value) {
3889
return value->data[0].v_pointer;
3893
static gchar* value_application_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
3894
if (collect_values[0].v_pointer) {
3895
Application* object;
3896
object = collect_values[0].v_pointer;
3897
if (object->parent_instance.g_class == NULL) {
3898
return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
3899
} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
3900
return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
3902
value->data[0].v_pointer = application_ref (object);
3904
value->data[0].v_pointer = NULL;
3910
static gchar* value_application_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
3911
Application** object_p;
3912
object_p = collect_values[0].v_pointer;
3914
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
3916
if (!value->data[0].v_pointer) {
3918
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
3919
*object_p = value->data[0].v_pointer;
3921
*object_p = application_ref (value->data[0].v_pointer);
3927
GParamSpec* param_spec_application (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
3928
ParamSpecApplication* spec;
3929
g_return_val_if_fail (g_type_is_a (object_type, TYPE_APPLICATION), NULL);
3930
spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
3931
G_PARAM_SPEC (spec)->value_type = object_type;
3932
return G_PARAM_SPEC (spec);
3936
gpointer value_get_application (const GValue* value) {
3937
g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_APPLICATION), NULL);
3938
return value->data[0].v_pointer;
3942
void value_set_application (GValue* value, gpointer v_object) {
3944
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_APPLICATION));
3945
old = value->data[0].v_pointer;
3947
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_APPLICATION));
3948
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
3949
value->data[0].v_pointer = v_object;
3950
application_ref (value->data[0].v_pointer);
3952
value->data[0].v_pointer = NULL;
3955
application_unref (old);
3960
void value_take_application (GValue* value, gpointer v_object) {
3962
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_APPLICATION));
3963
old = value->data[0].v_pointer;
3965
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_APPLICATION));
3966
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
3967
value->data[0].v_pointer = v_object;
3969
value->data[0].v_pointer = NULL;
3972
application_unref (old);
3977
static void application_class_init (ApplicationClass * klass) {
3978
application_parent_class = g_type_class_peek_parent (klass);
3979
APPLICATION_CLASS (klass)->finalize = application_finalize;
3980
g_type_class_add_private (klass, sizeof (ApplicationPrivate));
3984
static void application_instance_init (Application * self) {
3985
self->priv = APPLICATION_GET_PRIVATE (self);
3986
self->priv->preferences_dialog = NULL;
3987
self->priv->save_duration_timeout = (guint) 0;
3988
self->priv->open_dialog = NULL;
3989
self->priv->open_dialog_info_bar = NULL;
3990
self->priv->open_dialog_error_label = NULL;
3991
self->priv->save_dialog = NULL;
3992
self->priv->save_dialog_info_bar = NULL;
3993
self->priv->save_dialog_error_label = NULL;
3994
self->priv->about_dialog = NULL;
3995
self->priv->opponent = NULL;
3996
self->priv->human_player = NULL;
3997
self->priv->opponent_engine = NULL;
3998
self->ref_count = 1;
4002
static void application_finalize (Application* obj) {
4004
self = APPLICATION (obj);
4005
_g_object_unref0 (self->priv->settings);
4006
_history_unref0 (self->priv->history);
4007
_g_object_unref0 (self->priv->builder);
4008
_g_object_unref0 (self->priv->preferences_builder);
4009
_g_object_unref0 (self->priv->window);
4010
_g_object_unref0 (self->priv->save_menu);
4011
_g_object_unref0 (self->priv->save_as_menu);
4012
_g_object_unref0 (self->priv->fullscreen_menu);
4013
_g_object_unref0 (self->priv->info_bar);
4014
_g_object_unref0 (self->priv->info_title_label);
4015
_g_object_unref0 (self->priv->info_label);
4016
_g_object_unref0 (self->priv->view_container);
4017
_g_object_unref0 (self->priv->scene);
4018
_g_object_unref0 (self->priv->view);
4019
_g_object_unref0 (self->priv->undo_menu);
4020
_g_object_unref0 (self->priv->undo_button);
4021
_g_object_unref0 (self->priv->resign_menu);
4022
_g_object_unref0 (self->priv->resign_button);
4023
_g_object_unref0 (self->priv->first_move_button);
4024
_g_object_unref0 (self->priv->prev_move_button);
4025
_g_object_unref0 (self->priv->next_move_button);
4026
_g_object_unref0 (self->priv->last_move_button);
4027
_g_object_unref0 (self->priv->history_combo);
4028
_g_object_unref0 (self->priv->white_time_label);
4029
_g_object_unref0 (self->priv->black_time_label);
4030
_g_object_unref0 (self->priv->preferences_dialog);
4031
_g_object_unref0 (self->priv->duration_combo);
4032
_g_object_unref0 (self->priv->duration_adjustment);
4033
_g_object_unref0 (self->priv->custom_duration_box);
4034
_g_object_unref0 (self->priv->custom_duration_units_combo);
4035
_g_object_unref0 (self->priv->open_dialog);
4036
_g_object_unref0 (self->priv->open_dialog_info_bar);
4037
_g_object_unref0 (self->priv->open_dialog_error_label);
4038
_g_object_unref0 (self->priv->save_dialog);
4039
_g_object_unref0 (self->priv->save_dialog_info_bar);
4040
_g_object_unref0 (self->priv->save_dialog_error_label);
4041
_g_object_unref0 (self->priv->about_dialog);
4042
_pgn_game_unref0 (self->priv->pgn_game);
4043
_chess_game_unref0 (self->priv->game);
4044
_g_object_unref0 (self->priv->game_file);
4045
__g_list_free__ai_profile_unref0_0 (self->priv->ai_profiles);
4046
_g_object_unref0 (self->priv->opponent);
4047
_g_object_unref0 (self->priv->human_player);
4048
_g_object_unref0 (self->priv->opponent_engine);
4052
GType application_get_type (void) {
4053
static volatile gsize application_type_id__volatile = 0;
4054
if (g_once_init_enter (&application_type_id__volatile)) {
4055
static const GTypeValueTable g_define_type_value_table = { value_application_init, value_application_free_value, value_application_copy_value, value_application_peek_pointer, "p", value_application_collect_value, "p", value_application_lcopy_value };
4056
static const GTypeInfo g_define_type_info = { sizeof (ApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Application), 0, (GInstanceInitFunc) application_instance_init, &g_define_type_value_table };
4057
static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
4058
GType application_type_id;
4059
application_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Application", &g_define_type_info, &g_define_type_fundamental_info, 0);
4060
g_once_init_leave (&application_type_id__volatile, application_type_id);
4062
return application_type_id__volatile;
4066
gpointer application_ref (gpointer instance) {
4069
g_atomic_int_inc (&self->ref_count);
4074
void application_unref (gpointer instance) {
4077
if (g_atomic_int_dec_and_test (&self->ref_count)) {
4078
APPLICATION_GET_CLASS (self)->finalize (self);
4079
g_type_free_instance ((GTypeInstance *) self);
4084
gint gl_chess_main (gchar** args, int args_length1) {
4087
Application* _tmp6_ = NULL;
4089
GError * _inner_error_ = NULL;
4090
setlocale (LC_ALL, "");
4091
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
4092
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
4093
textdomain (GETTEXT_PACKAGE);
4094
gtk_init (&args_length1, &args);
4103
const gchar* _tmp1_;
4105
static GQuark _tmp2__label0 = 0;
4106
static GQuark _tmp2__label1 = 0;
4107
static GQuark _tmp2__label2 = 0;
4108
static GQuark _tmp2__label3 = 0;
4109
static GQuark _tmp2__label4 = 0;
4110
static GQuark _tmp2__label5 = 0;
4111
static GQuark _tmp2__label6 = 0;
4116
if (!(i < args_length1)) {
4120
_tmp2_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
4121
if ((_tmp2_ == ((0 != _tmp2__label0) ? _tmp2__label0 : (_tmp2__label0 = g_quark_from_static_string ("-v")))) || (_tmp2_ == ((0 != _tmp2__label1) ? _tmp2__label1 : (_tmp2__label1 = g_quark_from_static_string ("--version"))))) {
4125
fprintf (stderr, "glchess %s\n", VERSION);
4126
result = EXIT_SUCCESS;
4127
_g_object_unref0 (game_file);
4131
} else if (((_tmp2_ == ((0 != _tmp2__label2) ? _tmp2__label2 : (_tmp2__label2 = g_quark_from_static_string ("-h")))) || (_tmp2_ == ((0 != _tmp2__label3) ? _tmp2__label3 : (_tmp2__label3 = g_quark_from_static_string ("-?"))))) || (_tmp2_ == ((0 != _tmp2__label4) ? _tmp2__label4 : (_tmp2__label4 = g_quark_from_static_string ("--help"))))) {
4135
gl_chess_usage (args[0], FALSE, TRUE);
4136
result = EXIT_SUCCESS;
4137
_g_object_unref0 (game_file);
4141
} else if (_tmp2_ == ((0 != _tmp2__label5) ? _tmp2__label5 : (_tmp2__label5 = g_quark_from_static_string ("--help-gtk")))) {
4145
gl_chess_usage (args[0], TRUE, FALSE);
4146
result = EXIT_SUCCESS;
4147
_g_object_unref0 (game_file);
4151
} else if (_tmp2_ == ((0 != _tmp2__label6) ? _tmp2__label6 : (_tmp2__label6 = g_quark_from_static_string ("--help-all")))) {
4155
gl_chess_usage (args[0], TRUE, TRUE);
4156
result = EXIT_SUCCESS;
4157
_g_object_unref0 (game_file);
4165
gboolean _tmp3_ = FALSE;
4166
if (game_file == NULL) {
4168
_tmp4_ = g_str_has_prefix (args[i], "-");
4174
GFile* _tmp5_ = NULL;
4175
_tmp5_ = g_file_new_for_path (args[i]);
4176
_g_object_unref0 (game_file);
4179
fprintf (stderr, "Unknown argument '%s'\n", args[i]);
4180
fprintf (stderr, "Run '%s --help' to see a full list of available command line options.\n", args[0]);
4181
result = EXIT_FAILURE;
4182
_g_object_unref0 (game_file);
4192
_tmp6_ = application_new ();
4194
application_start (app, game_file, &_inner_error_);
4195
if (_inner_error_ != NULL) {
4196
goto __catch6_g_error;
4202
gchar* _tmp7_ = NULL;
4205
_inner_error_ = NULL;
4206
_tmp7_ = g_file_get_path (game_file);
4208
fprintf (stderr, "Failed to load %s: %s\n", _tmp8_, e->message);
4210
result = EXIT_FAILURE;
4212
_application_unref0 (app);
4213
_g_object_unref0 (game_file);
4217
if (_inner_error_ != NULL) {
4218
_application_unref0 (app);
4219
_g_object_unref0 (game_file);
4220
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);
4221
g_clear_error (&_inner_error_);
4225
result = EXIT_SUCCESS;
4226
_application_unref0 (app);
4227
_g_object_unref0 (game_file);
4232
int main (int argc, char ** argv) {
4234
return gl_chess_main (argv, argc);
4238
void gl_chess_usage (const gchar* appname, gboolean show_gtk, gboolean show_application) {
4239
g_return_if_fail (appname != NULL);
4240
fprintf (stderr, "Usage:\n" " %s [OPTIONS...] [FILE] - Play Chess", appname);
4241
fprintf (stderr, "\n\n");
4242
fprintf (stderr, "%s", "Help Options:\n" " -h, -?, --help Show help options\n" " --help-all Show all help options\n" " --help-gtk Show GTK+ options");
4243
fprintf (stderr, "\n\n");
4245
fprintf (stderr, "%s", "GTK+ Options:\n" " --class=CLASS Program class as used by the window " \
4246
"manager\n" " --name=NAME Program name as used by the window m" \
4247
"anager\n" " --screen=SCREEN X screen to use\n" " --sync Make X calls synchronous\n" " --gtk-module=MODULES Load additional GTK+ modules\n" " --g-fatal-warnings Make all warnings fatal");
4248
fprintf (stderr, "\n\n");
4250
if (show_application) {
4251
fprintf (stderr, "%s", "Application Options:\n" " -v, --version Show release version");
4252
fprintf (stderr, "\n\n");
4257
GlChess* gl_chess_construct (GType object_type) {
4258
GlChess* self = NULL;
4259
self = (GlChess*) g_type_create_instance (object_type);
4264
GlChess* gl_chess_new (void) {
4265
return gl_chess_construct (TYPE_GL_CHESS);
4269
static void value_gl_chess_init (GValue* value) {
4270
value->data[0].v_pointer = NULL;
4274
static void value_gl_chess_free_value (GValue* value) {
4275
if (value->data[0].v_pointer) {
4276
gl_chess_unref (value->data[0].v_pointer);
4281
static void value_gl_chess_copy_value (const GValue* src_value, GValue* dest_value) {
4282
if (src_value->data[0].v_pointer) {
4283
dest_value->data[0].v_pointer = gl_chess_ref (src_value->data[0].v_pointer);
4285
dest_value->data[0].v_pointer = NULL;
4290
static gpointer value_gl_chess_peek_pointer (const GValue* value) {
4291
return value->data[0].v_pointer;
4295
static gchar* value_gl_chess_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
4296
if (collect_values[0].v_pointer) {
4298
object = collect_values[0].v_pointer;
4299
if (object->parent_instance.g_class == NULL) {
4300
return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
4301
} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
4302
return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
4304
value->data[0].v_pointer = gl_chess_ref (object);
4306
value->data[0].v_pointer = NULL;
4312
static gchar* value_gl_chess_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
4314
object_p = collect_values[0].v_pointer;
4316
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
4318
if (!value->data[0].v_pointer) {
4320
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
4321
*object_p = value->data[0].v_pointer;
4323
*object_p = gl_chess_ref (value->data[0].v_pointer);
4329
GParamSpec* param_spec_gl_chess (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
4330
ParamSpecGlChess* spec;
4331
g_return_val_if_fail (g_type_is_a (object_type, TYPE_GL_CHESS), NULL);
4332
spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
4333
G_PARAM_SPEC (spec)->value_type = object_type;
4334
return G_PARAM_SPEC (spec);
4338
gpointer value_get_gl_chess (const GValue* value) {
4339
g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_GL_CHESS), NULL);
4340
return value->data[0].v_pointer;
4344
void value_set_gl_chess (GValue* value, gpointer v_object) {
4346
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_GL_CHESS));
4347
old = value->data[0].v_pointer;
4349
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_GL_CHESS));
4350
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
4351
value->data[0].v_pointer = v_object;
4352
gl_chess_ref (value->data[0].v_pointer);
4354
value->data[0].v_pointer = NULL;
4357
gl_chess_unref (old);
4362
void value_take_gl_chess (GValue* value, gpointer v_object) {
4364
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_GL_CHESS));
4365
old = value->data[0].v_pointer;
4367
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_GL_CHESS));
4368
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
4369
value->data[0].v_pointer = v_object;
4371
value->data[0].v_pointer = NULL;
4374
gl_chess_unref (old);
4379
static void gl_chess_class_init (GlChessClass * klass) {
4380
gl_chess_parent_class = g_type_class_peek_parent (klass);
4381
GL_CHESS_CLASS (klass)->finalize = gl_chess_finalize;
4385
static void gl_chess_instance_init (GlChess * self) {
4386
self->ref_count = 1;
4390
static void gl_chess_finalize (GlChess* obj) {
4392
self = GL_CHESS (obj);
4396
GType gl_chess_get_type (void) {
4397
static volatile gsize gl_chess_type_id__volatile = 0;
4398
if (g_once_init_enter (&gl_chess_type_id__volatile)) {
4399
static const GTypeValueTable g_define_type_value_table = { value_gl_chess_init, value_gl_chess_free_value, value_gl_chess_copy_value, value_gl_chess_peek_pointer, "p", value_gl_chess_collect_value, "p", value_gl_chess_lcopy_value };
4400
static const GTypeInfo g_define_type_info = { sizeof (GlChessClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gl_chess_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GlChess), 0, (GInstanceInitFunc) gl_chess_instance_init, &g_define_type_value_table };
4401
static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
4402
GType gl_chess_type_id;
4403
gl_chess_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GlChess", &g_define_type_info, &g_define_type_fundamental_info, 0);
4404
g_once_init_leave (&gl_chess_type_id__volatile, gl_chess_type_id);
4406
return gl_chess_type_id__volatile;
4410
gpointer gl_chess_ref (gpointer instance) {
4413
g_atomic_int_inc (&self->ref_count);
4418
void gl_chess_unref (gpointer instance) {
4421
if (g_atomic_int_dec_and_test (&self->ref_count)) {
4422
GL_CHESS_GET_CLASS (self)->finalize (self);
4423
g_type_free_instance ((GTypeInstance *) self);
4428
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
4429
if ((array != NULL) && (destroy_func != NULL)) {
4431
for (i = 0; i < array_length; i = i + 1) {
4432
if (((gpointer*) array)[i] != NULL) {
4433
destroy_func (((gpointer*) array)[i]);
4440
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
4441
_vala_array_destroy (array, array_length, destroy_func);
4446
static gint _vala_array_length (gpointer array) {
4450
while (((gpointer*) array)[length]) {