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/>. */
24 #include <libpspp/version.h>
25 #include <libpspp/copyleft.h>
27 static gboolean parse_command_line (int *argc, char ***argv, gchar **filename,
28 gboolean *show_splash, GError **err);
33 create_splash_window (void)
38 gtk_window_set_auto_startup_notification (FALSE);
40 splash = gtk_window_new (GTK_WINDOW_POPUP);
42 gtk_window_set_position (GTK_WINDOW (splash),
43 GTK_WIN_POS_CENTER_ALWAYS);
45 gtk_window_set_type_hint (GTK_WINDOW (splash),
46 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
48 image = gtk_image_new_from_file (PKGDATADIR "/splash.png");
50 gtk_container_add (GTK_CONTAINER (splash), image);
52 gtk_widget_show (image);
58 hide_splash_window (gpointer data)
60 GtkWidget *splash = data;
61 gtk_widget_destroy (splash);
62 gtk_window_set_auto_startup_notification (TRUE);
68 quit_one_loop (gpointer data)
76 run_inner_loop (gpointer data)
80 g_timeout_add (500, hide_splash_window, data);
92 main (int argc, char *argv[])
94 GtkWidget *splash_window;
96 gboolean show_splash = TRUE;
100 set_program_name (argv[0]);
102 if ( ! gtk_parse_args (&argc, &argv) )
104 perror ("Error parsing arguments");
108 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
110 GTK_MICRO_VERSION)) )
115 /* Deal with options like --version, --help etc */
116 if ( ! parse_command_line (&argc, &argv, &filename, &show_splash, &err) )
118 g_clear_error (&err);
122 gdk_init (&argc, &argv);
124 splash_window = create_splash_window ();
126 gtk_widget_show (splash_window);
128 g_idle_add (quit_one_loop, 0);
130 gtk_quit_add (0, run_inner_loop, splash_window);
138 /* Parses the command line specified by ARGC and ARGV as received by
139 main (). Returns true if normal execution should proceed,
140 false if the command-line indicates that PSPP should exit. */
142 parse_command_line (int *argc, char ***argv, gchar **filename,
143 gboolean *show_splash, GError **err)
146 static struct option long_options[] =
148 {"help", no_argument, NULL, 'h'},
149 {"version", no_argument, NULL, 'V'},
150 {"no-splash", no_argument, NULL, 'q'},
158 c = getopt_long (*argc, *argv, "hVq", long_options, NULL);
165 g_print ("Usage: psppire {|--help|--version|--no-splash}\n");
173 *show_splash = FALSE;
182 *filename = (*argv)[optind];