network: Remove helper functions
They're not complex enough or used in enough places to warrant keeping. They can be better refactored in the classes that use them.
This commit is contained in:
parent
75b4e5e061
commit
7f410ee1c6
5 changed files with 36 additions and 52 deletions
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
#include <NetworkManager.h>
|
#include <NetworkManager.h>
|
||||||
|
|
||||||
#include "../panel-common.h"
|
|
||||||
#include "ce-page-details.h"
|
#include "ce-page-details.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (CEPageDetails, ce_page_details, CE_TYPE_PAGE)
|
G_DEFINE_TYPE (CEPageDetails, ce_page_details, CE_TYPE_PAGE)
|
||||||
|
@ -264,17 +263,20 @@ connect_details_page (CEPageDetails *self)
|
||||||
if (device_is_active && self->device != NULL)
|
if (device_is_active && self->device != NULL)
|
||||||
ipv4_config = nm_device_get_ip4_config (self->device);
|
ipv4_config = nm_device_get_ip4_config (self->device);
|
||||||
if (ipv4_config != NULL) {
|
if (ipv4_config != NULL) {
|
||||||
g_autofree gchar *ipv4_text = NULL;
|
GPtrArray *addresses;
|
||||||
|
const gchar *ipv4_text = NULL;
|
||||||
g_autofree gchar *dns_text = NULL;
|
g_autofree gchar *dns_text = NULL;
|
||||||
const gchar *route_text;
|
const gchar *route_text;
|
||||||
|
|
||||||
ipv4_text = panel_get_ip4_address_as_string (ipv4_config);
|
addresses = nm_ip_config_get_addresses (ipv4_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ipv4_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
gtk_label_set_label (self->ipv4_label, ipv4_text);
|
gtk_label_set_label (self->ipv4_label, ipv4_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
|
||||||
have_ipv4_address = ipv4_text != NULL;
|
have_ipv4_address = ipv4_text != NULL;
|
||||||
|
|
||||||
dns_text = panel_get_ip4_dns_as_string (ipv4_config);
|
dns_text = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ipv4_config));
|
||||||
gtk_label_set_label (self->dns_label, dns_text);
|
gtk_label_set_label (self->dns_label, dns_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
|
||||||
|
@ -295,9 +297,12 @@ connect_details_page (CEPageDetails *self)
|
||||||
if (device_is_active && self->device != NULL)
|
if (device_is_active && self->device != NULL)
|
||||||
ipv6_config = nm_device_get_ip6_config (self->device);
|
ipv6_config = nm_device_get_ip6_config (self->device);
|
||||||
if (ipv6_config != NULL) {
|
if (ipv6_config != NULL) {
|
||||||
g_autofree gchar *ipv6_text = NULL;
|
GPtrArray *addresses;
|
||||||
|
const gchar *ipv6_text = NULL;
|
||||||
|
|
||||||
ipv6_text = panel_get_ip6_address_as_string (ipv6_config);
|
addresses = nm_ip_config_get_addresses (ipv6_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ipv6_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
gtk_label_set_label (self->ipv6_label, ipv6_text);
|
gtk_label_set_label (self->ipv6_label, ipv6_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
||||||
|
|
|
@ -142,21 +142,30 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMIPConfig *ip4_config = NULL;
|
NMIPConfig *ip4_config = NULL;
|
||||||
NMIPConfig *ip6_config = NULL;
|
NMIPConfig *ip6_config = NULL;
|
||||||
g_autofree gchar *ip4_address = NULL;
|
const gchar *ip4_address = NULL;
|
||||||
const gchar *ip4_route = NULL;
|
const gchar *ip4_route = NULL;
|
||||||
g_autofree gchar *ip4_dns = NULL;
|
g_autofree gchar *ip4_dns = NULL;
|
||||||
g_autofree gchar *ip6_address = NULL;
|
const gchar *ip6_address = NULL;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
ip4_config = nm_device_get_ip4_config (device);
|
ip4_config = nm_device_get_ip4_config (device);
|
||||||
if (ip4_config) {
|
if (ip4_config) {
|
||||||
ip4_address = panel_get_ip4_address_as_string (ip4_config);
|
GPtrArray *addresses;
|
||||||
|
|
||||||
|
addresses = nm_ip_config_get_addresses (ip4_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ip4_address = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
|
|
||||||
ip4_route = nm_ip_config_get_gateway (ip4_config);
|
ip4_route = nm_ip_config_get_gateway (ip4_config);
|
||||||
ip4_dns = panel_get_ip4_dns_as_string (ip4_config);
|
ip4_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip4_config));
|
||||||
}
|
}
|
||||||
ip6_config = nm_device_get_ip6_config (device);
|
ip6_config = nm_device_get_ip6_config (device);
|
||||||
if (ip6_config) {
|
if (ip6_config) {
|
||||||
ip6_address = panel_get_ip6_address_as_string (ip6_config);
|
GPtrArray *addresses;
|
||||||
|
|
||||||
|
addresses = nm_ip_config_get_addresses (ip6_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ip6_address = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip4_address && ip6_address) {
|
if (ip4_address && ip6_address) {
|
||||||
|
|
|
@ -419,17 +419,20 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
|
||||||
|
|
||||||
ipv4_config = nm_device_get_ip4_config (nm_device);
|
ipv4_config = nm_device_get_ip4_config (nm_device);
|
||||||
if (ipv4_config != NULL) {
|
if (ipv4_config != NULL) {
|
||||||
g_autofree gchar *ipv4_text = NULL;
|
GPtrArray *addresses;
|
||||||
|
const gchar *ipv4_text = NULL;
|
||||||
g_autofree gchar *dns_text = NULL;
|
g_autofree gchar *dns_text = NULL;
|
||||||
const gchar *route_text;
|
const gchar *route_text;
|
||||||
|
|
||||||
ipv4_text = panel_get_ip4_address_as_string (ipv4_config);
|
addresses = nm_ip_config_get_addresses (ipv4_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ipv4_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
gtk_label_set_label (self->ipv4_label, ipv4_text);
|
gtk_label_set_label (self->ipv4_label, ipv4_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
|
||||||
have_ipv4_address = ipv4_text != NULL;
|
have_ipv4_address = ipv4_text != NULL;
|
||||||
|
|
||||||
dns_text = panel_get_ip4_dns_as_string (ipv4_config);
|
dns_text = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ipv4_config));
|
||||||
gtk_label_set_label (self->dns_label, dns_text);
|
gtk_label_set_label (self->dns_label, dns_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
|
||||||
|
@ -449,9 +452,12 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
|
||||||
|
|
||||||
ipv6_config = nm_device_get_ip6_config (nm_device);
|
ipv6_config = nm_device_get_ip6_config (nm_device);
|
||||||
if (ipv6_config != NULL) {
|
if (ipv6_config != NULL) {
|
||||||
g_autofree gchar *ipv6_text = NULL;
|
GPtrArray *addresses;
|
||||||
|
const gchar *ipv6_text = NULL;
|
||||||
|
|
||||||
ipv6_text = panel_get_ip6_address_as_string (ipv6_config);
|
addresses = nm_ip_config_get_addresses (ipv6_config);
|
||||||
|
if (addresses->len > 0)
|
||||||
|
ipv6_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
|
||||||
gtk_label_set_label (self->ipv6_label, ipv6_text);
|
gtk_label_set_label (self->ipv6_label, ipv6_text);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
||||||
|
|
|
@ -313,36 +313,3 @@ panel_device_status_to_localized_string (NMDevice *nm_device,
|
||||||
|
|
||||||
return g_string_free (string, FALSE);
|
return g_string_free (string, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
|
||||||
panel_get_ip4_address_as_string (NMIPConfig *ip4_config)
|
|
||||||
{
|
|
||||||
GPtrArray *array;
|
|
||||||
NMIPAddress *address;
|
|
||||||
|
|
||||||
array = nm_ip_config_get_addresses (ip4_config);
|
|
||||||
if (array->len < 1)
|
|
||||||
return NULL;
|
|
||||||
address = array->pdata[0];
|
|
||||||
return g_strdup (nm_ip_address_get_address (address));
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
panel_get_ip4_dns_as_string (NMIPConfig *ip4_config)
|
|
||||||
{
|
|
||||||
return g_strjoinv (" ",
|
|
||||||
(char **) nm_ip_config_get_nameservers (ip4_config));
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
panel_get_ip6_address_as_string (NMIPConfig *ip6_config)
|
|
||||||
{
|
|
||||||
GPtrArray *array;
|
|
||||||
NMIPAddress *address;
|
|
||||||
|
|
||||||
array = nm_ip_config_get_addresses (ip6_config);
|
|
||||||
if (array->len < 1)
|
|
||||||
return NULL;
|
|
||||||
address = array->pdata[0];
|
|
||||||
return g_strdup (nm_ip_address_get_address (address));
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,8 +28,5 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
gchar *panel_device_status_to_localized_string (NMDevice *nm_device,
|
gchar *panel_device_status_to_localized_string (NMDevice *nm_device,
|
||||||
const gchar *speed);
|
const gchar *speed);
|
||||||
gchar *panel_get_ip4_address_as_string (NMIPConfig *config);
|
|
||||||
gchar *panel_get_ip4_dns_as_string (NMIPConfig *config);
|
|
||||||
gchar *panel_get_ip6_address_as_string (NMIPConfig *config);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue