[gnome-documents] view, errorBox: Split ErrorBox into its own file



commit 08c8fda12932050f5d99753ebcf2fa868257c813
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 6 15:24:23 2015 +0100

    view, errorBox: Split ErrorBox into its own file
    
    We also need it in PreviewView to handle load-error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745172

 src/Makefile-js.am |    1 +
 src/errorBox.js    |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/view.js        |   50 +----------------------------------
 3 files changed, 75 insertions(+), 48 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 88cf7a1..7e1ef60 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -5,6 +5,7 @@ dist_js_DATA = \
     documents.js \
     edit.js \
     embed.js \
+    errorBox.js \
     main.js \
     mainBooks.js \
     mainToolbar.js \
diff --git a/src/errorBox.js b/src/errorBox.js
new file mode 100644
index 0000000..23e4f89
--- /dev/null
+++ b/src/errorBox.js
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015 Red Hat, Inc.
+ *
+ * Gnome Documents is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+
+const Lang = imports.lang;
+
+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;
+    }
+});
diff --git a/src/view.js b/src/view.js
index 8bb45b5..1e46f7b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -33,6 +33,7 @@ const Mainloop = imports.mainloop;
 
 const Application = imports.application;
 const Documents = imports.documents;
+const ErrorBox = imports.errorBox;
 const TrackerUtils = imports.trackerUtils;
 const WindowMode = imports.windowMode;
 const Utils = imports.utils;
@@ -302,53 +303,6 @@ 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',
 
@@ -367,7 +321,7 @@ const ViewContainer = new Lang.Class({
         this._noResults = new EmptyResultsBox();
         this.widget.add_named(this._noResults.widget, 'no-results');
 
-        this._errorBox = new ErrorBox();
+        this._errorBox = new ErrorBox.ErrorBox();
         this.widget.add_named(this._errorBox.widget, 'error');
 
         this.view = new Gd.MainView({ shadow_type: Gtk.ShadowType.NONE });


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