[network-manager-applet/lr/wifi-dialog-fixes: 2/6] nma/pkcs11-cert-chooser: hide useless inputs



commit f5efbb64fa273c40db89ff0fb94b6947a4c733a2
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Oct 24 17:55:25 2018 +0200

    nma/pkcs11-cert-chooser: hide useless inputs
    
    If we're asking for secrets only, hide the entry boxes that are greyed
    out because the key/cert doesn't actually need a password.
    
    If both password entries are hidden then also remove the "show
    passwords" checkbox.

 src/libnma/nma-cert-chooser-private.h |  1 +
 src/libnma/nma-pkcs11-cert-chooser.c  | 26 ++++++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/libnma/nma-cert-chooser-private.h b/src/libnma/nma-cert-chooser-private.h
index e1852bc8..fd4a4e6a 100644
--- a/src/libnma/nma-cert-chooser-private.h
+++ b/src/libnma/nma-cert-chooser-private.h
@@ -46,6 +46,7 @@ typedef struct {
        GtkWidget *key_password;
        GtkWidget *cert_button;
        GtkWidget *cert_password;
+       GtkWidget *show_password;
 } NMAPkcs11CertChooserPrivate;
 
 typedef struct {
diff --git a/src/libnma/nma-pkcs11-cert-chooser.c b/src/libnma/nma-pkcs11-cert-chooser.c
index 80b02b34..411ef8a1 100644
--- a/src/libnma/nma-pkcs11-cert-chooser.c
+++ b/src/libnma/nma-pkcs11-cert-chooser.c
@@ -409,6 +409,21 @@ set_flags (NMACertChooser *cert_chooser, NMACertChooserFlags flags)
                gtk_widget_hide (priv->cert_button_label);
                gtk_widget_hide (priv->key_button);
                gtk_widget_hide (priv->key_button_label);
+
+               /* If these are not sensitive now, the cannot possibly be made
+                * sensitive and there's no point in showing them. */
+               if (!gtk_widget_get_sensitive (priv->cert_password)) {
+                       gtk_widget_hide (priv->cert_password);
+                       gtk_widget_hide (priv->cert_password_label);
+               }
+               if (!gtk_widget_get_sensitive (priv->key_password)) {
+                       gtk_widget_hide (priv->key_password);
+                       gtk_widget_hide (priv->key_password_label);
+               }
+               if (   !gtk_widget_get_visible (priv->cert_password)
+                   && !gtk_widget_get_visible (priv->key_password)) {
+                       gtk_widget_hide (priv->show_password);
+               }
        }
 }
 
@@ -416,7 +431,6 @@ static void
 init (NMACertChooser *cert_chooser)
 {
        NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
-       GtkWidget *show_password;
 
        gtk_grid_insert_column (GTK_GRID (cert_chooser), 2);
        gtk_grid_set_row_spacing (GTK_GRID (cert_chooser), 6);
@@ -424,11 +438,11 @@ init (NMACertChooser *cert_chooser)
 
        /* Show password */
        gtk_grid_insert_row (GTK_GRID (cert_chooser), 0);
-       show_password = gtk_check_button_new_with_mnemonic ("Sho_w passwords");
-       gtk_grid_attach (GTK_GRID (cert_chooser), show_password, 1, 2, 1, 1);
-       gtk_widget_show (show_password);
-       gtk_widget_set_no_show_all (show_password, TRUE);
-       g_signal_connect (show_password, "toggled",
+       priv->show_password = gtk_check_button_new_with_mnemonic ("Sho_w passwords");
+       gtk_grid_attach (GTK_GRID (cert_chooser), priv->show_password, 1, 2, 1, 1);
+       gtk_widget_show (priv->show_password);
+       gtk_widget_set_no_show_all (priv->show_password, TRUE);
+       g_signal_connect (priv->show_password, "toggled",
                          G_CALLBACK (show_toggled_cb), cert_chooser);
 
        /* The key chooser */


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