From: Matthias Clasen Date: Tue, 21 Jan 2020 21:57:20 +0000 (-0500) Subject: widget-factory: Add a way to quit automatically X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~243^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a6f300cefd2edfb7789e75565adb03f82a701530;p=gtk4.git widget-factory: Add a way to quit automatically This can be used to measure startup cost in tests. --- diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 559fb82c87..d50143deda 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -2000,6 +2000,13 @@ toggle_action (GSimpleAction *action, g_variant_new_boolean (!g_variant_get_boolean (state))); } +static gboolean +quit_timeout (gpointer data) +{ + exit (0); + return G_SOURCE_REMOVE; +} + int main (int argc, char *argv[]) { @@ -2065,6 +2072,9 @@ main (int argc, char *argv[]) g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL); + if (g_getenv ("GTK_DEBUG_AUTO_QUIT")) + g_timeout_add (500, quit_timeout, NULL); + g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app);