[gnome-games] retro: Add RetroRunner.on_media_number_changed()



commit 36098c91456b0b458e524f757f0cabba5c13a83e
Author: Ricard Gascons <gascons1995 gmail com>
Date:   Thu Aug 18 16:06:27 2016 +0200

    retro: Add RetroRunner.on_media_number_changed()
    
    This commit adds the method on_media_number_changed() to RetroRunner for
    later use in multi-source games.
    
    This is part of a series of commits to add multi-source support.

 src/retro/retro-runner.vala |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 07f0783..4f8457e 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -106,6 +106,8 @@ public class Games.RetroRunner : Object, Runner {
                this.module_basename = module_basename;
                this.uid = uid;
                this.core_supports_snapshotting = core_supports_snapshotting;
+
+               _media_set.notify["selected-media-number"].connect (on_media_number_changed);
        }
 
        ~RetroRunner () {
@@ -339,6 +341,27 @@ public class Games.RetroRunner : Object, Runner {
                stopped ();
        }
 
+       private void on_media_number_changed () {
+               if (!is_initialized)
+                       return;
+
+               var media_number = media_set.selected_media_number;
+
+               Media media = null;
+               try {
+                       media = media_set.get_selected_media (media_number);
+               }
+               catch (Error e) {
+                       warning (e.message);
+
+                       return;
+               }
+
+               var uri = media.uri;
+
+               try_load_game (core, uri);
+       }
+
        private void save () throws Error {
                if (!should_save)
                        return;


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