Index: trunk/src/error.c =================================================================== --- trunk/src/error.c (revision 483) +++ trunk/src/error.c (revision 484) @@ -93,10 +93,13 @@ Message (const char *Format, ...) { va_list args; - va_start (args, Format); - gui->logv (Format, args); - va_end (args); + if (gui != NULL) { + va_start (args, Format); + gui->logv (Format, args); + va_end (args); + } + #ifdef HAVE_STDARG_H va_start (args, Format); vfprintf(stderr, Format, args); Index: trunk/src/hid/common/hidinit.c =================================================================== --- trunk/src/hid/common/hidinit.c (revision 483) +++ trunk/src/hid/common/hidinit.c (revision 484) @@ -180,10 +180,18 @@ HID * -hid_find_gui () +hid_find_gui (const char *preference) { int i; + if (preference != NULL) { + for (i = 0; i < hid_num_hids; i++) + if (!hid_list[i]->printer && !hid_list[i]->exporter && !strcmp(hid_list[i]->name, preference)) + return hid_list[i]; + Message("Error: can't find gui '%s' (requested by the user)\n", preference); + return NULL; + } + for (i = 0; i < hid_num_hids; i++) if (!hid_list[i]->printer && !hid_list[i]->exporter) return hid_list[i]; Index: trunk/src/hid.h =================================================================== --- trunk/src/hid.h (revision 483) +++ trunk/src/hid.h (revision 484) @@ -589,7 +589,7 @@ /* When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI. This HID is the one that interacts with the mouse and keyboard. */ - HID *hid_find_gui (); + HID *hid_find_gui (const char *preference); /* Finds the one printer HID and instantiates it. */ HID *hid_find_printer (void); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 483) +++ trunk/src/main.c (revision 484) @@ -277,7 +277,7 @@ u ("PCB Printed Circuit Board editing program, http://pcb.gpleda.org"); u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname); - u ("%s [gui options] \t\tto edit", Progname); + u ("%s [--gui GUI] [gui options] \t\tto edit", Progname); u ("Available GUI hid%s:", n_gui == 1 ? "" : "s"); for (i = 0; hl[i]; i++) if (hl[i]->gui) @@ -1662,8 +1662,18 @@ argv += 2; } /* Otherwise start GUI. */ + else if (argc > 2 && strcmp (argv[1], "--gui") == 0) + { + gui = hid_find_gui (argv[2]); + if (gui == NULL) { + Message("Can't find the gui requested.\n"); + exit(1); + } + argc -= 2; + argv += 2; + } else - gui = hid_find_gui (); + gui = hid_find_gui (NULL); /* Exit with error if GUI failed to start. */ if (!gui)