X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpsppire.c;h=737b965c116b35d5ac7c214ca465d341c00e3463;hb=f1a02381223dd6d652c590e2a5514967b9448905;hp=e50ce2f0a3432187cbe4d4880c132f2c1fb4f2c9;hpb=c7b5e2dcfaeb0221b801dc3cc9fa1ab9a4ec5861;p=pspp-builds.git diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index e50ce2f0..737b965c 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2004, 2005, 2006 Free Software Foundation + Copyright (C) 2004, 2005, 2006, 2009 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -69,6 +68,7 @@ static void create_icon_factory (void); struct source_stream *the_source_stream ; struct dataset * the_dataset = NULL; +static GtkWidget *the_data_window; static void replace_casereader (struct casereader *s) @@ -79,6 +79,10 @@ replace_casereader (struct casereader *s) #define _(msgid) gettext (msgid) #define N_(msgid) msgid + +const char * output_file_name (void); + + void initialize (struct command_line_processor *clp, int argc, char **argv) { @@ -118,32 +122,41 @@ initialize (struct command_line_processor *clp, int argc, char **argv) the_data_store = psppire_data_store_new (dictionary); replace_casereader (NULL); + create_icon_factory (); + { + const char *filename = output_file_name (); - create_icon_factory (); + struct string config_string; - outp_configure_driver_line ( - ss_cstr ("gui:ascii:screen:squeeze=on headers=off top-margin=0 " - "bottom-margin=0 paginate=off length=auto width=auto " - "emphasis=none " - "output-file=\"" OUTPUT_FILE_NAME "\" append=yes")); + ds_init_empty (&config_string); - unlink (OUTPUT_FILE_NAME); + ds_put_format (&config_string, + "gui:ascii:screen:squeeze=on headers=off top-margin=0 " + "bottom-margin=0 paginate=off length=auto width=auto " + "emphasis=none " + "output-file=\"%s\" append=yes", filename); + + outp_configure_driver_line (ds_ss (&config_string)); + + unlink (filename); + + ds_destroy (&config_string); + } journal_enable (); textdomain (PACKAGE); - /* Ignore alarm clock signals */ - signal (SIGALRM, SIG_IGN); + the_data_window = psppire_data_window_new (); command_line_processor_replace_aux (clp, &post_init_argp, the_source_stream); command_line_processor_replace_aux (clp, &non_option_argp, the_source_stream); command_line_processor_parse (clp, argc, argv); - create_data_window (); - execute_syntax (create_syntax_string_source ("")); + + gtk_widget_show (the_data_window); } @@ -244,43 +257,8 @@ parse_non_options (int key, char *arg, struct argp_state *state) { case ARGP_KEY_ARG: { - struct string syntax; - FILE *fp = fopen (arg, "r"); - if (NULL == fp) - { - const int errnum = errno; - fprintf (state->err_stream, _("Cannot open %s: %s.\n"), - arg, strerror (errnum)); - return 0; - } - if ( sfm_detect (fp)) - { - ds_init_cstr (&syntax, "GET FILE="); - goto close; - } - rewind (fp); - if (pfm_detect (fp)) - { - ds_init_cstr (&syntax, "IMPORT FILE="); - goto close; - } - - fclose (fp); - msg (ME, _("%s is neither a system nor portable file"), arg); - break; - - close: - fclose (fp); - - syntax_gen_string (&syntax, ss_cstr (arg)); - ds_put_cstr (&syntax, "."); - - getl_append_source (ss, - create_syntax_string_source (ds_cstr (&syntax)), - GETL_BATCH, - ERRMODE_CONTINUE); - - ds_destroy (&syntax); + psppire_data_window_load_file (PSPPIRE_DATA_WINDOW (the_data_window), + arg); break; } default: @@ -291,3 +269,17 @@ parse_non_options (int key, char *arg, struct argp_state *state) const struct argp non_option_argp = {NULL, parse_non_options, 0, 0, 0, 0, 0}; + + +const char * +output_file_name (void) +{ + const char *dir = default_output_path (); + static char *filename = NULL; + + if ( NULL == filename ) + filename = xasprintf ("%s%s", dir, OUTPUT_FILE_NAME); + + + return filename; +}