In a subsequent patch, we will modify set_from_ui_generic() in such a way
that it will fit the fixed disks and the removable media drives, but no
longer the interfaces.
Detach set_interfaces_from_ui() from the set_from_ui_generic() function.
Copy the set_from_ui_generic() function body, open-code the parameters,
also directly use INTERFACES_COL_CONVERT in place of "0 /* CONVERT */". No
functional changes.
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2124538
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
gui.c | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/gui.c b/gui.c
index 561ba64d2a71..c40ed31a8bbc 100644
--- a/gui.c
+++ b/gui.c
@@ -1448,8 +1448,38 @@ set_removable_from_ui (struct config *config)
static void
set_interfaces_from_ui (struct config *config)
{
- set_from_ui_generic (all_interfaces, &config->interfaces,
- GTK_TREE_VIEW (interfaces_list));
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean b, v;
+ size_t i, j;
+
+ guestfs_int_free_string_list (config->interfaces);
+ if (all_interfaces == NULL) {
+ config->interfaces = NULL;
+ return;
+ }
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (interfaces_list));
+
+ config->interfaces = malloc ((1 +
+ guestfs_int_count_strings (all_interfaces)) *
+ sizeof (char *));
+ if (config->interfaces == NULL)
+ error (EXIT_FAILURE, errno, "malloc");
+ i = j = 0;
+
+ b = gtk_tree_model_get_iter_first (model, &iter);
+ while (b) {
+ gtk_tree_model_get (model, &iter, INTERFACES_COL_CONVERT, &v, -1);
+ if (v) {
+ assert (all_interfaces[i] != NULL);
+ config->interfaces[j++] = strdup (all_interfaces[i]);
+ }
+ b = gtk_tree_model_iter_next (model, &iter);
+ ++i;
+ }
+
+ config->interfaces[j] = NULL;
}
static void