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



commit 7a721baa6d91cbdf89d83607de74f919755dc49f
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Sat Jul 25 15:30:36 2015 +0200

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

 src/places.js  |   33 +++++++++++++++++----------------
 src/preview.js |    2 +-
 2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/places.js b/src/places.js
index 97732a4..c775b12 100644
--- a/src/places.js
+++ b/src/places.js
@@ -34,27 +34,28 @@ const Lang = imports.lang;
 
 const PlacesDialog = new Lang.Class({
     Name: 'PlacesDialog',
+    Extends: Gtk.Dialog,
 
     _init: function(model, bookmarks) {
+        let toplevel = Application.application.get_windows()[0];
+        this.parent({ resizable: true,
+                      transient_for: toplevel,
+                      modal: true,
+                      destroy_with_parent: true,
+                      use_header_bar: true,
+                      default_width: 600, // FIXME use toplevel size
+                      default_height: 600,
+                      title: "",
+                      hexpand: true });
+
         this._model = model;
         this._bookmarks = bookmarks;
         this._createWindow();
-        this.widget.show_all();
+        this.show_all();
     },
 
     _createWindow: function() {
-        let toplevel = Application.application.get_windows()[0];
-        this.widget = new Gtk.Dialog ({ resizable: true,
-                                        transient_for: toplevel,
-                                        modal: true,
-                                        destroy_with_parent: true,
-                                        use_header_bar: true,
-                                        default_width: 600, // FIXME use toplevel size
-                                        default_height: 600,
-                                        title: "",
-                                        hexpand: true });
-
-        let contentArea = this.widget.get_content_area();
+        let contentArea = this.get_content_area();
         this._stack = new Gtk.Stack({ border_width: 5,
                                       homogeneous: true });
         contentArea.pack_start(this._stack, true, true, 0);
@@ -89,7 +90,7 @@ const PlacesDialog = new Lang.Class({
         }
 
         let pages = this._stack.get_children();
-        let header = this.widget.get_header_bar();
+        let header = this.get_header_bar();
 
         if (pages.length == 1) {
             header.set_title(pages[0].name);
@@ -103,12 +104,12 @@ const PlacesDialog = new Lang.Class({
         if (link.action.type == EvDocument.LinkActionType.GOTO_DEST) {
             this._gotoDest(link.action.dest);
         }
-        this.widget.response(Gtk.ResponseType.DELETE_EVENT);
+        this.response(Gtk.ResponseType.DELETE_EVENT);
     },
 
     _handleBookmark: function(bookmark) {
         this._model.set_page(bookmark.page_number);
-        this.widget.response(Gtk.ResponseType.DELETE_EVENT);
+        this.response(Gtk.ResponseType.DELETE_EVENT);
     },
 
     _gotoDest: function(dest) {
diff --git a/src/preview.js b/src/preview.js
index c12bae5..594605c 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -222,7 +222,7 @@ const PreviewView = new Lang.Class({
 
     _showPlaces: function() {
         let dialog = new Places.PlacesDialog(this._model, this._bookmarks);
-        dialog.widget.connect('response', Lang.bind(this,
+        dialog.connect('response', Lang.bind(this,
             function(widget, response) {
                 widget.destroy();
             }));


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