[polari] connection: Use inheritance instead of delegation



commit 16f41758732f5973ffdf6fee461436707bb5c071
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Feb 6 21:59:50 2016 +0100

    connection: Use inheritance instead of delegation
    
    We used to use delegation almost exclusively, but since we started to apply
    templates, inheritance has been creeping in more and more. By now, from all
    our classes that provide a UI, about half inherit from Gtk.Widget while the
    other half uses a .widget delegate. The resulting inconsistency is getting
    rather annoying, so say good-bye to delegation and embrace inheritance ...

 src/application.js |    6 +++---
 src/connections.js |   22 +++++++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index b315535..0b0e929 100644
--- a/src/application.js
+++ b/src/application.js
@@ -445,12 +445,12 @@ const Application = new Lang.Class({
         let factory = Tp.AccountManager.dup().get_factory();
         let account = factory.ensure_account(accountPath, []);
         let dialog = new Connections.ConnectionDetailsDialog(account);
-        dialog.widget.transient_for = this._window.window;
-        dialog.widget.connect('response', Lang.bind(this,
+        dialog.transient_for = this._window.window;
+        dialog.connect('response', Lang.bind(this,
             function(w, response) {
                 w.destroy();
             }));
-        dialog.widget.show();
+        dialog.show();
     },
 
     _onShowPreferences: function() {
diff --git a/src/connections.js b/src/connections.js
index 4394fce..d466c48 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -205,32 +205,32 @@ const ConnectionDetails = new Lang.Class({
 
 const ConnectionDetailsDialog = new Lang.Class({
     Name: 'ConnectionDetailsDialog',
+    Extends: Gtk.Dialog,
 
     _init: function(account) {
-        this.widget = new Gtk.Dialog({ title: _("Edit Connection"),
-                                       modal: true,
-                                       destroy_with_parent: true,
-                                       use_header_bar: true });
+        this.parent({ title: _("Edit Connection"),
+                      modal: true,
+                      destroy_with_parent: true,
+                      use_header_bar: 1 });
 
-        this.widget.get_content_area().border_width = 0;
+        this.get_content_area().border_width = 0;
 
-        this.widget.connect('response', Lang.bind(this,
+        this.connect('response', Lang.bind(this,
             function(w, response) {
                 if (response == Gtk.ResponseType.OK)
                     this._details.save();
             }));
 
-        this.widget.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL);
+        this.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL);
 
-        this._confirmButton = this.widget.add_button(_("A_pply"),
-                                                     Gtk.ResponseType.OK);
+        this._confirmButton = this.add_button(_("A_pply"), Gtk.ResponseType.OK);
         this._confirmButton.get_style_context().add_class('suggested-action');
 
         this._details = new ConnectionDetails({ account: account });
         this._details.bind_property('can-confirm',
                                     this._confirmButton, 'sensitive',
                                     GObject.BindingFlags.SYNC_CREATE);
-        this.widget.get_content_area().add(this._details);
-        this.widget.set_default_response(Gtk.ResponseType.OK);
+        this.get_content_area().add(this._details);
+        this.set_default_response(Gtk.ResponseType.OK);
     }
 });


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