2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "relocatable.h"
28 #include "data-editor.h"
30 #include <libpspp/version.h>
31 #include <libpspp/copyleft.h>
32 #include <data/file-handle-def.h>
33 #include <data/format.h>
34 #include <data/storage-stream.h>
35 #include <data/case-source.h>
36 #include <data/settings.h>
37 #include <data/file-name.h>
38 #include <data/procedure.h>
39 #include <libpspp/getl.h>
40 #include <language/lexer/lexer.h>
41 #include <ui/flexifile.h>
46 #include <glade/glade.h>
47 #include "psppire-dict.h"
48 #include "psppire-var-store.h"
49 #include "psppire-data-store.h"
51 #include "data-sheet.h"
52 #include "var-sheet.h"
53 #include "message-dialog.h"
54 #include "flexifile-factory.h"
56 PsppireDataStore *the_data_store = 0;
59 static bool parse_command_line (int *argc, char ***argv,
60 gchar **filename, GError **err);
63 PsppireVarStore *the_var_store = 0;
65 void create_icon_factory (void);
67 struct source_stream *the_source_stream ;
68 struct dataset * the_dataset = NULL;
71 replace_dictionary (struct dictionary *d)
73 psppire_dict_replace_dictionary (the_data_store->dict,
79 replace_flexifile (struct case_source *s)
82 psppire_case_file_replace_flexifile (the_data_store->case_file,
83 (struct flexifile *) flexifile_create (0));
86 if ( ! case_source_is_class (s, &storage_source_class))
89 psppire_case_file_replace_flexifile (the_data_store->case_file,
91 storage_source_get_casefile (s));
97 main (int argc, char *argv[])
99 struct casefile_factory *factory;
100 PsppireDict *dictionary = 0;
106 set_program_name (argv[0]);
108 if ( ! gtk_parse_args (&argc, &argv) )
110 perror ("Error parsing arguments");
114 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
116 GTK_MICRO_VERSION)) )
122 /* gtk_init messes with the locale.
123 So unset the bits we want to control ourselves */
124 setlocale (LC_NUMERIC, "C");
126 bindtextdomain (PACKAGE, locale_dir);
128 textdomain (PACKAGE);
130 if ( ! parse_command_line (&argc, &argv, &filename, &err) )
132 g_clear_error (&err);
141 factory = flexifile_factory_create ();
142 the_source_stream = create_source_stream (
143 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
146 the_dataset = create_dataset (factory,
150 message_dialog_init (the_source_stream);
152 dictionary = psppire_dict_new_from_dict (
153 dataset_dict (the_dataset)
156 bind_textdomain_codeset (PACKAGE, "UTF-8");
158 gdk_init (&argc, &argv);
160 /* Create the model for the var_sheet */
161 the_var_store = psppire_var_store_new (dictionary);
164 the_data_store = psppire_data_store_new (dictionary);
166 proc_set_source (the_dataset,
167 storage_source_create (the_data_store->case_file->flexifile)
170 create_icon_factory ();
172 new_data_window (NULL, NULL);
174 /* start the event loop */
177 destroy_source_stream (the_source_stream);
178 message_dialog_done ();
186 /* Parses the command line specified by ARGC and ARGV as received by
187 main (). Returns true if normal execution should proceed,
188 false if the command-line indicates that PSPP should exit. */
190 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
192 static struct option long_options[] =
194 {"help", no_argument, NULL, 'h'},
195 {"version", no_argument, NULL, 'V'},
203 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
210 g_print ("Usage: psppire {|--help|--version}\n");
224 *filename = (*argv)[optind];
230 #define PIXBUF_NEW_FROM_FILE(FILE) \
231 gdk_pixbuf_new_from_file (relocate (PKGDATADIR "/" FILE), 0)
235 create_icon_factory (void)
237 GtkIconFactory *factory = gtk_icon_factory_new ();
239 GtkIconSet *icon_set;
243 pixbuf = PIXBUF_NEW_FROM_FILE ("value-labels.png");
244 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
245 g_object_unref (pixbuf);
246 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
248 pixbuf = PIXBUF_NEW_FROM_FILE ("weight-cases.png");
249 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
250 g_object_unref (pixbuf);
251 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
253 pixbuf = PIXBUF_NEW_FROM_FILE ("goto-variable.png");
254 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
255 g_object_unref (pixbuf);
256 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
258 pixbuf = PIXBUF_NEW_FROM_FILE ("insert-variable.png");
259 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
260 g_object_unref (pixbuf);
261 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
263 pixbuf = PIXBUF_NEW_FROM_FILE ("insert-case.png");
264 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
265 g_object_unref (pixbuf);
266 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
268 pixbuf = PIXBUF_NEW_FROM_FILE ("split-file.png");
269 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
270 g_object_unref (pixbuf);
271 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
273 pixbuf = PIXBUF_NEW_FROM_FILE ("select-cases.png");
274 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
275 g_object_unref (pixbuf);
276 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
278 pixbuf = PIXBUF_NEW_FROM_FILE ("recent-dialogs.png");
279 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
280 g_object_unref (pixbuf);
281 gtk_icon_factory_add ( factory, "pspp-recent-dialogs", icon_set);
285 gtk_icon_factory_add_default (factory);