[gtk/mainloop-cleanup: 17/21] Stop using gtk_main and gtk_main_quit
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/mainloop-cleanup: 17/21] Stop using gtk_main and gtk_main_quit
- Date: Mon, 10 Feb 2020 04:17:23 +0000 (UTC)
commit a6c54669007f3932d6e2813e618bb106579fd28f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 9 22:24:47 2020 -0500
Stop using gtk_main and gtk_main_quit
Replace these calls with direct use of GMainContext api.
docs/tools/shooter.c | 3 +-
gtk/gtktestutils.c | 12 +++--
gtk/tools/gtk-builder-tool-preview.c | 3 +-
tests/animated-resizing.c | 17 ++++++-
tests/animated-revealing.c | 17 ++++++-
tests/frame-stats.c | 2 +-
tests/gdkgears.c | 17 ++++++-
tests/listmodel.c | 3 +-
tests/motion-compression.c | 17 ++++++-
tests/overlayscroll.c | 17 ++++++-
tests/scrolling-performance.c | 18 ++++++-
tests/showrendernode.c | 18 ++++++-
tests/simple.c | 17 ++++++-
tests/syncscroll.c | 3 +-
tests/testaccel.c | 3 +-
tests/testadjustsize.c | 25 +++++++---
tests/testappchooser.c | 17 ++++++-
tests/testappchooserbutton.c | 17 ++++++-
tests/testassistant.c | 18 ++++++-
tests/testbaseline.c | 17 ++++++-
tests/testblur.c | 18 ++++++-
tests/testborderdrawing.c | 16 +++++-
tests/testbox.c | 3 +-
tests/testbuttons.c | 3 +-
tests/testcairo.c | 17 ++++++-
tests/testcalendar.c | 22 +++++++--
tests/testcellarea.c | 3 +-
tests/testcellrenderertext.c | 18 ++++++-
tests/testcenterbox.c | 17 ++++++-
tests/testclipboard2.c | 17 ++++++-
tests/testcolorchooser.c | 9 +++-
tests/testcolorchooser2.c | 3 +-
tests/testcombo.c | 17 ++++++-
tests/testdialog.c | 3 +-
tests/testdnd.c | 17 ++++++-
tests/testdnd2.c | 3 +-
tests/testdnd3.c | 3 +-
tests/testellipsise.c | 17 ++++++-
tests/testemblems.c | 3 +-
tests/testentrycompletion.c | 17 ++++++-
tests/testentryicons.c | 18 ++++++-
tests/testexpand.c | 3 +-
tests/testexpander.c | 14 ++++--
tests/testfilechooser.c | 15 ++++--
tests/testfilechooserbutton.c | 16 +++++-
tests/testflowbox.c | 17 ++++++-
tests/testfontchooser.c | 17 ++++++-
tests/testfontchooserdialog.c | 17 ++++++-
tests/testfontoptions.c | 3 +-
tests/testframe.c | 17 ++++++-
tests/testfullscreen.c | 3 +-
tests/testgaction.c | 9 +---
tests/testgiconpixbuf.c | 17 ++++++-
tests/testglarea.c | 17 ++++++-
tests/testglblending.c | 17 ++++++-
tests/testgmenu.c | 17 ++++++-
tests/testgrid.c | 3 +-
tests/testgridbaseline.c | 3 +-
tests/testgrouping.c | 17 ++++++-
tests/testgtk.c | 94 ++++++++++--------------------------
tests/testheaderbar.c | 19 ++++++--
tests/testheightforwidth.c | 17 ++++++-
tests/testicontheme.c | 17 ++++++-
tests/testiconview-keynav.c | 3 +-
tests/testiconview.c | 3 +-
tests/testkineticscrolling.c | 18 ++++++-
tests/testlevelbar.c | 17 ++++++-
tests/testlist.c | 3 +-
tests/testlist2.c | 17 ++++++-
tests/testlist3.c | 3 +-
tests/testlockbutton.c | 3 +-
tests/testmenubutton.c | 3 +-
tests/testmountoperation.c | 7 ++-
tests/testnoscreen.c | 3 +-
tests/testnotebookdnd.c | 17 ++++++-
tests/testorientable.c | 17 ++++++-
tests/testoutsetshadowdrawing.c | 16 +++++-
tests/testoverlay.c | 3 +-
tests/testoverlaystyleclass.c | 3 +-
tests/testpixbuf-scale.c | 17 ++++++-
tests/testplacesview.c | 17 ++++++-
tests/testpopover.c | 17 ++++++-
tests/testrevealer.c | 3 +-
tests/testscale.c | 17 ++++++-
tests/testscrolledge.c | 3 +-
tests/testscrolledwindow.c | 3 +-
tests/testselectionmode.c | 3 +-
tests/testsensitive.c | 3 +-
tests/testspinbutton.c | 10 +++-
tests/testsplitheaders.c | 3 +-
tests/teststack.c | 3 +-
tests/teststackedheaders.c | 3 +-
tests/testswitch.c | 17 ++++++-
tests/testtexture.c | 17 ++++++-
tests/testtextview.c | 3 +-
tests/testtextview2.c | 17 ++++++-
tests/testtoolbar2.c | 3 +-
tests/testtooltips.c | 17 ++++++-
tests/testtreechanging.c | 17 ++++++-
tests/testtreecolumns.c | 22 +++++++--
tests/testtreecolumnsizing.c | 17 ++++++-
tests/testtreednd.c | 3 +-
tests/testtreeedit.c | 17 ++++++-
tests/testtreeflow.c | 17 ++++++-
tests/testtreefocus.c | 19 ++++++--
tests/testtreelistmodel.c | 17 ++++++-
tests/testtreepos.c | 3 +-
tests/testtreesort.c | 21 ++++++--
tests/testtreeview.c | 17 ++++++-
tests/testverticalcells.c | 17 ++++++-
tests/testvolumebutton.c | 3 +-
tests/testwidgetfocus.c | 17 ++++++-
tests/testwidgettransforms.c | 18 +++++--
tests/testwindowdrag.c | 3 +-
tests/testwindowsize.c | 3 +-
tests/treestoretest.c | 18 ++++++-
tests/video-timer.c | 17 ++++++-
tests/visuals/visuals.c | 19 ++++++--
testsuite/a11y/testfocus.c | 3 +-
testsuite/gtk/displayclose.c | 1 -
testsuite/gtk/templates.c | 15 +++---
121 files changed, 1198 insertions(+), 292 deletions(-)
---
diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c
index 3cb1f86414..5074f3e8bc 100644
--- a/docs/tools/shooter.c
+++ b/docs/tools/shooter.c
@@ -308,7 +308,8 @@ int main (int argc, char **argv)
toplevels = get_all_widgets ();
queue_show ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c
index 34c802bced..4b4018fa81 100644
--- a/gtk/gtktestutils.c
+++ b/gtk/gtktestutils.c
@@ -87,7 +87,11 @@ quit_main_loop_callback (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
- gtk_main_quit ();
+ gboolean *done = user_data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
return G_SOURCE_REMOVE;
}
@@ -108,6 +112,7 @@ void
gtk_test_widget_wait_for_draw (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
+ gboolean done = FALSE;
/* We can do this here because the whole tick procedure does not
* reenter the main loop. Otherwise we'd need to manually get the
@@ -115,10 +120,11 @@ gtk_test_widget_wait_for_draw (GtkWidget *widget)
*/
gtk_widget_add_tick_callback (widget,
quit_main_loop_callback,
- NULL,
+ &done,
NULL);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
static GType *all_registered_types = NULL;
diff --git a/gtk/tools/gtk-builder-tool-preview.c b/gtk/tools/gtk-builder-tool-preview.c
index cc19251235..a5289744cb 100644
--- a/gtk/tools/gtk-builder-tool-preview.c
+++ b/gtk/tools/gtk-builder-tool-preview.c
@@ -143,7 +143,8 @@ preview_file (const char *filename,
gtk_window_present (GTK_WINDOW (window));
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
g_object_unref (builder);
}
diff --git a/tests/animated-resizing.c b/tests/animated-resizing.c
index 0301820d92..ca83ff6c8d 100644
--- a/tests/animated-resizing.c
+++ b/tests/animated-resizing.c
@@ -160,6 +160,17 @@ static GOptionEntry options[] = {
{ NULL }
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main(int argc, char **argv)
{
@@ -168,6 +179,7 @@ main(int argc, char **argv)
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle monitor_bounds;
+ gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@@ -194,7 +206,7 @@ main(int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), da);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), NULL);
g_signal_connect (window, "map",
G_CALLBACK (on_map), NULL);
@@ -206,7 +218,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/animated-revealing.c b/tests/animated-revealing.c
index 72e28459f4..e7f97832ef 100644
--- a/tests/animated-revealing.c
+++ b/tests/animated-revealing.c
@@ -17,6 +17,17 @@ toggle_reveal (GtkRevealer *revealer)
gtk_revealer_set_reveal_child (revealer, !gtk_revealer_get_reveal_child (revealer));
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main(int argc, char **argv)
{
@@ -24,6 +35,7 @@ main(int argc, char **argv)
GtkCssProvider *cssprovider;
GError *error = NULL;
guint x, y;
+ gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@@ -38,7 +50,7 @@ main(int argc, char **argv)
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
frame_stats_ensure (GTK_WINDOW (window));
revealer = gtk_revealer_new ();
@@ -70,7 +82,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/frame-stats.c b/tests/frame-stats.c
index 5d888d2856..289a70c6b7 100644
--- a/tests/frame-stats.c
+++ b/tests/frame-stats.c
@@ -102,7 +102,7 @@ on_frame_clock_after_paint (GdkFrameClock *frame_clock,
variable_init (&frame_stats->latency);
if (frame_stats->num_stats == max_stats)
- gtk_main_quit ();
+ exit (0);
}
frame_stats->frames_since_last_print++;
diff --git a/tests/gdkgears.c b/tests/gdkgears.c
index 2df86a98e2..f5a3d53cd8 100644
--- a/tests/gdkgears.c
+++ b/tests/gdkgears.c
@@ -107,6 +107,17 @@ less_gears (GtkButton *button, gpointer data)
gtk_widget_destroy (gears);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -114,13 +125,14 @@ main (int argc, char *argv[])
*fps_label, *gears, *extra_hbox, *bbox, *overlay,
*revealer, *frame, *label, *scrolled, *popover;
int i;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_titlebar (GTK_WINDOW (window), g_object_new (GTK_TYPE_HEADER_BAR, "visible", TRUE, "title",
"GdkGears", NULL));
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
overlay = gtk_overlay_new ();
g_object_set (overlay, "margin", 12, NULL);
@@ -244,7 +256,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/listmodel.c b/tests/listmodel.c
index c1bd0f933d..33faecc9ff 100644
--- a/tests/listmodel.c
+++ b/tests/listmodel.c
@@ -226,7 +226,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/motion-compression.c b/tests/motion-compression.c
index d69716e5f3..e79bb5c643 100644
--- a/tests/motion-compression.c
+++ b/tests/motion-compression.c
@@ -34,6 +34,17 @@ on_draw (GtkDrawingArea *da,
cairo_stroke (cr);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -43,6 +54,7 @@ main (int argc, char **argv)
GtkWidget *scale;
GtkWidget *da;
GtkEventController *controller;
+ gboolean done = FALSE;
gtk_init ();
@@ -71,10 +83,11 @@ main (int argc, char **argv)
gtk_widget_add_controller (da, controller);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/overlayscroll.c b/tests/overlayscroll.c
index 64f3279351..acd76246b6 100644
--- a/tests/overlayscroll.c
+++ b/tests/overlayscroll.c
@@ -39,6 +39,17 @@ mode_changed (GtkComboBox *combo, GtkScrolledWindow *sw)
gtk_scrolled_window_set_overlay_scrolling (sw, active == 1);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -50,12 +61,13 @@ main (int argc, char *argv[])
GtkWidget *sb2;
GtkWidget *combo;
GtkAdjustment *adj;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
gtk_container_add (GTK_CONTAINER (window), box);
@@ -92,7 +104,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/scrolling-performance.c b/tests/scrolling-performance.c
index bfba4acc74..4f195958ac 100644
--- a/tests/scrolling-performance.c
+++ b/tests/scrolling-performance.c
@@ -92,6 +92,17 @@ static GOptionEntry options[] = {
{ NULL }
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -101,6 +112,7 @@ main (int argc, char **argv)
GtkWidget *grid;
GError *error = NULL;
int i;
+ gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@@ -142,8 +154,10 @@ main (int argc, char **argv)
gtk_widget_show (window);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
- gtk_main ();
+ G_CALLBACK (quit_cb), &done);
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/showrendernode.c b/tests/showrendernode.c
index 6ea4ba1d5d..e1759cd1a1 100644
--- a/tests/showrendernode.c
+++ b/tests/showrendernode.c
@@ -119,6 +119,17 @@ deserialize_error_func (const GtkCssSection *section,
g_free (section_str);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -130,6 +141,7 @@ main (int argc, char **argv)
graphene_rect_t node_bounds;
GOptionContext *option_context;
GError *error = NULL;
+ gboolean done = FALSE;
option_context = g_option_context_new ("NODE-FILE [-o OUTPUT] [--compare]");
g_option_context_add_main_entries (option_context, options, NULL);
@@ -223,9 +235,11 @@ main (int argc, char **argv)
MAX (600, node_bounds.size.width),
MAX (500, node_bounds.size.height));
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/simple.c b/tests/simple.c
index 63ae18f2f6..09de9915c3 100644
--- a/tests/simple.c
+++ b/tests/simple.c
@@ -25,17 +25,29 @@ hello (void)
g_print ("hello world\n");
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window, *button;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "hello world");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
button = gtk_button_new ();
gtk_button_set_label (GTK_BUTTON (button), "hello world");
@@ -45,7 +57,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/syncscroll.c b/tests/syncscroll.c
index 9229ff9aea..d33b6ab850 100644
--- a/tests/syncscroll.c
+++ b/tests/syncscroll.c
@@ -63,7 +63,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testaccel.c b/tests/testaccel.c
index 0cc7d1600b..494eb8add0 100644
--- a/tests/testaccel.c
+++ b/tests/testaccel.c
@@ -128,7 +128,8 @@ main (gint argc, gchar **argv)
gtk_widget_show (dialog);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testadjustsize.c b/tests/testadjustsize.c
index 7bcb86215f..4d03a8ff0e 100644
--- a/tests/testadjustsize.c
+++ b/tests/testadjustsize.c
@@ -30,6 +30,7 @@ enum {
TEST_WIDGET_LAST
};
+static gboolean done = FALSE;
static GtkWidget *test_widgets[TEST_WIDGET_LAST];
static GtkWidget*
@@ -57,6 +58,17 @@ create_button (void)
return gtk_button_new_with_label ("BUTTON!");
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
static void
open_test_window (void)
{
@@ -66,7 +78,7 @@ open_test_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Tests");
- g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), test_window);
+ g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), FALSE);
@@ -131,7 +143,7 @@ open_control_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Controls");
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
@@ -230,7 +242,7 @@ open_alignment_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Alignment");
- g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (test_window), 500, 500);
@@ -291,7 +303,7 @@ open_margin_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Margin");
- g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
@@ -317,7 +329,7 @@ open_valigned_label_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (box);
@@ -372,7 +384,8 @@ main (int argc, char *argv[])
open_margin_window ();
open_valigned_label_window ();
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testappchooser.c b/tests/testappchooser.c
index baf9adcad2..c1e7699986 100644
--- a/tests/testappchooser.c
+++ b/tests/testappchooser.c
@@ -151,11 +151,23 @@ button_clicked (GtkButton *b,
g_free (path);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
GtkWidget *w1;
gchar *path;
+ gboolean done = FALSE;
gtk_init ();
@@ -221,9 +233,10 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (toplevel), grid);
gtk_widget_show (toplevel);
- g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/testappchooserbutton.c b/tests/testappchooserbutton.c
index 6aee3dad6d..8597fcc57c 100644
--- a/tests/testappchooserbutton.c
+++ b/tests/testappchooserbutton.c
@@ -60,11 +60,23 @@ action_cb (GtkAppChooserButton *b,
g_print ("Activated custom item %s\n", item_name);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc,
char **argv)
{
GtkWidget *w;
+ gboolean done = FALSE;
gtk_init ();
@@ -126,9 +138,10 @@ main (int argc,
#endif
gtk_widget_show (toplevel);
- g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/testassistant.c b/tests/testassistant.c
index ec3d3f9928..e59e29ae69 100644
--- a/tests/testassistant.c
+++ b/tests/testassistant.c
@@ -690,11 +690,23 @@ struct {
{ "page-flipping assistant", create_page_flipping_assistant },
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, gchar *argv[])
{
GtkWidget *window, *box, *button;
gint i;
+ gboolean done = FALSE;
gtk_init ();
@@ -704,7 +716,7 @@ main (int argc, gchar *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
- g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);
@@ -721,7 +733,9 @@ main (int argc, gchar *argv[])
}
gtk_widget_show (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testbaseline.c b/tests/testbaseline.c
index 2ab609582f..31269db210 100644
--- a/tests/testbaseline.c
+++ b/tests/testbaseline.c
@@ -66,6 +66,17 @@ set_font_size (GtkWidget *widget, gint size)
gtk_style_context_add_class (gtk_widget_get_style_context (widget), class[size]);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc,
char **argv)
@@ -75,6 +86,7 @@ main (int argc,
GtkAdjustment *adjustment;
int i, j;
GtkCssProvider *provider;
+ gboolean done = FALSE;
gtk_init ();
@@ -88,7 +100,7 @@ main (int argc,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit_cb), &done);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (window), notebook);
@@ -380,7 +392,8 @@ main (int argc,
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testblur.c b/tests/testblur.c
index 99632ffd9c..e425450d9e 100644
--- a/tests/testblur.c
+++ b/tests/testblur.c
@@ -72,6 +72,17 @@ value_changed_cb2 (GtkRange *range,
g_free (text);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -79,11 +90,12 @@ main (int argc, char **argv)
GtkWidget *blur_box;
GtkWidget *scale;
GtkWidget *value_label;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
blur_box = g_object_new (gtk_blur_box_get_type (),
"orientation", GTK_ORIENTATION_VERTICAL,
@@ -115,7 +127,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), blur_box);
gtk_widget_show (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testborderdrawing.c b/tests/testborderdrawing.c
index 80d5b81a96..b99b3aa75d 100644
--- a/tests/testborderdrawing.c
+++ b/tests/testborderdrawing.c
@@ -76,6 +76,16 @@ static const char *css =
"}"
;
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
int
main (int argc, char **argv)
@@ -86,6 +96,7 @@ main (int argc, char **argv)
GtkWidget *bottom;
GtkWidget *w;
GtkCssProvider *provider;
+ gboolean done = FALSE;
gtk_init ();
@@ -151,10 +162,11 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (box), top);
gtk_container_add (GTK_CONTAINER (box), bottom);
gtk_container_add (GTK_CONTAINER (window), box);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);
}
diff --git a/tests/testbox.c b/tests/testbox.c
index 106986d45b..6afd8a6c77 100644
--- a/tests/testbox.c
+++ b/tests/testbox.c
@@ -124,7 +124,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testbuttons.c b/tests/testbuttons.c
index 038dfade80..e34f10654a 100644
--- a/tests/testbuttons.c
+++ b/tests/testbuttons.c
@@ -115,7 +115,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcairo.c b/tests/testcairo.c
index 3f69ae6d48..5732528fa1 100644
--- a/tests/testcairo.c
+++ b/tests/testcairo.c
@@ -184,10 +184,22 @@ on_draw (GtkDrawingArea *darea,
cairo_surface_destroy (circles);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
GtkWidget *window, *darea;
+ gboolean done = FALSE;
gtk_init ();
@@ -200,11 +212,12 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), darea);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (darea), on_draw, NULL, NULL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcalendar.c b/tests/testcalendar.c
index 91cfa9f207..664498caa9 100644
--- a/tests/testcalendar.c
+++ b/tests/testcalendar.c
@@ -163,6 +163,17 @@ create_frame (const char *caption,
return frame;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
static void
create_calendar(void)
{
@@ -182,11 +193,12 @@ create_calendar(void)
{ "show-day-names", "Show Day Names", calendar },
{ "show-week-numbers", "Show Week Numbers", calendar },
};
+ gboolean done = FALSE;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example");
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
@@ -281,7 +293,7 @@ create_calendar(void)
gtk_widget_set_halign (bbox, GTK_ALIGN_END);
button = gtk_button_new_with_label ("Close");
- g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
gtk_container_add (GTK_CONTAINER (bbox), button);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
@@ -297,11 +309,11 @@ create_calendar(void)
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
- g_signal_connect (window, "close-request", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "close-request", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
-
- gtk_main();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
diff --git a/tests/testcellarea.c b/tests/testcellarea.c
index e4d9f19cec..6c4f4225a7 100644
--- a/tests/testcellarea.c
+++ b/tests/testcellarea.c
@@ -612,7 +612,8 @@ main (int argc, char *argv[])
focus_cell_area ();
background_area ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcellrenderertext.c b/tests/testcellrenderertext.c
index 4c35f13ef8..eaa41c47c5 100644
--- a/tests/testcellrenderertext.c
+++ b/tests/testcellrenderertext.c
@@ -246,6 +246,17 @@ create_tree (gboolean rtl)
return sw;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -253,12 +264,13 @@ main (int argc, char **argv)
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *tree;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -282,7 +294,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (vbox), tree);
gtk_widget_show (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcenterbox.c b/tests/testcenterbox.c
index 326a728bfb..e4a1350888 100644
--- a/tests/testcenterbox.c
+++ b/tests/testcenterbox.c
@@ -1,11 +1,23 @@
#include <gtk/gtk.h>
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *box;
GtkWidget *child;
+ gboolean done = FALSE;
gtk_init ();
@@ -28,11 +40,12 @@ main (int argc, char *argv[])
gtk_label_set_ellipsize (GTK_LABEL (child), PANGO_ELLIPSIZE_END);
gtk_center_box_set_end_widget (GTK_CENTER_BOX (box), child);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index e4ed34db37..84918215b1 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -383,11 +383,23 @@ get_window_contents (GdkDisplay *display,
return box;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
GtkWidget *window;
GdkDisplay *alt_display;
+ gboolean done = FALSE;
gtk_init ();
@@ -396,14 +408,15 @@ main (int argc, char **argv)
alt_display = gdk_display_get_default ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_container_add (GTK_CONTAINER (window),
get_window_contents (gtk_widget_get_display (window),
alt_display));
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcolorchooser.c b/tests/testcolorchooser.c
index 0a6fb1d5bc..ee0d643cb7 100644
--- a/tests/testcolorchooser.c
+++ b/tests/testcolorchooser.c
@@ -10,6 +10,8 @@ color_changed (GObject *o, GParamSpec *pspect, gpointer data)
color.red, color.green, color.blue, color.alpha);
}
+static gboolean done = FALSE;
+
static void
dialog_response (GtkDialog *dialog, gint response)
{
@@ -27,7 +29,9 @@ dialog_response (GtkDialog *dialog, gint response)
break;
}
- gtk_main_quit ();
+ done = TRUE;
+
+ g_main_context_wakeup (NULL);
}
int
@@ -96,7 +100,8 @@ main (int argc, char *argv[])
gtk_widget_show (dialog);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcolorchooser2.c b/tests/testcolorchooser2.c
index 15d8a90248..4309d9c754 100644
--- a/tests/testcolorchooser2.c
+++ b/tests/testcolorchooser2.c
@@ -53,7 +53,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testcombo.c b/tests/testcombo.c
index ade1673f80..d6d6d95f1f 100644
--- a/tests/testcombo.c
+++ b/tests/testcombo.c
@@ -919,6 +919,17 @@ displayed_row_changed (GtkComboBox *combo,
gtk_tree_path_free (path);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -932,6 +943,7 @@ main (int argc, char **argv)
GtkCellArea *area;
gchar *text;
gint i;
+ gboolean done = FALSE;
gtk_init ();
@@ -939,7 +951,7 @@ main (int argc, char **argv)
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add (GTK_CONTAINER (window), mainbox);
@@ -1286,7 +1298,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testdialog.c b/tests/testdialog.c
index 7ec34dc9cd..e6053abb2c 100644
--- a/tests/testdialog.c
+++ b/tests/testdialog.c
@@ -420,7 +420,8 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testdnd.c b/tests/testdnd.c
index 54df81423e..32a19de3c3 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -583,6 +583,17 @@ test_init (void)
g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -598,6 +609,7 @@ main (int argc, char **argv)
GtkDragSource *source;
GdkContentFormats *targets;
GtkDropTarget *dest;
+ gboolean done = FALSE;
test_init ();
@@ -605,7 +617,7 @@ main (int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
@@ -679,7 +691,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index f011399525..3323e4aa4c 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -443,7 +443,8 @@ main (int argc, char *Argv[])
gtk_grid_attach (GTK_GRID (grid), make_image ("dialog-information", CENTER), 1, 3, 1, 1);
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testdnd3.c b/tests/testdnd3.c
index f9315569fc..d1e9bfe832 100644
--- a/tests/testdnd3.c
+++ b/tests/testdnd3.c
@@ -392,7 +392,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testellipsise.c b/tests/testellipsise.c
index 7abb58f229..9bae0492f8 100644
--- a/tests/testellipsise.c
+++ b/tests/testellipsise.c
@@ -94,17 +94,29 @@ overlay_draw (GtkDrawingArea *da,
cairo_stroke (cr);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window, *vbox, *label;
GtkWidget *combo, *scale, *overlay, *da;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -141,7 +153,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testemblems.c b/tests/testemblems.c
index cd28b39952..013865afda 100644
--- a/tests/testemblems.c
+++ b/tests/testemblems.c
@@ -35,7 +35,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testentrycompletion.c b/tests/testentrycompletion.c
index 3967c0bba6..ac67928e76 100644
--- a/tests/testentrycompletion.c
+++ b/tests/testentrycompletion.c
@@ -286,6 +286,17 @@ match_selected_cb (GtkEntryCompletion *completion,
return TRUE;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -295,11 +306,12 @@ main (int argc, char *argv[])
GtkEntryCompletion *completion;
GtkTreeModel *completion_model;
GtkCellRenderer *cell;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -407,7 +419,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testentryicons.c b/tests/testentryicons.c
index e117579d2e..31987b18d5 100644
--- a/tests/testentryicons.c
+++ b/tests/testentryicons.c
@@ -74,6 +74,17 @@ icon_pressed_cb (GtkGesture *gesture,
g_print ("You clicked me!\n");
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -90,6 +101,7 @@ main (int argc, char **argv)
GIcon *icon;
GdkContentProvider *content;
GValue value = G_VALUE_INIT;
+ gboolean done = FALSE;
gtk_init ();
@@ -97,7 +109,7 @@ main (int argc, char **argv)
gtk_window_set_title (GTK_WINDOW (window), "Gtk Entry Icons Test");
g_signal_connect (G_OBJECT (window), "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (window), grid);
@@ -284,7 +296,9 @@ main (int argc, char **argv)
gtk_css_provider_load_from_data (provider, cssdata, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider),
800);
gtk_widget_show (window);
- gtk_main();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testexpand.c b/tests/testexpand.c
index 348e66dd85..2339e19db8 100644
--- a/tests/testexpand.c
+++ b/tests/testexpand.c
@@ -156,7 +156,8 @@ main (int argc, char *argv[])
create_box_window ();
create_grid_window ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testexpander.c b/tests/testexpander.c
index 114ef8bc94..486211a5c0 100644
--- a/tests/testexpander.c
+++ b/tests/testexpander.c
@@ -12,9 +12,13 @@ do_not_expand (GtkWidget *child, gpointer data)
}
static void
-response_cb (GtkDialog *dialog, gint response_id)
+response_cb (GtkDialog *dialog, gint response_id, gpointer data)
{
- gtk_main_quit ();
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
}
int
@@ -26,6 +30,7 @@ main (int argc, char *argv[])
GtkWidget *sw;
GtkWidget *tv;
GtkTextBuffer *buffer;
+ gboolean done = FALSE;
gtk_init ();
@@ -71,11 +76,12 @@ main (int argc, char *argv[])
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_cb), dialog);
- g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
+ g_signal_connect (dialog, "response", G_CALLBACK (response_cb), &done);
gtk_window_present (GTK_WINDOW (dialog));
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 2141994275..4ae441ef22 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -70,8 +70,11 @@ print_selected (GtkFileChooser *chooser)
static void
response_cb (GtkDialog *dialog,
- gint response_id)
+ gint response_id,
+ gpointer data)
{
+ gboolean *done = data;
+
if (response_id == GTK_RESPONSE_OK)
{
GSList *list;
@@ -98,7 +101,9 @@ response_cb (GtkDialog *dialog,
else
g_print ("Dialog was closed\n");
- gtk_main_quit ();
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
}
static gboolean
@@ -540,6 +545,7 @@ main (int argc, char **argv)
{ NULL }
};
GOptionContext *context;
+ gboolean done = FALSE;
context = g_option_context_new ("");
g_option_context_add_main_entries (context, options, NULL);
@@ -615,7 +621,7 @@ main (int argc, char **argv)
g_signal_connect (dialog, "current-folder-changed",
G_CALLBACK (print_current_folder), NULL);
g_signal_connect (dialog, "response",
- G_CALLBACK (response_cb), NULL);
+ G_CALLBACK (response_cb), &done);
g_signal_connect (dialog, "confirm-overwrite",
G_CALLBACK (confirm_overwrite_cb), NULL);
@@ -768,7 +774,8 @@ main (int argc, char **argv)
* someone else destroys them. We explicitly destroy windows to catch leaks.
*/
g_object_ref (dialog);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (dialog);
g_object_unref (dialog);
diff --git a/tests/testfilechooserbutton.c b/tests/testfilechooserbutton.c
index 1df31b9a04..39f5eb154c 100644
--- a/tests/testfilechooserbutton.c
+++ b/tests/testfilechooserbutton.c
@@ -242,6 +242,16 @@ add_new_filechooser_button (const gchar *mnemonic,
gtk_container_add (GTK_CONTAINER (hbox), button);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
int
main (int argc,
@@ -251,6 +261,7 @@ main (int argc,
GtkSizeGroup *label_group;
GOptionContext *context;
gchar *cwd;
+ gboolean done = FALSE;
context = g_option_context_new ("- test GtkFileChooserButton widget");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
@@ -269,7 +280,7 @@ main (int argc,
win = gtk_dialog_new_with_buttons ("TestFileChooserButton", NULL, 0,
"_Quit", GTK_RESPONSE_CLOSE, NULL);
- g_signal_connect (win, "response", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (win, "response", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
g_object_set (vbox, "margin", 6, NULL);
@@ -304,7 +315,8 @@ main (int argc,
gtk_widget_show (win);
gtk_window_present (GTK_WINDOW (win));
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testflowbox.c b/tests/testflowbox.c
index f1e8415aeb..0a116cfd84 100644
--- a/tests/testflowbox.c
+++ b/tests/testflowbox.c
@@ -626,20 +626,33 @@ create_window (void)
return window;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
+ gboolean done = FALSE;
gtk_init ();
window = create_window ();
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testfontchooser.c b/tests/testfontchooser.c
index 039a5695b5..fbf3bbc21f 100644
--- a/tests/testfontchooser.c
+++ b/tests/testfontchooser.c
@@ -54,12 +54,24 @@ font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer dat
g_debug ("font-activated: %s", font_name);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *box;
GtkWidget *fontchooser;
+ gboolean done = FALSE;
gtk_init ();
@@ -73,7 +85,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
g_signal_connect (fontchooser, "notify::font",
G_CALLBACK (notify_font_cb), NULL);
g_signal_connect (fontchooser, "notify::preview-text",
@@ -85,7 +97,8 @@ main (int argc, char *argv[])
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ &>>");
gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (fontchooser), FALSE);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testfontchooserdialog.c b/tests/testfontchooserdialog.c
index e85c6dc773..cd35ff98c5 100644
--- a/tests/testfontchooserdialog.c
+++ b/tests/testfontchooserdialog.c
@@ -64,11 +64,23 @@ font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer dat
g_debug ("font-activated: %s", font_name);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *font_button;
+ gboolean done = FALSE;
gtk_init ();
@@ -111,9 +123,10 @@ main (int argc, char *argv[])
monospace_filter, NULL, NULL);
}
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testfontoptions.c b/tests/testfontoptions.c
index 4043146199..0fb225fecf 100644
--- a/tests/testfontoptions.c
+++ b/tests/testfontoptions.c
@@ -85,7 +85,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testframe.c b/tests/testframe.c
index 20ca049ec2..75a16ba527 100644
--- a/tests/testframe.c
+++ b/tests/testframe.c
@@ -124,6 +124,17 @@ draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
gtk_frame_set_shadow_type (frame, shadow_type);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int main (int argc, char **argv)
{
GtkWidget *window, *widget;
@@ -132,13 +143,14 @@ int main (int argc, char **argv)
GtkGrid *grid;
gfloat xalign;
gboolean draw_border;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
g_object_set (vbox, "margin", 12, NULL);
@@ -194,7 +206,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testfullscreen.c b/tests/testfullscreen.c
index 64d8e31d20..3af779c1e3 100644
--- a/tests/testfullscreen.c
+++ b/tests/testfullscreen.c
@@ -68,7 +68,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgaction.c b/tests/testgaction.c
index 8591eae2d5..9a61a5af4e 100644
--- a/tests/testgaction.c
+++ b/tests/testgaction.c
@@ -136,13 +136,8 @@ int main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), box);
-
-
-
-
-
-
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgiconpixbuf.c b/tests/testgiconpixbuf.c
index 8a32943457..bbd1e407d8 100644
--- a/tests/testgiconpixbuf.c
+++ b/tests/testgiconpixbuf.c
@@ -19,6 +19,17 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc,
char **argv)
@@ -28,6 +39,7 @@ main (int argc,
GIcon *emblemed;
GEmblem *emblem;
gchar *str;
+ gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
@@ -70,9 +82,10 @@ main (int argc,
gtk_widget_show (toplevel);
- g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testglarea.c b/tests/testglarea.c
index 08ed63ce73..c2170adb0c 100644
--- a/tests/testglarea.c
+++ b/tests/testglarea.c
@@ -391,11 +391,23 @@ create_axis_slider (int axis)
return box;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window, *box, *button, *controls;
int i;
+ gboolean done = FALSE;
gtk_init ();
@@ -406,7 +418,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GtkGLArea - Triangle");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
@@ -438,7 +450,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/testglblending.c b/tests/testglblending.c
index fea7115582..7e0503537e 100644
--- a/tests/testglblending.c
+++ b/tests/testglblending.c
@@ -3,17 +3,29 @@
#include "gtkgears.h"
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window, *fixed, *gears, *spinner;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Test GL/gtk inter-blending");
gtk_window_set_default_size (GTK_WINDOW (window), 250, 250);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
fixed = gtk_fixed_new ();
gtk_container_add (GTK_CONTAINER (window), fixed);
@@ -75,7 +87,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/testgmenu.c b/tests/testgmenu.c
index ef4702165b..21f1b1250c 100644
--- a/tests/testgmenu.c
+++ b/tests/testgmenu.c
@@ -597,6 +597,17 @@ create_add_remove_buttons (GActionGroup *group,
#define BUS_NAME "org.gtk.TestMenus"
#define OBJ_PATH "/org/gtk/TestMenus"
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -617,6 +628,7 @@ main (int argc, char *argv[])
{ NULL, }
};
GOptionContext *context;
+ gboolean done = FALSE;
context = g_option_context_new ("");
g_option_context_add_main_entries (context, entries, NULL);
@@ -630,7 +642,7 @@ main (int argc, char *argv[])
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);
@@ -681,7 +693,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgrid.c b/tests/testgrid.c
index 4b63268895..733c858327 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -471,7 +471,8 @@ main (int argc, char *argv[])
empty_grid ();
spanning_grid ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgridbaseline.c b/tests/testgridbaseline.c
index 8c097bfd96..40016ca696 100644
--- a/tests/testgridbaseline.c
+++ b/tests/testgridbaseline.c
@@ -53,6 +53,7 @@ main (int argc, char *argv[])
gtk_grid_attach (GTK_GRID (grid), label4, 1, 1, 1, 1);
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgrouping.c b/tests/testgrouping.c
index fbcb20f051..20a08b35ae 100644
--- a/tests/testgrouping.c
+++ b/tests/testgrouping.c
@@ -97,6 +97,17 @@ tree_view_select_func (GtkTreeSelection *selection,
return FALSE;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -104,13 +115,14 @@ main (int argc, char **argv)
GtkTreeModel *model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ gboolean done = FALSE;
gtk_init ();
model = create_model ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 320, 480);
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -148,7 +160,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 998a13d218..f5695c55d1 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -49,6 +49,8 @@
#include "test.xpm"
+static gboolean done = FALSE;
+
gboolean
file_exists (const char *filename)
{
@@ -1701,8 +1703,8 @@ create_key_lookup (GtkWidget *widget)
static gboolean
cmw_destroy_cb(GtkWidget *widget)
{
- /* This is needed to get out of gtk_main */
- gtk_main_quit ();
+ done = TRUE;
+ g_main_context_wakeup (NULL);
return FALSE;
}
@@ -1724,7 +1726,8 @@ cmw_color (GtkWidget *widget, GtkWidget *parent)
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (csd);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
static void
@@ -1748,7 +1751,8 @@ cmw_file (GtkWidget *widget, GtkWidget *parent)
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (fs);
- gtk_main();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
@@ -1804,7 +1808,8 @@ create_modal_window (GtkWidget *widget)
gtk_widget_show (window);
/* wait until dialog get destroyed */
- gtk_main();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
/*
@@ -5680,65 +5685,6 @@ create_timeout_test (GtkWidget *widget)
gtk_widget_destroy (window);
}
-/*
- * Test of recursive mainloop
- */
-
-void
-mainloop_destroyed (GtkWidget *w, GtkWidget **window)
-{
- *window = NULL;
- gtk_main_quit ();
-}
-
-void
-create_mainloop (GtkWidget *widget)
-{
- static GtkWidget *window = NULL;
- GtkWidget *content_area;
- GtkWidget *label;
-
- if (!window)
- {
- window = gtk_dialog_new ();
-
- gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- gtk_window_set_title (GTK_WINDOW (window), "Test Main Loop");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (mainloop_destroyed),
- &window);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
-
- label = gtk_label_new ("In recursive main loop...");
- g_object_set (label, "margin", 20, NULL);
-
- gtk_container_add (GTK_CONTAINER (content_area), label);
- gtk_widget_show (label);
-
- gtk_dialog_add_button (GTK_DIALOG (window),
- "Leave",
- GTK_RESPONSE_OK);
- g_signal_connect_swapped (window, "response",
- G_CALLBACK (gtk_widget_destroy),
- window);
- }
-
- if (!gtk_widget_get_visible (window))
- {
- gtk_widget_show (window);
-
- g_print ("create_mainloop: start\n");
- gtk_main ();
- g_print ("create_mainloop: done\n");
- }
- else
- gtk_widget_destroy (window);
-}
-
static void
show_native (GtkWidget *button,
GtkFileChooserNative *native)
@@ -6125,7 +6071,8 @@ void
do_exit (GtkWidget *widget, GtkWidget *window)
{
gtk_widget_destroy (window);
- gtk_main_quit ();
+ done = TRUE;
+ g_main_context_wakeup (NULL);
}
struct {
@@ -6164,7 +6111,6 @@ struct {
{ "size groups", create_size_groups },
{ "spinbutton", create_spins },
{ "statusbar", create_statusbar },
- { "test mainloop", create_mainloop, TRUE },
{ "test timeout", create_timeout_test },
{ "toggle buttons", create_toggle_buttons },
{ "tooltips", create_tooltips },
@@ -6174,6 +6120,17 @@ struct {
};
int nbuttons = sizeof (buttons) / sizeof (buttons[0]);
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
void
create_main_window (void)
{
@@ -6191,7 +6148,7 @@ create_main_window (void)
gtk_widget_set_name (window, "main_window");
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
@@ -6476,7 +6433,8 @@ main (int argc, char *argv[])
create_main_window ();
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
if (1)
{
diff --git a/tests/testheaderbar.c b/tests/testheaderbar.c
index 51f5a97a13..d366ab1766 100644
--- a/tests/testheaderbar.c
+++ b/tests/testheaderbar.c
@@ -70,6 +70,19 @@ toggle_fullscreen (GtkButton *button, gpointer data)
}
}
+static gboolean done = FALSE;
+
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
static void
change_header (GtkButton *button, gpointer data)
{
@@ -100,7 +113,7 @@ change_header (GtkButton *button, gpointer data)
widget = gtk_button_new_with_label ("_Close");
gtk_button_set_use_underline (GTK_BUTTON (widget), TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "suggested-action");
- g_signal_connect (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (widget, "clicked", G_CALLBACK (quit_cb), &done);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);
@@ -142,7 +155,6 @@ main (int argc, char *argv[])
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
-
content = gtk_image_new_from_icon_name ("start-here-symbolic");
gtk_image_set_pixel_size (GTK_IMAGE (content), 512);
@@ -162,7 +174,8 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (box), footer);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);
diff --git a/tests/testheightforwidth.c b/tests/testheightforwidth.c
index 3a09bede1e..2ae275cf2d 100644
--- a/tests/testheightforwidth.c
+++ b/tests/testheightforwidth.c
@@ -830,20 +830,33 @@ create_window (void)
return window;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
+ gboolean done = FALSE;
gtk_init ();
window = create_window ();
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testicontheme.c b/tests/testicontheme.c
index d4b330d664..95644a4128 100644
--- a/tests/testicontheme.c
+++ b/tests/testicontheme.c
@@ -32,6 +32,17 @@ usage (void)
);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -71,6 +82,7 @@ main (int argc, char *argv[])
{
GtkIconPaintable *icon;
GtkWidget *window, *image;
+ gboolean done = FALSE;
if (argc < 4)
{
@@ -97,10 +109,11 @@ main (int argc, char *argv[])
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (icon));
g_object_unref (icon);
gtk_container_add (GTK_CONTAINER (window), image);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
else if (strcmp (argv[1], "list") == 0)
{
diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c
index 69a9b95869..2a653ce083 100644
--- a/tests/testiconview-keynav.c
+++ b/tests/testiconview-keynav.c
@@ -261,7 +261,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testiconview.c b/tests/testiconview.c
index f82d706950..0398f11bf6 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -588,7 +588,8 @@ main (gint argc, gchar **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testkineticscrolling.c b/tests/testkineticscrolling.c
index cc866e5f51..46365bd271 100644
--- a/tests/testkineticscrolling.c
+++ b/tests/testkineticscrolling.c
@@ -11,6 +11,19 @@ on_button_clicked (GtkWidget *widget, gpointer data)
g_print ("Button %d clicked\n", GPOINTER_TO_INT (data));
}
+static gboolean done = FALSE;
+
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
static void
kinetic_scrolling (void)
{
@@ -26,7 +39,7 @@ kinetic_scrolling (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
@@ -136,7 +149,8 @@ main (int argc, char **argv)
kinetic_scrolling ();
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testlevelbar.c b/tests/testlevelbar.c
index 255bd1d523..9a94e7dbd2 100644
--- a/tests/testlevelbar.c
+++ b/tests/testlevelbar.c
@@ -64,6 +64,17 @@ toggle (GtkSwitch *sw, GParamSpec *pspec, GtkLevelBar *bar)
gtk_level_bar_set_mode (bar, GTK_LEVEL_BAR_MODE_CONTINUOUS);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -72,6 +83,7 @@ main (int argc, char *argv[])
GtkWidget *bar;
GtkWidget *box2;
GtkWidget *sw;
+ gboolean done = FALSE;
gtk_init ();
@@ -93,10 +105,11 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
g_timeout_add (100, increase_level, bar);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testlist.c b/tests/testlist.c
index 8e3f8b9007..340afbd133 100644
--- a/tests/testlist.c
+++ b/tests/testlist.c
@@ -367,7 +367,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testlist2.c b/tests/testlist2.c
index c329f06fe5..601567ac68 100644
--- a/tests/testlist2.c
+++ b/tests/testlist2.c
@@ -95,11 +95,23 @@ create_row (const gchar *text)
return row;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int main (int argc, char *argv[])
{
GtkWidget *window, *list, *sw, *row;
gint i;
gchar *text;
+ gboolean done = FALSE;
gtk_init ();
@@ -120,10 +132,11 @@ int main (int argc, char *argv[])
gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
}
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 59120cc6bb..a9063eff17 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -196,7 +196,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testlockbutton.c b/tests/testlockbutton.c
index 732f8bdbd1..d954b6731a 100644
--- a/tests/testlockbutton.c
+++ b/tests/testlockbutton.c
@@ -263,7 +263,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_widget_show (dialog);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c
index 7e3d945b73..35e6dc9bc9 100644
--- a/tests/testmenubutton.c
+++ b/tests/testmenubutton.c
@@ -129,7 +129,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testmountoperation.c b/tests/testmountoperation.c
index 0a707e2e0c..c4cecc3032 100644
--- a/tests/testmountoperation.c
+++ b/tests/testmountoperation.c
@@ -26,6 +26,7 @@ static gboolean dont_ask_domain = FALSE;
static gboolean dont_ask_password = FALSE;
static gboolean dont_save_password = FALSE;
+static gboolean done = FALSE;
static void
got_reply (GMountOperation *op,
@@ -87,7 +88,8 @@ got_reply (GMountOperation *op,
else if (G_MOUNT_OPERATION_UNHANDLED)
g_assert_not_reached ();
- gtk_main_quit ();
+ done = TRUE;
+ g_main_context_wakeup (NULL);
}
int
@@ -163,6 +165,7 @@ main (int argc, char *argv[])
flags);
}
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testnoscreen.c b/tests/testnoscreen.c
index f6474bb298..8428e66497 100644
--- a/tests/testnoscreen.c
+++ b/tests/testnoscreen.c
@@ -43,7 +43,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c
index fe99dfc21d..2c23816541 100644
--- a/tests/testnotebookdnd.c
+++ b/tests/testnotebookdnd.c
@@ -308,10 +308,22 @@ create_trash_button (void)
return button;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
gint
main (gint argc, gchar *argv[])
{
GtkWidget *window, *grid;
+ gboolean done = FALSE;
gtk_init ();
@@ -341,11 +353,12 @@ main (gint argc, gchar *argv[])
gtk_container_add (GTK_CONTAINER (window), grid);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testorientable.c b/tests/testorientable.c
index c002eebd96..152336810e 100644
--- a/tests/testorientable.c
+++ b/tests/testorientable.c
@@ -43,6 +43,17 @@ orient_toggled (GtkToggleButton *button, gpointer user_data)
}
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -50,6 +61,7 @@ main (int argc, char **argv)
GtkWidget *grid;
GtkWidget *box, *button;
GList *orientables = NULL;
+ gboolean done = FALSE;
gtk_init ();
@@ -83,9 +95,10 @@ main (int argc, char **argv)
gtk_widget_show (window);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testoutsetshadowdrawing.c b/tests/testoutsetshadowdrawing.c
index 96462a3310..959a5a0ca7 100644
--- a/tests/testoutsetshadowdrawing.c
+++ b/tests/testoutsetshadowdrawing.c
@@ -73,6 +73,16 @@ static const char *css =
""
;
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
int
main (int argc, char **argv)
@@ -83,6 +93,7 @@ main (int argc, char **argv)
GtkWidget *bottom;
GtkWidget *w;
GtkCssProvider *provider;
+ gboolean done = FALSE;
gtk_init ();
@@ -149,8 +160,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (box), top);
gtk_container_add (GTK_CONTAINER (box), bottom);
gtk_container_add (GTK_CONTAINER (window), box);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index b73b0fc783..4e93a32f43 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -529,7 +529,8 @@ main (int argc, char *argv[])
win8 = test_input_stacking ();
gtk_widget_show (win8);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testoverlaystyleclass.c b/tests/testoverlaystyleclass.c
index 37a857d265..a400e54812 100644
--- a/tests/testoverlaystyleclass.c
+++ b/tests/testoverlaystyleclass.c
@@ -156,7 +156,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testpixbuf-scale.c b/tests/testpixbuf-scale.c
index 5e48ef8bd1..ae2bde9fd5 100644
--- a/tests/testpixbuf-scale.c
+++ b/tests/testpixbuf-scale.c
@@ -56,6 +56,17 @@ draw_func (GtkDrawingArea *darea,
g_object_unref (dest);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main(int argc, char **argv)
{
@@ -66,6 +77,7 @@ main(int argc, char **argv)
GtkRequisition scratch_requisition;
const gchar *creator;
GError *error;
+ gboolean done = FALSE;
gtk_init ();
@@ -89,7 +101,7 @@ main(int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -141,7 +153,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testplacesview.c b/tests/testplacesview.c
index e258c4405d..bd93224524 100644
--- a/tests/testplacesview.c
+++ b/tests/testplacesview.c
@@ -2,11 +2,23 @@
#define GTK_COMPILATION
#include "gtk/gtkplacesviewprivate.h"
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *win;
GtkWidget *view;
+ gboolean done = FALSE;
gtk_init ();
@@ -18,9 +30,10 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (win), view);
gtk_widget_show (win);
- g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), win);
+ g_signal_connect (win, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testpopover.c b/tests/testpopover.c
index 7927362d57..3b87341eb7 100644
--- a/tests/testpopover.c
+++ b/tests/testpopover.c
@@ -31,6 +31,17 @@ static GActionEntry entries[] = {
{ "action10", activate, NULL, NULL, NULL }
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -51,6 +62,7 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *combo;
GtkWidget *header_bar;
+ gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
@@ -167,10 +179,11 @@ main (int argc, char *argv[])
g_object_unref (builder);
- g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (win, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (win);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testrevealer.c b/tests/testrevealer.c
index cb2cf9b952..d4e653fa71 100644
--- a/tests/testrevealer.c
+++ b/tests/testrevealer.c
@@ -163,7 +163,8 @@ main (gint argc,
gtk_grid_attach (GTK_GRID (box), revealer, 3, 4, 1, 1);
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);
diff --git a/tests/testscale.c b/tests/testscale.c
index 33280dcf37..4c7bc652e7 100644
--- a/tests/testscale.c
+++ b/tests/testscale.c
@@ -88,6 +88,17 @@ extra (GtkToggleButton *button)
}
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int main (int argc, char *argv[])
{
GtkWidget *window;
@@ -113,12 +124,13 @@ int main (int argc, char *argv[])
gdouble pos_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
const gchar *pos_labels[4] = { "Left", "Right", "Top", "Bottom" };
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Ranges with marks");
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
flipbox = box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_hexpand (flipbox, TRUE);
@@ -228,7 +240,8 @@ int main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testscrolledge.c b/tests/testscrolledge.c
index 03a0b669fe..6c0f7c5298 100644
--- a/tests/testscrolledge.c
+++ b/tests/testscrolledge.c
@@ -129,7 +129,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testscrolledwindow.c b/tests/testscrolledwindow.c
index 417f172217..e045f7c0ea 100644
--- a/tests/testscrolledwindow.c
+++ b/tests/testscrolledwindow.c
@@ -327,7 +327,8 @@ main (int argc, char *argv[])
scrollable_policy ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testselectionmode.c b/tests/testselectionmode.c
index 2174d195de..f496409e30 100644
--- a/tests/testselectionmode.c
+++ b/tests/testselectionmode.c
@@ -213,7 +213,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testsensitive.c b/tests/testsensitive.c
index 4085b51373..6619340dbb 100644
--- a/tests/testsensitive.c
+++ b/tests/testsensitive.c
@@ -81,7 +81,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testspinbutton.c b/tests/testspinbutton.c
index 49420a69a5..4b9df504af 100644
--- a/tests/testspinbutton.c
+++ b/tests/testspinbutton.c
@@ -20,12 +20,17 @@
static gint num_windows = 0;
+static gboolean done = FALSE;
+
static gboolean
on_delete (GtkWindow *w)
{
num_windows--;
if (num_windows == 0)
- gtk_main_quit ();
+ {
+ done = TRUE;
+ g_main_context_wakeup (NULL);
+ }
return FALSE;
}
@@ -76,7 +81,8 @@ main (int argc, char **argv)
prepare_window_for_orientation (GTK_ORIENTATION_HORIZONTAL);
prepare_window_for_orientation (GTK_ORIENTATION_VERTICAL);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testsplitheaders.c b/tests/testsplitheaders.c
index 62cb8902c9..7bbf8d3c89 100644
--- a/tests/testsplitheaders.c
+++ b/tests/testsplitheaders.c
@@ -73,7 +73,8 @@ main (int argc, char *argv[])
G_BINDING_DEFAULT);
gtk_window_present (GTK_WINDOW (win));
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/teststack.c b/tests/teststack.c
index 672a12fd12..ef53d67ebc 100644
--- a/tests/teststack.c
+++ b/tests/teststack.c
@@ -257,7 +257,8 @@ main (gint argc,
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);
diff --git a/tests/teststackedheaders.c b/tests/teststackedheaders.c
index 7febdd6dea..0e40b62237 100644
--- a/tests/teststackedheaders.c
+++ b/tests/teststackedheaders.c
@@ -39,7 +39,8 @@ main (int argc, char *argv[])
gtk_window_present (GTK_WINDOW (win));
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testswitch.c b/tests/testswitch.c
index 9d9ded6d45..e54ad9522d 100644
--- a/tests/testswitch.c
+++ b/tests/testswitch.c
@@ -147,17 +147,29 @@ make_delayed_switch (gboolean is_on,
return hbox;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *vbox, *hbox;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GtkSwitch");
gtk_window_set_default_size (GTK_WINDOW (window), 400, -1);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
@@ -178,7 +190,8 @@ int main (int argc, char *argv[])
hbox = make_delayed_switch (FALSE, TRUE);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}
diff --git a/tests/testtexture.c b/tests/testtexture.c
index 3fe7dc358f..1389d30841 100644
--- a/tests/testtexture.c
+++ b/tests/testtexture.c
@@ -100,6 +100,17 @@ gtk_texture_view_class_init (GtkTextureViewClass *klass)
widget_class->snapshot = gtk_texture_view_snapshot;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -108,6 +119,7 @@ main (int argc, char **argv)
GdkTexture *texture;
GFile *file;
GError *error = NULL;
+ gboolean done = FALSE;
gtk_init ();
@@ -127,15 +139,16 @@ main (int argc, char **argv)
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
view = g_object_new (GTK_TYPE_TEXTURE_VIEW, NULL);
((GtkTextureView*)view)->texture = g_steal_pointer (&texture);
gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
g_object_unref (file);
diff --git a/tests/testtextview.c b/tests/testtextview.c
index c0458e2dd9..6ffe1b3b60 100644
--- a/tests/testtextview.c
+++ b/tests/testtextview.c
@@ -202,7 +202,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtextview2.c b/tests/testtextview2.c
index 83431bfc31..36e037887f 100644
--- a/tests/testtextview2.c
+++ b/tests/testtextview2.c
@@ -171,16 +171,28 @@ update_mark_position (void)
gtk_text_buffer_move_mark (buffer, the_mark, &iter);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window, *sw, *box, *box2, *button;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
@@ -232,7 +244,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtoolbar2.c b/tests/testtoolbar2.c
index 4b1b24e0fd..47174d9b49 100644
--- a/tests/testtoolbar2.c
+++ b/tests/testtoolbar2.c
@@ -34,7 +34,8 @@ int main (int argc, char *argv[])
gtk_widget_show (GTK_WIDGET (window));
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 0f9af5ce05..3ae905ed9c 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -260,6 +260,17 @@ query_tooltip_label_cb (GtkWidget *widget,
return TRUE;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -281,12 +292,13 @@ main (int argc, char *argv[])
GtkTextTag *tag;
gchar *text, *markup;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Tooltips test");
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_container_add (GTK_CONTAINER (window), box);
@@ -436,7 +448,8 @@ main (int argc, char *argv[])
/* Done! */
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreechanging.c b/tests/testtreechanging.c
index 0b5d6d8c06..f651bf07ee 100644
--- a/tests/testtreechanging.c
+++ b/tests/testtreechanging.c
@@ -464,6 +464,17 @@ setup_sanity_checks (GtkTreeView *treeview)
selection_changed_cb (gtk_tree_view_get_selection (treeview), NULL);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc,
char **argv)
@@ -473,6 +484,7 @@ main (int argc,
GtkWidget *treeview;
GtkTreeModel *model;
guint i;
+ gboolean done = FALSE;
gtk_init ();
@@ -480,7 +492,7 @@ main (int argc,
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -509,7 +521,8 @@ main (int argc,
g_idle_add (dance, treeview);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreecolumns.c b/tests/testtreecolumns.c
index b22f5fbf95..7f44f7f18c 100644
--- a/tests/testtreecolumns.c
+++ b/tests/testtreecolumns.c
@@ -707,6 +707,17 @@ static const char *row_targets[] = {
"GTK_TREE_MODEL_ROW"
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -720,6 +731,7 @@ main (int argc, char *argv[])
GtkTreeModel *sample_model;
GdkContentFormats *targets;
gint i;
+ gboolean done = FALSE;
gtk_init ();
@@ -744,7 +756,7 @@ main (int argc, char *argv[])
/* Set up the test windows. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
gtk_window_set_title (GTK_WINDOW (window), "Top Window");
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -753,7 +765,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
gtk_window_set_title (GTK_WINDOW (window), "Bottom Window");
swindow = gtk_scrolled_window_new (NULL, NULL);
@@ -763,7 +775,7 @@ main (int argc, char *argv[])
/* Set up the main window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 500, 300);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -897,7 +909,9 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (hbox), button);
gtk_widget_show (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreecolumnsizing.c b/tests/testtreecolumnsizing.c
index 7bd3187b58..00e347b456 100644
--- a/tests/testtreecolumnsizing.c
+++ b/tests/testtreecolumnsizing.c
@@ -159,6 +159,17 @@ combo_box_changed (GtkComboBox *combo_box,
g_list_free (columns);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -169,13 +180,14 @@ main (int argc, char **argv)
GtkWidget *sw;
GtkWidget *tree_view;
GtkWidget *button;
+ gboolean done = FALSE;
gtk_init ();
/* Window and box */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -231,7 +243,8 @@ main (int argc, char **argv)
/* Done */
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreednd.c b/tests/testtreednd.c
index 306e87ad45..16cabbba01 100644
--- a/tests/testtreednd.c
+++ b/tests/testtreednd.c
@@ -151,7 +151,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c
index 0b47b28a33..825bb9fef9 100644
--- a/tests/testtreeedit.c
+++ b/tests/testtreeedit.c
@@ -214,6 +214,17 @@ create_control (GtkWidget *box, gint number, gint cntl, CallbackData *data)
g_free (name);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
gint
main (gint argc, gchar **argv)
{
@@ -227,6 +238,7 @@ main (gint argc, gchar **argv)
GtkCellArea *area;
CallbackData callback[4];
GtkGesture *gesture;
+ gboolean done = FALSE;
gtk_init ();
@@ -235,7 +247,7 @@ main (gint argc, gchar **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GtkTreeView editing sample");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -381,7 +393,8 @@ main (gint argc, gchar **argv)
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreeflow.c b/tests/testtreeflow.c
index 6155744595..ee77e73fa5 100644
--- a/tests/testtreeflow.c
+++ b/tests/testtreeflow.c
@@ -116,6 +116,17 @@ futz (void)
return TRUE;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -126,13 +137,14 @@ main (int argc, char *argv[])
GtkWidget *hbox;
GtkWidget *button;
GtkTreePath *path;
+ gboolean done = FALSE;
gtk_init ();
path = gtk_tree_path_new_from_string ("80");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Reflow test");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Incremental Reflow Test"));
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -166,6 +178,7 @@ main (int argc, char *argv[])
gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
gtk_widget_show (window);
g_timeout_add (1000, (GSourceFunc) futz, NULL);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreefocus.c b/tests/testtreefocus.c
index 65cebaf587..1088082796 100644
--- a/tests/testtreefocus.c
+++ b/tests/testtreefocus.c
@@ -334,6 +334,17 @@ set_indicator_size (GtkTreeViewColumn *column,
g_object_set (cell, "indicator_size", size, NULL);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -345,12 +356,13 @@ main (int argc, char *argv[])
GtkCellRenderer *renderer;
gint col_offset;
GtkTreeViewColumn *column;
+ gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Card planning sheet");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Jonathan's Holiday Card Planning Sheet"));
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -465,7 +477,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Model");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("The model revealed"));
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -531,7 +543,8 @@ main (int argc, char *argv[])
650, 400);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreelistmodel.c b/tests/testtreelistmodel.c
index 277a6e156d..199af7cb75 100644
--- a/tests/testtreelistmodel.c
+++ b/tests/testtreelistmodel.c
@@ -297,6 +297,17 @@ match_file (gpointer item, gpointer data)
return result;
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -307,12 +318,13 @@ main (int argc, char *argv[])
GtkFilterListModel *filter;
GtkSliceListModel *slice;
GFile *root;
+ gboolean done = FALSE;
gtk_init ();
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
- g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), win);
+ g_signal_connect (win, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (win), vbox);
@@ -375,7 +387,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreepos.c b/tests/testtreepos.c
index 39944a26b7..564eb4902b 100644
--- a/tests/testtreepos.c
+++ b/tests/testtreepos.c
@@ -138,7 +138,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreesort.c b/tests/testtreesort.c
index 14a1b25e1e..b24f5cd61b 100644
--- a/tests/testtreesort.c
+++ b/tests/testtreesort.c
@@ -93,6 +93,17 @@ switch_search_method (GtkWidget *button,
gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), NULL);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -111,6 +122,7 @@ main (int argc, char *argv[])
GtkWidget *entry, *button;
GtkWidget *window2, *vbox2, *scrolled_window2, *tree_view2;
GtkWidget *window3, *vbox3, *scrolled_window3, *tree_view3;
+ gboolean done = FALSE;
gtk_init ();
@@ -120,7 +132,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Words, words, words - Window 1");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Jonathan and Kristian's list of cool words. (And
Anders' cool list of numbers) \n\nThis is just a GtkTreeStore"));
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -248,7 +260,7 @@ main (int argc, char *argv[])
window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window2),
"Words, words, words - window 2");
- g_signal_connect (window2, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window2, "destroy", G_CALLBACK (quit_cb), &done);
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox2),
gtk_label_new ("Jonathan and Kristian's list of words.\n\nA GtkTreeModelSort
wrapping the GtkTreeStore of window 1"));
@@ -317,7 +329,7 @@ main (int argc, char *argv[])
window3 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window3),
"Words, words, words - Window 3");
- g_signal_connect (window3, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window3, "destroy", G_CALLBACK (quit_cb), &done);
vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (vbox3),
gtk_label_new ("Jonathan and Kristian's list of words.\n\nA GtkTreeModelSort
wrapping the GtkTreeModelSort of window 2"));
@@ -400,7 +412,8 @@ main (int argc, char *argv[])
}
}
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testtreeview.c b/tests/testtreeview.c
index 37735cda33..903af9fa61 100644
--- a/tests/testtreeview.c
+++ b/tests/testtreeview.c
@@ -645,6 +645,17 @@ static const char *row_targets[] = {
"GTK_TREE_MODEL_ROW"
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc,
char **argv)
@@ -657,6 +668,7 @@ main (int argc,
GtkTreeModel *model;
GdkContentFormats *targets;
gint i;
+ gboolean done = FALSE;
gtk_init ();
@@ -687,7 +699,7 @@ main (int argc,
run_automated_tests ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -749,7 +761,8 @@ main (int argc,
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testverticalcells.c b/tests/testverticalcells.c
index 15512e114e..6946987e04 100644
--- a/tests/testverticalcells.c
+++ b/tests/testverticalcells.c
@@ -288,6 +288,17 @@ create_model (void)
return GTK_TREE_MODEL (model);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
gint
main (gint argc, gchar **argv)
{
@@ -298,6 +309,7 @@ main (gint argc, gchar **argv)
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkCellArea *area;
+ gboolean done = FALSE;
gtk_init ();
@@ -306,7 +318,7 @@ main (gint argc, gchar **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Vertical cells in GtkTreeViewColumn example");
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN);
@@ -371,7 +383,8 @@ main (gint argc, gchar **argv)
800, 400);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testvolumebutton.c b/tests/testvolumebutton.c
index 04bff92ccd..f35f31f139 100644
--- a/tests/testvolumebutton.c
+++ b/tests/testvolumebutton.c
@@ -114,7 +114,8 @@ main (int argc,
g_signal_emit_by_name (button, "clicked");
g_timeout_add (4000, (GSourceFunc) show_error, window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testwidgetfocus.c b/tests/testwidgetfocus.c
index 0ee9e7903c..08b92add02 100644
--- a/tests/testwidgetfocus.c
+++ b/tests/testwidgetfocus.c
@@ -265,12 +265,24 @@ gtk_focus_widget_class_init (GtkFocusWidgetClass *klass)
gtk_widget_class_set_css_name (widget_class, "focuswidget");
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main()
{
GtkWidget *window;
GtkWidget *widget;
GtkCssProvider *provider;
+ gboolean done = FALSE;
gtk_init ();
@@ -286,9 +298,10 @@ main()
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_container_add (GTK_CONTAINER (window), widget);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
}
diff --git a/tests/testwidgettransforms.c b/tests/testwidgettransforms.c
index d8cf78fc6c..f5a6f0aa78 100644
--- a/tests/testwidgettransforms.c
+++ b/tests/testwidgettransforms.c
@@ -278,6 +278,17 @@ toggled_cb (GtkToggleButton *source,
do_picking = gtk_toggle_button_get_active (source);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -287,6 +298,7 @@ main (int argc, char **argv)
GtkWidget *titlebar;
GtkWidget *toggle_button;
GtkCssProvider *provider;
+ gboolean done = FALSE;
gtk_init ();
@@ -296,7 +308,6 @@ main (int argc, char **argv)
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
matrix_chooser = g_object_new (GTK_TYPE_MATRIX_CHOOSER, NULL);
transform_tester = g_object_new (GTK_TYPE_TRANSFORM_TESTER, NULL);
@@ -333,10 +344,11 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), box);
gtk_window_set_default_size ((GtkWindow *)window, 200, 200);
- g_signal_connect (window, "close-request", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "close-request", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testwindowdrag.c b/tests/testwindowdrag.c
index baa49952ac..527684ea97 100644
--- a/tests/testwindowdrag.c
+++ b/tests/testwindowdrag.c
@@ -134,7 +134,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index e5fb876906..038c66887f 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -138,7 +138,8 @@ main (int argc, char *argv[])
create_window ();
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/treestoretest.c b/tests/treestoretest.c
index 2eaddcf702..32684b78ba 100644
--- a/tests/treestoretest.c
+++ b/tests/treestoretest.c
@@ -276,6 +276,19 @@ iter_append (GtkWidget *button, GtkTreeView *tree_view)
}
}
+static gboolean done = FALSE;
+
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
static void
make_window (gint view_type)
{
@@ -334,7 +347,7 @@ make_window (gint view_type)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
/* buttons */
button = gtk_button_new_with_label ("gtk_tree_store_remove");
@@ -448,7 +461,8 @@ main (int argc, char *argv[])
make_window (0);
make_window (1);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/video-timer.c b/tests/video-timer.c
index 033425ece4..14fcbfc0ba 100644
--- a/tests/video-timer.c
+++ b/tests/video-timer.c
@@ -359,6 +359,17 @@ static GOptionEntry options[] = {
{ NULL }
};
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main(int argc, char **argv)
{
@@ -366,6 +377,7 @@ main(int argc, char **argv)
GError *error = NULL;
GdkFrameClock *frame_clock;
GOptionContext *context;
+ gboolean done = FALSE;
context = g_option_context_new ("");
g_option_context_add_main_entries (context, options, NULL);
@@ -383,7 +395,7 @@ main(int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ G_CALLBACK (quit_cb), &done);
da = gtk_drawing_area_new ();
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), on_draw, NULL, NULL);
@@ -402,7 +414,8 @@ main(int argc, char **argv)
G_CALLBACK (on_update), NULL);
gdk_frame_clock_begin_updating (frame_clock);
- gtk_main ();
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/tests/visuals/visuals.c b/tests/visuals/visuals.c
index 069d8132f3..85de8b8cbd 100644
--- a/tests/visuals/visuals.c
+++ b/tests/visuals/visuals.c
@@ -53,12 +53,24 @@ create_dark_popup (GtkWidget *parent)
gtk_widget_show (popup);
}
+static void
+quit_cb (GtkWidget *widget,
+ gpointer data)
+{
+ gboolean *done = data;
+
+ *done = TRUE;
+
+ g_main_context_wakeup (NULL);
+}
+
int
main (int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
const gchar *filename;
+ gboolean done = FALSE;
gtk_init ();
@@ -71,12 +83,13 @@ main (int argc, char *argv[])
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
g_object_unref (G_OBJECT (builder));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
create_dark_popup (window);
- gtk_main ();
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/testsuite/a11y/testfocus.c b/testsuite/a11y/testfocus.c
index 51e3b179cd..6775e6d170 100644
--- a/testsuite/a11y/testfocus.c
+++ b/testsuite/a11y/testfocus.c
@@ -110,7 +110,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
- gtk_main ();
+ while (TRUE)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/testsuite/gtk/displayclose.c b/testsuite/gtk/displayclose.c
index 47794a476d..b1f66e2a32 100644
--- a/testsuite/gtk/displayclose.c
+++ b/testsuite/gtk/displayclose.c
@@ -24,7 +24,6 @@ main (int argc, char **argv)
gdk_display_manager_set_default_display (gdk_display_manager_get (), display);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
but = gtk_button_new_with_label ("Try to Exit");
g_signal_connect_swapped (but, "clicked",
diff --git a/testsuite/gtk/templates.c b/testsuite/gtk/templates.c
index d3ed82653b..1ec40ab045 100644
--- a/testsuite/gtk/templates.c
+++ b/testsuite/gtk/templates.c
@@ -180,7 +180,7 @@ static void
test_app_chooser_dialog_basic (void)
{
GtkWidget *widget;
- gboolean done;
+ gboolean done = FALSE;
widget = gtk_app_chooser_dialog_new_for_content_type (NULL, 0, "text/plain");
g_assert (GTK_IS_APP_CHOOSER_DIALOG (widget));
@@ -189,7 +189,6 @@ test_app_chooser_dialog_basic (void)
* the main context then app_chooser_online_get_default_ready_cb()
* will be eventually called and segfault.
*/
- done = FALSE;
g_timeout_add (500, main_loop_quit_cb, &done);
while (!done)
g_main_context_iteration (NULL, TRUE);
@@ -224,6 +223,7 @@ static void
test_file_chooser_widget_basic (void)
{
GtkWidget *widget;
+ gboolean done = FALSE;
/* This test also tests the internal GtkPathBar widget */
g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL);
@@ -240,8 +240,9 @@ test_file_chooser_widget_basic (void)
* Since we assert all automated children are finalized we
* can catch this
*/
- g_timeout_add (100, main_loop_quit_cb, NULL);
- gtk_main();
+ g_timeout_add (100, main_loop_quit_cb, &done);
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (widget);
}
@@ -272,13 +273,15 @@ static void
test_file_chooser_button_basic (void)
{
GtkWidget *widget;
+ gboolean done = FALSE;
g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL);
widget = gtk_file_chooser_button_new ("Choose a file !", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
g_assert (GTK_IS_FILE_CHOOSER_BUTTON (widget));
- g_timeout_add (100, main_loop_quit_cb, NULL);
- gtk_main();
+ g_timeout_add (100, main_loop_quit_cb, &done);
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]