1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2004, 2005, 2006 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/>. */
18 #include <gl/xalloc.h>
24 #include <gl/relocatable.h>
25 #include <ui/command-line.h>
26 #include <ui/source-init-opts.h>
28 #include <libpspp/version.h>
29 #include <libpspp/copyleft.h>
32 #define _(msgid) gettext (msgid)
33 #define N_(msgid) msgid
35 const char *argp_program_version = version;
36 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
39 /* Arguments to be interpreted before the X server gets initialised */
41 static const struct argp_option startup_options [] =
43 {"no-splash", 'q', 0, 0, N_("Don't show the splash screen"), 0 },
48 parse_startup_opts (int key, char *arg, struct argp_state *state)
50 gboolean *showsplash = state->input;
58 return ARGP_ERR_UNKNOWN;
63 static const struct argp startup_argp = {startup_options, parse_startup_opts, 0, 0, 0, 0, 0};
68 create_splash_window (void)
73 gtk_window_set_auto_startup_notification (FALSE);
75 splash = gtk_window_new (GTK_WINDOW_POPUP);
77 gtk_window_set_position (GTK_WINDOW (splash),
78 GTK_WIN_POS_CENTER_ALWAYS);
80 gtk_window_set_type_hint (GTK_WINDOW (splash),
81 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
83 image = gtk_image_new_from_file (relocate (PKGDATADIR "/splash.png"));
85 gtk_container_add (GTK_CONTAINER (splash), image);
87 gtk_widget_show (image);
93 hide_splash_window (gpointer data)
95 GtkWidget *splash = data;
96 gtk_widget_destroy (splash);
97 gtk_window_set_auto_startup_notification (TRUE);
103 quit_one_loop (gpointer data)
109 struct initialisation_parameters
113 GtkWidget *splash_window;
114 struct command_line_processor *clp;
119 run_inner_loop (gpointer data)
121 struct initialisation_parameters *ip = data;
122 initialize (ip->clp, ip->argc, ip->argv);
124 g_timeout_add (500, hide_splash_window, ip->splash_window);
134 static GMemVTable vtable =
145 main (int argc, char *argv[])
147 struct command_line_processor *clp ;
148 struct initialisation_parameters init_p;
149 gboolean show_splash = TRUE;
153 set_program_name (argv[0]);
155 g_mem_set_vtable (&vtable);
157 gtk_disable_setlocale ();
160 if ( ! gtk_parse_args (&argc, &argv) )
162 perror ("Error parsing arguments");
166 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
168 GTK_MICRO_VERSION)) )
173 clp = command_line_processor_create (_("PSPPIRE --- A user interface for PSPP"), "[ DATA-FILE ]", 0);
175 command_line_processor_add_options (clp, &startup_argp, _("Miscellaneous options:"), &show_splash);
176 command_line_processor_add_options (clp, &post_init_argp,
177 _("Options affecting syntax and behavior:"), NULL);
178 command_line_processor_add_options (clp, &non_option_argp, NULL, NULL);
180 command_line_processor_parse (clp, argc, argv);
182 gdk_init (&argc, &argv);
184 init_p.splash_window = create_splash_window ();
190 gtk_widget_show (init_p.splash_window);
192 g_idle_add (quit_one_loop, 0);
194 gtk_quit_add (0, run_inner_loop, &init_p);