[polari/wip/fmuellner/connection-list: 8/8] connections: Hide server settings for predefined networks



commit 5af31cee12d30fcc257a32fe334c7ac66d4cb08c
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 4 06:45:48 2016 +0100

    connections: Hide server settings for predefined networks
    
    The whole point of providing a list of networks is so users needn't
    bother with server addresses and ports. In addition, exposing those
    settings blurs the line between predefined and custom connections,
    which is problematic for features like using encrypted connections
    where possible.
    
    So just hide server settings for accounts created from a predefined
    network - in the end, users who are unhappy with the picks we make
    can still use a custom connection.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761859

 data/resources/connection-details.ui |   20 ++++++++++++++------
 src/connections.js                   |   15 ++++++++++++++-
 2 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/data/resources/connection-details.ui b/data/resources/connection-details.ui
index d31ef2e..dbc0233 100644
--- a/data/resources/connection-details.ui
+++ b/data/resources/connection-details.ui
@@ -6,7 +6,9 @@
     <property name="column-spacing">12</property>
     <child>
       <object class="GtkLabel" id="name_label">
-        <property name="visible">True</property>
+        <property name="visible" bind-source="Gjs_ConnectionDetails"
+                  bind-property="has-service"
+                  bind-flags="invert-boolean|sync-create"/>
         <property name="halign">end</property>
         <property name="label" translatable="yes">_Name</property>
         <property name="use-underline">True</property>
@@ -15,7 +17,9 @@
     </child>
     <child>
       <object class="GtkEntry" id="nameEntry">
-        <property name="visible">True</property>
+        <property name="visible" bind-source="Gjs_ConnectionDetails"
+                  bind-property="has-service"
+                  bind-flags="invert-boolean|sync-create"/>
         <property name="hexpand">True</property>
         <property name="activates-default">True</property>
         <property name="placeholder-text" translatable="yes">optional</property>
@@ -23,8 +27,11 @@
     </child>
     <child>
       <object class="GtkLabel" id="server_label">
-        <property name="visible">True</property>
+        <property name="visible" bind-source="Gjs_ConnectionDetails"
+                  bind-property="has-service"
+                  bind-flags="invert-boolean|sync-create"/>
         <property name="halign">end</property>
+        <property name="margin-bottom">24</property>
         <property name="label" translatable="yes">_Server</property>
         <property name="use-underline">True</property>
         <property name="mnemonic-widget">serverEntry</property>
@@ -36,8 +43,11 @@
     </child>
     <child>
       <object class="GtkEntry" id="serverEntry">
-        <property name="visible">True</property>
+        <property name="visible" bind-source="Gjs_ConnectionDetails"
+                  bind-property="has-service"
+                  bind-flags="invert-boolean|sync-create"/>
         <property name="hexpand">True</property>
+        <property name="margin-bottom">24</property>
         <property name="activates-default">True</property>
       </object>
       <packing>
@@ -49,7 +59,6 @@
       <object class="GtkLabel" id="nickname_label">
         <property name="visible">True</property>
         <property name="halign">end</property>
-        <property name="margin-top">24</property>
         <property name="label" translatable="yes">_Nickname</property>
         <property name="use-underline">True</property>
         <property name="mnemonic-widget">nickEntry</property>
@@ -64,7 +73,6 @@
         <property name="visible">True</property>
         <property name="hexpand">True</property>
         <property name="can-default">True</property>
-        <property name="margin-top">24</property>
         <property name="activates-default">True</property>
       </object>
       <packing>
diff --git a/src/connections.js b/src/connections.js
index ff532f6..38431dc 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -179,6 +179,11 @@ const ConnectionDetails = new Lang.Class({
                                                            'can-confirm',
                                                            'can-confirm',
                                                            GObject.ParamFlags.READABLE,
+                                                           false),
+                  'has-serivce': GObject.ParamSpec.boolean('has-service',
+                                                           'has-service',
+                                                           'has-service',
+                                                           GObject.ParamFlags.READABLE,
                                                            false)},
     Signals: { 'account-created': { param_types: [Tp.Account.$gtype] }},
 
@@ -242,7 +247,10 @@ const ConnectionDetails = new Lang.Class({
         this._nickEntry.text = GLib.get_user_name();
         this._realnameEntry.text = '';
 
-        this._serverEntry.grab_focus();
+        if (this._serverEntry.visible)
+            this._serverEntry.grab_focus();
+        else
+            this._nickEntry.grab_focus();
     },
 
     _onCanConfirmChanged: function() {
@@ -275,8 +283,13 @@ const ConnectionDetails = new Lang.Class({
                this._nickEntry.get_text_length() > 0;
     },
 
+    get has_service() {
+        return NetworksManager.getDefault().getAccountIsPredefined(this._account);
+    },
+
     set account(account) {
         this._account = account;
+        this.notify('has-service');
 
         this.reset();
         if (this._account)


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