mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-20 17:38:29 +02:00
merge: branch 'jv/tui-bond-other'
nmtui/bond: introduce "other options" list Closes #1805 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2392
This commit is contained in:
commit
fe793cd783
11 changed files with 226 additions and 129 deletions
3
NEWS
3
NEWS
|
|
@ -61,6 +61,9 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
|
|||
* Allow persisting the managed state across reboots from nmcli and the D-Bus API.
|
||||
* Allow changing the device's administrative state in the kernel at the same
|
||||
time as a change to the managed state from nmcli and the D-Bus API.
|
||||
* Allow configuring all bond options in nmtui by introducing a
|
||||
"other options" field, which covers options not already covered by a
|
||||
dedicated input field.
|
||||
|
||||
=============================================
|
||||
NetworkManager-1.56
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ executable(
|
|||
'nm-editor-bindings.c',
|
||||
'nm-editor-utils.c',
|
||||
'nmt-8021x-fields.c',
|
||||
'nmt-address-list.c',
|
||||
'nmt-connect-connection-list.c',
|
||||
'nmt-device-entry.c',
|
||||
'nmt-edit-connection-list.c',
|
||||
|
|
@ -16,6 +15,7 @@ executable(
|
|||
'nmt-editor-page-device.c',
|
||||
'nmt-editor-section.c',
|
||||
'nmt-ip-entry.c',
|
||||
'nmt-list.c',
|
||||
'nmt-mac-entry.c',
|
||||
'nmt-mtu-entry.c',
|
||||
'nmt-page-bond.c',
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ ip_addresses_with_prefix_from_strv(GBinding *binding,
|
|||
* @source: the source object (eg, an #NMSettingIP4Config)
|
||||
* @source_property: the property on @source to bind (eg,
|
||||
* %NM_SETTING_IP4_CONFIG_ADDRESSES)
|
||||
* @target: the target object (eg, an #NmtAddressList)
|
||||
* @target: the target object (eg, an #NmtList)
|
||||
* @target_property: the property on @target to bind
|
||||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
|
|
@ -253,7 +253,7 @@ ip_addresses_check_and_copy(GBinding *binding,
|
|||
* @source: the source object (eg, an #NMSettingIP4Config)
|
||||
* @source_property: the property on @source to bind (eg,
|
||||
* %NM_SETTING_IP4_CONFIG_DNS)
|
||||
* @target: the target object (eg, an #NmtAddressList)
|
||||
* @target: the target object (eg, an #NmtList)
|
||||
* @target_property: the property on @target to bind
|
||||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright (C) 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NMT_ADDRESS_LIST_H
|
||||
#define NMT_ADDRESS_LIST_H
|
||||
|
||||
#include "nmt-widget-list.h"
|
||||
|
||||
#define NMT_TYPE_ADDRESS_LIST (nmt_address_list_get_type())
|
||||
#define NMT_ADDRESS_LIST(obj) \
|
||||
(_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_ADDRESS_LIST, NmtAddressList))
|
||||
#define NMT_ADDRESS_LIST_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_ADDRESS_LIST, NmtAddressListClass))
|
||||
#define NMT_IS_ADDRESS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_ADDRESS_LIST))
|
||||
#define NMT_IS_ADDRESS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_ADDRESS_LIST))
|
||||
#define NMT_ADDRESS_LIST_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_ADDRESS_LIST, NmtAddressListClass))
|
||||
|
||||
typedef struct {
|
||||
NmtWidgetList parent;
|
||||
|
||||
} NmtAddressList;
|
||||
|
||||
typedef struct {
|
||||
NmtWidgetListClass parent;
|
||||
|
||||
} NmtAddressListClass;
|
||||
|
||||
GType nmt_address_list_get_type(void);
|
||||
|
||||
typedef enum {
|
||||
NMT_ADDRESS_LIST_IP4_WITH_PREFIX,
|
||||
NMT_ADDRESS_LIST_IP4,
|
||||
NMT_ADDRESS_LIST_IP6_WITH_PREFIX,
|
||||
NMT_ADDRESS_LIST_IP6,
|
||||
NMT_ADDRESS_LIST_HOSTNAME
|
||||
} NmtAddressListType;
|
||||
|
||||
NmtNewtWidget *nmt_address_list_new(NmtAddressListType list_type);
|
||||
|
||||
#endif /* NMT_ADDRESS_LIST_H */
|
||||
|
|
@ -4,20 +4,19 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* SECTION:nmt-address-list
|
||||
* @short_description: An editable list of IP addresses or hostnames
|
||||
* SECTION:nmt-list
|
||||
* @short_description: An editable list of IP addresses, hostnames, or key=value pairs
|
||||
*
|
||||
* #NmtAddressList is a subclass of #NmtWidgetList that contains
|
||||
* entries displaying IP addresses, address/prefix strings, or
|
||||
* hostnames. This is designed for binding its #NmtAddressList:strings
|
||||
* property to an appropriate #NMSettingIP4Config or
|
||||
* #NMSettingIP6Config property via one of the nm-editor-bindings
|
||||
* functions.
|
||||
* #NmtList is a subclass of #NmtWidgetList that contains
|
||||
* entries displaying IP addresses, address/prefix strings,
|
||||
* hostnames, or key=value pairs. This is designed for binding its
|
||||
* #NmtList:strings property to an appropriate property via one
|
||||
* of the nm-editor-bindings functions.
|
||||
*/
|
||||
|
||||
#include "libnm-client-aux-extern/nm-default-client.h"
|
||||
|
||||
#include "nmt-address-list.h"
|
||||
#include "nmt-list.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
|
@ -25,15 +24,14 @@
|
|||
|
||||
#include "nmt-ip-entry.h"
|
||||
|
||||
G_DEFINE_TYPE(NmtAddressList, nmt_address_list, NMT_TYPE_WIDGET_LIST)
|
||||
G_DEFINE_TYPE(NmtList, nmt_list, NMT_TYPE_WIDGET_LIST)
|
||||
|
||||
#define NMT_ADDRESS_LIST_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_ADDRESS_LIST, NmtAddressListPrivate))
|
||||
#define NMT_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_LIST, NmtListPrivate))
|
||||
|
||||
typedef struct {
|
||||
NmtAddressListType list_type;
|
||||
char **strings;
|
||||
} NmtAddressListPrivate;
|
||||
NmtListType list_type;
|
||||
char **strings;
|
||||
} NmtListPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
|
@ -44,32 +42,32 @@ enum {
|
|||
};
|
||||
|
||||
/**
|
||||
* NmtAddressListType:
|
||||
* @NMT_ADDRESS_LIST_IP4_WITH_PREFIX: IPv4 address/prefix strings
|
||||
* @NMT_ADDRESS_LIST_IP4: IPv4 addresses
|
||||
* @NMT_ADDRESS_LIST_IP6_WITH_PREFIX: IPv6 address/prefix strings
|
||||
* @NMT_ADDRESS_LIST_IP6: IPv6 addresses
|
||||
* @NMT_ADDRESS_LIST_HOSTNAME: hostnames
|
||||
* NmtListType:
|
||||
* @NMT_LIST_IP4_WITH_PREFIX: IPv4 address/prefix strings
|
||||
* @NMT_LIST_IP4: IPv4 addresses
|
||||
* @NMT_LIST_IP6_WITH_PREFIX: IPv6 address/prefix strings
|
||||
* @NMT_LIST_IP6: IPv6 addresses
|
||||
* @NMT_LIST_HOSTNAME: hostnames
|
||||
*
|
||||
* The type of address in an #NmtAddressList
|
||||
* The type of address in an #NmtList
|
||||
*/
|
||||
|
||||
/**
|
||||
* nmt_address_list_new:
|
||||
* nmt_list_new:
|
||||
* @list_type: the type of address the list will contain
|
||||
*
|
||||
* Creates a new #NmtAddressList
|
||||
* Creates a new #NmtList
|
||||
*
|
||||
* Returns: a new #NmtAddressList
|
||||
* Returns: a new #NmtList
|
||||
*/
|
||||
NmtNewtWidget *
|
||||
nmt_address_list_new(NmtAddressListType list_type)
|
||||
nmt_list_new(NmtListType list_type)
|
||||
{
|
||||
return g_object_new(NMT_TYPE_ADDRESS_LIST, "list-type", list_type, NULL);
|
||||
return g_object_new(NMT_TYPE_LIST, "list-type", list_type, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_init(NmtAddressList *list)
|
||||
nmt_list_init(NmtList *list)
|
||||
{}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -95,9 +93,9 @@ strings_transform_from_entry(GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
NmtAddressList *list = NMT_ADDRESS_LIST(g_binding_get_source(binding));
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list);
|
||||
int n = GPOINTER_TO_INT(user_data);
|
||||
NmtList *list = NMT_LIST(g_binding_get_source(binding));
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(list);
|
||||
int n = GPOINTER_TO_INT(user_data);
|
||||
|
||||
if (n >= g_strv_length(priv->strings))
|
||||
return FALSE;
|
||||
|
|
@ -115,23 +113,38 @@ hostname_filter(NmtNewtEntry *entry, const char *text, int ch, int position, gpo
|
|||
return g_ascii_isalnum(ch) || ch == '.' || ch == '-' || ch == '~';
|
||||
}
|
||||
|
||||
static NmtNewtWidget *
|
||||
nmt_address_list_create_widget(NmtWidgetList *list, int num)
|
||||
static gboolean
|
||||
key_value_validate(NmtNewtEntry *entry, const char *text, gpointer user_data)
|
||||
{
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list);
|
||||
NmtNewtWidget *entry;
|
||||
const char *val;
|
||||
|
||||
if (priv->list_type == NMT_ADDRESS_LIST_IP4_WITH_PREFIX) {
|
||||
if (!text || !text[0])
|
||||
return TRUE;
|
||||
|
||||
val = strchr(text, '=');
|
||||
return val && val != text && val[1];
|
||||
}
|
||||
|
||||
static NmtNewtWidget *
|
||||
nmt_list_create_widget(NmtWidgetList *list, int num)
|
||||
{
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(list);
|
||||
NmtNewtWidget *entry;
|
||||
|
||||
if (priv->list_type == NMT_LIST_IP4_WITH_PREFIX) {
|
||||
entry = nmt_ip_entry_new(25, AF_INET, TRUE, FALSE);
|
||||
} else if (priv->list_type == NMT_ADDRESS_LIST_IP4) {
|
||||
} else if (priv->list_type == NMT_LIST_IP4) {
|
||||
entry = nmt_ip_entry_new(25, AF_INET, FALSE, FALSE);
|
||||
} else if (priv->list_type == NMT_ADDRESS_LIST_IP6_WITH_PREFIX) {
|
||||
} else if (priv->list_type == NMT_LIST_IP6_WITH_PREFIX) {
|
||||
entry = nmt_ip_entry_new(25, AF_INET6, TRUE, FALSE);
|
||||
} else if (priv->list_type == NMT_ADDRESS_LIST_IP6) {
|
||||
} else if (priv->list_type == NMT_LIST_IP6) {
|
||||
entry = nmt_ip_entry_new(25, AF_INET6, FALSE, FALSE);
|
||||
} else if (priv->list_type == NMT_ADDRESS_LIST_HOSTNAME) {
|
||||
} else if (priv->list_type == NMT_LIST_HOSTNAME) {
|
||||
entry = nmt_newt_entry_new(25, NMT_NEWT_ENTRY_NONEMPTY);
|
||||
nmt_newt_entry_set_filter(NMT_NEWT_ENTRY(entry), hostname_filter, list);
|
||||
} else if (priv->list_type == NMT_LIST_KEY_VALUE) {
|
||||
entry = nmt_newt_entry_new(40, 0);
|
||||
nmt_newt_entry_set_validator(NMT_NEWT_ENTRY(entry), key_value_validate, NULL);
|
||||
} else {
|
||||
g_return_val_if_reached(NULL);
|
||||
}
|
||||
|
|
@ -150,10 +163,10 @@ nmt_address_list_create_widget(NmtWidgetList *list, int num)
|
|||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_add_clicked(NmtWidgetList *list)
|
||||
nmt_list_add_clicked(NmtWidgetList *list)
|
||||
{
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list);
|
||||
int len;
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(list);
|
||||
int len;
|
||||
|
||||
len = priv->strings ? g_strv_length(priv->strings) : 0;
|
||||
priv->strings = g_renew(char *, priv->strings, len + 2);
|
||||
|
|
@ -165,10 +178,10 @@ nmt_address_list_add_clicked(NmtWidgetList *list)
|
|||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_remove_clicked(NmtWidgetList *list, int num)
|
||||
nmt_list_remove_clicked(NmtWidgetList *list, int num)
|
||||
{
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list);
|
||||
int len;
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(list);
|
||||
int len;
|
||||
|
||||
len = g_strv_length(priv->strings);
|
||||
g_free(priv->strings[num]);
|
||||
|
|
@ -179,12 +192,9 @@ nmt_address_list_remove_clicked(NmtWidgetList *list, int num)
|
|||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
nmt_list_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(object);
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LIST_TYPE:
|
||||
|
|
@ -204,9 +214,9 @@ nmt_address_list_set_property(GObject *object,
|
|||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
nmt_list_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(object);
|
||||
NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LIST_TYPE:
|
||||
|
|
@ -222,23 +232,23 @@ nmt_address_list_get_property(GObject *object, guint prop_id, GValue *value, GPa
|
|||
}
|
||||
|
||||
static void
|
||||
nmt_address_list_class_init(NmtAddressListClass *list_class)
|
||||
nmt_list_class_init(NmtListClass *list_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(list_class);
|
||||
NmtWidgetListClass *widget_list_class = NMT_WIDGET_LIST_CLASS(list_class);
|
||||
|
||||
g_type_class_add_private(list_class, sizeof(NmtAddressListPrivate));
|
||||
g_type_class_add_private(list_class, sizeof(NmtListPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = nmt_address_list_set_property;
|
||||
object_class->get_property = nmt_address_list_get_property;
|
||||
object_class->set_property = nmt_list_set_property;
|
||||
object_class->get_property = nmt_list_get_property;
|
||||
|
||||
widget_list_class->create_widget = nmt_address_list_create_widget;
|
||||
widget_list_class->add_clicked = nmt_address_list_add_clicked;
|
||||
widget_list_class->remove_clicked = nmt_address_list_remove_clicked;
|
||||
widget_list_class->create_widget = nmt_list_create_widget;
|
||||
widget_list_class->add_clicked = nmt_list_add_clicked;
|
||||
widget_list_class->remove_clicked = nmt_list_remove_clicked;
|
||||
|
||||
/**
|
||||
* NmtAddressList:list-type:
|
||||
* NmtList:list-type:
|
||||
*
|
||||
* The type of address the list holds.
|
||||
*/
|
||||
|
|
@ -253,7 +263,7 @@ nmt_address_list_class_init(NmtAddressListClass *list_class)
|
|||
0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* NmtAddressList:strings:
|
||||
* NmtList:strings:
|
||||
*
|
||||
* The strings in the list's entries.
|
||||
*/
|
||||
41
src/nmtui/nmt-list.h
Normal file
41
src/nmtui/nmt-list.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright (C) 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NMT_LIST_H
|
||||
#define NMT_LIST_H
|
||||
|
||||
#include "nmt-widget-list.h"
|
||||
|
||||
#define NMT_TYPE_LIST (nmt_list_get_type())
|
||||
#define NMT_LIST(obj) (_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_LIST, NmtList))
|
||||
#define NMT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_LIST, NmtListClass))
|
||||
#define NMT_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_LIST))
|
||||
#define NMT_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_LIST))
|
||||
#define NMT_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_LIST, NmtListClass))
|
||||
|
||||
typedef struct {
|
||||
NmtWidgetList parent;
|
||||
|
||||
} NmtList;
|
||||
|
||||
typedef struct {
|
||||
NmtWidgetListClass parent;
|
||||
|
||||
} NmtListClass;
|
||||
|
||||
GType nmt_list_get_type(void);
|
||||
|
||||
typedef enum {
|
||||
NMT_LIST_IP4_WITH_PREFIX,
|
||||
NMT_LIST_IP4,
|
||||
NMT_LIST_IP6_WITH_PREFIX,
|
||||
NMT_LIST_IP6,
|
||||
NMT_LIST_HOSTNAME,
|
||||
NMT_LIST_KEY_VALUE
|
||||
} NmtListType;
|
||||
|
||||
NmtNewtWidget *nmt_list_new(NmtListType list_type);
|
||||
|
||||
#endif /* NMT_LIST_H */
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
|
||||
#include "nmt-mac-entry.h"
|
||||
#include "nmt-address-list.h"
|
||||
#include "nmt-list.h"
|
||||
#include "nmt-port-list.h"
|
||||
|
||||
G_DEFINE_TYPE(NmtPageBond, nmt_page_bond, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
||||
|
|
@ -41,14 +41,15 @@ typedef struct {
|
|||
/* Note: when adding new options to the UI also ensure they are
|
||||
* initialized in bond_connection_setup_func()
|
||||
*/
|
||||
NmtNewtPopup *mode;
|
||||
NmtNewtEntry *primary;
|
||||
NmtNewtPopup *monitoring;
|
||||
NmtNewtEntry *miimon;
|
||||
NmtNewtEntry *updelay;
|
||||
NmtNewtEntry *downdelay;
|
||||
NmtNewtEntry *arp_interval;
|
||||
NmtAddressList *arp_ip_target;
|
||||
NmtNewtPopup *mode;
|
||||
NmtNewtEntry *primary;
|
||||
NmtNewtPopup *monitoring;
|
||||
NmtNewtEntry *miimon;
|
||||
NmtNewtEntry *updelay;
|
||||
NmtNewtEntry *downdelay;
|
||||
NmtNewtEntry *arp_interval;
|
||||
NmtList *arp_ip_target;
|
||||
NmtList *other_options;
|
||||
|
||||
NmtPageBondMonitoringMode monitoring_mode;
|
||||
|
||||
|
|
@ -63,6 +64,43 @@ static void arp_ip_target_widget_changed(GObject *object, GParamSpec *pspec, gpo
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_is_other_option(const char *option)
|
||||
{
|
||||
return !NM_IN_STRSET(option,
|
||||
NM_SETTING_BOND_OPTION_MODE,
|
||||
NM_SETTING_BOND_OPTION_PRIMARY,
|
||||
NM_SETTING_BOND_OPTION_MIIMON,
|
||||
NM_SETTING_BOND_OPTION_UPDELAY,
|
||||
NM_SETTING_BOND_OPTION_DOWNDELAY,
|
||||
NM_SETTING_BOND_OPTION_ARP_INTERVAL,
|
||||
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
||||
}
|
||||
|
||||
static void
|
||||
_bond_update_other_options(NMSettingBond *s_bond, NmtList *list)
|
||||
{
|
||||
gs_unref_ptrarray GPtrArray *arr = g_ptr_array_new_with_free_func(g_free);
|
||||
guint num_opts = nm_setting_bond_get_num_options(s_bond);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_opts; i++) {
|
||||
const char *opt_name;
|
||||
const char *opt_value;
|
||||
|
||||
nm_assert(nm_setting_bond_get_option(s_bond, i, &opt_name, &opt_value));
|
||||
|
||||
if (_is_other_option(opt_name)) {
|
||||
g_ptr_array_add(arr, g_strdup_printf("%s=%s", opt_name, opt_value));
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_add(arr, NULL);
|
||||
g_object_set(G_OBJECT(list), "strings", arr->pdata, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NmtEditorPage *
|
||||
nmt_page_bond_new(NMConnection *conn, NmtDeviceEntry *deventry)
|
||||
{
|
||||
|
|
@ -155,6 +193,8 @@ bond_options_changed(GObject *object, GParamSpec *pspec, gpointer user_data)
|
|||
nmt_newt_widget_set_visible(NMT_NEWT_WIDGET(priv->arp_interval), !visible_mii);
|
||||
nmt_newt_widget_set_visible(NMT_NEWT_WIDGET(priv->arp_ip_target), !visible_mii);
|
||||
|
||||
_bond_update_other_options(s_bond, priv->other_options);
|
||||
|
||||
priv->updating = FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -308,6 +348,47 @@ arp_ip_target_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_d
|
|||
g_strfreev(ips);
|
||||
}
|
||||
|
||||
static void
|
||||
other_options_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NmtPageBond *bond = NMT_PAGE_BOND(user_data);
|
||||
NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond);
|
||||
gs_strfreev char **other_options = NULL;
|
||||
const char *name;
|
||||
guint num;
|
||||
guint i;
|
||||
|
||||
if (priv->updating)
|
||||
return;
|
||||
|
||||
priv->updating = TRUE;
|
||||
|
||||
g_object_get(G_OBJECT(priv->other_options), "strings", &other_options, NULL);
|
||||
|
||||
again:
|
||||
num = nm_setting_bond_get_num_options(priv->s_bond);
|
||||
for (i = 0; i < num; i++) {
|
||||
nm_assert(nm_setting_bond_get_option(priv->s_bond, i, &name, NULL));
|
||||
|
||||
if (_is_other_option(name)) {
|
||||
nm_setting_bond_remove_option(priv->s_bond, name);
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; other_options && other_options[i]; i++) {
|
||||
char *val = strchr(other_options[i], '=');
|
||||
|
||||
if (val && val != other_options[i] && val[1]) {
|
||||
*val = '\0';
|
||||
if (_is_other_option(other_options[i]))
|
||||
nm_setting_bond_add_option(priv->s_bond, other_options[i], val + 1);
|
||||
}
|
||||
}
|
||||
|
||||
priv->updating = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bond_connection_type_filter(GType connection_type, gpointer user_data)
|
||||
{
|
||||
|
|
@ -390,10 +471,15 @@ nmt_page_bond_constructed(GObject *object)
|
|||
nmt_editor_grid_append(grid, _("Monitoring frequency"), widget, label);
|
||||
priv->arp_interval = NMT_NEWT_ENTRY(widget);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_IP4);
|
||||
widget = nmt_list_new(NMT_LIST_IP4);
|
||||
g_signal_connect(widget, "notify::strings", G_CALLBACK(arp_ip_target_widget_changed), bond);
|
||||
nmt_editor_grid_append(grid, _("ARP targets"), widget, NULL);
|
||||
priv->arp_ip_target = NMT_ADDRESS_LIST(widget);
|
||||
priv->arp_ip_target = NMT_LIST(widget);
|
||||
|
||||
widget = nmt_list_new(NMT_LIST_KEY_VALUE);
|
||||
g_signal_connect(widget, "notify::strings", G_CALLBACK(other_options_widget_changed), bond);
|
||||
nmt_editor_grid_append(grid, _("Other options (key=value)"), widget, NULL);
|
||||
priv->other_options = NMT_LIST(widget);
|
||||
|
||||
widget = nmt_mac_entry_new(40, ETH_ALEN, NMT_MAC_ENTRY_TYPE_CLONED_ETHERNET);
|
||||
g_object_bind_property(s_wired,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include "nmt-page-bridge.h"
|
||||
|
||||
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
|
||||
#include "nmt-address-list.h"
|
||||
#include "nmt-list.h"
|
||||
#include "nmt-port-list.h"
|
||||
|
||||
G_DEFINE_TYPE(NmtPageBridge, nmt_page_bridge, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
|
||||
#include "nmt-ip-entry.h"
|
||||
#include "nmt-address-list.h"
|
||||
#include "nmt-list.h"
|
||||
#include "nmt-route-editor.h"
|
||||
|
||||
#include "nm-editor-bindings.h"
|
||||
|
|
@ -112,7 +112,7 @@ nmt_page_ip4_constructed(GObject *object)
|
|||
section = nmt_editor_section_new(_("IPv4 CONFIGURATION"), widget, show_by_default);
|
||||
grid = nmt_editor_section_get_body(section);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_IP4_WITH_PREFIX);
|
||||
widget = nmt_list_new(NMT_LIST_IP4_WITH_PREFIX);
|
||||
nm_editor_bind_ip_addresses_with_prefix_to_strv(AF_INET,
|
||||
s_ip4,
|
||||
NM_SETTING_IP_CONFIG_ADDRESSES,
|
||||
|
|
@ -131,7 +131,7 @@ nmt_page_ip4_constructed(GObject *object)
|
|||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
nmt_editor_grid_append(grid, _("Gateway"), widget, NULL);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_IP4);
|
||||
widget = nmt_list_new(NMT_LIST_IP4);
|
||||
nm_editor_bind_ip_addresses_to_strv(AF_INET,
|
||||
s_ip4,
|
||||
NM_SETTING_IP_CONFIG_DNS,
|
||||
|
|
@ -140,7 +140,7 @@ nmt_page_ip4_constructed(GObject *object)
|
|||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
nmt_editor_grid_append(grid, _("DNS servers"), widget, NULL);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_HOSTNAME);
|
||||
widget = nmt_list_new(NMT_LIST_HOSTNAME);
|
||||
g_object_bind_property(s_ip4,
|
||||
NM_SETTING_IP_CONFIG_DNS_SEARCH,
|
||||
widget,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
|
||||
#include "nmt-ip-entry.h"
|
||||
#include "nmt-address-list.h"
|
||||
#include "nmt-list.h"
|
||||
#include "nmt-route-editor.h"
|
||||
|
||||
#include "nm-editor-bindings.h"
|
||||
|
|
@ -114,7 +114,7 @@ nmt_page_ip6_constructed(GObject *object)
|
|||
section = nmt_editor_section_new(_("IPv6 CONFIGURATION"), widget, show_by_default);
|
||||
grid = nmt_editor_section_get_body(section);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_IP6_WITH_PREFIX);
|
||||
widget = nmt_list_new(NMT_LIST_IP6_WITH_PREFIX);
|
||||
nm_editor_bind_ip_addresses_with_prefix_to_strv(AF_INET6,
|
||||
s_ip6,
|
||||
NM_SETTING_IP_CONFIG_ADDRESSES,
|
||||
|
|
@ -133,7 +133,7 @@ nmt_page_ip6_constructed(GObject *object)
|
|||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
nmt_editor_grid_append(grid, _("Gateway"), widget, NULL);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_IP6);
|
||||
widget = nmt_list_new(NMT_LIST_IP6);
|
||||
nm_editor_bind_ip_addresses_to_strv(AF_INET6,
|
||||
s_ip6,
|
||||
NM_SETTING_IP_CONFIG_DNS,
|
||||
|
|
@ -142,7 +142,7 @@ nmt_page_ip6_constructed(GObject *object)
|
|||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
nmt_editor_grid_append(grid, _("DNS servers"), widget, NULL);
|
||||
|
||||
widget = nmt_address_list_new(NMT_ADDRESS_LIST_HOSTNAME);
|
||||
widget = nmt_list_new(NMT_LIST_HOSTNAME);
|
||||
g_object_bind_property(s_ip6,
|
||||
NM_SETTING_IP_CONFIG_DNS_SEARCH,
|
||||
widget,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* buttons next to each one, and an "Add" button at the button to add
|
||||
* new ones.
|
||||
*
|
||||
* It is the base class for #NmtAddressList, and is used internally by
|
||||
* It is the base class for #NmtList, and is used internally by
|
||||
* #NmtRouteTable.
|
||||
*
|
||||
* FIXME: The way this works is sort of weird.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue