[gnome-control-center] network: Make CEIPAddressEntry
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Make CEIPAddressEntry
- Date: Fri, 11 Dec 2020 19:10:50 +0000 (UTC)
commit c1a13ccaba701790b275e416a9775b58b10ddd1f
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Dec 2 11:11:02 2020 +1300
network: Make CEIPAddressEntry
.../connection-editor/ce-ip-address-entry.c | 99 ++++++++++++++++++++++
.../connection-editor/ce-ip-address-entry.h | 36 ++++++++
panels/network/connection-editor/ce-page-ip4.c | 72 ++++++----------
panels/network/connection-editor/ce-page-ip6.c | 76 ++++++-----------
panels/network/connection-editor/meson.build | 1 +
5 files changed, 186 insertions(+), 98 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-ip-address-entry.c
b/panels/network/connection-editor/ce-ip-address-entry.c
new file mode 100644
index 000000000..7bbcd6edd
--- /dev/null
+++ b/panels/network/connection-editor/ce-ip-address-entry.c
@@ -0,0 +1,99 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2020 Canonical Ltd.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <NetworkManager.h>
+
+#include "ce-ip-address-entry.h"
+
+struct _CEIPAddressEntry
+{
+ GtkEntry parent_instance;
+
+ int family;
+};
+
+static void ce_ip_address_entry_editable_init (GtkEditableInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (CEIPAddressEntry, ce_ip_address_entry, GTK_TYPE_ENTRY,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
+ ce_ip_address_entry_editable_init))
+
+static void
+ce_ip_address_entry_changed (GtkEditable *editable)
+{
+ CEIPAddressEntry *self = CE_IP_ADDRESS_ENTRY (editable);
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ if (ce_ip_address_entry_is_valid (self))
+ gtk_style_context_remove_class (context, "error");
+ else
+ gtk_style_context_add_class (context, "error");
+}
+
+static void
+ce_ip_address_entry_init (CEIPAddressEntry *self)
+{
+}
+
+static void
+ce_ip_address_entry_editable_init (GtkEditableInterface *iface)
+{
+ iface->changed = ce_ip_address_entry_changed;
+}
+
+static void
+ce_ip_address_entry_class_init (CEIPAddressEntryClass *klass)
+{
+}
+
+CEIPAddressEntry *
+ce_ip_address_entry_new (int family)
+{
+ CEIPAddressEntry *self;
+
+ self = CE_IP_ADDRESS_ENTRY (g_object_new (ce_ip_address_entry_get_type (), NULL));
+ self->family = family;
+
+ return self;
+}
+
+gboolean
+ce_ip_address_entry_is_empty (CEIPAddressEntry *self)
+{
+ const gchar *text;
+
+ g_return_val_if_fail (CE_IS_IP_ADDRESS_ENTRY (self), FALSE);
+
+ text = gtk_entry_get_text (GTK_ENTRY (self));
+ return text[0] == '\0';
+}
+
+gboolean
+ce_ip_address_entry_is_valid (CEIPAddressEntry *self)
+{
+ const gchar *text;
+
+ g_return_val_if_fail (CE_IS_IP_ADDRESS_ENTRY (self), FALSE);
+
+ text = gtk_entry_get_text (GTK_ENTRY (self));
+ return text[0] == '\0' || nm_utils_ipaddr_valid (self->family, text);
+}
diff --git a/panels/network/connection-editor/ce-ip-address-entry.h
b/panels/network/connection-editor/ce-ip-address-entry.h
new file mode 100644
index 000000000..e89a7fb05
--- /dev/null
+++ b/panels/network/connection-editor/ce-ip-address-entry.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2020 Canonical Ltd.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+G_DECLARE_FINAL_TYPE (CEIPAddressEntry, ce_ip_address_entry, CE, IP_ADDRESS_ENTRY, GtkEntry)
+
+CEIPAddressEntry *ce_ip_address_entry_new (int family);
+
+gboolean ce_ip_address_entry_is_empty (CEIPAddressEntry *entry);
+
+gboolean ce_ip_address_entry_is_valid (CEIPAddressEntry *entry);
+
+G_END_DECLS
diff --git a/panels/network/connection-editor/ce-page-ip4.c b/panels/network/connection-editor/ce-page-ip4.c
index bd4b29cab..f6dc38379 100644
--- a/panels/network/connection-editor/ce-page-ip4.c
+++ b/panels/network/connection-editor/ce-page-ip4.c
@@ -28,6 +28,7 @@
#include <NetworkManager.h>
#include "list-box-helper.h"
+#include "ce-ip-address-entry.h"
#include "ce-page.h"
#include "ce-page-ip4.h"
#include "ui-helpers.h"
@@ -207,7 +208,7 @@ add_address_row (CEPageIP4 *self,
row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (row_box), "linked");
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_address_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "address", widget);
@@ -225,7 +226,7 @@ add_address_row (CEPageIP4 *self,
gtk_widget_set_hexpand (widget, TRUE);
gtk_container_add (GTK_CONTAINER (row_box), widget);
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_address_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "gateway", widget);
@@ -349,7 +350,7 @@ add_route_row (CEPageIP4 *self,
row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (row_box), "linked");
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_routes_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "address", widget);
@@ -367,7 +368,7 @@ add_route_row (CEPageIP4 *self,
gtk_widget_set_hexpand (widget, TRUE);
gtk_container_add (GTK_CONTAINER (row_box), widget);
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_routes_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "gateway", widget);
@@ -586,37 +587,27 @@ ui_to_setting (CEPageIP4 *self)
for (GList *l = address_children; l; l = l->next) {
GtkWidget *row = l->data;
- GtkEntry *entry;
- GtkEntry *gateway_entry;
- const gchar *text_address;
+ CEIPAddressEntry *address_entry;
+ CEIPAddressEntry *gateway_entry;
const gchar *text_netmask;
- const gchar *text_gateway = "";
NMIPAddress *addr;
guint32 prefix;
- entry = GTK_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
- if (!entry)
+ address_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
+ if (!address_entry)
continue;
- text_address = gtk_entry_get_text (entry);
text_netmask = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row),
"network")));
- gateway_entry = g_object_get_data (G_OBJECT (row), "gateway");
- text_gateway = gtk_entry_get_text (gateway_entry);
+ gateway_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "gateway"));
- if (!*text_address && !*text_netmask && !*text_gateway) {
+ if (ce_ip_address_entry_is_empty (address_entry) && !*text_netmask &&
ce_ip_address_entry_is_empty (gateway_entry)) {
/* ignore empty rows */
- widget_unset_error (GTK_WIDGET (entry));
widget_unset_error (g_object_get_data (G_OBJECT (row), "network"));
- widget_unset_error (GTK_WIDGET (gateway_entry));
continue;
}
- if (!nm_utils_ipaddr_valid (AF_INET, text_address)) {
- widget_set_error (GTK_WIDGET (entry));
+ if (!ce_ip_address_entry_is_valid (address_entry))
ret = FALSE;
- } else {
- widget_unset_error (GTK_WIDGET (entry));
- }
if (!parse_netmask (text_netmask, &prefix)) {
widget_set_error (g_object_get_data (G_OBJECT (row), "network"));
@@ -625,22 +616,19 @@ ui_to_setting (CEPageIP4 *self)
widget_unset_error (g_object_get_data (G_OBJECT (row), "network"));
}
- if (*text_gateway &&
- !nm_utils_ipaddr_valid (AF_INET, text_gateway)) {
- widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
+ if (!ce_ip_address_entry_is_valid (gateway_entry)) {
ret = FALSE;
} else {
- widget_unset_error (GTK_WIDGET (gateway_entry));
- if (*text_gateway) {
+ if (!ce_ip_address_entry_is_empty (gateway_entry)) {
g_assert (default_gateway == NULL);
- default_gateway = text_gateway;
+ default_gateway = gtk_entry_get_text (GTK_ENTRY (gateway_entry));
}
}
if (!ret)
continue;
- addr = nm_ip_address_new (AF_INET, text_address, prefix, NULL);
+ addr = nm_ip_address_new (AF_INET, gtk_entry_get_text (GTK_ENTRY (address_entry)), prefix,
NULL);
if (addr)
g_ptr_array_add (addresses, addr);
@@ -695,35 +683,29 @@ ui_to_setting (CEPageIP4 *self)
for (GList *l = routes_children; l; l = l->next) {
GtkWidget *row = l->data;
- GtkEntry *entry;
- const gchar *text_address;
+ CEIPAddressEntry *address_entry;
+ CEIPAddressEntry *gateway_entry;
const gchar *text_netmask;
- const gchar *text_gateway;
const gchar *text_metric;
gint64 metric;
guint32 netmask;
NMIPRoute *route;
- entry = GTK_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
- if (!entry)
+ address_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
+ if (!address_entry)
continue;
- text_address = gtk_entry_get_text (entry);
text_netmask = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row),
"netmask")));
- text_gateway = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row),
"gateway")));
+ gateway_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "gateway"));
text_metric = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row), "metric")));
- if (!*text_address && !*text_netmask && !*text_gateway && !*text_metric) {
+ if (ce_ip_address_entry_is_empty (address_entry) && !*text_netmask &&
ce_ip_address_entry_is_empty (gateway_entry) && !*text_metric) {
/* ignore empty rows */
continue;
}
- if (text_address && !nm_utils_ipaddr_valid (AF_INET, text_address)) {
- widget_set_error (GTK_WIDGET (entry));
+ if (!ce_ip_address_entry_is_valid (address_entry))
ret = FALSE;
- } else {
- widget_unset_error (GTK_WIDGET (entry));
- }
if (!parse_netmask (text_netmask, &netmask)) {
widget_set_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "netmask")));
@@ -732,12 +714,8 @@ ui_to_setting (CEPageIP4 *self)
widget_unset_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "netmask")));
}
- if (text_gateway && !nm_utils_ipaddr_valid (AF_INET, text_gateway)) {
- widget_set_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway")));
+ if (!ce_ip_address_entry_is_valid (gateway_entry))
ret = FALSE;
- } else {
- widget_unset_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway")));
- }
metric = -1;
if (*text_metric) {
@@ -756,7 +734,7 @@ ui_to_setting (CEPageIP4 *self)
if (!ret)
continue;
- route = nm_ip_route_new (AF_INET, text_address, netmask, text_gateway, metric, NULL);
+ route = nm_ip_route_new (AF_INET, gtk_entry_get_text (GTK_ENTRY (address_entry)), netmask,
gtk_entry_get_text (GTK_ENTRY (gateway_entry)), metric, NULL);
if (route)
g_ptr_array_add (routes, route);
diff --git a/panels/network/connection-editor/ce-page-ip6.c b/panels/network/connection-editor/ce-page-ip6.c
index 6760d53ee..2fb61394c 100644
--- a/panels/network/connection-editor/ce-page-ip6.c
+++ b/panels/network/connection-editor/ce-page-ip6.c
@@ -28,6 +28,7 @@
#include <NetworkManager.h>
#include "list-box-helper.h"
+#include "ce-ip-address-entry.h"
#include "ce-page.h"
#include "ce-page-ip6.h"
#include "ui-helpers.h"
@@ -189,7 +190,7 @@ add_address_row (CEPageIP6 *self,
row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (row_box), "linked");
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET6));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_address_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "address", widget);
@@ -207,7 +208,7 @@ add_address_row (CEPageIP6 *self,
gtk_widget_set_hexpand (widget, TRUE);
gtk_container_add (GTK_CONTAINER (row_box), widget);
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET6));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_address_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "gateway", widget);
@@ -323,7 +324,7 @@ add_route_row (CEPageIP6 *self,
row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (row_box), "linked");
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET6));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_routes_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "address", widget);
@@ -341,7 +342,7 @@ add_route_row (CEPageIP6 *self,
gtk_widget_set_hexpand (widget, TRUE);
gtk_container_add (GTK_CONTAINER (row_box), widget);
- widget = gtk_entry_new ();
+ widget = GTK_WIDGET (ce_ip_address_entry_new (AF_INET6));
g_signal_connect_object (widget, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (widget, "activate", G_CALLBACK (ensure_empty_routes_row), self,
G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT (row), "gateway", widget);
@@ -545,37 +546,28 @@ ui_to_setting (CEPageIP6 *self)
for (GList *l = address_children; l; l = l->next) {
GtkWidget *row = l->data;
- GtkEntry *entry;
- const gchar *text_address;
+ CEIPAddressEntry *address_entry;
+ CEIPAddressEntry *gateway_entry;
const gchar *text_prefix;
- const gchar *text_gateway;
guint32 prefix;
gchar *end;
NMIPAddress *addr;
- gboolean have_gateway = FALSE;
- entry = GTK_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
- if (!entry)
+ address_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
+ if (!address_entry)
continue;
- text_address = gtk_entry_get_text (entry);
text_prefix = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row), "prefix")));
- text_gateway = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row),
"gateway")));
+ gateway_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "gateway"));
- if (!*text_address && !*text_prefix && !*text_gateway) {
+ if (ce_ip_address_entry_is_empty (address_entry) && !*text_prefix &&
ce_ip_address_entry_is_empty (gateway_entry)) {
/* ignore empty rows */
- widget_unset_error (GTK_WIDGET (entry));
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
- widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
continue;
}
- if (!*text_address || !nm_utils_ipaddr_valid (AF_INET6, text_address)) {
- widget_set_error (GTK_WIDGET (entry));
+ if (!ce_ip_address_entry_is_valid (address_entry))
ret = FALSE;
- } else {
- widget_unset_error (GTK_WIDGET (entry));
- }
prefix = strtoul (text_prefix, &end, 10);
if (!end || *end || prefix == 0 || prefix > 128) {
@@ -585,22 +577,16 @@ ui_to_setting (CEPageIP6 *self)
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
}
- if (*text_gateway && !nm_utils_ipaddr_valid (AF_INET6, text_gateway)) {
- widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
+ if (!ce_ip_address_entry_is_valid (gateway_entry))
ret = FALSE;
- } else {
- widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
- if (*text_gateway)
- have_gateway = TRUE;
- }
if (!ret)
continue;
- addr = nm_ip_address_new (AF_INET6, text_address, prefix, NULL);
- if (have_gateway)
+ addr = nm_ip_address_new (AF_INET6, gtk_entry_get_text (GTK_ENTRY (address_entry)), prefix,
NULL);
+ if (!ce_ip_address_entry_is_empty (gateway_entry))
g_object_set (G_OBJECT (self->setting),
- NM_SETTING_IP_CONFIG_GATEWAY, text_gateway,
+ NM_SETTING_IP_CONFIG_GATEWAY, gtk_entry_get_text (GTK_ENTRY
(gateway_entry)),
NULL);
nm_setting_ip_config_add_address (self->setting, addr);
@@ -646,40 +632,32 @@ ui_to_setting (CEPageIP6 *self)
for (GList *l = routes_children; l; l = l->next) {
GtkWidget *row = l->data;
- GtkEntry *entry;
- const gchar *text_address;
+ CEIPAddressEntry *address_entry;
+ CEIPAddressEntry *gateway_entry;
const gchar *text_prefix;
- const gchar *text_gateway;
const gchar *text_metric;
guint32 prefix;
gint64 metric;
gchar *end;
NMIPRoute *route;
- entry = GTK_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
- if (!entry)
+ address_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "address"));
+ if (!address_entry)
continue;
- text_address = gtk_entry_get_text (entry);
text_prefix = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row), "prefix")));
- text_gateway = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row),
"gateway")));
+ gateway_entry = CE_IP_ADDRESS_ENTRY (g_object_get_data (G_OBJECT (row), "gateway"));
text_metric = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (row), "metric")));
- if (!*text_address && !*text_prefix && !*text_gateway && !*text_metric) {
+ if (ce_ip_address_entry_is_empty (address_entry) && !*text_prefix &&
ce_ip_address_entry_is_empty (gateway_entry) && !*text_metric) {
/* ignore empty rows */
- widget_unset_error (GTK_WIDGET (entry));
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
- widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
widget_unset_error (g_object_get_data (G_OBJECT (row), "metric"));
continue;
}
- if (!nm_utils_ipaddr_valid (AF_INET6, text_address)) {
- widget_set_error (GTK_WIDGET (entry));
+ if (!ce_ip_address_entry_is_valid (address_entry))
ret = FALSE;
- } else {
- widget_unset_error (GTK_WIDGET (entry));
- }
prefix = strtoul (text_prefix, &end, 10);
if (!end || *end || prefix == 0 || prefix > 128) {
@@ -689,12 +667,8 @@ ui_to_setting (CEPageIP6 *self)
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
}
- if (!nm_utils_ipaddr_valid (AF_INET6, text_gateway)) {
- widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
+ if (!ce_ip_address_entry_is_valid (gateway_entry))
ret = FALSE;
- } else {
- widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
- }
metric = -1;
if (*text_metric) {
@@ -713,7 +687,7 @@ ui_to_setting (CEPageIP6 *self)
if (!ret)
continue;
- route = nm_ip_route_new (AF_INET6, text_address, prefix, text_gateway, metric, NULL);
+ route = nm_ip_route_new (AF_INET6, gtk_entry_get_text (GTK_ENTRY (address_entry)), prefix,
gtk_entry_get_text (GTK_ENTRY (gateway_entry)), metric, NULL);
nm_setting_ip_config_add_route (self->setting, route);
nm_ip_route_unref (route);
diff --git a/panels/network/connection-editor/meson.build b/panels/network/connection-editor/meson.build
index 856833fff..934392cbd 100644
--- a/panels/network/connection-editor/meson.build
+++ b/panels/network/connection-editor/meson.build
@@ -1,6 +1,7 @@
name = 'connection-editor'
sources = files(
+ 'ce-ip-address-entry.c',
'ce-page-8021x-security.c',
'ce-page-details.c',
'ce-page-ethernet.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]