[network-manager-applet: 2/3] libnma: focus first empty field in the VPN dialog



commit f70c827eba60b3a6b240672048c6956487df3a8f
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Mon Sep 30 11:18:02 2019 +0200

    libnma: focus first empty field in the VPN dialog
    
    Previously the secondary field would be focused even if the first was
    empty.

 src/libnma/nma-vpn-password-dialog.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/src/libnma/nma-vpn-password-dialog.c b/src/libnma/nma-vpn-password-dialog.c
index a6738146..adc67971 100644
--- a/src/libnma/nma-vpn-password-dialog.c
+++ b/src/libnma/nma-vpn-password-dialog.c
@@ -101,19 +101,18 @@ dialog_show_callback (GtkWidget *widget, gpointer callback_data)
        NMAVpnPasswordDialogPrivate *priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
        GtkWidget *to_focus = NULL;
 
-       if (   gtk_widget_get_visible (priv->password_entry_tertiary)
-           && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_tertiary)) == 0) {
-               to_focus = priv->password_entry_tertiary;
-       }
 
-       if (   gtk_widget_get_visible (priv->password_entry_secondary)
-                  && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_secondary)) == 0) {
+       if (   gtk_widget_get_visible (priv->password_entry)
+           && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry)) == 0)
+               to_focus = priv->password_entry;
+       else if (   gtk_widget_get_visible (priv->password_entry_secondary)
+                && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_secondary)) == 0)
                to_focus = priv->password_entry_secondary;
-       }
+       else if (   gtk_widget_get_visible (priv->password_entry_tertiary)
+                && gtk_entry_get_text_length (GTK_ENTRY (priv->password_entry_tertiary)) == 0)
+               to_focus = priv->password_entry_tertiary;
 
-       if (to_focus == NULL)
-               to_focus = priv->password_entry;
-       gtk_widget_grab_focus (to_focus);
+       gtk_widget_grab_focus (to_focus ?: priv->password_entry);
 }
 
 static void


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