[gnome-games/wip/exalm/savestates: 19/22] savestate: Use properties for populating metadata



commit 6f843938472d85a56427b3531f5d3c3a5018ea52
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Jan 26 00:53:41 2020 +0500

    savestate: Use properties for populating metadata
    
    Now that everything is properties, set_metadata_*() functions
    can be removed.

 src/core/savestate.vala     | 26 ++++----------------------
 src/retro/retro-runner.vala | 16 +++++++---------
 2 files changed, 11 insertions(+), 31 deletions(-)
---
diff --git a/src/core/savestate.vala b/src/core/savestate.vala
index 17c1f1df..dfc30c7d 100644
--- a/src/core/savestate.vala
+++ b/src/core/savestate.vala
@@ -4,11 +4,11 @@ public class Games.Savestate : Object {
 
        // Automatic means whether the savestate was created automatically when
        // quitting/loading the game or manually by the user using the Save button
-       public bool is_automatic { get; private set; }
+       public bool is_automatic { get; set; }
        public string name { get; set; }
-       public DateTime? creation_date { get; private set; }
-       public string core { get; private set; }
-       public double screenshot_aspect_ratio { get; private set; }
+       public DateTime? creation_date { get; set; }
+       public string core { get; set; }
+       public double screenshot_aspect_ratio { get; set; }
 
        private static Savestate load (Platform platform, string path) {
                var type = platform.get_savestate_type ();
@@ -132,24 +132,6 @@ public class Games.Savestate : Object {
                return Savestate.load (platform, new_savestate_dir_path);
        }
 
-       // Set the metadata for an automatic savestate
-       public void set_metadata_automatic (DateTime creation_date, string core, double aspect_ratio) throws 
Error {
-               is_automatic = true;
-               this.name = null;
-               this.creation_date = creation_date;
-               this.core = core;
-               this.screenshot_aspect_ratio = aspect_ratio;
-       }
-
-       // Set the metadata for a manual savestate
-       public void set_metadata_manual (string name, DateTime creation_date, string core, double 
aspect_ratio) throws Error {
-               is_automatic = false;
-               this.name = name;
-               this.creation_date = creation_date;
-               this.core = core;
-               this.screenshot_aspect_ratio = aspect_ratio;
-       }
-
        protected virtual void load_metadata (KeyFile keyfile) throws KeyFileError {
                is_automatic = keyfile.get_boolean ("Metadata", "Automatic");
 
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index b93f3812..6fc7037e 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -479,18 +479,16 @@ public class Games.RetroRunner : Object, Runner {
                save_screenshot_in_tmp ();
 
                // Populate the metadata file
-               var now_time = new DateTime.now ();
-               var ratio = Retro.pixbuf_get_aspect_ratio (current_state_pixbuf);
+               tmp_live_savestate.is_automatic = is_automatic;
 
                if (is_automatic)
-                       tmp_live_savestate.set_metadata_automatic (now_time,
-                                                                  get_core_id (), ratio);
-               else {
-                       var savestate_name = create_new_savestate_name ();
+                       tmp_live_savestate.name = null;
+               else
+                       tmp_live_savestate.name = create_new_savestate_name ();
 
-                       tmp_live_savestate.set_metadata_manual (savestate_name, now_time,
-                                                               get_core_id (), ratio);
-               }
+               tmp_live_savestate.creation_date = new DateTime.now ();
+               tmp_live_savestate.core = get_core_id ();
+               tmp_live_savestate.screenshot_aspect_ratio = Retro.pixbuf_get_aspect_ratio 
(current_state_pixbuf);
 
                save_savestate_metadata (tmp_live_savestate);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]