X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire.c;h=8a23346ce788667f611a5dede2ac4dd1cfff0b34;hb=ca259adce7a069f58545de7511e17d73c9e0a868;hp=b2861d8aee924b641136d93d139488f2c25e69c9;hpb=b6bcae693f035491ae0625f301f3e630c1335555;p=pspp-builds.git diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index b2861d8a..8a23346c 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 @@ -28,6 +27,7 @@ #include "psppire-data-window.h" #include "psppire.h" +#include "widgets.h" #include #include @@ -45,7 +45,6 @@ #include #include -#include #include "psppire-dict.h" #include "psppire-var-store.h" #include "psppire-data-store.h" @@ -53,7 +52,7 @@ #include "message-dialog.h" #include - +#include "psppire-window-register.h" #include "psppire-output-window.h" #include @@ -80,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) { @@ -92,7 +95,7 @@ initialize (struct command_line_processor *clp, int argc, char **argv) bindtextdomain (PACKAGE, locale_dir); - glade_init (); + preregister_widgets (); gsl_set_error_handler_off (); fn_init (); @@ -121,20 +124,29 @@ initialize (struct command_line_processor *clp, int argc, char **argv) create_icon_factory (); - 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")); + { + const char *filename = output_file_name (); + + struct string config_string; + + ds_init_empty (&config_string); + + 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 (OUTPUT_FILE_NAME); + 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); @@ -158,6 +170,24 @@ de_initialize (void) } +static void +func (gpointer key, gpointer value, gpointer data) +{ + gboolean rv; + PsppireWindow *window = PSPPIRE_WINDOW (value); + + g_signal_emit_by_name (window, "delete-event", 0, &rv); +} + +void +psppire_quit (void) +{ + PsppireWindowRegister *reg = psppire_window_register_new (); + psppire_window_register_foreach (reg, func, NULL); + + gtk_main_quit (); +} + struct icon_info { @@ -245,46 +275,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_window_set_filename (PSPPIRE_WINDOW (the_data_window), arg); - + psppire_data_window_load_file (PSPPIRE_DATA_WINDOW (the_data_window), + arg); break; } default: @@ -295,3 +287,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; +}