[network-manager-applet] vpn-password-dialog: focus the first visible and empty field
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] vpn-password-dialog: focus the first visible and empty field
- Date: Tue, 2 Apr 2019 08:58:09 +0000 (UTC)
commit 29447881ef63509eb5c98e4584dd680fce7b32f7
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Apr 2 10:54:49 2019 +0200
vpn-password-dialog: focus the first visible and empty field
Convenient if we have a saved password and a non-saved OTP.
src/libnma/nma-vpn-password-dialog.c | 20 ++++++++++++++------
src/libnma/tests/vpn-password-dialog.c | 3 +--
2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/libnma/nma-vpn-password-dialog.c b/src/libnma/nma-vpn-password-dialog.c
index 7ff13e66..df5d2278 100644
--- a/src/libnma/nma-vpn-password-dialog.c
+++ b/src/libnma/nma-vpn-password-dialog.c
@@ -104,13 +104,21 @@ dialog_show_callback (GtkWidget *widget, gpointer callback_data)
{
NMAVpnPasswordDialog *dialog = NMA_VPN_PASSWORD_DIALOG (callback_data);
NMAVpnPasswordDialogPrivate *priv = NMA_VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+ GtkWidget *to_focus = NULL;
- if (gtk_widget_get_visible (priv->password_entry))
- gtk_widget_grab_focus (priv->password_entry);
- else if (gtk_widget_get_visible (priv->password_entry_secondary))
- gtk_widget_grab_focus (priv->password_entry_secondary);
- else if (gtk_widget_get_visible (priv->password_entry_tertiary))
- gtk_widget_grab_focus (priv->password_entry_tertiary);
+ 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) {
+ to_focus = priv->password_entry_secondary;
+ }
+
+ if (to_focus == NULL)
+ to_focus = priv->password_entry;
+ gtk_widget_grab_focus (to_focus);
}
static void
diff --git a/src/libnma/tests/vpn-password-dialog.c b/src/libnma/tests/vpn-password-dialog.c
index d3e58175..ededcc6e 100644
--- a/src/libnma/tests/vpn-password-dialog.c
+++ b/src/libnma/tests/vpn-password-dialog.c
@@ -33,11 +33,10 @@ main (int argc, char *argv[])
nma_vpn_password_dialog_set_password (NMA_VPN_PASSWORD_DIALOG (widget), "Password One");
nma_vpn_password_dialog_set_password_label (NMA_VPN_PASSWORD_DIALOG (widget), "First _Label");
- nma_vpn_password_dialog_set_password_secondary (NMA_VPN_PASSWORD_DIALOG (widget), "Password Two");
+ nma_vpn_password_dialog_set_password_secondary (NMA_VPN_PASSWORD_DIALOG (widget), "");
nma_vpn_password_dialog_set_password_secondary_label (NMA_VPN_PASSWORD_DIALOG (widget), "_Second
Label");
nma_vpn_password_dialog_set_show_password_secondary (NMA_VPN_PASSWORD_DIALOG (widget), TRUE);
- nma_vpn_password_dialog_set_password_ternary (NMA_VPN_PASSWORD_DIALOG (widget), "Password Three");
nma_vpn_password_dialog_set_password_ternary_label (NMA_VPN_PASSWORD_DIALOG (widget), "_Third Label");
nma_vpn_password_dialog_set_show_password_ternary (NMA_VPN_PASSWORD_DIALOG (widget), TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]