[libnma/lr/gtk-4.0: 13/23] tests/bar-code: port to Gtk4
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma/lr/gtk-4.0: 13/23] tests/bar-code: port to Gtk4
- Date: Mon, 25 Oct 2021 13:06:09 +0000 (UTC)
commit 096d614feb67e56af3cced3a4146fedccf8bf92f
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Thu Oct 7 13:59:24 2021 +0200
tests/bar-code: port to Gtk4
src/tests/bar-code.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/tests/bar-code.c b/src/tests/bar-code.c
index ebda8b60..962a0e9e 100644
--- a/src/tests/bar-code.c
+++ b/src/tests/bar-code.c
@@ -23,11 +23,10 @@
#include "nma-bar-code-widget.h"
static gboolean
-delete (GtkWidget *widget, GdkEvent *event, gpointer user_data)
+delete (GMainLoop *main_loop)
{
- gtk_main_quit ();
-
- return FALSE;
+ g_main_loop_quit (main_loop);
+ return FALSE;
}
static void
@@ -93,6 +92,7 @@ key_mgmt_changed (GtkComboBox *combo_box, gpointer user_data)
int
main (int argc, char *argv[])
{
+ GMainLoop *loop;
GtkWidget *w, *pass;
GtkWidget *grid;
NMConnection *connection = NULL;
@@ -111,7 +111,13 @@ main (int argc, char *argv[])
w = gtk_window_new ();
gtk_widget_show (w);
gtk_window_set_default_size (GTK_WINDOW (w), 800, 680);
- g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);
+
+ loop = g_main_loop_new (NULL, FALSE);
+#if GTK_CHECK_VERSION(4,0,0)
+ g_signal_connect_swapped (w, "close-request", G_CALLBACK (delete), loop);
+#else
+ g_signal_connect_swapped (w, "delete-event", G_CALLBACK (delete), loop);
+#endif
grid = gtk_grid_new ();
gtk_widget_show (grid);
@@ -123,7 +129,7 @@ main (int argc, char *argv[])
"margin_top", 6,
"margin_bottom", 6,
NULL);
- gtk_container_add (GTK_CONTAINER (w), grid);
+ gtk_window_set_child (GTK_WINDOW (w), grid);
w = gtk_label_new ("SSID");
gtk_widget_show (w);
@@ -170,5 +176,6 @@ main (int argc, char *argv[])
gtk_widget_set_hexpand (w, TRUE);
gtk_grid_attach (GTK_GRID (grid), w, 0, 3, 2, 1);
- gtk_main ();
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]