[smuxi/stable] Frontend-GNOME: fix help text when using putty/plink in assistant



commit e3faab06eabf01caa97e2874a7dbbe272b1ecf47
Author: Mirco Bauer <meebey meebey net>
Date:   Sun Jul 10 12:26:58 2016 +0200

    Frontend-GNOME: fix help text when using putty/plink in assistant
    
    The SSH username field is optional with OpenSSH since it defaults to the
    username of the current user. PuTTY/Plink always requires a username to set be
    set.

 .../Views/Assistants/Engine/EngineAssistant.cs     |   17 ++++++++++++++++-
 .../Engine/EngineAssistantCredentialsWidget.cs     |    6 ++++++
 ...ntend.Gnome.EngineAssistantCredentialsWidget.cs |   20 +++++++++++---------
 src/Frontend-GNOME/gtk-gui/gui.stetic              |    2 +-
 4 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistant.cs 
b/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistant.cs
index 88a9e6f..5f7e61f 100644
--- a/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistant.cs
+++ b/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistant.cs
@@ -22,6 +22,7 @@
 
 using System;
 using System.IO;
+using System.Text.RegularExpressions;
 using Smuxi.Common;
 using Smuxi.Engine;
 using IOPath = System.IO.Path;
@@ -37,6 +38,7 @@ namespace Smuxi.Frontend.Gnome
         private int                              f_NamePage;
         private EngineAssistantConnectionWidget  f_ConnectionWidget;
         private EngineAssistantCredentialsWidget f_CredentialsWidget;
+        bool IsPutty { get; set; }
 
         public EngineAssistant(Gtk.Window parent, FrontendConfig config) :
                           this(parent, config, null)
@@ -63,6 +65,7 @@ namespace Smuxi.Frontend.Gnome
             SetDefaultSize(640, 480);
             SetPosition(Gtk.WindowPosition.CenterAlways);
             Title = _("Engine Assistant - Smuxi");
+            IsPutty = File.Exists("plink.exe");
 
             Apply += OnApply;
 
@@ -219,7 +222,15 @@ namespace Smuxi.Frontend.Gnome
 
             // HACK: only show the SSH password field if plink is present as
             // OpenSSH doesn't support passing passwords via command line
-            f_CredentialsWidget.SshPasswordVBox.Visible = File.Exists("plink.exe");
+            f_CredentialsWidget.SshPasswordVBox.Visible = IsPutty;
+
+            // Plink always requires a SSH username
+            if (IsPutty) {
+                // remove the (optional) portion from the label
+                f_CredentialsWidget.SshUsernameLabel.Text = Regex.Replace(
+                    f_CredentialsWidget.SshUsernameLabel.Text, @"\(.*?\)", ""
+                );
+            }
 
             if (f_EngineName != null) {
                 f_CredentialsWidget.SshUsernameEntry.Text = (string)
@@ -274,6 +285,10 @@ namespace Smuxi.Frontend.Gnome
                 f_CredentialsWidget.VerifyPasswordEntry.Text) {
                 isComplete = false;
             }
+            // Putty always requires a username
+            if (IsPutty && f_CredentialsWidget.SshUsernameEntry.Text.Trim().Length == 0) {
+                isComplete = false;
+            }
             SetPageComplete(f_CredentialsWidget, isComplete);
         }
 
diff --git a/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistantCredentialsWidget.cs 
b/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistantCredentialsWidget.cs
index 2379ced..b294ea7 100644
--- a/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistantCredentialsWidget.cs
+++ b/src/Frontend-GNOME/Views/Assistants/Engine/EngineAssistantCredentialsWidget.cs
@@ -50,6 +50,12 @@ namespace Smuxi.Frontend.Gnome
             }
         }
 
+        public Gtk.Label SshUsernameLabel {
+            get {
+                return f_SshUsernameLabel;
+            }
+        }
+
         public Gtk.Entry SshPasswordEntry {
             get {
                 return f_SshPasswordEntry;
diff --git a/src/Frontend-GNOME/gtk-gui/Smuxi.Frontend.Gnome.EngineAssistantCredentialsWidget.cs 
b/src/Frontend-GNOME/gtk-gui/Smuxi.Frontend.Gnome.EngineAssistantCredentialsWidget.cs
index 23b5755..a1074ea 100644
--- a/src/Frontend-GNOME/gtk-gui/Smuxi.Frontend.Gnome.EngineAssistantCredentialsWidget.cs
+++ b/src/Frontend-GNOME/gtk-gui/Smuxi.Frontend.Gnome.EngineAssistantCredentialsWidget.cs
@@ -6,7 +6,9 @@ namespace Smuxi.Frontend.Gnome
        {
                private global::Gtk.VBox vbox12;
                private global::Gtk.VBox vbox13;
-               private global::Gtk.Label label6;
+        
+               private global::Gtk.Label f_SshUsernameLabel;
+        
                private global::Gtk.Entry f_SshUsernameEntry;
                private global::Gtk.Label label9;
                private global::Gtk.VBox f_SshPasswordVBox;
@@ -46,13 +48,13 @@ namespace Smuxi.Frontend.Gnome
                        this.vbox13.Name = "vbox13";
                        this.vbox13.Spacing = 6;
                        // Container child vbox13.Gtk.Box+BoxChild
-                       this.label6 = new global::Gtk.Label ();
-                       this.label6.Name = "label6";
-                       this.label6.Xalign = 0F;
-                       this.label6.LabelProp = global::Mono.Unix.Catalog.GetString ("_SSH Username: 
(optional)");
-                       this.label6.UseUnderline = true;
-                       this.vbox13.Add (this.label6);
-                       global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox13 [this.label6]));
+                       this.f_SshUsernameLabel = new global::Gtk.Label ();
+                       this.f_SshUsernameLabel.Name = "f_SshUsernameLabel";
+                       this.f_SshUsernameLabel.Xalign = 0F;
+                       this.f_SshUsernameLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("_SSH 
Username: (optional)");
+                       this.f_SshUsernameLabel.UseUnderline = true;
+                       this.vbox13.Add (this.f_SshUsernameLabel);
+                       global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox13 
[this.f_SshUsernameLabel]));
                        w1.Position = 0;
                        w1.Expand = false;
                        w1.Fill = false;
@@ -305,7 +307,7 @@ namespace Smuxi.Frontend.Gnome
                        if ((this.Child != null)) {
                                this.Child.ShowAll ();
                        }
-                       this.label6.MnemonicWidget = this.f_SshUsernameEntry;
+                       this.f_SshUsernameLabel.MnemonicWidget = this.f_SshUsernameEntry;
                        this.label14.MnemonicWidget = this.f_SshUsernameEntry;
                        this.label16.MnemonicWidget = this.f_SshKeyfileChooserButton;
                        this.label12.MnemonicWidget = this.f_UsernameEntry;
diff --git a/src/Frontend-GNOME/gtk-gui/gui.stetic b/src/Frontend-GNOME/gtk-gui/gui.stetic
index 837beed..e238f42 100644
--- a/src/Frontend-GNOME/gtk-gui/gui.stetic
+++ b/src/Frontend-GNOME/gtk-gui/gui.stetic
@@ -3370,7 +3370,7 @@ Click "Forward" to begin.</property>
             <property name="MemberName" />
             <property name="Spacing">6</property>
             <child>
-              <widget class="Gtk.Label" id="label6">
+              <widget class="Gtk.Label" id="f_SshUsernameLabel">
                 <property name="MemberName" />
                 <property name="Xalign">0</property>
                 <property name="LabelProp" translatable="yes">_SSH Username: (optional)</property>


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