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;
95 gtk_init (&argc, &argv);
96 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
104 /* gtk_init messes with the locale.
105 So unset the bits we want to control ourselves */
106 setlocale (LC_NUMERIC, "C");
108 bindtextdomain (PACKAGE, locale_dir);
110 textdomain (PACKAGE);
112 if ( ! parse_command_line (&argc, &argv, &filename, &err) )
114 g_clear_error (&err);
123 factory = flexifile_factory_create ();
124 the_source_stream = create_source_stream (
125 fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
128 the_dataset = create_dataset (factory);
130 message_dialog_init (the_source_stream);
133 psppire_dict_new_from_dict (
134 dataset_dict (the_dataset)
137 bind_textdomain_codeset (PACKAGE, "UTF-8");
139 /* Create the model for the var_sheet */
140 the_var_store = psppire_var_store_new (dictionary);
143 the_data_store = psppire_data_store_new (dictionary);
145 create_icon_factory ();
148 /* load the interface */
149 data_editor_xml = glade_xml_new (PKGDATADIR "/data-editor.glade", NULL, NULL);
151 if ( !data_editor_xml ) return 1;
153 data_editor = get_widget_assert (data_editor_xml, "data_editor");
155 /* connect the signals in the interface */
156 glade_xml_signal_autoconnect (data_editor_xml);
158 var_sheet = GTK_SHEET (get_widget_assert (data_editor_xml, "variable_sheet"));
159 data_sheet = GTK_SHEET (get_widget_assert (data_editor_xml, "data_sheet"));
161 gtk_sheet_set_model (var_sheet, G_SHEET_MODEL (the_var_store));
163 gtk_sheet_set_model (data_sheet, G_SHEET_MODEL (the_data_store));
165 var_data_selection_init ();
168 GList *helps = glade_xml_get_widget_prefix (data_editor_xml, "help_button_");
171 for ( i = g_list_first (helps); i ; i = g_list_next (i))
172 g_signal_connect (GTK_WIDGET (i->data), "clicked", give_help, 0);
177 new_data_window (NULL, NULL);
179 /* start the event loop */
182 destroy_source_stream (the_source_stream);
183 message_dialog_done ();
191 /* Parses the command line specified by ARGC and ARGV as received by
192 main (). Returns true if normal execution should proceed,
193 false if the command-line indicates that PSPP should exit. */
195 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
197 static struct option long_options[] =
199 {"help", no_argument, NULL, 'h'},
200 {"version", no_argument, NULL, 'V'},
208 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
215 g_print ("Usage: psppire {|--help|--version}\n");
229 *filename = (*argv)[optind];
238 create_icon_factory (void)
240 GtkIconFactory *factory = gtk_icon_factory_new ();
242 GtkIconSet *icon_set;
246 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
247 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
248 g_object_unref (pixbuf);
249 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
251 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
252 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
253 g_object_unref (pixbuf);
254 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
256 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
257 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
258 g_object_unref (pixbuf);
259 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
261 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
262 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
263 g_object_unref (pixbuf);
264 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
266 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
267 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
268 g_object_unref (pixbuf);
269 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
271 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
272 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
273 g_object_unref (pixbuf);
274 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
276 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
277 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
278 g_object_unref (pixbuf);
279 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
281 gtk_icon_factory_add_default (factory);