--- pan/gui/pan.cc.orig	2007-04-11 21:57:47.653135412 -0400
+++ pan/gui/pan.cc	2007-04-11 21:54:00.379721291 -0400
@@ -211,7 +211,6 @@
   textdomain (GETTEXT_PACKAGE);
 
   g_thread_init (0);
-  gtk_init (&argc, &argv);
   g_mime_init (GMIME_INIT_FLAG_UTF8);
 
   bool gui(true), nzb(false);
@@ -236,19 +235,24 @@
     } else if (!strcmp (tok, "--nzb"))
       nzb = true;
     else if (!strcmp (tok, "--version"))
-      { std::cerr << "Pan " << VERSION << '\n'; return 0; }
+      { gui = false; std::cerr << "Pan " << VERSION << '\n'; return 0; }
     else if (!strcmp (tok, "-o") && i<argc-1) 
       nzb_output_path = argv[++i];
     else if (!memcmp (tok, "--output=", 9))
       nzb_output_path = tok+9;
     else if (!strcmp(tok,"-h") || !strcmp(tok,"--help"))
-      { usage (); return 0; }
+      { gui = false; usage (); return 0; }
     else {
       nzb = true;
       nzb_files.push_back (tok);
     }
   }
 
+  if (gui)
+    gtk_init (&argc, &argv); /* NB: gtk_init() implicitly contacts the
+                                X server so it should only be called 
+                                if we are sure we will have a gui */
+
   if (!gui && nzb_files.empty() && url.empty() && groups.empty()) {
     std::cerr << _("Error: --no-gui used without nzb files or news:message-id.") << std::endl;
     return 0;
