Enabled output generation in the GUI.
[pspp-builds.git] / src / ui / gui / psppire.c
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2004, 2005, 2006  Free Software Foundation
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #include <config.h>
18
19 #include <assert.h>
20 #include <libintl.h>
21
22 #include "relocatable.h"
23
24 #include "data-editor.h"
25
26 #include "psppire.h"
27
28
29 #include <data/casereader.h>
30 #include <data/datasheet.h>
31 #include <data/file-handle-def.h>
32 #include <data/format.h>
33 #include <data/settings.h>
34 #include <data/file-name.h>
35 #include <data/procedure.h>
36 #include <libpspp/getl.h>
37 #include <language/lexer/lexer.h>
38 #include <libpspp/version.h>
39 #include <output/output.h>
40
41 #include <gtk/gtk.h>
42 #include <glade/glade.h>
43 #include "psppire-dict.h"
44 #include "psppire-var-store.h"
45 #include "psppire-data-store.h"
46 #include "helper.h"
47 #include "data-sheet.h"
48 #include "var-sheet.h"
49 #include "message-dialog.h"
50
51 PsppireDataStore *the_data_store = 0;
52 PsppireVarStore *the_var_store = 0;
53
54 static void create_icon_factory (void);
55
56 struct source_stream *the_source_stream ;
57 struct dataset * the_dataset = NULL;
58
59
60 static void
61 replace_casereader (struct casereader *s)
62 {
63   PsppireCaseFile *pcf = psppire_case_file_new (s);
64
65   psppire_data_store_set_case_file (the_data_store, pcf);
66 }
67
68 void
69 initialize (void)
70 {
71   PsppireDict *dictionary = 0;
72
73   /* gtk_init messes with the locale.
74      So unset the bits we want to control ourselves */
75   setlocale (LC_NUMERIC, "C");
76
77   bindtextdomain (PACKAGE, locale_dir);
78
79   textdomain (PACKAGE);
80
81   glade_init ();
82
83   fmt_init ();
84   fn_init ();
85   outp_init ();
86   settings_init ();
87   fh_init ();
88   the_source_stream =
89     create_source_stream (
90                           fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
91                           );
92
93   the_dataset = create_dataset (NULL, NULL);
94
95
96   message_dialog_init (the_source_stream);
97
98   dictionary = psppire_dict_new_from_dict (dataset_dict (the_dataset));
99
100   bind_textdomain_codeset (PACKAGE, "UTF-8");
101
102   /* Create the model for the var_sheet */
103   the_var_store = psppire_var_store_new (dictionary);
104
105   the_data_store = psppire_data_store_new (dictionary);
106   replace_casereader (NULL);
107
108   create_icon_factory ();
109
110   outp_read_devices ();
111   outp_enable_device (true, OUTP_DEV_SCREEN);
112
113   new_data_window (NULL, NULL);
114 }
115
116
117 void
118 de_initialize (void)
119 {
120   destroy_source_stream (the_source_stream);
121   message_dialog_done ();
122   settings_done ();
123   outp_done ();
124 }
125
126
127 #define PIXBUF_NEW_FROM_FILE(FILE) \
128   gdk_pixbuf_new_from_file (relocate (PKGDATADIR "/" FILE), 0)
129
130
131 static void
132 create_icon_factory (void)
133 {
134   GtkIconFactory *factory = gtk_icon_factory_new ();
135
136   GtkIconSet *icon_set;
137
138   GdkPixbuf *pixbuf;
139
140   pixbuf = PIXBUF_NEW_FROM_FILE ("value-labels.png");
141   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
142   g_object_unref (pixbuf);
143   gtk_icon_factory_add ( factory, "pspp-value-labels", icon_set);
144
145   pixbuf = PIXBUF_NEW_FROM_FILE ("weight-cases.png");
146   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
147   g_object_unref (pixbuf);
148   gtk_icon_factory_add ( factory, "pspp-weight-cases", icon_set);
149
150   pixbuf = PIXBUF_NEW_FROM_FILE ("goto-variable.png");
151   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
152   g_object_unref (pixbuf);
153   gtk_icon_factory_add ( factory, "pspp-goto-variable", icon_set);
154
155   pixbuf = PIXBUF_NEW_FROM_FILE ("insert-variable.png");
156   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
157   g_object_unref (pixbuf);
158   gtk_icon_factory_add ( factory, "pspp-insert-variable", icon_set);
159
160   pixbuf = PIXBUF_NEW_FROM_FILE ("insert-case.png");
161   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
162   g_object_unref (pixbuf);
163   gtk_icon_factory_add ( factory, "pspp-insert-case", icon_set);
164
165   pixbuf = PIXBUF_NEW_FROM_FILE ("split-file.png");
166   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
167   g_object_unref (pixbuf);
168   gtk_icon_factory_add ( factory, "pspp-split-file", icon_set);
169
170   pixbuf = PIXBUF_NEW_FROM_FILE ("select-cases.png");
171   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
172   g_object_unref (pixbuf);
173   gtk_icon_factory_add ( factory, "pspp-select-cases", icon_set);
174
175   pixbuf = PIXBUF_NEW_FROM_FILE ("recent-dialogs.png");
176   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
177   g_object_unref (pixbuf);
178   gtk_icon_factory_add ( factory, "pspp-recent-dialogs", icon_set);
179
180   pixbuf = PIXBUF_NEW_FROM_FILE ("nominal.png");
181   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
182   g_object_unref (pixbuf);
183   gtk_icon_factory_add ( factory, "var-nominal", icon_set);
184
185   pixbuf = PIXBUF_NEW_FROM_FILE ("ordinal.png");
186   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
187   g_object_unref (pixbuf);
188   gtk_icon_factory_add ( factory, "var-ordinal", icon_set);
189
190   pixbuf = PIXBUF_NEW_FROM_FILE ("scale.png");
191   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
192   g_object_unref (pixbuf);
193   gtk_icon_factory_add ( factory, "var-scale", icon_set);
194
195   pixbuf = PIXBUF_NEW_FROM_FILE ("string.png");
196   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
197   g_object_unref (pixbuf);
198   gtk_icon_factory_add ( factory, "var-string", icon_set);
199
200   pixbuf = PIXBUF_NEW_FROM_FILE ("date-scale.png");
201   icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
202   g_object_unref (pixbuf);
203   gtk_icon_factory_add ( factory, "var-date-scale", icon_set);
204
205
206   gtk_icon_factory_add_default (factory);
207 }
208