[gnome-documents/wip/rishi/split-view: 7/11] embed, view: Move the error page into the ViewContainer
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/rishi/split-view: 7/11] embed, view: Move the error page into the ViewContainer
- Date: Thu, 19 Feb 2015 18:10:36 +0000 (UTC)
commit cb54c68750887903633c8a41ff6f92f7867a7a16
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 b20f732..628e74b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -226,6 +226,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',
@@ -243,6 +290,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);
@@ -290,6 +340,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
@@ -404,6 +456,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();
@@ -424,6 +480,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]