[gnome-chess] Remove ChessHistory class
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Remove ChessHistory class
- Date: Sun, 25 Aug 2013 18:04:50 +0000 (UTC)
commit cd6a23828144b588e788eedbf1f72a04c6b89879
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Aug 23 17:49:16 2013 -0500
Remove ChessHistory class
I'm not sure why this class originally existed, but currently it's only
used to maintain a stack of autosaved games, so that after completing
the first autoloaded game on the stack, the next time you start the game
the next game on the stack will be autoloaded. This feature was
determined to be undesirable -- we'd really like only one game to be
autoloaded at a time -- so I added a delete query to ChessHistory such
that all the previous games on the stack would be removed when a new one
was added. But that meant an SQLite database was used to store exactly
one game. Let's drop this.
We can also remove the dependency on SQLite.
https://bugzilla.gnome.org/show_bug.cgi?id=705878
configure.ac | 1 -
src/Makefile.am | 3 +-
src/gnome-chess.vala | 24 +++---
src/history.vala | 207 --------------------------------------------------
4 files changed, 12 insertions(+), 223 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9e69bc7..d60abb6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,6 @@ PKG_CHECK_MODULES(GNOME_CHESS, [
gmodule-2.0
gtk+-3.0 >= $GTK_REQUIRED
librsvg-2.0 >= $RSVG_REQUIRED
- sqlite3
gl
glu
x11
diff --git a/src/Makefile.am b/src/Makefile.am
index b7e8a3f..1c54089 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,8 +22,7 @@ gnome_chess_SOURCES = \
chess-scene.vala \
chess-view.vala \
chess-view-2d.vala \
- chess-view-3d.vala \
- history.vala
+ chess-view-3d.vala
test_chess_game_SOURCES = \
chess-bitboard.vala \
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 2757805..39d63e2 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -14,7 +14,6 @@ extern void gtk_file_filter_set_name (Gtk.FileFilter filter, string name);
public class Application : Gtk.Application
{
private Settings settings;
- private History history;
private Gtk.Builder builder;
private Gtk.Builder preferences_builder;
private Gtk.Window window;
@@ -57,6 +56,7 @@ public class Application : Gtk.Application
private PGNGame pgn_game;
private ChessGame game;
private bool in_history;
+ private string autosave_filename;
private File game_file;
private bool game_needs_saving;
private string? saved_filename = null;
@@ -118,8 +118,6 @@ public class Application : Gtk.Application
var data_dir = File.new_for_path (Path.build_filename (Environment.get_user_data_dir (),
"gnome-chess", null));
DirUtils.create_with_parents (data_dir.get_path (), 0755);
- history = new History (data_dir);
-
add_action_entries (app_entries, this);
builder = new Gtk.Builder ();
@@ -199,15 +197,16 @@ public class Application : Gtk.Application
foreach (var profile in ai_profiles)
message ("Detected AI profile %s in %s", profile.name, profile.path);
+ autosave_filename = data_dir.get_path () + "/autosave.pgn";
+
/* Load from history if no game requested */
if (game_file == null)
{
- var unfinished = history.get_unfinished ();
- if (unfinished != null)
- {
+ if (FileUtils.test (autosave_filename, FileTest.EXISTS))
+ game_file = File.new_for_path (autosave_filename);
+
+ if (game_file != null)
in_history = true;
- game_file = unfinished.last().data;
- }
else
start_new_game ();
}
@@ -352,16 +351,15 @@ public class Application : Gtk.Application
if (!game_needs_saving)
{
if (game_file != null)
- history.remove (game_file);
+ FileUtils.remove (game_file.get_path ());
return;
}
try
{
if (!in_history || game_file == null)
- game_file = history.add (pgn_game.date, pgn_game.result);
- else
- history.update (game_file, "", pgn_game.result);
+ game_file = File.new_for_path (autosave_filename);
+
debug ("Writing current game to %s", game_file.get_path ());
update_pgn_time_remaining ();
pgn_game.write (game_file);
@@ -1021,7 +1019,7 @@ public class Application : Gtk.Application
claim_draw_button.sensitive = false;
pause_button.sensitive = false;
- game_needs_saving = true;
+ game_needs_saving = false;
if (opponent_engine != null)
opponent_engine.stop ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]