[gnome-documents/wip/cosimoc/view-rework: 23/28] embed: move view loading spinner out of here



commit 1b3eb997794076dd5d48e24bac9f3503b74d4c04
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Aug 7 16:10:49 2016 -0700

    embed: move view loading spinner out of here
    
    And into the view container.

 src/embed.js |   17 -----------------
 src/view.js  |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index debc0a9..f2be0d9 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -97,11 +97,8 @@ const Embed = new Lang.Class({
 
         Application.modeController.connect('window-mode-changed',
                                            Lang.bind(this, this._onWindowModeChanged));
-
         Application.modeController.connect('fullscreen-changed',
                                            Lang.bind(this, this._onFullscreenChanged));
-        Application.trackerDocumentsController.connect('query-status-changed',
-                                                       Lang.bind(this, this._onQueryStatusChanged));
 
         Application.documentManager.connect('active-changed',
                                             Lang.bind(this, this._onActiveItemChanged));
@@ -122,8 +119,6 @@ const Embed = new Lang.Class({
         Application.searchController.connect('search-string-changed',
                                              Lang.bind(this, this._onSearchChanged));
 
-        this._onQueryStatusChanged();
-
         let windowMode = Application.modeController.getWindowMode();
         if (windowMode != WindowMode.WindowMode.NONE)
             this._onWindowModeChanged(Application.modeController, windowMode, WindowMode.WindowMode.NONE);
@@ -164,18 +159,6 @@ const Embed = new Lang.Class({
         this._stack.set_visible_child_name(page);
     },
 
-    _onQueryStatusChanged: function() {
-        let queryStatus = Application.trackerDocumentsController.getQueryStatus();
-
-        if (queryStatus) {
-            this._spinner.start();
-            this._stack.set_visible_child_name('spinner');
-        } else {
-            this._spinner.stop();
-            this._restoreLastPage();
-        }
-    },
-
     _onFullscreenChanged: function(controller, fullscreen) {
         this._toolbar.visible = !fullscreen;
         this._toolbar.sensitive = !fullscreen;
diff --git a/src/view.js b/src/view.js
index c359bd4..c85ce67 100644
--- a/src/view.js
+++ b/src/view.js
@@ -37,6 +37,8 @@ const ErrorBox = imports.errorBox;
 const WindowMode = imports.windowMode;
 const Utils = imports.utils;
 
+const _ICON_SIZE = 32;
+
 function getController(windowMode) {
     let offsetController;
     let trackerController;
@@ -350,6 +352,12 @@ const ViewContainer = new Lang.Class({
         this._errorBox = new ErrorBox.ErrorBox();
         this.add_named(this._errorBox, 'error');
 
+        this._spinner = new Gtk.Spinner({ width_request: _ICON_SIZE,
+                                          height_request: _ICON_SIZE,
+                                          halign: Gtk.Align.CENTER,
+                                          valign: Gtk.Align.CENTER });
+        this.add_named(this._spinner, 'spinner');
+
         this.show_all();
         this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
 
@@ -561,6 +569,10 @@ const ViewContainer = new Lang.Class({
             // unfreeze selection
             Application.selectionController.freezeSelection(false);
             this._updateSelection();
+
+            // hide the spinner
+            this._spinner.stop();
+            this.set_visible_child_name('view');
         } else {
             // save the last selection
             Application.selectionController.freezeSelection(true);
@@ -568,6 +580,10 @@ const ViewContainer = new Lang.Class({
             // if we're querying, clear the model from the view,
             // so that we don't uselessly refresh the rows
             this.view.set_model(null);
+
+            // kick off the spinner
+            this._spinner.start();
+            this.set_visible_child_name('spinner');
         }
     },
 


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