[gnome-games] libgames-support: Add GAMES_RUNTIME_PREFIX



commit 038d94380e906b653312f00aed22cc54ae7444eb
Author: Christian Persch <chpe gnome org>
Date:   Sun Sep 5 13:56:37 2010 +0200

    libgames-support: Add GAMES_RUNTIME_PREFIX

 aisleriot/lib/ar-card-theme-fixed.c |    4 +++-
 libgames-support/Makefile.am        |    1 +
 libgames-support/games-runtime.c    |   21 ++++++++++++++++++---
 libgames-support/games-runtime.h    |    7 +++----
 4 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/aisleriot/lib/ar-card-theme-fixed.c b/aisleriot/lib/ar-card-theme-fixed.c
index e05983b..2d5a6b8 100644
--- a/aisleriot/lib/ar-card-theme-fixed.c
+++ b/aisleriot/lib/ar-card-theme-fixed.c
@@ -339,7 +339,9 @@ ar_card_theme_fixed_class_foreach_theme_dir (ArCardThemeClass *klass,
   if (!_ar_card_theme_class_foreach_env (klass, "AR_CARD_THEME_PATH_FIXED", callback, data))
     return FALSE;
 
-  return callback (klass, games_runtime_get_directory (GAMES_RUNTIME_PRERENDERED_CARDS_DIRECTORY), data);
+  if (!callback (klass, games_runtime_get_directory (GAMES_RUNTIME_PRERENDERED_CARDS_DIRECTORY), data))
+    return FALSE;
+  return FALSE;
 }
 
 static void
diff --git a/libgames-support/Makefile.am b/libgames-support/Makefile.am
index 65647d4..c834dd9 100644
--- a/libgames-support/Makefile.am
+++ b/libgames-support/Makefile.am
@@ -93,6 +93,7 @@ endif # LIBGAMES_SUPPORT_FULL
 
 libgames_support_la_CPPFLAGS = \
 	-DPKGDATADIR="\"$(pkgdatadir)\""			\
+	-DPREFIX="\"$(prefix)\"" \
 	-DDATADIR="\"$(datadir)\""				\
 	-DCOMMON_DATADIR="\"$(datadir)/gnome-games-common\""	\
 	-DSCORESDIR="\"$(scoredir)\""				\
diff --git a/libgames-support/games-runtime.c b/libgames-support/games-runtime.c
index 8218f86..16a65e9 100644
--- a/libgames-support/games-runtime.c
+++ b/libgames-support/games-runtime.c
@@ -230,7 +230,7 @@ typedef struct {
 static const DerivedDirectory derived_directories[] = {
   /* Keep this in the same order as in the GamesRuntimeDirectory enum! */
 #ifdef ENABLE_BINRELOC
-  { GAMES_RUNTIME_MODULE_DIRECTORY,   "share"              }, /* GAMES_RUNTIME_DATA_DIRECTORY              */
+  { GAMES_RUNTIME_PREFIX,             "share"              }, /* GAMES_RUNTIME_DATA_DIRECTORY              */
   { GAMES_RUNTIME_DATA_DIRECTORY,     "gnome-games-common" }, /* GAMES_RUNTIME_COMMON_DATA_DIRECTORY       */
   { GAMES_RUNTIME_DATA_DIRECTORY,     "gnome-games"        }, /* GAMES_RUNTIME_PKG_DATA_DIRECTORY          */
   { GAMES_RUNTIME_DATA_DIRECTORY,     "scores"             }, /* GAMES_RUNTIME_SCORES_DIRECTORY            */
@@ -374,7 +374,7 @@ games_runtime_init (const char *name)
   const char *path;
 
   /* Now check that we can get the module installation directory */
-  path = games_runtime_get_directory (GAMES_RUNTIME_MODULE_DIRECTORY);
+  path = games_runtime_get_directory (GAMES_RUNTIME_PREFIX);
 
   _games_debug_print (GAMES_DEBUG_RUNTIME,
                       "Relocation path: %s\n", path ? path : "(null)");
@@ -492,7 +492,7 @@ games_runtime_get_directory (GamesRuntimeDirectory directory)
 
   switch ((int) directory) {
 #ifdef ENABLE_BINRELOC
-    case GAMES_RUNTIME_MODULE_DIRECTORY:
+    case GAMES_RUNTIME_PREFIX:
 #ifdef G_OS_WIN32
       path = g_win32_get_package_installation_directory_of_module (NULL);
 #else
@@ -526,6 +526,10 @@ games_runtime_get_directory (GamesRuntimeDirectory directory)
       break;
 #else /* !ENABLE_BINRELOC */
 
+    case GAMES_RUNTIME_PREFIX:
+      path = g_strdup (PREFIX);
+      break;
+
     case GAMES_RUNTIME_DATA_DIRECTORY:
       path = g_strdup (DATADIR);
       break;
@@ -590,3 +594,14 @@ games_runtime_get_gpl_version (void)
 {
   return gpl_version;
 }
+
+/**
+ * games_runtime_is_system_prefix:
+ *
+ * Returns: whether the runtime prefix is "/usr".
+ */
+gboolean
+games_runtime_is_system_prefix (void)
+{
+  return strcmp (games_runtime_get_directory (GAMES_RUNTIME_PREFIX), "/usr") == 0;
+}
diff --git a/libgames-support/games-runtime.h b/libgames-support/games-runtime.h
index 23fd30e..228966e 100644
--- a/libgames-support/games-runtime.h
+++ b/libgames-support/games-runtime.h
@@ -29,10 +29,7 @@ G_BEGIN_DECLS
 
 typedef enum {
   /* Base directories */
-#ifdef ENABLE_BINRELOC
-  GAMES_RUNTIME_MODULE_DIRECTORY,
-#endif
-
+  GAMES_RUNTIME_PREFIX,
   GAMES_RUNTIME_DATA_DIRECTORY,
   GAMES_RUNTIME_COMMON_DATA_DIRECTORY,
   GAMES_RUNTIME_PKG_DATA_DIRECTORY,
@@ -84,6 +81,8 @@ char * games_runtime_get_file (GamesRuntimeDirectory directory,
 
 int games_runtime_get_gpl_version (void);
 
+gboolean games_runtime_is_system_prefix (void);
+
 G_END_DECLS
 
 #endif /* !GAMES_RUNTIME_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]