2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include <libpspp/version.h>
27 #include <libpspp/copyleft.h>
29 static gboolean parse_command_line (int *argc, char ***argv, gchar **filename,
30 gboolean *show_splash, GError **err);
35 create_splash_window (void)
40 gtk_window_set_auto_startup_notification (FALSE);
42 splash = gtk_window_new (GTK_WINDOW_POPUP);
44 gtk_window_set_position (GTK_WINDOW (splash),
45 GTK_WIN_POS_CENTER_ALWAYS);
47 image = gtk_image_new_from_file (PKGDATADIR "/splash.png");
49 gtk_container_add (GTK_CONTAINER (splash), image);
51 gtk_widget_show (image);
57 hide_splash_window (gpointer data)
59 GtkWidget *splash = data;
60 gtk_widget_hide (splash);
61 gtk_window_set_auto_startup_notification (TRUE);
67 quit_one_loop (gpointer data)
75 run_inner_loop (gpointer data)
79 g_timeout_add (500, hide_splash_window, data);
91 main (int argc, char *argv[])
93 GtkWidget *splash_window;
95 gboolean show_splash = TRUE;
99 set_program_name (argv[0]);
101 if ( ! gtk_parse_args (&argc, &argv) )
103 perror ("Error parsing arguments");
107 if ( (vers = gtk_check_version (GTK_MAJOR_VERSION,
109 GTK_MICRO_VERSION)) )
114 /* Deal with options like --version, --help etc */
115 if ( ! parse_command_line (&argc, &argv, &filename, &show_splash, &err) )
117 g_clear_error (&err);
121 gdk_init (&argc, &argv);
123 splash_window = create_splash_window ();
125 gtk_widget_show (splash_window);
127 gtk_idle_add (quit_one_loop, 0);
129 gtk_quit_add (0, run_inner_loop, splash_window);
137 /* Parses the command line specified by ARGC and ARGV as received by
138 main (). Returns true if normal execution should proceed,
139 false if the command-line indicates that PSPP should exit. */
141 parse_command_line (int *argc, char ***argv, gchar **filename,
142 gboolean *show_splash, GError **err)
145 static struct option long_options[] =
147 {"help", no_argument, NULL, 'h'},
148 {"version", no_argument, NULL, 'V'},
149 {"no-splash", no_argument, NULL, 'q'},
157 c = getopt_long (*argc, *argv, "hVq", long_options, NULL);
164 g_print ("Usage: psppire {|--help|--version|--no-splash}\n");
172 *show_splash = FALSE;
181 *filename = (*argv)[optind];