[libnma/lr/gtk-4.0: 12/22] 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: 12/22] tests/bar-code: port to Gtk4
- Date: Wed, 20 Oct 2021 09:53:02 +0000 (UTC)
commit e47e918ec6b13ef857c1af04113a5832cb7a04c5
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 | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/tests/bar-code.c b/src/tests/bar-code.c
index 5cd30072..80fe78d3 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;
@@ -108,10 +108,15 @@ main (int argc, char *argv[])
gtk_init ();
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 +128,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 +175,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]