2001-04-16 04:12:16 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-07-08 18:38:13 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
#include <gtk/gtk.h>
|
2003-11-08 01:29:02 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include "gui-types.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
#include "splash.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
static GtkWidget *splash = NULL;
|
|
|
|
static PangoLayout *upper = NULL;
|
|
|
|
static PangoLayout *lower = NULL;
|
|
|
|
static GtkWidget *progress = NULL;
|
|
|
|
static gint width = 0;
|
|
|
|
static gint height = 0;
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
static void splash_map (void);
|
|
|
|
static gboolean splash_area_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GdkPixmap *pixmap);
|
2003-03-14 02:47:28 +08:00
|
|
|
|
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2004-03-15 08:17:21 +08:00
|
|
|
splash_create (void)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2003-03-18 21:49:02 +08:00
|
|
|
GtkWidget *frame;
|
2001-11-25 04:31:15 +08:00
|
|
|
GtkWidget *vbox;
|
2004-03-15 08:17:21 +08:00
|
|
|
GtkWidget *area;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
filename = g_build_filename (gimp_data_directory (),
|
|
|
|
"images", "gimp_splash.png", NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
if (! pixbuf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 04:05:33 +08:00
|
|
|
splash = g_object_new (GTK_TYPE_WINDOW,
|
|
|
|
"type", GTK_WINDOW_TOPLEVEL,
|
|
|
|
"type_hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
|
|
|
|
"title", _("GIMP Startup"),
|
2004-03-15 08:17:21 +08:00
|
|
|
"window_position", GTK_WIN_POS_CENTER,
|
2004-03-15 04:05:33 +08:00
|
|
|
"resizable", FALSE,
|
|
|
|
NULL);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 04:05:33 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (splash), "gimp-startup");
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 04:05:33 +08:00
|
|
|
g_signal_connect_swapped (splash, "delete_event",
|
|
|
|
G_CALLBACK (exit),
|
|
|
|
GINT_TO_POINTER (0));
|
2002-05-16 22:13:20 +08:00
|
|
|
|
2003-03-14 02:47:28 +08:00
|
|
|
/* we don't want the splash screen to send the startup notification */
|
|
|
|
gtk_window_set_auto_startup_notification (FALSE);
|
2004-03-15 04:05:33 +08:00
|
|
|
g_signal_connect (splash, "map",
|
2003-03-14 02:47:28 +08:00
|
|
|
G_CALLBACK (splash_map),
|
|
|
|
NULL);
|
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
2004-03-15 04:05:33 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (splash), frame);
|
2003-03-18 21:49:02 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
2003-03-18 21:49:02 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
2001-11-23 07:46:13 +08:00
|
|
|
gtk_widget_show (vbox);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
area = gtk_drawing_area_new ();
|
|
|
|
gtk_box_pack_start_defaults (GTK_BOX (vbox), area);
|
|
|
|
gtk_widget_show (area);
|
2003-11-08 01:29:02 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
gtk_widget_set_size_request (area, width, height);
|
2001-11-23 07:46:13 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
gtk_widget_realize (area);
|
|
|
|
pixmap = gdk_pixmap_new (area->window, width, height, -1);
|
2002-05-15 23:55:10 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
gdk_draw_pixbuf (pixmap, area->style->black_gc,
|
|
|
|
pixbuf, 0, 0, 0, 0, width, height,
|
|
|
|
GDK_RGB_DITHER_NORMAL, 0, 0);
|
|
|
|
g_object_unref (pixbuf);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
g_signal_connect (area, "expose_event",
|
|
|
|
G_CALLBACK (splash_area_expose),
|
|
|
|
pixmap);
|
|
|
|
g_signal_connect_swapped (area, "destroy",
|
|
|
|
G_CALLBACK (g_object_unref),
|
|
|
|
pixmap);
|
2001-11-23 07:46:13 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
upper = gtk_widget_create_pango_layout (splash, "");
|
|
|
|
lower = gtk_widget_create_pango_layout (splash, "");
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2001-09-03 21:13:48 +08:00
|
|
|
progress = gtk_progress_bar_new ();
|
2004-03-15 08:17:21 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), progress, FALSE, FALSE, 0);
|
2001-09-03 21:13:48 +08:00
|
|
|
gtk_widget_show (progress);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2004-03-15 04:05:33 +08:00
|
|
|
gtk_widget_show (splash);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
splash_destroy (void)
|
|
|
|
{
|
2004-03-15 04:05:33 +08:00
|
|
|
if (splash)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2004-03-15 04:05:33 +08:00
|
|
|
gtk_widget_destroy (splash);
|
|
|
|
splash = NULL;
|
2004-03-15 08:17:21 +08:00
|
|
|
|
|
|
|
g_object_unref (upper);
|
|
|
|
upper = NULL;
|
|
|
|
|
|
|
|
g_object_unref (lower);
|
|
|
|
lower = NULL;
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
splash_update (const gchar *text1,
|
|
|
|
const gchar *text2,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
2004-03-15 04:05:33 +08:00
|
|
|
if (! splash)
|
2001-11-25 04:31:15 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (text1)
|
2004-03-15 08:17:21 +08:00
|
|
|
pango_layout_set_text (upper, text1, -1);
|
2001-11-25 04:31:15 +08:00
|
|
|
|
|
|
|
if (text2)
|
2004-03-15 08:17:21 +08:00
|
|
|
pango_layout_set_text (lower, text2, -2);
|
2003-11-08 01:29:02 +08:00
|
|
|
|
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
|
2001-12-29 21:26:29 +08:00
|
|
|
CLAMP (percentage, 0.0, 1.0));
|
2003-11-08 01:29:02 +08:00
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
/* FIXME: It would be more effective to expose the text area only. */
|
|
|
|
gtk_widget_queue_draw (splash);
|
|
|
|
|
2001-11-25 04:31:15 +08:00
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
2003-03-14 02:47:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2004-03-15 08:17:21 +08:00
|
|
|
static gboolean
|
|
|
|
splash_area_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GdkPixmap *pixmap)
|
|
|
|
{
|
|
|
|
GdkRectangle rect;
|
|
|
|
GdkRectangle draw;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
rect.x = (widget->allocation.width - width) / 2;
|
|
|
|
rect.y = (widget->allocation.height - height) / 2;
|
|
|
|
rect.width = width;
|
|
|
|
rect.height = height;
|
|
|
|
|
|
|
|
if (gdk_rectangle_intersect (&rect, &event->area, &draw))
|
|
|
|
{
|
|
|
|
gdk_draw_drawable (widget->window,
|
|
|
|
widget->style->black_gc,
|
|
|
|
pixmap,
|
|
|
|
draw.x - rect.x, draw.y - rect.y,
|
|
|
|
draw.x, draw.y, draw.width, draw.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
pango_layout_get_pixel_size (upper, &x, &y);
|
|
|
|
|
|
|
|
x = (widget->allocation.width - x) / 2;
|
|
|
|
y = widget->allocation.height - 2 * y - 16;
|
|
|
|
gdk_draw_layout (widget->window, widget->style->black_gc, x, y, upper);
|
|
|
|
|
|
|
|
pango_layout_get_pixel_size (lower, &x, &y);
|
|
|
|
|
|
|
|
x = (widget->allocation.width - x) / 2;
|
|
|
|
y = widget->allocation.height - y - 8;
|
|
|
|
gdk_draw_layout (widget->window, widget->style->black_gc, x, y, lower);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-03-14 02:47:28 +08:00
|
|
|
static void
|
|
|
|
splash_map (void)
|
|
|
|
{
|
|
|
|
/* Reenable startup notification after the splash has been shown
|
2003-11-08 01:29:02 +08:00
|
|
|
* so that the next window that is mapped sends the notification.
|
2003-03-14 02:47:28 +08:00
|
|
|
*/
|
|
|
|
gtk_window_set_auto_startup_notification (TRUE);
|
|
|
|
}
|