summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-01-21 16:57:20 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-01-21 17:31:48 -0500
commita6f300cefd2edfb7789e75565adb03f82a701530 (patch)
tree7e8f2eb6a00fee5d5a24f5fd03c90dacc2682932
parent05b98c3834f8fddb41d8893b5c4820dc9a72a229 (diff)
downloadgtk+-a6f300cefd2edfb7789e75565adb03f82a701530.tar.gz
widget-factory: Add a way to quit automatically
This can be used to measure startup cost in tests.
-rw-r--r--demos/widget-factory/widget-factory.c10
1 files changed, 10 insertions, 0 deletions
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);