gcompris r3284 - in branches/gcomprixo/src: chess_computer-activity gcompris
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3284 - in branches/gcomprixo/src: chess_computer-activity gcompris
- Date: Sun, 9 Mar 2008 23:31:22 +0000 (GMT)
Author: bcoudoin
Date: Sun Mar 9 23:31:21 2008
New Revision: 3284
URL: http://svn.gnome.org/viewvc/gcompris?rev=3284&view=rev
Log:
Made the chess activity to search for gnuchess in usual
directory if it is not found in the one detected at compilation
time. It is done to accomodate cases were the run time and build
time have a different gnuchess package.
Modified:
branches/gcomprixo/src/chess_computer-activity/chess.c
branches/gcomprixo/src/gcompris/gcompris.c
Modified: branches/gcomprixo/src/chess_computer-activity/chess.c
==============================================================================
--- branches/gcomprixo/src/chess_computer-activity/chess.c (original)
+++ branches/gcomprixo/src/chess_computer-activity/chess.c Sun Mar 9 23:31:21 2008
@@ -122,6 +122,21 @@
char *format,
...);
+/* The first choice is the one detected at compilation time
+ * In case our binary is run on other systems, we do our best
+ * to use it from usual locations
+ */
+static gchar *gnuchess_path[] =
+ {
+ GNUCHESS,
+ "/usr/bin/gnuchess",
+ "/usr/games/gnuchess",
+ "/usr/local/bin/gnuchess",
+ "bin/gnuchess",
+ "gnuchess",
+ "gnuchess.exe",
+ NULL
+ };
/* Description of this plugin */
static BoardPlugin menu_bp =
@@ -185,27 +200,42 @@
{
gnuchess_pid = 0;
- gchar *gnuchess_bin = GNUCHESS;
+ gchar **gnuchess_pathptr = gnuchess_path;
+ gchar *gnuchess_bin = NULL;
-#ifndef WIN32
- signal(SIGTRAP, gnuchess_died);
- signal(SIGPIPE, gnuchess_died);
- if (!g_file_test (gnuchess_bin, G_FILE_TEST_EXISTS))
+
+ do
{
- /* check in same bin/ as we are */
- extern gchar *exec_prefix;
- gnuchess_bin = g_build_filename( exec_prefix, "bin", "gnuchess", NULL);
- if (!g_file_test (gnuchess_bin, G_FILE_TEST_EXISTS)) {
- gc_dialog(_("Error: The external program gnuchess is required\nto play chess in GCompris.\n"
- "Find this program on http://www.rpmfind.net or in your\nGNU/Linux distribution\n"
- "And check it is located here: "GNUCHESS),
- gc_board_stop);
- return;
- }
- }
+ if(*gnuchess_pathptr[0] == '/')
+ {
+ gnuchess_bin = strdup(*gnuchess_pathptr);
+ }
+ else
+ {
+ /* Check in our exec prefix */
+ extern gchar *exec_prefix;
+ gnuchess_bin = g_build_filename(exec_prefix, *gnuchess_pathptr,
+ NULL);
+ }
+
+ if (g_file_test (gnuchess_bin, G_FILE_TEST_IS_EXECUTABLE))
+ break;
+ gnuchess_pathptr++;
+ } while(*gnuchess_pathptr != NULL);
+
+ if(*gnuchess_pathptr == NULL)
+ {
+ gc_dialog(_("Error: The external program gnuchess is mandatory\n"
+ "to play chess in gcompris.\n"
+ "First install it, and check it is in "GNUCHESS), gc_board_stop);
+ return;
+ }
+
+ signal(SIGTRAP, gnuchess_died);
+ signal(SIGPIPE, gnuchess_died);
g_warning("GNUCHESS found %s", gnuchess_bin);
-#endif
+
if(agcomprisBoard!=NULL)
{
@@ -266,6 +296,8 @@
pause_board(FALSE);
}
+
+ g_free(gnuchess_bin);
}
/* ======================================= */
Modified: branches/gcomprixo/src/gcompris/gcompris.c
==============================================================================
--- branches/gcomprixo/src/gcompris/gcompris.c (original)
+++ branches/gcomprixo/src/gcompris/gcompris.c Sun Mar 9 23:31:21 2008
@@ -1066,6 +1066,14 @@
else
g_warning("Binary relocation disabled");
+ /* usefull for OSX bundle app */
+#ifdef NSBUNDLE
+ exec_prefix = gcompris_nsbundle_resource ();
+#else
+ exec_prefix = gbr_find_exe_dir("");
+#endif
+ g_warning("exec_prefix %s\n", exec_prefix);
+
prefix_dir = gbr_find_prefix(NULL);
g_warning("prefix_dir=%s\n", prefix_dir);
@@ -1287,15 +1295,6 @@
GError *error = NULL;
GOptionContext *context;
- /* usefull for OSX bundle app */
-#ifdef NSBUNDLE
- exec_prefix = gcompris_nsbundle_resource ();
- printf("exec_prefix %s\n", exec_prefix);
-#else
- exec_prefix = NULL;
- printf("exec_prefix NULL\n");
-#endif
-
/* First, Remove the gnome crash dialog because it locks the user when in full screen */
signal(SIGSEGV, gc_terminate);
signal(SIGINT, gc_terminate);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]