nmtui: always create ethernet settings for VLAN and wireless security for wifi.

Ethernet settings for VLAN are always created later in settings
normalization. We might as well always created them.

This fixes a user visible problem: currently if user specifies cloned
mac when connection is created this value doesn't get saved. User has
to go, edit saved connection to add it again.

Similar problem existed for wireless security and wifi

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
This commit is contained in:
Nikolay Martynov
2017-05-22 22:24:44 -04:00
committed by Thomas Haller
parent a5691020f8
commit 6a4af482f0
2 changed files with 5 additions and 55 deletions

View File

@@ -32,13 +32,6 @@
G_DEFINE_TYPE (NmtPageVlan, nmt_page_vlan, NMT_TYPE_EDITOR_PAGE_DEVICE)
#define NMT_PAGE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_VLAN, NmtPageVlanPrivate))
typedef struct {
NMSettingWired *s_wired;
} NmtPageVlanPrivate;
NmtEditorPage *
nmt_page_vlan_new (NMConnection *conn,
NmtDeviceEntry *deventry)
@@ -67,7 +60,6 @@ static void
nmt_page_vlan_constructed (GObject *object)
{
NmtPageVlan *vlan = NMT_PAGE_VLAN (object);
NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (vlan);
NmtEditorSection *section;
NmtEditorGrid *grid;
NMSettingWired *s_wired;
@@ -83,13 +75,9 @@ nmt_page_vlan_constructed (GObject *object)
}
s_wired = nm_connection_get_setting_wired (conn);
if (!s_wired) {
/* It makes things simpler if we always have a NMSettingWired;
* we'll hold a ref on one, and add it to and remove it from
* the connection as needed.
*/
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
nm_connection_add_setting (conn, nm_setting_wired_new ());
s_wired = nm_connection_get_setting_wired (conn);
}
priv->s_wired = g_object_ref_sink (s_wired);
section = nmt_editor_section_new (_("VLAN"), NULL, TRUE);
grid = nmt_editor_section_get_body (section);
@@ -132,24 +120,11 @@ nmt_page_vlan_constructed (GObject *object)
G_OBJECT_CLASS (nmt_page_vlan_parent_class)->constructed (object);
}
static void
nmt_page_vlan_finalize (GObject *object)
{
NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (object);
g_clear_object (&priv->s_wired);
G_OBJECT_CLASS (nmt_page_vlan_parent_class)->finalize (object);
}
static void
nmt_page_vlan_class_init (NmtPageVlanClass *vlan_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (vlan_class);
g_type_class_add_private (vlan_class, sizeof (NmtPageVlanPrivate));
/* virtual methods */
object_class->constructed = nmt_page_vlan_constructed;
object_class->finalize = nmt_page_vlan_finalize;
}

View File

@@ -38,13 +38,6 @@
G_DEFINE_TYPE (NmtPageWifi, nmt_page_wifi, NMT_TYPE_EDITOR_PAGE_DEVICE)
#define NMT_PAGE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_WIFI, NmtPageWifiPrivate))
typedef struct {
NMSettingWirelessSecurity *s_wsec;
} NmtPageWifiPrivate;
NmtEditorPage *
nmt_page_wifi_new (NMConnection *conn,
NmtDeviceEntry *deventry)
@@ -177,7 +170,6 @@ ssid_transform_from_entry (GBinding *binding,
static void
nmt_page_wifi_constructed (GObject *object)
{
NmtPageWifiPrivate *priv = NMT_PAGE_WIFI_GET_PRIVATE (object);
NmtPageWifi *wifi = NMT_PAGE_WIFI (object);
NmtDeviceEntry *deventry;
NmtEditorSection *section;
@@ -198,13 +190,10 @@ nmt_page_wifi_constructed (GObject *object)
s_wsec = nm_connection_get_setting_wireless_security (conn);
if (!s_wsec) {
/* It makes things simpler if we always have a
* NMSettingWirelessSecurity; we'll hold a ref on one, and add
* it to and remove it from the connection as needed.
*/
s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
nm_connection_add_setting (conn, nm_setting_wireless_security_new ());
s_wsec = nm_connection_get_setting_wireless_security (conn);
}
priv->s_wsec = g_object_ref_sink (s_wsec);
s_wsec = nm_connection_get_setting_wireless_security (conn);
deventry = nmt_editor_page_device_get_device_entry (NMT_EDITOR_PAGE_DEVICE (object));
g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS,
@@ -374,24 +363,10 @@ nmt_page_wifi_constructed (GObject *object)
G_OBJECT_CLASS (nmt_page_wifi_parent_class)->constructed (object);
}
static void
nmt_page_wifi_finalize (GObject *object)
{
NmtPageWifiPrivate *priv = NMT_PAGE_WIFI_GET_PRIVATE (object);
g_clear_object (&priv->s_wsec);
G_OBJECT_CLASS (nmt_page_wifi_parent_class)->finalize (object);
}
static void
nmt_page_wifi_class_init (NmtPageWifiClass *wifi_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (wifi_class);
g_type_class_add_private (wifi_class, sizeof (NmtPageWifiPrivate));
object_class->constructed = nmt_page_wifi_constructed;
object_class->finalize = nmt_page_wifi_finalize;
}