[libnma/lr/gtk-4.0: 14/33] ws: replace GtkContainer with GtkBox




commit b5650c7ca0eaf93f28d3cf8900cff589c1392d80
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Oct 7 11:03:53 2021 +0200

    ws: replace GtkContainer with GtkBox
    
    GtkContainer is gone from Gtk4.

 src/nma-wifi-dialog.c              | 30 ++++++++++++++----------------
 src/nma-ws/nma-eap-fast.c          | 25 +++++++++++--------------
 src/nma-ws/nma-eap-peap.c          | 24 +++++++++++-------------
 src/nma-ws/nma-eap-ttls.c          | 25 +++++++++++--------------
 src/nma-ws/nma-ws-802-1x-private.h |  5 +++--
 src/nma-ws/nma-ws-802-1x.c         | 17 +++++++----------
 6 files changed, 57 insertions(+), 69 deletions(-)
---
diff --git a/src/nma-wifi-dialog.c b/src/nma-wifi-dialog.c
index 60f718f5..d42c4484 100644
--- a/src/nma-wifi-dialog.c
+++ b/src/nma-wifi-dialog.c
@@ -3,7 +3,7 @@
  *
  * Dan Williams <dcbw redhat com>
  *
- * Copyright 2007 - 2017 Red Hat, Inc.
+ * Copyright (C) 2007 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -57,6 +57,8 @@ typedef struct {
        guint revalidate_id;
 
        GetSecretsInfo *secrets_info;
+
+       NMAWs *ws;
 } NMAWifiDialogPrivate;
 
 enum {
@@ -212,21 +214,17 @@ security_combo_changed (GtkWidget *combo,
        NMAWifiDialog *self = NMA_WIFI_DIALOG (user_data);
        NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (self);
        GtkWidget *vbox; // *def_widget;
-       GList *elt, *children;
        GtkTreeIter iter;
        GtkTreeModel *model;
-       NMAWs *ws = NULL;
 
        vbox = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_vbox"));
        g_assert (vbox);
 
        size_group_clear (priv->group);
 
-       /* Remove any previous wireless security widgets */
-       children = gtk_container_get_children (GTK_CONTAINER (vbox));
-       for (elt = children; elt; elt = g_list_next (elt))
-               gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
-       g_list_free (children);
+       /* Remove the previous wireless security widget */
+       if (priv->ws)
+               gtk_box_remove (GTK_BOX (vbox), GTK_WIDGET (priv->ws));
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter)) {
@@ -234,8 +232,8 @@ security_combo_changed (GtkWidget *combo,
                return;
        }
 
-       gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &ws, -1);
-       if (!ws) {
+       gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &priv->ws, -1);
+       if (!priv->ws) {
                /* Revalidate dialog if the user picked "None" so the OK button
                 * gets enabled if there's already a valid SSID.
                 */
@@ -243,15 +241,15 @@ security_combo_changed (GtkWidget *combo,
                return;
        }
 
-       gtk_widget_unparent (GTK_WIDGET (ws));
+       gtk_widget_unparent (GTK_WIDGET (priv->ws));
 
        size_group_add_permanent (priv->group, priv->builder);
-       nma_ws_add_to_size_group (ws, priv->group);
+       nma_ws_add_to_size_group (priv->ws, priv->group);
 
-       gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (ws));
+       gtk_box_append (GTK_BOX (vbox), GTK_WIDGET (priv->ws));
 
        /* Re-validate */
-       stuff_changed_cb (ws, self);
+       stuff_changed_cb (priv->ws, self);
 
 #if 0
        /* Set focus to the security method's default widget, but only if the
@@ -264,7 +262,7 @@ security_combo_changed (GtkWidget *combo,
        }
 #endif
 
-       g_object_unref (ws);
+       g_object_unref (priv->ws);
 }
 
 static void
@@ -1124,7 +1122,7 @@ internal_init (NMAWifiDialog *self,
                return FALSE;
        }
 
-       gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))), widget);
+       gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), widget);
 
        /* If given a valid connection, hide the SSID bits and connection combo */
        if (specific_connection) {
diff --git a/src/nma-ws/nma-eap-fast.c b/src/nma-ws/nma-eap-fast.c
index 545c23f5..d35c2ce0 100644
--- a/src/nma-ws/nma-eap-fast.c
+++ b/src/nma-ws/nma-eap-fast.c
@@ -26,6 +26,7 @@ struct _NMAEapFast {
        GtkSizeGroup *size_group;
        NMAWs8021x *ws_8021x;
        gboolean is_editor;
+       GtkWidget *eap_widget;
        char *pac_file_name;
 };
 
@@ -51,7 +52,7 @@ validate (NMAEap *parent, GError **error)
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton"));
        g_assert (widget);
-       provisioning = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+       provisioning = gtk_check_button_get_active (GTK_CHECK_BUTTON (widget));
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button"));
        g_assert (widget);
        if (!provisioning && !method->pac_file_name) {
@@ -139,7 +140,7 @@ fill_connection (NMAEap *parent, NMConnection *connection)
        g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, method->pac_file_name, NULL);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton"));
-       enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+       enabled = gtk_check_button_get_active (GTK_CHECK_BUTTON (widget));
 
        if (!enabled)
                g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "0", NULL);
@@ -178,34 +179,30 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 {
        NMAEap *parent = (NMAEap *) user_data;
        NMAEapFast *method = (NMAEapFast *) parent;
-       GtkWidget *vbox;
+       GtkBox *vbox;
        NMAEap *eap = NULL;
-       GList *elt, *children;
        GtkTreeModel *model;
        GtkTreeIter iter;
-       GtkWidget *eap_widget;
 
-       vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_vbox"));
+       vbox = GTK_BOX (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_vbox"));
        g_assert (vbox);
 
        /* Remove any previous wireless security widgets */
-       children = gtk_container_get_children (GTK_CONTAINER (vbox));
-       for (elt = children; elt; elt = g_list_next (elt))
-               gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
-       g_list_free (children);
+       if (method->eap_widget)
+               gtk_box_remove (vbox, method->eap_widget);
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
        gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
        g_assert (eap);
 
-       eap_widget = nma_eap_get_widget (eap);
-       g_assert (eap_widget);
-       gtk_widget_unparent (eap_widget);
+       method->eap_widget = nma_eap_get_widget (eap);
+       g_return_if_fail (method->eap_widget);
+       gtk_widget_unparent (method->eap_widget);
 
        if (method->size_group)
                nma_eap_add_to_size_group (eap, method->size_group);
-       gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
+       gtk_box_append (vbox, method->eap_widget);
 
        nma_eap_unref (eap);
 
diff --git a/src/nma-ws/nma-eap-peap.c b/src/nma-ws/nma-eap-peap.c
index 3f96c46d..4d5cc644 100644
--- a/src/nma-ws/nma-eap-peap.c
+++ b/src/nma-ws/nma-eap-peap.c
@@ -2,7 +2,7 @@
 /*
  * Dan Williams <dcbw redhat com>
  *
- * Copyright 2007 - 2019 Red Hat, Inc.
+ * Copyright (C) 2007 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -28,6 +28,7 @@ struct _NMAEapPeap {
        NMAWs8021x *ws_8021x;
        gboolean is_editor;
        GtkWidget *ca_cert_chooser;
+       GtkWidget *eap_widget;
 };
 
 static void
@@ -205,33 +206,30 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 {
        NMAEap *parent = (NMAEap *) user_data;
        NMAEapPeap *method = (NMAEapPeap *) parent;
-       GtkWidget *vbox;
+       GtkBox *vbox;
        NMAEap *eap = NULL;
-       GList *elt, *children;
        GtkTreeModel *model;
        GtkTreeIter iter;
-       GtkWidget *eap_widget;
 
-       vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_vbox"));
-       g_assert (vbox);
+       vbox = GTK_BOX (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_vbox"));
+       g_return_if_fail (vbox);
 
        /* Remove any previous wireless security widgets */
-       children = gtk_container_get_children (GTK_CONTAINER (vbox));
-       for (elt = children; elt; elt = g_list_next (elt))
-               gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
+       if (method->eap_widget)
+               gtk_box_remove (vbox, method->eap_widget);
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
        gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
        g_assert (eap);
 
-       eap_widget = nma_eap_get_widget (eap);
-       g_assert (eap_widget);
-       gtk_widget_unparent (eap_widget);
+       method->eap_widget = nma_eap_get_widget (eap);
+       g_return_if_fail (method->eap_widget);
+       gtk_widget_unparent (method->eap_widget);
 
        if (method->size_group)
                nma_eap_add_to_size_group (eap, method->size_group);
-       gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
+       gtk_box_append (vbox, method->eap_widget);
 
        nma_eap_unref (eap);
 
diff --git a/src/nma-ws/nma-eap-ttls.c b/src/nma-ws/nma-eap-ttls.c
index fee809f8..859955b3 100644
--- a/src/nma-ws/nma-eap-ttls.c
+++ b/src/nma-ws/nma-eap-ttls.c
@@ -2,7 +2,7 @@
 /*
  * Dan Williams <dcbw redhat com>
  *
- * Copyright 2007 - 2019 Red Hat, Inc.
+ * Copyright (C) 2007 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -29,6 +29,7 @@ struct _NMAEapTtls {
        gboolean is_editor;
 
        GtkWidget *ca_cert_chooser;
+       GtkWidget *eap_widget;
 };
 
 static void
@@ -188,34 +189,30 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 {
        NMAEap *parent = (NMAEap *) user_data;
        NMAEapTtls *method = (NMAEapTtls *) parent;
-       GtkWidget *vbox;
+       GtkBox *vbox;
        NMAEap *eap = NULL;
-       GList *elt, *children;
        GtkTreeModel *model;
        GtkTreeIter iter;
-       GtkWidget *eap_widget;
 
-       vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_vbox"));
-       g_assert (vbox);
+       vbox = GTK_BOX (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_vbox"));
+       g_return_if_fail (vbox);
 
        /* Remove any previous wireless security widgets */
-       children = gtk_container_get_children (GTK_CONTAINER (vbox));
-       for (elt = children; elt; elt = g_list_next (elt))
-               gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
-       g_list_free (children);
+       if (method->eap_widget)
+               gtk_box_remove (vbox, method->eap_widget);
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
        gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
        g_assert (eap);
 
-       eap_widget = nma_eap_get_widget (eap);
-       g_assert (eap_widget);
-       gtk_widget_unparent (eap_widget);
+       method->eap_widget = nma_eap_get_widget (eap);
+       g_return_if_fail (method->eap_widget);
+       gtk_widget_unparent (method->eap_widget);
 
        if (method->size_group)
                nma_eap_add_to_size_group (eap, method->size_group);
-       gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
+       gtk_box_append (vbox, method->eap_widget);
 
        nma_eap_unref (eap);
 
diff --git a/src/nma-ws/nma-ws-802-1x-private.h b/src/nma-ws/nma-ws-802-1x-private.h
index 23743eee..0b20214a 100644
--- a/src/nma-ws/nma-ws-802-1x-private.h
+++ b/src/nma-ws/nma-ws-802-1x-private.h
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2007 - 2019 Red Hat, Inc.
+ * Copyright (C) 2007 - 2021 Red Hat, Inc.
  */
 
 #ifndef NMA_WS_802_1X_PRIVATE_H
@@ -15,7 +15,8 @@ struct _NMAWs8021x {
 
        GtkWidget *eap_auth_combo;
        GtkWidget *eap_auth_label;
-       GtkWidget *eap_vbox;
+       GtkBox *eap_vbox;
+       GtkWidget *eap_widget;
 
        NMConnection *connection;
        gboolean secrets_only;
diff --git a/src/nma-ws/nma-ws-802-1x.c b/src/nma-ws/nma-ws-802-1x.c
index 0c148ce5..09317358 100644
--- a/src/nma-ws/nma-ws-802-1x.c
+++ b/src/nma-ws/nma-ws-802-1x.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2007 - 2019 Red Hat, Inc.
+ * Copyright (C) 2007 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -113,27 +113,24 @@ auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
        NMAWs8021x *self = NMA_WS_802_1X (user_data);
 
        NMAEap *eap = NULL;
-       GList *elt, *children;
        GtkTreeModel *model;
        GtkTreeIter iter;
-       GtkWidget *eap_widget;
        GtkWidget *eap_default_widget = NULL;
 
        /* Remove any previous wireless security widgets */
-       children = gtk_container_get_children (GTK_CONTAINER (self->eap_vbox));
-       for (elt = children; elt; elt = g_list_next (elt))
-               gtk_container_remove (GTK_CONTAINER (self->eap_vbox), GTK_WIDGET (elt->data));
+       if (self->eap_widget)
+               gtk_box_remove (self->eap_vbox, self->eap_widget);
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
        gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
        g_return_if_fail (eap);
 
-       eap_widget = nma_eap_get_widget (eap);
-       g_return_if_fail (eap_widget);
-       gtk_widget_unparent (eap_widget);
+       self->eap_widget = nma_eap_get_widget (eap);
+       g_return_if_fail (self->eap_widget);
+       gtk_widget_unparent (self->eap_widget);
 
-       gtk_container_add (GTK_CONTAINER (self->eap_vbox), eap_widget);
+       gtk_box_append (self->eap_vbox, self->eap_widget);
 
        /* Refocus the EAP method's default widget */
        if (eap->default_field) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]