[polari] joinDialog: Select newly-created accounts



commit 6f276e32719ba0b04b9996e983b450dbe5fcdc09
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Oct 16 17:20:39 2015 +0200

    joinDialog: Select newly-created accounts
    
    If the user creates a new connection from the join dialog, it's safe
    to assume that she intends to join a room on that server.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756702

 src/connections.js |    5 ++++-
 src/joinDialog.js  |    6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 33a5f95..81515fb 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -191,6 +191,7 @@ const ConnectionDetails = new Lang.Class({
                                                            'can-confirm',
                                                            GObject.ParamFlags.READABLE,
                                                            false)},
+    Signals: { 'account-created': { param_types: [Tp.Account.$gtype] }},
 
     _init: function(params) {
         if (params) {
@@ -328,7 +329,9 @@ const ConnectionDetails = new Lang.Class({
 
         req.create_account_async(Lang.bind(this,
             function(r, res) {
-                req.create_account_finish(res); // TODO: Check for errors
+                let account = req.create_account_finish(res);
+                if (account) // TODO: Handle errors
+                    this.emit('account-created', account);
             }));
     },
 
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 33865cd..30ac420 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -77,6 +77,10 @@ const JoinDialog = new Lang.Class({
         this._stack.add_named(this._details, 'connection');
         this._details.connect('notify::can-confirm',
                               Lang.bind(this, this._updateCanConfirm));
+        this._details.connect('account-created', Lang.bind(this,
+            function(details, account) {
+                this._connectionCombo.set_active_id(account.display_name);
+            }));
 
         this._connectionButton = builder.get_object('add_connection_button');
         this._connectionButton.connect('clicked', Lang.bind(this,
@@ -175,7 +179,7 @@ const JoinDialog = new Lang.Class({
                 return (a < b) ? -1 : ((a > b) ? 1 : 0);
             });
         for (let i = 0; i < names.length; i++)
-            this._connectionCombo.append_text(names[i]);
+            this._connectionCombo.append(names[i], names[i]);
         this._connectionCombo.sensitive = names.length > 1;
 
         let activeRoom = this._roomManager.getActiveRoom();


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