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



commit 85731f7bd7d397c734a3cefdd28c5c29d83a05e5
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.
    
    NB: we lost the ability to handle load-error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686461

 src/embed.js |   60 ---------------------------------------------------------
 src/view.js  |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 60 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 8d95ea7..41aa8c4 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;
@@ -294,7 +240,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) {
@@ -352,11 +297,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..faacaab 100644
--- a/src/view.js
+++ b/src/view.js
@@ -221,6 +221,53 @@ const EmptyResultsBox = new Lang.Class({
     }
 });
 
+const _ICON_SIZE = 128;
+
+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 +285,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 +335,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 +451,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 +475,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]