[gnome-games/wip/exalm/snapshot: 6/6] core: Rename Savestate to Snapshot
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/snapshot: 6/6] core: Rename Savestate to Snapshot
- Date: Sun, 8 Mar 2020 14:31:58 +0000 (UTC)
commit 9206101850d28c75289e8902b514090b4f00f9ac
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Mar 8 19:29:35 2020 +0500
core: Rename Savestate to Snapshot
plugins/nintendo-ds/src/nintendo-ds-platform.vala | 2 +-
plugins/nintendo-ds/src/nintendo-ds-runner.vala | 28 ++++-----
plugins/nintendo-ds/src/nintendo-ds-snapshot.vala | 2 +-
src/command/command-runner.vala | 10 ++--
src/core/platform.vala | 2 +-
src/core/runner.vala | 10 ++--
src/core/snapshot-manager.vala | 22 +++----
src/core/{savestate.vala => snapshot.vala} | 32 +++++------
src/dummy/dummy-platform.vala | 4 +-
src/generic/generic-platform.vala | 4 +-
src/meson.build | 2 +-
src/retro/retro-platform.vala | 4 +-
src/retro/retro-runner.vala | 70 +++++++++++------------
src/ui/display-view.vala | 28 ++++-----
src/ui/snapshot-row.vala | 46 +++++++--------
src/ui/snapshots-list.vala | 53 ++++++++---------
16 files changed, 155 insertions(+), 164 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/nintendo-ds-platform.vala
b/plugins/nintendo-ds/src/nintendo-ds-platform.vala
index 6ab4dad6..1629987f 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-platform.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-platform.vala
@@ -5,7 +5,7 @@ public class Games.NintendoDsPlatform : RetroPlatform {
base (id, name, mime_types, prefix);
}
- public override Type get_savestate_type () {
+ public override Type get_snapshot_type () {
return typeof (NintendoDsSnapshot);
}
}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index 1836364f..0ac4a95b 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -164,28 +164,28 @@ private class Games.NintendoDsRunner : RetroRunner {
return true;
}
- protected override void save_to_snapshot (Savestate savestate) throws Error {
- base.save_to_snapshot (savestate);
+ protected override void save_to_snapshot (Snapshot snapshot) throws Error {
+ base.save_to_snapshot (snapshot);
- assert (savestate is NintendoDsSnapshot);
+ assert (snapshot is NintendoDsSnapshot);
- var ds_savestate = savestate as NintendoDsSnapshot;
- ds_savestate.screen_layout = screen_layout;
- ds_savestate.view_bottom_screen = view_bottom_screen;
+ var ds_snapshot = snapshot as NintendoDsSnapshot;
+ ds_snapshot.screen_layout = screen_layout;
+ ds_snapshot.view_bottom_screen = view_bottom_screen;
}
- protected override void load_from_snapshot (Savestate savestate) throws Error {
- base.load_from_snapshot (savestate);
+ protected override void load_from_snapshot (Snapshot snapshot) throws Error {
+ base.load_from_snapshot (snapshot);
- assert (savestate is NintendoDsSnapshot);
+ assert (snapshot is NintendoDsSnapshot);
- var ds_savestate = savestate as NintendoDsSnapshot;
- screen_layout = ds_savestate.screen_layout;
- view_bottom_screen = ds_savestate.view_bottom_screen;
+ var ds_snapshot = snapshot as NintendoDsSnapshot;
+ screen_layout = ds_snapshot.screen_layout;
+ view_bottom_screen = ds_snapshot.view_bottom_screen;
}
- protected override void reset_with_snapshot (Savestate? last_savestate) throws Error {
- base.reset_with_snapshot (last_savestate);
+ protected override void reset_with_snapshot (Snapshot? last_snapshot) throws Error {
+ base.reset_with_snapshot (last_snapshot);
screen_layout = NintendoDsLayout.TOP_BOTTOM;
view_bottom_screen = false;
diff --git a/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
b/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
index 58aa9ec1..acf25c11 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
@@ -1,6 +1,6 @@
// This file is part of GNOME Games. License: GPL-3.0+.
-public class Games.NintendoDsSnapshot : Savestate {
+public class Games.NintendoDsSnapshot : Snapshot {
public NintendoDsLayout screen_layout { get; set; }
public bool view_bottom_screen { get; set; }
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index cda7a565..9a7b210f 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -48,13 +48,13 @@ public class Games.CommandRunner : Object, Runner {
public void preview_current_state () {
}
- public void preview_savestate (Savestate savestate) {
+ public void preview_snapshot (Snapshot snapshot) {
}
- public void load_previewed_savestate () {
+ public void load_previewed_snapshot() {
}
- public Savestate[] get_savestates () {
+ public Snapshot[] get_snapshots () {
return {};
}
@@ -94,11 +94,11 @@ public class Games.CommandRunner : Object, Runner {
public void stop () {
}
- public Savestate? try_create_savestate (bool is_automatic) {
+ public Snapshot? try_create_snapshot (bool is_automatic) {
return null;
}
- public void delete_savestate (Savestate savestate) {
+ public void delete_snapshot (Snapshot snapshot) {
}
public InputMode[] get_available_input_modes () {
diff --git a/src/core/platform.vala b/src/core/platform.vala
index e9794622..966be821 100644
--- a/src/core/platform.vala
+++ b/src/core/platform.vala
@@ -9,7 +9,7 @@ public interface Games.Platform : Object {
public abstract PreferencesPagePlatformsRow get_row ();
- public abstract Type get_savestate_type ();
+ public abstract Type get_snapshot_type ();
public static uint hash (Platform platform) {
return str_hash (platform.get_id ());
diff --git a/src/core/runner.vala b/src/core/runner.vala
index 7f9e972c..9e4e853b 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -22,12 +22,12 @@ public interface Games.Runner : Object {
public abstract void pause ();
public abstract void stop ();
- public abstract Savestate? try_create_savestate (bool is_automatic);
- public abstract void delete_savestate (Savestate savestate);
- public abstract void preview_savestate (Savestate savestate);
+ public abstract Snapshot? try_create_snapshot (bool is_automatic);
+ public abstract void delete_snapshot (Snapshot snapshot);
+ public abstract void preview_snapshot (Snapshot snapshot);
public abstract void preview_current_state ();
- public abstract void load_previewed_savestate () throws Error;
- public abstract Savestate[] get_savestates ();
+ public abstract void load_previewed_snapshot () throws Error;
+ public abstract Snapshot[] get_snapshots ();
public abstract InputMode[] get_available_input_modes ();
public abstract bool key_press_event (uint keyval, Gdk.ModifierType state);
diff --git a/src/core/snapshot-manager.vala b/src/core/snapshot-manager.vala
index 87694d16..ceea640b 100644
--- a/src/core/snapshot-manager.vala
+++ b/src/core/snapshot-manager.vala
@@ -3,12 +3,12 @@
public class Games.SnapshotManager : Object {
private const int MAX_AUTOSAVES = 5;
- public delegate void SnapshotFunc (Savestate snapshot) throws Error;
+ public delegate void SnapshotFunc (Snapshot snapshot) throws Error;
private Game game;
private string core_id;
- private Savestate[] snapshots;
+ private Snapshot[] snapshots;
public SnapshotManager (Game game, string core_id) throws Error {
this.game = game;
@@ -31,10 +31,10 @@ public class Games.SnapshotManager : Object {
while ((snapshot_name = dir.read_name ()) != null) {
var snapshot_path = Path.build_filename (dir_path, snapshot_name);
- snapshots += Savestate.load (game.platform, core_id, snapshot_path);
+ snapshots += Snapshot.load (game.platform, core_id, snapshot_path);
}
- qsort_with_data (snapshots, sizeof (Savestate), Savestate.compare);
+ qsort_with_data (snapshots, sizeof (Snapshot), Snapshot.compare);
}
private string get_snapshots_dir () throws Error {
@@ -46,7 +46,7 @@ public class Games.SnapshotManager : Object {
@"$uid-$core_id_prefix");
}
- public Savestate[] get_snapshots () {
+ public Snapshot[] get_snapshots () {
return snapshots;
}
@@ -54,7 +54,7 @@ public class Games.SnapshotManager : Object {
return snapshots.length > 0;
}
- public Savestate? get_latest_snapshot () {
+ public Snapshot? get_latest_snapshot () {
if (has_snapshots ())
return snapshots[0];
@@ -107,7 +107,7 @@ public class Games.SnapshotManager : Object {
return _("New snapshot %s").printf (next_number.to_string ());
}
- public Savestate create_snapshot (bool is_automatic, SnapshotFunc save_callback) throws Error {
+ public Snapshot create_snapshot (bool is_automatic, SnapshotFunc save_callback) throws Error {
// Make room for the new automatic snapshot
if (is_automatic)
trim_autosaves ();
@@ -116,7 +116,7 @@ public class Games.SnapshotManager : Object {
var path = Path.build_filename (get_snapshots_dir (),
creation_date.to_string ());
- var snapshot = Savestate.create_empty (game, core_id, path);
+ var snapshot = Snapshot.create_empty (game, core_id, path);
snapshot.is_automatic = is_automatic;
snapshot.name = is_automatic ? null : create_new_snapshot_name ();
@@ -127,7 +127,7 @@ public class Games.SnapshotManager : Object {
snapshot = snapshot.move_to (path);
- Savestate[] new_snapshots = {};
+ Snapshot[] new_snapshots = {};
new_snapshots += snapshot;
foreach (var s in snapshots)
@@ -138,8 +138,8 @@ public class Games.SnapshotManager : Object {
return snapshot;
}
- public void delete_snapshot (Savestate snapshot) {
- Savestate[] new_snapshots = {};
+ public void delete_snapshot (Snapshot snapshot) {
+ Snapshot[] new_snapshots = {};
foreach (var s in snapshots)
if (snapshot != s)
diff --git a/src/core/savestate.vala b/src/core/snapshot.vala
similarity index 85%
rename from src/core/savestate.vala
rename to src/core/snapshot.vala
index 9b487d6f..847da723 100644
--- a/src/core/savestate.vala
+++ b/src/core/snapshot.vala
@@ -1,29 +1,29 @@
// This file is part of GNOME Games. License: GPL-3.0+.
-public class Games.Savestate : Object {
+public class Games.Snapshot : Object {
public string path { get; construct; }
public Platform platform { get; construct; }
public string core { get; construct; }
- // Automatic means whether the savestate was created automatically when
+ // Automatic means whether the snapshot was created automatically when
// quitting/loading the game or manually by the user using the Save button
public bool is_automatic { get; set; }
public string name { get; set; }
public DateTime? creation_date { get; set; }
public double screenshot_aspect_ratio { get; set; }
- public static Savestate load (Platform platform, string core_id, string path) {
- var type = platform.get_savestate_type ();
+ public static Snapshot load (Platform platform, string core_id, string path) {
+ var type = platform.get_snapshot_type ();
- var savestate = Object.new (type,
+ var snapshot = Object.new (type,
"path", path,
"platform", platform,
"core", core_id,
- null) as Savestate;
+ null) as Snapshot;
- savestate.load_keyfile ();
+ snapshot.load_keyfile ();
- return savestate;
+ return snapshot;
}
private void load_keyfile () {
@@ -101,7 +101,7 @@ public class Games.Savestate : Object {
var creation_date_str = keyfile.get_string ("Metadata", "Creation Date");
creation_date = new DateTime.from_iso8601 (creation_date_str, new TimeZone.local ());
- // Migrated savestates aren't going to have this
+ // Migrated snapshots aren't going to have this
if (keyfile.has_group ("Screenshot"))
screenshot_aspect_ratio = keyfile.get_double ("Screenshot", "Aspect Ratio");
else
@@ -135,19 +135,19 @@ public class Games.Savestate : Object {
}
public void delete_from_disk () {
- var savestate_dir = File.new_for_path (path);
+ var snapshot_dir = File.new_for_path (path);
// Treat errors locally in this method because there isn't much that
// can go wrong with deleting files
try {
- FileOperations.delete_files (savestate_dir, {});
+ FileOperations.delete_files (snapshot_dir, {});
}
catch (Error e) {
warning ("Failed to delete snapshot at %s: %s", path, e.message);
}
}
- public static Savestate create_empty (Game game, string core_id, string path) throws Error {
+ public static Snapshot create_empty (Game game, string core_id, string path) throws Error {
var random = Random.next_int ();
var tmp_path = @"$(path)_$random";
@@ -157,10 +157,10 @@ public class Games.Savestate : Object {
var save_dir = dir.get_child ("save-dir");
save_dir.make_directory ();
- return Savestate.load (game.platform, core_id, tmp_path);
+ return Snapshot.load (game.platform, core_id, tmp_path);
}
- public Savestate move_to (string dest_path) throws Error {
+ public Snapshot move_to (string dest_path) throws Error {
var current_dir = File.new_for_path (path);
var dest_dir = File.new_for_path (dest_path);
@@ -172,7 +172,7 @@ public class Games.Savestate : Object {
current_dir.move (dest_dir, FileCopyFlags.ALL_METADATA);
- return Savestate.load (platform, core, dest);
+ return Snapshot.load (platform, core, dest);
}
public void copy_save_dir_to (string dest) throws Error {
@@ -182,7 +182,7 @@ public class Games.Savestate : Object {
FileOperations.copy_contents (save_dir_file, dest_file);
}
- public static int compare (Savestate s1, Savestate s2) {
+ public static int compare (Snapshot s1, Snapshot s2) {
if (s1.path < s2.path)
return 1;
diff --git a/src/dummy/dummy-platform.vala b/src/dummy/dummy-platform.vala
index 82c2765c..9eb40fb4 100644
--- a/src/dummy/dummy-platform.vala
+++ b/src/dummy/dummy-platform.vala
@@ -17,7 +17,7 @@ public class Games.DummyPlatform : Object, Platform {
return new PreferencesPagePlatformsGenericRow (_("Unknown"));
}
- public Type get_savestate_type () {
- return typeof (Savestate);
+ public Type get_snapshot_type () {
+ return typeof (Snapshot);
}
}
diff --git a/src/generic/generic-platform.vala b/src/generic/generic-platform.vala
index 0721b89c..5c3e4c47 100644
--- a/src/generic/generic-platform.vala
+++ b/src/generic/generic-platform.vala
@@ -27,7 +27,7 @@ public class Games.GenericPlatform : Object, Platform {
return new PreferencesPagePlatformsGenericRow (name);
}
- public Type get_savestate_type () {
- return typeof (Savestate);
+ public Type get_snapshot_type () {
+ return typeof (Snapshot);
}
}
diff --git a/src/meson.build b/src/meson.build
index a63c466b..651a305a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -38,7 +38,7 @@ vala_sources = [
'core/runner.vala',
'core/runner-error.vala',
'core/runner-factory.vala',
- 'core/savestate.vala',
+ 'core/snapshot.vala',
'core/snapshot-manager.vala',
'core/title.vala',
'core/uid.vala',
diff --git a/src/retro/retro-platform.vala b/src/retro/retro-platform.vala
index dfbcad9f..90e816fd 100644
--- a/src/retro/retro-platform.vala
+++ b/src/retro/retro-platform.vala
@@ -33,7 +33,7 @@ public class Games.RetroPlatform : Object, Platform {
return new PreferencesPagePlatformsRetroRow (this);
}
- public virtual Type get_savestate_type () {
- return typeof (Savestate);
+ public virtual Type get_snapshot_type () {
+ return typeof (Snapshot);
}
}
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 63188fd1..7dba1410 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -47,7 +47,7 @@ public class Games.RetroRunner : Object, Runner {
private Game game;
private SnapshotManager snapshot_manager;
- private Savestate previewed_savestate;
+ private Snapshot previewed_snapshot;
private string tmp_save_dir;
@@ -221,7 +221,7 @@ public class Games.RetroRunner : Object, Runner {
reset_with_snapshot (snapshot);
if (snapshot != null)
- preview_savestate (snapshot);
+ preview_snapshot (snapshot);
}
catch (RetroError.MODULE_NOT_FOUND e) {
debug ("%s\n", e.message);
@@ -245,8 +245,8 @@ public class Games.RetroRunner : Object, Runner {
public void restart () throws Error {
pause ();
- var savestate = try_create_savestate (true);
- reset_with_snapshot (savestate);
+ var snapshot = try_create_snapshot (true);
+ reset_with_snapshot (snapshot);
core.reset ();
@@ -274,10 +274,6 @@ public class Games.RetroRunner : Object, Runner {
core.stop ();
}
- //FIXME:
- // In the future here there will be code which updates the currently
- // used temporary savestate
-
running = false;
}
@@ -311,7 +307,7 @@ public class Games.RetroRunner : Object, Runner {
core_loaded = false;
}
- public Savestate? try_create_savestate (bool is_automatic) {
+ public Snapshot? try_create_snapshot (bool is_automatic) {
if (!supports_snapshots)
return null;
@@ -328,22 +324,22 @@ public class Games.RetroRunner : Object, Runner {
}
}
- public void delete_savestate (Savestate savestate) {
- snapshot_manager.delete_snapshot (savestate);
+ public void delete_snapshot (Snapshot snapshot) {
+ snapshot_manager.delete_snapshot (snapshot);
}
- public void preview_savestate (Savestate savestate) {
- previewed_savestate = savestate;
+ public void preview_snapshot (Snapshot snapshot) {
+ previewed_snapshot = snapshot;
- var screenshot_path = savestate.get_screenshot_path ();
+ var screenshot_path = snapshot.get_screenshot_path ();
Gdk.Pixbuf pixbuf = null;
- // Treat errors locally because loading the savestate screenshot is not
+ // Treat errors locally because loading the snapshot screenshot is not
// a critical operation
try {
pixbuf = new Gdk.Pixbuf.from_file (screenshot_path);
- var aspect_ratio = savestate.screenshot_aspect_ratio;
+ var aspect_ratio = snapshot.screenshot_aspect_ratio;
if (aspect_ratio != 0)
Retro.pixbuf_set_aspect_ratio (pixbuf, (float) aspect_ratio);
@@ -359,11 +355,11 @@ public class Games.RetroRunner : Object, Runner {
view.set_pixbuf (current_state_pixbuf);
}
- public void load_previewed_savestate () throws Error {
- load_from_snapshot (previewed_savestate);
+ public void load_previewed_snapshot () throws Error {
+ load_from_snapshot (previewed_snapshot);
}
- public Savestate[] get_savestates () {
+ public Snapshot[] get_snapshots () {
if (snapshot_manager == null)
return {};
@@ -474,42 +470,42 @@ public class Games.RetroRunner : Object, Runner {
core.load_memory (Retro.MemoryType.SAVE_RAM, save_ram_path);
}
- protected virtual void save_to_snapshot (Savestate savestate) throws Error {
+ protected virtual void save_to_snapshot (Snapshot snapshot) throws Error {
if (core.get_memory_size (Retro.MemoryType.SAVE_RAM) > 0)
core.save_memory (Retro.MemoryType.SAVE_RAM,
- savestate.get_save_ram_path ());
+ snapshot.get_save_ram_path ());
var tmp_dir = File.new_for_path (tmp_save_dir);
- var dest_dir = File.new_for_path (savestate.get_save_directory_path ());
+ var dest_dir = File.new_for_path (snapshot.get_save_directory_path ());
FileOperations.copy_contents (tmp_dir, dest_dir);
if (media_set.get_size () > 1)
- savestate.set_media_data (media_set);
+ snapshot.set_media_data (media_set);
- core.save_state (savestate.get_snapshot_path ());
- save_screenshot (savestate.get_screenshot_path ());
- savestate.screenshot_aspect_ratio = Retro.pixbuf_get_aspect_ratio (current_state_pixbuf);
+ core.save_state (snapshot.get_snapshot_path ());
+ save_screenshot (snapshot.get_screenshot_path ());
+ snapshot.screenshot_aspect_ratio = Retro.pixbuf_get_aspect_ratio (current_state_pixbuf);
}
- protected virtual void load_from_snapshot (Savestate savestate) throws Error {
+ protected virtual void load_from_snapshot (Snapshot snapshot) throws Error {
tmp_save_dir = create_tmp_save_dir ();
- savestate.copy_save_dir_to (tmp_save_dir);
+ snapshot.copy_save_dir_to (tmp_save_dir);
core.save_directory = tmp_save_dir;
- load_save_ram (savestate.get_save_ram_path ());
- core.load_state (savestate.get_snapshot_path ());
+ load_save_ram (snapshot.get_save_ram_path ());
+ core.load_state (snapshot.get_snapshot_path ());
- if (savestate.has_media_data ())
- media_set.selected_media_number = savestate.get_media_data ();
+ if (snapshot.has_media_data ())
+ media_set.selected_media_number = snapshot.get_media_data ();
}
- protected virtual void reset_with_snapshot (Savestate? last_savestate) throws Error {
- if (last_savestate == null)
+ protected virtual void reset_with_snapshot (Snapshot? last_snapshot) throws Error {
+ if (last_snapshot == null)
return;
- load_save_ram (last_savestate.get_save_ram_path ());
+ load_save_ram (last_snapshot.get_save_ram_path ());
- if (last_savestate.has_media_data ())
- media_set.selected_media_number = last_savestate.get_media_data ();
+ if (last_snapshot.has_media_data ())
+ media_set.selected_media_number = last_snapshot.get_media_data ();
}
}
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index ac36fdda..384ed520 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -182,14 +182,14 @@ private class Games.DisplayView : Object, UiView {
if (((keyval == Gdk.Key.s || keyval == Gdk.Key.S) && ctrl_pressed) ||
(keyval == Gdk.Key.F2)) {
- create_new_savestate ();
+ create_new_snapshot ();
return true;
}
if ((keyval == Gdk.Key.d || keyval == Gdk.Key.D) && ctrl_pressed ||
(keyval == Gdk.Key.F3)) {
- load_latest_savestate ();
+ load_latest_snapshot ();
return true;
}
@@ -199,31 +199,31 @@ private class Games.DisplayView : Object, UiView {
private void on_escape_key_pressed () {
if (is_showing_snapshots)
- on_display_back (); // Hide Savestates menu
+ on_display_back ();
else if (can_fullscreen) {
is_fullscreen = false;
settings.set_boolean ("fullscreen", false);
}
}
- private void create_new_savestate () {
+ private void create_new_snapshot () {
runner.pause ();
- runner.try_create_savestate (false);
+ runner.try_create_snapshot (false);
runner.resume ();
runner.get_display ().grab_focus ();
}
- private void load_latest_savestate () {
- var savestates = runner.get_savestates ();
+ private void load_latest_snapshot () {
+ var snapshots = runner.get_snapshots ();
- if (savestates.length == 0)
+ if (snapshots.length == 0)
return;
runner.pause ();
- runner.preview_savestate (savestates[0]);
+ runner.preview_snapshot (snapshots[0]);
try {
- runner.load_previewed_savestate ();
+ runner.load_previewed_snapshot ();
}
catch (Error e) {
warning ("Failed to load snapshot: %s", e.message);
@@ -398,7 +398,7 @@ private class Games.DisplayView : Object, UiView {
private bool start_or_resume (Runner runner, bool resume) {
try {
if (resume)
- runner.load_previewed_savestate ();
+ runner.load_previewed_snapshot ();
runner.start ();
@@ -471,13 +471,13 @@ private class Games.DisplayView : Object, UiView {
runner.pause ();
if (!runner.is_integrated) {
- // Game does not and will not support savestates (e.g. Steam games)
+ // Game does not and will not support snapshots (e.g. Steam games)
// => Progress cannot be saved so game can be quit safely
runner.stop ();
return true;
}
- if (runner.try_create_savestate (true) != null) {
+ if (runner.try_create_snapshot (true) != null) {
// Progress saved => can quit game safely
runner.stop ();
return true;
@@ -590,7 +590,7 @@ private class Games.DisplayView : Object, UiView {
private void load_snapshot () {
try {
- runner.load_previewed_savestate ();
+ runner.load_previewed_snapshot ();
}
catch (Error e) {
critical ("Failed to load snapshot: %s", e.message);
diff --git a/src/ui/snapshot-row.vala b/src/ui/snapshot-row.vala
index 82fe277f..8cca1725 100644
--- a/src/ui/snapshot-row.vala
+++ b/src/ui/snapshot-row.vala
@@ -13,18 +13,18 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
[GtkChild]
private Gtk.Revealer revealer;
- private Savestate _savestate;
- public Savestate savestate {
- get { return _savestate; }
+ private Snapshot _snapshot;
+ public Snapshot snapshot {
+ get { return _snapshot; }
set {
- _savestate = value;
+ _snapshot = value;
- if (savestate.is_automatic)
+ if (snapshot.is_automatic)
name_label.label = _("Autosave");
else
- name_label.label = savestate.name;
+ name_label.label = snapshot.name;
- var creation_date = savestate.creation_date;
+ var creation_date = snapshot.creation_date;
var date_format = get_date_format (creation_date);
date_label.label = creation_date.format (date_format);
@@ -34,23 +34,23 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
private Gdk.Pixbuf pixbuf;
- public SnapshotRow (Savestate savestate) {
- Object (savestate: savestate);
+ public SnapshotRow (Snapshot snapshot) {
+ Object (snapshot: snapshot);
}
private void load_thumbnail () {
- if (savestate == null)
+ if (snapshot == null)
return;
- var screenshot_path = savestate.get_screenshot_path ();
+ var screenshot_path = snapshot.get_screenshot_path ();
var screenshot_width = 0;
var screenshot_height = 0;
Gdk.Pixbuf.get_file_info (screenshot_path, out screenshot_width, out screenshot_height);
- var aspect_ratio = savestate.screenshot_aspect_ratio;
+ var aspect_ratio = snapshot.screenshot_aspect_ratio;
- // A fallback for migrated savestates
+ // A fallback for migrated snapshots
if (aspect_ratio == 0)
aspect_ratio = (double) screenshot_width / screenshot_height;
@@ -87,10 +87,10 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
public void set_name (string name) {
name_label.label = name;
- savestate.name = name;
+ snapshot.name = name;
try {
- savestate.write_metadata ();
+ snapshot.write_metadata ();
}
catch (Error e) {
critical ("Couldn't update snapshot name: %s", e.message);
@@ -174,17 +174,15 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
cr.close_path ();
}
- // Get the date format such that savestates dates are presented similar to
- // Nautilus's Modified column
// Adapted from nautilus-file.c, nautilus_file_get_date_as_string()
- private string get_date_format (DateTime savestate_date) {
- var savestate_date_midnight = new DateTime.local (savestate_date.get_year (),
- savestate_date.get_month (),
- savestate_date.get_day_of_month (),
- 0, 0, 0);
+ private string get_date_format (DateTime date) {
+ var date_midnight = new DateTime.local (date.get_year (),
+ date.get_month (),
+ date.get_day_of_month (),
+ 0, 0, 0);
var now = new DateTime.now ();
var today_midnight = new DateTime.local (now.get_year (), now.get_month (),
now.get_day_of_month (), 0, 0, 0);
- var days_ago = (today_midnight.difference (savestate_date_midnight)) / GLib.TimeSpan.DAY;
+ var days_ago = (today_midnight.difference (date_midnight)) / GLib.TimeSpan.DAY;
if (days_ago == 0) {
/* Translators: Time in locale format */
@@ -203,7 +201,7 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
/* xgettext:no-c-format */
return _("%a %X");
}
- else if (savestate_date.get_year () == now.get_year ()) {
+ else if (date.get_year () == now.get_year ()) {
/* Translators: this is the day of the month followed
* by the abbreviated month name followed by a time in
* locale format i.e. "3 Feb 23:04:35" */
diff --git a/src/ui/snapshots-list.vala b/src/ui/snapshots-list.vala
index 1c5be589..7d27e305 100644
--- a/src/ui/snapshots-list.vala
+++ b/src/ui/snapshots-list.vala
@@ -24,7 +24,7 @@ private class Games.SnapshotsList : Gtk.Box {
[GtkChild]
private Gtk.Label rename_error_label;
- private Savestate selected_savestate;
+ private Snapshot selected_snapshot;
public bool is_revealed { get; set; }
public Runner runner { get; set; }
@@ -43,9 +43,9 @@ private class Games.SnapshotsList : Gtk.Box {
if (row != null && row is SnapshotRow) {
var snapshot_row = row as SnapshotRow;
- var savestate = snapshot_row.savestate;
+ var snapshot = snapshot_row.snapshot;
- if (savestate != selected_savestate)
+ if (snapshot != selected_snapshot)
select_snapshot_row (row);
}
}
@@ -53,28 +53,25 @@ private class Games.SnapshotsList : Gtk.Box {
[GtkCallback]
private void on_row_activated (Gtk.ListBoxRow activated_row) {
if (activated_row == new_snapshot_row) {
- var savestate = runner.try_create_savestate (false);
+ var snapshot = runner.try_create_snapshot (false);
- if (savestate != null) {
- var snapshot_row = new SnapshotRow (savestate);
+ if (snapshot != null) {
+ var snapshot_row = new SnapshotRow (snapshot);
list_box.insert (snapshot_row, 1);
select_snapshot_row (snapshot_row);
snapshot_row.reveal ();
}
else {
- // Savestate creation failed
select_snapshot_row (list_box.get_row_at_index (1));
- // TODO: Perhaps we should warn the user that the creation of
- // the savestate failed via an in-app notification ?
+ // TODO: Add a warning
}
} else
select_snapshot_row (activated_row);
}
private void populate_list_box () {
- // Remove current savestate rows
var list_rows = list_box.get_children ();
foreach (var row in list_rows) {
if (row != new_snapshot_row)
@@ -84,9 +81,9 @@ private class Games.SnapshotsList : Gtk.Box {
if (runner == null)
return;
- var savestates = _runner.get_savestates ();
- foreach (var savestate in savestates) {
- var list_row = new SnapshotRow (savestate);
+ var snapshots = _runner.get_snapshots ();
+ foreach (var snapshot in snapshots) {
+ var list_row = new SnapshotRow (snapshot);
// Reveal it early so that it doesn't animate
list_row.reveal ();
@@ -114,10 +111,10 @@ private class Games.SnapshotsList : Gtk.Box {
var selected_row = list_box.get_selected_row ();
var selected_row_index = selected_row.get_index ();
var snapshot_row = selected_row as SnapshotRow;
- var savestate = snapshot_row.savestate;
+ var snapshot = snapshot_row.snapshot;
ensure_row_is_visible (selected_row);
- runner.delete_savestate (savestate);
+ runner.delete_snapshot (snapshot);
// Select and preview a new row
var next_row_index = selected_row_index + 1;
@@ -153,7 +150,7 @@ private class Games.SnapshotsList : Gtk.Box {
ensure_row_is_visible (selected_row);
- rename_entry.text = selected_savestate.name;
+ rename_entry.text = selected_snapshot.name;
rename_popover.relative_to = selected_row;
rename_popover.popup ();
}
@@ -195,15 +192,15 @@ private class Games.SnapshotsList : Gtk.Box {
foreach (var list_child in list_box.get_children ()) {
if (!(list_child is SnapshotRow))
- continue; // Ignore the new savestate row;
+ continue;
var snapshot_row = list_child as SnapshotRow;
- var savestate = snapshot_row.savestate;
+ var snapshot = snapshot_row.snapshot;
- if (savestate.is_automatic)
+ if (snapshot.is_automatic)
continue;
- if (savestate.name == entry_text) {
+ if (snapshot.name == entry_text) {
rename_entry.get_style_context ().add_class ("error");
rename_popover_btn.sensitive = false;
rename_error_label.label = _("A snapshot with this name already exists");
@@ -251,7 +248,7 @@ private class Games.SnapshotsList : Gtk.Box {
if (row == null) {
runner.preview_current_state ();
- selected_savestate = null;
+ selected_snapshot = null;
lookup_action ("load-snapshot").set_enabled (false);
}
else {
@@ -261,21 +258,21 @@ private class Games.SnapshotsList : Gtk.Box {
return;
var snapshot_row = row as SnapshotRow;
- var savestate = snapshot_row.savestate;
+ var snapshot = snapshot_row.snapshot;
- if (savestate == selected_savestate) {
+ if (snapshot == selected_snapshot) {
lookup_action ("load-snapshot").activate (null);
return;
}
- runner.preview_savestate (savestate);
- selected_savestate = savestate;
+ runner.preview_snapshot (snapshot);
+ selected_snapshot = snapshot;
lookup_action ("load-snapshot").set_enabled (true);
}
- delete_btn.sensitive = (selected_savestate != null);
- rename_btn.sensitive = (selected_savestate != null &&
- !selected_savestate.is_automatic);
+ delete_btn.sensitive = (selected_snapshot != null);
+ rename_btn.sensitive = (selected_snapshot != null &&
+ !selected_snapshot.is_automatic);
}
public bool on_key_press_event (uint keyval, Gdk.ModifierType state) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]