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/>. */
23 #include <gl/relocatable.h>
24 #include <ui/command-line.h>
25 #include <ui/source-init-opts.h>
27 #include <libpspp/version.h>
28 #include <libpspp/copyleft.h>
31 #define _(msgid) gettext (msgid)
32 #define N_(msgid) msgid
34 const char *argp_program_version = version;
35 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
38 /* Arguments to be interpreted before the X server gets initialised */
40 static const struct argp_option startup_options [] =
42 {"no-splash", 'q', 0, 0, N_("Don't show the splash screen"), 0 },
47 parse_startup_opts (int key, char *arg, struct argp_state *state)
49 gboolean *showsplash = state->input;
57 return ARGP_ERR_UNKNOWN;
62 static const struct argp startup_argp = {startup_options, parse_startup_opts, 0, 0, 0, 0, 0};
67 create_splash_window (void)
72 gtk_window_set_auto_startup_notification (FALSE);
74 splash = gtk_window_new (GTK_WINDOW_POPUP);
76 gtk_window_set_position (GTK_WINDOW (splash),
77 GTK_WIN_POS_CENTER_ALWAYS);
79 gtk_window_set_type_hint (GTK_WINDOW (splash),
80 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
82 image = gtk_image_new_from_file (relocate (PKGDATADIR "/splash.png"));
84 gtk_container_add (GTK_CONTAINER (splash), image);
86 gtk_widget_show (image);
92 hide_splash_window (gpointer data)
94 GtkWidget *splash = data;
95 gtk_widget_destroy (splash);
96 gtk_window_set_auto_startup_notification (TRUE);
102 quit_one_loop (gpointer data)
108 struct initialisation_parameters
112 GtkWidget *splash_window;
113 struct command_line_processor *clp;
118 run_inner_loop (gpointer data)
120 struct initialisation_parameters *ip = data;
121 initialize (ip->clp, ip->argc, ip->argv);
123 g_timeout_add (500, hide_splash_window, ip->splash_window);
135 main (int argc, char *argv[])
137 struct command_line_processor *clp ;
138 struct initialisation_parameters init_p;
139 gboolean show_splash = TRUE;
143 set_program_name (argv[0]);
145 if ( ! gtk_parse_args (&argc, &argv) )
147 perror ("Error parsing arguments");
151 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
153 GTK_MICRO_VERSION)) )
158 clp = command_line_processor_create (_("PSPPIRE --- A user interface for PSPP"), "[ DATA-FILE ]", 0);
160 command_line_processor_add_options (clp, &startup_argp, _("Miscellaneous options:"), &show_splash);
161 command_line_processor_add_options (clp, &post_init_argp,
162 _("Options affecting syntax and behavior:"), NULL);
163 command_line_processor_add_options (clp, &non_option_argp, NULL, NULL);
165 command_line_processor_parse (clp, argc, argv);
167 gdk_init (&argc, &argv);
169 init_p.splash_window = create_splash_window ();
175 gtk_widget_show (init_p.splash_window);
177 g_idle_add (quit_one_loop, 0);
179 gtk_quit_add (0, run_inner_loop, &init_p);