[gnome-documents] errorBox: Use inheritance instead of composition



commit fad6d6387a351c160d10fc9fecb078321f6bf092
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Sat Jul 25 14:11:43 2015 +0200

    errorBox: Use inheritance instead of composition
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752792

 src/errorBox.js |   21 +++++++++++----------
 src/preview.js  |    2 +-
 src/view.js     |    2 +-
 3 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/errorBox.js b/src/errorBox.js
index 23e4f89..95ec791 100644
--- a/src/errorBox.js
+++ b/src/errorBox.js
@@ -28,28 +28,29 @@ const _ICON_SIZE = 128;
 
 const ErrorBox = new Lang.Class({
     Name: 'ErrorBox',
+    Extends: Gtk.Grid,
 
     _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.parent({ 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.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.add(this._primaryLabel);
 
         this._secondaryLabel =
             new Gtk.Label({ label: '',
@@ -57,9 +58,9 @@ const ErrorBox = new Lang.Class({
                             wrap: true,
                             halign: Gtk.Align.CENTER,
                             valign: Gtk.Align.CENTER });
-        this.widget.add(this._secondaryLabel);
+        this.add(this._secondaryLabel);
 
-        this.widget.show_all();
+        this.show_all();
     },
 
     update: function(primary, secondary) {
diff --git a/src/preview.js b/src/preview.js
index 0c2e05c..b2fcc72 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -70,7 +70,7 @@ const PreviewView = new Lang.Class({
                                       transition_type: Gtk.StackTransitionType.CROSSFADE });
 
         this._errorBox = new ErrorBox.ErrorBox();
-        this.widget.add_named(this._errorBox.widget, 'error');
+        this.widget.add_named(this._errorBox, 'error');
 
         this._sw = new Gtk.ScrolledWindow({ hexpand: true,
                                             vexpand: true });
diff --git a/src/view.js b/src/view.js
index cacc060..e5d2f0e 100644
--- a/src/view.js
+++ b/src/view.js
@@ -328,7 +328,7 @@ const ViewContainer = new Lang.Class({
         this.widget.add_named(this._noResults.widget, 'no-results');
 
         this._errorBox = new ErrorBox.ErrorBox();
-        this.widget.add_named(this._errorBox.widget, 'error');
+        this.widget.add_named(this._errorBox, 'error');
 
         this.view = new Gd.MainView({ shadow_type: Gtk.ShadowType.NONE });
         grid.add(this.view);


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