gtk-builder-tool: Small reshuffle
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 Apr 2022 15:19:07 +0000 (11:19 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 Apr 2022 15:23:00 +0000 (11:23 -0400)
Move the display check into the preview command.

tools/gtk-builder-tool-preview.c
tools/gtk-builder-tool.c

index db345c7bca720b58a7fee08e8d167e377fed90ca..df6e29976fb8cdd4bc589787bc849dd6f074d3ed 100644 (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);
index b62773738aa1d1ceebde4b8a6c20c25a23ce5303..7de50fc28383d5c0cd5158e928db43e5eb080fcc 100644 (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 ();