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



commit 39f8ca868413179719c588168fb0fb248fedc552
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Sat Jul 25 18:10:36 2015 +0200

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

 src/selections.js |    4 ++--
 src/sharing.js    |   27 ++++++++++++++-------------
 2 files changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/src/selections.js b/src/selections.js
index 675d748..64da3d6 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -937,9 +937,9 @@ const SelectionToolbar = new Lang.Class({
    _onToolbarShare: function(widget) {
        let dialog = new Sharing.SharingDialog();
 
-       dialog.widget.connect('response', Lang.bind(this,
+       dialog.connect('response', Lang.bind(this,
            function(widget, response) {
-               dialog.widget.destroy();
+               dialog.destroy();
                Application.selectionController.setSelectionMode(false);
            }));
     },
diff --git a/src/sharing.js b/src/sharing.js
index b4e57bf..22f371f 100644
--- a/src/sharing.js
+++ b/src/sharing.js
@@ -70,6 +70,7 @@ const DocumentUpdateType = {
 
 const SharingDialog = new Lang.Class({
     Name: 'SharingDialog',
+    Extends: Gtk.Dialog,
 
     _init: function() {
         let urn = Application.selectionController.getSelection();
@@ -97,25 +98,25 @@ const SharingDialog = new Lang.Class({
         this._changePermissionVisible = false;
 
         let toplevel = Application.application.get_windows()[0];
-        this.widget = new Gtk.Dialog({ resizable: false,
-                                       transient_for: toplevel,
-                                       modal: true,
-                                       destroy_with_parent: true,
-                                       use_header_bar: true,
-                                       width_request: 335,
-                                       margin_top: 5,
-                                       title: _("Sharing Settings"),
-                                       hexpand: true });
+        this.parent({ resizable: false,
+                      transient_for: toplevel,
+                      modal: true,
+                      destroy_with_parent: true,
+                      use_header_bar: true,
+                      width_request: 335,
+                      margin_top: 5,
+                      title: _("Sharing Settings"),
+                      hexpand: true });
 
         // Label for Done button in Sharing dialog
-        this.widget.add_button(_("Done"), Gtk.ResponseType.CLOSE);
+        this.add_button(_("Done"), Gtk.ResponseType.CLOSE);
 
         let mainGrid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
                                       column_spacing: 6,
                                       row_spacing: 6,
                                       margin_start: 12,
                                       margin_end: 12 });
-        let contentArea = this.widget.get_content_area();
+        let contentArea = this.get_content_area();
         contentArea.pack_start(mainGrid, true, true, 0);
 
         this._scrolledWin = new Gtk.ScrolledWindow({ shadow_type: Gtk.ShadowType.IN,
@@ -234,7 +235,7 @@ const SharingDialog = new Lang.Class({
         this._grid.add(this._noPermission);
         this._grid.child_set_property(this._noPermission, 'width', 3);
 
-        this.widget.show_all();
+        this.show_all();
         this._updatePermissionButtons();
     },
 
@@ -612,7 +613,7 @@ const SharingDialog = new Lang.Class({
     },
 
     _showErrorDialog: function(errorStr) {
-        let errorDialog = new Gtk.MessageDialog ({ transient_for: this.widget,
+        let errorDialog = new Gtk.MessageDialog ({ transient_for: this,
                                                    modal: true,
                                                    destroy_with_parent: true,
                                                    buttons: Gtk.ButtonsType.OK,


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