[gnome-games/wip/exalm/spinner: 22/25] ui: Use loading state instead of loading notification



commit a47d48dfb5dadcee13c739757be3a869935d4b18
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed Sep 5 20:18:53 2018 +0500

    ui: Use loading state instead of loading notification

 src/ui/application-window.vala | 16 ++++++++++++++++
 src/ui/application.vala        | 11 +----------
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index c07034b5..6a4ce199 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -116,6 +116,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
        private KonamiCode konami_code;
 
+       private Game game_to_run;
+
        public ApplicationWindow (ListModel collection) {
                collection_box.collection = collection;
                collection.items_changed.connect (() => {
@@ -175,6 +177,11 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        public void run_game (Game game) {
+               if (ui_state == UiState.LOADING) {
+                       game_to_run = game;
+                       return;
+               }
+
                // If there is a game already running we have to quit it first
                if (display_box.runner != null && !quit_game())
                        return;
@@ -736,4 +743,13 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        critical (e.message);
                }
        }
+
+       public void on_collection_loaded () {
+               if (game_to_run != null) {
+                       ui_state = UiState.DISPLAY;
+                       run_game (game_to_run);
+                       game_to_run = null;
+               } else
+                       ui_state = UiState.COLLECTION;
+       }
 }
diff --git a/src/ui/application.vala b/src/ui/application.vala
index c0b285cb..40ff77cb 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -234,15 +234,6 @@ public class Games.Application : Gtk.Application {
                        quit_application ();
                });
                window.show ();
-
-               GLib.Timeout.add (500, show_loading_notification);
-       }
-
-       private bool show_loading_notification () {
-               if (!game_list_loaded)
-                       window.loading_notification = true;
-
-               return false;
        }
 
        private void init_game_sources () {
@@ -340,7 +331,7 @@ public class Games.Application : Gtk.Application {
 
                game_list_loaded = true;
                if (window != null)
-                       window.loading_notification = false;
+                       window.on_collection_loaded ();
        }
 
        private void preferences () {


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