diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index a1fd5bc04..1126e1fc5 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -59,7 +59,6 @@ struct _NetDeviceWifi NetDevice parent; GtkBuilder *builder; - GtkWidget *details_dialog; GtkSwitch *hotspot_switch; gboolean updating_device; gchar *selected_ssid_title; @@ -106,11 +105,6 @@ device_wifi_proxy_add_to_stack (NetObject *object, nmdevice = net_device_get_nm_device (NET_DEVICE (object)); - /* add widgets to size group */ - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, - "heading_ipv4")); - gtk_size_group_add_widget (heading_size_group, widget); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "notebook_view")); gtk_stack_add_titled (stack, widget, @@ -120,45 +114,6 @@ device_wifi_proxy_add_to_stack (NetObject *object, return widget; } -static gchar * -get_ap_security_string (NMAccessPoint *ap) -{ - NM80211ApSecurityFlags wpa_flags, rsn_flags; - NM80211ApFlags flags; - GString *str; - - flags = nm_access_point_get_flags (ap); - wpa_flags = nm_access_point_get_wpa_flags (ap); - rsn_flags = nm_access_point_get_rsn_flags (ap); - - str = g_string_new (""); - if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && - (wpa_flags == NM_802_11_AP_SEC_NONE) && - (rsn_flags == NM_802_11_AP_SEC_NONE)) { - /* TRANSLATORS: this WEP WiFi security */ - g_string_append_printf (str, "%s, ", _("WEP")); - } - if (wpa_flags != NM_802_11_AP_SEC_NONE) { - /* TRANSLATORS: this WPA WiFi security */ - g_string_append_printf (str, "%s, ", _("WPA")); - } - if (rsn_flags != NM_802_11_AP_SEC_NONE) { - /* TRANSLATORS: this WPA WiFi security */ - g_string_append_printf (str, "%s, ", _("WPA2")); - } - if ((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) || - (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - /* TRANSLATORS: this Enterprise WiFi security */ - g_string_append_printf (str, "%s, ", _("Enterprise")); - } - if (str->len > 0) - g_string_set_size (str, str->len - 2); - else { - g_string_append (str, C_("Wifi security", "None")); - } - return g_string_free (str, FALSE); -} - static void disable_scan_timeout (NetDeviceWifi *device_wifi) { @@ -380,44 +335,6 @@ nm_device_wifi_refresh_hotspot (NetDeviceWifi *device_wifi) panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), NULL); } -static void -update_last_used (NetDeviceWifi *device_wifi, NMConnection *connection) -{ - g_autofree gchar *last_used = NULL; - g_autoptr(GDateTime) now = NULL; - g_autoptr(GDateTime) then = NULL; - gint days; - GTimeSpan diff; - guint64 timestamp; - NMSettingConnection *s_con; - GtkWidget *heading, *widget; - - s_con = nm_connection_get_setting_connection (connection); - if (s_con == NULL) - goto out; - timestamp = nm_setting_connection_get_timestamp (s_con); - if (timestamp == 0) { - last_used = g_strdup (_("never")); - goto out; - } - - /* calculate the amount of time that has elapsed */ - now = g_date_time_new_now_utc (); - then = g_date_time_new_from_unix_utc (timestamp); - diff = g_date_time_difference (now, then); - days = diff / G_TIME_SPAN_DAY; - if (days == 0) - last_used = g_strdup (_("today")); - else if (days == 1) - last_used = g_strdup (_("yesterday")); - else - last_used = g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days); -out: - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_last_used")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_last_used")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), last_used); -} - static void set_scanning (NetDeviceWifi *self, gboolean scanning, @@ -481,19 +398,9 @@ request_scan (gpointer user_data) static void nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi) { - const gchar *str; - g_autofree gchar *speed_text = NULL; - g_autofree gchar *security_text = NULL; - gint strength = 0; - guint speed = 0; - NMAccessPoint *active_ap; NMDevice *nm_device; - NMDeviceState state; NMClient *client; - NMAccessPoint *ap; - NMConnection *connection; - GtkWidget *dialog; - GtkWidget *heading, *widget; + GtkWidget *widget; g_autofree gchar *status = NULL; if (device_is_hotspot (device_wifi)) { @@ -512,89 +419,11 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi) request_scan (device_wifi); } - dialog = device_wifi->details_dialog; - - ap = g_object_get_data (G_OBJECT (dialog), "ap"); - connection = g_object_get_data (G_OBJECT (dialog), "connection"); - nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi)); - active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (nm_device)); - - state = nm_device_get_state (nm_device); /* keep this in sync with the signal handler setup in cc_network_panel_init */ wireless_enabled_toggled (client, NULL, device_wifi); - if (ap != active_ap) - speed = 0; - else if (state != NM_DEVICE_STATE_UNAVAILABLE) - speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (nm_device)); - speed /= 1000; - if (speed > 0) { - /* Translators: network device speed */ - speed_text = g_strdup_printf (_("%d Mb/s"), speed); - } - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_speed")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_speed")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), speed_text); - - /* device MAC */ - str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (nm_device)); - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_mac")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_mac")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), str); - - /* security */ - if (ap == active_ap && active_ap != NULL) - security_text = get_ap_security_string (active_ap); - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_security")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_security")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), security_text); - - /* signal strength */ - if (ap != NULL) - strength = nm_access_point_get_strength (ap); - else - strength = 0; - if (strength <= 0) - str = NULL; - else if (strength < 20) - str = C_("Signal strength", "None"); - else if (strength < 40) - str = C_("Signal strength", "Weak"); - else if (strength < 50) - str = C_("Signal strength", "Ok"); - else if (strength < 80) - str = C_("Signal strength", "Good"); - else - str = C_("Signal strength", "Excellent"); - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_strength")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_strength")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), str); - - /* device MAC */ - if (ap != active_ap) - str = NULL; - else - str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (nm_device)); - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_mac")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_mac")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), str); - - /* set IP entries */ - if (ap != active_ap) - panel_set_device_widgets (device_wifi->builder, NULL); - else - panel_set_device_widgets (device_wifi->builder, nm_device); - - if (ap != active_ap && connection) - update_last_used (device_wifi, connection); - else { - heading = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_last_used")); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "label_last_used")); - panel_set_device_widget_details (GTK_LABEL (heading), GTK_LABEL (widget), NULL); - } - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "heading_status")); status = panel_device_status_to_localized_string (nm_device, NULL); gtk_label_set_label (GTK_LABEL (widget), status); @@ -1157,7 +986,6 @@ net_device_wifi_finalize (GObject *object) } disable_scan_timeout (device_wifi); - g_clear_pointer (&device_wifi->details_dialog, gtk_widget_destroy); g_object_unref (device_wifi->builder); g_free (device_wifi->selected_ssid_title); g_free (device_wifi->selected_connection_id); @@ -1595,10 +1423,6 @@ net_device_wifi_init (NetDeviceWifi *device_wifi) device_wifi->cancellable = g_cancellable_new (); - widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, - "details_dialog")); - device_wifi->details_dialog = widget; - /* setup wifi views */ widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->builder, "device_off_switch")); diff --git a/panels/network/network-wifi.ui b/panels/network/network-wifi.ui index 937f9022b..36e7b44c8 100644 --- a/panels/network/network-wifi.ui +++ b/panels/network/network-wifi.ui @@ -1,1417 +1,6 @@ - - False - 5 - False - True - 600 - 300 - dialog - - - False - vertical - 2 - - - False - end - end - - - _Cancel - True - True - True - True - - - False - True - 2 - - - - - _Apply - True - True - True - True - - - False - True - 3 - - - - - False - True - end - 0 - - - - - True - False - - - True - True - never - in - - - True - True - details_store - False - False - 0 - - - - - - - - 10 - - - 0 - - - - - 20 - - - - - - - - - True - True - 0 - - - - - True - True - False - False - - - True - False - vertical - - - True - False - end - center - 6 - - - True - False - Automatic _Connect - True - automatic_connect_switch - - - False - True - 0 - - - - - True - True - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - start - 50 - 50 - 12 - 12 - True - True - 10 - 6 - - - True - False - True - 1 - Signal Strength - - - - 0 - 0 - 1 - 1 - - - - - True - True - True - 0 - Weak - True - - - 1 - 0 - 1 - 1 - - - - - True - False - 1 - Link speed - - - - 0 - 1 - 1 - 1 - - - - - True - True - 0 - 1Mb/sec - True - - - 1 - 1 - 1 - 1 - - - - - True - False - 1 - Security - - - - 0 - 2 - 1 - 1 - - - - - True - False - 1 - IPv4 Address - - - - 0 - 3 - 1 - 1 - - - - - True - False - 1 - IPv6 Address - - - - 0 - 4 - 1 - 1 - - - - - True - False - 1 - Hardware Address - - - - 0 - 5 - 1 - 1 - - - - - True - False - 1 - Default Route - - - - 0 - 6 - 1 - 1 - - - - - True - False - 1 - 0 - DNS - - - - 0 - 7 - 1 - 1 - - - - - True - False - 1 - Last used - - - - 0 - 8 - 1 - 1 - - - - - True - True - 0 - WPA - True - - - 1 - 2 - 1 - 1 - - - - - True - True - 0 - 127.0.0.1 - True - - - 1 - 3 - 1 - 1 - - - - - True - True - 0 - ::1 - True - - - 1 - 4 - 1 - 1 - - - - - True - True - 0 - AA:BB:CC:DD:55:66:77:88 - True - - - 1 - 5 - 1 - 1 - - - - - True - True - 0 - 127.0.0.1 - True - - - 1 - 6 - 1 - 1 - - - - - True - True - 0 - 0 - 127.0.0.1 - True - True - - - 1 - 7 - 1 - 1 - - - - - True - True - 0 - today - True - - - 1 - 8 - 1 - 1 - - - - - True - True - 1 - - - - - - - True - False - 50 - 50 - 12 - 12 - True - True - 10 - 6 - - - True - False - 1 - _SSID - True - entry_ssid - - - 0 - 0 - 1 - 1 - - - - - True - False - 1 - _BSSID - True - entry_bssid - - - 0 - 1 - 1 - 1 - - - - - True - False - 1 - S_ecurity - True - combo_sec - - - 0 - 2 - 1 - 1 - - - - - True - False - 1 - _Password - True - entry_password - - - 0 - 3 - 1 - 1 - - - - - True - True - True - - - - 1 - 0 - 1 - 1 - - - - - True - True - True - - - - 1 - 1 - 1 - 1 - - - - - True - False - True - 0 - 1 - - WPA - None - - - - 1 - 2 - 1 - 1 - - - - - True - True - True - False - - blablabla - - - 1 - 3 - 1 - 1 - - - - - Show P_assword - True - True - False - center - True - 0 - True - - - 1 - 4 - 1 - 1 - - - - - True - False - - - 0 - 4 - 1 - 1 - - - - - Make available to other users - True - True - False - end - True - 0 - True - - - 1 - 5 - 1 - 1 - - - - - - - - 1 - - - - - True - True - never - - - True - False - - - True - False - 20 - 20 - 10 - 10 - vertical - 10 - - - True - False - - - True - False - IPv_4 - True - switch_ipv4_ipv4 - - - - - - False - True - 0 - - - - - True - True - end - True - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - - - True - False - _Addresses - True - combo_ipv4_addresses - - - - - - False - True - 0 - - - - - True - False - end - True - 0 - 1 - - Manual - Automatic (DHCP) - Automatic (DHCP) addresses only - Link-local only - Shared with other computers - Disabled - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - vertical - - - True - False - Address -section -goes -here - - - False - True - 0 - - - - - False - True - 2 - - - - - True - False - 24 - 6 - 0 - DNS - - - - - - False - True - 3 - - - - - True - False - vertical - - - True - False - DNS -section -goes -here - - - False - True - 0 - - - - - False - True - 4 - - - - - True - False - 24 - 6 - 0 - Routes - - - - - - False - True - 5 - - - - - True - False - vertical - - - True - False - Routes -section -goes -here - - - False - True - 0 - - - - - False - True - 6 - - - - - _Ignore automatically obtained routes - True - True - False - True - 0 - True - - - False - True - 7 - - - - - Use this connection _only for resources on its network - True - True - False - True - 0 - True - - - False - True - 8 - - - - - - - - - 2 - - - - - True - True - never - in - - - True - False - - - True - False - vertical - 10 - - - True - False - - - True - False - IPv_6 - True - switch_ipv6_ipv6 - - - - - - False - True - 0 - - - - - True - True - end - True - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - - - True - False - _Addresses - True - combo_ipv6_addresses - - - - - - False - True - 0 - - - - - True - False - end - True - 0 - 1 - - Manual - Automatic (DHCP) - Automatic (DHCP) addresses only - Link-local only - Shared with other computers - Disabled - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - vertical - - - True - False - Address -section -goes -here - - - False - True - 0 - - - - - False - True - 2 - - - - - True - False - 24 - 6 - 0 - DNS - - - - - - False - True - 3 - - - - - True - False - vertical - - - True - False - DNS -section -goes -here - - - False - True - 0 - - - - - False - True - 4 - - - - - True - False - 24 - 6 - 0 - Routes - - - - - - False - True - 5 - - - - - True - False - vertical - - - True - False - Routes -section -goes -here - - - False - True - 0 - - - - - False - True - 6 - - - - - _Ignore automatically obtained routes - True - True - False - True - 0 - True - - - False - True - 7 - - - - - Use this connection _only for resources on its network - True - True - False - True - 0 - True - - - False - True - 8 - - - - - - - - - 3 - - - - - True - False - 50 - 50 - 12 - 12 - True - True - 10 - 6 - - - True - False - 1 - _MAC Address - True - label_hw_mac - - - 0 - 0 - 1 - 1 - - - - - True - False - 1 - _Cloned MAC Address - True - entry_hw_cloned_mac - - - 0 - 1 - 1 - 1 - - - - - True - False - True - 0 - 00:24:16:31:8G:7A - True - - - 1 - 0 - 1 - 1 - - - - - True - True - True - - - - 1 - 1 - 1 - 1 - - - - - 4 - - - - - True - False - 50 - 50 - 12 - 12 - 10 - 10 - - - _Reset - True - True - True - start - True - - - 0 - 0 - 1 - 1 - - - - - _Forget - True - True - True - start - True - - - 0 - 1 - 1 - 1 - - - - - True - False - True - 0 - Reset the settings for this connection to their defaults, but remember as a preferred connection. - True - 40 - - - 1 - 0 - 1 - 1 - - - - - True - False - True - 0 - Remove all details relating to this network and do not try to automatically connect to it. - True - 30 - - - 1 - 1 - 1 - 1 - - - - - 5 - - - - - True - True - 1 - - - - - True - True - 1 - - - - - - details_cancel_button - details_apply_button - - - - - - - - - - - - Details - 0 - - - Identity - 1 - - - IPv4 - 2 - - - IPv6 - 3 - - - Hardware - 4 - - - Reset - 5 - - - True True