[geary/wip/714104-refine-account-dialog] Split out account editor TLS combo into a stand-alone class for reuse
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/714104-refine-account-dialog] Split out account editor TLS combo into a stand-alone class for reuse
- Date: Wed, 12 Sep 2018 11:54:13 +0000 (UTC)
commit df2cd2beff821c56d1cc46b14d1113cd933df81b
Author: Michael Gratton <mike vee net>
Date: Wed Sep 5 23:45:27 2018 +1000
Split out account editor TLS combo into a stand-alone class for reuse
src/client/accounts/accounts-editor-row.vala | 70 ++++++++++++++++++++++
.../accounts/accounts-editor-servers-pane.vala | 45 ++------------
2 files changed, 76 insertions(+), 39 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-row.vala b/src/client/accounts/accounts-editor-row.vala
index 2ec4c2f6..a2653d72 100644
--- a/src/client/accounts/accounts-editor-row.vala
+++ b/src/client/accounts/accounts-editor-row.vala
@@ -189,6 +189,76 @@ private abstract class Accounts.ServiceRow<PaneType,V> : AccountRow<PaneType,V>
}
+internal class Accounts.TlsComboBox : Gtk.ComboBox {
+
+ private const string INSECURE_ICON = "channel-insecure-symbolic";
+ private const string SECURE_ICON = "channel-secure-symbolic";
+
+
+ public string label { get; private set; default = ""; }
+
+
+ public Geary.TlsNegotiationMethod method {
+ get {
+ try {
+ return Geary.TlsNegotiationMethod.for_value(this.active_id);
+ } catch {
+ return Geary.TlsNegotiationMethod.TRANSPORT;
+ }
+ }
+ set {
+ this.active_id = value.to_value();
+ }
+ }
+
+
+ public TlsComboBox() {
+ // Translators: This label describes what form of transport
+ // security (TLS, StartTLS, etc) used by an account's IMAP or SMTP
+ // service.
+ this.label = _("Connection security");
+
+ Gtk.ListStore store = new Gtk.ListStore(
+ 3, typeof(string), typeof(string), typeof(string)
+ );
+ Gtk.TreeIter iter;
+ store.append(out iter);
+ store.set(
+ iter,
+ 0, Geary.TlsNegotiationMethod.NONE.to_value(),
+ 1, INSECURE_ICON,
+ 2, _("None")
+ );
+ store.append(out iter);
+ store.set(
+ iter,
+ 0, Geary.TlsNegotiationMethod.START_TLS.to_value(),
+ 1, SECURE_ICON,
+ 2, _("StartTLS")
+ );
+ store.append(out iter);
+ store.set(
+ iter,
+ 0, Geary.TlsNegotiationMethod.TRANSPORT.to_value(),
+ 1, SECURE_ICON,
+ 2, _("TLS")
+ );
+
+ this.model = store;
+ set_id_column(0);
+
+ Gtk.CellRendererText text_renderer = new Gtk.CellRendererText();
+ pack_start(text_renderer, true);
+ add_attribute(text_renderer, "text", 2);
+
+ Gtk.CellRendererPixbuf icon_renderer = new Gtk.CellRendererPixbuf();
+ pack_start(icon_renderer, true);
+ add_attribute(icon_renderer, "icon_name", 1);
+ }
+
+}
+
+
internal class Accounts.EditorPopover : Gtk.Popover {
diff --git a/src/client/accounts/accounts-editor-servers-pane.vala
b/src/client/accounts/accounts-editor-servers-pane.vala
index aeb9e4fe..8ac599b6 100644
--- a/src/client/accounts/accounts-editor-servers-pane.vala
+++ b/src/client/accounts/accounts-editor-servers-pane.vala
@@ -187,55 +187,22 @@ private class Accounts.ServiceHostRow :
private class Accounts.ServiceSecurityRow :
- ServiceRow<EditorServersPane,Gtk.ComboBoxText> {
-
- private const string INSECURE_ICON = "channel-insecure-symbolic";
- private const string SECURE_ICON = "channel-secure-symbolic";
+ ServiceRow<EditorServersPane,TlsComboBox> {
public ServiceSecurityRow(Geary.AccountInformation account,
Geary.ServiceInformation service) {
- Gtk.ListStore store = new Gtk.ListStore(
- 3, typeof(string), typeof(string), typeof(string)
- );
- Gtk.TreeIter iter;
- store.append(out iter);
- store.set(iter, 0, "none", 1, INSECURE_ICON, 2, _("None"));
- store.append(out iter);
- store.set(iter, 0, "start-tls", 1, SECURE_ICON, 2, _("StartTLS"));
- store.append(out iter);
- store.set(iter, 0, "tls", 1, SECURE_ICON, 2, _("TLS"));
-
- Gtk.ComboBox combo = new Gtk.ComboBox.with_model(store);
- combo.set_id_column(0);
-
- Gtk.CellRendererText text_renderer = new Gtk.CellRendererText();
- combo.pack_start(text_renderer, true);
- combo.add_attribute(text_renderer, "text", 2);
-
- Gtk.CellRendererPixbuf icon_renderer = new Gtk.CellRendererPixbuf();
- combo.pack_start(icon_renderer, true);
- combo.add_attribute(icon_renderer, "icon_name", 1);
-
- base(
- account,
- service,
- // Translators: This label describes what form of secure
- // connection (TLS, StartTLS, etc) used by an account's
- // IMAP or SMTP service.
- _("Transport security"),
- combo
- );
-
+ TlsComboBox value = new TlsComboBox();
+ base(account, service, value.label, value);
update();
}
public override void update() {
if (this.service.use_ssl) {
- this.value.set_active_id("tls");
+ this.value.method = Geary.TlsNegotiationMethod.TRANSPORT;
} else if (this.service.use_starttls) {
- this.value.set_active_id("start-tls");
+ this.value.method = Geary.TlsNegotiationMethod.START_TLS;
} else {
- this.value.set_active_id("none");
+ this.value.method = Geary.TlsNegotiationMethod.NONE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]