2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation
4 Written by John Darrington
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <libpspp/version.h>
25 #include <libpspp/copyleft.h>
26 #include <data/settings.h>
31 #include <glade/glade.h>
32 #include "menu-actions.h"
33 #include "psppire-dict.h"
34 #include "psppire-var-store.h"
35 #include "psppire-data-store.h"
37 #include "data-sheet.h"
38 #include "var-sheet.h"
39 #include "psppire-case-array.h"
40 #include "message-dialog.h"
45 PsppireDict *the_dictionary = 0;
46 PsppireCaseArray *the_cases = 0;
49 PsppireDataStore *data_store = 0;
52 static bool parse_command_line (int *argc, char ***argv,
53 gchar **filename, GError **err);
56 #define _(msgid) gettext (msgid)
57 #define N_(msgid) msgid
62 static struct msg m = {
70 m.text=g_strdup(_("Sorry. The help system hasn't yet been implemented."));
75 PsppireVarStore *var_store = 0;
78 main(int argc, char *argv[])
81 GtkWidget *data_editor ;
83 GtkSheet *data_sheet ;
88 gtk_init(&argc, &argv);
90 /* gtk_init messes with the locale.
91 So unset the bits we want to control ourselves */
92 setlocale (LC_NUMERIC, "C");
94 bindtextdomain (PACKAGE, locale_dir);
98 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
111 set_pspp_locale("da_DK");
114 message_dialog_init();
116 the_dictionary = psppire_dict_new();
118 bind_textdomain_codeset(PACKAGE, "UTF-8");
120 /* Create the model for the var_sheet */
121 var_store = psppire_var_store_new(the_dictionary);
123 /* Create the model for the data sheet */
124 the_cases = psppire_case_array_new(100000, 20);
126 data_store = psppire_data_store_new(the_dictionary, the_cases);
128 /* load the interface */
129 xml = glade_xml_new(PKGDATADIR "/psppire.glade", NULL, NULL);
131 if ( !xml ) return 1;
133 data_editor = get_widget_assert(xml, "data_editor");
134 gtk_window_set_icon_from_file(GTK_WINDOW(data_editor),
135 PKGDATADIR "/psppicon.png",0);
137 /* connect the signals in the interface */
138 glade_xml_signal_autoconnect(xml);
140 var_sheet = GTK_SHEET(get_widget_assert(xml, "variable_sheet"));
141 data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet"));
143 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(var_store));
145 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store));
148 gtk_init_add((GtkFunction)load_system_file, filename);
150 gtk_init_add((GtkFunction)clear_file, 0);
152 var_data_selection_init();
155 GList *helps = glade_xml_get_widget_prefix(xml, "help_button_");
158 for ( i = g_list_first(helps); i ; i = g_list_next(i))
159 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
163 /* start the event loop */
166 message_dialog_done();
174 /* Parses the command line specified by ARGC and ARGV as received by
175 main(). Returns true if normal execution should proceed,
176 false if the command-line indicates that PSPP should exit. */
178 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
180 static struct option long_options[] =
182 {"help", no_argument, NULL, 'h'},
183 {"version", no_argument, NULL, 'V'},
191 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
198 g_printerr("Usage: psppire {|--help|--version}\n");
212 *filename = (*argv)[optind];