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
24 #include <libpspp/version.h>
25 #include <libpspp/copyleft.h>
26 #include <data/settings.h>
31 #include <glade/glade.h>
32 #include "menu-actions.h"
33 #include "psppire-dict.h"
34 #include "psppire-var-store.h"
35 #include "psppire-data-store.h"
37 #include "data-sheet.h"
38 #include "var-sheet.h"
39 #include "message-dialog.h"
44 PsppireDict *the_dictionary = 0;
46 PsppireDataStore *data_store = 0;
49 static bool parse_command_line (int *argc, char ***argv,
50 gchar **filename, GError **err);
53 #define _(msgid) gettext (msgid)
54 #define N_(msgid) msgid
59 static struct msg m = {
67 m.text=g_strdup(_("Sorry. The help system hasn't yet been implemented."));
72 PsppireVarStore *var_store = 0;
74 void create_icon_factory (void);
77 main(int argc, char *argv[])
80 GtkWidget *data_editor ;
82 GtkSheet *data_sheet ;
88 gtk_init(&argc, &argv);
89 if ( (vers = gtk_check_version(GTK_MAJOR_VERSION,
97 /* gtk_init messes with the locale.
98 So unset the bits we want to control ourselves */
99 setlocale (LC_NUMERIC, "C");
101 bindtextdomain (PACKAGE, locale_dir);
103 textdomain (PACKAGE);
105 if ( ! parse_command_line(&argc, &argv, &filename, &err) )
117 message_dialog_init();
119 the_dictionary = psppire_dict_new();
121 bind_textdomain_codeset(PACKAGE, "UTF-8");
123 /* Create the model for the var_sheet */
124 var_store = psppire_var_store_new(the_dictionary);
126 data_store = psppire_data_store_new(the_dictionary);
128 create_icon_factory();
130 /* load the interface */
131 xml = glade_xml_new(PKGDATADIR "/psppire.glade", NULL, NULL);
133 if ( !xml ) return 1;
135 data_editor = get_widget_assert(xml, "data_editor");
136 gtk_window_set_icon_from_file(GTK_WINDOW(data_editor),
137 PKGDATADIR "/psppicon.png",0);
139 /* connect the signals in the interface */
140 glade_xml_signal_autoconnect(xml);
142 var_sheet = GTK_SHEET(get_widget_assert(xml, "variable_sheet"));
143 data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet"));
145 gtk_sheet_set_model(var_sheet, G_SHEET_MODEL(var_store));
147 gtk_sheet_set_model(data_sheet, G_SHEET_MODEL(data_store));
150 gtk_init_add((GtkFunction)load_system_file, filename);
152 gtk_init_add((GtkFunction)clear_file, 0);
154 var_data_selection_init();
157 GList *helps = glade_xml_get_widget_prefix(xml, "help_button_");
160 for ( i = g_list_first(helps); i ; i = g_list_next(i))
161 g_signal_connect(GTK_WIDGET(i->data), "clicked", give_help, 0);
165 /* start the event loop */
168 message_dialog_done();
176 /* Parses the command line specified by ARGC and ARGV as received by
177 main(). Returns true if normal execution should proceed,
178 false if the command-line indicates that PSPP should exit. */
180 parse_command_line (int *argc, char ***argv, gchar **filename, GError **err)
182 static struct option long_options[] =
184 {"help", no_argument, NULL, 'h'},
185 {"version", no_argument, NULL, 'V'},
193 c = getopt_long (*argc, *argv, "hV", long_options, NULL);
200 g_print ("Usage: psppire {|--help|--version}\n");
214 *filename = (*argv)[optind];
223 create_icon_factory (void)
225 GtkIconFactory *factory = gtk_icon_factory_new();
227 GtkIconSet *icon_set;
231 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/value-labels.png", 0);
232 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
233 g_object_unref (pixbuf);
234 gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
236 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/weight-cases.png", 0);
237 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
238 g_object_unref (pixbuf);
239 gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
241 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/goto-variable.png", 0);
242 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
243 g_object_unref (pixbuf);
244 gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
246 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-variable.png", 0);
247 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
248 g_object_unref (pixbuf);
249 gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
251 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/insert-case.png", 0);
252 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
253 g_object_unref (pixbuf);
254 gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
256 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/split-file.png", 0);
257 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
258 g_object_unref (pixbuf);
259 gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
261 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR "/select-cases.png", 0);
262 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
263 g_object_unref (pixbuf);
264 gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
266 gtk_icon_factory_add_default (factory);