[gnome-documents] preview: Use inheritance instead of composition
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview: Use inheritance instead of composition
- Date: Tue, 28 Jul 2015 08:27:44 +0000 (UTC)
commit 38891404bdc1810763bb8e5cbaddd70fad748547
Author: Alessandro Bono <shadow openaliasbox org>
Date: Sat Jul 25 17:45:18 2015 +0200
preview: Use inheritance instead of composition
https://bugzilla.gnome.org/show_bug.cgi?id=752792
src/embed.js | 4 ++--
src/preview.js | 19 ++++++++++---------
2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index f914898..acd368d 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -117,7 +117,7 @@ const Embed = new Lang.Class({
this._stack.add_named(this._search.widget, 'search');
this._preview = new Preview.PreviewView(this._stackOverlay);
- this._stack.add_named(this._preview.widget, 'preview');
+ this._stack.add_named(this._preview, 'preview');
this._edit = new Edit.EditView(this._stackOverlay);
this._stack.add_named(this._edit.widget, 'edit');
@@ -373,7 +373,7 @@ const Embed = new Lang.Class({
docModel.set_page_layout(EvView.PageLayout.AUTOMATIC);
this._toolbar.setModel(docModel);
this._preview.setModel(docModel);
- this._preview.widget.grab_focus();
+ this._preview.grab_focus();
this._clearLoadTimer();
this._spinnerBox.stop();
diff --git a/src/preview.js b/src/preview.js
index 20b5219..06aa4b2 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -48,6 +48,7 @@ const _FULLSCREEN_TOOLBAR_TIMEOUT = 2; // seconds
const PreviewView = new Lang.Class({
Name: 'PreviewView',
+ Extends: Gtk.Stack,
_init: function(overlay) {
this._model = null;
@@ -66,11 +67,11 @@ const PreviewView = new Lang.Class({
Application.modeController.connect('window-mode-changed', Lang.bind(this,
this._onWindowModeChanged));
- this.widget = new Gtk.Stack({ homogeneous: true,
- transition_type: Gtk.StackTransitionType.CROSSFADE });
+ this.parent({ homogeneous: true,
+ transition_type: Gtk.StackTransitionType.CROSSFADE });
this._errorBox = new ErrorBox.ErrorBox();
- this.widget.add_named(this._errorBox, 'error');
+ this.add_named(this._errorBox, 'error');
this._sw = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true });
@@ -79,7 +80,7 @@ const PreviewView = new Lang.Class({
this._sw.get_vscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
this._sw.get_hadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
this._sw.get_vadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
- this.widget.add_named(this._sw, 'view');
+ this.add_named(this._sw, 'view');
this._createView();
@@ -88,7 +89,7 @@ const PreviewView = new Lang.Class({
this._previewContextMenu = Gtk.Menu.new_from_model(model);
this._previewContextMenu.attach_to_widget(this._sw, null);
- this.widget.show_all();
+ this.show_all();
this._bookmarkPage = Application.application.lookup_action('bookmark-page');
this._bookmarkPage.enabled = false;
@@ -151,7 +152,7 @@ const PreviewView = new Lang.Class({
Application.documentManager.connect('load-error',
Lang.bind(this, this._onLoadError));
- this.widget.connect('destroy', Lang.bind(this,
+ this.connect('destroy', Lang.bind(this,
function() {
this._bookmarkPage.disconnect(bookmarkPageId);
this._zoomIn.disconnect(zoomInId);
@@ -217,7 +218,7 @@ const PreviewView = new Lang.Class({
_setError: function(primary, secondary) {
this._errorBox.update(primary, secondary);
- this.widget.set_visible_child_name('error');
+ this.set_visible_child_name('error');
},
_showPlaces: function() {
@@ -361,7 +362,7 @@ const PreviewView = new Lang.Class({
this._handleExternalLink));
this._navControls = new PreviewNavControls(this, this._overlay);
- this.widget.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
+ this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
},
_getPreviewContextMenu: function() {
@@ -566,7 +567,7 @@ const PreviewView = new Lang.Class({
this._updateNightMode();
- this.widget.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
+ this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]