1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2004, 2005, 2006, 2010 Free Software Foundation
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.
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.
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/>. */
19 #include "ui/gui/psppire.h"
24 #include "libpspp/argv-parser.h"
25 #include "libpspp/assertion.h"
26 #include "libpspp/getl.h"
27 #include "libpspp/version.h"
28 #include "libpspp/copyleft.h"
29 #include "ui/source-init-opts.h"
31 #include "gl/configmake.h"
32 #include "gl/progname.h"
33 #include "gl/relocatable.h"
34 #include "gl/xalloc.h"
37 #define _(msgid) gettext (msgid)
38 #define N_(msgid) msgid
41 /* Arguments to be interpreted before the X server gets initialised */
49 static const struct argv_option startup_options[N_STARTUP_OPTIONS] =
51 {"no-splash", 'q', no_argument, OPT_NO_SPLASH}
55 startup_option_callback (int id, void *show_splash_)
57 gboolean *show_splash = show_splash_;
71 create_splash_window (void)
76 gtk_window_set_auto_startup_notification (FALSE);
78 splash = gtk_window_new (GTK_WINDOW_POPUP);
80 gtk_window_set_position (GTK_WINDOW (splash),
81 GTK_WIN_POS_CENTER_ALWAYS);
83 gtk_window_set_type_hint (GTK_WINDOW (splash),
84 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
86 image = gtk_image_new_from_file (relocate (PKGDATADIR "/splash.png"));
88 gtk_container_add (GTK_CONTAINER (splash), image);
90 gtk_widget_show (image);
96 hide_splash_window (gpointer data)
98 GtkWidget *splash = data;
99 gtk_widget_destroy (splash);
100 gtk_window_set_auto_startup_notification (TRUE);
106 quit_one_loop (gpointer data)
112 struct initialisation_parameters
114 struct source_stream *ss;
115 const char *data_file;
116 GtkWidget *splash_window;
121 run_inner_loop (gpointer data)
123 struct initialisation_parameters *ip = data;
124 initialize (ip->ss, ip->data_file);
126 g_timeout_add (500, hide_splash_window, ip->splash_window);
136 static GMemVTable vtable =
147 main (int argc, char *argv[])
149 struct initialisation_parameters init_p;
150 gboolean show_splash = TRUE;
151 struct argv_parser *parser;
152 struct source_stream *ss;
155 set_program_name (argv[0]);
157 g_mem_set_vtable (&vtable);
159 gtk_disable_setlocale ();
162 if ( ! gtk_parse_args (&argc, &argv) )
164 perror ("Error parsing arguments");
168 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
170 GTK_MICRO_VERSION)) )
172 g_warning ("%s", vers);
175 /* Let GDK remove any options that it owns. */
176 gdk_init (&argc, &argv);
178 /* Parse our own options. */
179 ss = create_source_stream ();
180 parser = argv_parser_create ();
181 argv_parser_add_options (parser, startup_options, N_STARTUP_OPTIONS,
182 startup_option_callback, &show_splash);
183 source_init_register_argv_parser (parser, ss);
184 if (!argv_parser_run (parser, argc, argv))
186 argv_parser_destroy (parser);
188 init_p.splash_window = create_splash_window ();
190 init_p.data_file = optind < argc ? argv[optind] : NULL;
193 gtk_widget_show (init_p.splash_window);
195 g_idle_add (quit_one_loop, 0);
197 gtk_quit_add (0, run_inner_loop, &init_p);