[libnma/lr/gtk-4.0: 17/33] tests: use compat wrappers for gtk_init() and gtk_window_new()




commit 4229fbf19aeafc8f32ad0ab51279be2a42e6ef3d
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Oct 12 09:18:12 2021 +0200

    tests: use compat wrappers for gtk_init() and gtk_window_new()
    
    These work differently in Gtk4.

 src/tests/bar-code.c            |  8 ++------
 src/tests/cert-chooser.c        |  7 ++-----
 src/tests/mobile-wizard.c       |  7 ++-----
 src/tests/run-vpn.c             | 10 ++++------
 src/tests/vpn-password-dialog.c |  4 ----
 src/tests/wifi-dialog-secrets.c |  4 ----
 src/tests/wifi-dialog.c         |  6 +-----
 src/tests/ws.c                  | 10 +++-------
 8 files changed, 14 insertions(+), 42 deletions(-)
---
diff --git a/src/tests/bar-code.c b/src/tests/bar-code.c
index f85a0cfa..5cd30072 100644
--- a/src/tests/bar-code.c
+++ b/src/tests/bar-code.c
@@ -9,7 +9,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * Copyright 2018, 2019 Red Hat, Inc.
+ * Copyright (C) 2018 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -106,13 +106,9 @@ main (int argc, char *argv[])
        nm_connection_add_setting (connection,
                                   nm_setting_wireless_new ());
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
+       w = gtk_window_new ();
 
-       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_show (w);
        gtk_window_set_default_size (GTK_WINDOW (w), 800, 680);
        g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);
diff --git a/src/tests/cert-chooser.c b/src/tests/cert-chooser.c
index 99808d12..5fa9277d 100644
--- a/src/tests/cert-chooser.c
+++ b/src/tests/cert-chooser.c
@@ -9,10 +9,11 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * Copyright 2019 Red Hat, Inc.
+ * Copyright (C) 2018 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
+#include "nma-private.h"
 
 #include <gtk/gtk.h>
 #include "nma-cert-chooser.h"
@@ -24,11 +25,7 @@ main (int argc, char *argv[])
        GtkBox *content;
        GtkWidget *widget;
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        dialog = gtk_dialog_new_with_buttons ("NMACertChooser test",
                                              NULL, GTK_DIALOG_MODAL,
diff --git a/src/tests/mobile-wizard.c b/src/tests/mobile-wizard.c
index 1e21868f..24d9aee9 100644
--- a/src/tests/mobile-wizard.c
+++ b/src/tests/mobile-wizard.c
@@ -1,9 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2018 Red Hat, Inc.
+ * Copyright (C) 2018 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
+#include "nma-private.h"
 
 #include <gtk/gtk.h>
 #include "nma-mobile-wizard.h"
@@ -19,11 +20,7 @@ main (int argc, char *argv[])
 {
        NMAMobileWizard *wizard;
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        wizard = nma_mobile_wizard_new (NULL, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, TRUE, wizard_cb, NULL);
 
diff --git a/src/tests/run-vpn.c b/src/tests/run-vpn.c
index b0e39d9d..40ec610b 100644
--- a/src/tests/run-vpn.c
+++ b/src/tests/run-vpn.c
@@ -2,10 +2,12 @@
 /*
  * run-vpn - VPN plugin runner for testing
  *
- * (C) Copyright 2018 Lubomir Rintel
+ * Copyright (C) 2018 Lubomir Rintel
+ * Copyright (C) 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
+#include "nma-private.h"
 
 #include <NetworkManager.h>
 #include <gtk/gtk.h>
@@ -33,11 +35,7 @@ main (int argc, char *argv[])
        GtkWidget *widget;
        gs_free_error GError *error = NULL;
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        if (argc != 2) {
                g_printerr ("Usage: %s libnm-vpn-plugin-<name>.so\n", argv[0]);
@@ -66,7 +64,7 @@ main (int argc, char *argv[])
        }
 
        main_loop = g_main_loop_new (NULL, FALSE);
-       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       window = gtk_window_new ();
        gtk_widget_show (window);
        g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (window_deleted), main_loop);
 
diff --git a/src/tests/vpn-password-dialog.c b/src/tests/vpn-password-dialog.c
index c66263af..4cb0f521 100644
--- a/src/tests/vpn-password-dialog.c
+++ b/src/tests/vpn-password-dialog.c
@@ -14,11 +14,7 @@ main (int argc, char *argv[])
 {
        GtkWidget *dialog;
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        dialog = nma_vpn_password_dialog_new ("Title", "Message", "Password");
 
diff --git a/src/tests/wifi-dialog-secrets.c b/src/tests/wifi-dialog-secrets.c
index 99004ce3..2cf85c6b 100644
--- a/src/tests/wifi-dialog-secrets.c
+++ b/src/tests/wifi-dialog-secrets.c
@@ -55,11 +55,7 @@ main (int argc, char *argv[])
                NULL
        };
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        client = nm_client_new (NULL, NULL);
        connection = nm_simple_connection_new ();
diff --git a/src/tests/wifi-dialog.c b/src/tests/wifi-dialog.c
index 5957373e..ae177258 100644
--- a/src/tests/wifi-dialog.c
+++ b/src/tests/wifi-dialog.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2018 Red Hat, Inc.
+ * Copyright (C) 2018 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -21,11 +21,7 @@ main (int argc, char *argv[])
        GError *error = NULL;
        gs_unref_bytes GBytes *ssid = g_bytes_new_static ("<Maj Vaj Faj>", 13);
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
 
        client = nm_client_new (NULL, NULL);
        connection = nm_simple_connection_new ();
diff --git a/src/tests/ws.c b/src/tests/ws.c
index 97fe37c2..a7d6973c 100644
--- a/src/tests/ws.c
+++ b/src/tests/ws.c
@@ -1,9 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2019 Red Hat, Inc.
+ * Copyright (C) 2019 - 2021 Red Hat, Inc.
  */
 
 #include "nm-default.h"
+#include "nma-private.h"
 
 #include <gtk/gtk.h>
 
@@ -46,13 +47,8 @@ main (int argc, char *argv[])
        nm_connection_add_setting (connection,
                                   nm_setting_wireless_new ());
 
-#if GTK_CHECK_VERSION(3,90,0)
        gtk_init ();
-#else
-       gtk_init (&argc, &argv);
-#endif
-
-       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       w = gtk_window_new ();
        gtk_widget_show (w);
        g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);
 


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