gtk-builder-tool: Small reshuffle

Move the display check into the preview command.
This commit is contained in:
Matthias Clasen
2022-04-17 11:19:07 -04:00
parent da5bb6ff22
commit b88ac0890e
2 changed files with 8 additions and 12 deletions

View File

@@ -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);

View File

@@ -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 ();