static void
add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
{
        NMIP4Config *ip4_config = NULL;
        NMIP6Config *ip6_config = NULL;
        gchar *ip4_address = NULL;
        gchar *ip4_route = NULL;
        gchar *ip4_dns = NULL;
        gchar *ip6_address = NULL;
        gint i = 0;

        ip4_config = nm_device_get_ip4_config (device);
        if (ip4_config) {
                ip4_address = panel_get_ip4_address_as_string (ip4_config, "address");
                ip4_route = panel_get_ip4_address_as_string (ip4_config, "gateway");
                ip4_dns = panel_get_ip4_dns_as_string (ip4_config);
        }
        ip6_config = nm_device_get_ip6_config (device);
        if (ip6_config) {
                ip6_address = panel_get_ip6_address_as_string (ip6_config);
        }

        if (ip4_address && ip6_address) {
                add_details_row (details, i++, _("IPv4 Address"), ip4_address);
                add_details_row (details, i++, _("IPv6 Address"), ip6_address);
        } else if (ip4_address) {
                add_details_row (details, i++, _("IP Address"), ip4_address);
        } else if (ip6_address) {
                add_details_row (details, i++, _("IPv6 Address"), ip6_address);
        }

        add_details_row (details, i++, _("Hardware Address"),
                         nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device)));

        if (ip4_route)
                add_details_row (details, i++, _("Default Route"), ip4_route);
        if (ip4_dns)
                add_details_row (details, i++, _("DNS"), ip4_dns);

        if (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED) {
                gchar *last_used;
                last_used = get_last_used_string (connection);
                add_details_row (details, i++, _("Last used"), last_used);
                g_free (last_used);
        }

        g_free (ip4_address);
        g_free (ip4_route);
        g_free (ip4_dns);
        g_free (ip6_address);
}
void
panel_set_device_widgets (GtkBuilder *builder, NMDevice *device)
{
        NMIP4Config *ip4_config = NULL;
        NMIP6Config *ip6_config = NULL;
        gboolean has_ip4;
        gboolean has_ip6;
        gchar *str_tmp;

        /* get IPv4 parameters */
        ip4_config = nm_device_get_ip4_config (device);
        if (ip4_config != NULL) {

                /* IPv4 address */
                str_tmp = panel_get_ip4_address_as_string (ip4_config, "address");
                panel_set_device_widget_details (builder,
                                                 "ipv4",
                                                 str_tmp);
                has_ip4 = str_tmp != NULL;
                g_free (str_tmp);

                /* IPv4 DNS */
                str_tmp = panel_get_ip4_dns_as_string (ip4_config);
                panel_set_device_widget_details (builder,
                                                 "dns",
                                                 str_tmp);
                g_free (str_tmp);

                /* IPv4 route */
                str_tmp = panel_get_ip4_address_as_string (ip4_config, "gateway");
                panel_set_device_widget_details (builder,
                                                 "route",
                                                 str_tmp);
                g_free (str_tmp);

        } else {
                /* IPv4 address */
                panel_set_device_widget_details (builder,
                                                 "ipv4",
                                                 NULL);
                has_ip4 = FALSE;

                /* IPv4 DNS */
                panel_set_device_widget_details (builder,
                                                 "dns",
                                                 NULL);

                /* IPv4 route */
                panel_set_device_widget_details (builder,
                                                 "route",
                                                 NULL);
        }

        /* get IPv6 parameters */
        ip6_config = nm_device_get_ip6_config (device);
        if (ip6_config != NULL) {
                str_tmp = panel_get_ip6_address_as_string (ip6_config);
                panel_set_device_widget_details (builder, "ipv6", str_tmp);
                has_ip6 = str_tmp != NULL;
                g_free (str_tmp);
        } else {
                panel_set_device_widget_details (builder, "ipv6", NULL);
                has_ip6 = FALSE;
        }

        if (has_ip4 && has_ip6) {
                panel_set_device_widget_header (builder, "ipv4", _("IPv4 Address"));
                panel_set_device_widget_header (builder, "ipv6", _("IPv6 Address"));
        } else if (has_ip4) {
                panel_set_device_widget_header (builder, "ipv4", _("IP Address"));
        } else if (has_ip6) {
                panel_set_device_widget_header (builder, "ipv6", _("IP Address"));
        }
}