--- /dev/null
+diff -ru -x *.pot -x cat-id-tbl* glade-0.5.7-orig/glade/main.c glade-0.5.7/glade/main.c
+--- glade-0.5.7-orig/glade/main.c Wed Dec 22 17:01:00 1999
++++ glade-0.5.7/glade/main.c Sun Mar 12 20:44:11 2000
+@@ -36,14 +36,31 @@
+ static void parse_command_line (int argc,
+ char *argv[],
+ GladeProjectWindow *project_window);
++static void post_command_line (GladeProjectWindow *project_window);
+ static void usage (void);
+
+
++/* Currently we handle only command-line arguments an XML file to load
++ and request for source build.
++ For Gnome we have to use popt, even though we have no options. */
++
++static gchar *arg_filename=NULL;
++static int arg_write_source=0;
++
+ #ifdef USE_GNOME
+ static poptContext pctx;
+
+ static struct poptOption options[] = {
+ {
++ "writesource",
++ 'w',
++ 0,
++ &arg_write_source,
++ 0,
++ N_("Whether to automatically (and only) build the source files"),
++ NULL
++ },
++ {
+ NULL,
+ '\0',
+ 0,
+@@ -95,6 +112,7 @@
+ glade_show_property_editor ();
+
+ parse_command_line (argc, argv, project_window);
++ post_command_line (project_window);
+ if (current_project == NULL)
+ glade_project_new ();
+
+@@ -104,15 +122,44 @@
+ return 0;
+ }
+
++static void
++post_command_line (GladeProjectWindow *project_window)
++{
++ gchar *directory;
++ GladeProject *project;
++ GladeError *error;
++
++ if (arg_filename)
++ {
++ directory = g_get_current_dir ();
++ arg_filename = glade_util_make_absolute_path (directory, arg_filename);
++ glade_project_window_open_project (project_window, arg_filename);
++ g_free (directory);
++ g_free (arg_filename);
++ }
++ if (arg_write_source)
++ {
++ if (!arg_filename) {
++ fprintf(stderr,_("Project name not specified, requited for \"--writesource\" option.\n"));
++ exit(1);
++ }
++ project = glade_project_view_get_project (GLADE_PROJECT_VIEW (project_window->project_view));
++ g_return_if_fail (project != NULL);
++ error = glade_project_write_source (project);
++ if (error) {
++ fprintf(stderr,_("Error writing source, use GUI to fix it.\n"));
++ glade_error_free (error);
++ exit(1);
++ }
++ exit(0);
++ }
++}
+
+-/* Currently the only command-line argument we handle is an XML file to load.
+- For Gnome we have to use popt, even though we have no options. */
+ #ifdef USE_GNOME
+ static void
+ parse_command_line (int argc, char *argv[],
+ GladeProjectWindow *project_window)
+ {
+- gchar *filename = NULL, *directory;
+ const gchar **args;
+ gint i;
+
+@@ -120,22 +167,13 @@
+
+ for (i = 0; args && args[i]; i++)
+ {
+- if (filename == NULL)
+- filename = (gchar*) args[i];
+- else
+- usage ();
++ if (arg_filename == NULL)
++ arg_filename = (gchar*) args[i];
++ else
++ usage ();
+ }
+
+ poptFreeContext (pctx);
+-
+- if (filename)
+- {
+- directory = g_get_current_dir ();
+- filename = glade_util_make_absolute_path (directory, filename);
+- glade_project_window_open_project (project_window, filename);
+- g_free (directory);
+- g_free (filename);
+- }
+ }
+
+ #else
+@@ -143,28 +181,18 @@
+ parse_command_line (int argc, char *argv[],
+ GladeProjectWindow *project_window)
+ {
+- gchar *filename = NULL, *directory;
+ gint i;
+
+ /* GTK parses argc & argv and sets arguments to NULL if it has used them. */
+ for (i = 1; i < argc; i++)
+ {
+- if (argv[i])
+- {
+- if (filename == NULL)
+- filename = argv[i];
+- else
+- usage ();
+- }
+- }
+-
+- if (filename)
+- {
+- directory = g_get_current_dir ();
+- filename = glade_util_make_absolute_path (directory, filename);
+- glade_project_window_open_project (project_window, filename);
+- g_free (directory);
+- g_free (filename);
++ if (!argv[i]) continue;
++ if (!strcmp(argv[i],"-w") || !strcmp(argv[i],"--writesource"))
++ arg_write_source = 1;
++ else if (arg_filename == NULL)
++ arg_filename = (gchar*) argv[i];
++ else
++ usage ();
+ }
+ }
+ #endif
+@@ -173,6 +201,6 @@
+ static void
+ usage (void)
+ {
+- fprintf (stderr, "Usage: glade [filename]\n");
++ fprintf (stderr, "Usage: glade [-w|--writesource] [<filename>]\n");
+ exit (0);
+ }