gnome-session patch ...



Hi guys,

	Since gnome-session had a few issues, particularly with startup time,
the latency issues of using the Canvas' font stuff for string rendering
- so, I switched the splash rendering to use Gtk+ [ and retain the AA
icon stuff ].

	There are a few changes - more intelligent icon placement, removed the
Gtk+ frame, so grapical splash people don't always have that frame on
top [ needs a nicer frame in the current splash ].

	Oh, and it also doesn't hang with a blank / white screen to start with
- which is an improvement.

	May I commit ?

	Regards,

		Michael.

Index: gnome-session/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/ChangeLog,v
retrieving revision 1.308
diff -u -p -u -r1.308 ChangeLog
--- gnome-session/ChangeLog	8 Jul 2002 20:40:08 -0000	1.308
+++ gnome-session/ChangeLog	15 Jul 2002 20:21:40 -0000
@@ -1,3 +1,15 @@
+2002-07-15  Michael Meeks  <michael ximian com>
+
+	* splash-widget.[ch]: impl.
+
+	* splash.[ch]: kill.
+
+	* manager.c (run_command_prop): upd.
+
+	* main.c (main): upd.
+
+	* Makefile.am: upd.
+
 2002-07-08  jacob berkman  <jacob ximian com>
 
 	* session-properties-capplet.c (main): quit on the SM die signal
Index: gnome-session/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/Makefile.am,v
retrieving revision 1.87
diff -u -p -u -r1.87 Makefile.am
--- gnome-session/Makefile.am	11 Jul 2002 12:28:01 -0000	1.87
+++ gnome-session/Makefile.am	15 Jul 2002 20:21:40 -0000
@@ -49,9 +49,9 @@ bin_PROGRAMS = \
 	gnome-session-properties
 endif
 
-splash_test_SOURCES = \
-	splash.c	\
-	splash.h	\
+splash_test_SOURCES =	\
+	splash-widget.c	\
+	splash-widget.h	\
 	splash-test.c
 
 gnome_session_SOURCES =		\
@@ -71,8 +71,8 @@ gnome_session_SOURCES =		\
 	remote.h		\
 	logout.c		\
 	logout.h		\
-	splash.c		\
-	splash.h		\
+	splash-widget.c		\
+	splash-widget.h		\
 	gsm-gsd.c		\
 	gsm-gsd.h		\
 	gsm-protocol.c		\
Index: gnome-session/main.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/main.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 main.c
--- gnome-session/main.c	11 Jul 2002 10:49:41 -0000	1.46
+++ gnome-session/main.c	15 Jul 2002 20:21:41 -0000
@@ -39,7 +39,7 @@
 #include "ice.h"
 #include "save.h"
 #include "command.h"
-#include "splash.h"
+#include "splash-widget.h"
 #include "util.h"
 #include "gsm-sound.h"
 #include "gsm-gsd.h"
@@ -352,7 +352,7 @@ main (int argc, char *argv[])
   gsm_gsd_start ();
 
   if (splashing)
-    start_splash (49.0);
+    splash_start ();
 
   start_session (the_session);
 
Index: gnome-session/manager.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/manager.c,v
retrieving revision 1.74
diff -u -p -u -r1.74 manager.c
--- gnome-session/manager.c	21 Jun 2002 05:27:10 -0000	1.74
+++ gnome-session/manager.c	15 Jul 2002 20:21:41 -0000
@@ -33,7 +33,7 @@ extern int errno;
 #include "session.h"
 #include "prop.h"
 #include "command.h"
-#include "splash.h"
+#include "splash-widget.h"
 #include "remote.h"
 #include "save.h"
 #include "logout.h"
@@ -365,7 +365,7 @@ run_command_prop (Client     *client, 
       envv = NULL; /* sanity */
       envc = 0;
 
-      update_splash (argv[0], (gfloat)client->priority);
+      splash_update (argv [0]);
 
       restart_info = NULL;
       find_string_property (client, GsmRestartService, &restart_info);
@@ -1170,7 +1170,7 @@ update_save_state (void)
 	    return;
 	}
       save_state = MANAGER_IDLE;
-      stop_splash ();
+      splash_stop ();
      }    
 
   if (save_state == SAVE_PHASE_1)
Index: gnome-session/splash-test.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/splash-test.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 splash-test.c
--- gnome-session/splash-test.c	21 Sep 2001 17:40:20 -0000	1.1
+++ gnome-session/splash-test.c	15 Jul 2002 20:21:41 -0000
@@ -1,11 +1,11 @@
 #include <config.h>
 
-#include <splash.h>
+#include <splash-widget.h>
 
 #include <gtk/gtkmain.h>
 #include <libgnomeui/gnome-ui-init.h>
 
-#define LAST_SPLASH 7
+#define LAST_SPLASH 45
 
 static gboolean
 time_cb (gpointer data)
@@ -17,15 +17,25 @@ time_cb (gpointer data)
 
 	switch (i) {
 	case LAST_SPLASH:
-		stop_splash ();
+		splash_stop ();
 		gtk_main_quit ();
 		return FALSE;
 	case 0:
-		start_splash (LAST_SPLASH);
+		splash_start ();
 		/* FALL THROUGH */
+	case 1:
+		splash_update ("metacity");
+		break;
+	case 2:
+		splash_update ("gnome-wm");
+		break;
+	case 3:
+		splash_update ("gnome-panel");
+		break;
+
 	default:
-		s = g_strdup_printf ("%d", i);
-		update_splash (s, (gfloat)i);
+		s = g_strdup_printf ("Item %d", i);
+		splash_update (s);
 		g_free (s);
 		break;
 	}
@@ -42,7 +52,7 @@ main (int argc, char *argv[])
 			    LIBGNOMEUI_MODULE,
 			    argc, argv, NULL);
 
-	g_timeout_add (1000, time_cb, NULL);
+	g_timeout_add (500, time_cb, NULL);
 
 	gtk_main ();
 
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/gnome-session/po/POTFILES.in,v
retrieving revision 1.110
diff -u -p -u -r1.110 POTFILES.in
--- po/POTFILES.in	1 Jul 2002 19:19:47 -0000	1.110
+++ po/POTFILES.in	15 Jul 2002 20:21:41 -0000
@@ -14,4 +14,5 @@ gnome-session/session-properties-capplet
 gnome-session/session-properties.c
 gnome-session/session-properties.desktop.in
 gnome-session/splash.c
+gnome-session/splash-widget.c
 gnome-session/startup-programs.c
-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot
/* splash-widget.c - splash screen rendering

   Copyright (C) 1999-2002 Jacob Berkman, Ximian Inc.

   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, 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"
#include <stdio.h>
#include <string.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-macros.h>

#include "headers.h"
#include "splash-widget.h"

GNOME_CLASS_BOILERPLATE (SplashWidget,
			 splash_widget,
			 GObject,
			 GTK_TYPE_WINDOW);

typedef struct {
	char *human_name;
	char *exe;
	char *icon;
} SplashApp;

static const SplashApp splash_map_table[] = {
	{ N_("Audio Settings"),               "gnome-sound-properties",         "gnome-audio2.png" },
	{ N_("Screensaver"),                  "xscreensaver-demo",              "gnome-ccscreensaver.png" },
	{ N_("Sawfish Window Manager"),       "sawfish",                        "gnome-ccwindowmanager.png" },
	{ N_("Metacity Window Manager"),      "metacity",                       "gnome-ccwindowmanager.png" },
	{ N_("Window Manager"),               "gnome-wm",                       "gnome-ccwindowmanager.png" },
	{ N_("Background Settings"),          "gnome-background-properties",    "gnome-ccbackground.png" },
	{ N_("Mouse Settings"),               "gnome-mouse-properties",         "gnome-mouse.png" },
	{ N_("Keyboard Settings"),            "gnome-keyboard-properties",      "gnome-cckeyboard.png" },
	{ N_("The Panel"),                    "gnome-panel",                    "gnome-panel.png" },
	{ N_("Session Manager Proxy"),        "gnome-smproxy",                  "gnome-session.png" },
	{ N_("Nautilus"),                     "nautilus",                       "gnome-ccdesktop.png" },
};

static const SplashApp *
get_splash_app (const char *exe)
{
	int i;

	for (i = 0; i < G_N_ELEMENTS (splash_map_table); i++) {
		if (!strcmp (splash_map_table [i].exe, exe))
			return &splash_map_table [i];
	}

	return NULL;
}

typedef struct {
	GdkRectangle position;
	GdkPixbuf   *unscaled;
	GdkPixbuf   *scaled;
} SplashIcon;

static gboolean
re_scale (SplashWidget *sw)
{
	int i;

	static struct {
		int icon_size;
		int icon_spacing;
		int icon_rows;
	} scales[] = {
		{ SPLASH_BASE_ICON_SIZE,
		  SPLASH_ICON_SPACING,
		  SPLASH_BASE_ICON_ROWS },
		{ 24, 3, 1 },
		{ 24, 3, 2 },
		{ 16, 2, 2 },
		{ 16, 2, 3 },
		{ 12, 1, 3 },
		{ 8, 1, 4 },
		{ 4, 1, 5 },
		{ 4, 1, 4 }
	};

	for (i = 0; i < G_N_ELEMENTS (scales); i++) {
		if (scales [i].icon_size < sw->icon_size ||
		    scales [i].icon_rows > sw->icon_rows) {
			sw->icon_size    = scales [i].icon_size;
			sw->icon_spacing = scales [i].icon_spacing;
			sw->icon_rows    = scales [i].icon_rows;
			break;
		}
	}

	if (i == G_N_ELEMENTS (scales)) {
		g_warning ("Too many inits - overflowing");
		return FALSE;
	} else
		return TRUE;
}

static gboolean
splash_widget_expose_event (GtkWidget      *widget,
			    GdkEventExpose *event)
{
	GList *l;
	SplashWidget *sw = SPLASH_WIDGET (widget);

	if (!GTK_WIDGET_DRAWABLE (widget))
		return FALSE;

	for (l = sw->icons; l; l = l->next) {
		SplashIcon *si = l->data;
		GdkRectangle exposed;

		if (gdk_rectangle_intersect (&event->area,
					     &si->position,
					     &exposed))
			gdk_pixbuf_render_to_drawable (
				si->scaled, widget->window,
				widget->style->black_gc,
				si->position.x - exposed.x,
				si->position.y - exposed.y,
				exposed.x, exposed.y,
				exposed.width, exposed.height,
				GDK_RGB_DITHER_NORMAL,
				exposed.x, exposed.y);
	}

	if (sw->layout) {
		GdkRectangle text, exposed;
		PangoRectangle pixel_rect;

		pango_layout_get_pixel_extents (sw->layout, NULL, &pixel_rect);

		text.x = (sw->text_box.x + sw->text_box.width / 2 - pixel_rect.width / 2);
		text.y = sw->text_box.y;
		text.width = pixel_rect.width;
		text.height = pixel_rect.height;

		if (gdk_rectangle_intersect (&event->area, &text, &exposed)) {
			/* drop shadow */
			gdk_draw_layout (widget->window,
					 widget->style->black_gc,
					 text.x + 1, text.y + 1, sw->layout);
			
			/* text */
			gdk_draw_layout (widget->window,
					 widget->style->white_gc,
					 text.x, text.y, sw->layout);
		}
	}

	return FALSE;
}

static gboolean
splash_widget_button_release_event (GtkWidget      *widget,
				    GdkEventButton *event)
{
	gtk_widget_hide (widget);
	return TRUE;
}

static void
splash_widget_size_allocate (GtkWidget     *widget,
			     GtkAllocation *allocation)
{
	gint xfpad, yfpad;
	SplashWidget *sw = SPLASH_WIDGET (widget);

	xfpad = widget->style->xthickness;
	yfpad = widget->style->ythickness;

	sw->image_bounds = *allocation;

	sw->text_box.x = allocation->x;
	sw->text_box.y = (allocation->y + allocation->height -
			  SPLASH_LABEL_V_OFFSET - SPLASH_LABEL_V_HEIGHT);
	sw->text_box.width = allocation->width;
	sw->text_box.height = allocation->height - sw->text_box.y;

	GNOME_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
}

static void
splash_widget_size_request (GtkWidget      *widget,
			    GtkRequisition *requisition)
{
	SplashWidget *sw = (SplashWidget *) widget;

	if (!sw->background) {
		requisition->width = SPLASH_BASE_WIDTH;
		requisition->height = SPLASH_BASE_HEIGHT;
	} else {
		/* FIXME: need more padding */
		requisition->width  = gdk_pixbuf_get_width  (sw->background);
		requisition->height = gdk_pixbuf_get_height (sw->background);

		requisition->width  += widget->style->xthickness * 2;
		requisition->height += widget->style->ythickness * 2;
	}
}

static void
splash_widget_realize (GtkWidget *widget)
{
	GdkPixmap *pm;
	SplashWidget *sw = (SplashWidget *) widget;

	GNOME_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget));

	if (sw->background && widget->window) {
		int width, height;

		width = gdk_pixbuf_get_width  (sw->background);
		height = gdk_pixbuf_get_height (sw->background);

		pm = gdk_pixmap_new (
			widget->window,
			width, height,
			gdk_drawable_get_visual (widget->window)->depth);

		if (pm) {
			gdk_pixbuf_render_to_drawable (
				sw->background, GDK_DRAWABLE (pm),
				widget->style->black_gc,
				0, 0, 0, 0, width, height,
				GDK_RGB_DITHER_NORMAL,
				0, 0);
			
			gdk_window_set_back_pixmap (
				widget->window, pm, FALSE);
			g_object_unref (pm);
		}
	}
}

static void
splash_widget_unrealize (GtkWidget *widget)
{
/*	SplashWidget *sw = (SplashWidget *) widget; */
	GNOME_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget));
}

static void
splash_icon_destroy (SplashIcon *si)
{
	g_object_unref (si->unscaled);
	if (si->scaled)
		g_object_unref (si->scaled);

	g_free (si);
}

static void
splash_widget_finalize (GObject *object)
{
	SplashWidget *sw = (SplashWidget *) object;

	g_list_foreach (sw->icons, (GFunc) splash_icon_destroy, NULL);
	g_list_free (sw->icons);

	g_object_unref (sw->layout);

	GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}

static void
splash_widget_class_init (SplashWidgetClass *klass)
{
	GObjectClass *gobject_class = (GObjectClass *) klass;
	GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;

	gobject_class->finalize = splash_widget_finalize;

	widget_class->realize = splash_widget_realize;
	widget_class->unrealize = splash_widget_unrealize;
	widget_class->expose_event = splash_widget_expose_event;
	widget_class->size_request = splash_widget_size_request;
	widget_class->size_allocate = splash_widget_size_allocate;
	widget_class->button_release_event = splash_widget_button_release_event;
}

static void
read_background (SplashWidget *sw)
{
	char *filename;
	GdkPixbuf *pb;
	int maj, minor, pl;

	/* Find a splash screen by looking at "gnome-splash-major.minor.pl.png",
	   "gnome-splash-major.minor.png" and "gnome-splash.png" */
	if (sscanf (VERSION, "%d.%d.%d", &maj, &minor, &pl) != 3) {
		pl = 0;
		if (sscanf (VERSION, "%d.%d", &maj, &minor) != 2) {
			maj = minor = pl = 0; /* sort of illegal version */
		}
	}
	
	filename = g_strdup_printf (
		"%s/splash/gnome-splash-%d.%d.%d.png",
		GNOME_ICONDIR, maj, minor, pl);

	pb = gdk_pixbuf_new_from_file (filename, NULL);
	g_free (filename);
	if (!pb) {
		filename = g_strdup_printf (
			"%s/splash/gnome-splash-%d.%d.png",
			GNOME_ICONDIR, maj, minor);

		pb = gdk_pixbuf_new_from_file (filename, NULL);
		g_free (filename);
	}
	
	if (!pb)
		pb = gdk_pixbuf_new_from_file (
			GNOME_ICONDIR "/splash/gnome-splash.png", NULL);

	sw->background = pb;

	fprintf (stderr, "Loaded background '%p\n", pb);
}

static void
splash_widget_instance_init (SplashWidget *sw)
{
	GtkWindow *window;
	PangoAttrList *attrs;

	window = &sw->window;

	/* window->type clobbered by default properties on GtkWindow */
	gtk_window_set_position (window, GTK_WIN_POS_CENTER);
	g_object_set (window, "allow_shrink", FALSE,
		      "allow_grow", FALSE, NULL);

	sw->icon_size = SPLASH_BASE_ICON_SIZE;
	sw->icon_spacing = SPLASH_ICON_SPACING;
	sw->cur_y_row = SPLASH_BASE_ICON_ROWS;

	gtk_widget_add_events (GTK_WIDGET (window),
			       GDK_BUTTON_RELEASE_MASK);

	sw->layout = gtk_widget_create_pango_layout (GTK_WIDGET (sw), "");
	pango_layout_set_alignment (sw->layout, PANGO_ALIGN_CENTER);

	attrs = pango_attr_list_new ();
	pango_attr_list_insert (attrs,
				pango_attr_size_new (SPLASH_LABEL_FONT_SIZE));
	pango_layout_set_attributes (sw->layout, attrs);
	pango_attr_list_unref (attrs);

	read_background (sw);
}

static GdkPixbuf *
get_splash_icon (SplashWidget *sw, const char *icon_name)
{
	char *fname;
	GdkPixbuf *pb;

	fname = g_build_filename (GNOME_ICONDIR, icon_name, NULL);

	if (g_file_test (fname, G_FILE_TEST_EXISTS))
		pb = gdk_pixbuf_new_from_file (fname, NULL);
	else
		pb = NULL;

	g_free (fname);

	return pb;
}

static void re_laydown (SplashWidget *sw);

static void
layout_icon (SplashWidget *sw, SplashIcon *si, GdkRectangle *area)
{
	g_return_if_fail (si != NULL);

	si->position.x = sw->image_bounds.x + sw->cur_x_offset + SPLASH_ICON_BORDER;
	si->position.y = (sw->image_bounds.y + sw->image_bounds.height -
			  SPLASH_ICON_V_OFFSET -
			  (sw->icon_size + sw->icon_spacing) * sw->cur_y_row);
	si->position.width = si->position.height = sw->icon_size;

	sw->cur_x_offset += sw->icon_size + sw->icon_spacing;

	if (area)
		*area = si->position;

	if (!si->scaled)
		si->scaled = gdk_pixbuf_scale_simple (
			si->unscaled, sw->icon_size,
			sw->icon_size, GDK_INTERP_BILINEAR);

	if (sw->cur_x_offset >= (sw->image_bounds.width - SPLASH_ICON_BORDER * 2 -
				 sw->icon_size)) {
		if (--sw->cur_y_row > 0)
			sw->cur_x_offset = 0;

		else {
			if (re_scale (sw)) {
				re_laydown (sw);
				gtk_widget_queue_draw (GTK_WIDGET (sw));
			}
		}
	}
}

static void
re_laydown (SplashWidget *sw)
{
	GList *l;

	sw->cur_x_offset = 0;
	sw->cur_y_row = sw->icon_rows;

	for (l = sw->icons; l; l = l->next) {
		SplashIcon *si = l->data;

		if (si->scaled) {
			g_object_unref (si->scaled);
			si->scaled = NULL;
		}
		layout_icon (sw, l->data, NULL);
	}
}
 
void
splash_widget_add_icon (SplashWidget *sw,
			const char   *executable_name)
{
	char *text;
	char *basename;
	GdkPixbuf *pb;
	const SplashApp *app;

	g_return_if_fail (SPLASH_IS_WIDGET (sw));

	if (!executable_name || executable_name [0] == '\0')
		return;

	basename = g_path_get_basename (executable_name);

	pb = NULL;
	text = NULL;
	app = get_splash_app (basename);

	if (app) {
		pb = get_splash_icon (sw, app->icon);
		text = _(app->human_name);
	}

	/* FIXME: we should allow arbitrary apps to install
	   stuff here, by mangling the app name to a pixmap
	   name */

	if (!pb)
		pb = get_splash_icon (sw, "gnome-unknown.png");

	if (!text)
		text = basename;

	pango_layout_set_text (sw->layout, text, -1);

	if (pb) {
		SplashIcon *si;
		GdkRectangle area;

		si = g_new0 (SplashIcon, 1);
		si->unscaled = pb;

		sw->icons = g_list_append (sw->icons, si);

		layout_icon (sw, si, &area);
		
		gtk_widget_queue_draw_area (
			GTK_WIDGET (sw),
			area.x, area.y,
			area.width, area.height);
	}

	gtk_widget_queue_draw_area (
		GTK_WIDGET (sw),
		sw->text_box.x, sw->text_box.y,
		sw->text_box.width, sw->text_box.height);
}

static SplashWidget *global_splash = NULL;

void
splash_start (void)
{
	if (global_splash)
		return;

	global_splash = g_object_new (SPLASH_TYPE_WIDGET,
				      "type", GTK_WINDOW_POPUP, NULL);
	gtk_widget_show_now (GTK_WIDGET (global_splash));
}

void
splash_update (const gchar *text)
{
	if (!global_splash || !text || !text[0])
		return;

	if (!strcmp (text, "rm"))
		return;

	if (!strcmp (text, "done")) {
		splash_stop ();
		return;
	}

	splash_widget_add_icon (global_splash, text);
}

void
splash_stop (void)
{
	if (global_splash) {
		gtk_widget_destroy (GTK_WIDGET (global_splash));
		g_object_unref (global_splash);
		global_splash = NULL;
	}
}

/* splash-widget.h - splash screen rendering

   Copyright (C) 1999-2002 Jacob Berkman, Ximian Inc.

   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, 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.  
*/
#ifndef SPLASH_WIDGET_H
#define SPLASH_WIDGET_H

#include <gtk/gtkwindow.h>

#define SPLASH_TYPE_WIDGET                  (splash_widget_get_type ())
#define SPLASH_WIDGET(obj)                  (GTK_CHECK_CAST ((obj), SPLASH_TYPE_WIDGET, SplashWidget))
#define SPLASH_WIDGET_CLASS(klass)          (GTK_CHECK_CLASS_CAST ((klass), SPLASH_TYPE_WIDGET, SplashWidgetClass))
#define SPLASH_IS_WIDGET(obj)               (GTK_CHECK_TYPE ((obj), SPLASH_TYPE_WIDGET))
#define SPLASH_IS_WIDGET_CLASS(klass)       (GTK_CHECK_CLASS_TYPE ((klass), SPLASH_TYPE_WIDGET))
#define SPLASH_WIDGET_GET_CLASS(obj)        (GTK_CHECK_GET_CLASS ((obj), SPLASH_TYPE_WIDGET, SplashWidgetClass))

typedef struct  {
	GtkWindow    window;

	GdkPixbuf   *background;
	GList       *icons;
	PangoLayout *layout;

	/* current placement offsets */
	int          cur_x_offset;
	int          cur_y_row;

	/* Layout Measurements */
	int           icon_size;
	int           icon_spacing;
	int           icon_rows;
	GdkRectangle  image_bounds;
	GdkRectangle  text_box;
} SplashWidget;

typedef struct {
	GtkWindowClass parent_class;
} SplashWidgetClass;

GType splash_widget_get_type (void);
void  splash_widget_add_icon (SplashWidget *sw,
			      const char   *executable_name);

/* width / height if we have no image */
#define SPLASH_BASE_WIDTH 480
#define SPLASH_BASE_HEIGHT 220

/* offset from bottom of label & font */
#define SPLASH_LABEL_V_OFFSET 12
#define SPLASH_LABEL_V_HEIGHT 8
#define SPLASH_LABEL_FONT_SIZE 8

/* icon border, spacing, offset from bottom and initial size */
#define SPLASH_ICON_BORDER  8
#define SPLASH_ICON_SPACING 4
#define SPLASH_ICON_V_OFFSET 18
#define SPLASH_BASE_ICON_SIZE 36
#define SPLASH_BASE_ICON_ROWS 1

/* The global API */
void splash_start  (void);
void splash_update (const gchar *text);
void splash_stop   (void);

#endif /* SPLASH_WIDGET_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]