From b88ac0890eaeb4294d41ba409cbd8460d575fcad Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 Apr 2022 11:19:07 -0400 Subject: [PATCH] gtk-builder-tool: Small reshuffle Move the display check into the preview command. --- tools/gtk-builder-tool-preview.c | 6 ++++++ tools/gtk-builder-tool.c | 14 ++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tools/gtk-builder-tool-preview.c b/tools/gtk-builder-tool-preview.c index db345c7bca..df6e29976f 100644 --- a/tools/gtk-builder-tool-preview.c +++ b/tools/gtk-builder-tool-preview.c @@ -180,6 +180,12 @@ do_preview (int *argc, }; GError *error = NULL; + if (gdk_display_get_default () == NULL) + { + g_printerr ("Could not initialize windowing system\n"); + exit (1); + } + context = g_option_context_new (NULL); g_option_context_set_help_enabled (context, FALSE); g_option_context_add_main_entries (context, entries, NULL); diff --git a/tools/gtk-builder-tool.c b/tools/gtk-builder-tool.c index b62773738a..7de50fc283 100644 --- a/tools/gtk-builder-tool.c +++ b/tools/gtk-builder-tool.c @@ -109,13 +109,11 @@ log_writer_func (GLogLevelFlags level, int main (int argc, const char *argv[]) { - gboolean has_display; - g_set_prgname ("gtk-builder-tool"); g_log_set_writer_func (log_writer_func, NULL, NULL); - has_display = gtk_init_check (); + gtk_init_check (); gtk_test_register_all_types (); @@ -135,15 +133,7 @@ main (int argc, const char *argv[]) else if (strcmp (argv[0], "enumerate") == 0) do_enumerate (&argc, &argv); else if (strcmp (argv[0], "preview") == 0) - { - if (!has_display) - { - g_printerr ("Could not initialize windowing system\n"); - return 1; - } - - do_preview (&argc, &argv); - } + do_preview (&argc, &argv); else usage (); -- 2.30.2