re-adding .pngs as binary
[dia.git] / app / splash.c
blob364101577afffbda8db2e5856915a99687c0ef9d
1 #include <config.h>
3 #include <gtk/gtk.h>
4 #include <gdk-pixbuf/gdk-pixbuf.h>
6 #include "intl.h"
7 #include "dia_dirs.h"
8 #include "app_procs.h"
10 extern GdkPixbuf *logo;
12 static GtkWidget*
13 get_logo_pixmap (void)
15 GtkWidget* gpixmap = NULL;
16 gchar str[512];
18 if (!logo) {
19 gchar* datadir = dia_get_data_directory("");
20 g_snprintf(str, sizeof(str), "%s/dia_logo.png", datadir);
21 logo = gdk_pixbuf_new_from_file(str);
22 g_free(datadir);
25 if (logo) {
26 GdkPixmap *pixmap;
27 GdkBitmap *bitmap;
29 gdk_pixbuf_render_pixmap_and_mask(logo, &pixmap, &bitmap, 128);
30 gpixmap = gtk_pixmap_new(pixmap, bitmap);
31 gdk_pixmap_unref(pixmap);
32 if (bitmap) gdk_bitmap_unref(bitmap);
34 return gpixmap;
37 static GtkWidget* splash = NULL;
39 static void
40 splash_expose (GtkWidget *widget, GdkEventExpose *event)
42 /* this gets called after the splash screen gets exposed ... */
43 gtk_main_quit();
46 void
47 app_splash_init (const gchar* fname)
49 GtkWidget *vbox;
50 GtkWidget* gpixmap;
51 GtkWidget *label;
52 GtkWidget *frame;
53 gchar str[256];
54 guint signal_id;
56 splash = gtk_window_new (GTK_WINDOW_DIALOG);
57 gtk_window_set_wmclass (GTK_WINDOW (splash), "start_dialog", "Dia");
58 gtk_window_set_title (GTK_WINDOW (splash), _("Loading ..."));
59 gtk_window_set_policy (GTK_WINDOW (splash), FALSE, FALSE, FALSE);
60 gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);
62 vbox = gtk_vbox_new (FALSE, 2);
63 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
64 gtk_container_add (GTK_CONTAINER(splash), vbox);
66 gpixmap = get_logo_pixmap();
68 frame = gtk_frame_new (NULL);
69 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
70 gtk_container_set_border_width (GTK_CONTAINER (frame), 1);
71 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 1);
73 gtk_container_add (GTK_CONTAINER(frame), gpixmap);
75 g_snprintf(str, sizeof(str), _("Dia v %s"), VERSION);
76 label = gtk_label_new (str);
77 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 1);
79 gtk_widget_show_all (splash);
81 signal_id = gtk_signal_connect_after(GTK_OBJECT(splash), "expose_event",
82 GTK_SIGNAL_FUNC(splash_expose), NULL);
84 /* splash_expose gets us out of this */
85 gtk_main();
86 gtk_signal_disconnect(GTK_OBJECT(splash), signal_id);
89 void
90 app_splash_done (void)
92 if (splash)
94 gtk_widget_destroy (splash);
95 splash = NULL;