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 <libpspp/version.h>
27 #include <libpspp/copyleft.h>
28 #include <data/file-handle-def.h>
29 #include <data/format.h>
30 #include <data/settings.h>
31 #include <data/file-name.h>
32 #include <data/procedure.h>
33 #include <libpspp/getl.h>
34 #include <language/lexer/lexer.h>
39 #include <glade/glade.h>
40 #include "menu-actions.h"
41 #include "psppire-dict.h"
42 #include "psppire-var-store.h"
43 #include "psppire-data-store.h"
45 #include "data-sheet.h"
46 #include "var-sheet.h"
47 #include "message-dialog.h"
48 #include "flexifile-factory.h"
53 PsppireDict *the_dictionary = 0;
55 PsppireDataStore *data_store = 0;
58 static bool parse_command_line (int *argc, char ***argv,
59 gchar **filename, GError **err);
62 #define _(msgid) gettext (msgid)
63 #define N_(msgid) msgid
68 static struct msg m = {
76 m.text=g_strdup(_("Sorry. The help system hasn't yet been implemented."));
81 PsppireVarStore *var_store = 0;
83 void create_icon_factory (void);
85 struct source_stream *the_source_stream ;
86 struct lexer *the_lexer;
87 struct dataset * the_dataset = NULL;
91 main(int argc, char *argv[])
93 struct casefile_factory *factory;
95 GtkWidget *data_editor ;
97 GtkSheet *data_sheet ;
103 gtk_init(&argc, &argv);
104 if ( (vers = gtk_check_version(GTK_MAJOR_VERSION,
106 GTK_MICRO_VERSION)) )
112 /* gtk_init messes with the locale.
113 So unset the bits we want to control ourselves */
114 setlocale (LC_NUMERIC, "C");
116 bindtextdomain (PACKAGE, locale_dir);
118 textdomain (PACKAGE);
120 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
131 factory = flexifile_factory_create ();
132 the_source_stream = create_source_stream (
133 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
136 the_lexer = lex_create (the_source_stream);
138 the_dataset = create_dataset (factory);
140 message_dialog_init (the_source_stream);
143 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 var_store = psppire_var_store_new(the_dictionary);
152 data_store = psppire_data_store_new(the_dictionary);
154 create_icon_factory();
156 /* load the interface */
157 xml = glade_xml_new(PKGDATADIR "/psppire.glade", NULL, NULL);
159 if ( !xml ) return 1;
161 data_editor = get_widget_assert(xml, "data_editor");
162 gtk_window_set_icon_from_file(GTK_WINDOW(data_editor),
163 PKGDATADIR "/psppicon.png",0);
165 /* connect the signals in the interface */
166 glade_xml_signal_autoconnect(xml);
168 var_sheet = GTK_SHEET(get_widget_assert(xml, "variable_sheet"));
169 data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet"));
171 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(var_store));
173 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store));
176 gtk_init_add((GtkFunction)load_system_file, filename);
178 gtk_init_add((GtkFunction)clear_file, 0);
180 var_data_selection_init();
183 GList *helps = glade_xml_get_widget_prefix(xml, "help_button_");
186 for ( i = g_list_first(helps); i ; i = g_list_next(i))
187 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
191 /* start the event loop */
194 destroy_source_stream (the_source_stream);
195 message_dialog_done();
203 /* Parses the command line specified by ARGC and ARGV as received by
204 main(). Returns true if normal execution should proceed,
205 false if the command-line indicates that PSPP should exit. */
207 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
209 static struct option long_options[] =
211 {"help", no_argument, NULL, 'h'},
212 {"version", no_argument, NULL, 'V'},
220 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
227 g_print ("Usage: psppire {|--help|--version}\n");
241 *filename = (*argv)[optind];
250 create_icon_factory (void)
252 GtkIconFactory *factory = gtk_icon_factory_new();
254 GtkIconSet *icon_set;
258 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
259 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
260 g_object_unref (pixbuf);
261 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
263 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
264 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
265 g_object_unref (pixbuf);
266 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
268 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
269 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
270 g_object_unref (pixbuf);
271 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
273 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
274 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
275 g_object_unref (pixbuf);
276 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
278 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
279 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
280 g_object_unref (pixbuf);
281 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
283 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
284 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
285 g_object_unref (pixbuf);
286 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
288 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
289 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
290 g_object_unref (pixbuf);
291 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
293 gtk_icon_factory_add_default (factory);