[polari] connections: Hide server settings for predefined networks
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] connections: Hide server settings for predefined networks
- Date: Thu, 18 Feb 2016 00:16:17 +0000 (UTC)
commit b1eec99d3e1ec3d54c4575d9523bfb2aa2a1f73b
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 | 32 +++++++++++++++++++++++++++++++-
2 files changed, 45 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 78a723e..eaeda41 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -179,10 +179,21 @@ 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] }},
_init: function(params) {
+ this._networksManager = NetworksManager.getDefault();
+ this._networksManager.connect('changed', Lang.bind(this,
+ function() {
+ this.notify('has-service');
+ }));
+
this.parent(params);
this._nameEntry.connect('changed',
@@ -251,7 +262,10 @@ const ConnectionDetails = new Lang.Class({
this._nickEntry.text = this._savedNick;
this._realnameEntry.text = this._savedRealname;
- this._serverEntry.grab_focus();
+ if (this._serverEntry.visible)
+ this._serverEntry.grab_focus();
+ else
+ this._nickEntry.grab_focus();
},
_onCanConfirmChanged: function() {
@@ -291,8 +305,13 @@ const ConnectionDetails = new Lang.Class({
paramsChanged;
},
+ get has_service() {
+ return this._networksManager.getAccountIsPredefined(this._account);
+ },
+
set account(account) {
this._account = account;
+ this.notify('has-service');
this.reset();
if (this._account)
@@ -384,6 +403,17 @@ const ConnectionProperties = new Lang.Class({
this._details.account = account;
+ this._details.connect('notify::has-service', Lang.bind(this,
+ function() {
+ /* HACK:
+ * Shrink back to minimum height when the visibility of
+ * some elements in Details could have changed; this
+ * assumes that this only happens before the user could
+ * resize the dialog herself
+ */
+ this.resize(this.default_width, 1);
+ }));
+
this.connect('response', Lang.bind(this,
function(w, response) {
if (response == Gtk.ResponseType.OK)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]