Index: src/gfx.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnect/src/gfx.c,v
retrieving revision 1.10
diff -u -p -r1.10 gfx.c
--- src/gfx.c	11 Jul 2004 07:55:27 -0000	1.10
+++ src/gfx.c	10 Sep 2004 12:29:53 -0000
@@ -38,20 +38,39 @@ extern gint       gboard[7][7];
 extern GtkWidget *app;
 extern GtkWidget *drawarea;
 
-static gint       width, height;
-static gint       tilew, tileh;
+static gint       boardsize = 0;
+static gint       tilesize = 0;
 static gint       offset[6];
+
+/* unscaled pixbufs */
+static GdkPixbuf *pb_tileset_raw = NULL;
+static GdkPixbuf *pb_bground_raw = NULL;
+
+/* scaled pixbufs */
 static GdkPixbuf *pb_tileset = NULL;
 static GdkPixbuf *pb_bground = NULL;
-static GdkPixmap *pm_display = NULL;
+
+/* background pixmap, we draw the grid on it */
 static GdkPixmap *pm_bground = NULL;
-GdkGC     *gc = NULL;
+
+/* the buffer we draw in */
+static GdkPixmap *pm_display = NULL;
+
+static GdkGC *gc = NULL;
 
 
 
 void
 gfx_free (void)
 {
+	if (pb_tileset_raw != NULL) {
+		g_object_unref (pb_tileset_raw);
+		pb_tileset = NULL;
+	}
+	if (pb_bground_raw != NULL) {
+		g_object_unref (pb_bground_raw);
+		pb_bground = NULL;
+	}
 	if (pb_tileset != NULL) {
 		g_object_unref (pb_tileset);
 		pb_tileset = NULL;
@@ -76,8 +95,12 @@ gint
 gfx_get_column (gint xpos)
 {
 	/* Derive column from pixel position */
-	gint c = xpos / tilew;
-	if (c > 6) c = 6;
+	gint c = xpos / tilesize;
+	if (c > 6)
+		c = 6;
+	if (c < 0)
+		c = 0;
+
 	return c;
 }
 
@@ -86,40 +109,48 @@ gfx_get_column (gint xpos)
 void
 gfx_draw_tile (gint r, gint c, gboolean refresh)
 {
-	gint x = c * tilew;
-	gint y = r * tileh;
+	gint x = c * tilesize;
+	gint y = r * tilesize;
 	gint tile = gboard[r][c];
 	gint os = 0;
 
+	g_return_if_fail (gc != NULL);
+
 	switch (tile) {
 	case TILE_PLAYER1:
-		os = offset[TILE_PLAYER1];
-		if (y == 0) os = offset[TILE_PLAYER1_CURSOR];
+		if (r == 0)
+			os = offset[TILE_PLAYER1_CURSOR];
+		else
+			os = offset[TILE_PLAYER1];
 		break;
 	case TILE_PLAYER2:
-		os = offset[TILE_PLAYER2];
-		if (y == 0) os = offset[TILE_PLAYER2_CURSOR];
+		if (r == 0)
+			os = offset[TILE_PLAYER2_CURSOR];
+		else
+			os = offset[TILE_PLAYER2];
 		break;
 	default:
 		break;
 	}
 
-	gdk_draw_drawable (pm_display, gc, pm_bground, x, y, x, y, tilew, tileh);
+	gdk_draw_drawable (pm_display, gc, pm_bground, x, y, x, y, tilesize, tilesize);
 
 	if (tile != TILE_CLEAR) {
 		gdk_pixbuf_render_to_drawable_alpha (pb_tileset, pm_display,
-		  os, 0, x, y, tilew, tileh, GDK_PIXBUF_ALPHA_BILEVEL, 128,
-		  GDK_RGB_DITHER_NORMAL, 0, 0);
+						     os, 0, x, y, tilesize, tilesize,
+						     GDK_PIXBUF_ALPHA_BILEVEL, 128,
+						     GDK_RGB_DITHER_NORMAL, 0, 0);
 	}
 
 	if (refresh) {
-		gtk_widget_queue_draw_area (drawarea, x, y, tilew, tileh);
+		gtk_widget_queue_draw_area (drawarea, x, y, tilesize, tilesize);
 	}
 }
 
 
+
 void
-gfx_draw_all (gboolean refresh)
+gfx_draw_all (void)
 {
 	gint r, c;
 
@@ -129,52 +160,92 @@ gfx_draw_all (gboolean refresh)
 		}
 	}
 
-	if (refresh) {
-		gtk_widget_queue_draw_area (drawarea, 0, 0, width, height);
-	}
+	gtk_widget_queue_draw_area (drawarea, 0, 0, boardsize, boardsize);
 }
 
 
 
-void
-gfx_expose (GdkRectangle *area)
+static void
+gfx_refresh_pixmaps (void)
 {
-	gdk_draw_drawable (drawarea->window, gc, pm_display,
-	                   area->x, area->y, area->x, area->y,
-	                   area->width, area->height);
+	gint i;
+
+	g_return_if_fail (gc != NULL);
+
+	/* scale the pixbufs */
+	if (pb_tileset)
+		g_object_unref (pb_tileset);
+	if (pb_bground)
+		g_object_unref (pb_bground);
+
+	pb_tileset = gdk_pixbuf_scale_simple (pb_tileset_raw,
+	                                      tilesize * 6, tilesize,
+					      GDK_INTERP_BILINEAR);
+	pb_bground = gdk_pixbuf_scale_simple (pb_bground_raw,
+	                                      boardsize, boardsize,
+	                                      GDK_INTERP_BILINEAR);
+
+	/* draw the background */
+	gdk_draw_pixbuf (pm_bground, gc, pb_bground,
+			 0, 0, 0, 0, -1, -1,
+			 GDK_RGB_DITHER_NORMAL, 0, 0);
+
+	/* draw the grid on the background pixmap */
+	for (i = 1; i < 7; i++) {
+		gdk_draw_line (pm_bground, gc, i * tilesize, 0, i* tilesize, boardsize);
+		gdk_draw_line (pm_bground, gc, 0, i * tilesize, boardsize, i * tilesize);
+	}
 }
 
 
 
 void
-gfx_draw_grid (void)
+gfx_resize (GtkWidget *w)
 {
-	GdkColormap *cmap;
-	GdkColor color;
-	gint i;
+	int width, height;
 
-	if (theme[p.theme_id].grid_rgb == NULL) return;
+	width = w->allocation.width;
+	height = w->allocation.height;
 
-	if (!gdk_color_parse (theme[p.theme_id].grid_rgb, &color)) {
-		gdk_color_parse ("#727F8C", &color);
-	}
+	boardsize = MIN (width, height);
+	tilesize = boardsize / 7;
 
-	cmap = gtk_widget_get_colormap (drawarea);
+	offset[TILE_PLAYER1]        = 0;
+	offset[TILE_PLAYER2]        = tilesize;
+	offset[TILE_CLEAR]          = tilesize * 2;
+	offset[TILE_CLEAR_CURSOR]   = tilesize * 3;
+	offset[TILE_PLAYER1_CURSOR] = tilesize * 4;
+	offset[TILE_PLAYER2_CURSOR] = tilesize * 5;
 
-	gdk_colormap_alloc_color (cmap, &color, FALSE, TRUE);
-	gdk_gc_set_foreground (gc, &color);
+	/* create the buffer and background pixmap of the proper size */
+	if (pm_display != NULL)
+		g_object_unref (pm_display);
+	if (pm_bground != NULL)
+		g_object_unref (pm_bground);
 
-	gdk_gc_set_line_attributes (gc, 0, theme[p.theme_id].grid_style,
-	                            GDK_CAP_BUTT, GDK_JOIN_MITER);
+	pm_display = gdk_pixmap_new (w->window, boardsize, boardsize, -1);
+	pm_bground = gdk_pixmap_new (w->window, boardsize, boardsize, -1);
 
-	for (i = tilew; i < width; i = i + tilew) {
-		gdk_draw_line (pm_bground, gc, i, 0, i, height);
-	}
-	for (i = tileh; i < height; i = i + tileh) {
-		gdk_draw_line (pm_bground, gc, 0, i, width, i);
+	/* the first time the configure signal is emitted, the drawarea
+	 * is not shown yet so we do not have the gc.
+	 */
+	if (gc) {
+		gfx_refresh_pixmaps ();
+		gfx_draw_all ();
 	}
-	gdk_colormap_free_colors (cmap, &color, 1);
-	g_object_unref (cmap);
+}
+
+
+
+void
+gfx_expose (GdkRectangle *area)
+{
+	gdk_draw_pixmap (drawarea->window,
+			 gc,
+			 pm_display,
+			 area->x, area->y,
+			 area->x, area->y,
+			 area->width, area->height);
 }
 
 
@@ -197,31 +268,49 @@ gfx_load_error (const gchar *fname)
 
 
 gboolean
-gfx_load (gint id)
+gfx_load_pixmaps (void)
 {
-	GdkPixbuf *pb_tileset_tmp;
-	GdkPixbuf *pb_bground_tmp = NULL;
 	gchar *dname;
 	gchar *fname;
+	GdkPixbuf *pb_tileset_tmp;
+	GdkPixbuf *pb_bground_tmp = NULL;
 
 	dname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
 	                                   APPNAME, FALSE, NULL);
 
-	fname = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", dname,
-	                         theme[id].fname_tileset);
+	/* Try the theme pixmaps, fallback to the default and then give up */
+	while (TRUE)
+	{
+		fname = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", dname,
+	        	                 theme[p.theme_id].fname_tileset);
+
+		pb_tileset_tmp = gdk_pixbuf_new_from_file (fname, NULL);
+		if (pb_tileset_tmp == NULL) {
+			if (p.theme_id != 0) {
+				p.theme_id = 0;
+				g_free (fname);
+				continue;
+			}
+			else {
+				gfx_load_error (fname);
+				g_free (dname);
+				g_free (fname);
+				return FALSE;
+			}
+		}
 
-	pb_tileset_tmp = gdk_pixbuf_new_from_file (fname, NULL);
-	if (pb_tileset_tmp == NULL) {
-		gfx_load_error (fname);
-		g_free (dname);
 		g_free (fname);
-		return FALSE;
+		break;
 	}
-	g_free (fname);
 
-	if (theme[id].fname_bground != NULL) {
+	if (pb_tileset_raw)
+		g_object_unref (pb_tileset_raw);
+
+	pb_tileset_raw = pb_tileset_tmp;
+
+	if (theme[p.theme_id].fname_bground != NULL) {
 		fname = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", dname,
-		                         theme[id].fname_bground);
+		                         theme[p.theme_id].fname_bground);
 		pb_bground_tmp = gdk_pixbuf_new_from_file (fname, NULL);
 		if (pb_bground_tmp == NULL) {
 			gfx_load_error (fname);
@@ -232,61 +321,90 @@ gfx_load (gint id)
 		}
 		g_free (fname);
 	}
-	g_free (dname);
-
-	gfx_free ();
-	p.theme_id = id;
-
-	pb_tileset = pb_tileset_tmp;
-
-	tilew = gdk_pixbuf_get_width (pb_tileset) / 6;
-	tileh = gdk_pixbuf_get_height (pb_tileset);
 
-	width = tilew * 7;
-	height = tileh * 7;
+	g_free (dname);
 
-	offset[TILE_PLAYER1]        = 0;
-	offset[TILE_PLAYER2]        = tilew;
-	offset[TILE_CLEAR]          = tilew * 2;
-	offset[TILE_CLEAR_CURSOR]   = tilew * 3;
-	offset[TILE_PLAYER1_CURSOR] = tilew * 4;
-	offset[TILE_PLAYER2_CURSOR] = tilew * 5;
+	if (pb_bground_raw)
+		g_object_unref (pb_bground_raw);
 
+	/* If a separate background image wasn't supplied,
+	 * derive the background image from the tile set
+	 */
 	if (pb_bground_tmp != NULL) {
-
-		/* a separate background image was supplied */
-
-		pb_bground = gdk_pixbuf_scale_simple (pb_bground_tmp, width, height, GDK_INTERP_BILINEAR);
-		gdk_pixbuf_unref (pb_bground_tmp);
+		pb_bground_raw = pb_bground_tmp;
 	}
 	else {
-
-		/* derive the background image from the tile set */
-
+		gint tilesize_raw;
 		gint i, j;
 
-		pb_bground = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+		tilesize_raw = gdk_pixbuf_get_height (pb_tileset_raw);
+
+		pb_bground_raw = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+		                                 tilesize_raw * 7, tilesize_raw * 7);
 		for (i = 0; i < 7; i++) {
-			gdk_pixbuf_copy_area (pb_tileset, offset[TILE_CLEAR_CURSOR], 0, tilew, tileh, pb_bground, i * tilew, 0);
+			gdk_pixbuf_copy_area (pb_tileset_raw,
+					      tilesize_raw * 3, 0,
+					      tilesize_raw, tilesize_raw,
+					      pb_bground_raw, i * tilesize_raw, 0);
 			for (j = 1; j < 7; j++) {
-				gdk_pixbuf_copy_area (pb_tileset, offset[TILE_CLEAR], 0, tilew, tileh, pb_bground, i * tilew, j * tileh);
+				gdk_pixbuf_copy_area (pb_tileset_raw,
+						      tilesize_raw * 2, 0,
+						      tilesize_raw, tilesize_raw,
+						      pb_bground_raw,
+						      i * tilesize_raw, j * tilesize_raw);
 			}
 		}
 	}
 
-	pm_display = gdk_pixmap_new (app->window, width, height, -1);
-	pm_bground = gdk_pixmap_new (app->window, width, height, -1);
+	return TRUE;
+}
+
+
+
+gboolean
+gfx_set_grid_style (void)
+{
+	GdkColormap *cmap;
+	GdkColor color;
+
+	g_return_val_if_fail (drawarea != NULL, FALSE);
+
+	if (!gc)
+		gc = gdk_gc_new (drawarea->window);
+
+	if (theme[p.theme_id].grid_rgb == NULL)
+		return FALSE;
+
+	if (!gdk_color_parse (theme[p.theme_id].grid_rgb, &color))
+		gdk_color_parse ("#727F8C", &color);
+
+	cmap = gtk_widget_get_colormap (drawarea);
+	gdk_colormap_alloc_color (cmap, &color, FALSE, TRUE);
+
+	gdk_gc_set_foreground (gc, &color);
+
+	gdk_colormap_free_colors (cmap, &color, 1);
+	g_object_unref (cmap);
 
-	gdk_pixbuf_render_to_drawable (pb_bground, pm_bground, gc, 0, 0, 0, 0,
-	                               width, height, GDK_RGB_DITHER_NORMAL, 0, 0);
+	gdk_gc_set_line_attributes (gc, 0, theme[p.theme_id].grid_style,
+	                            GDK_CAP_BUTT, GDK_JOIN_MITER);
+
+	return TRUE;
+}
 
-	gtk_widget_set_size_request (GTK_WIDGET(drawarea), width, height);
 
-	gfx_draw_grid ();
-	gfx_draw_all (TRUE);
 
-	scorebox_update (); /* update visible player descriptions */
-	prompt_player ();
+gboolean
+gfx_change_theme (void)
+{
+	if (!gfx_load_pixmaps ())
+		return FALSE;
+
+	if (!gfx_set_grid_style ())
+		return FALSE;
+
+	gfx_refresh_pixmaps ();
+	gfx_draw_all ();
 
 	return TRUE;
 }
Index: src/gfx.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gnect/src/gfx.h,v
retrieving revision 1.5
diff -u -p -r1.5 gfx.h
--- src/gfx.h	16 Mar 2004 09:03:27 -0000	1.5
+++ src/gfx.h	10 Sep 2004 12:29:53 -0000
@@ -2,12 +2,14 @@
 
 
 
-gboolean gfx_load (gint id);
+gboolean gfx_load_pixmaps (void);
+gboolean gfx_set_grid_style (void);
+gboolean gfx_change_theme (void);
 void     gfx_free (void);
+void     gfx_resize (GtkWidget *w);
 void     gfx_expose (GdkRectangle *area);
 void     gfx_draw_tile (gint r, gint c, gboolean refresh);
-void     gfx_draw_all (gboolean refresh);
-void     gfx_draw_grid (void);
+void     gfx_draw_all (void);
 gint     gfx_get_column (gint xpos);
-extern GdkGC     *gc;
+
 
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnect/src/main.c,v
retrieving revision 1.14
diff -u -p -r1.14 main.c
--- src/main.c	16 Mar 2004 09:03:27 -0000	1.14
+++ src/main.c	10 Sep 2004 12:29:54 -0000
@@ -27,6 +27,7 @@
 #include "config.h"
 #include <gnome.h>
 #include <gconf/gconf-client.h>
+#include "games-gridframe.h"
 #include "connect4.h"
 #include "main.h"
 #include "theme.h"
@@ -203,8 +204,10 @@ move_cursor (gint c)
 
 	column = c;
 
-	if (player == PLAYER1) gboard[0][c] = TILE_PLAYER1;
-	else gboard[0][c] = TILE_PLAYER2;
+	if (player == PLAYER1)
+		gboard[0][c] = TILE_PLAYER1;
+	else
+		gboard[0][c] = TILE_PLAYER2;
 
 	gfx_draw_tile (0, c, TRUE);
 
@@ -222,8 +225,10 @@ move (gint c)
 
 	column = c;
 
-	if (player == PLAYER1) gboard[0][c] = TILE_PLAYER1;
-	else gboard[0][c] = TILE_PLAYER2;
+	if (player == PLAYER1)
+		gboard[0][c] = TILE_PLAYER1;
+	else
+		gboard[0][c] = TILE_PLAYER2;
 
 	gfx_draw_tile (0, c, TRUE);
 }
@@ -428,7 +433,7 @@ game_reset (gboolean start)
 
 	clear_board ();
 	set_status (STATUS_CLEAR, NULL);
-	gfx_draw_all (TRUE);
+	gfx_draw_all ();
 
 	if (start) {
 		move_cursor (column);
@@ -1086,6 +1091,26 @@ process_move (gint c)
 
 
 
+static gint
+on_drawarea_resize (GtkWidget *w, GdkEventConfigure *e, gpointer data)
+{
+	gfx_resize (w);
+
+	return TRUE;
+}
+
+
+
+static gboolean
+on_drawarea_expose (GtkWidget *w, GdkEventExpose *e, gpointer data)
+{
+	gfx_expose (&e->area);
+
+	return FALSE;
+}
+
+
+
 static gboolean
 on_key_press (GtkWidget* w, GdkEventKey* e, gpointer data)
 {
@@ -1118,30 +1143,21 @@ on_key_press (GtkWidget* w, GdkEventKey*
 
 
 
-static void
-on_drawarea_event (GtkWidget *w, const GdkEvent *e)
+static gboolean
+on_button_press (GtkWidget *w, GdkEventButton *e, gpointer data)
 {
-	GdkEventExpose *expose;
 	gint x, y;
 
-	switch (e->type) {
-	case GDK_EXPOSE:
-		expose = (GdkEventExpose*)e;
-		gfx_expose (&expose->area);
-		break;
-	case GDK_BUTTON_PRESS:
-		if (gameover && !timeout) {
-			blink_winner (2);
-			set_status (STATUS_FLASH, _("Select \"New game\" from the \"Game\" menu to begin."));
-		}
-		else if (is_player_human () && !timeout) {
-			gtk_widget_get_pointer (w, &x, &y);
-			process_move (gfx_get_column (x));
-		}
-		return;
-	default:
-		break;
+	if (gameover && !timeout) {
+		blink_winner (2);
+		set_status (STATUS_FLASH, _("Select \"New game\" from the \"Game\" menu to begin."));
 	}
+	else if (is_player_human () && !timeout) {
+		gtk_widget_get_pointer (w, &x, &y);
+		process_move (gfx_get_column (x));
+	}
+
+	return TRUE;
 }
 
 
@@ -1199,10 +1215,10 @@ create_app (void)
 {
 	BonoboDockItem *gdi;
 	GtkWidget *bonobodock;
+	GtkWidget *gridframe;
 
 	app = gnome_app_new (APPNAME, _("Four-in-a-row"));
-	gtk_window_set_resizable (GTK_WINDOW (app), FALSE);
-	gtk_window_set_wmclass (GTK_WINDOW (app), APPNAME, "main");
+	gtk_window_set_default_size (GTK_WINDOW (app), 350, 390);
 
 	g_signal_connect (G_OBJECT(app), "delete_event",
 	                  G_CALLBACK(on_delete_event), NULL);
@@ -1220,13 +1236,25 @@ create_app (void)
 	gnome_app_create_menus (GNOME_APP(app), menubar_uiinfo);
 	gnome_app_create_toolbar (GNOME_APP(app), toolbar);
 
+	gridframe = games_grid_frame_new (7, 7);
+	gnome_app_set_contents (GNOME_APP (app), gridframe);
+
 	drawarea = gtk_drawing_area_new ();
-	gtk_widget_set_size_request (drawarea, 350, 350);
-	gnome_app_set_contents (GNOME_APP (app), drawarea);
+
+	/* set a min size to avoid pathological behavior of gtk when scaling down */
+	gtk_widget_set_size_request (drawarea, 200, 200);
+
+	gtk_container_add (GTK_CONTAINER (gridframe), drawarea);
 
 	gtk_widget_set_events (drawarea, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
-	g_signal_connect (GTK_OBJECT(drawarea), "event", GTK_SIGNAL_FUNC(on_drawarea_event), NULL);
-	g_signal_connect (GTK_OBJECT(app), "key_press_event", GTK_SIGNAL_FUNC(on_key_press), NULL);
+	g_signal_connect (G_OBJECT(drawarea), "configure_event",
+			  G_CALLBACK (on_drawarea_resize), NULL);
+	g_signal_connect (G_OBJECT(drawarea), "expose_event",
+	                  G_CALLBACK(on_drawarea_expose), NULL);
+	g_signal_connect (G_OBJECT(drawarea), "button_press_event",
+	                  G_CALLBACK(on_button_press), NULL);
+	g_signal_connect (G_OBJECT(app), "key_press_event",
+	                  G_CALLBACK(on_key_press), NULL);
 
 	appbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER);
 	gnome_app_set_statusbar (GNOME_APP(app), appbar);
@@ -1241,23 +1269,17 @@ create_app (void)
 	undo_set_sensitive (FALSE);
 
 	gtk_widget_show_all (app);
-	gc = gdk_gc_new (drawarea->window);
+
+	if (!gfx_set_grid_style ())
+		return FALSE;
 
 	if (!p.do_toolbar) {
 		gdi = gnome_app_get_dock_item_by_name (GNOME_APP(app), GNOME_APP_TOOLBAR_NAME);
 		gtk_widget_hide (GTK_WIDGET(gdi));
 	}
 
-	if (!gfx_load (p.theme_id)) {
-		if (p.theme_id != 0) {
-			if (!gfx_load (0)) {
-				return FALSE;
-			}
-		}
-		else {
-			return FALSE;
-		}
-	}
+	scorebox_update (); /* update visible player descriptions */
+	prompt_player ();
 
 	set_status (STATUS_FLASH, _("Welcome to Gnect!"));
 
@@ -1279,9 +1301,13 @@ main (int argc, char *argv[])
 	prefs_init (argc, argv);
 	game_init ();
 
-	if (create_app ()) {
+	/* init gfx */
+	if (!gfx_load_pixmaps ())
+		return 0;
+
+	if (create_app ())
 		gtk_main ();
-	}
+
 
 	game_free ();
 
Index: src/prefs.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnect/src/prefs.c,v
retrieving revision 1.28
diff -u -p -r1.28 prefs.c
--- src/prefs.c	5 Jun 2004 12:27:27 -0000	1.28
+++ src/prefs.c	10 Sep 2004 12:29:55 -0000
@@ -226,9 +226,11 @@ gconf_theme_changed (GConfClient *client
 
 	val = sane_theme_id (gconf_client_get_int (conf_client, KEY_THEME_ID, NULL));
 	if (val != p.theme_id) {
-		if (!gfx_load (val)) return;
 		p.theme_id = val;
-		if (prefsbox == NULL) return;
+		if (!gfx_change_theme ())
+			return;
+		if (prefsbox == NULL)
+			return;
 		gtk_combo_box_set_active (GTK_COMBO_BOX(combobox_theme), p.theme_id);
 		prefsbox_update_player_labels ();
 	}
@@ -242,8 +244,6 @@ on_select_theme (GtkComboBox *combo, gpo
 	gint id;
 
 	id = gtk_combo_box_get_active (combo);
-	if (!gfx_load (id)) return;
-	prefsbox_update_player_labels ();
 
 	gconf_client_set_int (conf_client, KEY_THEME_ID, id, NULL);
 }
