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 "data-editor.h"
27 #include <libpspp/version.h>
28 #include <libpspp/copyleft.h>
29 #include <data/file-handle-def.h>
30 #include <data/format.h>
31 #include <data/storage-stream.h>
32 #include <data/case-source.h>
33 #include <data/settings.h>
34 #include <data/file-name.h>
35 #include <data/procedure.h>
36 #include <libpspp/getl.h>
37 #include <language/lexer/lexer.h>
38 #include <ui/flexifile.h>
43 #include <glade/glade.h>
44 #include "psppire-dict.h"
45 #include "psppire-var-store.h"
46 #include "psppire-data-store.h"
48 #include "data-sheet.h"
49 #include "var-sheet.h"
50 #include "message-dialog.h"
51 #include "flexifile-factory.h"
53 PsppireDataStore *the_data_store = 0;
56 static bool parse_command_line (int *argc, char ***argv,
57 gchar **filename, GError **err);
60 PsppireVarStore *the_var_store = 0;
62 void create_icon_factory (void);
64 struct source_stream *the_source_stream ;
65 struct dataset * the_dataset = NULL;
68 replace_dictionary (struct dictionary *d)
70 psppire_dict_replace_dictionary (the_data_store->dict,
76 replace_flexifile (struct case_source *s)
79 psppire_case_file_replace_flexifile (the_data_store->case_file,
80 (struct flexifile *) flexifile_create (0));
83 if ( ! case_source_is_class (s, &storage_source_class))
86 psppire_case_file_replace_flexifile (the_data_store->case_file,
88 storage_source_get_casefile (s));
94 main (int argc, char *argv[])
96 struct casefile_factory *factory;
97 PsppireDict *dictionary = 0;
104 gtk_init (&argc, &argv);
105 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
107 GTK_MICRO_VERSION)) )
113 /* gtk_init messes with the locale.
114 So unset the bits we want to control ourselves */
115 setlocale (LC_NUMERIC, "C");
117 bindtextdomain (PACKAGE, locale_dir);
119 textdomain (PACKAGE);
121 if ( ! parse_command_line (&argc, &argv, &filename, &err) )
123 g_clear_error (&err);
132 factory = flexifile_factory_create ();
133 the_source_stream = create_source_stream (
134 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
137 the_dataset = create_dataset (factory,
141 message_dialog_init (the_source_stream);
143 dictionary = psppire_dict_new_from_dict (
144 dataset_dict (the_dataset)
147 bind_textdomain_codeset (PACKAGE, "UTF-8");
149 /* Create the model for the var_sheet */
150 the_var_store = psppire_var_store_new (dictionary);
153 the_data_store = psppire_data_store_new (dictionary);
155 proc_set_source (the_dataset,
156 storage_source_create (the_data_store->case_file->flexifile)
159 create_icon_factory ();
161 new_data_window (NULL, NULL);
163 /* start the event loop */
166 destroy_source_stream (the_source_stream);
167 message_dialog_done ();
175 /* Parses the command line specified by ARGC and ARGV as received by
176 main (). Returns true if normal execution should proceed,
177 false if the command-line indicates that PSPP should exit. */
179 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
181 static struct option long_options[] =
183 {"help", no_argument, NULL, 'h'},
184 {"version", no_argument, NULL, 'V'},
192 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
199 g_print ("Usage: psppire {|--help|--version}\n");
213 *filename = (*argv)[optind];
222 create_icon_factory (void)
224 GtkIconFactory *factory = gtk_icon_factory_new ();
226 GtkIconSet *icon_set;
230 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
231 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
232 g_object_unref (pixbuf);
233 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
235 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
236 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
237 g_object_unref (pixbuf);
238 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
240 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
241 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
242 g_object_unref (pixbuf);
243 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
245 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
246 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
247 g_object_unref (pixbuf);
248 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
250 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
251 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
252 g_object_unref (pixbuf);
253 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
255 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
256 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
257 g_object_unref (pixbuf);
258 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
260 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
261 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
262 g_object_unref (pixbuf);
263 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
265 gtk_icon_factory_add_default (factory);