[gnome-documents/wip/lokdocview-rebase: 5/24] Add an error view to the LOKview stack



commit 2c9ea763cba2023b7bf5b23c3104b001b1fc6b9a
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Dec 4 18:02:24 2015 +0100

    Add an error view to the LOKview stack

 src/lokview.js |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/lokview.js b/src/lokview.js
index a9bba2a..99a6b09 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -35,6 +35,7 @@ const Signals = imports.signals;
 const Tweener = imports.tweener.tweener;
 
 const Application = imports.application;
+const ErrorBox = imports.errorBox;
 const MainToolbar = imports.mainToolbar;
 const Searchbar = imports.searchbar;
 const Utils = imports.utils;
@@ -45,25 +46,33 @@ const Documents = imports.documents;
 // FIXME: https://bugs.documentfoundation.org/show_bug.cgi?id=96247
 const LO_PATH = '/usr/lib64/libreoffice/program'
 
+function isAvailable() {
+    return (LOKDocView != undefined);
+}
+
 const LOKView = new Lang.Class({
     Name: 'LOKView',
-    Extends: Gtk.Overlay,
-
-    _init: function() {
-        this._uri = null;
+    Extends: Gtk.Stack,
 
+    _init: function(overlay) {
         this.parent();
+
+        this._uri = null;
+        this._overlay = overlay;
         this.get_style_context().add_class('documents-scrolledwin');
 
+        this._errorBox = new ErrorBox.ErrorBox();
+        this.add_named(this._errorBox, 'error');
+
         this._sw = new Gtk.ScrolledWindow({hexpand: true,
                                            vexpand: true});
 
         this._progressBar = new Gtk.ProgressBar({ halign: Gtk.Align.FILL,
                                                   valign: Gtk.Align.START });
         this._progressBar.get_style_context().add_class('osd');
-        this.add_overlay(this._progressBar);
+        this._overlay.add_overlay(this._progressBar);
 
-        this.add(this._sw);
+        this.add_named(this._sw, 'view');
         this._createView();
 
         this.show_all();
@@ -108,6 +117,7 @@ const LOKView = new Lang.Class({
             this.hasParts = false;
 
         this._progressBar.hide();
+        this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
         this.view.show();
     },
 
@@ -129,7 +139,8 @@ const LOKView = new Lang.Class({
         this._sw.add(this.view);
         this.view.connect('load-changed', Lang.bind(this, this._onProgressChanged));
 
-        this._navControls = new LOKViewNavControls(this, this);
+        this._navControls = new LOKViewNavControls(this, this._overlay);
+        this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
     },
 
     _onProgressChanged: function() {


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