[gnome-weather] Show the window even if not loaded after 1 second



commit eca351c1f721531e9360c17ba3bf6bbc68a52b2b
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Feb 18 14:17:29 2014 +0100

    Show the window even if not loaded after 1 second
    
    If the model fails to load, for example due to network problems,
    show the window anyway after one second, other the user has no
    clue as to why the app is not working.
    Among other things, this should fix tests in continuous (because
    the testing infrastructure expects the window to appear in 10
    seconds)

 src/main.js |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/main.js b/src/main.js
index 5ffd350..5b83776 100644
--- a/src/main.js
+++ b/src/main.js
@@ -123,8 +123,18 @@ const Application = new Lang.Class({
         let win = new Window.MainWindow({ application: this });
 
         if (this.model.loading) {
-            let id = this.model.connect('notify::loading', function(model) {
-                model.disconnect(id);
+            let timeoutId, notifyId;
+            let model = this.model;
+
+            timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, function() {
+                log('Timeout during model load, perhaps the network is not available?');
+                model.disconnect(notifyId);
+                win.show();
+                return false;
+            });
+            notifyId = this.model.connect('notify::loading', function(model) {
+                model.disconnect(notifyId);
+                GLib.source_remove(timeoutId);
                 win.show();
             });
         } else {


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