Index: gnome-games/gataxx/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/Makefile.am,v
retrieving revision 1.38
diff -u -r1.38 Makefile.am
--- gnome-games/gataxx/Makefile.am	2 Oct 2006 03:34:46 -0000	1.38
+++ gnome-games/gataxx/Makefile.am	5 Oct 2006 12:15:08 -0000
@@ -14,14 +14,6 @@
 gataxx_SOURCES = \
 	ai.c \
 	ai.h \
-	appbar.c \
-	appbar.h \
-	gtkgridboard.c \
-	gtkgridboard.h \
-	gtkgridboardthemes.c \
-	gtkgridboardthemes.h \
-	menus.c \
-	menus.h \
 	gataxx.c \
 	gataxx.h \
 	properties.c \
Index: gnome-games/gataxx/ai.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/ai.c,v
retrieving revision 1.4
diff -u -r1.4 ai.c
--- gnome-games/gataxx/ai.c	3 Oct 2006 20:57:24 -0000	1.4
+++ gnome-games/gataxx/ai.c	5 Oct 2006 12:15:08 -0000
@@ -1,6 +1,6 @@
-/* (C) 2003/2004 Sjoerd Langkemper
- * ai.c - Artificial intelligence
- * 
+/*
+ * ai.c
+ *
  * 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
@@ -18,267 +18,316 @@
  * For more details see the file COPYING.
  */
 
+#include <gnome.h>
 
-#include <glib.h>
-#include <gtkgridboard.h>
-#include "gataxx.h"
 #include "ai.h"
-#include "properties.h"
-
 
-static int steps;
+gint8 board0[SIZE][SIZE];
+gint vsquares[MAX_VPOINTER][3];
+guint move_count;
+guint whose_turn;
+guint bcount;
+guint wcount;
+
+static gint history[MAX_MOVE_COUNT][13];
+static gint vpointer;
+static GRand *rgen;
 
 
-static int alphabeta (GtkGridBoard * gridboard, int alpha, int beta, int mode,
-		      int me, int depth);
-static int get_possible_moves_size (move * pm);
-static move *get_possible_moves (GtkGridBoard * gridboard, int turn);
-static move get_best_move_to (GtkGridBoard * gridboard, int x, int y, int me);
-static void free_possible_moves (move * pm);
+/* Initialization of data */
+void
+init (void)
+{
+  gint i, j;
 
+  rgen = g_rand_new ();
 
-/* take a random move */
-static move
-computer_move_random (GtkGridBoard * gridboard, int turn)
-{
-  move *pm;
-  move result;
-  int size, item;
-
-  pm = get_possible_moves (gridboard, turn);
-  size = get_possible_moves_size (pm);
-  if (size > 0) {
-    item = g_random_int_range (0, size);
-  } else {
-    item = 0;
-  }
-  result = pm[item];
-  free_possible_moves (pm);
-  return result;
+  for (i = 0; i < SIZE; i++)
+    for (j = 0; j < SIZE; j++)
+      board0[i][j] = BLANK;
+
+  board0[0][0] = WHITE;
+  board0[0][SIZE - 1] = BLACK;
+  board0[SIZE - 1][0] = BLACK;
+  board0[SIZE - 1][SIZE - 1] = WHITE;
+
+  vpointer = 0;
+  move_count = 0;
+  whose_turn = WHITE;
+  bcount = 2;
+  wcount = 2;
 }
 
-/* makes a move which is not completely dumb, but not as hard as the move with
- * the highest heuristic value
- */
-static move
-computer_move_easy (GtkGridBoard * gridboard, int turn)
+gboolean
+is_valid (gint ox, gint oy, gint nx, gint ny)
 {
-  move *pm;
-  move bm = { {0, 0, 0}, {0, 0, 0} };
-  int i, size, h, maxh = -100;
-  steps = 0;
-
-  pm = get_possible_moves (gridboard, turn);
-  size = get_possible_moves_size (pm);
-  for (i = 0; i < size; i += 5) {
-    gtk_gridboard_save_state (gridboard, NULL);
-    gridboard_move (gridboard, pm[i]);
-    h = gtk_gridboard_count_pieces (gridboard, turn);
-    gtk_gridboard_revert_state (gridboard);
-    if (h > maxh) {
-      maxh = h;
-      bm = pm[i];
-    }
-  }
-  free_possible_moves (pm);
-  return bm;
+  if (ox < 0 || ox > SIZE - 1 || nx < 0 || nx > SIZE - 1)
+    return FALSE;
+  if (board0[oy][ox] != (gint8) whose_turn)
+    return FALSE;
+  if (board0[ny][nx] != BLANK)
+    return FALSE;
+  if (ox - nx > 2 || ox - nx < -2 || oy - ny > 2 || oy - ny < -2)
+    return FALSE;
+  return TRUE;
 }
 
-/* decides which move to take with alphabeta algorithm
- * @param turn  the current player
- * @param depth the maximum search depth in the tree
- * @return the chosen move
- */
-static move
-computer_move_ab (GtkGridBoard * gridboard, int turn, int depth)
+void
+move_board (gint ox, gint oy, gint nx, gint ny)
 {
-  move *pm;			/* possible moves */
-  move bm = { {0, 0, 0}, {0, 0, 0} };	/* best move */
-  move *gm;			/* good moves */
-  int i, pmsize, gmsize = 0;
-  int h, maxh = -100;		/* heuristic values */
-  steps = 0;			/* FIXME: debug var */
-
-  pm = get_possible_moves (gridboard, turn);
-  pmsize = get_possible_moves_size (pm);
-  gm = calloc (pmsize, sizeof (move));
-  for (i = 0; i < pmsize; i++) {
-    gtk_gridboard_save_state (gridboard, NULL);
-    gridboard_move (gridboard, pm[i]);
-    h = alphabeta (gridboard, -100, 100, FALSE, turn, depth);
-    gtk_gridboard_revert_state (gridboard);
-    if (h > maxh) {
-      maxh = h;
-      gmsize = 0;
-      gm[gmsize++] = pm[i];
-    } else if (h == maxh) {
-      gm[gmsize++] = pm[i];
-    }
-  }
-  free_possible_moves (pm);
-
-  i = g_random_int_range (0, gmsize);
-  bm = gm[i];
-  free (gm);
-  return bm;
+  gint i, j;
+  gint count = 0, stat = 0, not_me = OTHER_PLAYER (whose_turn);
 
+  if (!is_valid (ox, oy, nx, ny))
+    return;
+
+  for (i = ny - 1; i <= ny + 1; i++)
+    {
+      for (j = nx - 1; j <= nx + 1; j++)
+	{
+	  if (i >= 0 && i <= SIZE - 1 && j >= 0 && j <= SIZE - 1)
+	    {
+	      if (board0[i][j] == (gint8) whose_turn)
+		stat = 1;
+	      else if (board0[i][j] == (gint8) not_me)
+		{
+		  board0[i][j] = (gint8) whose_turn;
+		  count++;
+		  history[move_count][4 + count] = i * SIZE + j;
+		}
+	    }
+	}
+    }
+  board0[ny][nx] = (gint8) whose_turn;
+  if (!stat)
+    board0[oy][ox] = BLANK;
+  history[move_count][0] = whose_turn;
+  history[move_count][1] = oy * SIZE + ox;
+  history[move_count][2] = ny * SIZE + nx;
+  history[move_count][3] = stat;
+  history[move_count][4] = count;
+  if (whose_turn == BLACK)
+    {
+      bcount += count + stat;
+      wcount -= count;
+    }
+  else
+    {
+      wcount += count + stat;
+      bcount -= count;
+    }
+  move_count++;
+  whose_turn = OTHER_PLAYER (whose_turn);
 }
 
-/* this function gets called from gataxx */
-move
-computer_move (GtkGridBoard * gridboard, int turn)
+/* Back to before board0 */
+void
+back (void)
 {
-  int level = props_get_level (turn);
-  move ai_move;
-
-  gtk_gridboard_set_visibility (gridboard, FALSE);
-
-  if (level == 1) {
-    ai_move = computer_move_random (gridboard, turn);
-  } else if (level == 2) {
-    ai_move = computer_move_easy (gridboard, turn);
-  } else {
-    ai_move = computer_move_ab (gridboard, turn, level - 3);
-  }
+  gint o_yx, n_yx;
+  gint count, not_me, stat;
 
-  gtk_gridboard_set_visibility (gridboard, TRUE);
+  move_count--;
+  whose_turn = history[move_count][0];
+  o_yx = history[move_count][1];
+  n_yx = history[move_count][2];
+  stat = history[move_count][3];
+  count = history[move_count][4];
+
+  if (whose_turn == WHITE)
+    {
+      wcount -= count + stat;
+      bcount += count;
+    }
+  else
+    {
+      bcount -= count + stat;
+      wcount += count;
+    }
 
-  return ai_move;
+  board0[n_yx / SIZE][n_yx % SIZE] = BLANK;
+  if (!stat)
+    board0[o_yx / SIZE][o_yx % SIZE] = (gint8) whose_turn;
+  not_me = OTHER_PLAYER (whose_turn);
+  while (count > 0)
+    {
+      o_yx = history[move_count][4 + count];
+      board0[o_yx / SIZE][o_yx % SIZE] = (gint8) not_me;
+      count--;
+    }
 }
 
-/* alphabeta search the possible moves */
-static int
-alphabeta (GtkGridBoard * gridboard, int alpha, int beta, int mode, int me,
-	   int depth)
+static gint
+entry_valid_movement (void)
 {
-  move *pm;
-  int size, i, h;
-  int notme = (me == WHITE ? BLACK : WHITE);
-  int mec, notmec;
-
-  steps++;
-
-  if (depth == 0) {
-    mec = gtk_gridboard_count_pieces (GTK_GRIDBOARD (gridboard), me);
-    if (mec == 0)
-      return -50;
-    notmec = gtk_gridboard_count_pieces (GTK_GRIDBOARD (gridboard), notme);
-    if (notmec == 0)
-      return 50;
-    return mec;			/* -notmec; */
-  }
-  if (mode) {			/* max */
-    pm = get_possible_moves (gridboard, me);
-    size = get_possible_moves_size (pm);
-    for (i = 0; i < size; i++) {
-      gtk_gridboard_save_state (GTK_GRIDBOARD (gridboard), NULL);
-      gridboard_move (gridboard, pm[i]);
-      h = alphabeta (gridboard, alpha, beta, !mode, me, depth - 1);
-      if (h > alpha)
-	alpha = h;
-      gtk_gridboard_revert_state (GTK_GRIDBOARD (gridboard));
-      if (alpha > beta)
-	break;
-    }
-    free_possible_moves (pm);
-    return alpha;
-  } else {
-    pm = get_possible_moves (gridboard, notme);
-    size = get_possible_moves_size (pm);
-    for (i = 0; i < size; i++) {
-      gtk_gridboard_save_state (GTK_GRIDBOARD (gridboard), NULL);
-      gridboard_move (gridboard, pm[i]);
-      h = alphabeta (gridboard, alpha, beta, !mode, me, depth - 1);
-      if (h < beta)
-	beta = h;
-      gtk_gridboard_revert_state (GTK_GRIDBOARD (gridboard));
-      if (alpha > beta)
-	break;
-    }
-    free_possible_moves (pm);
-    return beta;
-  }
-}
+  gint ox, oy, nx, ny;
+  gint j;
 
-/* returns possible moves
- * The less moves this returns, the faster the search algorithm will work.
- * Therefore, this does not really return _all_ possible moves.
- */
-static move *
-get_possible_moves (GtkGridBoard * gridboard, int turn)
-{
-  int x, y, i = 0;
-  move *pm;
-  move bm;
-
-  pm = calloc (sizeof (move), BWIDTH * BHEIGHT);
-  for (x = 0; x < BWIDTH; x++) {
-    for (y = 0; y < BHEIGHT; y++) {
-      bm = get_best_move_to (gridboard, x, y, turn);
-      if (bm.from.valid)
-	pm[i++] = bm;
-    }
-  }
-  pm[0].from.valid = i;
-  return pm;
+  j = vpointer;
+  for (oy = 0; oy < SIZE; oy++)
+    {
+      for (ox = 0; ox < SIZE; ox++)
+	{
+	  for (ny = oy - 2; ny <= oy + 2; ny++)
+	    {
+	      if (ny >= 0 && ny <= SIZE - 1)
+		for (nx = ox - 2; nx <= ox + 2; nx++)
+		  {
+		    if (nx >= 0 && nx <= SIZE - 1)
+		      {
+			if (is_valid (ox, oy, nx, ny))
+			  {
+			    j++;
+			    vsquares[j][1] = oy * SIZE + ox;
+			    vsquares[j][2] = ny * SIZE + nx;
+			    move_board (ox, oy, nx, ny);
+			    if (whose_turn == WHITE)
+			      vsquares[j][0] = wcount - bcount;
+			    else
+			      vsquares[j][0] = bcount - wcount;
+			    back ();
+			  }
+		      }
+		  }
+	    }
+	}
+    }
+  return j;
 }
 
-static int
-get_possible_moves_size (move * pm)
+gboolean
+is_game_over (void)
 {
-  return pm[0].from.valid;
+  if (entry_valid_movement () == vpointer)
+    return TRUE;
+  return FALSE;
 }
 
+/* Sort vsquares by small order */
 static void
-free_possible_moves (move * pm)
+sort (guint l, guint r)
 {
-  free (pm);
+  guint i, j;
+  gint u, v, w, x;
+
+  i = l;
+  j = r;
+  x = vsquares[(l + r) / 2][0];
+  do
+    {
+      while (vsquares[i][0] < x)
+	i++;
+      while (x < vsquares[j][0])
+	j--;
+      if (i < j)
+	{
+	  u = vsquares[i][0];
+	  v = vsquares[i][1];
+	  w = vsquares[i][2];
+	  vsquares[i][0] = vsquares[j][0];
+	  vsquares[i][1] = vsquares[j][1];
+	  vsquares[i][2] = vsquares[j][2];
+	  vsquares[j][0] = u;
+	  vsquares[j][1] = v;
+	  vsquares[j][2] = w;
+	}
+      if (i <= j)
+	{
+	  i++;
+	  j--;
+	}
+    }
+  while (i <= j);
+
+  if (l < j)
+    sort (l, j);
+  if (i < r)
+    sort (i, r);
 }
 
-/* only thing to make sure the returned move is the "best" move is to
- * prioritize normal moves over jumps
- */
-static move
-get_best_move_to (GtkGridBoard * gridboard, int x, int y, int me)
+/* alpha-beta search */
+static gint
+search (guint n, gint a, gint b)
 {
-  move bm;
-  int _x, _y, piece;
+  gint ox, oy, nx, ny;
+  gint aa, bb;
+  gint i, j;
+
+  if (!n)			/* end ? */
+    {
+      if (whose_turn == WHITE)
+	return wcount - bcount;
+      return bcount - wcount;
+    }
 
-  bm.from.x = bm.from.y = bm.from.valid = bm.to.x = bm.to.y = bm.to.valid = 0;
-  if (gtk_gridboard_get_piece (gridboard, x, y) != EMPTY)
-    return bm;
-
-  /* search for normal moves */
-  for (_x = MAX (0, x - 1); _x < MIN (BWIDTH, x + 2); _x++) {
-    for (_y = MAX (0, y - 1); _y < MIN (BHEIGHT, y + 2); _y++) {
-      piece = gtk_gridboard_get_piece (gridboard, _x, _y);
-      if (piece == me) {
-	bm.from.x = _x;
-	bm.from.y = _y;
-	bm.from.valid = TRUE;
-	bm.to.x = x;
-	bm.to.y = y;
-	bm.to.valid = TRUE;
-	return bm;
-      }
-    }
-  }
-
-  /* search for jumps also */
-  for (_x = MAX (0, x - 2); _x < MIN (BWIDTH, x + 3); _x++) {
-    for (_y = MAX (0, y - 2); _y < MIN (BHEIGHT, y + 3); _y++) {
-      piece = gtk_gridboard_get_piece (gridboard, _x, _y);
-      if (piece == me) {
-	bm.from.x = _x;
-	bm.from.y = _y;
-	bm.from.valid = TRUE;
-	bm.to.x = x;
-	bm.to.y = y;
-	bm.to.valid = TRUE;
-	return bm;
-      }
+  aa = a;
+  j = entry_valid_movement ();
+  if (j == vpointer)		/* end ? */
+    {
+      aa = wcount - bcount;
+      if (whose_turn == BLACK)
+	aa = -aa;
+      if (aa > 0)
+	return aa + 1000;
+      if (aa < 0)
+	return aa - 1000;
+      return 0;
     }
-  }
 
-  return bm;
+  sort (vpointer + 1, j);	/* sort vsquares    */
+  i = vpointer;			/* save vpointer    */
+  vpointer = j + 1;		/* new vpointer     */
+
+  j = i + 1;
+  while (aa < b && j < vpointer)	/* evaluate squares */
+    {
+      oy = vsquares[j][1] / SIZE;
+      ox = vsquares[j][1] % SIZE;
+      ny = vsquares[j][2] / SIZE;
+      nx = vsquares[j][2] % SIZE;
+      move_board (ox, oy, nx, ny);
+      bb = -search (n - 1, -b, -aa);
+      back ();
+      if (aa < bb)
+	{
+	  aa = bb;
+	  vsquares[i][1] = vsquares[j][1];
+	  vsquares[i][2] = vsquares[j][2];
+	}
+      j++;
+    }
+  vpointer = i;			/* pop vpointer      */
+  return aa;
+}
+
+static gint
+random_select (void)
+{
+  guint i, j;
+
+  j = entry_valid_movement ();
+  i = vpointer + 1;
+  if (j > i)
+    i = g_rand_int_range (rgen, i, j + 1);
+  vsquares[0][1] = vsquares[i][1];
+  vsquares[0][2] = vsquares[i][2];
+  return 0;
+}
+
+void
+computer_move (gint level, gint * ox, gint * oy, gint * nx, gint * ny)
+{
+  if (move_count < RANDOM)
+    vsquares[0][0] = random_select ();
+  else if (move_count < RANDOM * 3)
+    vsquares[0][0] = search (level + 1, -32767, 32767);
+  else if (SIZE * SIZE - bcount - wcount < level * 3)
+    vsquares[0][0] = search (level + 2, -32767, 32767);
+  else
+    vsquares[0][0] = search (level, -32767, 32767);
+
+  *ox = vsquares[0][1] % SIZE;
+  *oy = vsquares[0][1] / SIZE;
+  *nx = vsquares[0][2] % SIZE;
+  *ny = vsquares[0][2] / SIZE;
 }
Index: gnome-games/gataxx/ai.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/ai.h,v
retrieving revision 1.4
diff -u -r1.4 ai.h
--- gnome-games/gataxx/ai.h	3 Oct 2006 20:57:24 -0000	1.4
+++ gnome-games/gataxx/ai.h	5 Oct 2006 12:15:08 -0000
@@ -1,6 +1,6 @@
-/* 
- * ai.c - Artificial intelligence
- * 
+/*
+ * ai.h
+ *
  * 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
@@ -18,9 +18,27 @@
  * For more details see the file COPYING.
  */
 
-#ifndef AI_H
-#define AI_H
+#define SIZE            7
+#define RANDOM		    4
+#define MAX_DEPTH	    5
+#define MAX_MOVE_COUNT	105
+#define MAX_VPOINTER	MAX_DEPTH * 120
+
+#define BLACK		    1
+#define WHITE		    31
+#define BLANK		    127
+
+#define OUTSIDE (BLACK + WHITE)
+#define OTHER_PLAYER(who) (OUTSIDE - who)
+
+void init (void);
+
+gboolean is_valid (gint ox, gint oy, gint nx, gint ny);
+
+void move_board (gint ox, gint oy, gint nx, gint ny);
+
+void back (void);
 
-move computer_move (GtkGridBoard * gridboard, int turn);
+gboolean is_game_over (void);
 
-#endif /* AI_H */
+void computer_move (gint level, gint *ox, gint *oy, gint *nx, gint *ny);
Index: gnome-games/gataxx/gataxx.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/gataxx.c,v
retrieving revision 1.73
diff -u -r1.73 gataxx.c
--- gnome-games/gataxx/gataxx.c	3 Oct 2006 20:57:24 -0000	1.73
+++ gnome-games/gataxx/gataxx.c	5 Oct 2006 12:15:08 -0000
@@ -1,7 +1,6 @@
-/* (C) 2003/2004 Sjoerd Langkemper
- * (C) 1999-2003 Chris Rogers
- * gataxx.c -
- * 
+/*
+ * gataxx.c
+ *
  * 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
@@ -19,409 +18,494 @@
  * For more details see the file COPYING.
  */
 
+#define GATAXX  1
 
 #include "config.h"
-#include <gdk/gdkkeysyms.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include <sys/time.h>
-#include <string.h>
+#include <gnome.h>
+#include <glib.h>
 #include <gconf/gconf-client.h>
-#include <games-gconf.h>
-#include <games-gridframe.h>
-#include <games-stock.h>
-#include <libintl.h>
-#include <libgnome/libgnome.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "games-stock.h"
 
-#include "gtkgridboard.h"
+#include "ai.h"
 #include "properties.h"
 #include "gataxx.h"
-#include "menus.h"
-#include "appbar.h"
-#include "ai.h"
 
-#define GCONF_WINDOW_WIDTH "/apps/gataxx/width"
-#define GCONF_WINDOW_HEIGHT "/apps/gataxx/height"
+guint8 kifu[MAX_MOVE_COUNT][3];
+static gint old_x = -1;
+static gint old_y = -1;
+static guint t_black_computer_level;
+static guint t_white_computer_level;
+static guint computer_id = 0;
+static guint computer_id1 = 0;
+
+
+extern gint8 pixmaps[8][8];
+extern gint8 board[8][8];
+
+extern GtkWidget *window;
+extern GtkWidget *file_open_dialog;
+extern GtkWidget *file_save_dialog;
+extern GtkWidget *counter;
+extern GtkWidget *score[4];
+extern GtkWidget *entry;
+extern GTimer *b_timer;
+extern GTimer *w_timer;
+
+extern guint black_computer_level;
+extern guint white_computer_level;
+extern gboolean flip_final;
+extern guint computer_speed;
+extern guint tile_width;
+extern guint tile_height;
+extern gboolean game_in_progress;
+extern gboolean gameover;
+extern guint flip_final_id;
+extern gboolean flip_tiles;
+extern gboolean play_sound;
+extern guint t_move_count;
+extern guint t_whose_turn;
+extern guint t_bcount;
+extern guint t_wcount;
+
+extern gint8 board0[SIZE][SIZE];
+extern gint vsquares[MAX_VPOINTER][3];
+extern guint move_count;
+extern guint whose_turn;
+extern guint bcount;
+extern guint wcount;
 
-GtkGridBoard *gridboard;	/* current gridboard */
-GtkWidget *window;		/* The apps main window. */
-gint turn;			/* current player */
-position selection = { 0, 0, 0 };	/* last selected position */
-int timeout;			/* computer speed */
-
-GnomeProgram *program;
-
-/* Command-line handling. */
-static gint iturn = 1;
-static gchar *state = NULL;
-
-static const GOptionEntry options[] = {
-  {"state", 's', 0, G_OPTION_ARG_STRING, &state,
-   N_("Set the state of the board at start-up."), N_("STATE")},
-  {"turn", 't', 0, G_OPTION_ARG_INT, &iturn,
-   N_("Set whose turn it is."), N_("1 (Light) or 2 (Dark)")},
-  {NULL}
-};
 
-/* gettext i18n stuff */
 static void
-settextdomain ()
+copy_board (void)
 {
-  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
+  guint i, j;
+
+  for (i = 0; i < SIZE; i++)
+    for (j = 0; j < SIZE; j++)
+      board[i][j] = board0[i][j];
+
+  t_move_count = move_count;
+  t_whose_turn = whose_turn;
+  t_bcount = bcount;
+  t_wcount = wcount;
 }
 
-/* returns true if at least one move is possible for player /turn/ */
-gboolean
-move_possible (GtkGridBoard * gridboard, int turn)
+static void
+gui_hint (gint oyx, gint nyx, gint score)
 {
-  int x, y;
-  gboolean mov;
+  gchar message[16];
 
-  for (x = 0; x < BWIDTH; x++) {
-    for (y = 0; y < BHEIGHT; y++) {
-      mov = move_possible_to (gridboard, x, y, turn);
-      if (mov) {
-	return TRUE;
-      }
-    }
-  }
-  return FALSE;
+  message[0] = (gchar) (oyx % SIZE + 0x41);
+  message[1] = (gchar) (oyx / SIZE + 0x31);
+  message[2] = 0x2D;
+  message[3] = (gchar) (nyx % SIZE + 0x41);
+  message[4] = (gchar) (nyx / SIZE + 0x31);
+  message[5] = 0x20;
+  sprintf (&message[6], _("%d"), score);
+
+  gui_entry (message);
 }
 
-/* returns true if a move is possible to (x, y) */
-gboolean
-move_possible_to (GtkGridBoard * gridboard, int x, int y, int turn)
+static gboolean
+check_game_over (void)
 {
-  int piece, _x, _y;
-  if (gtk_gridboard_get_piece (gridboard, x, y) != EMPTY)
-    return FALSE;
-  for (_x = MAX (0, x - 2); _x < MIN (BWIDTH, x + 3); _x++) {
-    for (_y = MAX (0, y - 2); _y < MIN (BHEIGHT, y + 3); _y++) {
-      piece = gtk_gridboard_get_piece (gridboard, _x, _y);
-      if (piece == turn)
-	return TRUE;
+  if (!is_game_over ())
+    {
+      if (whose_turn == BLACK)
+	{
+	  gui_message ("Dark's move");
+	  if (game_in_progress)
+	    g_timer_continue (b_timer);
+	}
+      else if (whose_turn == WHITE)
+	{
+	  gui_message ("Light's move");
+	  if (game_in_progress)
+	    g_timer_continue (w_timer);
+	}
+      return FALSE;
     }
-  }
-  return FALSE;
+
+  if (wcount > bcount)
+    gui_message ("Light player wins!");
+  if (bcount > wcount)
+    gui_message ("Dark player wins!");
+  if (wcount == bcount)
+    gui_message ("The game was a draw.");
+
+  if (flip_final)
+    flip_final_id = g_timeout_add (computer_speed, flip_final_results, NULL);
+
+  whose_turn = 0;
+  t_whose_turn = 0;
+  game_in_progress = FALSE;
+  gameover = TRUE;
+  return TRUE;
 }
 
-/* after a move is done, a timeout is set on this function */
-gboolean
-computer_move_cb (gpointer turn)
+static gboolean
+t_computer_move (gpointer level)
 {
-  move cm;
+  gint ox, oy, nx, ny;
 
-  /* In case the level gets changed between the timeout
-   * being set and it going off. */
-  if (props_get_level (GPOINTER_TO_INT (turn)) < 1)
-    return FALSE;
-
-  cm = computer_move (gridboard, GPOINTER_TO_INT (turn));
-  do_move (cm);
+  computer_move (GPOINTER_TO_INT (level), &ox, &oy, &nx, &ny);
+  if (game_in_progress)
+    move (whose_turn, ox, oy, nx, ny);
+  computer_id = 0;
   return FALSE;
 }
 
-/* gets called when the user clicks with the mouse */
-void
-boxclicked_cb (GtkWidget * widget, int x, int y)
+static gboolean
+check_computer_players (void)
 {
-  int dist = MAX (ABS (selection.x - x), ABS (selection.y - y));
-  int piece = gtk_gridboard_get_piece (gridboard, x, y);
-  move m = { {selection.x, selection.y, selection.valid}, {x, y, TRUE} };
+  guint level = 0;
 
-  if (!props_is_human (turn))
-    return;
-
-  if ((selection.valid) && (piece == EMPTY) && (dist <= 2)) {
-    dist = MAX (ABS (selection.x - x), ABS (selection.y - y));
-    do_move (m);
-    selection.valid = FALSE;
-  } else if (piece == turn) {
-    do_select (x, y);
-    selection.x = x;
-    selection.y = y;
-    selection.valid = TRUE;
-  }
+  if (computer_id)
+    {
+      g_source_remove (computer_id);
+      computer_id = 0;
+    }
 
-  gtk_gridboard_paint (gridboard);
+  if (black_computer_level && t_whose_turn == BLACK)
+    level = black_computer_level;
+  else if (white_computer_level && t_whose_turn == WHITE)
+    level = white_computer_level;
+  if (level)
+    {
+      gui_entry ("Now thinking.");
+      computer_id = g_timeout_add (computer_speed,
+				   (GSourceFunc) t_computer_move,
+				   GINT_TO_POINTER (level));
+    }
+  return FALSE;
 }
 
-/* sets pieces, adds undo info, changes statusbar and changes turn */
-void
-do_move (move m)
+static gboolean
+check_computer_level_changed (gpointer user_data)
 {
-  /* undo info */
-  if (props_is_human (turn)) {
-    gtk_gridboard_save_state (gridboard, GINT_TO_POINTER (turn));
-  }
-  if (gtk_gridboard_states_present (gridboard)) {
-    menu_undo_set_sensitive (TRUE);
-  } else {
-    menu_undo_set_sensitive (FALSE);
-  }
-
-
-  gtk_gridboard_clear_selections (GTK_GRIDBOARD (gridboard));
-  gridboard_move (gridboard, m);
-
-  appbar_set_white (gtk_gridboard_count_pieces
-		    (GTK_GRIDBOARD (gridboard), WHITE));
-  appbar_set_black (gtk_gridboard_count_pieces
-		    (GTK_GRIDBOARD (gridboard), BLACK));
+  if (!game_in_progress)
+    return TRUE;
+  if (t_black_computer_level == black_computer_level
+      && t_white_computer_level == white_computer_level)
+    return TRUE;
+
+  t_black_computer_level = black_computer_level;
+  t_white_computer_level = white_computer_level;
+  check_computer_players ();
 
-  turn = turn == BLACK ? WHITE : BLACK;
-  appbar_set_turn (turn);
+  return TRUE;
+};
 
-  if (!move_possible (gridboard, turn)) {
-    g_timeout_add (timeout, end_game_cb, GINT_TO_POINTER (turn));
-    return;
-  }
+static void
+set_computerid1 (void)
+{
+  computer_id1 = g_timeout_add (500,
+				(GSourceFunc) check_computer_level_changed,
+				NULL);
+};
 
-  if (!props_is_human (turn)) {
-    g_timeout_add (timeout, computer_move_cb, GINT_TO_POINTER (turn));
-  }
+static gboolean
+check_valid_move (gint who, gint ox, gint oy, gint nx, gint ny)
+{
+  if (!game_in_progress)
+    return FALSE;
+  if (who != whose_turn)
+    return FALSE;
+  if (ox < 0 || ox > SIZE - 1 || oy < 0 || oy > SIZE - 1
+      || nx < 0 || nx > SIZE - 1 || ny < 0 || ny > SIZE - 1)
+    return FALSE;
 
+  return is_valid (ox, oy, nx, ny);
 }
 
-/* game over */
 gboolean
-end_game_cb (gpointer data)
+move (gint who, gint ox, gint oy, gint nx, gint ny)
 {
-  int wc = gtk_gridboard_count_pieces (gridboard, WHITE);
-  int bc = gtk_gridboard_count_pieces (gridboard, BLACK);
+  if (!check_valid_move (who, ox, oy, nx, ny))
+    return FALSE;
+  if (game_in_progress)
+    {
+      kifu[move_count][0] = whose_turn;
+      kifu[move_count][1] = oy * SIZE + ox;
+      kifu[move_count][2] = ny * SIZE + nx;
+      kifu[move_count + 1][0] = 0;
+      if (whose_turn == BLACK)
+	g_timer_stop (b_timer);
+      else
+	g_timer_stop (w_timer);
+    }
 
-  turn = EMPTY;
+  move_board (ox, oy, nx, ny);
 
-  if (wc > bc) {
-    appbar_set_status (_("Light player wins!"));
-  } else if (wc < bc) {
-    appbar_set_status (_("Dark player wins!"));
-  } else {
-    appbar_set_status (_("The game was a draw."));
-  }
+  if (move_count >= MAX_MOVE_COUNT - MAX_DEPTH)
+    {
+      gui_message ("Count overflow!");
+      game_in_progress = FALSE;
+      return FALSE;
+    }
 
-  flip_final (gridboard, wc, bc);
-  gtk_gridboard_paint (gridboard);
+  old_x = -1;
+  old_y = -1;
+  gui_entry (" ");
+  gtk_entry_set_position ((GtkEntry *) entry, 0);
+  copy_board ();
+  gui_status ();
+  flip_tiles = TRUE;
+  play_sound = TRUE;
+  check_game_over ();
+  if (game_in_progress)
+    return check_computer_players ();
 
-  return FALSE;			/* kill the timeout */
+  return FALSE;
 }
 
-/* makes an overview of all the pieces on the board at the end of the game */
 void
-flip_final (GtkGridBoard * gridboard, int wc, int bc)
+init_new_game (void)
 {
-  int x, y, piece = EMPTY;
-  int ec = BWIDTH * BHEIGHT - wc - bc;
-
-  for (y = 0; y < BWIDTH; y++) {
-    for (x = 0; x < BHEIGHT; x++) {
-      if (wc) {
-	piece = WHITE;
-	wc--;
-      } else if (ec) {
-	piece = EMPTY;
-	ec--;
-      } else if (bc) {
-	piece = BLACK;
-	bc--;
-      }
-      gtk_gridboard_set_piece (gridboard, x, y, piece);
+  if (flip_final_id)
+    {
+      g_source_remove (flip_final_id);
+      flip_final_id = 0;
     }
-  }
+  if (computer_id)
+    {
+      g_source_remove (computer_id);
+      computer_id = 0;
+    }
+
+  kifu[0][0] = 0;
+  init ();
+  copy_board ();
+  redraw_board ();
+  game_in_progress = TRUE;
+  g_timer_stop (b_timer);
+  g_timer_reset (b_timer);
+  g_timer_stop (w_timer);
+  g_timer_reset (w_timer);
+  gui_timer ();
+  timer_start ();
+  check_game_over ();
+  check_computer_players ();
 }
 
-/* changes the pieces on the board */
-void
-gridboard_move (GtkGridBoard * gridboard, move m)
+static void
+on_new_game_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  int dist;
-  int piece = gtk_gridboard_get_piece (gridboard, m.from.x, m.from.y);
-  dist = MAX (ABS (m.from.x - m.to.x), ABS (m.from.y - m.to.y));
-  if (dist == 1) {
-    gtk_gridboard_set_piece (gridboard, m.to.x, m.to.y, piece);
-  } else if (dist == 2) {
-    gtk_gridboard_set_piece (gridboard, m.to.x, m.to.y, piece);
-    gtk_gridboard_set_piece (gridboard, m.from.x, m.from.y, EMPTY);
-  } else {
-    return;
-  }
-  turn_pieces (gridboard, m.to.x, m.to.y);
+  init_new_game ();
 }
 
-/* turn all surrounding pieces */
-void
-turn_pieces (GtkGridBoard * gridboard, int x, int y)
+static void
+on_sync_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  int me, _x, _y, piece;
-  me = gtk_gridboard_get_piece (gridboard, x, y);
-  for (_x = MAX (0, x - 1); _x < MIN (BWIDTH, x + 2); _x++) {
-    for (_y = MAX (0, y - 1); _y < MIN (BHEIGHT, y + 2); _y++) {
-      piece = gtk_gridboard_get_piece (gridboard, _x, _y);
-      if ((piece != EMPTY) && (piece != me)) {
-	gtk_gridboard_set_piece (gridboard, _x, _y, me);
-      }
-    }
-  }
 }
 
-/* selects (x, y) and all surrounding boxes */
-void
-do_select (int x, int y)
+static void
+on_again_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  int _x, _y;
+}
 
-  gtk_gridboard_clear_selections (gridboard);
-  for (_x = MAX (0, x - 2); _x < MIN (BWIDTH, x + 3); _x++) {
-    for (_y = MAX (0, y - 2); _y < MIN (BHEIGHT, y + 3); _y++) {
-      if (gtk_gridboard_get_piece (gridboard, _x, _y) == EMPTY) {
-	gtk_gridboard_set_selection (gridboard, SELECTED_A, _x, _y);
-      }
-    }
-  }
-  gtk_gridboard_set_selection (gridboard, SELECTED_B, x, y);
+static void
+on_redo_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  if (game_in_progress)
+    return;
+  if (move_count < 0)
+    return;
+  if (is_game_over ())
+    return;
+
+  game_in_progress = TRUE;
+  kifu[move_count][0] = 0;
+  check_game_over ();
+  check_computer_players ();
 }
 
-/* Restore the state of the board from the command line. */
 static void
-restore_state (void)
+on_hint_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  int i, j;
+  gint ox, oy, nx, ny;
 
-  gtk_gridboard_clear (gridboard);
+  if (move_count < 0)
+    return;
+  if (is_game_over ())
+    return;
+
+  computer_move (MAX_DEPTH, &ox, &oy, &nx, &ny);
+  gui_hint (oy * SIZE + ox, ny * SIZE + nx, vsquares[0][0]);
+}
+
+static gboolean
+check_back (void)
+{
+  if (flip_final_id)
+    {
+      g_source_remove (flip_final_id);
+      flip_final_id = 0;
+    }
+  if (game_in_progress)
+    {
+      game_in_progress = FALSE;
+      if (whose_turn == BLACK)
+	g_timer_stop (b_timer);
+      else
+	g_timer_stop (w_timer);
+    }
+  return TRUE;
+}
 
-  if (!state)
+static void
+on_head_button_clicked (GtkToolButton * toolbutton, gpointer user_data)
+{
+  if (!check_back ())
     return;
 
-  for (j = 0; j < BHEIGHT; j++) {
-    for (i = 0; i < BWIDTH; i++) {
-      if (*state == '\0')
-	return;
-      switch (*state) {
-      case '1':
-	gtk_gridboard_set_piece (gridboard, i, j, WHITE);
-	break;
-      case '2':
-	gtk_gridboard_set_piece (gridboard, i, j, BLACK);
-	break;
-      }
-      state++;
-    }
-  }
-}
-
-/* This handles both games loaded off the command line and proper new games. */
-static void
-new_game (void)
-{
-  gboolean boardok = FALSE;
-
-  if (state) {
-    restore_state ();
-    state = NULL;
-    boardok = (gtk_gridboard_count_pieces (gridboard, WHITE) > 0) &&
-      (gtk_gridboard_count_pieces (gridboard, BLACK) > 0);
-  }
-  if (!boardok) {
-    gtk_gridboard_clear (gridboard);
-
-    gtk_gridboard_set_piece (gridboard, 0, 0, WHITE);
-    gtk_gridboard_set_piece (gridboard, 0, 6, BLACK);
-    gtk_gridboard_set_piece (gridboard, 6, 0, BLACK);
-    gtk_gridboard_set_piece (gridboard, 6, 6, WHITE);
-  }
-
-  if (iturn != WHITE) {
-    turn = BLACK;
-    iturn = WHITE;
-  } else {
-    turn = WHITE;
-  }
-
-  appbar_set_turn (turn);
-  appbar_set_white (gtk_gridboard_count_pieces (gridboard, WHITE));
-  appbar_set_black (gtk_gridboard_count_pieces (gridboard, BLACK));
-
-  if (!props_is_human (turn)) {
-    g_timeout_add (timeout, computer_move_cb, GINT_TO_POINTER (turn));
-  }
+  init ();
+  copy_board ();
+  redraw_board ();
+  check_game_over ();
 }
 
-/* menu: Game->New game */
-void
-new_game_cb (GtkWidget * widget, gpointer data)
+static void
+read_kifu (int fd)
 {
-  new_game ();
-  gtk_gridboard_paint (gridboard);
+  gchar buf[12];
+  gint i = 0;
+  ssize_t err;
+
+  err = read (fd, buf, 7);
+  buf[7] = 0;
+  if (!g_str_equal (buf, _("gataxx\n")))
+    {
+      gui_message (_("not gataxx's file"));
+      return;
+    }
+  err = read (fd, buf, 11);
+  while (err > 0)
+    {
+      i = (gint) ((buf[0] - 0x30) * 10 + buf[1] - 0x30 - 1);
+      kifu[i][0] = (buf[3] == 0x42) ? BLACK : WHITE;
+      kifu[i][1] = (gint) ((buf[6] - 0x31) * 7 + buf[5] - 0x41);
+      kifu[i][2] = (gint) ((buf[9] - 0x31) * 7 + buf[8] - 0x41);
+      err = read (fd, buf, 11);
+    }
+  kifu[i + 1][0] = 0;
 }
 
+static void
+on_open_clicked (GtkButton * button, gpointer user_data)
+{
+  gchar *filename;
+  int fd;
+
+  filename =
+    gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_open_dialog));
+  fd = open (filename, 0, 0644);
+  if (fd)
+    {
+      read_kifu (fd);
+      close (fd);
+    }
+  gtk_widget_destroy (file_open_dialog);
+  g_free (filename);
+  on_head_button_clicked (NULL, NULL);
+}
 
-/* menu: Game->Undo move */
-void
-undo_move_cb (GtkWidget * widget, gpointer data)
+static void
+on_open_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_gridboard_states_present (gridboard)) {
-    turn = GPOINTER_TO_INT (gtk_gridboard_revert_state (gridboard));
-  }
-  if (gtk_gridboard_states_present (gridboard)) {
-    menu_undo_set_sensitive (TRUE);
-  } else {
-    menu_undo_set_sensitive (FALSE);
-  }
-  if (!props_is_human (turn)) {
-    g_timeout_add (timeout, computer_move_cb, GINT_TO_POINTER (turn));
-  }
-  selection.valid = FALSE;
-  appbar_set_turn (turn);
-  appbar_set_white (gtk_gridboard_count_pieces (gridboard, WHITE));
-  appbar_set_black (gtk_gridboard_count_pieces (gridboard, BLACK));
-  gtk_gridboard_paint (gridboard);
+  game_in_progress = FALSE;
+  g_timer_stop (b_timer);
+  g_timer_stop (w_timer);
+  g_timer_reset (b_timer);
+  g_timer_reset (w_timer);
+  gui_timer ();
+  kifu[0][0] = 0;
+  file_open_dialog =
+    create_file_open_dialog ((GtkSignalFunc *) on_open_clicked);
+  gtk_widget_show (file_open_dialog);
 }
 
-/* menu: Game->Quit */
-gboolean
-quit_game_cb (GtkWidget * widget, gpointer data)
+static void
+write_kifu (int fd)
 {
-  gtk_main_quit ();
+  gchar buf[12] = { 0, 0, 0x20, 0, 0x20, 0, 0, 0x2D, 0, 0, 0x0A, 0 };
+  gint8 i = 0;
+  ssize_t err;
+
+  err = write (fd, _("gataxx\n"), 7);
+  while (kifu[i][0] && err > 0)
+    {
+      buf[0] = (i + 1) / 10 + 0x30;
+      buf[1] = (i + 1) % 10 + 0x30;
+      buf[3] = (kifu[i][0] == BLACK) ? 0x42 : 0x57;
+      buf[5] = (gchar) (kifu[i][1] % 7 + 0x41);
+      buf[6] = (gchar) (kifu[i][1] / 7 + 0x31);
+      buf[8] = (gchar) (kifu[i][2] % 7 + 0x41);
+      buf[9] = (gchar) (kifu[i][2] / 7 + 0x31);
 
-  return TRUE;
+      err = write (fd, buf, 11);
+      i++;
+    }
 }
 
-/* menu: Settings->Preferences */
-void
-properties_cb (GtkWidget * widget, gpointer data)
+static void
+on_save_clicked (GtkButton * button, gpointer user_data)
 {
-  show_properties_dialog ();
+  gchar *filename;
+  int fd;
+
+  filename =
+    gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_save_dialog));
+  fd = creat (filename, 0644);
+  if (fd)
+    {
+      write_kifu (fd);
+      close (fd);
+    }
+  gtk_widget_destroy (file_save_dialog);
+  g_free (filename);
 }
 
-/* this gets called whenever some setting has changed */
-void
-apply_changes ()
+static void
+on_save_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  gtk_gridboard_set_animate (gridboard, props_get_animate ());
-  gtk_gridboard_set_theme (gridboard, props_get_theme ());
+  GDate *date;
+  gchar filename[17];
 
-  if (props_get_quick_moves ()) {
-    timeout = DEF_TIMEOUT / 2;
-  } else {
-    timeout = DEF_TIMEOUT;
-  }
-  gtk_gridboard_paint (gridboard);
+  date = g_date_new ();
+  g_date_set_time_t (date, time (NULL));
+  g_date_strftime (filename, 17, _("%y%m%d%H"), date);
+
+  file_save_dialog =
+    create_file_save_dialog ((GtkSignalFunc *) on_save_clicked);
+  gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_save_dialog),
+				     filename);
+  gtk_widget_show (file_save_dialog);
+  g_date_free (date);
 }
 
-/* menu: Help->About */
-void
-about_cb (GtkWidget * widget, gpointer data)
+static void
+on_help_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  const gchar *authors[] = { "Chris Rogers", "Sjoerd Langkemper",
+  gnome_help_display ("gataxx.xml", NULL, NULL);
+}
+
+static void
+on_about_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  const gchar *authors[] = {
+    "Chris Rogers", "Sjoerd Langkemper",
     N_("Based on code from Iagno by Ian Peters"), NULL
   };
 
-  const gchar *documenters[] = { "Aaron Weber",
+  const gchar *documenters[] = {
+    "Aaron Weber",
     NULL
   };
-  gchar *license = games_get_license (_("Ataxx"));
 
   gtk_show_about_dialog (GTK_WINDOW (window),
 			 "name", _("Ataxx"),
@@ -430,7 +514,7 @@
 			 "Copyright \xc2\xa9 1999-2003 Chris Rogers\n"
 			 "Copyright \xc2\xa9 2004-2005 Sjoerd Langkemper\n"
 			 "Copyright \xc2\xa9 2005-2006 Callum McKenzie",
-			 "license", license, "comments",
+			 "license", "GPL 2+", "comments",
 			 _
 			 ("A disk-flipping game where you attempt to dominate the board."),
 			 "authors", authors, "documenters", documenters,
@@ -438,169 +522,183 @@
 			 "logo-icon-name", "gnome-ataxx", "website",
 			 "http://www.gnome.org/projects/gnome-games/",
 			 "wrap-license", TRUE, NULL);
-  g_free (license);
-
 }
 
-
-/* the properties dialog wants to know the gconf client */
-GConfClient *
-get_gconf_client ()
+static void
+on_back_button_clicked (GtkToolButton * toolbutton, gpointer user_data)
 {
-  static GConfClient *gconfclient = NULL;
-  if (gconfclient == NULL)
-    gconfclient = gconf_client_get_default ();
-  return gconfclient;
-}
+  if (move_count < 1)
+    return;
+  if (!check_back ())
+    return;
 
-static gboolean
-save_state_cb (GnomeClient * client, gint phase,
-	       GnomeSaveStyle style, gboolean shutdown,
-	       GnomeInteractStyle interactive, gboolean fast, gpointer data)
-{
-  gchar *argv[3];
-  gchar *state, *statestr;
-  int i, j;
-
-  argv[0] = "gataxx";
-
-  state = statestr = g_malloc0 (BWIDTH * BHEIGHT + 1);
-
-  for (j = 0; j < BHEIGHT; j++) {
-    for (i = 0; i < BWIDTH; i++) {
-      switch (gtk_gridboard_get_piece (gridboard, i, j)) {
-      case WHITE:
-	*state = '1';
-	break;
-      case BLACK:
-	*state = '2';
-	break;
-      default:
-	*state = '0';
-      }
-      state++;
-    }
-  }
-
-  argv[1] = g_strconcat ("--state=", statestr, NULL);
-
-
-  if (turn == WHITE)
-    argv[2] = "--turn=1";
-  else
-    argv[2] = "--turn=2";
+  back ();
+  copy_board ();
+  gui_status ();
+  flip_tiles = TRUE;
+  play_sound = TRUE;
+  check_game_over ();
+}
 
-  gnome_client_set_restart_command (client, 3, argv);
+static void
+on_forward_button_clicked (GtkToolButton * toolbutton, gpointer user_data)
+{
+  game_in_progress = FALSE;
 
-  g_free (statestr);
-  g_free (argv[1]);
+  if (!kifu[move_count][0])
+    {
+      if (!check_game_over ())
+	{
+	  game_in_progress = TRUE;
+	  check_computer_players ();
+	}
+      return;
+    }
 
-  return TRUE;
+  whose_turn = kifu[move_count][0];
+  move_board (kifu[move_count][1] % SIZE, kifu[move_count][1] / SIZE,
+	      kifu[move_count][2] % SIZE, kifu[move_count][2] / SIZE);
+  copy_board ();
+  gui_status ();
+  flip_tiles = TRUE;
+  play_sound = TRUE;
+  check_game_over ();
 }
 
 static void
-initgnomeclient (int argc, char **argv)
+on_last_button_clicked (GtkToolButton * toolbutton, gpointer user_data)
 {
-  GnomeClient *client;
-  GOptionContext *option_context;
+  game_in_progress = FALSE;
 
-  option_context = g_option_context_new ("");
-  g_option_context_add_main_entries (option_context,
-				     options, GETTEXT_PACKAGE);
-  program = gnome_program_init ("gataxx", VERSION,
-				LIBGNOMEUI_MODULE,
-				argc, argv,
-				GNOME_PARAM_GOPTION_CONTEXT, option_context,
-				GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
-  gtk_window_set_default_icon_name ("gnome-ataxx");
-  client = gnome_master_client ();
-
-  g_signal_connect (G_OBJECT (client), "save_yourself",
-		    G_CALLBACK (save_state_cb), argv[0]);
-  g_signal_connect (G_OBJECT (client), "die",
-		    G_CALLBACK (quit_game_cb), argv[0]);
+  while (kifu[move_count][0])
+    {
+      whose_turn = kifu[move_count][0];
+      move_board (kifu[move_count][1] % SIZE, kifu[move_count][1] / SIZE,
+		  kifu[move_count][2] % SIZE, kifu[move_count][2] / SIZE);
+    }
+  copy_board ();
+  redraw_board ();
+  if (!check_game_over ())
+    {
+      game_in_progress = TRUE;
+      check_computer_players ();
+    }
 }
 
-static gint
-resize_cb (GtkWindow * window, GdkEventConfigure * e, gpointer data)
+static gboolean
+check_event_move (gint ox, gint oy, gint nx, gint ny)
 {
-  GConfClient *client;
-
-  client = gconf_client_get_default ();
+  if (whose_turn == WHITE && white_computer_level)
+    return FALSE;
+  if (whose_turn == BLACK && black_computer_level)
+    return FALSE;
+  return move (whose_turn, ox, oy, nx, ny);
+}
 
-  gconf_client_set_int (client, GCONF_WINDOW_WIDTH, e->width, NULL);
-  gconf_client_set_int (client, GCONF_WINDOW_HEIGHT, e->height, NULL);
+static gboolean
+on_drawing_area_button_press_event (GtkWidget * widget,
+				    GdkEventButton * event,
+				    gpointer user_data)
+{
+  guint x, y;
 
-  g_object_unref (client);
+  if (event->button != 1)
+    return FALSE;
 
-  return FALSE;
+  x = event->x / (tile_width + GRIDWIDTH);
+  y = event->y / (tile_height + GRIDWIDTH);
+  if (board[y][x] == whose_turn)
+    {
+      old_x = x;
+      old_y = y;
+      return FALSE;
+    }
+  return check_event_move (old_x, old_y, x, y);
 }
 
-static void
-create_window ()
+static gboolean
+on_entry_key_press_event (GtkWidget * widget,
+			  GdkEventKey * event, gpointer user_data)
 {
-  GtkWidget *aspectbox;
-  gint width, height;
-  GConfClient *client;
-  gchar *theme;
-
-  client = gconf_client_get_default ();
-
-  width = gconf_client_get_int (client, GCONF_WINDOW_WIDTH, NULL);
-  height = gconf_client_get_int (client, GCONF_WINDOW_HEIGHT, NULL);
-
-  g_object_unref (client);
-
-  if (width <= 0)
-    width = 400;
-  if (height <= 0)
-    height = 450;
-
-  window = gnome_app_new ("gataxx", "Ataxx");
-  g_signal_connect (G_OBJECT (window), "delete_event",
-		    G_CALLBACK (quit_game_cb), NULL);
-  gtk_window_set_default_size (GTK_WINDOW (window), width, height);
-  g_signal_connect (G_OBJECT (window), "configure_event",
-		    G_CALLBACK (resize_cb), NULL);
-
-  gnome_app_create_menus (GNOME_APP (window), mainmenu);
-  menu_undo_set_sensitive (FALSE);
-
-  gnome_app_set_statusbar (GNOME_APP (window), appbar_new ());
-  gnome_app_install_menu_hints (GNOME_APP (window), mainmenu);
-
-  props_init (GTK_WINDOW (window), "gataxx");
-  theme = props_get_theme ();
-
-  aspectbox = games_grid_frame_new (BWIDTH, BHEIGHT);
-  gnome_app_set_contents (GNOME_APP (window), aspectbox);
-  gridboard = GTK_GRIDBOARD (gtk_gridboard_new (BWIDTH, BHEIGHT, theme));
-  gtk_container_add (GTK_CONTAINER (aspectbox), GTK_WIDGET (gridboard));
-  g_signal_connect (G_OBJECT (gridboard), "boxclicked",
-		    G_CALLBACK (boxclicked_cb), NULL);
-  gtk_widget_show_all (window);
-  apply_changes ();
+  gchar *ch;
+  gint ox, oy, nx, ny;
+
+  ch = (gchar *) gtk_entry_get_text (GTK_ENTRY (entry));
+  ox = (gint) ((*ch++ & 0xdf) - 0x41);
+  if (!*ch)
+    return FALSE;
+  oy = (gint) (*ch++ - 0x31);
+  if (!*ch)
+    return FALSE;
+  if (*ch == 0x2D)
+    ch++;
+  nx = (gint) ((*ch++ & 0xdf) - 0x41);
+  if (!*ch)
+    return FALSE;
+  ny = (gint) (*ch - 0x31);
+
+  return check_event_move (ox, oy, nx, ny);
 }
 
-/* this is where it all starts. After the window is brought up, the user
- * probably starts a new game (new_game_cb()), and clicks some (boxclicked_cb).
- */
+const GCallback *callbacks[MAX_ACTION_NUMBER] = {
+  NULL,
+  (GCallback *) on_new_game_activate,
+  (GCallback *) on_redo_activate,
+  (GCallback *) on_hint_activate,
+  (GCallback *) on_sync_activate,
+  (GCallback *) on_again_activate,
+  (GCallback *) on_open_activate,
+  (GCallback *) on_save_activate,
+  (GCallback *) on_quit_activate,
+  NULL,
+  (GCallback *) on_properties_activate,
+  (GCallback *) on_minimum_board_activate,
+  NULL,
+  (GCallback *) on_help_activate,
+  (GCallback *) on_about_activate,
+  (GCallback *) on_head_button_clicked,
+  (GCallback *) on_back_button_clicked,
+  (GCallback *) on_forward_button_clicked,
+  (GCallback *) on_last_button_clicked,
+  (GCallback *) on_hint_activate,
+  (GCallback *) on_redo_activate,
+  (GCallback *) on_new_game_activate,
+  (GCallback *) on_quit_activate
+};
+
+const GtkSignalFunc *signalfuncs[2] = {
+  (GtkSignalFunc *) on_drawing_area_button_press_event,
+  (GtkSignalFunc *) on_entry_key_press_event,
+};
+
 int
-main (int argc, char **argv)
+main (int argc, char *argv[])
 {
+  GnomeProgram *program;
+
   gnome_score_init ("gataxx");
 
-  settextdomain ();
+  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
 
-  initgnomeclient (argc, argv);
+  program =
+    gnome_program_init ("gataxx", VERSION, LIBGNOMEUI_MODULE, argc, argv,
+			GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
 
-  create_window ();
+  gconf_init (argc, argv, NULL);
+  games_stock_init ();
+  gtk_window_set_default_icon_name ("gnome-ataxx");
 
-  new_game ();
+  load_properties (MAX_DEPTH);
+  window = create_window (GATAXX, callbacks, signalfuncs);
+  reset_properties ();
+  apply_changes ();
+  set_computerid1 ();
 
+  gui_message ("Welcome to gataxx!");
   gtk_main ();
 
   g_object_unref (program);
-
   return 0;
 }
Index: gnome-games/gataxx/gataxx.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/gataxx.h,v
retrieving revision 1.12
diff -u -r1.12 gataxx.h
--- gnome-games/gataxx/gataxx.h	3 Oct 2006 20:57:24 -0000	1.12
+++ gnome-games/gataxx/gataxx.h	5 Oct 2006 12:15:08 -0000
@@ -1,6 +1,6 @@
-/* (C) 2003/2004 Sjoerd Langkemper
- * gataxx.h -
- * 
+/*
+ * gataxx.h
+ *
  * 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
@@ -18,48 +18,6 @@
  * For more details see the file COPYING.
  */
 
-#ifndef GATAXX_H
-#define GATAXX_H
-
-#include <glib.h>
-#include <libgnomeui/libgnomeui.h>
-#include <gconf/gconf-client.h>
-#include <gtkgridboard.h>
-
-#define BHEIGHT 7		/* board height */
-#define BWIDTH 7		/* board width  */
-#define DEF_TIMEOUT 1000	/* computer timeout default */
-
-typedef struct {
-  int x;
-  int y;
-  int valid;
-} position;
-
-typedef struct {
-  position from;
-  position to;
-} move;
-
-void new_game_cb (GtkWidget * widget, gpointer data);
-void undo_move_cb (GtkWidget * widget, gpointer data);
-gboolean quit_game_cb (GtkWidget * widget, gpointer data);
-void properties_cb (GtkWidget * widget, gpointer data);
-void about_cb (GtkWidget * widget, gpointer data);
-void boxclicked_cb (GtkWidget * widget, int x, int y);
-GnomeUIInfo *get_mainmenu (void);
-GConfClient *get_gconf_client (void);
-gboolean computer_move_cb (gpointer turn);
-void do_move (move m);
-void do_select (int x, int y);
-void gridboard_move (GtkGridBoard * gridboard, move m);
-void turn_pieces (GtkGridBoard * gridboard, int x, int y);
-void apply_changes (void);
-GConfClient *get_gconf_client (void);
-void menu_undo_set_sensitive (gboolean sens);
-gboolean move_possible (GtkGridBoard * gridboard, int turn);
-gboolean move_possible_to (GtkGridBoard * gridboard, int x, int y, int turn);
-gboolean end_game_cb (gpointer data);
-void flip_final (GtkGridBoard * gridboard, int wc, int bc);
+gboolean move (gint who, gint ox, gint oy, gint nx, gint ny);
 
-#endif /* GATAXX_H */
+void init_new_game (void);
Index: gnome-games/gataxx/properties.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/properties.c,v
retrieving revision 1.42
diff -u -r1.42 properties.c
--- gnome-games/gataxx/properties.c	3 Oct 2006 20:57:24 -0000	1.42
+++ gnome-games/gataxx/properties.c	5 Oct 2006 12:15:08 -0000
@@ -1,7 +1,6 @@
-/* (C) 2003/2004 Sjoerd Langkemper
- * (C) 1999-2003 Chris Rogers
- * properties.c - properties dialog and info 
- * 
+/*
+ * properties.c - user interface code.
+ *
  * 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
@@ -18,435 +17,1326 @@
  *
  * For more details see the file COPYING.
  */
-
 #include "config.h"
 #include <gnome.h>
-#include <glib/gi18n.h>
-#include <string.h>
-#include <dirent.h>
-#include <games-clock.h>
-#include <games-frame.h>
+#include <glib.h>
 #include <gconf/gconf-client.h>
-#include "gtkgridboard.h"
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
 
-#include "games-files.h"
+#include "games-stock.h"
+#include "games-preimage.h"
 
 #include "properties.h"
-#include "gataxx.h"
 
-#define GCONF_PREFIX "/apps/gataxx/"
+#define BLACK	1
+#define WHITE	31
+#define BLANK	127
+
+gint8 pixmaps[8][8];
+gint8 board[8][8];
+
+GtkWidget *window;
+GtkWidget *file_open_dialog;
+GtkWidget *file_save_dialog;
+GtkWidget *counter;
+GtkWidget *score[4];
+GtkWidget *entry;
+GTimer *b_timer;
+GTimer *w_timer;
+
+guint tile_width;
+guint tile_height;
+guint black_computer_level;
+guint white_computer_level;
+gboolean flip_final;
+guint computer_speed;
+gboolean game_in_progress;
+gboolean play_sound = FALSE;
+gboolean gameover = FALSE;
+gboolean flip_tiles = FALSE;
+guint flip_final_id = 0;
+guint t_move_count;
+guint t_whose_turn;
+guint t_bcount;
+guint t_wcount;
+gboolean ggz_network_mode = FALSE;
+
+static const gchar *keys[11][2] = {
+  {"/apps/iagno/black_level",        "/apps/gataxx/blacklevel"},
+  {"/apps/iagno/white_level",        "/apps/gataxx/whitelevel"},
+  {"/apps/iagno/animate",            "/apps/gataxx/animate"},
+  {"/apps/iagno/quick_moves",        "/apps/gataxx/quickmoves"},
+  {"/apps/iagno/animate_stagger",    "/apps/gataxx/animate_stagger"},
+  {"/apps/iagno/show_grid",          "/apps/gataxx/show_grid"},
+  {"/apps/iagno/flip_final_results", "/apps/gataxx/flip_final_results"},
+  {"/apps/iagno/tileset",            "/apps/gataxx/tileset"},
+  {"/apps/iagno/bg_color_name",      "/apps/gataxx/bg_color_name"},
+  {"/apps/iagno/board_width",        "/apps/gataxx/width"},
+  {"/apps/iagno/board_height",       "/apps/gataxx/height"}
+};
+
+static GtkWidget *properties_dialog = NULL;
+static GtkWidget *drawing_area;
+static GtkWidget *menubar;
+static GtkWidget *toolbar;
+static GtkWidget *statusbar;
+static GdkGC *gridGC[2] = { 0 };
+static GdkColor bg_color[3] = {
+  {0, 0, 0, 0},			/* background color */
+  {0xffffffff, 0xffff, 0xffff, 0xffff},	/* grid color */
+  {0, 0, 0, 0}			/* tmp color  */
+};
+
+static guint gataxx;
+static guint size;
+static guint board_width;
+static guint board_height;
+static gboolean animate;
+static gboolean quick_moves;
+static gboolean animate_stagger;
+static gboolean grid;
+static gchar *tile_set;
+static gchar *bg_color_name;
+static guint flip_speed;
+static GdkPixmap *buffer_pixmap = NULL;
+static GdkPixmap *tiles_pixmap = NULL;
+static gchar *flip_sound;
+static gchar *gameover_sound;
+static guint context_id = 0;
+static guint flip_pixmaps_id = 0;
+static guint timer_id = 0;
+static GamesPreimage *t_image;
+static guint t_image_id = 0;
+
+static GtkActionGroup *action_group;
+static GtkUIManager *manager;
+static GtkAction *open_action;
+static GtkAction *new_game_action;
+static GtkAction *redo_game_action;
+static GtkAction *show_hint_action;
+static GtkAction *sync_action;
+static GtkAction *again_action;
+static GtkAction *preferences_action;
+
+gint
+clamp_int (gint input, gint low, gint high)
+{
+  if (input < low)
+    input = low;
+  if (input > high)
+    input = high;
+
+  return input;
+}
 
-#define GCONF_BLACKLEVEL GCONF_PREFIX "blacklevel"
-#define GCONF_WHITELEVEL GCONF_PREFIX "whitelevel"
-#define GCONF_QUICKMOVES GCONF_PREFIX "quickmoves"
-#define GCONF_THEME GCONF_PREFIX "theme"
-#define GCONF_ANIMATE GCONF_PREFIX "animate"
+/******* for main window *******/
 
-typedef struct {
-  gint black_level;
-  gint white_level;
-  gboolean animate;
-  gboolean quick_moves;
-  gchar *theme;
-} PropertiesData;
+static void
+copy_pixmaps (void)
+{
+  guint i, j;
 
-PropertiesData _props;
-PropertiesData *props = &_props;
+  for (i = 0; i < size; i++)
+    for (j = 0; j < size; j++)
+      pixmaps[i][j] = board[i][j];
+}
 
-static GtkWidget *propbox = NULL;
-static GtkWindow *mainwindow = NULL;
-static GtkTooltips *tooltips = NULL;
+static void
+clear_board (void)
+{
+  guint i, j;
 
-/* functions to get things from the PropertiesData struct */
+  for (i = 0; i < size; i++)
+    for (j = 0; j < size; j++)
+      board[i][j] = BLANK;
+
+  game_in_progress = FALSE;
+  t_move_count = 0;
+  t_bcount = 0;
+  t_wcount = 0;
+}
 
-int
-props_is_human (int piece)
+static void
+set_board_size (void)
 {
-  return props_get_level (piece) == 0;
+  gint depth = -1;
+
+  board_width  = clamp_int (board_width, BOARD_MIN, BOARD_W_MAX);
+  board_height = clamp_int (board_height, BOARD_MIN, BOARD_H_MAX);
+  tile_width   = (board_width - GRIDWIDTH * (size - 1)) / size;
+  tile_height  = (board_height - GRIDWIDTH * (size - 1)) / size;
+  board_width  = tile_width * size + GRIDWIDTH * (size - 1);
+  board_height = tile_height * size + GRIDWIDTH * (size - 1);
+  save_properties ();
+
+  gtk_widget_set_size_request (drawing_area, board_width, board_height);
+  if (buffer_pixmap)
+    {
+      g_object_unref (buffer_pixmap);
+      depth = gdk_drawable_get_depth ((GdkDrawable *) drawing_area->window);
+    }
+  buffer_pixmap = gdk_pixmap_new (drawing_area->window,
+				  board_width, board_height, depth);
 }
 
-int
-props_get_level (int piece)
+static void
+set_bg_color (void)
 {
-  if (piece == WHITE)
-    return props_get_white_level ();
-  else
-    return props_get_black_level ();
+  gint i;
+
+  gdk_color_parse (bg_color_name, &bg_color[0]);
+  gdk_colormap_alloc_color (gtk_widget_get_colormap (drawing_area),
+			    &bg_color[0], FALSE, TRUE);
+
+  for (i = 0; i < 2; i++)
+    {
+      if (gridGC[i])
+	g_object_unref (gridGC[i]);
+      gridGC[i] = gdk_gc_new (drawing_area->window);
+      gdk_gc_copy (gridGC[i], drawing_area->style->bg_gc[0]);
+      gdk_gc_set_background (gridGC[i], &bg_color[i]);
+      gdk_gc_set_foreground (gridGC[i], &bg_color[i]);
+    }
 }
 
-int
-props_get_white_level ()
+static gboolean
+free_t_image (gpointer user_data)
 {
-  return props->white_level;
+  g_object_unref (t_image);
+  t_image = NULL;
+  t_image_id = 0;
+  return FALSE;
 }
 
-int
-props_get_black_level ()
+static void
+load_image (gchar * tileset)
 {
-  return props->black_level;
+  gchar *fname, *pathname;
+  GError *error = NULL;
+
+  if (t_image)
+    return;
+  fname = g_build_filename ("iagno", tileset, NULL);
+  pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
+					fname, TRUE, NULL);
+  t_image = games_preimage_new_from_file (pathname, &error);
+  g_free (fname);
+  t_image_id = g_timeout_add (3000, (GSourceFunc) free_t_image, NULL);
 }
 
-gboolean
-props_get_animate ()
+static void
+load_pixmaps (void)
 {
-  return props->animate;
+  GdkPixbuf *image;
+  gint depth = -1;
+  GdkGC *gc;
+
+  load_image (tile_set);
+  if (!t_image)
+    {
+      if (tile_set)
+	g_free (tile_set);
+      tile_set = g_strdup (_("marble.svg"));
+      load_image (tile_set);
+      if (!t_image)
+	{
+	  g_print (_("Could not find \'%s\' pixmap file\n"),
+		   _("iagno/marble.svg"));
+	  exit (1);
+	}
+      save_properties ();
+      reset_properties ();
+    }
+
+  image = games_preimage_render (t_image,
+				 tile_width * 8, tile_height * 4, NULL);
+
+  if (tiles_pixmap)
+    {
+      g_object_unref (tiles_pixmap);
+      depth = gdk_drawable_get_depth ((GdkDrawable *) drawing_area->window);
+    }
+  tiles_pixmap = gdk_pixmap_new (drawing_area->window,
+				 tile_width * 8, tile_height * 4, depth);
+
+  gc = gdk_gc_new (tiles_pixmap);
+  gdk_gc_set_foreground (gc, &bg_color[0]);
+  gdk_gc_set_background (gc, &bg_color[0]);
+
+  gdk_draw_rectangle (tiles_pixmap, gc, TRUE, 0, 0,
+		      tile_width * 8, tile_height * 4);
+  gdk_draw_pixbuf (tiles_pixmap, gc, image, 0, 0, 0, 0,
+		   tile_width * 8, tile_height * 4, GDK_RGB_DITHER_NONE, 0,
+		   0);
+
+  g_object_unref (image);
 }
 
-gboolean
-props_get_quick_moves ()
+static void
+gui_draw_pixmap_buffer (guint x, guint y, guint which)
 {
-  return props->quick_moves;
+  gdk_draw_drawable (buffer_pixmap, gridGC[0], tiles_pixmap,
+		     tile_width * (which % 8), tile_height * (which / 8),
+		     (tile_width + GRIDWIDTH) * x,
+		     (tile_height + GRIDWIDTH) * y, tile_width, tile_height);
 }
 
-gchar *
-props_get_theme ()
+static void
+gui_draw_pixmap (guint x, guint y, guint which)
 {
-  return props->theme;
+  gui_draw_pixmap_buffer (x, y, which);
+  gdk_draw_drawable (drawing_area->window, gridGC[0], tiles_pixmap,
+		     tile_width * (which % 8), tile_height * (which / 8),
+		     (tile_width + GRIDWIDTH) * x,
+		     (tile_height + GRIDWIDTH) * y, tile_width, tile_height);
 }
 
-/* functions to get things from gconf */
-static int
-props_get_int (const gchar * key, int def, int low, int high)
+static void
+gui_draw_grid (guint j)
 {
-  int result;
-  GError *error = NULL;
+  guint i;
 
-  result = gconf_client_get_int (get_gconf_client (), key, &error);
-  if (error != NULL) {
-    g_error_free (error);
-    return def;
-  }
+  gdk_gc_set_line_attributes (gridGC[1], GRIDWIDTH, GDK_LINE_ON_OFF_DASH,
+			      GDK_CAP_BUTT, GDK_JOIN_MITER);
 
-  return CLAMP (result, low, high);
+  for (i = tile_height; i < board_height; i += tile_height + GRIDWIDTH)
+    gdk_draw_line (buffer_pixmap, gridGC[j], 0, i, board_width, i);
+  for (i = tile_width; i < board_width; i += tile_width + GRIDWIDTH)
+    gdk_draw_line (buffer_pixmap, gridGC[j], i, 0, i, board_height);
 }
 
-static gboolean
-props_get_bool (const gchar * key, gboolean def)
+void
+gui_status (void)
 {
-  GError *error = NULL;
-  gboolean result;
+  gchar message[5];
 
-  result = gconf_client_get_bool (get_gconf_client (), key, &error);
-  if (error != NULL) {
-    g_error_free (error);
-    return def;
-  }
+  sprintf (message, _("%.2d"), t_move_count);
+  gtk_label_set_text (GTK_LABEL (counter), message);
+  sprintf (message, _("%.2d"), t_bcount);
+  gtk_label_set_text (GTK_LABEL (score[0]), message);
+  sprintf (message, _("%.2d"), t_wcount);
+  gtk_label_set_text (GTK_LABEL (score[1]), message);
+}
 
-  return result;
+void
+redraw_board (void)
+{
+  guint i, j, which;
+
+  copy_pixmaps ();
+  for (i = 0; i < size; i++)
+    for (j = 0; j < size; j++)
+      {
+	which = 0;
+	if (pixmaps[i][j] != BLANK)
+	  which = (guint) (pixmaps[i][j] - BLACK + 1);
+	gui_draw_pixmap_buffer (j, i, which);
+      }
+
+  gui_draw_grid (0);
+  if (grid)
+    gui_draw_grid (1);
+  gtk_widget_queue_draw_area (drawing_area, 0, 0, board_width, board_height);
+  gui_status ();
 }
 
-/* FIXME: watch this: */
-/* Returns gchar* you should free with g_free(). Returns NULL on not-found
- * or other error. */
-static gchar *
-props_get_string (const gchar * key)
+void
+refresh_board (void)
 {
-  GError *error = NULL;
-  gchar *retval;
+  set_board_size ();
+  set_bg_color ();
+  load_pixmaps ();
+  redraw_board ();
+}
 
-  retval = gconf_client_get_string (get_gconf_client (), key, &error);
-  if (error != NULL) {
-    g_error_free (error);
-    return NULL;
-  }
+static void
+sprint_time (gchar * message, GTimer * timer)
+{
+  gint mm, ss;
 
-  return retval;
+  ss = (gint) g_timer_elapsed (timer, NULL);
+  mm = ss / 60;
+  ss -= mm * 60;
+  sprintf (message, _("%.2d:%.2d"), mm, ss);
 }
 
 void
-load_properties (void)
+gui_timer (void)
 {
-  props->black_level = props_get_int (GCONF_BLACKLEVEL, 0, 0, 3);
-  props->white_level = props_get_int (GCONF_WHITELEVEL, 0, 0, 3);
+  gchar message[9];
 
-  props->theme = props_get_string (GCONF_THEME);
-  if (props->theme == NULL)
-    props->theme = g_strdup ("Plain");
+  sprint_time (message, b_timer);
+  gtk_label_set_text (GTK_LABEL (score[2]), message);
+  sprint_time (message, w_timer);
+  gtk_label_set_text (GTK_LABEL (score[3]), message);
+}
 
-  props->animate = props_get_bool (GCONF_ANIMATE, TRUE);
-  props->quick_moves = props_get_bool (GCONF_QUICKMOVES, FALSE);
+void
+timer_start (void)
+{
+  if (timer_id)
+    g_source_remove (timer_id);
+  timer_id = g_timeout_add (500, (GSourceFunc) gui_timer, NULL);
 }
 
-static void
-save_properties (void)
+void
+gui_message (gchar * message)
 {
-  gconf_client_set_int (get_gconf_client (), GCONF_BLACKLEVEL,
-			props->black_level, NULL);
-  gconf_client_set_int (get_gconf_client (), GCONF_WHITELEVEL,
-			props->white_level, NULL);
-  gconf_client_set_bool (get_gconf_client (), GCONF_QUICKMOVES,
-			 props->quick_moves, NULL);
-  gconf_client_set_string (get_gconf_client (), GCONF_THEME,
-			   props->theme, NULL);
-  gconf_client_set_bool (get_gconf_client (), GCONF_ANIMATE,
-			 props->animate, NULL);
+  if (context_id)
+    gtk_statusbar_pop (GTK_STATUSBAR (statusbar), context_id);
+  context_id =
+    gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), message);
+  gtk_statusbar_push (GTK_STATUSBAR (statusbar), context_id, message);
 }
 
-/* callbacks for the various check and radiobuttons */
-static void
-black_level_select (GtkWidget * widget, gpointer data)
+void
+gui_entry (gchar * message)
 {
-  if (GTK_TOGGLE_BUTTON (widget)->active) {
-    props->black_level = GPOINTER_TO_INT (data);
-  }
-  save_properties ();
-  apply_changes ();
+  gtk_entry_set_text (GTK_ENTRY (entry), message);
 }
 
 static void
-white_level_select (GtkWidget * widget, gpointer data)
+check_sound (void)
 {
-  if (GTK_TOGGLE_BUTTON (widget)->active) {
-    props->white_level = GPOINTER_TO_INT (data);
-  }
-  save_properties ();
-  apply_changes ();
+  if (play_sound)
+    {
+      gnome_sound_play (flip_sound);
+      play_sound = FALSE;
+    }
+  if (gameover)
+    {
+      gnome_sound_play (gameover_sound);
+      gameover = FALSE;
+    }
+}
+
+static gboolean
+flip_pixmaps (gpointer data)
+{
+  guint i, j, which;
+
+  check_sound ();
+
+  if (!flip_tiles)
+    return TRUE;
+  flip_tiles = FALSE;
+
+  for (i = 0; i < size; i++)
+    for (j = 0; j < size; j++)
+      {
+	if (pixmaps[i][j] == BLANK && board[i][j] != BLANK)
+	  {
+	    pixmaps[i][j] = board[i][j];
+	    which = clamp_int ((gint) pixmaps[i][j], BLACK, WHITE);
+	    gui_draw_pixmap (j, i, which - BLACK + 1);
+	    flip_tiles = TRUE;
+	  }
+	else if (pixmaps[i][j] != BLANK && board[i][j] == BLANK)
+	  {
+	    pixmaps[i][j] = BLANK;
+	    gui_draw_pixmap (j, i, 0);
+	    flip_tiles = TRUE;
+	  }
+	else if (pixmaps[i][j] < board[i][j] && board[i][j] != BLANK)
+	  {
+	    if (!animate)
+	      {
+		if (pixmaps[i][j] == BLACK)
+		  pixmaps[i][j] = board[i][j];
+		else
+		  pixmaps[i][j]++;
+	      }
+	    else
+	      pixmaps[i][j]++;
+
+	    which = clamp_int ((gint) pixmaps[i][j], BLACK, WHITE);
+	    gui_draw_pixmap (j, i, which - BLACK + 1);
+	    flip_tiles = TRUE;
+	  }
+	else if (pixmaps[i][j] > board[i][j] && pixmaps[i][j] != BLANK)
+	  {
+	    if (!animate)
+	      {
+		if (pixmaps[i][j] == WHITE)
+		  pixmaps[i][j] = board[i][j];
+		else
+		  pixmaps[i][j]--;
+	      }
+	    else
+	      pixmaps[i][j]--;
+
+	    which = clamp_int ((gint) pixmaps[i][j], BLACK, WHITE);
+	    gui_draw_pixmap (j, i, which - BLACK + 1);
+	    flip_tiles = TRUE;
+	  }
+      }
+
+  return TRUE;
 }
 
 static void
-set_variable_cb (GtkWidget * widget, gpointer data)
+set_flip_pixmaps_id (void)
 {
-  *((gint *) data) = GTK_TOGGLE_BUTTON (widget)->active;
-  apply_changes ();
+  if (flip_pixmaps_id)
+    g_source_remove (flip_pixmaps_id);
+
+  if (!animate)
+    flip_pixmaps_id = g_timeout_add (100, flip_pixmaps, NULL);
+  else
+    flip_pixmaps_id = g_timeout_add (flip_speed, flip_pixmaps, NULL);
+}
+
+gboolean
+flip_final_results (gpointer data)
+{
+  guint i;
+  gint8 adder = 0;
+
+  i = 0;
+  for (; i < t_bcount; i++)
+    {
+      board[i / size][i % size] = BLACK;
+      if (pixmaps[i / size][i % size] == BLANK)
+	pixmaps[i / size][i % size] = WHITE;
+      if (pixmaps[i / size][i % size] == WHITE)
+	{
+	  pixmaps[i / size][i % size] += adder;
+	  if (animate_stagger)
+	    adder++;
+	}
+    }
+
+  for (; i < size * size - t_wcount; i++)
+    board[i / size][i % size] = BLANK;
+
+  for (; i < size * size; i++)
+    {
+      board[i / size][i % size] = WHITE;
+      if (pixmaps[i / size][i % size] == BLANK)
+	pixmaps[i / size][i % size] = BLACK;
+      if (pixmaps[i / size][i % size] == BLACK)
+	{
+	  pixmaps[i / size][i % size] -= adder;
+	  if (animate_stagger)
+	    adder++;
+	}
+    }
+  flip_tiles = TRUE;
+  return FALSE;
 }
 
 static void
-set_selection (GtkWidget * widget, gpointer data)
+network_gui_update (void)
 {
-  int n;
+  if (ggz_network_mode)
+    {
+      black_computer_level = 0;
+      white_computer_level = 0;
+    }
+  gtk_action_set_sensitive (open_action,        !ggz_network_mode);
+  gtk_action_set_visible   (new_game_action,    !ggz_network_mode);
+  gtk_action_set_visible   (redo_game_action,   !ggz_network_mode);
+  gtk_action_set_visible   (show_hint_action,   !ggz_network_mode);
+  gtk_action_set_visible   (sync_action,         ggz_network_mode);
+  gtk_action_set_visible   (again_action,        ggz_network_mode);
+  gtk_action_set_sensitive (preferences_action, !ggz_network_mode);
+  gtk_widget_set_sensitive (toolbar,            !ggz_network_mode);
+}
 
-  if (props->theme)
-    g_free (props->theme);
+void
+on_quit_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+  gtk_main_quit ();
+}
 
-  /* We can't use _get_active_text since the text may be
-   * translated. */
-  n = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
-  props->theme = g_strdup (gtk_gridboard_themes[n].name);
+void
+on_properties_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+  if (properties_dialog)
+    return;
+  properties_dialog = create_properties_dialog ();
+  gtk_widget_show (properties_dialog);
+}
 
-  save_properties ();
-  apply_changes ();
+void
+on_minimum_board_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+  board_width = board_height = BOARD_MIN;
+  gtk_window_resize ((GtkWindow *) window, board_width, board_height);
+  refresh_board ();
 }
 
-/* fills the pixmap options menu */
-static GtkWidget *
-fill_theme_menu (void)
-{
-  GtkWidget *combo_box;
-  GtkGridBoardTheme *t;
-  int n;
-
-  combo_box = gtk_combo_box_new_text ();
-
-  t = gtk_gridboard_themes;
-  n = 0;
-  while (t->name != NULL) {
-    gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), _(t->name));
-    if (g_utf8_collate (t->name, props->theme) == 0)
-      gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), n);
-    n++;
-    t++;
-  }
+gboolean
+on_drawing_area_expose_event (GtkWidget *widget,
+			      GdkEventExpose *event, gpointer user_data)
+{
+  gdk_draw_drawable (drawing_area->window, gridGC[0], buffer_pixmap,
+		     event->area.x, event->area.y,
+		     event->area.x, event->area.y,
+		     event->area.width, event->area.height);
+  return FALSE;
+}
+
+gboolean
+on_drawing_area_configure_event (GtkWidget * widget,
+				 GdkEventConfigure * event,
+				 gpointer user_data)
+{
+  board_width = (event->width * 99) / 100;
+  board_height = (event->height * 99) / 100;
 
-  return combo_box;
+  refresh_board ();
+  return FALSE;
 }
 
-/* makes a perty radio button for a particular computer level */
-static GtkWidget *
-add_level (GtkWidget * container,
-	   GtkWidget * prev, const gchar * caption, gint level, gint piece)
+static void
+set_sound (void)
 {
-  GtkWidget *button;
-  int computer_level;
-  GCallback callback;
+  gchar *tmp;
 
-  if (piece == BLACK) {
-    computer_level = props->black_level;
-    callback = G_CALLBACK (black_level_select);
-  } else {
-    computer_level = props->white_level;
-    callback = G_CALLBACK (white_level_select);
-  }
+  tmp = g_build_filename ("iagno", "flip-piece.wav", NULL);
+  flip_sound = gnome_program_locate_file (NULL,
+					  GNOME_FILE_DOMAIN_APP_SOUND, tmp,
+					  TRUE, NULL);
+  g_free (tmp);
+
+  tmp = g_build_filename ("iagno", "gameover.wav", NULL);
+  gameover_sound = gnome_program_locate_file (NULL,
+					      GNOME_FILE_DOMAIN_APP_SOUND,
+					      tmp, TRUE, NULL);
+  g_free (tmp);
+}
+
+const char manager_definition[] = {
+  "<ui>"
+  "  <menubar name='MenuBar'>"
+  "    <menu name='GameMenu'			action='game_menu'>"
+  "      <menuitem name='New_Game'		action='new_game'/>"
+  "      <separator/>"
+  "      <menuitem name='Redo'			action='redo_game'/>"
+  "      <menuitem name='Hint'			action='show_hint'/>"
+  "      <separator/>"
+  "      <menuitem name='Sync'			action='sync'/>"
+  "      <menuitem name='Again'			action='again'/>"
+  "      <separator/>"
+  "      <menuitem name='Open'			action='open'/>"
+  "      <menuitem name='Save'			action='save'/>"
+  "      <separator/>"
+  "      <menuitem name='Quit_Game'		action='quit_game'/>"
+  "    </menu>"
+  "    <menu name='SettingsMenu'		action='settings_menu'>"
+  "      <menuitem name='Preferences'		action='preferences'/>"
+  "      <menuitem name='Minimum Board'   action='minimum_board'/>"
+  "    </menu>"
+  "    <menu name='HelpMenu'			action='help_menu'>"
+  "      <menuitem name='Contents'		action='help'/>"
+  "      <menuitem name='About'			action='about'/>"
+  "    </menu>"
+  "  </menubar>"
+  "  <toolbar  name='ToolBar'>"
+  "      <toolitem name='Head'		action='head'/>"
+  "      <toolitem name='Back'		action='back'/>"
+  "      <toolitem name='Forward'		action='forward'/>"
+  "      <toolitem name='Last'		action='last'/>"
+  "      <toolitem name='Hint'		action='hint'/>"
+  "      <toolitem name='Redo'		action='redo'/>"
+  "      <toolitem name='New'			action='new'/>"
+  "      <toolitem name='Quit'		action='quit'/>"
+  "  </toolbar>"
+  "</ui>"
+};
+
+GtkActionEntry entries[MAX_ACTION_NUMBER] = {
+  {"game_menu",     NULL,                  N_("_Game")},
+  {"new_game",      GAMES_STOCK_NEW_GAME,  NULL, NULL,              NULL, NULL},
+  {"redo_game",     GAMES_STOCK_REDO_MOVE, NULL, NULL,              NULL, NULL},
+  {"show_hint",     GAMES_STOCK_HINT,      NULL, NULL,              NULL, NULL},
+  {"sync",          NULL,                  N_("_Sync"),       NULL, NULL, NULL},
+  {"again",         NULL,                  N_("Play _Again"), NULL, NULL, NULL},
+  {"open",          GTK_STOCK_OPEN,        NULL, NULL,              NULL, NULL},
+  {"save",          GTK_STOCK_SAVE,        NULL, NULL,              NULL, NULL},
+  {"quit_game",     GTK_STOCK_QUIT,        NULL, NULL,              NULL, NULL},
+  {"settings_menu", NULL,                  N_("_Settings")},
+  {"preferences",   GTK_STOCK_PREFERENCES, NULL, NULL,              NULL, NULL},
+  {"minimum_board", GTK_STOCK_ZOOM_OUT,    NULL, NULL,              NULL, NULL},
+  {"help_menu",     NULL,                  N_("_Help")},
+  {"help",          GAMES_STOCK_CONTENTS,  NULL, NULL,              NULL, NULL},
+  {"about",         GTK_STOCK_ABOUT,       NULL, NULL,              NULL, NULL},
+  {"head",          GTK_STOCK_GOTO_FIRST,  NULL, "<Ctl><Shift>f" ,  NULL, NULL},
+  {"back",          GTK_STOCK_GO_BACK,     NULL, "<Ctl>b",          NULL, NULL},
+  {"forward",       GTK_STOCK_GO_FORWARD,  NULL, "<Ctl>f",          NULL, NULL},
+  {"last",          GTK_STOCK_GOTO_LAST,   NULL, "<Ctl>l" ,         NULL, NULL},
+  {"hint",          GAMES_STOCK_HINT,      NULL, "<Ctl>h",          NULL, NULL},
+  {"redo",          GAMES_STOCK_REDO_MOVE, NULL, "<Ctl>r" ,         NULL, NULL},
+  {"new",           GAMES_STOCK_NEW_GAME,  NULL, NULL,              NULL, NULL},
+  {"quit",          GTK_STOCK_QUIT,        NULL, NULL,              NULL, NULL}
+};
 
-  button =
-    gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (prev),
-						 caption);
-  if (computer_level == level) {
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+static void
+set_callbacks (GCallback **callbacks)
+{
+  guint i;
+  
+  for (i = 0; i < 23; i++)
+  {
+    if (*callbacks)
+     entries[i].callback = *(callbacks++);
+    else
+      callbacks++;
   }
-  g_signal_connect (G_OBJECT (button), "toggled", callback,
-		    GINT_TO_POINTER (level));
-  gtk_box_pack_start (GTK_BOX (container), button, FALSE, FALSE, 0);
-  return button;
+};
+
+static void
+set_actions (void)
+{
+  open_action        = gtk_action_group_get_action (action_group, "open");
+  new_game_action    = gtk_action_group_get_action (action_group, "new_game");
+  redo_game_action   = gtk_action_group_get_action (action_group, "redo_game");
+  show_hint_action   = gtk_action_group_get_action (action_group, "show_hint");
+  sync_action        = gtk_action_group_get_action (action_group, "sync");
+  again_action       = gtk_action_group_get_action (action_group, "again");
+  preferences_action = gtk_action_group_get_action (action_group, "preferences");
+}
+
+GtkWidget *
+create_window (guint t_gataxx, GCallback **callbacks,
+	       GtkSignalFunc **signalfuncs)
+{
+  const gchar *strs[] = {
+    N_("Dark:"),        /* 0 */
+    N_("Light:"),	/* 1 */
+    _("00"),		/* 2 */
+    _("00:00"),		/* 3 */
+    _("iagno"),		/* 4 */
+    _("gataxx")		/* 5 */
+  };
+
+  GtkWidget *window;
+  GtkWidget *vbox1;
+  GtkWidget *vbox3;
+  GtkWidget *hbox;
+  GtkWidget *label;
+  GtkAccelGroup *accel_group;
+
+  gint i, j;
+  gchar name[2] = { 0, 0 };
+  gchar *markup;
+
+  GError *error = NULL;
+
+  gataxx = t_gataxx;
+  if (gataxx)
+    size = 7;
+  else
+    size = 8;
+  clear_board ();
+  
+  accel_group = gtk_accel_group_new ();
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (window), strs[gataxx + 4]);
+  g_signal_connect ((gpointer) window, "destroy",
+		    G_CALLBACK (on_quit_activate), NULL);
+
+  set_callbacks (callbacks);
+  manager = gtk_ui_manager_new ();
+  gtk_ui_manager_add_ui_from_string (manager, manager_definition, -1, &error);
+  action_group = gtk_action_group_new ("ActionGroup");
+  gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+  gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries),
+				window);
+  gtk_ui_manager_insert_action_group (manager, action_group, 0);
+  gtk_window_add_accel_group (GTK_WINDOW (window),
+			      gtk_ui_manager_get_accel_group (manager));
+  set_actions ();
+
+  vbox1 = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (window), vbox1);
+
+  menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
+  toolbar = gtk_ui_manager_get_widget (manager, "/ToolBar");
+  gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1), toolbar, FALSE, FALSE, 0);
+  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
+  for (i = 0; i < 8; i++)
+    {
+      gtk_tool_item_set_expand (gtk_toolbar_get_nth_item
+				((GtkToolbar *) toolbar, i), TRUE);
+      gtk_tool_item_set_homogeneous (gtk_toolbar_get_nth_item
+				     ((GtkToolbar *) toolbar, i), FALSE);
+    }
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox, TRUE, TRUE, 0);
+
+  label = gtk_label_new (_("  "));
+  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+  gtk_widget_set_size_request (label, 17, 17);
+
+  for (*name = 0x41; *name < 0x41 + size; (*name)++)
+    {
+      label = gtk_label_new (name);
+      gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+      gtk_widget_set_size_request (label, -1, 17);
+      markup =
+	g_markup_printf_escaped ("<span foreground=\"red\">%s</span>", name);
+      gtk_label_set_markup_with_mnemonic ((GtkLabel *) label, markup);
+      g_free (markup);
+    }
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox, TRUE, TRUE, 0);
+
+  vbox3 = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox3, TRUE, TRUE, 0);
+
+  for (*name = 0x31; *name < 0x31 + size; (*name)++)
+    {
+      label = gtk_label_new (name);
+      gtk_box_pack_start (GTK_BOX (vbox3), label, TRUE, TRUE, 0);
+      gtk_widget_set_size_request (label, 17, -1);
+      markup =
+	g_markup_printf_escaped ("<span foreground=\"red\">%s</span>", name);
+      gtk_label_set_markup_with_mnemonic ((GtkLabel *) label, markup);
+      g_free (markup);
+    }
+
+  drawing_area = gtk_drawing_area_new ();
+  /* We do our own double-buffering. */
+  gtk_widget_set_double_buffered (drawing_area, FALSE);
+  gtk_widget_set_size_request (drawing_area, board_width, board_height);
+  gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
+  gtk_widget_set_events (drawing_area, GDK_BUTTON_PRESS_MASK);
+  g_signal_connect ((gpointer) drawing_area, "expose_event",
+		    G_CALLBACK (on_drawing_area_expose_event), NULL);
+  g_signal_connect ((gpointer) drawing_area, "configure_event",
+		    G_CALLBACK (on_drawing_area_configure_event), NULL);
+  g_signal_connect ((gpointer) drawing_area, "button_press_event",
+		    G_CALLBACK (signalfuncs[0]), NULL);
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
+
+  counter = gtk_label_new (_("00"));
+  gtk_box_pack_start (GTK_BOX (hbox), counter, TRUE, TRUE, 0);
+
+  for (i = 0; i < 2; i++)
+    for (j = 0; j < 2; j++)
+      {
+	label = gtk_label_new (strs[j]);
+	gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+	markup =
+	  g_markup_printf_escaped ("<span foreground=\"blue\">%s</span>",
+				   strs[j]);
+	gtk_label_set_markup_with_mnemonic ((GtkLabel *) label, markup);
+	g_free (markup);
+	score[i * 2 + j] = gtk_label_new (strs[i + 2]);
+	gtk_box_pack_start (GTK_BOX (hbox), score[i * 2 + j], TRUE, TRUE, 0);
+      }
+
+  hbox = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1), hbox, TRUE, FALSE, 0);
+
+  statusbar = gtk_statusbar_new ();
+  gtk_box_pack_start (GTK_BOX (hbox), statusbar, TRUE, TRUE, 0);
+  gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE);
+
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
+  gtk_widget_set_events (entry, GDK_KEY_PRESS_MASK);
+  g_signal_connect ((gpointer) entry, "key_press_event",
+		    G_CALLBACK (signalfuncs[1]), NULL);
+
+  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+  gtk_widget_show_all (window);
+  gtk_widget_grab_focus (entry);
+
+  set_sound ();
+  b_timer = g_timer_new ();
+  w_timer = g_timer_new ();
+  network_gui_update ();
+  return window;
+}
+
+/******* for properties dialog *******/
+
+static guint t_computer_level[2];
+static gboolean t_options[5];
+static gchar *t_tile_set;
+static gchar *t_bg_color_name;
+static guint max_depth;
+
+void
+load_properties (guint t_maxdepth)
+{
+  GConfClient *client;
+
+  client = gconf_client_get_default ();
+  max_depth = t_maxdepth;
+
+  if (tile_set)
+    g_free (tile_set);
+  if (bg_color_name)
+    g_free (bg_color_name);
+
+  black_computer_level = clamp_int (gconf_client_get_int (client,
+                            keys[0][gataxx], NULL), 0, max_depth - 1);
+  white_computer_level = clamp_int (gconf_client_get_int (client,
+                            keys[1][gataxx], NULL), 0, max_depth - 1);
+  animate         = gconf_client_get_bool   (client, keys[2][gataxx], NULL);
+  quick_moves     = gconf_client_get_bool   (client, keys[3][gataxx], NULL);
+  animate_stagger = gconf_client_get_bool   (client, keys[4][gataxx], NULL);
+  grid            = gconf_client_get_bool   (client, keys[5][gataxx], NULL);
+  flip_final      = gconf_client_get_bool   (client, keys[6][gataxx], NULL);
+  tile_set        = gconf_client_get_string (client, keys[7][gataxx], NULL);
+  bg_color_name   = gconf_client_get_string (client, keys[8][gataxx], NULL);
+  board_width     = gconf_client_get_int    (client, keys[9][gataxx], NULL);
+  board_height    = gconf_client_get_int    (client, keys[10][gataxx], NULL);
+
+  if (!bg_color_name)
+    bg_color_name = g_strdup (_("#000066660000"));
+  if (!board_width || !board_height)
+    board_width = board_height = BOARD_SIZE;
+
+  g_object_unref (client);
 }
 
-static gboolean
-quit_properties_dialog (GtkWidget * widget, gpointer data)
+void
+save_properties (void)
 {
-  save_properties ();
-  apply_changes ();
-  g_object_unref (tooltips);
-  tooltips = NULL;
-  gtk_widget_destroy (propbox);
-  propbox = NULL;
-  return FALSE;
+  GConfClient *client;
+
+  client = gconf_client_get_default ();
+
+  gconf_client_set_int    (client, keys[0][gataxx], black_computer_level, NULL);
+  gconf_client_set_int    (client, keys[1][gataxx], white_computer_level, NULL);
+  gconf_client_set_bool   (client, keys[2][gataxx], animate,              NULL);
+  gconf_client_set_bool   (client, keys[3][gataxx], quick_moves,          NULL);
+  gconf_client_set_bool   (client, keys[4][gataxx], animate_stagger,      NULL);
+  gconf_client_set_bool   (client, keys[5][gataxx], grid,                 NULL);
+  gconf_client_set_bool   (client, keys[6][gataxx], flip_final,           NULL);
+  gconf_client_set_string (client, keys[7][gataxx], tile_set,             NULL);
+  gconf_client_set_string (client, keys[8][gataxx], bg_color_name,        NULL);
+  gconf_client_set_int    (client, keys[9][gataxx], board_width,          NULL);
+  gconf_client_set_int    (client, keys[10][gataxx], board_height,        NULL);
+
+  g_object_unref (client);
 }
 
 void
-props_init (GtkWindow * window, char *title)
+reset_properties (void)
 {
-  mainwindow = window;
-  load_properties ();
+  if (t_tile_set)
+    g_free (t_tile_set);
+  if (t_bg_color_name)
+    g_free (t_bg_color_name);
+
+  t_computer_level[0] = black_computer_level;
+  t_computer_level[1] = white_computer_level;
+  t_options[0]        = animate;
+  t_options[1]        = quick_moves;
+  t_options[2]        = animate_stagger;
+  t_options[3]        = grid;
+  t_options[4]        = flip_final;
+  t_tile_set          = g_strdup (tile_set);
+  t_bg_color_name     = g_strdup (bg_color_name);
+  gdk_color_parse (t_bg_color_name, &bg_color[2]);
+  if (drawing_area)
+    gdk_colormap_alloc_color (gtk_widget_get_colormap (drawing_area),
+			      &bg_color[2], FALSE, TRUE);
 }
 
 void
-show_properties_dialog (void)
+apply_changes (void)
 {
-  GtkWidget *notebook;
-  GtkWidget *frame;
-  GtkWidget *label;
-  GtkWidget *table;
-  GtkWidget *button;
-  GtkWidget *vbox, *vbox2;
-  GtkWidget *hbox;
-  GtkWidget *menu;
+  if (bg_color_name)
+    g_free (bg_color_name);
+  if (tile_set)
+    g_free (tile_set);
+
+  black_computer_level = t_computer_level[0];
+  white_computer_level = t_computer_level[1];
+  animate              = t_options[0];
+  quick_moves          = t_options[1];
+  animate_stagger      = t_options[2];
+  grid                 = t_options[3];
+  flip_final           = t_options[4];
+  tile_set             = g_strdup (t_tile_set);
+  bg_color_name        = g_strdup (t_bg_color_name);
+  computer_speed       = COMPUTER_MOVE_DELAY;
+  flip_speed           = PIXMAP_FLIP_DELAY;
+  if (quick_moves)
+    {
+      computer_speed /= 2;
+      flip_speed /= 2;
+    }
+  set_flip_pixmaps_id ();
 
-  if (propbox != NULL) {
-    gtk_window_present (GTK_WINDOW (propbox));
-    return;
-  }
+  refresh_board ();
+}
 
-  /* create window */
-  propbox = gtk_dialog_new_with_buttons (_("Ataxx Preferences"),
-					 GTK_WINDOW (mainwindow),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_NO_SEPARATOR,
-					 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-					 NULL);
-
-  gtk_window_set_resizable (GTK_WINDOW (propbox), FALSE);
-  gtk_container_set_border_width (GTK_CONTAINER (propbox), 5);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (propbox)->vbox), 2);
-
-  g_signal_connect (G_OBJECT (propbox), "response",
-		    G_CALLBACK (quit_properties_dialog), &propbox);
-
-  g_signal_connect (G_OBJECT (propbox), "delete_event",
-		    G_CALLBACK (quit_properties_dialog), &propbox);
-
-  /* create tooltips */
-  tooltips = gtk_tooltips_new ();
-  g_object_ref (tooltips);
-  gtk_object_sink (GTK_OBJECT (tooltips));
+static void
+on_computer_level_changed (GtkToggleButton *togglebutton, gpointer user_data)
+{
+  if (togglebutton->active)
+    t_computer_level[GPOINTER_TO_INT (user_data) / 16] =
+      GPOINTER_TO_INT (user_data) % 16;
+}
 
-  /* create notebook (tabs) */
-  notebook = gtk_notebook_new ();
-  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
-  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (propbox)->vbox), notebook, TRUE,
-		      TRUE, 0);
-
-  /* Players tab */
-
-  label = gtk_label_new (_("Players"));
-
-  vbox = gtk_vbox_new (FALSE, 18);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
-  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
-
-  table = gtk_table_new (1, 2, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 18);
-  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
-
-  vbox2 = gtk_vbox_new (FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
-  button = gtk_check_button_new_with_mnemonic (_("_Quick moves"));
-  gtk_tooltips_set_tip (tooltips, button,
-			_
-			("Shortens the time a computer waits before doing a move"),
-			NULL);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-				props->quick_moves);
-  g_signal_connect (G_OBJECT (button), "toggled",
-		    G_CALLBACK (set_variable_cb), &(props->quick_moves));
-  gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
-
-
-  /* Dark level select */
-  frame = games_frame_new (_("Dark"));
-
-  vbox2 = gtk_vbox_new (FALSE, 6);
-
-  button = add_level (vbox2, NULL, _("Human"), 0, BLACK);
-  button = add_level (vbox2, button, _("Very easy"), 1, BLACK);
-  button = add_level (vbox2, button, Q_ ("gataxx|Easy"), 2, BLACK);
-  button = add_level (vbox2, button, Q_ ("gataxx|Medium"), 3, BLACK);
-  button = add_level (vbox2, button, _("Hard"), 4, BLACK);
-  button = add_level (vbox2, button, _("Very hard"), 5, BLACK);
-
-  gtk_container_add (GTK_CONTAINER (frame), vbox2);
-
-  gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1,
-		    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-
-  /* Light level select */
-  frame = games_frame_new (_("Light"));
-
-  vbox2 = gtk_vbox_new (FALSE, 6);
-
-  button = add_level (vbox2, NULL, _("Human"), 0, WHITE);
-  button = add_level (vbox2, button, _("Very easy"), 1, WHITE);
-  button = add_level (vbox2, button, _("Easy"), 2, WHITE);
-  button = add_level (vbox2, button, _("Medium"), 3, WHITE);
-  button = add_level (vbox2, button, _("Hard"), 4, WHITE);
-  button = add_level (vbox2, button, _("Very hard"), 5, WHITE);
-
-  gtk_container_add (GTK_CONTAINER (frame), (vbox2));
-
-  gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 1,
-		    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-
-  /* Appearance tab */
-  label = gtk_label_new (_("Appearance"));
-  vbox = gtk_vbox_new (FALSE, 6);
-
-  frame = games_frame_new (_("Appearance"));
-  gtk_container_add (GTK_CONTAINER (frame), vbox);
-  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
-  gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
-
-  /* animation button */
-  button = gtk_check_button_new_with_mnemonic (_("_Animation"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), props->animate);
-  g_signal_connect (G_OBJECT (button), "toggled",
-		    G_CALLBACK (set_variable_cb), &(props->animate));
-  gtk_tooltips_set_tip (tooltips, button,
-			_("Flip the pieces with some visual effects"), NULL);
-  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-
-  /*  theme select */
-  hbox = gtk_hbox_new (FALSE, 12);
-  label = gtk_label_new_with_mnemonic (_("_Tile set:"));
-  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-  menu = fill_theme_menu ();
-  g_signal_connect (G_OBJECT (menu), "changed",
-		    G_CALLBACK (set_selection), NULL);
-  gtk_tooltips_set_tip (tooltips, menu, _("The appearance of the pieces"),
-			NULL);
-  gtk_box_pack_start (GTK_BOX (hbox), menu, TRUE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
+static void
+on_options_toggled (GtkToggleButton *togglebutton, gpointer user_data)
+{
+  t_options[GPOINTER_TO_INT (user_data)] = togglebutton->active;
+}
 
-  /* end of appearance tab */
-  gtk_widget_show_all (propbox);
+static void
+on_tile_set_box_changed (GtkComboBox *combobox, gpointer user_data)
+{
+  if (t_tile_set)
+    g_free (t_tile_set);
+  t_tile_set = gtk_combo_box_get_active_text (combobox);
+}
 
+static void
+on_color_button_color_set (GtkColorButton *colorbutton, gpointer user_data)
+{
+  gtk_color_button_get_color (colorbutton, &bg_color[2]);
+  if (t_bg_color_name)
+    g_free (t_bg_color_name);
+  t_bg_color_name = g_strdup_printf ("#%04X%04X%04X",
+				     bg_color[2].red, bg_color[2].green,
+				     bg_color[2].blue);
 }
 
-/* FIXME rewrite this to clear the whole struct */
-void
-reload_properties (void)
+static void
+on_apply_button_clicked (GtkButton *button, gpointer user_data)
 {
-  g_free (props->theme);
-  props->theme = NULL;
-  load_properties ();
   apply_changes ();
+  save_properties ();
+}
+
+static void
+on_properties_cancel_clicked (GtkButton *button, gpointer user_data)
+{
+  reset_properties ();
+  gtk_widget_destroy (properties_dialog);
+  properties_dialog = NULL;
+}
+
+static void
+on_ok_button_clicked (GtkButton *button, gpointer user_data)
+{
+  apply_changes ();
+  save_properties ();
+  gtk_widget_destroy (properties_dialog);
+  properties_dialog = NULL;
+}
+
+GtkWidget *
+create_properties_dialog (void)
+{
+  const gchar *strs[] = {
+    N_("Human"),		/* 0 */
+    N_("Level "),		/* 1 */
+    N_("Dark"),			/* 2 */
+    N_("Light"),		/* 3 */
+    N_("A_nimation"),		/* 4 */
+    N_("Use _Quick moves"),	/* 5 */
+    N_("_Stagger flips"),	/* 6 */
+    N_("Show _Grid"),		/* 7 */
+    N_("_Flip final results"),	/* 8 */
+    N_("Tile set:"),		/* 9 */
+    N_("Background color:"),	/* 10 */
+    N_("Options"),		/* 11 */
+    N_("Players"),		/* 12 */
+    N_("Appearance"),		/* 13 */
+    N_("Iagno Preferences"),	/* 14 */
+    N_("Gataxx Preferences"),	/* 15 */
+    _("gtk-apply"),		/* 16 */
+    _("gtk-cancel"),		/* 17 */
+    _("gtk-ok"),		/* 18 */
+    _("coin.svg"),		/* 19 */
+    _("marble.svg"),		/* 20 */
+    _("sun_and_star.svg")	/* 21 */
+  };
+
+  const GtkSignalFunc *signalfunc[3] = {
+    (GtkSignalFunc *) on_apply_button_clicked,
+    (GtkSignalFunc *) on_properties_cancel_clicked,
+    (GtkSignalFunc *) on_ok_button_clicked
+  };
+
+  GtkWidget *properties_dialog;
+  GtkWidget *dialog_vbox;
+  GtkWidget *notebook;
+  GtkWidget *hbox;
+  GtkWidget *frame;
+  GtkWidget *alignment;
+  GtkWidget *vbox;
+  GtkWidget *button;
+  GtkWidget *label;
+  GSList *human_group[2] = { NULL, NULL };
+  GtkWidget *table;
+  GtkWidget *tile_set_box;
+  GtkWidget *color_button;
+  GtkWidget *dialog_action_area;
+  GString *string;
+
+  gint n, f, v;
+
+  properties_dialog = gtk_dialog_new ();
+  gtk_window_set_title (GTK_WINDOW (properties_dialog), strs[gataxx + 14]);
+  gtk_window_set_resizable (GTK_WINDOW (properties_dialog), FALSE);
+  gtk_window_set_type_hint (GTK_WINDOW (properties_dialog),
+			    GDK_WINDOW_TYPE_HINT_DIALOG);
+
+  dialog_vbox = GTK_DIALOG (properties_dialog)->vbox;
+
+  notebook = gtk_notebook_new ();
+  gtk_box_pack_start (GTK_BOX (dialog_vbox), notebook, TRUE, TRUE, 0);
+
+  for (n = 0; n < 2; n++)
+    {
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (notebook), hbox);
+
+      if (n == 0)
+	{
+	  for (f = 0; f < 2; f++)
+	    {
+	      frame = gtk_frame_new (NULL);
+	      gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+	      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+
+	      alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
+	      gtk_container_add (GTK_CONTAINER (frame), alignment);
+	      gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12,
+					 0);
+
+	      vbox = gtk_vbox_new (FALSE, 0);
+	      gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+	      for (v = 0; v < max_depth; v++)
+		{
+		  if (!v)
+		    button =
+		      gtk_radio_button_new_with_mnemonic (NULL, strs[0]);
+		  else
+		    {
+		      string = g_string_new (strs[1]);
+		      g_string_append_printf (string, "%d", v);
+		      button =
+			gtk_radio_button_new_with_mnemonic (NULL,
+							    string->str);
+		      g_string_free (string, TRUE);
+		    }
+		  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE,
+				      0);
+		  gtk_radio_button_set_group (GTK_RADIO_BUTTON (button),
+					      human_group[f]);
+		  human_group[f] =
+		    gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
+		  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+						(t_computer_level[f] == v));
+		  g_signal_connect ((gpointer) button, "toggled",
+				    G_CALLBACK (on_computer_level_changed),
+				    GINT_TO_POINTER (f * 16 + v));
+		}
+
+	      label = gtk_label_new (strs[f + 2]);
+	      gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+	      gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+	    }
+	}
+      else
+	{
+	  for (f = 0; f < 2; f++)
+	    {
+	      frame = gtk_frame_new (NULL);
+	      gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+	      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+
+	      alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
+	      gtk_container_add (GTK_CONTAINER (frame), alignment);
+	      gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12,
+					 0);
+
+	      vbox = gtk_vbox_new (FALSE, 0);
+	      gtk_container_add (GTK_CONTAINER (alignment), vbox);
+	      if (f == 0)
+		{
+		  for (v = 0; v < 5; v++)
+		    {
+		      button =
+			gtk_check_button_new_with_mnemonic (strs[v + 4]);
+		      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE,
+					  FALSE, 0);
+		      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+						    (button), t_options[v]);
+		      g_signal_connect ((gpointer) button, "toggled",
+					G_CALLBACK (on_options_toggled),
+					GINT_TO_POINTER (v));
+		    }
+		}
+	      else
+		{
+		  table = gtk_table_new (2, 2, FALSE);
+		  gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
+
+		  for (v = 0; v < 2; v++)
+		    {
+		      label = gtk_label_new (strs[v + 9]);
+		      gtk_table_attach (GTK_TABLE (table), label, 0, 1, v,
+					v + 1, (GtkAttachOptions) (0),
+					(GtkAttachOptions) (0), 0, 0);
+		      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+		    }
+
+		  tile_set_box = gtk_combo_box_new_text ();
+		  gtk_table_attach (GTK_TABLE (table), tile_set_box, 1, 2, 0,
+				    1, (GtkAttachOptions) (0),
+				    (GtkAttachOptions) (0), 0, 0);
+		  for (v = 0; v < 3; v++)
+		    {
+		      gtk_combo_box_append_text (GTK_COMBO_BOX (tile_set_box),
+						 strs[v + 19]);
+		      if (g_str_equal (t_tile_set, strs[v + 19]))
+			gtk_combo_box_set_active (GTK_COMBO_BOX
+						  (tile_set_box), v);
+		    }
+		  g_signal_connect ((gpointer) tile_set_box, "changed",
+				    G_CALLBACK (on_tile_set_box_changed),
+				    NULL);
+
+		  color_button = gtk_color_button_new ();
+		  gtk_table_attach (GTK_TABLE (table), color_button, 1, 2, 1,
+				    2, (GtkAttachOptions) (0),
+				    (GtkAttachOptions) (0), 0, 0);
+		  gtk_color_button_set_color ((GtkColorButton *) color_button,
+					      &bg_color[2]);
+		  g_signal_connect ((gpointer) color_button, "color_set",
+				    G_CALLBACK (on_color_button_color_set),
+				    NULL);
+		}
+	      label = gtk_label_new (strs[11]);
+	      gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+	      gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+	    }
+	}
+      label = gtk_label_new (strs[n + 12]);
+      gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook),
+				  gtk_notebook_get_nth_page (GTK_NOTEBOOK
+							     (notebook), n),
+				  label);
+    }
+
+  dialog_action_area = GTK_DIALOG (properties_dialog)->action_area;
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area),
+			     GTK_BUTTONBOX_END);
+
+  for (n = 0; n < 3; n++)
+    {
+      button = gtk_button_new_from_stock (strs[n + 16]);
+      gtk_dialog_add_action_widget (GTK_DIALOG (properties_dialog),
+				    button, GTK_RESPONSE_APPLY);
+      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+      g_signal_connect ((gpointer) button, "clicked",
+			G_CALLBACK (signalfunc[n]), NULL);
+    };
+
+  gtk_widget_show_all (properties_dialog);
+  return properties_dialog;
+}
+
+/******* for file save dialog *******/
+
+GtkWidget *
+create_file_save_dialog (GtkSignalFunc *callback)
+{
+  GtkWidget *file_save_dialog;
+  GtkWidget *dialog_vbox;
+  GtkWidget *dialog_action_area;
+  GtkWidget *save_cancel;
+  GtkWidget *save;
+
+  file_save_dialog =
+    gtk_file_chooser_dialog_new ("", (GtkWindow *) window,
+				 GTK_FILE_CHOOSER_ACTION_SAVE, NULL);
+  gtk_window_set_type_hint (GTK_WINDOW (file_save_dialog),
+			    GDK_WINDOW_TYPE_HINT_DIALOG);
+  g_signal_connect ((gpointer) file_save_dialog, "destroy",
+		    G_CALLBACK (gtk_widget_destroy), NULL);
+
+  dialog_vbox = GTK_DIALOG (file_save_dialog)->vbox;
+
+  dialog_action_area = GTK_DIALOG (file_save_dialog)->action_area;
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area),
+			     GTK_BUTTONBOX_END);
+
+  save_cancel = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_dialog_add_action_widget (GTK_DIALOG (file_save_dialog),
+				save_cancel, GTK_RESPONSE_CANCEL);
+  GTK_WIDGET_SET_FLAGS (save_cancel, GTK_CAN_DEFAULT);
+  g_signal_connect_swapped ((gpointer) save_cancel, "clicked",
+			    G_CALLBACK (gtk_widget_destroy),
+			    (gpointer) file_save_dialog);
+
+  save = gtk_button_new_from_stock ("gtk-save");
+  gtk_dialog_add_action_widget (GTK_DIALOG (file_save_dialog), save,
+				GTK_RESPONSE_OK);
+  GTK_WIDGET_SET_FLAGS (save, GTK_CAN_DEFAULT);
+  g_signal_connect ((gpointer) save, "clicked",
+		    G_CALLBACK (callback), NULL);
+
+  gtk_widget_show_all (file_save_dialog);
+  gtk_widget_grab_default (save);
+  return file_save_dialog;
+}
+
+/******* for file open dialog *******/
+
+GtkWidget *
+create_file_open_dialog (GtkSignalFunc *callback)
+{
+  GtkWidget *file_open_dialog;
+  GtkWidget *dialog_vbox;
+  GtkWidget *dialog_action_area;
+  GtkWidget *open_cancel;
+  GtkWidget *open;
+
+  file_open_dialog =
+    gtk_file_chooser_dialog_new ("", (GtkWindow *) window,
+				 GTK_FILE_CHOOSER_ACTION_OPEN, NULL);
+  gtk_window_set_type_hint (GTK_WINDOW (file_open_dialog),
+			    GDK_WINDOW_TYPE_HINT_DIALOG);
+  g_signal_connect ((gpointer) file_open_dialog, "destroy",
+		    G_CALLBACK (gtk_widget_destroy), NULL);
+
+  dialog_vbox = GTK_DIALOG (file_open_dialog)->vbox;
+
+  dialog_action_area = GTK_DIALOG (file_open_dialog)->action_area;
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area),
+			     GTK_BUTTONBOX_END);
+
+  open_cancel = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_dialog_add_action_widget (GTK_DIALOG (file_open_dialog),
+				open_cancel, GTK_RESPONSE_CANCEL);
+  GTK_WIDGET_SET_FLAGS (open_cancel, GTK_CAN_DEFAULT);
+  g_signal_connect_swapped ((gpointer) open_cancel, "clicked",
+			    G_CALLBACK (gtk_widget_destroy),
+			    (gpointer) file_open_dialog);
+
+  open = gtk_button_new_from_stock ("gtk-open");
+  gtk_dialog_add_action_widget (GTK_DIALOG (file_open_dialog), open,
+				GTK_RESPONSE_OK);
+  GTK_WIDGET_SET_FLAGS (open, GTK_CAN_DEFAULT);
+  g_signal_connect ((gpointer) open, "clicked",
+		    G_CALLBACK (callback), NULL);
+
+  gtk_widget_show_all (file_open_dialog);
+  gtk_widget_grab_default (open);
+  return file_open_dialog;
 }
Index: gnome-games/gataxx/properties.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gataxx/properties.h,v
retrieving revision 1.8
diff -u -r1.8 properties.h
--- gnome-games/gataxx/properties.h	3 Oct 2006 20:57:24 -0000	1.8
+++ gnome-games/gataxx/properties.h	5 Oct 2006 12:15:08 -0000
@@ -1,6 +1,6 @@
-/* (C) 2003/2004 Sjoerd Langkemper
- * properties.h - 
- * 
+/*
+ * properties.h
+ *
  * 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
@@ -13,29 +13,70 @@
  *
  * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * For more details see the file COPYING.
  */
 
-#ifndef _PROPERTIES_H_
-#define _PROPERTIES_H_
+#define BOARD_SIZE    519
+#define BOARD_MIN     279
+#define BOARD_W_MAX  1214
+#define BOARD_H_MAX   799
+#define GRIDWIDTH       1
+
+#define PIXMAP_FLIP_DELAY      30
+#define PIXMAP_STAGGER_DELAY    3
+#define COMPUTER_MOVE_DELAY  1000
+
+#define MAX_ACTION_NUMBER      23
+
+gint clamp_int (gint input, gint low, gint high);
+
+void gui_status (void);
+
+void redraw_board (void);
+
+void refresh_board (void);
+
+void gui_timer (void);
+
+void timer_start (void);
+
+void gui_message (gchar *message);
+
+void gui_entry (gchar *message);
+
+gboolean flip_final_results (gpointer data);
+
+void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data);
+
+void on_properties_activate (GtkMenuItem *menuitem, gpointer user_data);
+
+void on_minimum_board_activate (GtkMenuItem *menuitem, gpointer user_data);
+
+gboolean
+on_drawing_area_expose_event (GtkWidget *widget,
+			      GdkEventExpose *event, gpointer user_data);
+                              
+gboolean
+on_drawing_area_configure_event (GtkWidget *widget,
+				 GdkEventConfigure *event, gpointer user_data);
+
+GtkWidget *
+create_window (guint t_gataxx,
+                GCallback **callbacks, GtkSignalFunc **signalfuncs);
+
+
+void load_properties (guint t_maxdepth);
+
+void save_properties (void);
+
+void reset_properties (void);
+
+void apply_changes (void);
 
-#include <glib.h>
+GtkWidget* create_properties_dialog (void);
 
-void load_properties (void);
-void reload_properties (void);
-void show_properties_dialog (void);
-int props_get_level (int piece);
-int props_get_white_level (void);
-int props_get_black_level (void);
-void load_properties (void);
-void show_properties_dialog (void);
-void reload_properties (void);
-gboolean props_get_animate (void);
-gboolean props_get_quick_moves (void);
-gchar *props_get_theme (void);
-int props_is_human (int piece);
-void props_init (GtkWindow * window, char *title);
+GtkWidget* create_file_save_dialog (GtkSignalFunc *callback);
 
-#endif
+GtkWidget* create_file_open_dialog (GtkSignalFunc *callback);
