[gnome-games] playstation: Sort discs before adding them to the media set



commit 989f6856f14049a1763c8f7e0ba7c42ea52d471b
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sat Sep 3 15:48:15 2016 +0200

    playstation: Sort discs before adding them to the media set
    
    This avoids discs to be in the wrong order in the media set and hence in
    the UI.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770780

 .../playstation/src/playstation-game-factory.vala  |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 0f8c6db..724ef29 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -103,7 +103,24 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                Media[] medias = {};
 
                var gameinfo = get_gameinfo ();
-               disc_set.foreach ((disc_id) => {
+               var disc_list = disc_set.get_values ();
+               disc_list.sort_with_data ((disc_id_a, disc_id_b) => {
+                       int index_a;
+                       int index_b;
+                       try {
+                               index_a = gameinfo.get_disc_set_index_for_disc_id (disc_id_a);
+                               index_b = gameinfo.get_disc_set_index_for_disc_id (disc_id_b);
+                       }
+                       catch (Error e) {
+                               debug (e.message);
+
+                               return 0;
+                       }
+
+                       return (int) (index_a > index_b) - (int) (index_a < index_b);
+               });
+
+               disc_list.foreach ((disc_id) => {
                        var uri = discs[disc_id];
                        var title = new GameinfoDiscIdDiscTitle (gameinfo, disc_id);
                        medias += new Media (uri, title);


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