[network-manager-applet/lr/wifi-dialog-fixes: 4/6] libnma/wifi-dialog: present the validation error in tooltip
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/lr/wifi-dialog-fixes: 4/6] libnma/wifi-dialog: present the validation error in tooltip
- Date: Wed, 24 Oct 2018 16:57:56 +0000 (UTC)
commit 4d0dd6da4fb4e1de4362a095ee17cabee9e094ba
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Wed Oct 24 18:41:51 2018 +0200
libnma/wifi-dialog: present the validation error in tooltip
...similarly to what we do in the editor windows. It provides some clue
about why is the "Connect" button greyed out.
src/libnma/nma-wifi-dialog.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
index 9edfd8bd..0300ea56 100644
--- a/src/libnma/nma-wifi-dialog.c
+++ b/src/libnma/nma-wifi-dialog.c
@@ -114,16 +114,14 @@ size_group_clear (GtkSizeGroup *group)
}
static void
-_set_ok_sensitive (NMAWifiDialog *self, gboolean is_sensitive)
+_set_ok_sensitive (NMAWifiDialog *self, gboolean is_sensitive, const char *error_tooltip)
{
NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, is_sensitive);
if (priv->ok_response_button) {
gtk_widget_set_tooltip_text (priv->ok_response_button,
- is_sensitive
- ? _("Click to connect")
- : _("Either a password is missing or the connection is
invalid. In the latter case, you have to edit the connection with nm-connection-editor first"));
+ is_sensitive ? _("Click to connect") : error_tooltip);
}
}
@@ -252,6 +250,7 @@ stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
GtkTreeModel *model;
GtkTreeIter iter;
WirelessSecurity *sel_sec = NULL;
+ gs_free_error GError *error = NULL;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
@@ -274,7 +273,7 @@ stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
}
if (ssid) {
- valid = wireless_security_validate (sec, NULL);
+ valid = wireless_security_validate (sec, &error);
if (free_ssid)
g_bytes_unref (ssid);
}
@@ -286,7 +285,7 @@ stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
if (priv->secrets_info)
valid = FALSE;
- _set_ok_sensitive (self, valid);
+ _set_ok_sensitive (self, valid, error ? error->message : NULL);
}
static void
@@ -299,6 +298,7 @@ ssid_entry_changed (GtkWidget *entry, gpointer user_data)
GtkTreeModel *model;
gboolean valid = FALSE;
GBytes *ssid;
+ gs_free_error GError *error = NULL;
/* If the network name entry was touched at all, allow focus to go to
* the default widget of the security method now.
@@ -314,7 +314,7 @@ ssid_entry_changed (GtkWidget *entry, gpointer user_data)
gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
if (sec) {
- valid = wireless_security_validate (sec, NULL);
+ valid = wireless_security_validate (sec, &error);
wireless_security_unref (sec);
} else {
valid = TRUE;
@@ -328,7 +328,7 @@ out:
if (priv->secrets_info)
valid = FALSE;
- _set_ok_sensitive (self, valid);
+ _set_ok_sensitive (self, valid, error ? error->message : NULL);
}
static void
@@ -774,7 +774,7 @@ get_secrets_cb (GObject *object,
}
if (current_secrets)
- _set_ok_sensitive (info->self, TRUE);
+ _set_ok_sensitive (info->self, TRUE, NULL);
/* User might have changed the connection while the secrets call was in
* progress, so don't try to update the wrong connection with the secrets
@@ -994,7 +994,7 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only)
/* Desensitize the dialog's buttons while we wait for the secrets
* operation to complete.
*/
- _set_ok_sensitive (self, FALSE);
+ _set_ok_sensitive (self, FALSE, NULL);
gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_CANCEL, TRUE);
info = g_malloc0 (sizeof (GetSecretsInfo));
@@ -1085,7 +1085,7 @@ internal_init (NMAWifiDialog *self,
priv->network_name_focus = TRUE;
}
- _set_ok_sensitive (self, FALSE);
+ _set_ok_sensitive (self, FALSE, NULL);
if (!device_combo_init (self, specific_device)) {
g_warning ("No Wi-Fi devices available.");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]