diff -ruN dia/app/app_procs.c dia.new/app/app_procs.c --- dia/app/app_procs.c 2003-12-06 15:45:34.000000000 +0000 +++ dia.new/app/app_procs.c 2003-12-06 15:42:03.000000000 +0000 @@ -90,6 +90,13 @@ static void create_user_dirs(void); static PluginInitResult internal_plugin_init(PluginInfo *info); +static void process_opts(int argc, char **argv, + poptContext poptCtx, struct poptOption options[], + GSList **files, char **export_file_name, + char **export_file_format, char **size); +static gboolean handle_all_diagrammes(GSList *files, char *export_file_name, + char *export_file_format, char *size); +static void print_credits(gboolean credits); static gboolean dia_is_interactive = TRUE; @@ -232,9 +239,11 @@ if (export_file_format) { char *export_file_name = NULL; DiaExportFilter *ef; + /* First try guessing based on extension */ export_file_name = build_output_file_name(in_file_name, export_file_format); + ef = filter_guess_export_filter(export_file_name); if (ef == NULL) { ef = filter_get_by_name(export_file_format); @@ -259,9 +268,10 @@ if (diagram != NULL) { diagram_update_extents(diagram); - layer_dialog_set_diagram(diagram); - - ddisp = new_display(diagram); + if (app_is_interactive()) { + layer_dialog_set_diagram(diagram); + ddisp = new_display(diagram); + } } } return made_conversions; @@ -318,11 +328,9 @@ char *export_file_format = NULL; char *size = NULL; gboolean made_conversions = FALSE; + GSList *files = NULL; #ifdef HAVE_POPT -#ifndef GNOME - int rc = 0; -#endif poptContext poptCtx = NULL; gchar *export_format_string = /* Translators: The argument is a list of options, not to be translated */ @@ -361,7 +369,7 @@ #endif argv0 = (argc > 0) ? argv[0] : "(none)"; - + gtk_set_locale(); setlocale(LC_NUMERIC, "C"); @@ -371,6 +379,8 @@ #endif textdomain(GETTEXT_PACKAGE); + process_opts(argc, argv, poptCtx, options, &files, + &export_file_name, &export_file_format, &size); if (argv) { #ifdef GNOME GnomeProgram *program = @@ -392,27 +402,12 @@ /* This smaller icon is 48x48, standard Gnome size */ gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/dia_gnome_icon.png"); -#else - gtk_init (&argc, &argv); -#ifdef HAVE_POPT - poptCtx = poptGetContext(PACKAGE, argc, (const char **)argv, options, 0); - poptSetOtherOptionHelp(poptCtx, _("[OPTION...] [FILE...]")); - while (rc >= 0) { - if((rc = poptGetNextOpt(poptCtx)) < -1) { - fprintf(stderr, - _("Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n"), - poptBadOption(poptCtx, 0), - poptStrerror(rc), - argv[0]); - exit(1); - } - if(rc == 1) { - poptPrintHelp(poptCtx, stderr, 0); - exit(0); - } - } -#endif +#else + if (dia_is_interactive) + gtk_init(&argc, &argv); + else + g_type_init(); #endif } @@ -426,43 +421,7 @@ exit(0); } - /* --credits option. Added by Andrew Ferrier. - - Hopefully we're not ignoring anything too crucial by - quitting directly after the credits. - - The phrasing of the English here might need changing - if we switch from plural to non-plural (say, only - one maintainer). - */ - - if (credits) { - int i; - const gint nauthors = (sizeof(authors) / sizeof(authors[0])) - 1; - const gint ndocumentors = (sizeof(documentors) / sizeof(documentors[0])) - 1; - - printf("The original author of Dia was:\n\n"); - for (i = 0; i < NUMBER_OF_ORIG_AUTHORS; i++) { - printf(authors[i]); printf("\n"); - } - - printf("\nThe current maintainers of Dia are:\n\n"); - for (i = NUMBER_OF_ORIG_AUTHORS; i < NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i++) { - printf(authors[i]); printf("\n"); - } - - printf("\nOther authors are:\n\n"); - for (i = NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i < nauthors; i++) { - printf(authors[i]); printf("\n"); - } - - printf("\nDia is documented by:\n\n"); - for (i = 0; i < ndocumentors; i++) { - printf(documentors[i]); printf("\n"); - } - - exit(0); - } + print_credits(credits); LIBXML_TEST_VERSION; @@ -476,9 +435,9 @@ gdk_rgb_init(); - gtk_rc_parse ("diagtkrc"); + gtk_rc_parse("diagtkrc"); - if (!nosplash) + if (dia_is_interactive && !nosplash) app_splash_init(""); create_user_dirs(); @@ -510,84 +469,47 @@ prefs_load(); - persistence_load(); + if (dia_is_interactive) { + persistence_load(); - /* further initialization *before* reading files */ - active_tool = create_modify_tool(); + /* further initialization *before* reading files */ + active_tool = create_modify_tool(); - create_toolbox(); + create_toolbox(); - persistence_register_window_create("layer_window", - (NullaryFunc*)&create_layer_dialog); + persistence_register_window_create("layer_window", + (NullaryFunc*)&create_layer_dialog); - /*fill recent file menu */ - recent_file_history_init(); + /*fill recent file menu */ + recent_file_history_init(); - /* Set up autosave to check every 5 minutes */ - gtk_timeout_add(5*60*1000, autosave_check_autosave, NULL); + /* Set up autosave to check every 5 minutes */ + gtk_timeout_add(5*60*1000, autosave_check_autosave, NULL); - create_tree_window(); + create_tree_window(); - persistence_register_window_create("sheets_main_dialog", - (NullaryFunc*)&sheets_dialog_create); + persistence_register_window_create("sheets_main_dialog", + (NullaryFunc*)&sheets_dialog_create); - /* In current setup, we can't find the autosaved files. */ - /*autosave_restore_documents();*/ - - if (argv) { -#ifdef HAVE_POPT - while (poptPeekArg(poptCtx)) { - char *in_file_name = (char *)poptGetArg(poptCtx); - - made_conversions |= handle_initial_diagram(in_file_name, - export_file_name, - export_file_format, - size); - } - poptFreeContext(poptCtx); -#else - int i; - - for (i=1; i= 0) { + if((rc = poptGetNextOpt(poptCtx)) < -1) { + fprintf(stderr, + _("Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n"), + poptBadOption(poptCtx, 0), + poptStrerror(rc), + argv[0]); + exit(1); + } + if(rc == 1) { + poptPrintHelp(poptCtx, stderr, 0); + exit(0); + } + } +#endif + if (argv) { +#ifdef HAVE_POPT + while (poptPeekArg(poptCtx)) { + char *in_file_name = (char *)poptGetArg(poptCtx); + + *files = g_slist_append(*files, in_file_name); + } + poptFreeContext(poptCtx); +#else + int i; + + for (i=1; inext) { + made_conversions |= + handle_initial_diagram(files->data, export_file_name, + export_file_format, size); + } + return made_conversions; +} + +/* --credits option. Added by Andrew Ferrier. + + Hopefully we're not ignoring anything too crucial by + quitting directly after the credits. + + The phrasing of the English here might need changing + if we switch from plural to non-plural (say, only + one maintainer). +*/ +static void +print_credits(gboolean credits) +{ + if (credits) { + int i; + const gint nauthors = (sizeof(authors) / sizeof(authors[0])) - 1; + const gint ndocumentors = (sizeof(documentors) / sizeof(documentors[0])) - 1; + + printf("The original author of Dia was:\n\n"); + for (i = 0; i < NUMBER_OF_ORIG_AUTHORS; i++) { + printf(authors[i]); printf("\n"); + } + + printf("\nThe current maintainers of Dia are:\n\n"); + for (i = NUMBER_OF_ORIG_AUTHORS; i < NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i++) { + printf(authors[i]); printf("\n"); + } + + printf("\nOther authors are:\n\n"); + for (i = NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i < nauthors; i++) { + printf(authors[i]); printf("\n"); + } + + printf("\nDia is documented by:\n\n"); + for (i = 0; i < ndocumentors; i++) { + printf(documentors[i]); printf("\n"); + } + + exit(0); + } +} + /* parses a string of the form "[0-9]*x[0-9]*" and transforms it into two long values width and height. */ void diff -ruN dia/app/diagram.c dia.new/app/diagram.c --- dia/app/diagram.c 2003-12-06 15:43:39.000000000 +0000 +++ dia.new/app/diagram.c 2003-12-06 15:42:31.000000000 +0000 @@ -76,7 +76,8 @@ if (!g_list_find(open_diagrams, dia)) open_diagrams = g_list_prepend(open_diagrams, dia); - layer_dialog_update_diagram_list(); + if (app_is_interactive()) + layer_dialog_update_diagram_list(); } int @@ -94,7 +95,8 @@ if (ifilter->import(filename, diagram->data, ifilter->user_data)) { diagram->unsaved = FALSE; diagram_set_modified(diagram, FALSE); - recent_file_history_add(filename, ifilter, 0); + if (app_is_interactive()) + recent_file_history_add(filename, ifilter, 0); diagram_tree_add(diagram_tree(), diagram); return TRUE; } else diff -ruN dia/app/export_png.c dia.new/app/export_png.c --- dia/app/export_png.c 2003-12-06 15:45:34.000000000 +0000 +++ dia.new/app/export_png.c 2003-12-06 15:42:43.000000000 +0000 @@ -75,7 +75,7 @@ Rectangle visible; guint32 width, height, band, row, i; real band_height; - guint32 imagewidth, imageheight; + guint32 imagewidth = 0, imageheight = 0; long req_width, req_height; real imagezoom; diff -ruN dia/app/main.c dia.new/app/main.c --- dia/app/main.c 2003-12-06 15:43:49.000000000 +0000 +++ dia.new/app/main.c 2003-12-06 15:42:56.000000000 +0000 @@ -35,6 +35,9 @@ { app_init(argc, argv); + if (!app_is_interactive()) + return 0; + toolbox_show(); app_splash_done(); diff -ruN dia/lib/dia_image.c dia.new/lib/dia_image.c --- dia/lib/dia_image.c 2003-12-06 15:44:05.000000000 +0000 +++ dia.new/lib/dia_image.c 2003-12-06 15:43:17.000000000 +0000 @@ -40,7 +40,8 @@ void dia_image_init(void) { - gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); + if (app_is_interactive()) + gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); } DiaImage