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
25 #include <libpspp/version.h>
26 #include <libpspp/copyleft.h>
27 #include <data/file-handle-def.h>
28 #include <data/format.h>
29 #include <data/settings.h>
30 #include <data/file-name.h>
31 #include <data/procedure.h>
32 #include <libpspp/getl.h>
33 #include <language/lexer/lexer.h>
38 #include <glade/glade.h>
39 #include "menu-actions.h"
40 #include "psppire-dict.h"
41 #include "psppire-var-store.h"
42 #include "psppire-data-store.h"
44 #include "data-sheet.h"
45 #include "var-sheet.h"
46 #include "message-dialog.h"
51 PsppireDict *the_dictionary = 0;
53 PsppireDataStore *data_store = 0;
56 static bool parse_command_line (int *argc, char ***argv,
57 gchar **filename, GError **err);
60 #define _(msgid) gettext (msgid)
61 #define N_(msgid) msgid
66 static struct msg m = {
74 m.text=g_strdup(_("Sorry. The help system hasn't yet been implemented."));
79 PsppireVarStore *var_store = 0;
81 void create_icon_factory (void);
83 struct source_stream *the_source_stream ;
84 struct lexer *the_lexer;
85 struct dataset * the_dataset = NULL;
89 main(int argc, char *argv[])
92 GtkWidget *data_editor ;
94 GtkSheet *data_sheet ;
100 gtk_init(&argc, &argv);
101 if ( (vers = gtk_check_version(GTK_MAJOR_VERSION,
103 GTK_MICRO_VERSION)) )
109 /* gtk_init messes with the locale.
110 So unset the bits we want to control ourselves */
111 setlocale (LC_NUMERIC, "C");
113 bindtextdomain (PACKAGE, locale_dir);
115 textdomain (PACKAGE);
117 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
128 the_source_stream = create_source_stream (
129 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
132 the_lexer = lex_create (the_source_stream);
134 the_dataset = create_dataset ();
136 message_dialog_init (the_source_stream);
139 psppire_dict_new_from_dict (
140 dataset_dict (the_dataset)
143 bind_textdomain_codeset(PACKAGE, "UTF-8");
145 /* Create the model for the var_sheet */
146 var_store = psppire_var_store_new(the_dictionary);
148 data_store = psppire_data_store_new(the_dictionary);
150 create_icon_factory();
152 /* load the interface */
153 xml = glade_xml_new(PKGDATADIR "/psppire.glade", NULL, NULL);
155 if ( !xml ) return 1;
157 data_editor = get_widget_assert(xml, "data_editor");
158 gtk_window_set_icon_from_file(GTK_WINDOW(data_editor),
159 PKGDATADIR "/psppicon.png",0);
161 /* connect the signals in the interface */
162 glade_xml_signal_autoconnect(xml);
164 var_sheet = GTK_SHEET(get_widget_assert(xml, "variable_sheet"));
165 data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet"));
167 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(var_store));
169 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store));
172 gtk_init_add((GtkFunction)load_system_file, filename);
174 gtk_init_add((GtkFunction)clear_file, 0);
176 var_data_selection_init();
179 GList *helps = glade_xml_get_widget_prefix(xml, "help_button_");
182 for ( i = g_list_first(helps); i ; i = g_list_next(i))
183 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
187 /* start the event loop */
190 destroy_source_stream (the_source_stream);
191 message_dialog_done();
199 /* Parses the command line specified by ARGC and ARGV as received by
200 main(). Returns true if normal execution should proceed,
201 false if the command-line indicates that PSPP should exit. */
203 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
205 static struct option long_options[] =
207 {"help", no_argument, NULL, 'h'},
208 {"version", no_argument, NULL, 'V'},
216 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
223 g_print ("Usage: psppire {|--help|--version}\n");
237 *filename = (*argv)[optind];
246 create_icon_factory (void)
248 GtkIconFactory *factory = gtk_icon_factory_new();
250 GtkIconSet *icon_set;
254 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
255 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
256 g_object_unref (pixbuf);
257 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
259 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
260 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
261 g_object_unref (pixbuf);
262 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
264 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
265 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
266 g_object_unref (pixbuf);
267 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
269 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
270 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
271 g_object_unref (pixbuf);
272 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
274 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
275 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
276 g_object_unref (pixbuf);
277 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
279 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
280 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
281 g_object_unref (pixbuf);
282 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
284 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
285 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
286 g_object_unref (pixbuf);
287 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
289 gtk_icon_factory_add_default (factory);