Index: blockops.cpp
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/blockops.cpp,v
retrieving revision 1.17
diff -u -p -r1.17 blockops.cpp
--- blockops.cpp	10 Jul 2005 02:01:03 -0000	1.17
+++ blockops.cpp	31 Aug 2005 14:39:34 -0000
@@ -21,32 +21,15 @@
 #include "blockops.h"
 #include "blocks.h"
 #include "field.h"
-#include "gnome-canvas-pimage.h"
 
-GnomeCanvasItem *BlockOps::generateItem(int x, int y, int colour)
-{
-	GnomeCanvasItem *it = gnome_canvas_item_new(
-  			gnome_canvas_root(GNOME_CANVAS(fieldDisplay->getWidget())),
-  			gnome_canvas_pimage_get_type(),
-  			"image", pic[colour],
-  			"x", (double) x * BLOCK_SIZE,
-  			"y", (double) y * BLOCK_SIZE,
-			"width", (double) BLOCK_SIZE,
-			"height", (double) BLOCK_SIZE,
-  			NULL);
-
-	return it;
-}
 
-BlockOps::BlockOps(Field *f)
+BlockOps::BlockOps()
 {
 	field = new Block*[COLUMNS];
-	fieldDisplay = f;
 	
 	for (int i = 0; i < COLUMNS; ++i)
 		field[i] = new Block[LINES];
 
-	field_initialized = false;
 	emptyField();
 }
 
@@ -62,7 +45,7 @@ bool 
 BlockOps::blockOkHere(int x, int y, int b, int r)
 {
 	x -= 2;
-	
+
 	for (int x1 = 0; x1 < 4; ++x1)
 	{
 		for (int y1 = 0; y1 < 4; ++y1)
@@ -77,6 +60,7 @@ BlockOps::blockOkHere(int x, int y, int 
 				return false;
 		}
 	}
+
 	return true;	
 }
 
@@ -102,6 +86,7 @@ BlockOps::getLinesToBottom()
 				lines = tmp;
 		}
 	}
+
 	return lines;
 }
 
@@ -209,17 +194,8 @@ BlockOps::eliminateLine(int l)
 	{
 		for (int x = 0; x < COLUMNS; ++x)
 		{
-			if (field[x][y].item)
-				gtk_object_destroy(GTK_OBJECT(field[x][y].item));
-
 			field[x][y] = field[x][y - 1];
-			if (field[x][y].item)
-				field[x][y].item = generateItem(x, y, field[x][y].color);
 
-			if (field[x][y - 1].item)
-				gtk_object_destroy(GTK_OBJECT(field[x][y - 1].item));
-
-			field[x][y - 1].item = NULL;
 			field[x][y - 1].what = EMPTY;
 			field[x][y - 1].color = 0;
 		}
@@ -299,12 +275,9 @@ BlockOps::emptyField(int filled_lines, i
 
 		for (int x = 0; x < COLUMNS; ++x)
 		{
-			if (field_initialized && field[x][y].item != 0)
-			{
-				gtk_object_destroy(GTK_OBJECT(field[x][y].item));
-			}
-			field[x][y].item = 0;
 			field[x][y].what = EMPTY;
+			field[x][y].color = 0; 
+
 			if ((y>=(LINES - filled_lines)) && (x != blank) &&
 			    ((g_random_int_range(0, 10)) < fill_prob)) { 
 				field[x][y].what = LAYING;
@@ -316,11 +289,9 @@ BlockOps::emptyField(int filled_lines, i
 					// up and nr_of_colors is
 					// defined.
 					field[x][y].color = 0; 
-				field[x][y].item = generateItem(x,y,field[x][y].color);
 			}
 		}
 	}
-	field_initialized = true;
 }
 
 void
@@ -338,26 +309,18 @@ BlockOps::putBlockInField(bool erase)
 		{
 			if (blockTable[blocknr][rot][x][y])
 			{
-				field[posx - 2 + x][y + posy].what = erase ? EMPTY : FALLING;
 				if (erase)
 				{
-					GnomeCanvasItem *o = field[posx - 2 + x][y + posy].item;
-					if (o)
-						gtk_object_destroy(GTK_OBJECT(o));
-					field[posx - 2 + x][y + posy].item = 0;
+					field[posx - 2 + x][y + posy].what = EMPTY;
+					field[posx - 2 + x][y + posy].color = 0;
 				}
 				else
 				{
+					field[posx - 2 + x][y + posy].what = FALLING;
 					field[posx - 2 + x][y + posy].color = color;
-					field[posx - 2 + x][y + posy].item = 
-						generateItem(posx - 2 + x, y + posy, 
-									 field[posx - 2 + x][y + posy].color);
 				}
 			}
 		}
 	}
 }
-
-
-
 
Index: blockops.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/blockops.h,v
retrieving revision 1.10
diff -u -p -r1.10 blockops.h
--- blockops.h	10 Jul 2005 02:01:03 -0000	1.10
+++ blockops.h	31 Aug 2005 14:39:34 -0000
@@ -26,7 +26,7 @@
 class BlockOps
 {
 public:
-	BlockOps(Field *f);
+	BlockOps();
 	~BlockOps();
 	
 	bool moveBlockLeft();
@@ -41,16 +41,13 @@ public:
 	void emptyField(int filled_lines, int fill_prob);
 	void putBlockInField(bool erase);
 	int getLinesToBottom();
-	GnomeCanvasItem *generateItem(int x, int y, int color);
-
-	const Block * const getFieldAt(int x, int y) {return &(field[x][y]);}
 
 private:
 	bool blockOkHere(int x, int y, int b, int r);
 	void eliminateLine(int l);
+
+protected:
 	Block **field;
-	bool field_initialized;
-	Field *fieldDisplay;
 };
 
 #endif //__blockops_h__
Index: field.cpp
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/field.cpp,v
retrieving revision 1.12
diff -u -p -r1.12 field.cpp
--- field.cpp	10 Jul 2005 02:01:03 -0000	1.12
+++ field.cpp	31 Aug 2005 14:39:35 -0000
@@ -20,132 +20,249 @@
 
 #include "field.h"
 #include "blocks.h"
-#include "gnome-canvas-pimage.h"
 
-Field::	Field()
+
+#define FONT "Sans Bold"
+
+
+Field::Field():
+	BlockOps(),
+	buffer(NULL),
+	background(NULL),
+	showPause(false),
+	showGameOver(false),
+	backgroundImage(NULL),
+	backgroundImageTiled(false),
+	backgroundColor(NULL)
 {
-	bg = NULL;
-	pausemsg = NULL;
-	gameovermsg = NULL;
-
-	w = gnome_canvas_new();
+	w = gtk_drawing_area_new();
+
+	g_signal_connect (w, "expose_event", G_CALLBACK (expose), this);
+	g_signal_connect (w, "configure_event", G_CALLBACK (configure), this);
+
+	gtk_widget_show (w);
+}
+
+Field::~Field()
+{
+	if (buffer)
+		cairo_surface_destroy(buffer);
+	if (background)
+		cairo_surface_destroy(background);
+}
+
+gboolean
+Field::configure(GtkWidget *widget, GdkEventConfigure *event, Field *field)
+{
+	cairo_t *cr;
+	cairo_t *bg_cr;
+
+	field->width = widget->allocation.width;
+	field->height = widget->allocation.height;
+
+	cr = gdk_cairo_create (widget->window);
+
+	if (field->buffer)
+		cairo_surface_destroy(field->buffer);
+	if (field->background)
+		cairo_surface_destroy(field->background);
+
+	// backing buffer
+	field->buffer =  cairo_surface_create_similar (cairo_get_target (cr),
+						       CAIRO_CONTENT_COLOR,
+						       widget->allocation.width,
+						       widget->allocation.height);
+
+	// cached background
+	field->background =  cairo_surface_create_similar (cairo_get_target (cr),
+							   CAIRO_CONTENT_COLOR,
+							   widget->allocation.width,
+							   widget->allocation.height);
+
+	cairo_destroy (cr);
+
+	bg_cr = cairo_create (field->background);
+
+	if (field->backgroundImage)
+		gdk_cairo_set_source_pixbuf(bg_cr, field->backgroundImage, 0, 0);
+	else if (field->backgroundColor)
+		gdk_cairo_set_source_color(bg_cr, field->backgroundColor);
+	else
+		cairo_set_source_rgb(bg_cr, 0., 0., 0.);
+
+	cairo_paint(bg_cr);
+
+	cairo_destroy(bg_cr);
+
+	field->redraw();
+
+	return TRUE;
+}
+
+gboolean
+Field::expose(GtkWidget *widget, GdkEventExpose *event, Field *field)
+{
+	cairo_t *cr;
+
+	cr = gdk_cairo_create(widget->window);
+
+	// blit to window
+	cairo_set_source_surface(cr, field->buffer, 0, 0);
+	cairo_rectangle(cr,
+			event->area.x, event->area.y,
+			event->area.width, event->area.height);
+	cairo_fill(cr);
+
+	cairo_destroy(cr);
+
+	return TRUE;
 }
 
 void
-Field::updateSize(GdkPixbuf * bgImage, GdkColor *bgcolour)
-{
-	gtk_widget_set_size_request(w, COLUMNS * BLOCK_SIZE, LINES * BLOCK_SIZE);
-	gnome_canvas_set_scroll_region(GNOME_CANVAS(w), 0.0, 0.0, COLUMNS * BLOCK_SIZE, LINES * BLOCK_SIZE);
-
-	if (bg)
-		gtk_object_destroy(GTK_OBJECT(bg));
-	
-  	if (bgImage)
-  		bg = gnome_canvas_item_new(
-  			gnome_canvas_root(GNOME_CANVAS(w)),
-  			gnome_canvas_pimage_get_type(),
-  			"image", bgImage,
-  			"x", (double) 0,
-  			"y", (double) 0,
-			"width", (double) COLUMNS * BLOCK_SIZE,
-			"height", (double) LINES * BLOCK_SIZE,
-  			NULL);
-		else
-			bg = gnome_canvas_item_new(
-  			gnome_canvas_root(GNOME_CANVAS(w)),
-				gnome_canvas_rect_get_type(),
-  			"x1", (double) 0,
-  			"y1", (double) 0,
-  			"x2", (double) COLUMNS * BLOCK_SIZE,
-  			"y2", (double) LINES * BLOCK_SIZE,
-				"fill_color_gdk", bgcolour,
-				"outline_color", "black",
-				"width_units", 1.0,
-  			NULL);
+Field::drawBackground(cairo_t *cr)
+{
+	cairo_save(cr);
+
+	cairo_set_source_surface(cr, background, 0, 0);
+	cairo_paint(cr);
+
+	cairo_restore(cr);
 }
 
 void
-Field::showPauseMessage()
+Field::drawForeground(cairo_t *cr)
 {
-	if (!pausemsg)
+	cairo_save(cr);
+
+	cairo_scale(cr, 1.0 * width / COLUMNS, 1.0 * height / LINES);
+
+	cairo_set_source_rgba(cr, 1., 0., 0., 0.6);
+
+	for (int y = 0; y < LINES; ++y)
 	{
-		double x1, y1, x2, y2;
-		double width;
-		double pts;
-
-		pausemsg = gnome_canvas_item_new (
-			gnome_canvas_root(GNOME_CANVAS(w)),
-			gnome_canvas_text_get_type(),
-			"fill_color",
-			"white",
-			"x", COLUMNS * BLOCK_SIZE / 2.0,
-			"y", LINES * BLOCK_SIZE / 2.0,
-			"text", _("Paused"),
-			"size_points", 36.0,
-			NULL);
-
-		/* Since gnome_canvas doesn't support setting the size of text in
-		 * pixels (read the source where the "size" parameter gets set)
-		 * and pango isn't forthcoming about how it scales things (see
-		 * http://mail.gnome.org/archives/gtk-i18n-list/2003-August/msg00001.html
-		 * and bug #119081). We guess at the size, see what size it is rendered
-		 * to and then adjust the point size to fit. 36.0 points is pretty
-		 * close for 96 dpi . */
-
-		gnome_canvas_item_get_bounds (pausemsg, &x1, &y1, &x2, &y2);
-		width = x2 - x1;
-		/* 0.8 is the fraction of the screen we want to use and 36.0 is
-		 * the guess we use previously for the point size. */
-		pts = 0.8 * 36.0 * COLUMNS * BLOCK_SIZE / width;
-		gnome_canvas_item_set (pausemsg, "size_points", pts, 0);
+		for (int x = 0; x < COLUMNS; ++x)
+		{
+			if (field[x][y].what != EMPTY)
+			{
+				cairo_rectangle(cr, x, y, 1, 1);
+			}
+		}
 	}
 
-	gnome_canvas_item_show (pausemsg);
-	gnome_canvas_item_raise_to_top (pausemsg);
+	cairo_fill(cr);
+
+	cairo_restore(cr);
+}
+
+void
+Field::drawMessage(cairo_t *cr, const char *msg)
+{
+	PangoLayout *dummy_layout;
+	PangoLayout *layout;
+	PangoFontDescription *desc;
+	int lw, lh;
+
+	cairo_save(cr);
+
+	// Center coordinates
+	cairo_translate(cr, width / 2, height / 2);
+
+	desc = pango_font_description_from_string(FONT);
+
+	layout = pango_cairo_create_layout(cr);
+	pango_layout_set_text(layout, msg, -1);
+
+	dummy_layout = pango_layout_copy(layout);
+	pango_layout_set_font_description(dummy_layout, desc);
+	pango_layout_get_size(dummy_layout, &lw, &lh);
+	g_object_unref(dummy_layout);
+
+	// desired height : lh = widget width * 0.9 : lw 
+	pango_font_description_set_absolute_size(desc, ((float) lh / lw) * PANGO_SCALE * width * 0.8);
+	pango_layout_set_font_description(layout, desc);
+	pango_font_description_free(desc);
+
+	pango_layout_get_size(layout, &lw, &lh);
+	cairo_move_to(cr, -((double)lw / PANGO_SCALE) / 2, -((double)lh / PANGO_SCALE) / 2);
+	cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+	pango_cairo_show_layout(cr, layout);
+
+	g_object_unref(layout);
+
+	cairo_restore(cr);
+}
+
+void
+Field::redraw()
+{
+	cairo_t *cr;
+
+	g_return_if_fail(buffer);
+
+	cr = cairo_create(buffer);
+
+	drawBackground(cr);
+	drawForeground(cr);
+
+	if (showPause)
+		drawMessage(cr, _("Paused"));
+	else if (showGameOver)
+		drawMessage(cr, _("Game Over"));
+
+	cairo_destroy(cr);
+
+	gtk_widget_queue_draw(w);
+}
+
+void
+Field::setBackground(GdkPixbuf *bgImage)//, bool tiled)
+{
+	backgroundImage = (GdkPixbuf *) g_object_ref(bgImage);
+//	backgroundImageTiled = tiled;
+
+	// make sure to rerurn configure(), so that the bg surface
+	// is recached and redrawn.
+	gtk_widget_queue_resize (w);
+}
+
+void
+Field::setBackground(GdkColor *bgColor)
+{
+	backgroundColor = gdk_color_copy(bgColor);
+
+	// make sure to rerurn configure(), so that the bg surface
+	// is recached and redrawn.
+	gtk_widget_queue_resize (w);
+}
+
+void
+Field::showPauseMessage()
+{
+	showPause = true;
+
+	redraw();
 }
 
 void
 Field::hidePauseMessage()
 {
-	if (pausemsg)
-		gnome_canvas_item_hide (pausemsg);
+	showPause = false;
+
+	redraw();
 }
 
 void
 Field::showGameOverMessage()
 {
-	if (!gameovermsg)
-	{
-		double x1, y1, x2, y2;
-		double width;
-		double pts;
-
-		gameovermsg = gnome_canvas_item_new (
-			gnome_canvas_root(GNOME_CANVAS(w)),
-			gnome_canvas_text_get_type(),
-			"fill_color",
-			"white",
-			"x", COLUMNS * BLOCK_SIZE / 2.0,
-			"y", LINES * BLOCK_SIZE / 2.0,
-			"text", _("Game Over"),
-			"size_points", 36.0,
-			NULL);
-
-		gnome_canvas_item_get_bounds (gameovermsg, &x1, &y1, &x2, &y2);
-		width = x2 - x1;
-		/* 0.9 is the fraction of the screen we want to use and 36.0 is
-		 * the guess we use previously for the point size. */
-		pts = 0.9 * 36.0 * COLUMNS * BLOCK_SIZE / width;
-		gnome_canvas_item_set (gameovermsg, "size_points", pts, 0);
-	}
+	showGameOver = true;
 
-	gnome_canvas_item_show (gameovermsg);
-	gnome_canvas_item_raise_to_top (gameovermsg);
+	redraw();
 }
 
 void
 Field::hideGameOverMessage()
 {
-	if (gameovermsg)
-		gnome_canvas_item_hide (gameovermsg);
+	showGameOver = false;
+
+	redraw();
 }
Index: field.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/field.h,v
retrieving revision 1.7
diff -u -p -r1.7 field.h
--- field.h	10 Jul 2005 02:01:03 -0000	1.7
+++ field.h	31 Aug 2005 14:39:35 -0000
@@ -24,24 +24,53 @@
 #include "tetris.h"
 #include "blockops.h"
 
-class Field
+class Field : public BlockOps
 {
 public:
 	Field();
-	
-	void updateSize(GdkPixbuf * bgImage, GdkColor *bgcolour);
+	~Field();
+
+	void setBackground(GdkPixbuf *bgImage); //, bool tiled); fixme: move tiling here.
+	void setBackground(GdkColor *bgColor);
+	void placeBlock(int x, int y, int bcolor, bool remove);
 	void showPauseMessage();
 	void hidePauseMessage();
 	void showGameOverMessage();
 	void hideGameOverMessage();
+	void redraw();
 
 	GtkWidget * getWidget()	{return w;}
-	
+
 private:
-	GtkWidget * w;
-	GnomeCanvasItem *bg;
-	GnomeCanvasItem *pausemsg;
-	GnomeCanvasItem *gameovermsg;
+	GtkWidget *w;
+
+	int width;
+	int height;
+
+	cairo_surface_t *buffer;
+	cairo_surface_t *background;
+	cairo_surface_t **blocks;
+
+	bool showPause;
+	bool showGameOver;
+
+	GdkPixbuf *backgroundImage;
+	bool backgroundImageTiled;
+	GdkColor *backgroundColor;
+
+	void drawBackground(cairo_t *cr);
+	void drawForeground(cairo_t *cr);
+	void drawMessage(cairo_t *cr, const char *msg);
+	void redrawAll();
+
+	static gboolean configure(GtkWidget *widget, GdkEventConfigure *event, Field *field);
+	static gboolean expose(GtkWidget *widget, GdkEventExpose *event, Field *field);
+
+	// temp stuff
+
+	GTimer *t;
+
+	Block **foofield;
 };
 
 #endif //__field_h__
Index: preview.cpp
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/preview.cpp,v
retrieving revision 1.9
diff -u -p -r1.9 preview.cpp
--- preview.cpp	15 Jun 2005 02:34:01 -0000	1.9
+++ preview.cpp	31 Aug 2005 14:39:36 -0000
@@ -71,42 +71,57 @@ gint
 Preview::expose(GtkWidget * widget, GdkEventExpose * event, Preview * preview)
 {
 	GdkRectangle *area = &(event->area);
+	cairo_t *cr;
 
-	gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
-			    area->x, area->y, area->width, area->height);
+	cr = gdk_cairo_create (widget->window);
 
-	int xoffs = (preview->width 
-		     - sizeTable[preview->blocknr][preview->blockrot][1] * BLOCK_SIZE) / 2;
-	int yoffs = (preview->height 
-		     - sizeTable[preview->blocknr][preview->blockrot][0] * BLOCK_SIZE) / 2;
-
-	xoffs -= offsetTable[preview->blocknr][preview->blockrot][1] * BLOCK_SIZE;
-	yoffs -= offsetTable[preview->blocknr][preview->blockrot][0] * BLOCK_SIZE;
+	/* restrict our drawing */
+//	owen says it's not worth... in fact I can't see a measurable differnce
+//	gdk_cairo_rectangle (cr, area);
+//	cairo_clip (cr);
+
+	cairo_rectangle (cr, 0 , 0, widget->allocation.width, widget->allocation.height);
+	cairo_set_source_rgb (cr, 0, 0, 0);
+	cairo_fill_preserve (cr);
+	cairo_set_source_rgb (cr, 1.0, 1.0, 0);
+	cairo_stroke (cr);
 
 	if (!preview->enabled)
 	{
-		gdk_draw_line(widget->window, widget->style->white_gc, 0, 0, 
-			      preview->width, preview->height);
-		gdk_draw_line(widget->window, widget->style->white_gc, 0, 
-			      preview->height, preview->width, 0);
-
-		return TRUE;
-	}
+		cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+		cairo_set_line_width (cr, 1.5);
 
-	if (preview->blocknr == -1)
-		return TRUE;
+		cairo_move_to (cr, 0, 0);
+		cairo_line_to (cr, widget->allocation.width, widget->allocation.height);
+		cairo_move_to (cr, widget->allocation.width, 0);
+		cairo_line_to (cr, 0, widget->allocation.height);
 
-	for (int x = 0; x < 4; ++x) {
-		for (int y = 0; y < 4; ++y) {
-			if (blockTable[preview->blocknr][preview->blockrot][x][y]) {
-				gdk_draw_pixbuf (widget->window, widget->style->black_gc, pic[preview->blockcolor],
-						 0, 0, 
-						 x * BLOCK_SIZE + xoffs, y * BLOCK_SIZE + yoffs,
-						 BLOCK_SIZE, BLOCK_SIZE,
-						 GDK_RGB_DITHER_NORMAL, 0, 0);
+		cairo_stroke (cr);
+	}
+	else if (preview->blocknr != -1)
+	{
+		int xoffs = (preview->width 
+			     - sizeTable[preview->blocknr][preview->blockrot][1] * BLOCK_SIZE) / 2;
+		int yoffs = (preview->height 
+			     - sizeTable[preview->blocknr][preview->blockrot][0] * BLOCK_SIZE) / 2;
+
+		xoffs -= offsetTable[preview->blocknr][preview->blockrot][1] * BLOCK_SIZE;
+		yoffs -= offsetTable[preview->blocknr][preview->blockrot][0] * BLOCK_SIZE;
+
+		for (int x = 0; x < 4; ++x) {
+			for (int y = 0; y < 4; ++y) {
+				if (blockTable[preview->blocknr][preview->blockrot][x][y]) {
+					gdk_draw_pixbuf (widget->window, widget->style->black_gc, pic[preview->blockcolor],
+							 0, 0, 
+							 x * BLOCK_SIZE + xoffs, y * BLOCK_SIZE + yoffs,
+							 BLOCK_SIZE, BLOCK_SIZE,
+							 GDK_RGB_DITHER_NORMAL, 0, 0);
+				}
 			}
 		}
 	}
+
+	cairo_destroy (cr);
 
 	return TRUE;
 }
Index: tetris.cpp
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/tetris.cpp,v
retrieving revision 1.91
diff -u -p -r1.91 tetris.cpp
--- tetris.cpp	12 Jul 2005 02:56:24 -0000	1.91
+++ tetris.cpp	31 Aug 2005 14:40:08 -0000
@@ -116,6 +116,7 @@ Tetris::Tetris(int cmdlLevel): 
 	GtkAccelGroup *accel_group;
 	GtkActionGroup *action_group;
 	GtkWidget *vbox;
+	GtkWidget *aspect_frame;
 	GtkWidget *menubar;
 
 	gchar *outdir;
@@ -181,7 +182,8 @@ Tetris::Tetris(int cmdlLevel): 
 	
 	w = gnome_app_new("gnometris", _("Gnometris"));
 	g_signal_connect (w, "delete_event", G_CALLBACK (gameQuit), this);
-	gtk_window_set_resizable (GTK_WINDOW (w), FALSE);
+	gtk_window_set_default_size (GTK_WINDOW (w), 300, 200);
+//	gtk_window_set_resizable (GTK_WINDOW (w), FALSE);
 	gtk_drag_dest_set (w, GTK_DEST_DEFAULT_ALL, targets, 
 			   G_N_ELEMENTS(targets), 
 			   GDK_ACTION_MOVE);
@@ -235,16 +237,19 @@ Tetris::Tetris(int cmdlLevel): 
 	gtk_box_pack_start (GTK_BOX (vbox), hb, TRUE, TRUE, 0);
 
 	field = new Field();
-	ops = new BlockOps(field);
+
+	aspect_frame = gtk_aspect_frame_new (NULL, 0.5, 0.5, (float) COLUMNS / (float) LINES, FALSE);
+	gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_NONE);
+	gtk_container_add (GTK_CONTAINER (aspect_frame), field->getWidget());
 
 	gtk_widget_set_events(w, gtk_widget_get_events(w) | 
 						  GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
-	
+
 	GtkWidget *vb1 = gtk_vbox_new(FALSE, 0);
 	gtk_container_set_border_width(GTK_CONTAINER(vb1), 10);
-	gtk_box_pack_start_defaults(GTK_BOX(vb1), field->getWidget());
-	gtk_box_pack_start(GTK_BOX(hb), vb1, 0, 0, 0);
-	gtk_widget_show(field->getWidget());
+	gtk_box_pack_start_defaults(GTK_BOX(vb1), aspect_frame);
+	gtk_box_pack_start_defaults(GTK_BOX(hb), vb1);
+
 	setupPixmap();
 
 	g_signal_connect (w, "key_press_event", G_CALLBACK (keyPressHandler), this);
@@ -270,6 +275,8 @@ Tetris::Tetris(int cmdlLevel): 
 	gtk_widget_show(hb);
 	gtk_widget_show(vb1);
 	gtk_widget_show(vb2);
+	gtk_widget_show(aspect_frame);
+	gtk_widget_show(field->getWidget());
 	scoreFrame->show();
 	gtk_widget_show(w);
 
@@ -282,7 +289,6 @@ Tetris::Tetris(int cmdlLevel): 
 
 Tetris::~Tetris()
 {
-	delete ops;
 	delete field;
 	delete preview;
 	delete scoreFrame;
@@ -451,8 +457,10 @@ Tetris::setupPixmap()
 
 	if (field)
 	{
-		field->updateSize (bgimage, &bgcolour);
-		gtk_widget_queue_resize (field->getWidget());
+		if (bgimage)
+			field->setBackground (bgimage);
+		else
+			field->setBackground (&bgcolour);
 	}
 	
 	if (preview)
@@ -1004,12 +1012,12 @@ Tetris::generateTimer(int level)
 void
 Tetris::manageFallen()
 {
-	ops->fallingToLaying();
+	field->fallingToLaying();
 	sound->playSound (SOUND_LAND);
 
 	int levelBefore = scoreFrame->getLevel();
 
-	int fullLines = ops->checkFullLines();
+	int fullLines = field->checkFullLines();
 	if (fullLines > 0)
 		scoreFrame->incLines(fullLines);
 	int levelAfter = scoreFrame->getLevel();
@@ -1032,12 +1040,14 @@ Tetris::timeoutHandler(void *d)
  	if (t->onePause)
  	{
 		t->onePause = false;
-		gtk_widget_queue_draw(t->field->getWidget());
+		//gtk_widget_queue_draw(t->field->getWidget());
+		t->field->redraw();
 	}
  	else
 	{
-		bool res = t->ops->moveBlockDown();
-		gtk_widget_queue_draw(t->field->getWidget());
+		bool res = t->field->moveBlockDown();
+		//gtk_widget_queue_draw(t->field->getWidget());
+		t->field->redraw();
 
 		if (res)
 		{
@@ -1076,17 +1086,17 @@ Tetris::keyPressHandler(GtkWidget *widge
 		return FALSE;
 
 	if (keyval == t->moveLeft) {
-		res = t->ops->moveBlockLeft();
+		res = t->field->moveBlockLeft();
 		if (res)
 			sound->playSound (SOUND_SLIDE);
 		t->onePause = false;
 	} else if (keyval == t->moveRight) {
-		res = t->ops->moveBlockRight();
+		res = t->field->moveBlockRight();
 		if (res)
 			sound->playSound (SOUND_SLIDE);
 		t->onePause = false;
 	} else if (keyval == t->moveRotate) {
-		res = t->ops->rotateBlock(rotateCounterClockWise);
+		res = t->field->rotateBlock(rotateCounterClockWise);
 		if (res)
 			sound->playSound (SOUND_TURN);
 		t->onePause = false;
@@ -1101,13 +1111,15 @@ Tetris::keyPressHandler(GtkWidget *widge
 	} else if (keyval == t->moveDrop) {
 		if (!t->dropBlock) {
 			t->dropBlock = true;
-			bonus = t->ops->dropBlock();
+			bonus = t->field->dropBlock();
 			t->scoreFrame->incScore(bonus);
 			t->manageFallen();
 			res = TRUE;
 		}        
 	}
 
+	t->field->redraw();
+
 	return res;
 }
 
@@ -1331,7 +1343,6 @@ Tetris::dragDrop(GtkWidget *widget, GdkD
 	gnome_vfs_close (inhandle);
  error_exit:
 	return;
-
 }
 
 void
@@ -1353,9 +1364,9 @@ Tetris::togglePause()
 void
 Tetris::generate()
 {
-	if (ops->generateFallingBlock())
+	if (field->generateFallingBlock())
 	{
-		ops->putBlockInField(false);
+		field->putBlockInField(false);
 		preview->previewBlock(blocknr_next, rot_next, color_next);
 		gtk_widget_queue_draw(preview->getWidget());
 		onePause = true;
@@ -1421,13 +1432,14 @@ Tetris::gameNew(GtkAction *action, void 
 	t->scoreFrame->setStartingLevel(level);
 
 	t->timeoutId = g_timeout_add_full(0, 1000 - 100 * (level - 1), timeoutHandler, t, NULL);
-	t->ops->emptyField(t->line_fill_height,t->line_fill_prob);
+	t->field->emptyField(t->line_fill_height,t->line_fill_prob);
 
 	t->scoreFrame->resetLines();
 	t->paused = false;
 	
-	t->ops->generateFallingBlock();
-	gtk_widget_queue_draw(t->field->getWidget());
+	t->field->generateFallingBlock();
+	//gtk_widget_queue_draw(t->field->getWidget());
+	t->field->redraw();
 	t->preview->previewBlock(blocknr_next, rot_next, color_next);
 	gtk_widget_queue_draw(t->preview->getWidget());
 
@@ -1458,7 +1470,7 @@ Tetris::gameAbout(GtkAction *action, voi
 {
 	Tetris *t = (Tetris*) d;
 
-	const gchar *authors[] = { "J. Marcin Gorycki", NULL };
+	const gchar * const authors[] = { "J. Marcin Gorycki", NULL };
 
 	gtk_show_about_dialog (GTK_WINDOW (t->getWidget()),
 			       "name", _("Gnometris"),
Index: tetris.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gnometris/tetris.h,v
retrieving revision 1.36
diff -u -p -r1.36 tetris.h
--- tetris.h	12 Jul 2005 02:56:24 -0000	1.36
+++ tetris.h	31 Aug 2005 14:40:08 -0000
@@ -44,7 +44,6 @@ struct Block
 {
 	SlotType what;
 	int color;
-	GnomeCanvasItem* item;
 };
 
 extern GdkPixmap *pix;
