summaryrefslogtreecommitdiff
path: root/clients/tui
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-19 17:30:10 -0400
committerDan Winship <danw@gnome.org>2014-11-07 07:49:40 -0500
commit3f30c6f1c2f9ce76b24fada0e75fd3cf733ca4bc (patch)
treef413fc1880cdeee48d5891d06b3d474142448ee3 /clients/tui
parent39709fdc2ecaf42e431410f9ad425a9fb5c57812 (diff)
downloadNetworkManager-3f30c6f1c2f9ce76b24fada0e75fd3cf733ca4bc.tar.gz
libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes
Split a base NMSettingIPConfig class out of NMSettingIP4Config and NMSettingIP6Config, and update things accordingly. Further simplifications of now-redundant IPv4-vs-IPv6 code are possible, and should happen in the future.
Diffstat (limited to 'clients/tui')
-rw-r--r--clients/tui/nmt-page-ip4.c28
-rw-r--r--clients/tui/nmt-page-ip6.c28
-rw-r--r--clients/tui/nmt-route-editor.c36
3 files changed, 41 insertions, 51 deletions
diff --git a/clients/tui/nmt-page-ip4.c b/clients/tui/nmt-page-ip4.c
index 686c2ce923..782a204fc9 100644
--- a/clients/tui/nmt-page-ip4.c
+++ b/clients/tui/nmt-page-ip4.c
@@ -59,12 +59,12 @@ static gboolean
nmt_page_ip4_show_by_default (NmtEditorPage *page)
{
NMConnection *conn;
- NMSettingIP4Config *s_ip4;
+ NMSettingIPConfig *s_ip4;
conn = nmt_editor_page_get_connection (page);
s_ip4 = nm_connection_get_setting_ip4_config (conn);
- if ( !g_strcmp0 (nm_setting_ip4_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
- || nm_setting_ip4_config_get_num_addresses (s_ip4))
+ if ( !g_strcmp0 (nm_setting_ip_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
+ || nm_setting_ip_config_get_num_addresses (s_ip4))
return TRUE;
return FALSE;
}
@@ -115,22 +115,22 @@ nmt_page_ip4_constructed (GObject *object)
{
NmtPageIP4 *ip4 = NMT_PAGE_IP4 (object);
NmtPageGrid *grid;
- NMSettingIP4Config *s_ip4;
+ NMSettingIPConfig *s_ip4;
NmtNewtWidget *widget, *button;
NMConnection *conn;
conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ip4));
s_ip4 = nm_connection_get_setting_ip4_config (conn);
if (!s_ip4) {
- s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
+ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
g_object_set (G_OBJECT (s_ip4),
- NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NULL);
nm_connection_add_setting (conn, (NMSetting *) s_ip4);
}
widget = nmt_newt_popup_new (ip4methods);
- g_object_bind_property (s_ip4, NM_SETTING_IP4_CONFIG_METHOD,
+ g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_METHOD,
widget, "active-id",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_editor_page_set_header_widget (NMT_EDITOR_PAGE (ip4), widget);
@@ -139,27 +139,27 @@ nmt_page_ip4_constructed (GObject *object)
widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4_WITH_PREFIX);
nm_editor_bind_ip_addresses_with_prefix_to_strv (AF_INET,
- s_ip4, NM_SETTING_IP4_CONFIG_ADDRESSES,
+ s_ip4, NM_SETTING_IP_CONFIG_ADDRESSES,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Addresses"), widget, NULL);
widget = nmt_ip_entry_new (25, AF_INET, FALSE, TRUE);
nm_editor_bind_ip_gateway_to_string (AF_INET,
- s_ip4, NM_SETTING_IP4_CONFIG_ADDRESSES,
+ s_ip4, NM_SETTING_IP_CONFIG_ADDRESSES,
widget, "text",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Gateway"), widget, NULL);
widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4);
nm_editor_bind_ip_addresses_to_strv (AF_INET,
- s_ip4, NM_SETTING_IP4_CONFIG_DNS,
+ s_ip4, NM_SETTING_IP_CONFIG_DNS,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("DNS servers"), widget, NULL);
widget = nmt_address_list_new (NMT_ADDRESS_LIST_HOSTNAME);
- g_object_bind_property (s_ip4, NM_SETTING_IP4_CONFIG_DNS_SEARCH,
+ g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_DNS_SEARCH,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Search domains"), widget, NULL);
@@ -170,7 +170,7 @@ nmt_page_ip4_constructed (GObject *object)
"text", "",
"style", NMT_NEWT_LABEL_PLAIN,
NULL);
- g_object_bind_property_full (s_ip4, NM_SETTING_IP4_CONFIG_ROUTES,
+ g_object_bind_property_full (s_ip4, NM_SETTING_IP_CONFIG_ROUTES,
widget, "text",
G_BINDING_SYNC_CREATE,
ip4_routes_transform_to_description,
@@ -180,7 +180,7 @@ nmt_page_ip4_constructed (GObject *object)
nmt_page_grid_append (grid, _("Routing"), widget, button);
widget = nmt_newt_checkbox_new (_("Never use this network for default route"));
- g_object_bind_property (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT,
+ g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_NEVER_DEFAULT,
widget, "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
nmt_page_grid_append (grid, NULL, widget, NULL);
@@ -188,7 +188,7 @@ nmt_page_ip4_constructed (GObject *object)
nmt_page_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
widget = nmt_newt_checkbox_new (_("Require IPv4 addressing for this connection"));
- g_object_bind_property (s_ip4, NM_SETTING_IP4_CONFIG_MAY_FAIL,
+ g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_MAY_FAIL,
widget, "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL |
G_BINDING_INVERT_BOOLEAN);
diff --git a/clients/tui/nmt-page-ip6.c b/clients/tui/nmt-page-ip6.c
index 05917fa0c8..88b948cd14 100644
--- a/clients/tui/nmt-page-ip6.c
+++ b/clients/tui/nmt-page-ip6.c
@@ -59,12 +59,12 @@ static gboolean
nmt_page_ip6_show_by_default (NmtEditorPage *page)
{
NMConnection *conn;
- NMSettingIP6Config *s_ip6;
+ NMSettingIPConfig *s_ip6;
conn = nmt_editor_page_get_connection (page);
s_ip6 = nm_connection_get_setting_ip6_config (conn);
- if ( !g_strcmp0 (nm_setting_ip6_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)
- || nm_setting_ip6_config_get_num_addresses (s_ip6))
+ if ( !g_strcmp0 (nm_setting_ip_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)
+ || nm_setting_ip_config_get_num_addresses (s_ip6))
return TRUE;
return FALSE;
}
@@ -115,22 +115,22 @@ nmt_page_ip6_constructed (GObject *object)
{
NmtPageIP6 *ip6 = NMT_PAGE_IP6 (object);
NmtPageGrid *grid;
- NMSettingIP6Config *s_ip6;
+ NMSettingIPConfig *s_ip6;
NmtNewtWidget *widget, *button;
NMConnection *conn;
conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ip6));
s_ip6 = nm_connection_get_setting_ip6_config (conn);
if (!s_ip6) {
- s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
+ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new ();
g_object_set (G_OBJECT (s_ip6),
- NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NULL);
nm_connection_add_setting (conn, (NMSetting *) s_ip6);
}
widget = nmt_newt_popup_new (ip6methods);
- g_object_bind_property (s_ip6, NM_SETTING_IP6_CONFIG_METHOD,
+ g_object_bind_property (s_ip6, NM_SETTING_IP_CONFIG_METHOD,
widget, "active-id",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_editor_page_set_header_widget (NMT_EDITOR_PAGE (ip6), widget);
@@ -139,27 +139,27 @@ nmt_page_ip6_constructed (GObject *object)
widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP6_WITH_PREFIX);
nm_editor_bind_ip_addresses_with_prefix_to_strv (AF_INET6,
- s_ip6, NM_SETTING_IP6_CONFIG_ADDRESSES,
+ s_ip6, NM_SETTING_IP_CONFIG_ADDRESSES,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Addresses"), widget, NULL);
widget = nmt_ip_entry_new (25, AF_INET6, FALSE, TRUE);
nm_editor_bind_ip_gateway_to_string (AF_INET6,
- s_ip6, NM_SETTING_IP6_CONFIG_ADDRESSES,
+ s_ip6, NM_SETTING_IP_CONFIG_ADDRESSES,
widget, "text",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Gateway"), widget, NULL);
widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP6);
nm_editor_bind_ip_addresses_to_strv (AF_INET6,
- s_ip6, NM_SETTING_IP6_CONFIG_DNS,
+ s_ip6, NM_SETTING_IP_CONFIG_DNS,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("DNS servers"), widget, NULL);
widget = nmt_address_list_new (NMT_ADDRESS_LIST_HOSTNAME);
- g_object_bind_property (s_ip6, NM_SETTING_IP6_CONFIG_DNS_SEARCH,
+ g_object_bind_property (s_ip6, NM_SETTING_IP_CONFIG_DNS_SEARCH,
widget, "strings",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
nmt_page_grid_append (grid, _("Search domains"), widget, NULL);
@@ -168,7 +168,7 @@ nmt_page_ip6_constructed (GObject *object)
"text", "",
"style", NMT_NEWT_LABEL_PLAIN,
NULL);
- g_object_bind_property_full (s_ip6, NM_SETTING_IP6_CONFIG_ROUTES,
+ g_object_bind_property_full (s_ip6, NM_SETTING_IP_CONFIG_ROUTES,
widget, "text",
G_BINDING_SYNC_CREATE,
ip6_routes_transform_to_description,
@@ -178,7 +178,7 @@ nmt_page_ip6_constructed (GObject *object)
nmt_page_grid_append (grid, _("Routing"), widget, button);
widget = nmt_newt_checkbox_new (_("Never use this network for default route"));
- g_object_bind_property (s_ip6, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT,
+ g_object_bind_property (s_ip6, NM_SETTING_IP_CONFIG_NEVER_DEFAULT,
widget, "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
nmt_page_grid_append (grid, NULL, widget, NULL);
@@ -186,7 +186,7 @@ nmt_page_ip6_constructed (GObject *object)
nmt_page_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
widget = nmt_newt_checkbox_new (_("Require IPv6 addressing for this connection"));
- g_object_bind_property (s_ip6, NM_SETTING_IP6_CONFIG_MAY_FAIL,
+ g_object_bind_property (s_ip6, NM_SETTING_IP_CONFIG_MAY_FAIL,
widget, "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL |
G_BINDING_INVERT_BOOLEAN);
diff --git a/clients/tui/nmt-route-editor.c b/clients/tui/nmt-route-editor.c
index 3871b86302..77bbec76de 100644
--- a/clients/tui/nmt-route-editor.c
+++ b/clients/tui/nmt-route-editor.c
@@ -77,21 +77,15 @@ save_routes_and_exit (NmtNewtButton *button,
{
NmtRouteEditor *editor = user_data;
NmtRouteEditorPrivate *priv = NMT_ROUTE_EDITOR_GET_PRIVATE (editor);
- const char *property;
- GBinding *binding;
+ GPtrArray *routes;
- if (NM_IS_SETTING_IP4_CONFIG (priv->edit_setting))
- property = NM_SETTING_IP4_CONFIG_ROUTES;
- else
- property = NM_SETTING_IP6_CONFIG_ROUTES;
-
- /* Because of the complicated dbus-glib GTypes, it's easier to cheat
- * and use GBinding to do this than it is to copy the value by hand.
- */
- binding = g_object_bind_property (priv->edit_setting, property,
- priv->orig_setting, property,
- G_BINDING_SYNC_CREATE);
- g_object_unref (binding);
+ g_object_get (priv->edit_setting,
+ NM_SETTING_IP_CONFIG_ROUTES, &routes,
+ NULL);
+ g_object_set (priv->orig_setting,
+ NM_SETTING_IP_CONFIG_ROUTES, routes,
+ NULL);
+ g_ptr_array_unref (routes);
nmt_newt_form_quit (NMT_NEWT_FORM (editor));
}
@@ -106,17 +100,13 @@ nmt_route_editor_constructed (GObject *object)
if (G_OBJECT_CLASS (nmt_route_editor_parent_class)->constructed)
G_OBJECT_CLASS (nmt_route_editor_parent_class)->constructed (object);
- if (NM_IS_SETTING_IP4_CONFIG (priv->edit_setting)) {
+ if (NM_IS_SETTING_IP4_CONFIG (priv->edit_setting))
routes = nmt_route_table_new (AF_INET);
- g_object_bind_property (priv->edit_setting, NM_SETTING_IP4_CONFIG_ROUTES,
- routes, "routes",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- } else {
+ else
routes = nmt_route_table_new (AF_INET6);
- g_object_bind_property (priv->edit_setting, NM_SETTING_IP6_CONFIG_ROUTES,
- routes, "routes",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- }
+ g_object_bind_property (priv->edit_setting, NM_SETTING_IP_CONFIG_ROUTES,
+ routes, "routes",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
vbox = nmt_newt_grid_new ();
nmt_newt_grid_add (NMT_NEWT_GRID (vbox), routes, 0, 0);