2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * splash.c: Splash screen module
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <libgnome/libgnome.h>
32 #ifdef PACKAGE_DATA_DIR
33 #define SPLASH_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-logo.png")
35 #define SPLASH_PIXMAP gnome_pixmap_file("glabels/glabels-logo.png")
38 #define SPLASH_TIMEOUT 2000
40 static GtkWidget *splash = NULL;
42 static gint splash_timeout (gpointer not_used);
45 /***************************************************************************/
46 /* Create splash screen. */
47 /***************************************************************************/
51 GtkWidget *wimage, *wvbox, *whbox, *wframe1, *wframe2;
54 GError *gerror = NULL;
59 splash = gtk_window_new (GTK_WINDOW_POPUP);
60 gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);
62 wframe1 = gtk_frame_new (NULL);
63 gtk_frame_set_shadow_type (GTK_FRAME (wframe1), GTK_SHADOW_OUT);
64 wframe2 = gtk_frame_new (NULL);
66 wvbox = gtk_vbox_new (FALSE, 5);
67 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 2);
69 whbox = gtk_hbox_new (FALSE, 5);
71 if (!g_file_test (SPLASH_PIXMAP, G_FILE_TEST_EXISTS)) {
72 g_warning ("Could not find %s", SPLASH_PIXMAP);
74 pixbuf = gdk_pixbuf_new_from_file (SPLASH_PIXMAP, &gerror);
76 g_warning ("cannot open splash pixbuf: %s", gerror->message );
77 gtk_widget_destroy (splash);
80 wimage = gtk_image_new_from_pixbuf (pixbuf);
82 gtk_container_add (GTK_CONTAINER (splash), wframe1);
83 gtk_container_add (GTK_CONTAINER (wframe1), wframe2);
84 gtk_container_add (GTK_CONTAINER (wframe2), wvbox);
86 gtk_box_pack_start (GTK_BOX (wvbox), wimage, TRUE, TRUE, 0);
88 label = g_strdup_printf ("Version %s", VERSION);
89 gtk_box_pack_start (GTK_BOX (wvbox),
90 gtk_label_new (label), TRUE, TRUE, 0);
93 gtk_widget_show_all (splash);
95 gtk_timeout_add (SPLASH_TIMEOUT, splash_timeout, NULL);
97 while (gtk_events_pending ()) {
98 gtk_main_iteration ();
102 /*-------------------------------------------------------------------------*/
103 /* PRIVATE. Callback to tear-down splash screen once timer has expired. */
104 /*-------------------------------------------------------------------------*/
106 splash_timeout (gpointer not_used)
109 gtk_widget_destroy (splash);