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 dataset * the_dataset = NULL;
85 main(int argc, char *argv[])
87 struct casefile_factory *factory;
88 PsppireDict *dictionary = 0;
91 GtkWidget *data_editor ;
93 GtkSheet *data_sheet ;
99 gtk_init(&argc, &argv);
100 if ( (vers = gtk_check_version(GTK_MAJOR_VERSION,
102 GTK_MICRO_VERSION)) )
108 /* gtk_init messes with the locale.
109 So unset the bits we want to control ourselves */
110 setlocale (LC_NUMERIC, "C");
112 bindtextdomain (PACKAGE, locale_dir);
114 textdomain (PACKAGE);
116 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
127 factory = flexifile_factory_create ();
128 the_source_stream = create_source_stream (
129 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
132 the_dataset = create_dataset (factory);
134 message_dialog_init (the_source_stream);
137 psppire_dict_new_from_dict (
138 dataset_dict (the_dataset)
141 bind_textdomain_codeset(PACKAGE, "UTF-8");
143 /* Create the model for the var_sheet */
144 the_var_store = psppire_var_store_new(dictionary);
147 the_data_store = psppire_data_store_new (dictionary);
149 create_icon_factory();
152 /* load the interface */
153 data_editor_xml = glade_xml_new(PKGDATADIR "/data-editor.glade", NULL, NULL);
155 if ( !data_editor_xml ) return 1;
157 data_editor = get_widget_assert(data_editor_xml, "data_editor");
159 /* connect the signals in the interface */
160 glade_xml_signal_autoconnect(data_editor_xml);
162 var_sheet = GTK_SHEET(get_widget_assert(data_editor_xml, "variable_sheet"));
163 data_sheet = GTK_SHEET(get_widget_assert(data_editor_xml, "data_sheet"));
165 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(the_var_store));
167 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(the_data_store));
169 var_data_selection_init();
172 GList *helps = glade_xml_get_widget_prefix(data_editor_xml, "help_button_");
175 for ( i = g_list_first(helps); i ; i = g_list_next(i))
176 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
181 new_data_window (NULL, NULL);
183 /* start the event loop */
186 destroy_source_stream (the_source_stream);
187 message_dialog_done();
195 /* Parses the command line specified by ARGC and ARGV as received by
196 main(). Returns true if normal execution should proceed,
197 false if the command-line indicates that PSPP should exit. */
199 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
201 static struct option long_options[] =
203 {"help", no_argument, NULL, 'h'},
204 {"version", no_argument, NULL, 'V'},
212 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
219 g_print ("Usage: psppire {|--help|--version}\n");
233 *filename = (*argv)[optind];
242 create_icon_factory (void)
244 GtkIconFactory *factory = gtk_icon_factory_new();
246 GtkIconSet *icon_set;
250 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
251 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
252 g_object_unref (pixbuf);
253 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
255 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
256 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
257 g_object_unref (pixbuf);
258 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
260 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
261 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
262 g_object_unref (pixbuf);
263 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
265 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
266 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
267 g_object_unref (pixbuf);
268 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
270 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
271 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
272 g_object_unref (pixbuf);
273 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
275 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
276 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
277 g_object_unref (pixbuf);
278 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
280 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
281 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
282 g_object_unref (pixbuf);
283 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
285 gtk_icon_factory_add_default (factory);