[polari/wip/dmoelgaard/initial-setup] initSetup: Reuse ConnectionsList



commit 65a5bd36d08046e2f082d55aecef0e2b9d8ad24d
Author: Bastian Ilsø <bastianilso gnome org>
Date:   Wed Aug 2 01:22:11 2017 +0100

    initSetup: Reuse ConnectionsList

 data/resources/init-setup.ui |    5 ++-
 src/initSetup.js             |   86 ------------------------------------------
 2 files changed, 4 insertions(+), 87 deletions(-)
---
diff --git a/data/resources/init-setup.ui b/data/resources/init-setup.ui
index 497d858..ca5a4d6 100644
--- a/data/resources/init-setup.ui
+++ b/data/resources/init-setup.ui
@@ -135,8 +135,11 @@
               </object>
             </child>
             <child>
-              <object class="Gjs_InitSetupConnectionsList" id="connectionPageList">
+              <object class="Gjs_ConnectionsList" id="connectionPageList">
                 <property name="visible">True</property>
+                <property name="vscrollbar-policy">never</property>
+                <property name="shadow-type">in</property>
+                <property name="favorites-only">True</property>
               </object>
             </child>
           </object>
diff --git a/src/initSetup.js b/src/initSetup.js
index aa3cf49..6cfadc0 100644
--- a/src/initSetup.js
+++ b/src/initSetup.js
@@ -124,89 +124,3 @@ var InitSetup = new Lang.Class({
     }
 
 });
-
-const InitSetupConnectionsList = new Lang.Class({
-    Name: 'InitSetupConnectionsList',
-    Extends: Gtk.Frame,
-    Signals: { 'account-created': { param_types: [Tp.Account.$gtype] } },
-
-    _init: function(params) {
-        this.parent(params);
-
-        this._list = new Gtk.ListBox({ visible: true });
-        this._list.connect('row-activated',
-                           Lang.bind(this, this._onRowActivated));
-        this.add(this._list);
-
-        this._rows = new Map();
-
-        this._list.set_header_func(Lang.bind(this, this._updateHeader));
-
-        this._networksManager = NetworksManager.getDefault();
-        this._networksChanged();
-    },
-
-    _updateHeader: function(row, before) {
-        if (!before)
-            row.set_header(null);
-        else if (!row.get_header())
-            row.set_header(new Gtk.Separator());
-    },
-
-    _networksChanged: function() {
-        for (let network of this._networksManager.favoriteNetworks) {
-            this._rows.set(network.id,
-                           new InitSetupConnectionRow({ id: network.id }));
-            this._list.add(this._rows.get(network.id));
-        }
-    },
-
-    _onRowActivated: function(list, row) {
-        let name = this._networksManager.getNetworkName(row.id);
-        let req = new Tp.AccountRequest({ account_manager: Tp.AccountManager.dup(),
-                                          connection_manager: 'idle',
-                                          protocol: 'irc',
-                                          display_name: name });
-        req.set_service(row.id);
-        req.set_enabled(true);
-
-        let details = this._networksManager.getNetworkDetails(row.id);
-
-        for (let prop in details)
-            req.set_parameter(prop, details[prop]);
-
-        req.create_account_async(Lang.bind(this,
-            function(r, res) {
-                let account = req.create_account_finish(res);
-                this.emit('account-created', account);
-            }));
-    }
-});
-
-const InitSetupConnectionRow = new Lang.Class({
-    Name: 'InitSetupConnectionRow',
-    Extends: Gtk.ListBoxRow,
-
-    _init: function(params) {
-        if (!params || !params.id)
-            throw new Error('No id in parameters');
-
-        this._id = params.id;
-        delete params.id;
-
-        this.parent(params);
-
-        let box = new Gtk.Box({ spacing: 12, margin: 12 });
-        this.add(box);
-
-        let name = NetworksManager.getDefault().getNetworkName(this._id);
-        box.add(new Gtk.Label({ label: name, halign: Gtk.Align.START }));
-
-        this.show_all();
-    },
-
-    get id() {
-        return this._id;
-    }
-
-});


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