[geary/wip/714104-refine-account-dialog: 168/180] Enable reusing account editor SMTP auth source combobox



commit 89aca2bf7f3e4d372c958a94f2b5c7d569f70e23
Author: Michael Gratton <mike vee net>
Date:   Sat Oct 20 10:33:23 2018 +1100

    Enable reusing account editor SMTP auth source combobox
    
    Break it out into a seperate class.

 src/client/accounts/accounts-editor-add-pane.vala | 37 ++++---------------
 src/client/accounts/accounts-editor-row.vala      | 43 +++++++++++++++++++++++
 2 files changed, 50 insertions(+), 30 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-add-pane.vala 
b/src/client/accounts/accounts-editor-add-pane.vala
index e763678c..6e130945 100644
--- a/src/client/accounts/accounts-editor-add-pane.vala
+++ b/src/client/accounts/accounts-editor-add-pane.vala
@@ -209,7 +209,7 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
                     // There was an SMTP auth error, but IMAP already
                     // succeeded, so the user probably needs to
                     // specify custom creds here
-                    this.smtp_auth.source = Geary.SmtpCredentials.CUSTOM;
+                    this.smtp_auth.value.source = Geary.SmtpCredentials.CUSTOM;
                     to_focus = this.smtp_login.value;
                     // Translators: In-app notification label
                     message = _("Check your sending login and password");
@@ -312,7 +312,7 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
            this.accounts.new_libsecret_service(Geary.Protocol.SMTP);
 
         if (this.provider == Geary.ServiceProvider.OTHER) {
-            switch (this.smtp_auth.source) {
+            switch (this.smtp_auth.value.source) {
             case Geary.SmtpCredentials.NONE:
                 service.smtp_noauth = true;
                 service.smtp_use_imap_credentials = false;
@@ -401,7 +401,7 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
     }
 
     private void on_smtp_auth_changed() {
-        if (this.smtp_auth.source == Geary.SmtpCredentials.CUSTOM) {
+        if (this.smtp_auth.value.source == Geary.SmtpCredentials.CUSTOM) {
             this.sending_list.add(this.smtp_login);
             this.sending_list.add(this.smtp_password);
         } else if (this.smtp_login.parent != null) {
@@ -609,37 +609,14 @@ private class Accounts.TransportSecurityRow :
 
 
 private class Accounts.SmtpAuthRow :
-    LabelledEditorRow<EditorAddPane,Gtk.ComboBoxText> {
-
-    public Geary.SmtpCredentials source {
-        get {
-            try {
-                return Geary.SmtpCredentials.for_value(this.value.active_id);
-            } catch {
-                return Geary.SmtpCredentials.IMAP;
-            }
-        }
-        set {
-            this.value.active_id = value.to_value();
-        }
-    }
-
+    LabelledEditorRow<EditorAddPane,SmtpAuthComboBox> {
 
     public SmtpAuthRow() {
-        base(
-            // Translators: Label for SMTP authentication method
-            // (none, use IMAP, custom) when adding a new account
-            _("Login"),
-            new Gtk.ComboBoxText()
-        );
+        SmtpAuthComboBox value = new SmtpAuthComboBox();
+        base(value.label, value);
 
         this.activatable = false;
-
-        this.value.append(Geary.SmtpCredentials.NONE.to_value(), _("No login needed"));
-        this.value.append(Geary.SmtpCredentials.IMAP.to_value(), _("Use IMAP login"));
-        this.value.append(Geary.SmtpCredentials.CUSTOM.to_value(), _("Use different login"));
-
-        this.source = Geary.SmtpCredentials.IMAP;
+        this.value.source = Geary.SmtpCredentials.IMAP;
     }
 
 }
diff --git a/src/client/accounts/accounts-editor-row.vala b/src/client/accounts/accounts-editor-row.vala
index a2653d72..11a49f02 100644
--- a/src/client/accounts/accounts-editor-row.vala
+++ b/src/client/accounts/accounts-editor-row.vala
@@ -259,6 +259,49 @@ internal class Accounts.TlsComboBox : Gtk.ComboBox {
 }
 
 
+internal class Accounts.SmtpAuthComboBox : Gtk.ComboBoxText {
+
+
+    public string label { get; private set; }
+
+    public Geary.SmtpCredentials source {
+        get {
+            try {
+                return Geary.SmtpCredentials.for_value(this.active_id);
+            } catch {
+                return Geary.SmtpCredentials.IMAP;
+            }
+        }
+        set {
+            this.active_id = value.to_value();
+        }
+    }
+
+
+    public SmtpAuthComboBox() {
+        // Translators: Label for source of SMTP authentication
+        // credentials (none, use IMAP, custom) when adding a new
+        // account
+        this.label = _("Login");
+
+        // Translators: ComboBox value for source of SMTP
+        // authentication credentials (none) when adding a new account
+        append(Geary.SmtpCredentials.NONE.to_value(), _("No login needed"));
+
+        // Translators: ComboBox value for source of SMTP
+        // authentication credentials (use IMAP) when adding a new
+        // account
+        append(Geary.SmtpCredentials.IMAP.to_value(), _("Use IMAP login"));
+
+        // Translators: ComboBox value for source of SMTP
+        // authentication credentials (custom) when adding a new
+        // account
+        append(Geary.SmtpCredentials.CUSTOM.to_value(), _("Use different login"));
+    }
+
+}
+
+
 internal class Accounts.EditorPopover : Gtk.Popover {
 
 


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