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/settings.h>
32 #include <data/file-name.h>
33 #include <data/procedure.h>
34 #include <libpspp/getl.h>
35 #include <language/lexer/lexer.h>
40 #include <glade/glade.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"
50 PsppireDataStore *the_data_store = 0;
53 static bool parse_command_line (int *argc, char ***argv,
54 gchar **filename, GError **err);
57 #define _(msgid) gettext (msgid)
58 #define N_(msgid) msgid
63 static struct msg m = {
71 m.text=g_strdup(_("Sorry. The help system hasn't yet been implemented."));
76 PsppireVarStore *the_var_store = 0;
78 void create_icon_factory (void);
80 struct source_stream *the_source_stream ;
81 struct lexer *the_lexer;
82 struct dataset * the_dataset = NULL;
86 main(int argc, char *argv[])
88 struct casefile_factory *factory;
89 PsppireDict *dictionary = 0;
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 factory = flexifile_factory_create ();
129 the_source_stream = create_source_stream (
130 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
133 the_lexer = lex_create (the_source_stream);
135 the_dataset = create_dataset (factory);
137 message_dialog_init (the_source_stream);
140 psppire_dict_new_from_dict (
141 dataset_dict (the_dataset)
144 bind_textdomain_codeset(PACKAGE, "UTF-8");
146 /* Create the model for the var_sheet */
147 the_var_store = psppire_var_store_new(dictionary);
150 the_data_store = psppire_data_store_new (dictionary);
152 create_icon_factory();
155 /* load the interface */
156 data_editor_xml = glade_xml_new(PKGDATADIR "/data-editor.glade", NULL, NULL);
158 if ( !data_editor_xml ) return 1;
160 data_editor = get_widget_assert(data_editor_xml, "data_editor");
162 /* connect the signals in the interface */
163 glade_xml_signal_autoconnect(data_editor_xml);
165 var_sheet = GTK_SHEET(get_widget_assert(data_editor_xml, "variable_sheet"));
166 data_sheet = GTK_SHEET(get_widget_assert(data_editor_xml, "data_sheet"));
168 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(the_var_store));
170 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(the_data_store));
172 var_data_selection_init();
175 GList *helps = glade_xml_get_widget_prefix(data_editor_xml, "help_button_");
178 for ( i = g_list_first(helps); i ; i = g_list_next(i))
179 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
184 new_data_window (NULL, NULL);
186 /* start the event loop */
189 destroy_source_stream (the_source_stream);
190 message_dialog_done();
198 /* Parses the command line specified by ARGC and ARGV as received by
199 main(). Returns true if normal execution should proceed,
200 false if the command-line indicates that PSPP should exit. */
202 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
204 static struct option long_options[] =
206 {"help", no_argument, NULL, 'h'},
207 {"version", no_argument, NULL, 'V'},
215 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
222 g_print ("Usage: psppire {|--help|--version}\n");
236 *filename = (*argv)[optind];
245 create_icon_factory (void)
247 GtkIconFactory *factory = gtk_icon_factory_new();
249 GtkIconSet *icon_set;
253 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
254 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
255 g_object_unref (pixbuf);
256 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
258 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
259 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
260 g_object_unref (pixbuf);
261 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
263 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
264 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
265 g_object_unref (pixbuf);
266 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
268 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-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-insert-variable", icon_set);
273 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.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-case", icon_set);
278 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
279 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
280 g_object_unref (pixbuf);
281 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
283 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
284 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
285 g_object_unref (pixbuf);
286 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
288 gtk_icon_factory_add_default (factory);