[polari/wip/fmuellner/connection-list: 1/8] connections: Set ConnectionDetails account after creation
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/connection-list: 1/8] connections: Set ConnectionDetails account after creation
- Date: Thu, 11 Feb 2016 12:58:09 +0000 (UTC)
commit 6488a4829a46da43f7986a22e0b46fe1d3069745
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 3 23:10:27 2016 +0100
connections: Set ConnectionDetails account after creation
Not having to pass the account at construction time makes it possible to
use ConnectionDetails directly in .ui files.
https://bugzilla.gnome.org/show_bug.cgi?id=761859
src/connections.js | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 952d7d1..bcc6198 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -25,11 +25,6 @@ const ConnectionDetails = new Lang.Class({
Signals: { 'account-created': { param_types: [Tp.Account.$gtype] }},
_init: function(params) {
- if (params) {
- this._account = params.account;
- delete params.account;
- }
-
this.parent(params);
this._serverEntry.connect('changed',
@@ -48,14 +43,6 @@ const ConnectionDetails = new Lang.Class({
this._realnameEntry.set_completion(completion);
this.reset();
-
- if (!this._account)
- return;
-
- this._populateFromAccount(this._account);
-
- this._account.connect('notify::connection-status', Lang.bind(this, this._syncErrorMessage));
- this._syncErrorMessage();
},
_syncErrorMessage: function() {
@@ -136,6 +123,25 @@ const ConnectionDetails = new Lang.Class({
this._nickEntry.get_text_length() > 0;
},
+ set account(account) {
+ if (this._connectionStatusChangedId)
+ this._account.disconnect(this._connectionStatusChangedId);
+ this._connectionStatusChangedId = 0;
+
+ this._account = account;
+
+ this.reset();
+
+ if (this._account) {
+ this._populateFromAccount(this._account);
+
+ this._connectionStatusChangedId =
+ this._account.connect('notify::connection-status',
+ Lang.bind(this, this._syncErrorMessage));
+ this._syncErrorMessage();
+ }
+ },
+
save: function() {
if (!this.can_confirm)
return;
@@ -231,7 +237,8 @@ const ConnectionProperties = new Lang.Class({
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 = new ConnectionDetails();
+ this._details.account = account;
this._details.bind_property('can-confirm',
this._confirmButton, 'sensitive',
GObject.BindingFlags.SYNC_CREATE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]