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/progname.h"
32 #include "gl/relocatable.h"
33 #include "gl/xalloc.h"
36 #define _(msgid) gettext (msgid)
37 #define N_(msgid) msgid
40 /* Arguments to be interpreted before the X server gets initialised */
48 static const struct argv_option startup_options[N_STARTUP_OPTIONS] =
50 {"no-splash", 'q', no_argument, OPT_NO_SPLASH}
54 startup_option_callback (int id, void *show_splash_)
56 gboolean *show_splash = show_splash_;
70 create_splash_window (void)
75 gtk_window_set_auto_startup_notification (FALSE);
77 splash = gtk_window_new (GTK_WINDOW_POPUP);
79 gtk_window_set_position (GTK_WINDOW (splash),
80 GTK_WIN_POS_CENTER_ALWAYS);
82 gtk_window_set_type_hint (GTK_WINDOW (splash),
83 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
85 image = gtk_image_new_from_file (relocate (PKGDATADIR "/splash.png"));
87 gtk_container_add (GTK_CONTAINER (splash), image);
89 gtk_widget_show (image);
95 hide_splash_window (gpointer data)
97 GtkWidget *splash = data;
98 gtk_widget_destroy (splash);
99 gtk_window_set_auto_startup_notification (TRUE);
105 quit_one_loop (gpointer data)
111 struct initialisation_parameters
113 struct source_stream *ss;
114 const char *data_file;
115 GtkWidget *splash_window;
120 run_inner_loop (gpointer data)
122 struct initialisation_parameters *ip = data;
123 initialize (ip->ss, ip->data_file);
125 g_timeout_add (500, hide_splash_window, ip->splash_window);
135 static GMemVTable vtable =
146 main (int argc, char *argv[])
148 struct initialisation_parameters init_p;
149 gboolean show_splash = TRUE;
150 struct argv_parser *parser;
151 struct source_stream *ss;
154 set_program_name (argv[0]);
156 g_mem_set_vtable (&vtable);
158 gtk_disable_setlocale ();
161 if ( ! gtk_parse_args (&argc, &argv) )
163 perror ("Error parsing arguments");
167 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
169 GTK_MICRO_VERSION)) )
171 g_warning ("%s", vers);
174 /* Let GDK remove any options that it owns. */
175 gdk_init (&argc, &argv);
177 /* Parse our own options. */
178 ss = create_source_stream ();
179 parser = argv_parser_create ();
180 argv_parser_add_options (parser, startup_options, N_STARTUP_OPTIONS,
181 startup_option_callback, &show_splash);
182 source_init_register_argv_parser (parser, ss);
183 if (!argv_parser_run (parser, argc, argv))
185 argv_parser_destroy (parser);
187 init_p.splash_window = create_splash_window ();
189 init_p.data_file = optind < argc ? argv[optind] : NULL;
192 gtk_widget_show (init_p.splash_window);
194 g_idle_add (quit_one_loop, 0);
196 gtk_quit_add (0, run_inner_loop, &init_p);