diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-10-24 18:41:51 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-26 14:24:40 +0100 |
commit | 93d7b09d6897717afb598f9ebb77b88b0a68cd1d (patch) | |
tree | 686e8193df85d334beeedc240b3547249f6a51e0 | |
parent | d15e6e08efd2ae5b5a6713dd425e08d2bbf70ab0 (diff) | |
download | network-manager-applet-93d7b09d6897717afb598f9ebb77b88b0a68cd1d.tar.gz |
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.
-rw-r--r-- | src/libnma/nma-wifi-dialog.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c index 8372afee..1803a1f0 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, FALSE); info = g_malloc0 (sizeof (GetSecretsInfo)); @@ -1084,7 +1084,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."); |