[gnome-characters] Add timeout before the spinner is showing up



commit cd6793bfad5380e25bc3a0bef2894dd4184222fa
Author: Daiki Ueno <dueno src gnome org>
Date:   Fri Oct 3 16:49:21 2014 +0900

    Add timeout before the spinner is showing up

 src/window.js |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/window.js b/src/window.js
index c41ae40..dbcfd5a 100644
--- a/src/window.js
+++ b/src/window.js
@@ -251,13 +251,21 @@ const MainView = new Lang.Class({
     _startSearch: function() {
         this._cancellable.cancel();
         this._cancellable.reset();
-        this._spinner.start();
-        this.visible_child_name = 'loading-banner';
-        this.show_all();
+        this._spinnerTimeoutId =
+            GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000,
+                             Lang.bind(this, function () {
+                                 this._spinnerTimeoutId = 0;
+                                 this._spinner.start();
+                                 this.visible_child_name = 'loading-banner';
+                                 this.show_all();
+                             }));
     },
 
     _finishSearch: function(name, result) {
-        this._spinner.stop();
+        if (this._spinnerTimeoutId > 0) {
+            GLib.source_remove(this._spinnerTimeoutId);
+            this._spinner.stop();
+        }
 
         let characters = [];
         for (let index = 0; index < result.len; index++) {


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