Re: gnome-session patch ...
- From: Michael Meeks <michael ximian com>
- To: Mark McLoughlin <mark skynet ie>
- Cc: desktop-devel-list gnome org, Jacob Berkman <jacob ximian com>
- Subject: Re: gnome-session patch ...
- Date: 17 Jul 2002 16:12:24 +0100
Hi Mark,
Jacob's dealing with it now, it blocked for a while on a Gtk+ problem,
now fixed.
On Wed, 2002-07-17 at 04:43, Mark McLoughlin wrote:
> 1) You should use GnomeIconLoader to locate the icons so they
> can be themed.
Currently gnome-session doesn't depend on gnome-desktop, so I'll leave
it doing what it did at least for now.
> 2 You seem to scale the icon unconditionally (or am I missing
> something) - should you not check to see if the pixbuf is
> already the desired size first ?
Ok - fixed that.
> 3) The unref after destroying the splash is bogus right ?
Yes, gone.
> 4) As someone else mentioned this remvoes our dependacy on
> the canvas - could oyu updated configure.in accordingly ?
done.
> 5) The ChangeLog entry could give just a little more info on
> what the change actually accomplishes ... :-)
Beefed that up a bit.
> 6) The button release handler doesn't work because you haven't
> selected button release events.
Works for me - the GtkWindow I sub-class listens for release events.
Committing the attached,
HTH,
Michael.
--
mmeeks gnu org <><, Pseudo Engineer, itinerant idiot
? gnome-core.spec
? jacob
? gnome-session/save-session
? gnome-session/session-properties
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-session/ChangeLog,v
retrieving revision 1.439
diff -u -p -u -r1.439 ChangeLog
--- ChangeLog 11 Jul 2002 10:49:39 -0000 1.439
+++ ChangeLog 17 Jul 2002 15:09:39 -0000
@@ -1,3 +1,7 @@
+2002-07-16 Michael Meeks <michael ximian com>
+
+ * configure.in: remove canvas check.
+
2002-07-11 Brian Cameron <Brian Cameron sun com>
* gnome-session/configure.in
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-session/configure.in,v
retrieving revision 1.397
diff -u -p -u -r1.397 configure.in
--- configure.in 11 Jul 2002 10:49:40 -0000 1.397
+++ configure.in 17 Jul 2002 15:09:39 -0000
@@ -20,11 +20,9 @@ dnl If you add a version number here, yo
dnl it too, or it will never make it into the spec file!
ESOUND_REQUIRED=0.2.26
-LIBGNOMECANVAS_REQUIRED=1.1
LIBGNOMEUI_REQUIRED=1.1
AC_SUBST(ESOUND_REQUIRED)
-AC_SUBST(LIBGNOMECANVAS_REQUIRED)
AC_SUBST(LIBGNOMEUI_REQUIRED)
dnl pkg-config dependency checks
@@ -39,7 +37,7 @@ PKG_CHECK_MODULES(SOUND_TEST, $ESOUND_MO
ESOUND_MODULE=""
])
-PKG_CHECK_MODULES(GNOME_SESSION, libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $ESOUND_MODULE)
+PKG_CHECK_MODULES(GNOME_SESSION, libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $ESOUND_MODULE)
AC_SUBST(GNOME_SESSION_CFLAGS)
AC_SUBST(GNOME_SESSION_LIBS)
Index: gnome-session/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/ChangeLog,v
retrieving revision 1.314
diff -u -p -u -r1.314 ChangeLog
--- gnome-session/ChangeLog 15 Jul 2002 18:10:45 -0000 1.314
+++ gnome-session/ChangeLog 17 Jul 2002 15:09:39 -0000
@@ -1,3 +1,25 @@
+2002-07-17 Michael Meeks <michael ximian com>
+
+ * main.c (gnome_login_check): only destroy the
+ widget if we created it.
+
+ * splash-widget.c (layout_icon): only scale if
+ necessary.
+
+2002-07-15 Michael Meeks <michael ximian com>
+
+ * splash-widget.[ch]: re-write the splash widget
+ completely, to use pure Gtk+ instead of the canvas,
+ to improve performance by avoiding the Pango stuff.
+
+ * splash.[ch]: kill.
+
+ * manager.c (run_command_prop): upd.
+
+ * main.c (main): upd.
+
+ * Makefile.am: upd.
+
2002-07-15 jacob berkman <jacob ximian com>
* logout.c (display_gui): don't reference a destroyed widget
Index: gnome-session/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/Makefile.am,v
retrieving revision 1.88
diff -u -p -u -r1.88 Makefile.am
--- gnome-session/Makefile.am 12 Jul 2002 09:02:06 -0000 1.88
+++ gnome-session/Makefile.am 17 Jul 2002 15:09:39 -0000
@@ -50,9 +50,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 = \
@@ -72,8 +72,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.47
diff -u -p -u -r1.47 main.c
--- gnome-session/main.c 15 Jul 2002 14:25:09 -0000 1.47
+++ gnome-session/main.c 17 Jul 2002 15:09:40 -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"
@@ -229,7 +229,8 @@ gnome_login_check (void)
break;
}
- gtk_widget_destroy (tmp_msgbox);
+ if (tmp_msgbox)
+ gtk_widget_destroy (tmp_msgbox);
}
int
@@ -356,7 +357,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.75
diff -u -p -u -r1.75 manager.c
--- gnome-session/manager.c 12 Jul 2002 15:02:39 -0000 1.75
+++ gnome-session/manager.c 17 Jul 2002 15:09:40 -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 17 Jul 2002 15:09:40 -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: gnome-session/splash-widget.c
===================================================================
RCS file: gnome-session/splash-widget.c
diff -N gnome-session/splash-widget.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnome-session/splash-widget.c 17 Jul 2002 15:09:40 -0000
@@ -0,0 +1,561 @@
+/* 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;
+ GdkRectangle exposed;
+ SplashWidget *sw = SPLASH_WIDGET (widget);
+
+ if (!GTK_WIDGET_DRAWABLE (widget))
+ return FALSE;
+
+ if (gdk_rectangle_intersect (
+ &event->area, &sw->image_bounds, &exposed))
+ gdk_draw_drawable (
+ GDK_DRAWABLE (widget->window),
+ widget->style->black_gc,
+ GDK_DRAWABLE (sw->bg_pixmap),
+ exposed.x, exposed.y,
+ exposed.x, exposed.y,
+ exposed.width, exposed.height);
+
+ for (l = sw->icons; l; l = l->next) {
+ SplashIcon *si = l->data;
+
+ 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;
+ 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);
+ sw->bg_pixmap = pm;
+ }
+ }
+}
+
+static void
+splash_widget_unrealize (GtkWidget *widget)
+{
+ SplashWidget *sw = (SplashWidget *) widget;
+
+ if (sw->bg_pixmap) {
+ g_object_unref (sw->bg_pixmap);
+ sw->bg_pixmap = NULL;
+ }
+
+ 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) {
+ if (gdk_pixbuf_get_width (si->unscaled) == sw->icon_size &&
+ gdk_pixbuf_get_height (si->unscaled) == sw->icon_size)
+ si->scaled = g_object_ref (si->unscaled);
+ else
+ 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));
+ global_splash = NULL;
+ }
+}
+
Index: gnome-session/splash-widget.h
===================================================================
RCS file: gnome-session/splash-widget.h
diff -N gnome-session/splash-widget.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnome-session/splash-widget.h 17 Jul 2002 15:09:40 -0000
@@ -0,0 +1,81 @@
+/* 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;
+ GdkPixmap *bg_pixmap;
+ 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 */
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 17 Jul 2002 15:09:40 -0000
@@ -13,5 +13,5 @@ gnome-session/session-names.c
gnome-session/session-properties-capplet.c
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]