2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation
4 Written by John Darrington
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include <libpspp/version.h>
27 #include <libpspp/copyleft.h>
28 #include <data/format.h>
29 #include <data/settings.h>
30 #include <libpspp/getl.h>
35 #include <glade/glade.h>
36 #include "menu-actions.h"
37 #include "psppire-dict.h"
38 #include "psppire-var-store.h"
39 #include "psppire-data-store.h"
41 #include "data-sheet.h"
42 #include "var-sheet.h"
43 #include "message-dialog.h"
48 PsppireDict *the_dictionary = 0;
50 PsppireDataStore *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 *var_store = 0;
78 void create_icon_factory (void);
80 static struct source_stream *the_source_stream ;
83 main(int argc, char *argv[])
86 GtkWidget *data_editor ;
88 GtkSheet *data_sheet ;
94 gtk_init(&argc, &argv);
95 if ( (vers = gtk_check_version(GTK_MAJOR_VERSION,
103 /* gtk_init messes with the locale.
104 So unset the bits we want to control ourselves */
105 setlocale (LC_NUMERIC, "C");
107 bindtextdomain (PACKAGE, locale_dir);
109 textdomain (PACKAGE);
111 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
121 the_source_stream = create_source_stream ();
122 message_dialog_init (the_source_stream);
124 the_dictionary = psppire_dict_new();
126 bind_textdomain_codeset(PACKAGE, "UTF-8");
128 /* Create the model for the var_sheet */
129 var_store = psppire_var_store_new(the_dictionary);
131 data_store = psppire_data_store_new(the_dictionary);
133 create_icon_factory();
135 /* load the interface */
136 xml = glade_xml_new(PKGDATADIR "/psppire.glade", NULL, NULL);
138 if ( !xml ) return 1;
140 data_editor = get_widget_assert(xml, "data_editor");
141 gtk_window_set_icon_from_file(GTK_WINDOW(data_editor),
142 PKGDATADIR "/psppicon.png",0);
144 /* connect the signals in the interface */
145 glade_xml_signal_autoconnect(xml);
147 var_sheet = GTK_SHEET(get_widget_assert(xml, "variable_sheet"));
148 data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet"));
150 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(var_store));
152 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store));
155 gtk_init_add((GtkFunction)load_system_file, filename);
157 gtk_init_add((GtkFunction)clear_file, 0);
159 var_data_selection_init();
162 GList *helps = glade_xml_get_widget_prefix(xml, "help_button_");
165 for ( i = g_list_first(helps); i ; i = g_list_next(i))
166 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
170 /* start the event loop */
173 destroy_source_stream (the_source_stream);
174 message_dialog_done();
182 /* Parses the command line specified by ARGC and ARGV as received by
183 main(). Returns true if normal execution should proceed,
184 false if the command-line indicates that PSPP should exit. */
186 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
188 static struct option long_options[] =
190 {"help", no_argument, NULL, 'h'},
191 {"version", no_argument, NULL, 'V'},
199 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
206 g_print ("Usage: psppire {|--help|--version}\n");
220 *filename = (*argv)[optind];
229 create_icon_factory (void)
231 GtkIconFactory *factory = gtk_icon_factory_new();
233 GtkIconSet *icon_set;
237 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
238 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
239 g_object_unref (pixbuf);
240 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
242 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
243 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
244 g_object_unref (pixbuf);
245 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
247 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
248 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
249 g_object_unref (pixbuf);
250 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
252 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
253 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
254 g_object_unref (pixbuf);
255 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
257 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
258 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
259 g_object_unref (pixbuf);
260 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
262 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
263 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
264 g_object_unref (pixbuf);
265 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
267 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
268 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
269 g_object_unref (pixbuf);
270 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
272 gtk_icon_factory_add_default (factory);