From 6a841072ec3b3fae7012d078f2a58133169e31b1 Mon Sep 17 00:00:00 2001 From: Jan Vaclav Date: Wed, 1 Apr 2026 14:43:30 +0200 Subject: [PATCH 1/2] nmtui/bond: introduce "other options" list Bond connections can have options that are not exposed by any widget in the bond editor. The presence of certain mode-specific options makes it impossible to change the mode, e.g. from 802.3ad to active-backup when `lacp_rate` is set. Introduce an "Other options" list that shows all bond options not already configurable by a specific widget, and allow the user to edit them as key=value entries. Resolves #1805 Resolves: https://redhat.atlassian.net/browse/NMT-1888 --- NEWS | 3 ++ src/nmtui/nmt-address-list.c | 26 ++++++++--- src/nmtui/nmt-address-list.h | 3 +- src/nmtui/nmt-page-bond.c | 86 ++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index cba09f8722..214b65a91f 100644 --- a/NEWS +++ b/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 diff --git a/src/nmtui/nmt-address-list.c b/src/nmtui/nmt-address-list.c index 9b8a948e0e..52b2bc92e5 100644 --- a/src/nmtui/nmt-address-list.c +++ b/src/nmtui/nmt-address-list.c @@ -5,14 +5,13 @@ /** * SECTION:nmt-address-list - * @short_description: An editable list of IP addresses or hostnames + * @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. + * entries displaying IP addresses, address/prefix strings, + * hostnames, or key=value pairs. This is designed for binding its + * #NmtAddressList:strings property to an appropriate property via one + * of the nm-editor-bindings functions. */ #include "libnm-client-aux-extern/nm-default-client.h" @@ -115,6 +114,18 @@ hostname_filter(NmtNewtEntry *entry, const char *text, int ch, int position, gpo return g_ascii_isalnum(ch) || ch == '.' || ch == '-' || ch == '~'; } +static gboolean +key_value_validate(NmtNewtEntry *entry, const char *text, gpointer user_data) +{ + const char *val; + + if (!text || !text[0]) + return TRUE; + + val = strchr(text, '='); + return val && val != text && val[1]; +} + static NmtNewtWidget * nmt_address_list_create_widget(NmtWidgetList *list, int num) { @@ -132,6 +143,9 @@ nmt_address_list_create_widget(NmtWidgetList *list, int num) } else if (priv->list_type == NMT_ADDRESS_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_ADDRESS_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); } diff --git a/src/nmtui/nmt-address-list.h b/src/nmtui/nmt-address-list.h index 01669fbd86..3de667f75e 100644 --- a/src/nmtui/nmt-address-list.h +++ b/src/nmtui/nmt-address-list.h @@ -35,7 +35,8 @@ typedef enum { NMT_ADDRESS_LIST_IP4, NMT_ADDRESS_LIST_IP6_WITH_PREFIX, NMT_ADDRESS_LIST_IP6, - NMT_ADDRESS_LIST_HOSTNAME + NMT_ADDRESS_LIST_HOSTNAME, + NMT_ADDRESS_LIST_KEY_VALUE } NmtAddressListType; NmtNewtWidget *nmt_address_list_new(NmtAddressListType list_type); diff --git a/src/nmtui/nmt-page-bond.c b/src/nmtui/nmt-page-bond.c index f74bac2732..dbc05c8411 100644 --- a/src/nmtui/nmt-page-bond.c +++ b/src/nmtui/nmt-page-bond.c @@ -49,6 +49,7 @@ typedef struct { NmtNewtEntry *downdelay; NmtNewtEntry *arp_interval; NmtAddressList *arp_ip_target; + NmtAddressList *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, NmtAddressList *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) { @@ -395,6 +476,11 @@ nmt_page_bond_constructed(GObject *object) nmt_editor_grid_append(grid, _("ARP targets"), widget, NULL); priv->arp_ip_target = NMT_ADDRESS_LIST(widget); + widget = nmt_address_list_new(NMT_ADDRESS_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_ADDRESS_LIST(widget); + widget = nmt_mac_entry_new(40, ETH_ALEN, NMT_MAC_ENTRY_TYPE_CLONED_ETHERNET); g_object_bind_property(s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, From 0b3db7c6ee9c6dc69f0fba2ae2205ce0eecba7b6 Mon Sep 17 00:00:00 2001 From: Jan Vaclav Date: Wed, 8 Apr 2026 10:07:32 +0200 Subject: [PATCH 2/2] nmtui: rename NMTAddressList -> NmtList --- src/nmtui/meson.build | 2 +- src/nmtui/nm-editor-bindings.c | 4 +- src/nmtui/nmt-address-list.h | 44 -------- src/nmtui/{nmt-address-list.c => nmt-list.c} | 110 +++++++++---------- src/nmtui/nmt-list.h | 41 +++++++ src/nmtui/nmt-page-bond.c | 30 ++--- src/nmtui/nmt-page-bridge.c | 2 +- src/nmtui/nmt-page-ip4.c | 8 +- src/nmtui/nmt-page-ip6.c | 8 +- src/nmtui/nmt-widget-list.c | 2 +- 10 files changed, 122 insertions(+), 129 deletions(-) delete mode 100644 src/nmtui/nmt-address-list.h rename src/nmtui/{nmt-address-list.c => nmt-list.c} (64%) create mode 100644 src/nmtui/nmt-list.h diff --git a/src/nmtui/meson.build b/src/nmtui/meson.build index 40bb40b9da..28989f1548 100644 --- a/src/nmtui/meson.build +++ b/src/nmtui/meson.build @@ -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', diff --git a/src/nmtui/nm-editor-bindings.c b/src/nmtui/nm-editor-bindings.c index 360cf3ad97..1408d263ec 100644 --- a/src/nmtui/nm-editor-bindings.c +++ b/src/nmtui/nm-editor-bindings.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 diff --git a/src/nmtui/nmt-address-list.h b/src/nmtui/nmt-address-list.h deleted file mode 100644 index 3de667f75e..0000000000 --- a/src/nmtui/nmt-address-list.h +++ /dev/null @@ -1,44 +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, - NMT_ADDRESS_LIST_KEY_VALUE -} NmtAddressListType; - -NmtNewtWidget *nmt_address_list_new(NmtAddressListType list_type); - -#endif /* NMT_ADDRESS_LIST_H */ diff --git a/src/nmtui/nmt-address-list.c b/src/nmtui/nmt-list.c similarity index 64% rename from src/nmtui/nmt-address-list.c rename to src/nmtui/nmt-list.c index 52b2bc92e5..3058638a60 100644 --- a/src/nmtui/nmt-address-list.c +++ b/src/nmtui/nmt-list.c @@ -4,19 +4,19 @@ */ /** - * SECTION:nmt-address-list + * SECTION:nmt-list * @short_description: An editable list of IP addresses, hostnames, or key=value pairs * - * #NmtAddressList is a subclass of #NmtWidgetList that contains + * #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 - * #NmtAddressList:strings property to an appropriate property via one + * #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 #include @@ -24,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, @@ -43,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 @@ -94,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; @@ -127,23 +126,23 @@ key_value_validate(NmtNewtEntry *entry, const char *text, gpointer user_data) } static NmtNewtWidget * -nmt_address_list_create_widget(NmtWidgetList *list, int num) +nmt_list_create_widget(NmtWidgetList *list, int num) { - NmtAddressListPrivate *priv = NMT_ADDRESS_LIST_GET_PRIVATE(list); - NmtNewtWidget *entry; + NmtListPrivate *priv = NMT_LIST_GET_PRIVATE(list); + NmtNewtWidget *entry; - if (priv->list_type == NMT_ADDRESS_LIST_IP4_WITH_PREFIX) { + 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_ADDRESS_LIST_KEY_VALUE) { + } 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 { @@ -164,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); @@ -179,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]); @@ -193,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: @@ -218,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: @@ -236,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. */ @@ -267,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. */ diff --git a/src/nmtui/nmt-list.h b/src/nmtui/nmt-list.h new file mode 100644 index 0000000000..65def93813 --- /dev/null +++ b/src/nmtui/nmt-list.h @@ -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 */ diff --git a/src/nmtui/nmt-page-bond.c b/src/nmtui/nmt-page-bond.c index dbc05c8411..962a95096b 100644 --- a/src/nmtui/nmt-page-bond.c +++ b/src/nmtui/nmt-page-bond.c @@ -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,15 +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; - NmtAddressList *other_options; + 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; @@ -78,7 +78,7 @@ _is_other_option(const char *option) } static void -_bond_update_other_options(NMSettingBond *s_bond, NmtAddressList *list) +_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); @@ -471,15 +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_address_list_new(NMT_ADDRESS_LIST_KEY_VALUE); + 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_ADDRESS_LIST(widget); + 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, diff --git a/src/nmtui/nmt-page-bridge.c b/src/nmtui/nmt-page-bridge.c index da765b145c..97c444be13 100644 --- a/src/nmtui/nmt-page-bridge.c +++ b/src/nmtui/nmt-page-bridge.c @@ -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) diff --git a/src/nmtui/nmt-page-ip4.c b/src/nmtui/nmt-page-ip4.c index 4d01b35662..ebbc768224 100644 --- a/src/nmtui/nmt-page-ip4.c +++ b/src/nmtui/nmt-page-ip4.c @@ -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, diff --git a/src/nmtui/nmt-page-ip6.c b/src/nmtui/nmt-page-ip6.c index bd29a3a7c5..c0dc88f31f 100644 --- a/src/nmtui/nmt-page-ip6.c +++ b/src/nmtui/nmt-page-ip6.c @@ -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, diff --git a/src/nmtui/nmt-widget-list.c b/src/nmtui/nmt-widget-list.c index d150eee081..c827db0406 100644 --- a/src/nmtui/nmt-widget-list.c +++ b/src/nmtui/nmt-widget-list.c @@ -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.