[gnome-documents/wip/rishi/split-view: 13/15] embed, view: Move the error page into the ViewContainer



commit 3195e6583bfedbab70c1807ce96bb8676b1b903e
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 9 18:07:13 2015 +0100

    embed, view: Move the error page into the ViewContainer
    
    With multiple views, it is simpler to give each view its own error
    page, so that they can individually react to query errors specific to
    them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686461

 src/embed.js |   60 ----------------------------------------------------------
 src/view.js  |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 60 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 30ecdb6..4042a2f 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -73,51 +73,6 @@ const SpinnerBox = new Lang.Class({
     }
 });
 
-const ErrorBox = new Lang.Class({
-    Name: 'ErrorBox',
-
-    _init: function(primary, secondary) {
-        this.widget = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
-                                     row_spacing: 12,
-                                     hexpand: true,
-                                     vexpand: true,
-                                     halign: Gtk.Align.CENTER,
-                                     valign: Gtk.Align.CENTER });
-
-        this._image = new Gtk.Image({ pixel_size: _ICON_SIZE,
-                                      icon_name: 'face-uncertain-symbolic',
-                                      halign: Gtk.Align.CENTER,
-                                      valign: Gtk.Align.CENTER });
-
-        this.widget.add(this._image);
-
-        this._primaryLabel =
-            new Gtk.Label({ label: '',
-                            use_markup: true,
-                            halign: Gtk.Align.CENTER,
-                            valign: Gtk.Align.CENTER });
-        this.widget.add(this._primaryLabel);
-
-        this._secondaryLabel =
-            new Gtk.Label({ label: '',
-                            use_markup: true,
-                            wrap: true,
-                            halign: Gtk.Align.CENTER,
-                            valign: Gtk.Align.CENTER });
-        this.widget.add(this._secondaryLabel);
-
-        this.widget.show_all();
-    },
-
-    update: function(primary, secondary) {
-        let primaryMarkup = '<big><b>' + GLib.markup_escape_text(primary, -1) + '</b></big>';
-        let secondaryMarkup = GLib.markup_escape_text(secondary, -1);
-
-        this._primaryLabel.label = primaryMarkup;
-        this._secondaryLabel.label = secondaryMarkup;
-    }
-});
-
 const Embed = new Lang.Class({
     Name: 'Embed',
 
@@ -161,9 +116,6 @@ const Embed = new Lang.Class({
         this._spinnerBox = new SpinnerBox();
         this._stack.add_named(this._spinnerBox.widget, 'spinner');
 
-        this._errorBox = new ErrorBox();
-        this._stack.add_named(this._errorBox.widget, 'error');
-
         Application.modeController.connect('window-mode-changed',
                                            Lang.bind(this, this._onWindowModeChanged));
 
@@ -171,8 +123,6 @@ const Embed = new Lang.Class({
                                            Lang.bind(this, this._onFullscreenChanged));
         Application.trackerController.connect('query-status-changed',
                                               Lang.bind(this, this._onQueryStatusChanged));
-        Application.trackerController.connect('query-error',
-                                              Lang.bind(this, this._onQueryError));
 
         Application.documentManager.connect('active-changed',
                                             Lang.bind(this, this._onActiveItemChanged));
@@ -217,10 +167,6 @@ const Embed = new Lang.Class({
         }
     },
 
-    _onQueryError: function(manager, message, exception) {
-        this._setError(message, exception.message);
-    },
-
     _onFullscreenChanged: function(controller, fullscreen) {
         this._toolbar.widget.visible = !fullscreen;
         this._toolbar.widget.sensitive = !fullscreen;
@@ -298,7 +244,6 @@ const Embed = new Lang.Class({
     _onLoadError: function(manager, doc, message, exception) {
         this._clearLoadTimer();
         this._spinnerBox.stop();
-        this._setError(message, exception.message);
     },
 
     _onPasswordNeeded: function(manager, doc) {
@@ -356,11 +301,6 @@ const Embed = new Lang.Class({
         this._stack.set_visible_child_name('edit');
     },
 
-    _setError: function(primary, secondary) {
-        this._errorBox.update(primary, secondary);
-        this._stack.set_visible_child_name('error');
-    },
-
     getMainToolbar: function() {
         let windowMode = Application.modeController.getWindowMode();
         let fullscreen = Application.modeController.getFullscreen();
diff --git a/src/view.js b/src/view.js
index 8298035..6b7173b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -221,6 +221,51 @@ const EmptyResultsBox = new Lang.Class({
     }
 });
 
+const ErrorBox = new Lang.Class({
+    Name: 'ErrorBox',
+
+    _init: function(primary, secondary) {
+        this.widget = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
+                                     row_spacing: 12,
+                                     hexpand: true,
+                                     vexpand: true,
+                                     halign: Gtk.Align.CENTER,
+                                     valign: Gtk.Align.CENTER });
+
+        this._image = new Gtk.Image({ pixel_size: _ICON_SIZE,
+                                      icon_name: 'face-uncertain-symbolic',
+                                      halign: Gtk.Align.CENTER,
+                                      valign: Gtk.Align.CENTER });
+
+        this.widget.add(this._image);
+
+        this._primaryLabel =
+            new Gtk.Label({ label: '',
+                            use_markup: true,
+                            halign: Gtk.Align.CENTER,
+                            valign: Gtk.Align.CENTER });
+        this.widget.add(this._primaryLabel);
+
+        this._secondaryLabel =
+            new Gtk.Label({ label: '',
+                            use_markup: true,
+                            wrap: true,
+                            halign: Gtk.Align.CENTER,
+                            valign: Gtk.Align.CENTER });
+        this.widget.add(this._secondaryLabel);
+
+        this.widget.show_all();
+    },
+
+    update: function(primary, secondary) {
+        let primaryMarkup = '<big><b>' + GLib.markup_escape_text(primary, -1) + '</b></big>';
+        let secondaryMarkup = GLib.markup_escape_text(secondary, -1);
+
+        this._primaryLabel.label = primaryMarkup;
+        this._secondaryLabel.label = secondaryMarkup;
+    }
+});
+
 const ViewContainer = new Lang.Class({
     Name: 'ViewContainer',
 
@@ -238,6 +283,9 @@ const ViewContainer = new Lang.Class({
         this._noResults = new EmptyResultsBox();
         this.widget.add_named(this._noResults.widget, 'no-results');
 
+        this._errorBox = new ErrorBox();
+        this.widget.add_named(this._errorBox.widget, 'error');
+
         this.view = new Gd.MainView({ shadow_type: Gtk.ShadowType.NONE });
         grid.add(this.view);
 
@@ -285,6 +333,8 @@ const ViewContainer = new Lang.Class({
                     this.widget.set_visible_child_name('view');
             }));
 
+        Application.trackerController.connect('query-error',
+            Lang.bind(this, this._onQueryError));
         this._queryId = Application.trackerController.connect('query-status-changed',
             Lang.bind(this, this._onQueryStatusChanged));
         // ensure the tracker controller is started
@@ -399,6 +449,10 @@ const ViewContainer = new Lang.Class({
         Application.documentManager.setActiveItemById(id);
     },
 
+    _onQueryError: function(manager, message, exception) {
+        this._setError(message, exception.message);
+    },
+
     _onQueryStatusChanged: function() {
         let status = Application.trackerController.getQueryStatus();
 
@@ -419,6 +473,11 @@ const ViewContainer = new Lang.Class({
         }
     },
 
+    _setError: function(primary, secondary) {
+        this._errorBox.update(primary, secondary);
+        this.widget.set_visible_child_name('error');
+    },
+
     _updateSelection: function() {
         let selected = Application.selectionController.getSelection();
         let newSelection = [];


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