[gnome-control-center/wip/benzea/wifi-panel: 15/21] wifi: Show the connection name when it is different to SSID
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/benzea/wifi-panel: 15/21] wifi: Show the connection name when it is different to SSID
- Date: Thu, 3 Jan 2019 16:04:55 +0000 (UTC)
commit 19a06467e00759e94053642fe622b7757e195b2f
Author: Benjamin Berg <bberg redhat com>
Date: Sat Dec 15 17:35:44 2018 +0100
wifi: Show the connection name when it is different to SSID
In almost all cases, the SSID will be identical with the connection name
(in fact, we do not even allow modifying the connection name). However,
as it is now, we can end up with multiple connections with the same name
in the list.
Change the list to indicate the SSID separately in a way that will not
result in any changes in the usual case.
panels/network/cc-wifi-connection-row.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/panels/network/cc-wifi-connection-row.c b/panels/network/cc-wifi-connection-row.c
index 88e53168f..f2589567d 100644
--- a/panels/network/cc-wifi-connection-row.c
+++ b/panels/network/cc-wifi-connection-row.c
@@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <glib/gi18n.h>
#include <config.h>
#include "cc-wifi-connection-row.h"
@@ -113,13 +114,42 @@ update_ui (CcWifiConnectionRow *self)
if (self->connection)
{
NMSettingWireless *sw;
+ const gchar *name = NULL;
+ g_autofree gchar *ssid_str = NULL;
+ gchar *ssid_pos;
+
sw = nm_connection_get_setting_wireless (self->connection);
ssid = nm_setting_wireless_get_ssid (sw);
+ ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
+ name = nm_connection_get_id (NM_CONNECTION (self->connection));
+
+ ssid_pos = strstr (name, ssid_str);
+ if (ssid_pos == name && strlen (name) == strlen (ssid_str))
+ {
+ title = g_strdup (name);
+ }
+ else if (ssid_pos)
+ {
+ g_autofree gchar *before = g_strndup (name, ssid_pos - name);
+ g_autofree gchar *after = g_strndup (ssid_pos + strlen (ssid_str), strlen(ssid_pos) -
strlen(ssid_str));
+ title = g_markup_printf_escaped ("<i>%s</i>%s<i>%s</i>",
+ before, ssid_str, after);
+ }
+ else
+ {
+ /* TRANSLATORS: This happens when the connection name does not contain the SSID. */
+ title = g_markup_printf_escaped (C_("Wi-Fi Connection", "%s (SSID: %s)"),
+ name, ssid_str);
+ }
+
+ gtk_label_set_markup (self->name_label, title);
}
else
{
ssid = nm_access_point_get_ssid (self->ap);
+ title = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
+ gtk_label_set_text (self->name_label, title);
}
if (self->ap != NULL)
@@ -145,8 +175,6 @@ update_ui (CcWifiConnectionRow *self)
}
- title = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
- gtk_label_set_text (self->name_label, title);
if (connecting)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]