offset fixes, admit to textline, proper updating of height/font at attr set,
[dia.git] / app / splash.c
blobd9a1b44d9bf4860c47f9b972faf8d5ca9537b0c1
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 static GtkWidget*
11 get_logo_pixmap (void)
13 GdkPixbuf *logo = NULL;
14 GtkWidget* gpixmap = NULL;
15 gchar str[512];
17 gchar* datadir = dia_get_data_directory("");
18 g_snprintf(str, sizeof(str), "%s/dia_logo.png", datadir);
19 logo = gdk_pixbuf_new_from_file(str, NULL);
20 g_free(datadir);
22 if (logo) {
23 GdkPixmap *pixmap;
24 GdkBitmap *bitmap;
26 gdk_pixbuf_render_pixmap_and_mask(logo, &pixmap, &bitmap, 128);
27 gpixmap = gtk_pixmap_new(pixmap, bitmap);
28 gdk_pixmap_unref(pixmap);
29 if (bitmap) gdk_bitmap_unref(bitmap);
30 g_object_unref (logo);
32 return gpixmap;
35 static GtkWidget* splash = NULL;
37 static void
38 splash_expose (GtkWidget *widget, GdkEventExpose *event)
40 /* this gets called after the splash screen gets exposed ... */
41 gtk_main_quit();
44 void
45 app_splash_init (const gchar* fname)
47 GtkWidget *vbox;
48 GtkWidget* gpixmap;
49 GtkWidget *label;
50 GtkWidget *frame;
51 gchar str[256];
52 gulong signal_id;
54 splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);
55 gtk_window_set_role (GTK_WINDOW (splash), "start_dialog");
56 gtk_window_set_title (GTK_WINDOW (splash), _("Loading ..."));
57 gtk_window_set_resizable (GTK_WINDOW (splash), FALSE);
58 gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);
60 vbox = gtk_vbox_new (FALSE, 2);
61 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
62 gtk_container_add (GTK_CONTAINER(splash), vbox);
64 gpixmap = get_logo_pixmap();
66 frame = gtk_frame_new (NULL);
67 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
68 gtk_container_set_border_width (GTK_CONTAINER (frame), 1);
69 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 1);
71 if (gpixmap)
72 gtk_container_add (GTK_CONTAINER(frame), gpixmap);
74 g_snprintf(str, sizeof(str), _("Dia v %s"), VERSION);
75 label = gtk_label_new (str);
76 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 1);
78 gtk_widget_show_all (splash);
80 signal_id = g_signal_connect_after(GTK_OBJECT(splash), "expose_event",
81 GTK_SIGNAL_FUNC(splash_expose), NULL);
83 /* splash_expose gets us out of this */
84 gtk_main();
85 g_signal_handler_disconnect(GTK_OBJECT(splash), signal_id);
88 void
89 app_splash_done (void)
91 if (splash)
93 gtk_widget_destroy (splash);
94 splash = NULL;