splash.c 1.85 KB
Newer Older
Lars Clausen's avatar
Lars Clausen committed
1
#include <config.h>
2 3 4 5 6 7 8

#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#include "intl.h"
#include "dia_dirs.h"
#include "app_procs.h"
9
#include "widgets.h"
10 11 12

static GtkWidget* splash = NULL;

13 14 15 16 17 18 19
static void
splash_expose (GtkWidget *widget, GdkEventExpose *event)
{
  /* this gets called after the splash screen gets exposed ... */
  gtk_main_quit();
}

20 21 22 23 24 25 26 27
void
app_splash_init (const gchar* fname)
{
  GtkWidget *vbox;
  GtkWidget* gpixmap;
  GtkWidget *label;
  GtkWidget *frame;
  gchar str[256];
Lars Clausen's avatar
Lars Clausen committed
28
  gulong signal_id;
29

30
  splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);
31
  gtk_window_set_role (GTK_WINDOW (splash), "start_dialog");
32
  gtk_window_set_title (GTK_WINDOW (splash), _("Loading \342\200\246"));
33
  gtk_window_set_resizable (GTK_WINDOW (splash), FALSE);
34 35 36 37 38 39
  gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);

  vbox = gtk_vbox_new (FALSE, 2);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  gtk_container_add (GTK_CONTAINER(splash), vbox);

40
  gpixmap = gtk_image_new_from_pixbuf (pixbuf_from_resource ("/org/gnome/Dia/dia-splash.png"));
41 42 43 44 45 46

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_container_set_border_width (GTK_CONTAINER (frame), 1);
  gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 1);

47
  gtk_container_add (GTK_CONTAINER(frame), gpixmap);
48

49
  g_snprintf(str, sizeof(str), _("Dia v %s"), VERSION);
50 51 52 53 54
  label = gtk_label_new (str);
  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 1);

  gtk_widget_show_all (splash);

Zander's avatar
Zander committed
55 56
  signal_id = g_signal_connect_after (G_OBJECT (splash), "expose-event",
                                      G_CALLBACK (splash_expose), NULL);
57 58 59

  /* splash_expose gets us out of this */
  gtk_main();
Hans Breuer's avatar
Hans Breuer committed
60
  g_signal_handler_disconnect(G_OBJECT(splash), signal_id);
61 62 63 64 65 66 67 68 69 70 71
}

void
app_splash_done (void)
{
  if (splash)
  {
    gtk_widget_destroy (splash);
    splash = NULL;
  }
}