+
+static void
+wait_for_splash (GApplication *app, GtkWindow *x)
+{
+ if (wsplash)
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (wsplash), x);
+ gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (wsplash));
+ gtk_window_set_keep_above (GTK_WINDOW (wsplash), TRUE);
+ gtk_window_present (GTK_WINDOW (wsplash));
+
+ /* Remove the splash screen after SPLASH_DURATION milliseconds */
+ gint64 elapsed_time = (g_get_monotonic_time () - start_time) / 1000;
+ if (SPLASH_DURATION - elapsed_time <= 0)
+ destroy_splash (wsplash);
+ else
+ g_timeout_add (SPLASH_DURATION - elapsed_time, destroy_splash, wsplash);
+ }
+}
+
+static GtkWidget *fatal_error_dialog = NULL;
+static GtkWidget *fatal_error_label;
+static const char *diagnostic_info;
+
+static void
+fatal_error_handler (int sig)
+{
+ /* Reset SIG to its default handling so that if it happens again we won't
+ recurse. */
+ signal (sig, SIG_DFL);
+
+ static char message [1024];
+ strcpy (message, "proximate cause: ");
+ switch (sig)
+ {
+ case SIGABRT:
+ strcat (message, "Assertion Failure/Abort");
+ break;
+ case SIGFPE:
+ strcat (message, "Floating Point Exception");
+ break;
+ case SIGSEGV:
+ strcat (message, "Segmentation Violation");
+ break;
+ default:
+ strcat (message, "Unknown");
+ break;
+ }
+ strcat (message, "\n");
+ strcat (message, diagnostic_info);
+
+ g_object_set (fatal_error_label,
+ "label", message,
+ NULL);
+
+ gtk_dialog_run (GTK_DIALOG (fatal_error_dialog));
+
+ /* Re-raise the signal so that we terminate with the correct status. */
+ raise (sig);
+}
+